Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 private function _processCommentsDisplay($model, $response)
 {
     $stmt = \GO\Comments\Model\Comment::model()->find(\GO\Base\Db\FindParams::newInstance()->limit(5)->select('t.*,cat.name AS categoryName')->order('id', 'DESC')->joinModel(array('model' => 'GO\\Comments\\Model\\Category', 'localTableAlias' => 't', 'localField' => 'category_id', 'foreignField' => 'id', 'tableAlias' => 'cat', 'type' => 'LEFT'))->criteria(\GO\Base\Db\FindCriteria::newInstance()->addModel(\GO\Comments\Model\Comment::model())->addCondition('model_id', $model->id)->addCondition('model_type_id', $model->modelTypeId())));
     $store = \GO\Base\Data\Store::newInstance(\GO\Comments\Model\Comment::model());
     $store->setStatement($stmt);
     $columnModel = $store->getColumnModel();
     $columnModel->formatColumn('user_name', '$model->user->name');
     $data = $store->getData();
     foreach ($data['results'] as $k => $v) {
         $data['results'][$k]['categoryName'] = !empty($v['categoryName']) ? $v['categoryName'] : \GO::t('noCategory', 'comments');
     }
     $response['data']['comments'] = $data['results'];
     return $response;
 }
Exemplo n.º 3
0
 private function _moveComments(ActiveRecord $sourceModel)
 {
     if (GO::modules()->isInstalled('comments') && $this->hasLinks()) {
         $findParams = FindParams::newInstance()->ignoreAcl()->order('id', 'DESC')->criteria(FindCriteria::newInstance()->addCondition('model_id', $sourceModel->id)->addCondition('model_type_id', $sourceModel->modelTypeId()));
         $stmt = \GO\Comments\Model\Comment::model()->find($findParams);
         while ($comment = $stmt->fetch()) {
             $comment->model_type_id = $this->modelTypeId();
             $comment->model_id = $this->id;
             $comment->save();
         }
     }
 }