当前位置: 首页>>代码示例>>PHP>>正文


PHP GO::getModel方法代码示例

本文整理汇总了PHP中GO::getModel方法的典型用法代码示例。如果您正苦于以下问题:PHP GO::getModel方法的具体用法?PHP GO::getModel怎么用?PHP GO::getModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GO的用法示例。


在下文中一共展示了GO::getModel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionPortletFoldersByUser

 /**
  * Load the folders that need to be displayed in the portlet
  * 
  * @param array $params
  * @return array $response
  */
 protected function actionPortletFoldersByUser($params)
 {
     $findCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('user_id', \GO::user()->id);
     $findParams = \GO\Base\Db\FindParams::newInstance()->debugSql()->criteria($findCriteria);
     $portletFoldersStatement = \GO\email\Model\PortletFolder::model()->find($findParams);
     $portletFoldersStore = \GO\Base\Data\Store::newInstance(\GO::getModel($this->model));
     $portletFoldersStore->setStatement($portletFoldersStatement);
     return $portletFoldersStore->getData();
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:15,代码来源:PortletController.php

示例2: load

 /**
  * Execute a grouped query and return the statement. This class may be extended
  * so you can document loaded properties or implement additional functions.
  * 
  * @param string $modelName
  * @param array $groupBy eg array('t.name')
  * @param string $selectFields
  * @param \GO\Base\Db\FindParams $findParams
  * @return \GO\Base\Db\ActiveStatement
  */
 public function load($modelName, $groupBy, $selectFields, \GO\Base\Db\FindParams $findParams = null)
 {
     if (!isset($findParams)) {
         $findParams = \GO\Base\Db\FindParams::newInstance();
     }
     $findParams->ignoreAcl()->select($selectFields)->group($groupBy)->fetchClass(get_class($this));
     $stmt = \GO::getModel($modelName)->find($findParams);
     return $stmt;
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:19,代码来源:Grouped.php

示例3: __construct

 /**
  * Constructor of the ColumnModel class.
  * 
  * Use this to constructor a new ColumnModel. You can give two parameters.
  * If you give the $model param then the columns of that model are set automatically in this columnModel.
  * The public parameters and the customfield parameters are also set.
  * The $excludeColumns are meant to give up the column names that need to be excluded in the columnModel.
  * 
  * @param string $modelName The models where to get the columns from.
  * @param Array $excludeColumns 
  * @param Array $includeColumns
  */
 public function __construct($modelName = false, $excludeColumns = array(), $includeColumns = array())
 {
     if ($modelName) {
         if (is_string($modelName)) {
             $modelName = \GO::getModel($modelName);
         }
         $this->setColumnsFromModel($modelName, $excludeColumns, $includeColumns);
         $this->_model = $modelName;
     }
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:22,代码来源:ColumnModel.php

示例4: getAttachedObject

 public function getAttachedObject()
 {
     $modelType = \GO\Base\Model\ModelType::model()->findByPk($this->model_type_id);
     if ($modelType) {
         $obj = \GO::getModel($modelType->model_name)->findByPk($this->model_id);
         if ($obj) {
             return $obj;
         }
     }
     return false;
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:11,代码来源:Comment.php

示例5: getModelFromParams

 protected function getModelFromParams($params)
 {
     $modelName = $this->model;
     $model = false;
     $pk = $this->getPrimaryKeyFromParams($params);
     if (!empty($pk)) {
         $model = \GO::getModel($modelName)->findByPk($pk);
     }
     if (!$model) {
         $model = new $modelName();
         $model->setAttributes($params);
     }
     return $model;
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:14,代码来源:FolderPreferenceController.php

示例6: beforeSubmit

 protected function beforeSubmit(&$response, &$model, &$params)
 {
     if (!empty($params['link'])) {
         $link = explode(':', $params['link']);
         $params['model_id'] = $link[1];
         $params['model_type_id'] = \GO::getModel($link[0])->modelTypeId();
     } else {
         $params['model_id'] = 0;
         $params['model_type_id'] = 0;
     }
     $params['manual'] = 1;
     $params['vtime'] = $params['time'] = $params['date'] . ' ' . $params['time'];
     return parent::beforeSubmit($response, $model, $params);
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:14,代码来源:ReminderController.php

示例7: actionCombinedStore

 protected function actionCombinedStore($params)
 {
     $response = array('success' => true, 'total' => 0, 'results' => array());
     $cm = new \GO\Base\Data\ColumnModel();
     $cm->setColumnsFromModel(\GO::getModel('GO\\Comments\\Model\\Comment'));
     $store = \GO\Base\Data\Store::newInstance($cm);
     $storeParams = $store->getDefaultParams($params)->mergeWith($this->getStoreParams($params));
     $findParams = \GO\Base\Db\FindParams::newInstance()->select('t.*,type.model_name')->joinModel(array('model' => 'GO\\Base\\Model\\ModelType', 'localTableAlias' => 't', 'localField' => 'model_type_id', 'foreignField' => 'id', 'tableAlias' => 'type'));
     $findParams->mergeWith($storeParams);
     $store->setStatement(\GO\Comments\Model\Comment::model()->find($findParams));
     return $store->getData();
     //
     //		return $response;
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:14,代码来源:CommentController.php

示例8: export

 /**
  * Export the contact model to a .csv, including the company.
  * 
  * @param array $params
  */
 public function export($params)
 {
     GO::$disableModelCache = true;
     GO::setMaxExecutionTime(420);
     // Load the data from the session.
     $findParams = \GO::session()->values['contact']['findParams'];
     $findParams->getCriteria()->recreateTemporaryTables();
     $model = \GO::getModel(\GO::session()->values['contact']['model']);
     // Include the companies
     $findParams->joinRelation('company', 'LEFT');
     // Let the export handle all found records without a limit
     $findParams->limit(0);
     // Create the statement
     $stmt = $model->find($findParams);
     // Create the csv file
     $csvFile = new \GO\Base\Fs\CsvFile(\GO\Base\Fs\File::stripInvalidChars('export.csv'));
     // Output the download headers
     \GO\Base\Util\Http::outputDownloadHeaders($csvFile, false);
     $csvWriter = new \GO\Base\Csv\Writer('php://output');
     $headerPrinted = false;
     $attrs = array();
     $compAttrs = array();
     foreach ($stmt as $m) {
         $iterationStartUnix = time();
         if (!$headerPrinted) {
             $attrs = $m->getAttributes();
             $compAttrs = $m->company->getAttributes();
         }
         $header = array();
         $record = array();
         foreach ($attrs as $attr => $val) {
             if (!$headerPrinted) {
                 $header[$attr] = $m->getAttributeLabel($attr);
             }
             $record[$attr] = $m->{$attr};
         }
         foreach ($compAttrs as $cattr => $cval) {
             if (!$headerPrinted) {
                 $header[GO::t('company', 'addressbook') . $cattr] = GO::t('company', 'addressbook') . ':' . $m->company->getAttributeLabel($cattr);
             }
             $record[GO::t('company', 'addressbook') . $cattr] = $m->company->{$cattr};
         }
         if (!$headerPrinted) {
             $csvWriter->putRecord($header);
             $headerPrinted = true;
         }
         $csvWriter->putRecord($record);
     }
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:54,代码来源:ExportContactsWithCompaniesController.php

示例9: getItemNames

 public function getItemNames($forModelId, $forModelName)
 {
     $modelUnderBlock = \GO::getModel($this->customField->category->extends_model);
     $cfTableName = 'cf_' . $modelUnderBlock->tableName();
     $stmt = $modelUnderBlock->find(\GO\Base\Db\FindParams::newInstance()->ignoreAcl()->join($cfTableName, \GO\Base\Db\FindCriteria::newInstance()->addRawCondition('cf.model_id', 't.id'), 'cf', 'INNER')->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('col_' . $this->field_id, $forModelId . ':%', 'LIKE', 'cf')));
     $itemNamesArr = array();
     foreach ($stmt as $item) {
         $name = $item->className() == 'GO\\Addressbook\\Model\\Company' || $item->className() == 'GO\\Addressbook\\Model\\Contact' ? $item->name . ' (' . $item->addressbook->name . ')' : $item->name;
         $itemNamesArr[] = array('model_id' => $item->id, 'model_name' => $item->className(), 'item_name' => $name);
     }
     usort($itemNamesArr, function ($a, $b) {
         return $a['item_name'] >= $b['item_name'] ? 1 : -1;
     });
     return $itemNamesArr;
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:15,代码来源:Block.php

示例10: actionSelectNewStore

 /**
  * Return all new items for a grid. 
  * So this are the items that are not already selected.
  * 
  * Parameters:
  *	model_id =	The value of one of the keys from the combined primary key of the linkModel that is not given in the linkModelField;
  *			Example:	The combined key of the linkModel is: [user_id,tasklist_id].
  *								The given linkModelField is: [tasklist_id].
  *								Then the model_id needs to be the other value of the combined key so in this example: The value for [user_id]
  *							
  * 
  * @param Array $params
  * @return type 
  */
 protected function actionSelectNewStore($params)
 {
     $model = \GO::getModel($this->modelName());
     $linkModel = \GO::getModel($this->linkModelName());
     $store = \GO\Base\Data\Store::newInstance($model);
     $joinCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition($this->getRemoteKey(), $params['model_id'], '=', 'lt')->addCondition($model->primaryKey(), 'lt.' . $this->linkModelField(), '=', 't', true, true);
     $this->formatColumns($store->getColumnModel());
     $findParams = $store->getDefaultParams($params);
     if ($this->uniqueSelection) {
         $findParams->join($linkModel->tableName(), $joinCriteria, 'lt', 'LEFT');
         $findCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition($this->linkModelField(), null, 'IS', 'lt');
         $findParams->criteria($findCriteria);
     }
     $availableModels = $model->find($findParams);
     $store->setStatement($availableModels);
     return $store->getData();
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:31,代码来源:AddressbookFavoritesController.php

示例11: actionSubmit

 /**
  * Update the given id's with the given data
  * The params array must contain at least:
  * 
  * @param array $params 
  * <code>
  * $params['data'] = The new values that need to be set
  * $params['keys'] = The keys of the records that need to get the new data
  * $params['model_name']= The model classname of the records that need to be updated
  * </code>
  */
 protected function actionSubmit($params)
 {
     if (empty($params['data']) || empty($params['keys']) || empty($params['model_name'])) {
         return false;
     }
     $data = json_decode($params['data'], true);
     $keys = json_decode($params['keys'], true);
     if (is_array($keys)) {
         foreach ($keys as $key) {
             $model = \GO::getModel($params['model_name'])->findByPk($key);
             if (!empty($model)) {
                 $this->_updateModel($model, $data);
             }
         }
     }
     $response['success'] = true;
     $this->fireEvent('submit', array(&$this, &$response, &$model, &$params));
     return $response;
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:30,代码来源:BatchEditController.php

示例12: actionMoveLinks

 protected function actionMoveLinks($params)
 {
     $moveLinks = json_decode($params['selections'], true);
     $target = json_decode($params['target']);
     $response['moved_links'] = array();
     foreach ($moveLinks as $modelNameAndId) {
         $link = explode(':', $modelNameAndId);
         $modelName = $link[0];
         $modelId = $link[1];
         if ($modelName == 'GO\\Base\\Model\\LinkFolder') {
             $moveFolder = \GO\Base\Model\LinkFolder::model()->findByPk($modelId);
             $moveFolder->parent_id = intval($target->folder_id);
             $moveFolder->save();
         } else {
             $moveModel = \GO::getModel($modelName)->findByPk($modelId);
             $targetModel = \GO::getModel($target->model_name)->findByPk($target->model_id);
             $targetModel->updateLink($moveModel, array('folder_id' => intval($target->folder_id)));
         }
     }
     $response['success'] = true;
     return $response;
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:22,代码来源:LinkFolderController.php

示例13: formatReminderRecord

 public function formatReminderRecord($record, $model, $store)
 {
     $record['iconCls'] = 'go-icon-reminders';
     $record['type'] = \GO::t('other');
     $record['model_name'] = '';
     if (!empty($record['model_type_id'])) {
         $modelType = \GO\Base\Model\ModelType::model()->findByPk($record['model_type_id']);
         if ($modelType && \GO::getModel($modelType->model_name)) {
             $record['iconCls'] = 'go-model-icon-' . $modelType->model_name;
             $record['type'] = \GO::getModel($modelType->model_name)->localizedName;
             $record['model_name'] = $modelType->model_name;
         }
     }
     $now = \GO\Base\Util\Date::clear_time(time());
     $time = $model->vtime ? $model->vtime : $model->time;
     if (\GO\Base\Util\Date::clear_time($time) != $now) {
         $record['local_time'] = date(\GO::user()->completeDateFormat, $time);
     } else {
         $record['local_time'] = date(\GO::user()->time_format, $time);
     }
     $record['text'] = htmlspecialchars_decode($record['text']);
     return $record;
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:23,代码来源:ReminderController.php

示例14: findByModel

 public function findByModel($modelName, $id)
 {
     $model_type_id = \GO::getModel($modelName)->modelTypeId();
     return $this->find(\GO\Base\Db\FindParams::newInstance()->criteria(\GO\Base\Db\FindCriteria::newInstance()->addModel(Reminder::model())->addCondition('model_type_id', $model_type_id)->addCondition('model_id', $id)));
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:5,代码来源:Reminder.php

示例15: renderSubmit

 /**
  * Render the JSON outbut for a submit action to be used by ExtJS Form submit
  * @param \GO\Base\Db\ActiveRecord $$data['model']
  * @return \GO\Base\Data\JsonResponse Response object
  */
 public function renderSubmit($data)
 {
     $response = array('feedback' => '', 'success' => true, 'validationErrors' => array(), 'data' => array());
     //Init data array
     foreach ($data as $modelName => $model) {
         if (is_array($model)) {
             $response['data'][$modelName] = $model;
         } else {
             $response['data'][$modelName] = $model->getAttributes();
         }
         // $modelName cannot be the same as the reserved results
         if ($modelName == 'feedback' || $modelName == 'success' || $modelName == 'validationErrors') {
             throw new \Exception('Cannot use "' . $modelName . '" as key for your data. Please change the key.');
         }
         if (is_a($model, "\\GO\\Base\\Model")) {
             //$ret = $this->beforeSubmit($response, $model, $params);
             //$modifiedAttributes = $model->getModifiedAttributes();
             if (!$model->hasValidationErrors() && !$model->isNew) {
                 //model was saved
                 $response['id'] = $model->pk;
                 //If the model has it's own ACL id then we return the newly created ACL id.
                 //The model automatically creates it.
                 if ($model->aclField() && !$model->isJoinedAclField) {
                     $response[$model->aclField()] = $model->{$model->aclField()};
                 }
                 //TODO: move the link saving to the model someday
                 if (!empty(\GO::request()->post['link']) && $model->hasLinks()) {
                     //a link is sent like  \GO\Notes\Model\Note:1
                     //where 1 is the id of the model
                     $linkProps = explode(':', \GO::request()->post['link']);
                     $linkModel = \GO::getModel($linkProps[0])->findByPk($linkProps[1]);
                     $model->link($linkModel);
                 }
             } else {
                 // model was not saved
                 $response['success'] = false;
                 //can't use <br /> tags in response because this goes wrong with the extjs fileupload hack with an iframe.
                 $response['feedback'] = sprintf(\GO::t('validationErrorsFound'), strtolower($model->localizedName)) . "\n\n" . implode("\n", $model->getValidationErrors()) . "\n";
                 if (\GO\Base\Util\Http::isAjaxRequest(false)) {
                     $response['feedback'] = nl2br($response['feedback']);
                 }
                 $response['errors'] = array(sprintf(\GO::t('validationErrorsFound'), strtolower($model->localizedName)) . "\n\n" . implode("\n", $model->getValidationErrors()) . "\n");
                 $response['validationErrors'][$modelName] = $model->getValidationErrors();
             }
         } else {
             $response[$modelName] = $model;
         }
     }
     return new \GO\Base\Data\JsonResponse($response);
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:55,代码来源:JsonView.php


注:本文中的GO::getModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。