Example #1
0
 protected function afterDisplay(&$response, &$model, &$params)
 {
     $modelType = \GO\Base\Model\ModelType::model()->findByPk($model->model_type_id);
     $scModel = \GO\Base\Model\SearchCacheRecord::model()->findByPk(array('model_id' => $model->model_id, 'model_type_id' => $model->model_type_id));
     if (!isset($response['data']['parent'])) {
         $response['data']['parent'] = array();
     }
     if ($scModel) {
         $response['data']['parent']['name'] = $scModel->name;
     }
     $response['data']['parent']['model_type'] = $modelType ? $modelType->model_name : false;
     $response['data']['parent']['model_id'] = $model->model_id;
     $response['data']['comments'] = $model->comments;
     $response['data']['category_name'] = $model->category ? $model->category->name : '';
     $response['data']['short'] = strlen($model->comments) > 13 ? substr($model->comments, 0, 10) . '...' : $model->comments;
     return $response;
 }
Example #2
0
 public function actionView($params)
 {
     //		Do not close session writing because SMIME stores the password in the session
     //		GO::session()->closeWriting();
     $params['no_max_body_size'] = !empty($params['no_max_body_size']) && $params['no_max_body_size'] !== 'false' ? true : false;
     $account = Account::model()->findByPk($params['account_id']);
     if (!$account) {
         throw new \GO\Base\Exception\NotFound();
     }
     $imapMessage = \GO\Email\Model\ImapMessage::model()->findByUid($account, $params['mailbox'], $params['uid']);
     if (!$imapMessage) {
         throw new \GO\Base\Exception\NotFound();
     }
     //workaround for gmail. It doesn't flag messages as seen automatically.
     //		if (!$imapMessage->seen && stripos($account->host, 'gmail') !== false)
     //			$imapMessage->getImapConnection()->set_message_flag(array($imapMessage->uid), "\Seen");
     if (!empty($params['create_temporary_attachments'])) {
         $imapMessage->createTempFilesForAttachments();
     }
     $plaintext = !empty($params['plaintext']);
     $response = $imapMessage->toOutputArray(!$plaintext, false, $params['no_max_body_size']);
     $response['uid'] = intval($params['uid']);
     $response['mailbox'] = $params['mailbox'];
     $response['account_id'] = intval($params['account_id']);
     $response['do_not_mark_as_read'] = $account->do_not_mark_as_read;
     if (!$plaintext) {
         if ($params['mailbox'] != $account->sent && $params['mailbox'] != $account->drafts) {
             $response = $this->_blockImages($params, $response);
             $response = $this->_checkXSS($params, $response);
         }
         //Don't do these special actions in the special folders
         if ($params['mailbox'] != $account->sent && $params['mailbox'] != $account->trash && $params['mailbox'] != $account->drafts) {
             $linkedModels = $this->_handleAutoLinkTag($imapMessage, $response);
             $response = $this->_handleInvitations($imapMessage, $params, $response);
             $linkedModels = $this->_handleAutoContactLinkFromSender($imapMessage, $linkedModels);
             // Process found autolink tags
             if (count($linkedModels) > 0) {
                 $linkedItems = '';
                 foreach ($linkedModels as $linkedModel) {
                     $searchModel = \GO\Base\Model\SearchCacheRecord::model()->findByPk(array('model_id' => $linkedModel->pk, 'model_type_id' => $linkedModel->modelTypeId()), false, true);
                     if ($searchModel) {
                         $linkedItems .= ', <span class="em-autolink-link" onclick="GO.linkHandlers[\'' . \GO\Base\Util\String::escape_javascript($linkedModel->className()) . '\'].call(this, ' . $linkedModel->id . ');">' . $searchModel->name . ' (' . $linkedModel->localizedName . ')</span>';
                     }
                 }
                 $linkedItems = trim($linkedItems, ' ,');
                 $response['htmlbody'] = '<div class="em-autolink-message">' . sprintf(GO::t('autolinked', 'email'), $linkedItems) . '</div>' . $response['htmlbody'];
             }
         }
     }
     $response['isInSpamFolder'] = $this->_getSpamMoveMailboxName($params['uid'], $params['mailbox'], $account->id);
     $response = $this->_getContactInfo($imapMessage, $params, $response);
     $this->fireEvent('view', array(&$this, &$response, $imapMessage, $account, $params));
     $response['success'] = true;
     return $response;
 }
Example #3
0
 private function _processLinksDisplay($model, $response)
 {
     $findParams = \GO\Base\Db\FindParams::newInstance()->limit(15);
     $ignoreModelTypes = array();
     if (\GO::modules()->calendar) {
         $ignoreModelTypes[] = \GO\Calendar\Model\Event::model()->modelTypeId();
     }
     if (\GO::modules()->tasks) {
         $ignoreModelTypes[] = \GO\Tasks\Model\Task::model()->modelTypeId();
     }
     $findParams->getCriteria()->addInCondition('model_type_id', $ignoreModelTypes, 't', true, true);
     $stmt = \GO\Base\Model\SearchCacheRecord::model()->findLinks($model, $findParams);
     $store = \GO\Base\Data\Store::newInstance(\GO\Base\Model\SearchCacheRecord::model());
     $store->setStatement($stmt);
     $columnModel = $store->getColumnModel();
     $columnModel->formatColumn('link_count', '\\GO::getModel($model->model_name)->countLinks($model->model_id)');
     $columnModel->formatColumn('link_description', '$model->link_description');
     $data = $store->getData();
     $response['data']['links'] = $data['results'];
     return $response;
 }
Example #4
0
 protected function actionLinks($params)
 {
     $model = \GO::getModel($params['model_name'])->findByPk($params['model_id']);
     $store = Store::newInstance(\GO\Base\Model\SearchCacheRecord::model());
     //$model->unlink($model);
     if (!empty($params['unlinks'])) {
         $keys = json_decode($params['unlinks'], true);
         foreach ($keys as $key) {
             $key = explode(':', $key);
             $linkedModel = \GO::getModel($key[0])->findByPk($key[1]);
             $model->unlink($linkedModel);
         }
     }
     //		if(!empty($params['delete_keys'])){
     //
     //			$keys = json_decode($params['delete_keys'], true);
     //
     //			foreach($keys as $key){
     //				$key = explode(':',$key);
     //
     //				$linkedModel = \GO::getModel($key[0])->findByPk($key[1]);
     //				$linkedModel->delete();
     //			}
     //		}
     //we'll do a full text search in getStoreParams
     //		$params['match']=isset($params["query"]) ? $params["query"] : '';
     //		unset($params["query"]);
     $storeParams = $store->getDefaultParams($params)->select("t.*,l.description AS link_description");
     $storeParams->mergeWith($this->getStoreParams($params));
     //if(!empty($params['folder_id']))
     $storeParams->getCriteria()->addCondition('folder_id', $params['folder_id'], '=', 'l');
     if (isset($params['types'])) {
         $types = json_decode($params['types'], true);
         if (count($types)) {
             $storeParams->getCriteria()->addInCondition('model_type_id', $types);
         }
     }
     $stmt = \GO\Base\Model\SearchCacheRecord::model()->findLinks($model, $storeParams);
     $store->setStatement($stmt);
     $cm = $store->getColumnModel();
     $cm->formatColumn('iconCls', '"go-model-".str_replace(\'\\\\\',\'_\',$model->model_name)');
     $cm->formatColumn('name_and_type', '"(".$model->type.") ".$model->name');
     $cm->formatColumn('model_name_and_id', '$model->model_name.":".$model->model_id');
     $cm->formatColumn('link_count', '\\GO::getModel($model->model_name)->countLinks($model->model_id)');
     $data = $store->getData();
     $data['permissionLevel'] = $model->getPermissionLevel();
     return $data;
 }
Example #5
0
 /**
  * Copy links from this model to the target model.
  *
  * @param ActiveRecord $targetModel
  */
 public function copyLinks(ActiveRecord $targetModel)
 {
     if (!$this->hasLinks() || !$targetModel->hasLinks()) {
         return false;
     }
     $stmt = \GO\Base\Model\SearchCacheRecord::model()->findLinks($this);
     while ($searchCacheModel = $stmt->fetch()) {
         $targetModel->link($searchCacheModel, $searchCacheModel->link_description);
     }
     return true;
 }
Example #6
0
 public function findRecent($start = false, $limit = false)
 {
     $storeParams = \GO\Base\Db\FindParams::newInstance()->ignoreAcl();
     $joinSearchCacheCriteria = \GO\Base\Db\FindCriteria::newInstance()->addRawCondition('`t`.`id`', '`sc`.`model_id`')->addCondition('model_type_id', $this->modelTypeId(), '=', 'sc');
     $storeParams->join(\GO\Base\Model\SearchCacheRecord::model()->tableName(), $joinSearchCacheCriteria, 'sc', 'INNER');
     $aclJoinCriteria = \GO\Base\Db\FindCriteria::newInstance()->addRawCondition('a.acl_id', 'sc.acl_id', '=', false);
     $aclWhereCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('user_id', \GO::user()->id, '=', 'a', false)->addInCondition("group_id", \GO\Base\Model\User::getGroupIds(\GO::user()->id), "a", false);
     $storeParams->join(\GO\Base\Model\AclUsersGroups::model()->tableName(), $aclJoinCriteria, 'a', 'INNER');
     $storeParams->criteria(\GO\Base\Db\FindCriteria::newInstance()->addModel(Folder::model())->mergeWith($aclWhereCriteria));
     $storeParams->group(array('t.id'))->order('mtime', 'DESC');
     $storeParams->getCriteria()->addCondition('mtime', \GO\Base\Util\Date::date_add(\GO\Base\Util\Date::clear_time(time()), -7), '>');
     if ($start !== false) {
         $storeParams->start($start);
     }
     if ($limit !== false) {
         $storeParams->limit($limit);
     }
     return $this->find($storeParams);
 }
Example #7
0
 protected function beforeLoad(&$response, &$model, &$params)
 {
     if ($model->model_id > 0) {
         $modelType = \GO\Base\Model\ModelType::model()->findByPk($model->model_type_id);
         $response['data']['link'] = $modelType->model_name . ':' . $model->model_id;
         $searchCacheRecord = \GO\Base\Model\SearchCacheRecord::model()->findSingleByAttributes(array('model_id' => $model->model_id, 'model_type_id' => $model->model_type_id));
         if ($searchCacheRecord) {
             $response['data']['link_name'] = $searchCacheRecord->name;
         }
     } else {
         $response['data']['link_name'] = '';
     }
     return $response;
 }