Ejemplo n.º 1
0
 public function Save($blnForceInsert = false, $blnForceUpdate = false)
 {
     if (!$this->__blnRestored || $blnForceInsert) {
         $this->CreatedBy = QApplication::$objUserAccount->UserAccountId;
         $this->CreationDate = new QDateTime(QDateTime::Now);
         parent::Save($blnForceInsert, $blnForceUpdate);
     } else {
         $this->ModifiedBy = QApplication::$objUserAccount->UserAccountId;
         // Load the CustomFieldValue object before modifing
         $objOldCustomFieldValue = CustomFieldValue::LoadByCustomFieldValueId($this->CustomFieldValueId);
         parent::Save($blnForceInsert, $blnForceUpdate);
         // If short_description have been modified
         if ($this->ShortDescription != $objOldCustomFieldValue->ShortDescription) {
             if ($objCustomField = $this->CustomField) {
                 $objDatabase = CustomFieldValue::GetDatabase();
                 $objCustomFieldSelectionArray = CustomFieldSelection::LoadArrayByCustomFieldValueId($this->CustomFieldValueId);
                 foreach ($objCustomFieldSelectionArray as $objCustomFieldSelection) {
                     // If helper table exists
                     if ($strHelperTableArray = $this->GetHelperTableByEntityQtypeId($objCustomFieldSelection->EntityQtypeId)) {
                         $strHelperTable = $strHelperTableArray[0];
                         $strTableName = $strHelperTableArray[1];
                         // Update the data into helper table
                         $strQuery = sprintf("UPDATE %s SET `cfv_%s`=%s WHERE `%s_id`='%s';", $strHelperTable, $objCustomField->CustomFieldId, $objDatabase->SqlVariable($this->ShortDescription), $strTableName, $objCustomFieldSelection->EntityId);
                         $objDatabase->NonQuery($strQuery);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Gets all associated CustomFieldSelections as an array of CustomFieldSelection objects
  * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  * @return CustomFieldSelection[]
  */
 public function GetCustomFieldSelectionArray($objOptionalClauses = null)
 {
     if (is_null($this->intCustomFieldValueId)) {
         return array();
     }
     try {
         return CustomFieldSelection::LoadArrayByCustomFieldValueId($this->intCustomFieldValueId, $objOptionalClauses);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
 }