コード例 #1
0
ファイル: Actions.php プロジェクト: tymiles003/X2CRM
 private function saveMetaData()
 {
     // No action text exists for this yet
     if (!$this->actionText instanceof ActionText) {
         $actionText = new ActionText();
         // Create new oen
         $actionText->actionId = $this->id;
         $actionText->text = $this->actionDescriptionTemp;
         // A magic setter sets actionDescriptionTemp value
         $actionText->save();
     } else {
         // We have an action text
         if ($this->actionText->text != $this->actionDescriptionTemp) {
             // Only update if different
             $this->actionText->text = $this->actionDescriptionTemp;
             $this->actionText->save();
         }
     }
     if (!$this->actionMetaData instanceof ActionMetaData) {
         $metaData = new ActionMetaData();
         $metaData->actionId = $this->id;
     } else {
         $metaData = $this->actionMetaData;
     }
     foreach ($this->metaDataTemp as $name => $value) {
         $metaData->{$name} = $value;
     }
     if (!$metaData->save()) {
         //AuxLib::debugLogR ($metaData->getErrors ());
     }
 }
コード例 #2
0
ファイル: Api2Controller.php プロジェクト: tymiles003/X2CRM
 /**
  * Work-arounds for querying records of the Actions class, which is special
  *
  * The {@link Actions} class is special and different from all the other
  * {@link X2Model} sub-classes, hence this function was written to deal with
  * the differences.
  * 
  * @param type $searchAttributes Search parameters
  * @param CDbCriteria $criteria The search criteria to modify
  */
 public function kludgesForSearchingActions(&$searchAttributes, $criteria)
 {
     // Searching through actionDescription
     //
     // The property Actions.actionDescription is actually a TEXT column in a
     // related table, x2_action_text. That's why searching based on
     // actionDescription is NOT recommended; it will be very, very slow.
     //
     // Also, note (THIS IS IMPORTANT) because it's in a joined table, we
     // cannot use the elegant CDbCriteria.compare() function to perform
     // the comparison. We thus lose all the advanced comparison and sorting
     // options. Just know that whatever the 'actionDescription' parameter
     // equals will be included directly as a parameter to a "LIKE"
     // comparison statement.
     if (isset($_GET['actionDescription'])) {
         $atTable = ActionText::model()->tableName();
         $atAlias = 'at';
         $criteria->join .= " INNER JOIN `{$atTable}` `{$atAlias}` " . "ON `{$atAlias}`.`actionId` = `{$criteria->alias}`.`id` " . "AND `{$at}`.`text` LIKE :apiSearchActionDescription";
         $criteria->params[':apiSearchActionDescription'] = $_GET['actionDescription'];
     }
     // Awful, ugly kludge for validating Actions' associationType field:
     //
     // The following lines should be removed as soon as associationType in
     // Actions is "fixed" (meaning, it references actual class names instead
     // of module names). The following line was added to account for the
     // case of a database with case-sensitive collation, whereupon a query
     // for associated actions using api2/[class]/[id]/Actions would for
     // instance always return zero results, because associationType (which
     // by URL rules maps to the "_class" parameter) is "Contacts" (the
     // actual class name) rather than "contacts" (the "association type" as
     // dictated by the unwieldy convention that we've had for Actions almost
     // from the very beginnings of X2Engine).
     if (isset($searchAttributes['associationType'])) {
         $associationClass = isset(X2Model::$associationModels[$searchAttributes['associationType']]) ? X2Model::$associationModels[$searchAttributes['associationType']] : $searchAttributes['associationType'];
         $staticSearchModel = X2Model::model($associationClass);
         $searchAttributes['associationType'] = $staticSearchModel->asa('X2LinkableBehavior') === null ? lcfirst(get_class($staticSearchModel)) : $staticSearchModel->asa('X2LinkableBehavior')->module;
     }
 }