public function getAttribute($name, $renderFlag = false, $makeLinks = false) { if (in_array($name, array_keys($this->metaDataTemp))) { return $this->{$name}; } elseif ($name === 'actionDescription') { $model = ActionText::model()->findByAttributes(array('actionId' => $this->id)); if ($model) { return $model->text; } } else { return parent::getAttribute($name, $renderFlag); } return null; }
/** * 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; } }