本文整理汇总了PHP中Vtiger_Relation_Model类的典型用法代码示例。如果您正苦于以下问题:PHP Vtiger_Relation_Model类的具体用法?PHP Vtiger_Relation_Model怎么用?PHP Vtiger_Relation_Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Vtiger_Relation_Model类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setRelatedList
/**
* Set related list information between other module
* @param Vtiger_Module Instance of target module with which relation should be setup
* @param String Label to display in related list (default is target module name)
* @param Array List of action button to show ('ADD', 'SELECT')
* @param String Callback function name of this module to use as handler
*
* @internal Creates table vtiger_crmentityrel if it does not exists
*/
function setRelatedList($moduleInstance, $label = '', $actions = false, $functionName = 'get_related_list')
{
$adb = PearDatabase::getInstance();
if (empty($moduleInstance)) {
return;
}
if (empty($label)) {
$label = $moduleInstance->name;
}
$result = $adb->pquery('SELECT relation_id FROM vtiger_relatedlists WHERE tabid=? AND related_tabid = ? AND name = ? AND label = ?;', [$this->id, $moduleInstance->id, $functionName, $label]);
if ($result->rowCount() > 0) {
self::log("Setting relation with {$moduleInstance->name} [{$useactions_text}] ... Error, the related module already exists");
return;
}
$sequence = $this->__getNextRelatedListSequence();
$presence = 0;
// 0 - Enabled, 1 - Disabled
// Allow ADD action of other module records (default)
if ($actions === false) {
$actions = ['ADD'];
}
$useactionsText = $actions;
if (is_array($actions)) {
$useactionsText = implode(',', $actions);
}
$useactionsText = strtoupper($useactionsText);
$adb->insert('vtiger_relatedlists', ['relation_id' => $adb->getUniqueID('vtiger_relatedlists'), 'tabid' => $this->id, 'related_tabid' => $moduleInstance->id, 'name' => $functionName, 'sequence' => $sequence, 'label' => $label, 'presence' => $presence, 'actions' => $useactionsText]);
if ($functionName == 'get_many_to_many') {
$refTableName = Vtiger_Relation_Model::getReferenceTableInfo($moduleInstance->name, $this->name);
if (!Vtiger_Utils::CheckTable($refTableName['table'])) {
Vtiger_Utils::CreateTable($refTableName['table'], '(crmid INT(19) ,relcrmid INT(19),KEY crmid (crmid),KEY relcrmid (relcrmid))', true);
}
}
self::log("Setting relation with {$moduleInstance->name} [{$useactions_text}] ... DONE");
}
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:44,代码来源:Module.php
示例2: getPopupViewFieldsList
/**
* Funtion that returns fields that will be showed in the record selection popup
* @return <Array of fields>
*/
public function getPopupViewFieldsList($sourceModule = false)
{
if (!empty($sourceModule)) {
$parentRecordModel = Vtiger_Module_Model::getInstance($sourceModule);
$relationModel = Vtiger_Relation_Model::getInstance($parentRecordModel, $this);
}
$popupFields = array();
if ($relationModel) {
$popupFields = $relationModel->getRelationFields(true);
}
if (count($popupFields) == 0) {
$popupFileds = $this->getSummaryViewFieldsList();
foreach ($popupFileds as $fieldName => $fieldModel) {
if ($fieldName === 'folderid' || $fieldName === 'modifiedtime') {
unset($popupFileds[$fieldName]);
}
}
$reqPopUpFields = array('File Status' => 'filestatus', 'File Size' => 'filesize', 'File Location Type' => 'filelocationtype');
foreach ($reqPopUpFields as $fieldLabel => $fieldName) {
$fieldModel = Vtiger_Field_Model::getInstance($fieldName, $this);
if ($fieldModel->getPermissions('readwrite')) {
$popupFileds[$fieldName] = $fieldModel;
}
}
$popupFields = array_keys($popupFileds);
}
return $popupFields;
}
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:32,代码来源:Module.php
示例3: getRelatedModuleRecordIds
public function getRelatedModuleRecordIds(Vtiger_Request $request, $recordIds = [])
{
$db = PearDatabase::getInstance();
$basicModule = $request->getModule();
$relatedModules = $request->get('related_modules');
$parentModuleModel = Vtiger_Module_Model::getInstance($basicModule);
$relatedIds = [];
if (!empty($relatedModules)) {
foreach ($relatedModules as $relModData) {
$relModData = explode('::', $relModData);
$relatedModule = $relModData[0];
$type = $relModData[1];
switch ($type) {
case 0:
$field = $relModData[2];
foreach ($recordIds as $recordId) {
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $basicModule);
if ($recordModel->get($field) != 0 && Vtiger_Functions::getCRMRecordType($recordModel->get($field)) == $relatedModule) {
$relatedIds[] = $recordModel->get($field);
}
}
break;
case 1:
$relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModule);
$instance = CRMEntity::getInstance($relatedModule);
$relationModel = Vtiger_Relation_Model::getInstance($parentModuleModel, $relatedModuleModel);
$fieldModel = $relationModel->getRelationField();
$tablename = $fieldModel->get('table');
$tabIndex = $instance->table_index;
$relIndex = $this->getRelatedFieldName($relatedModule, $basicModule);
if (!$relIndex) {
break;
}
$sql = "SELECT vtiger_crmentity.crmid FROM vtiger_crmentity INNER JOIN {$tablename} ON {$tablename}.{$tabIndex} = vtiger_crmentity.crmid\n\t\t\t\t\t\tWHERE {$tablename}.{$relIndex} IN (" . $db->generateQuestionMarks($recordIds) . ")";
$result = $db->pquery($sql, $recordIds);
while ($crmid = $db->getSingleValue($result)) {
$relatedIds[] = $crmid;
}
break;
case 2:
foreach ($recordIds as $recordId) {
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $basicModule);
$relationListView = Vtiger_RelationListView_Model::getInstance($recordModel, $relatedModule);
$query = $relationListView->getRelationQuery();
$queryEx = explode('FROM', $query, 2);
$query = 'SELECT DISTINCT vtiger_crmentity.crmid FROM' . $queryEx[1];
$result = $db->query($query);
while ($crmid = $db->getSingleValue($result)) {
$relatedIds[] = $crmid;
}
}
break;
}
$relatedIds = array_unique($relatedIds);
}
}
return $relatedIds;
}
开发者ID:awflu,项目名称:YetiForceCRM,代码行数:58,代码来源:TransferOwnership.php
示例4: saveRecord
/**
* Function to save record
* @param <Vtiger_Request> $request - values of the record
* @return <RecordModel> - record Model of saved record
*/
public function saveRecord($request)
{
$adb = PearDatabase::getInstance();
$recordModel = $this->getRecordModelFromRequest($request);
$recordModel->save();
$originalRecordId = $recordModel->getId();
if ($request->get('relationOperation')) {
$parentModuleName = $request->get('sourceModule');
$parentModuleModel = Vtiger_Module_Model::getInstance($parentModuleName);
$parentRecordId = $request->get('sourceRecord');
$relatedModule = $recordModel->getModule();
if ($relatedModule->getName() == 'Events') {
$relatedModule = Vtiger_Module_Model::getInstance('Calendar');
}
$relatedRecordId = $recordModel->getId();
$relationModel = Vtiger_Relation_Model::getInstance($parentModuleModel, $relatedModule);
$relationModel->addRelation($parentRecordId, $relatedRecordId);
}
// Handled to save follow up event
$followupMode = $request->get('followup');
//Start Date and Time values
$startTime = Vtiger_Time_UIType::getTimeValueWithSeconds($request->get('followup_time_start'));
$startDateTime = Vtiger_Datetime_UIType::getDBDateTimeValue($request->get('followup_date_start') . " " . $startTime);
list($startDate, $startTime) = explode(' ', $startDateTime);
$subject = $request->get('subject');
if ($followupMode == 'on' && $startTime != '' && $startDate != '') {
$recordModel->set('eventstatus', 'Planned');
$recordModel->set('subject', '[Followup] ' . $subject);
$recordModel->set('date_start', $startDate);
$recordModel->set('time_start', $startTime);
$currentUser = Users_Record_Model::getCurrentUserModel();
$activityType = $recordModel->get('activitytype');
if ($activityType == 'Call') {
$minutes = $currentUser->get('callduration');
} else {
$minutes = $currentUser->get('othereventduration');
}
$dueDateTime = date('Y-m-d H:i:s', strtotime("{$startDateTime}+{$minutes} minutes"));
list($startDate, $startTime) = explode(' ', $dueDateTime);
$recordModel->set('due_date', $startDate);
$recordModel->set('time_end', $startTime);
$recordModel->set('recurringtype', '');
$recordModel->set('mode', 'create');
$recordModel->save();
$heldevent = true;
}
//TODO: remove the dependency on $_REQUEST
if ($_REQUEST['recurringtype'] != '' && $_REQUEST['recurringtype'] != '--None--') {
vimport('~modules/Calendar/RepeatEvents.php');
$focus = new Activity();
//get all the stored data to this object
$focus->column_fields = $recordModel->getData();
Calendar_RepeatEvents::repeatFromRequest($focus);
}
return $recordModel;
}
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:61,代码来源:Save.php
示例5: removeRelation
public function removeRelation(Vtiger_Request $request)
{
$relationId = $request->get('relationId');
$response = new Vtiger_Response();
try {
Vtiger_Relation_Model::removeRelationById($relationId);
$response->setResult(['success' => true]);
} catch (Exception $e) {
$response->setError($e->getCode(), $e->getMessage());
}
$response->emit();
}
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:12,代码来源:Relation.php
示例6: addRelation
function addRelation($request)
{
$sourceModule = $request->getModule();
$sourceRecordId = $request->get('src_record');
$relatedModule = $request->get('related_module');
$relatedRecordIdList = $request->get('related_record_list');
$sourceModuleModel = Vtiger_Module_Model::getInstance($sourceModule);
$relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModule);
$relationModel = Vtiger_Relation_Model::getInstance($sourceModuleModel, $relatedModuleModel);
foreach ($relatedRecordIdList as $relatedRecordId) {
$relationModel->addRelation($sourceRecordId, $relatedRecordId, $listPrice);
}
}
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:13,代码来源:RelationAjax.php
示例7: updateSelectedFields
public function updateSelectedFields(Vtiger_Request $request)
{
$fields = $request->get('fields');
$relationId = $request->get('relationId');
$response = new Vtiger_Response();
try {
Vtiger_Relation_Model::updateModuleRelatedFields($relationId, $fields);
$response->setResult(array('success' => true));
} catch (Exception $e) {
$response->setError($e->getCode(), $e->getMessage());
}
$response->emit();
}
开发者ID:rcrrich,项目名称:UpdatePackages,代码行数:13,代码来源:Relation.php
示例8: addListPrice
/**
* Function adds Products/Services-PriceBooks Relation
* @param type $request
*/
function addListPrice($request)
{
$sourceModule = $request->getModule();
$sourceRecordId = $request->get('src_record');
$relatedModule = $request->get('related_module');
$relInfos = $request->get('relinfo');
$sourceModuleModel = Vtiger_Module_Model::getInstance($sourceModule);
$relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModule);
$relationModel = Vtiger_Relation_Model::getInstance($sourceModuleModel, $relatedModuleModel);
foreach ($relInfos as $relInfo) {
$price = CurrencyField::convertToDBFormat($relInfo['price'], null, true);
$relationModel->addListPrice($sourceRecordId, $relInfo['id'], $price);
}
}
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:18,代码来源:RelationAjax.php
示例9: saveRecord
/**
* Function to save record
* @param <Vtiger_Request> $request - values of the record
* @return <RecordModel> - record Model of saved record
*/
public function saveRecord($request)
{
$recordModel = $this->getRecordModelFromRequest($request);
$recordModel->save();
if ($request->get('relationOperation')) {
$parentModuleName = $request->get('sourceModule');
$parentModuleModel = Vtiger_Module_Model::getInstance($parentModuleName);
$parentRecordId = $request->get('sourceRecord');
$relatedModule = $recordModel->getModule();
$relatedRecordId = $recordModel->getId();
$relationModel = Vtiger_Relation_Model::getInstance($parentModuleModel, $relatedModule);
$relationModel->addRelation($parentRecordId, $relatedRecordId);
}
return $recordModel;
}
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:20,代码来源:SaveAjax.php
示例10: deleteRelation
/**
* Function to delete the relation for specified source record id and related record id list
* @param <array> $request
* keys Content
* src_module source module name
* src_record source record id
* related_module related module name
* related_record_list json encoded of list of related record ids
*/
function deleteRelation($request)
{
$sourceModule = $request->getModule();
$sourceRecordId = $request->get('src_record');
$relatedModule = $request->get('related_module');
$relatedRecordIdList = $request->get('related_record_list');
//Setting related module as current module to delete the relation
vglobal('currentModule', $relatedModule);
$sourceModuleModel = Vtiger_Module_Model::getInstance($sourceModule);
$relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModule);
$relationModel = Vtiger_Relation_Model::getInstance($sourceModuleModel, $relatedModuleModel);
foreach ($relatedRecordIdList as $relatedRecordId) {
$response = $relationModel->deleteRelation($sourceRecordId, $relatedRecordId);
}
echo $response;
}
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:25,代码来源:RelationAjax.php
示例11: updateStatus
/**
* Function to update Relation status
* @param Vtiger_Request $request
*/
public function updateStatus(Vtiger_Request $request)
{
$relatedModuleName = $request->get('relatedModule');
$relatedRecordId = $request->get('relatedRecord');
$status = $request->get('status');
$response = new Vtiger_Response();
if ($relatedRecordId && $status && $status < 5) {
$sourceModuleModel = Vtiger_Module_Model::getInstance($request->getModule());
$relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModuleName);
$relationModel = Vtiger_Relation_Model::getInstance($sourceModuleModel, $relatedModuleModel);
$relationModel->updateStatus($request->get('sourceRecord'), array($relatedRecordId => $status));
$response->setResult(array(true));
} else {
$response->setError($code);
}
$response->emit();
}
开发者ID:yozhi,项目名称:YetiForceCRM,代码行数:21,代码来源:RelationAjax.php
示例12: addRelation
function addRelation($request)
{
$sourceModule = $request->getModule();
$sourceRecordId = $request->get('src_record');
$relatedModule = $request->get('related_module');
if (is_numeric($relatedModule)) {
$relatedModule = Vtiger_Functions::getModuleName($relatedModule);
}
$relatedRecordIdList = $request->get('related_record_list');
$sourceModuleModel = Vtiger_Module_Model::getInstance($sourceModule);
$relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModule);
$relationModel = Vtiger_Relation_Model::getInstance($sourceModuleModel, $relatedModuleModel);
foreach ($relatedRecordIdList as $relatedRecordId) {
$relationModel->addRelation($sourceRecordId, $relatedRecordId, $listPrice);
}
$response = new Vtiger_Response();
$response->setResult(true);
$response->emit();
}
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:19,代码来源:RelationAjax.php
示例13: saveRecord
/**
* Function to save record
* @param <Vtiger_Request> $request - values of the record
* @return <RecordModel> - record Model of saved record
*/
public function saveRecord($request)
{
$recordModel = $this->getRecordModelFromRequest($request);
$recordModel->save();
if ($request->get('relationOperation')) {
$parentModuleName = $request->get('sourceModule');
$parentModuleModel = Vtiger_Module_Model::getInstance($parentModuleName);
$parentRecordId = $request->get('sourceRecord');
$relatedModule = $recordModel->getModule();
$relatedRecordId = $recordModel->getId();
$relationModel = Vtiger_Relation_Model::getInstance($parentModuleModel, $relatedModule);
$relationModel->addRelation($parentRecordId, $relatedRecordId);
//To store the relationship between Products/Services and PriceBooks
if ($parentRecordId && ($parentModuleName === 'Products' || $parentModuleName === 'Services')) {
$parentRecordModel = Vtiger_Record_Model::getInstanceById($parentRecordId, $parentModuleName);
$recordModel->updateListPrice($parentRecordId, $parentRecordModel->get('unit_price'));
}
}
return $recordModel;
}
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:25,代码来源:Save.php
示例14: addRelation
function addRelation($request)
{
$sourceModule = $request->getModule();
$sourceRecordId = $request->get('src_record');
$relatedModule = $request->get('related_module');
$relatedRecordIdList = $request->get('related_record_list');
$sourceModuleModel = Vtiger_Module_Model::getInstance($sourceModule);
$relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModule);
$relationModel = Vtiger_Relation_Model::getInstance($sourceModuleModel, $relatedModuleModel);
foreach ($relatedRecordIdList as $relatedRecordId) {
$relationModel->addRelation($sourceRecordId, $relatedRecordId, $listPrice);
if ($relatedModule == 'PriceBooks') {
$recordModel = Vtiger_Record_Model::getInstanceById($relatedRecordId);
if ($sourceRecordId && ($sourceModule === 'Products' || $sourceModule === 'Services')) {
$parentRecordModel = Vtiger_Record_Model::getInstanceById($sourceRecordId, $sourceModule);
$recordModel->updateListPrice($sourceRecordId, $parentRecordModel->get('unit_price'));
}
}
}
}
开发者ID:nouphet,项目名称:vtigercrm-6.0.0-ja,代码行数:20,代码来源:RelationAjax.php
示例15: saveRecord
/**
* Function to save record
* @param <Vtiger_Request> $request - values of the record
* @return <RecordModel> - record Model of saved record
*/
public function saveRecord($request)
{
$recordModel = $this->getRecordModelFromRequest($request);
$recordModel->save();
if ($request->get('relationOperation')) {
$parentModuleName = $request->get('sourceModule');
$parentModuleModel = Vtiger_Module_Model::getInstance($parentModuleName);
$parentRecordId = $request->get('sourceRecord');
$relatedModule = $recordModel->getModule();
$relatedRecordId = $recordModel->getId();
$relationModel = Vtiger_Relation_Model::getInstance($parentModuleModel, $relatedModule);
$relationModel->addRelation($parentRecordId, $relatedRecordId);
}
if ($request->get('imgDeleted')) {
$imageIds = $request->get('imageid');
foreach ($imageIds as $imageId) {
$status = $recordModel->deleteImage($imageId);
}
}
return $recordModel;
}
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:26,代码来源:Save.php
示例16: process
public function process(Vtiger_Request $request)
{
$relationInfo = $request->get('related_info');
$updatedRelatedList = $relationInfo['updated'];
$deletedRelatedList = $relationInfo['deleted'];
if (empty($updatedRelatedList)) {
$updatedRelatedList = array();
}
if (empty($deletedRelatedList)) {
$deletedRelatedList = array();
}
$sourceModule = $request->get('sourceModule');
$moduleModel = Vtiger_Module_Model::getInstance($sourceModule, false);
$relationModulesList = Vtiger_Relation_Model::getAllRelations($moduleModel, false);
$sequenceList = array();
foreach ($relationModulesList as $relationModuleModel) {
$sequenceList[] = $relationModuleModel->get('sequence');
}
//To sort sequence in ascending order
sort($sequenceList);
$relationUpdateDetail = array();
$index = 0;
foreach ($updatedRelatedList as $relatedId) {
$relationUpdateDetail[] = array('relation_id' => $relatedId, 'sequence' => $sequenceList[$index++], 'presence' => 0);
}
foreach ($deletedRelatedList as $relatedId) {
$relationUpdateDetail[] = array('relation_id' => $relatedId, 'sequence' => $sequenceList[$index++], 'presence' => 1);
}
$response = new Vtiger_Response();
try {
$response->setResult(array('success' => true));
Vtiger_Relation_Model::updateRelationSequenceAndPresence($relationUpdateDetail, $moduleModel->getId());
} catch (Exception $e) {
$response->setError($e->getCode(), $e->getMessage());
}
$response->emit();
}
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:37,代码来源:Relation.php
示例17: getRelations
public function getRelations()
{
if ($this->relations === null) {
$this->relations = Vtiger_Relation_Model::getAllRelations($this, false);
}
// Contacts relation-tab is turned into custom block on DetailView.
if ($this->getName() == 'Calendar') {
$contactsIndex = false;
foreach ($this->relations as $index => $model) {
if ($model->getRelationModuleName() == 'Contacts') {
$contactsIndex = $index;
break;
}
}
if ($contactsIndex !== false) {
array_splice($this->relations, $contactsIndex, 1);
}
}
return $this->relations;
}
开发者ID:noclav,项目名称:UpdatePackages,代码行数:20,代码来源:Module.php
示例18: isDeletable
public function isDeletable()
{
$srcModuleModel = Vtiger_Module_Model::getInstance($this->get('srcModule'));
$relationModel = Vtiger_Relation_Model::getInstance($srcModuleModel, $this->get('module'));
return $relationModel->isDeletable();
}
开发者ID:nikdejan,项目名称:YetiForceCRM,代码行数:6,代码来源:TreeCategoryModal.php
示例19: getInstance
public static function getInstance($parentRecordModel, $relationModuleName, $label = false)
{
$parentModuleName = $parentRecordModel->getModule()->get('name');
$className = Vtiger_Loader::getComponentClassName('Model', 'RelationListView', $parentModuleName);
$instance = new $className();
$parentModuleModel = $parentRecordModel->getModule();
$relatedModuleModel = Vtiger_Module_Model::getInstance($relationModuleName);
$instance->setRelatedModuleModel($relatedModuleModel);
$relationModel = Vtiger_Relation_Model::getInstance($parentModuleModel, $relatedModuleModel, $label);
$instance->setParentRecordModel($parentRecordModel);
if (!$relationModel) {
$relatedModuleName = $relatedModuleModel->getName();
$parentModuleModel = $instance->getParentRecordModel()->getModule();
$referenceFieldOfParentModule = $parentModuleModel->getFieldsByType('reference');
foreach ($referenceFieldOfParentModule as $fieldName => $fieldModel) {
$refredModulesOfReferenceField = $fieldModel->getReferenceList();
if (in_array($relatedModuleName, $refredModulesOfReferenceField)) {
$relationModelClassName = Vtiger_Loader::getComponentClassName('Model', 'Relation', $parentModuleModel->getName());
$relationModel = new $relationModelClassName();
$relationModel->setParentModuleModel($parentModuleModel)->setRelationModuleModel($relatedModuleModel);
$parentModuleModel->set('directRelatedFieldName', $fieldModel->get('column'));
}
}
}
if (!$relationModel) {
$relationModel = false;
}
$instance->setRelationModel($relationModel);
return $instance;
}
开发者ID:vinzdrance,项目名称:YetiForceCRM,代码行数:30,代码来源:RelationListView.php
示例20: saveRecord
/**
* Function to save record
* @param <Vtiger_Request> $request - values of the record
* @return <RecordModel> - record Model of saved record
*/
public function saveRecord($request)
{
$recordId = $request->get('record');
$recordModel = $this->getRecordModelFromRequest($request);
$mode = $recordModel->get('mode');
$adb = PearDatabase::getInstance();
// check if encryption is enabled
$config == false;
if (file_exists('modules/OSSPasswords/config.ini.php')) {
$config = parse_ini_file('modules/OSSPasswords/config.ini.php');
}
//check if password was edited with hidden password
$properPassword = $recordModel->get('password');
// edit mode
if ($recordId != '' && $mode == 'edit') {
if ($properPassword == '**********') {
// hidden password sent in edit mode, get the correct one
if ($config) {
// when encryption is on
$sql = "SELECT AES_DECRYPT(`password`, '" . $config['key'] . "') AS pass FROM `vtiger_osspasswords` WHERE `osspasswordsid` = ?;";
$result = $adb->pquery($sql, array($recordId), true);
$properPassword = $adb->query_result($result, 0, 'pass');
} else {
// encryption mode is off
$sql = "SELECT `password` AS pass FROM `vtiger_osspasswords` WHERE `osspasswordsid` = ?;";
$result = $adb->pquery($sql, array($recordId), true);
$properPassword = $adb->query_result($result, 0, 'pass');
}
}
$recordModel->set('password', $properPassword);
$recordModel->save();
// after save we check if encryption is active
if ($config) {
$sql = "UPDATE `vtiger_osspasswords` SET `password` = AES_ENCRYPT(?,?) WHERE `osspasswordsid` = ?;";
$result = $adb->pquery($sql, array($properPassword, $config['key'], $recordId), true);
}
} else {
if ($recordId == '' && $mode == '') {
$recordModel->save();
// if encryption mode is on we will encrypt the password
$recordId = $recordModel->get('id');
if ($config) {
// when encryption is on
$sql = "UPDATE `vtiger_osspasswords` SET `password` = AES_ENCRYPT(`password`, ?) WHERE `osspasswordsid` = ?;";
$result = $adb->pquery($sql, array($config['key'], $recordId), true);
}
}
}
if ($request->get('relationOperation')) {
$parentModuleName = $request->get('sourceModule');
$parentModuleModel = Vtiger_Module_Model::getInstance($parentModuleName);
$parentRecordId = $request->get('sourceRecord');
$relatedModule = $recordModel->getModule();
$relatedRecordId = $recordModel->getId();
$relationModel = Vtiger_Relation_Model::getInstance($parentModuleModel, $relatedModule);
$relationModel->addRelation($parentRecordId, $relatedRecordId);
}
return $recordModel;
}
开发者ID:awflu,项目名称:YetiForceCRM,代码行数:64,代码来源:Save.php
注:本文中的Vtiger_Relation_Model类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论