/** * Can be used in actionDisplay like actions * @param \GO\Base\Db\ActiveRecord $data['model'] the model to render display data for * @param array $extraFields the extra fields that should be attached to the data array as key => value * @return \GO\Base\Data\JsonResponse Response object */ public function renderDisplay($data) { $response = array('data' => array(), 'success' => true); $response['data'] = $data['model']->getAttributes('html'); if (!empty($data['model']->user)) { $response['data']['username'] = $data['model']->user->name; } if (!empty($data['model']->mUser)) { $response['data']['musername'] = $data['model']->mUser->name; } //$response['data'] = $model->getAttributes('html'); //$response['data']['model'] = $model->className(); $response['data']['permission_level'] = $data['model']->getPermissionLevel(); $response['data']['write_permission'] = \GO\Base\Model\Acl::hasPermission($response['data']['permission_level'], \GO\Base\Model\Acl::WRITE_PERMISSION); $response['data']['customfields'] = array(); if (!isset($response['data']['workflow']) && \GO::modules()->workflow) { $response = $this->_processWorkflowDisplay($data['model'], $response); } if ($data['model']->customfieldsRecord) { $response = $this->_processCustomFieldsDisplay($data['model'], $response); } if ($data['model']->hasLinks()) { $response = $this->_processLinksDisplay($data['model'], $response); if (!isset($response['data']['events']) && \GO::modules()->calendar) { $response = $this->_processEventsDisplay($data['model'], $response); } if (!isset($response['data']['tasks']) && \GO::modules()->tasks) { $response = $this->_processTasksDisplay($data['model'], $response); } } if (\GO::modules()->files && !isset($response['data']['files'])) { $response = $this->_processFilesDisplay($data['model'], $response); } if (\GO::modules()->comments) { $response = $this->_processCommentsDisplay($data['model'], $response); } if (\GO::modules()->lists) { $response = \GO\Lists\ListsModule::displayResponse($data['model'], $response); } // // $this->fireEvent('display', array( // &$this, // &$response, // &$model // )); return new \GO\Base\Data\JsonResponse($response); }
/** * The default action for displaying a model in a DisplayPanel. */ protected function actionDisplay($params) { $response = array('data' => array(), 'success' => true); $modelName = $this->model; $model = \GO::getModel($modelName)->findByPk($this->getPrimaryKeyFromParams($params)); if (!$model) { throw new \GO\Base\Exception\NotFound(); } $response = $this->beforeDisplay($response, $model, $params); //todo build in new style. Now it's necessary for old library functions //require_once(\GO::config()->root_path.'Group-Office.php'); $response['data'] = array_merge($response['data'], $model->getAttributes('html')); $response['data']['model'] = $model->className(); $response['data']['permission_level'] = $model->getPermissionLevel(); $response['data']['write_permission'] = \GO\Base\Model\Acl::hasPermission($response['data']['permission_level'], \GO\Base\Model\Acl::WRITE_PERMISSION); if (!empty($model->ctime)) { $response['data']['ctime'] = \GO\Base\Util\Date::get_timestamp($model->ctime); } if (!empty($model->mtime)) { $response['data']['mtime'] = \GO\Base\Util\Date::get_timestamp($model->mtime); } if (!empty($model->user)) { $response['data']['username'] = $model->user->name; } if (!empty($model->mUser)) { $response['data']['musername'] = $model->mUser->name; } $response['data']['customfields'] = array(); if (!isset($response['data']['workflow']) && \GO::modules()->workflow) { $response = $this->_processWorkflowDisplay($model, $response); } if ($model->customfieldsRecord) { $response = $this->_processCustomFieldsDisplay($model, $response); } if ($model->hasLinks()) { $response = $this->_processLinksDisplay($model, $response, isset($params['links_limit']) ? $params['links_limit'] : 15); if (!isset($response['data']['events']) && \GO::modules()->calendar) { $response = $this->_processEventsDisplay($model, $response); } if (!isset($response['data']['tasks']) && \GO::modules()->tasks) { $response = $this->_processTasksDisplay($model, $response); } } if (!isset($response['data']['files'])) { $response = $this->_processFilesDisplay($model, $response); } if (\GO::modules()->comments) { $response = $this->_processCommentsDisplay($model, $response); } if (\GO::modules()->lists) { $response = \GO\Lists\ListsModule::displayResponse($model, $response); } $response = $this->afterDisplay($response, $model, $params); $this->fireEvent('display', array(&$this, &$response, &$model)); return $response; }