@@ -6,22 +6,22 @@ |
||
| 6 | 6 | require_once 'include/main/WebUI.php'; |
| 7 | 7 | \App\Config::$requestMode = 'API'; |
| 8 | 8 | try { |
| 9 | - if (!in_array('webservice', $enabledServices)) { |
|
| 10 | - throw new \App\Exceptions\NoPermittedToApi('Webservice - Service is not active', 403); |
|
| 11 | - } |
|
| 12 | - $controller = Api\Controller::getInstance(); |
|
| 13 | - $process = $controller->preProcess(); |
|
| 14 | - if ($process) { |
|
| 15 | - $controller->process(); |
|
| 16 | - } |
|
| 17 | - $controller->postProcess(); |
|
| 9 | + if (!in_array('webservice', $enabledServices)) { |
|
| 10 | + throw new \App\Exceptions\NoPermittedToApi('Webservice - Service is not active', 403); |
|
| 11 | + } |
|
| 12 | + $controller = Api\Controller::getInstance(); |
|
| 13 | + $process = $controller->preProcess(); |
|
| 14 | + if ($process) { |
|
| 15 | + $controller->process(); |
|
| 16 | + } |
|
| 17 | + $controller->postProcess(); |
|
| 18 | 18 | } catch (\Api\Core\Exception $e) { |
| 19 | - $e->handleError(); |
|
| 19 | + $e->handleError(); |
|
| 20 | 20 | } catch (\App\Exceptions\NoPermittedToApi $e) { |
| 21 | - echo json_encode([ |
|
| 22 | - 'status' => 0, |
|
| 23 | - 'error' => [ |
|
| 24 | - 'message' => $e->getMessage(), |
|
| 25 | - ], |
|
| 26 | - ]); |
|
| 21 | + echo json_encode([ |
|
| 22 | + 'status' => 0, |
|
| 23 | + 'error' => [ |
|
| 24 | + 'message' => $e->getMessage(), |
|
| 25 | + ], |
|
| 26 | + ]); |
|
| 27 | 27 | } |
@@ -8,9 +8,9 @@ discard block |
||
| 8 | 8 | /* +******** active services *********** */ |
| 9 | 9 | //List of active services. To enable you must uncomment the appropriate line. |
| 10 | 10 | $enabledServices = [ |
| 11 | - //'dav', |
|
| 12 | - //'webservices', |
|
| 13 | - //'webservice', |
|
| 11 | + //'dav', |
|
| 12 | + //'webservices', |
|
| 13 | + //'webservice', |
|
| 14 | 14 | ]; |
| 15 | 15 | /* +*************** DAV **************** */ |
| 16 | 16 | $enableBrowser = false; |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | /* +********* Webservice config ********* */ |
| 22 | 22 | $API_CONFIG = [ |
| 23 | - 'ENCRYPT_DATA_TRANSFER' => false, |
|
| 24 | - 'AUTH_METHOD' => 'Basic', |
|
| 25 | - 'PRIVATE_KEY' => 'config/private.key', |
|
| 26 | - 'PUBLIC_KEY' => 'config/public.key', |
|
| 23 | + 'ENCRYPT_DATA_TRANSFER' => false, |
|
| 24 | + 'AUTH_METHOD' => 'Basic', |
|
| 25 | + 'PRIVATE_KEY' => 'config/private.key', |
|
| 26 | + 'PUBLIC_KEY' => 'config/public.key', |
|
| 27 | 27 | ]; |
@@ -6,16 +6,16 @@ |
||
| 6 | 6 | * @license YetiForce Public License 3.0 (licenses/LicenseEN.txt or yetiforce.com) |
| 7 | 7 | */ |
| 8 | 8 | $DEVELOPER_CONFIG = [ |
| 9 | - // Turn the possibility to change generatedtype |
|
| 10 | - 'CHANGE_GENERATEDTYPE' => false, |
|
| 11 | - // Enable minimize JS files |
|
| 12 | - 'MINIMIZE_JS' => true, |
|
| 13 | - // Enable minimize CSS files |
|
| 14 | - 'MINIMIZE_CSS' => true, |
|
| 15 | - // Change of fields visibility |
|
| 16 | - 'CHANGE_VISIBILITY' => false, |
|
| 17 | - // Adding/Deleting relations between modules. |
|
| 18 | - 'CHANGE_RELATIONS' => false, |
|
| 19 | - // Developer libraries update mode |
|
| 20 | - 'MISSING_LIBRARY_DEV_MODE' => false, |
|
| 9 | + // Turn the possibility to change generatedtype |
|
| 10 | + 'CHANGE_GENERATEDTYPE' => false, |
|
| 11 | + // Enable minimize JS files |
|
| 12 | + 'MINIMIZE_JS' => true, |
|
| 13 | + // Enable minimize CSS files |
|
| 14 | + 'MINIMIZE_CSS' => true, |
|
| 15 | + // Change of fields visibility |
|
| 16 | + 'CHANGE_VISIBILITY' => false, |
|
| 17 | + // Adding/Deleting relations between modules. |
|
| 18 | + 'CHANGE_RELATIONS' => false, |
|
| 19 | + // Developer libraries update mode |
|
| 20 | + 'MISSING_LIBRARY_DEV_MODE' => false, |
|
| 21 | 21 | ]; |
@@ -10,203 +10,203 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class Vtiger_HistoryRelation_Widget extends Vtiger_Basic_Widget |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * Names od classes that define color. |
|
| 15 | - * |
|
| 16 | - * @var string[] |
|
| 17 | - */ |
|
| 18 | - public static $colors = [ |
|
| 19 | - 'ModComments' => 'bg-primary', |
|
| 20 | - 'OSSMailViewReceived' => 'bg-danger', |
|
| 21 | - 'OSSMailViewSent' => 'bg-success', |
|
| 22 | - 'OSSMailViewInternal' => 'bg-primary', |
|
| 23 | - 'Calendar' => 'bg-warning', |
|
| 24 | - ]; |
|
| 13 | + /** |
|
| 14 | + * Names od classes that define color. |
|
| 15 | + * |
|
| 16 | + * @var string[] |
|
| 17 | + */ |
|
| 18 | + public static $colors = [ |
|
| 19 | + 'ModComments' => 'bg-primary', |
|
| 20 | + 'OSSMailViewReceived' => 'bg-danger', |
|
| 21 | + 'OSSMailViewSent' => 'bg-success', |
|
| 22 | + 'OSSMailViewInternal' => 'bg-primary', |
|
| 23 | + 'Calendar' => 'bg-warning', |
|
| 24 | + ]; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Function gets modules name. |
|
| 28 | - * |
|
| 29 | - * @return string[] |
|
| 30 | - */ |
|
| 31 | - public static function getActions() |
|
| 32 | - { |
|
| 33 | - $modules = ['ModComments', 'OSSMailView', 'Calendar']; |
|
| 34 | - foreach ($modules as $key => $module) { |
|
| 35 | - if (!\App\Privilege::isPermitted($module)) { |
|
| 36 | - unset($modules[$key]); |
|
| 37 | - } |
|
| 38 | - } |
|
| 26 | + /** |
|
| 27 | + * Function gets modules name. |
|
| 28 | + * |
|
| 29 | + * @return string[] |
|
| 30 | + */ |
|
| 31 | + public static function getActions() |
|
| 32 | + { |
|
| 33 | + $modules = ['ModComments', 'OSSMailView', 'Calendar']; |
|
| 34 | + foreach ($modules as $key => $module) { |
|
| 35 | + if (!\App\Privilege::isPermitted($module)) { |
|
| 36 | + unset($modules[$key]); |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - return $modules; |
|
| 41 | - } |
|
| 40 | + return $modules; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public function getUrl() |
|
| 44 | - { |
|
| 45 | - $url = 'module='.$this->Module.'&view=Detail&record='.$this->Record.'&mode=showRecentRelation&page=1&limit='.$this->Data['limit']; |
|
| 46 | - foreach (self::getActions() as $type) { |
|
| 47 | - $url .= '&type[]='.$type; |
|
| 48 | - } |
|
| 43 | + public function getUrl() |
|
| 44 | + { |
|
| 45 | + $url = 'module='.$this->Module.'&view=Detail&record='.$this->Record.'&mode=showRecentRelation&page=1&limit='.$this->Data['limit']; |
|
| 46 | + foreach (self::getActions() as $type) { |
|
| 47 | + $url .= '&type[]='.$type; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - return $url; |
|
| 51 | - } |
|
| 50 | + return $url; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function getWidget() |
|
| 54 | - { |
|
| 55 | - $this->Config['tpl'] = 'HistoryRelation.tpl'; |
|
| 56 | - $this->Config['url'] = $this->getUrl(); |
|
| 57 | - $widget = $this->Config; |
|
| 53 | + public function getWidget() |
|
| 54 | + { |
|
| 55 | + $this->Config['tpl'] = 'HistoryRelation.tpl'; |
|
| 56 | + $this->Config['url'] = $this->getUrl(); |
|
| 57 | + $widget = $this->Config; |
|
| 58 | 58 | |
| 59 | - return $widget; |
|
| 60 | - } |
|
| 59 | + return $widget; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - public function getConfigTplName() |
|
| 63 | - { |
|
| 64 | - return 'HistoryRelationConfig'; |
|
| 65 | - } |
|
| 62 | + public function getConfigTplName() |
|
| 63 | + { |
|
| 64 | + return 'HistoryRelationConfig'; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Function gets records for timeline widget. |
|
| 69 | - * |
|
| 70 | - * @param \App\Request $request |
|
| 71 | - * @param Vtiger_Paging_Model $pagingModel |
|
| 72 | - * |
|
| 73 | - * @return array - List of records |
|
| 74 | - */ |
|
| 75 | - public static function getHistory(\App\Request $request, Vtiger_Paging_Model $pagingModel) |
|
| 76 | - { |
|
| 77 | - $recordId = $request->getInteger('record'); |
|
| 78 | - if ($request->isEmpty('type')) { |
|
| 79 | - return []; |
|
| 80 | - } |
|
| 81 | - $query = static::getQuery($recordId, $request->getModule(), $request->get('type')); |
|
| 82 | - if (empty($query)) { |
|
| 83 | - return []; |
|
| 84 | - } |
|
| 85 | - $startIndex = $pagingModel->getStartIndex(); |
|
| 86 | - $pageLimit = $pagingModel->getPageLimit(); |
|
| 67 | + /** |
|
| 68 | + * Function gets records for timeline widget. |
|
| 69 | + * |
|
| 70 | + * @param \App\Request $request |
|
| 71 | + * @param Vtiger_Paging_Model $pagingModel |
|
| 72 | + * |
|
| 73 | + * @return array - List of records |
|
| 74 | + */ |
|
| 75 | + public static function getHistory(\App\Request $request, Vtiger_Paging_Model $pagingModel) |
|
| 76 | + { |
|
| 77 | + $recordId = $request->getInteger('record'); |
|
| 78 | + if ($request->isEmpty('type')) { |
|
| 79 | + return []; |
|
| 80 | + } |
|
| 81 | + $query = static::getQuery($recordId, $request->getModule(), $request->get('type')); |
|
| 82 | + if (empty($query)) { |
|
| 83 | + return []; |
|
| 84 | + } |
|
| 85 | + $startIndex = $pagingModel->getStartIndex(); |
|
| 86 | + $pageLimit = $pagingModel->getPageLimit(); |
|
| 87 | 87 | |
| 88 | - $query->limit($pageLimit)->offset($startIndex); |
|
| 89 | - $history = []; |
|
| 90 | - $groups = Settings_Groups_Record_Model::getAll(); |
|
| 91 | - $groupIds = array_keys($groups); |
|
| 92 | - $dataReader = $query->createCommand()->query(); |
|
| 93 | - while ($row = $dataReader->read()) { |
|
| 94 | - if (in_array($row['user'], $groupIds)) { |
|
| 95 | - $row['isGroup'] = true; |
|
| 96 | - $row['userModel'] = $groups[$row['user']]; |
|
| 97 | - } else { |
|
| 98 | - $row['isGroup'] = false; |
|
| 99 | - $row['userModel'] = Users_Privileges_Model::getInstanceById($row['user']); |
|
| 100 | - } |
|
| 101 | - $row['class'] = self::$colors[$row['type']]; |
|
| 102 | - if (strpos($row['type'], 'OSSMailView') !== false) { |
|
| 103 | - $row['type'] = 'OSSMailView'; |
|
| 104 | - $row['url'] = Vtiger_Module_Model::getInstance('OSSMailView')->getPreviewViewUrl($row['id']); |
|
| 105 | - } else { |
|
| 106 | - $row['url'] = Vtiger_Module_Model::getInstance($row['type'])->getDetailViewUrl($row['id']); |
|
| 107 | - } |
|
| 108 | - $body = trim(App\Purifier::purify($row['body'])); |
|
| 109 | - if (!$request->getBoolean('isFullscreen')) { |
|
| 110 | - $body = App\TextParser::textTruncate($body, 100); |
|
| 111 | - } else { |
|
| 112 | - $body = str_replace(['<p></p>', '<p class="MsoNormal">'], ["\r\n", "\r\n"], App\Purifier::decodeHtml(App\Purifier::purify($body))); |
|
| 113 | - $body = nl2br(App\TextParser::textTruncate($body, 500), false); |
|
| 114 | - } |
|
| 115 | - $row['body'] = $body; |
|
| 116 | - $history[] = $row; |
|
| 117 | - } |
|
| 88 | + $query->limit($pageLimit)->offset($startIndex); |
|
| 89 | + $history = []; |
|
| 90 | + $groups = Settings_Groups_Record_Model::getAll(); |
|
| 91 | + $groupIds = array_keys($groups); |
|
| 92 | + $dataReader = $query->createCommand()->query(); |
|
| 93 | + while ($row = $dataReader->read()) { |
|
| 94 | + if (in_array($row['user'], $groupIds)) { |
|
| 95 | + $row['isGroup'] = true; |
|
| 96 | + $row['userModel'] = $groups[$row['user']]; |
|
| 97 | + } else { |
|
| 98 | + $row['isGroup'] = false; |
|
| 99 | + $row['userModel'] = Users_Privileges_Model::getInstanceById($row['user']); |
|
| 100 | + } |
|
| 101 | + $row['class'] = self::$colors[$row['type']]; |
|
| 102 | + if (strpos($row['type'], 'OSSMailView') !== false) { |
|
| 103 | + $row['type'] = 'OSSMailView'; |
|
| 104 | + $row['url'] = Vtiger_Module_Model::getInstance('OSSMailView')->getPreviewViewUrl($row['id']); |
|
| 105 | + } else { |
|
| 106 | + $row['url'] = Vtiger_Module_Model::getInstance($row['type'])->getDetailViewUrl($row['id']); |
|
| 107 | + } |
|
| 108 | + $body = trim(App\Purifier::purify($row['body'])); |
|
| 109 | + if (!$request->getBoolean('isFullscreen')) { |
|
| 110 | + $body = App\TextParser::textTruncate($body, 100); |
|
| 111 | + } else { |
|
| 112 | + $body = str_replace(['<p></p>', '<p class="MsoNormal">'], ["\r\n", "\r\n"], App\Purifier::decodeHtml(App\Purifier::purify($body))); |
|
| 113 | + $body = nl2br(App\TextParser::textTruncate($body, 500), false); |
|
| 114 | + } |
|
| 115 | + $row['body'] = $body; |
|
| 116 | + $history[] = $row; |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - return $history; |
|
| 120 | - } |
|
| 119 | + return $history; |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * Function creates database query in order to get records for timeline widget. |
|
| 124 | - * |
|
| 125 | - * @param int $recordId |
|
| 126 | - * @param string $moduleName |
|
| 127 | - * @param array $type |
|
| 128 | - * |
|
| 129 | - * @return \App\Db\Query()|false |
|
| 130 | - */ |
|
| 131 | - public static function getQuery($recordId, $moduleName, $type) |
|
| 132 | - { |
|
| 133 | - $queries = []; |
|
| 134 | - $field = \App\ModuleHierarchy::getMappingRelatedField($moduleName); |
|
| 135 | - $db = App\Db::getInstance(); |
|
| 136 | - if (in_array('Calendar', $type)) { |
|
| 137 | - $query = (new \App\Db\Query()) |
|
| 138 | - ->select([ |
|
| 139 | - 'body' => new \yii\db\Expression($db->quoteValue('')), |
|
| 140 | - 'attachments_exist' => new \yii\db\Expression($db->quoteValue('')), |
|
| 141 | - 'type' => new \yii\db\Expression($db->quoteValue('Calendar')), |
|
| 142 | - 'id' => 'vtiger_crmentity.crmid', |
|
| 143 | - 'content' => 'a.subject', |
|
| 144 | - 'user' => 'vtiger_crmentity.smownerid', |
|
| 145 | - 'time' => new \yii\db\Expression('CONCAT(a.date_start, '.$db->quoteValue(' ').', a.time_start)'), |
|
| 146 | - ]) |
|
| 147 | - ->from('vtiger_activity a') |
|
| 148 | - ->innerJoin('vtiger_crmentity', 'vtiger_crmentity.crmid = a.activityid') |
|
| 149 | - ->where(['vtiger_crmentity.deleted' => 0]) |
|
| 150 | - ->andWhere(['=', 'a.'.$field, $recordId]); |
|
| 151 | - \App\PrivilegeQuery::getConditions($query, 'Calendar', false, $recordId); |
|
| 152 | - $queries[] = $query; |
|
| 153 | - } |
|
| 154 | - if (in_array('ModComments', $type)) { |
|
| 155 | - $query = (new \App\Db\Query()) |
|
| 156 | - ->select([ |
|
| 157 | - 'body' => new \yii\db\Expression($db->quoteValue('')), |
|
| 158 | - 'attachments_exist' => new \yii\db\Expression($db->quoteValue('')), |
|
| 159 | - 'type' => new \yii\db\Expression($db->quoteValue('ModComments')), |
|
| 160 | - 'id' => 'm.modcommentsid', |
|
| 161 | - 'content' => 'm.commentcontent', |
|
| 162 | - 'user' => 'vtiger_crmentity.smownerid', |
|
| 163 | - 'time' => 'vtiger_crmentity.createdtime', |
|
| 164 | - ]) |
|
| 165 | - ->from('vtiger_modcomments m') |
|
| 166 | - ->innerJoin('vtiger_crmentity', 'vtiger_crmentity.crmid = m.modcommentsid') |
|
| 167 | - ->where(['vtiger_crmentity.deleted' => 0]) |
|
| 168 | - ->andWhere(['=', 'related_to', $recordId]); |
|
| 169 | - \App\PrivilegeQuery::getConditions($query, 'ModComments', false, $recordId); |
|
| 170 | - $queries[] = $query; |
|
| 171 | - } |
|
| 172 | - if (in_array('OSSMailView', $type)) { |
|
| 173 | - $query = (new \App\Db\Query()) |
|
| 174 | - ->select([ |
|
| 175 | - 'body' => 'o.content', |
|
| 176 | - 'attachments_exist', |
|
| 177 | - 'type' => new \yii\db\Expression('CONCAT(\'OSSMailView\', o.ossmailview_sendtype)'), |
|
| 178 | - 'id' => 'o.ossmailviewid', |
|
| 179 | - 'content' => 'o.subject', |
|
| 180 | - 'user' => 'vtiger_crmentity.smownerid', |
|
| 181 | - 'time' => 'vtiger_crmentity.createdtime', |
|
| 182 | - ]) |
|
| 183 | - ->from('vtiger_ossmailview o') |
|
| 184 | - ->innerJoin('vtiger_crmentity', 'vtiger_crmentity.crmid = o.ossmailviewid') |
|
| 185 | - ->innerJoin('vtiger_ossmailview_relation r', 'r.ossmailviewid = o.ossmailviewid ') |
|
| 186 | - ->where(['vtiger_crmentity.deleted' => 0]) |
|
| 187 | - ->andWhere(['=', 'r.crmid', $recordId]); |
|
| 188 | - \App\PrivilegeQuery::getConditions($query, 'OSSMailView', false, $recordId); |
|
| 189 | - $queries[] = $query; |
|
| 190 | - } |
|
| 191 | - if (count($queries) == 1) { |
|
| 192 | - $sql = reset($queries); |
|
| 193 | - } else { |
|
| 194 | - $subQuery = reset($queries); |
|
| 195 | - $index = 0; |
|
| 196 | - foreach ($queries as $query) { |
|
| 197 | - if ($index !== 0) { |
|
| 198 | - $subQuery->union($query, true); |
|
| 199 | - } |
|
| 122 | + /** |
|
| 123 | + * Function creates database query in order to get records for timeline widget. |
|
| 124 | + * |
|
| 125 | + * @param int $recordId |
|
| 126 | + * @param string $moduleName |
|
| 127 | + * @param array $type |
|
| 128 | + * |
|
| 129 | + * @return \App\Db\Query()|false |
|
| 130 | + */ |
|
| 131 | + public static function getQuery($recordId, $moduleName, $type) |
|
| 132 | + { |
|
| 133 | + $queries = []; |
|
| 134 | + $field = \App\ModuleHierarchy::getMappingRelatedField($moduleName); |
|
| 135 | + $db = App\Db::getInstance(); |
|
| 136 | + if (in_array('Calendar', $type)) { |
|
| 137 | + $query = (new \App\Db\Query()) |
|
| 138 | + ->select([ |
|
| 139 | + 'body' => new \yii\db\Expression($db->quoteValue('')), |
|
| 140 | + 'attachments_exist' => new \yii\db\Expression($db->quoteValue('')), |
|
| 141 | + 'type' => new \yii\db\Expression($db->quoteValue('Calendar')), |
|
| 142 | + 'id' => 'vtiger_crmentity.crmid', |
|
| 143 | + 'content' => 'a.subject', |
|
| 144 | + 'user' => 'vtiger_crmentity.smownerid', |
|
| 145 | + 'time' => new \yii\db\Expression('CONCAT(a.date_start, '.$db->quoteValue(' ').', a.time_start)'), |
|
| 146 | + ]) |
|
| 147 | + ->from('vtiger_activity a') |
|
| 148 | + ->innerJoin('vtiger_crmentity', 'vtiger_crmentity.crmid = a.activityid') |
|
| 149 | + ->where(['vtiger_crmentity.deleted' => 0]) |
|
| 150 | + ->andWhere(['=', 'a.'.$field, $recordId]); |
|
| 151 | + \App\PrivilegeQuery::getConditions($query, 'Calendar', false, $recordId); |
|
| 152 | + $queries[] = $query; |
|
| 153 | + } |
|
| 154 | + if (in_array('ModComments', $type)) { |
|
| 155 | + $query = (new \App\Db\Query()) |
|
| 156 | + ->select([ |
|
| 157 | + 'body' => new \yii\db\Expression($db->quoteValue('')), |
|
| 158 | + 'attachments_exist' => new \yii\db\Expression($db->quoteValue('')), |
|
| 159 | + 'type' => new \yii\db\Expression($db->quoteValue('ModComments')), |
|
| 160 | + 'id' => 'm.modcommentsid', |
|
| 161 | + 'content' => 'm.commentcontent', |
|
| 162 | + 'user' => 'vtiger_crmentity.smownerid', |
|
| 163 | + 'time' => 'vtiger_crmentity.createdtime', |
|
| 164 | + ]) |
|
| 165 | + ->from('vtiger_modcomments m') |
|
| 166 | + ->innerJoin('vtiger_crmentity', 'vtiger_crmentity.crmid = m.modcommentsid') |
|
| 167 | + ->where(['vtiger_crmentity.deleted' => 0]) |
|
| 168 | + ->andWhere(['=', 'related_to', $recordId]); |
|
| 169 | + \App\PrivilegeQuery::getConditions($query, 'ModComments', false, $recordId); |
|
| 170 | + $queries[] = $query; |
|
| 171 | + } |
|
| 172 | + if (in_array('OSSMailView', $type)) { |
|
| 173 | + $query = (new \App\Db\Query()) |
|
| 174 | + ->select([ |
|
| 175 | + 'body' => 'o.content', |
|
| 176 | + 'attachments_exist', |
|
| 177 | + 'type' => new \yii\db\Expression('CONCAT(\'OSSMailView\', o.ossmailview_sendtype)'), |
|
| 178 | + 'id' => 'o.ossmailviewid', |
|
| 179 | + 'content' => 'o.subject', |
|
| 180 | + 'user' => 'vtiger_crmentity.smownerid', |
|
| 181 | + 'time' => 'vtiger_crmentity.createdtime', |
|
| 182 | + ]) |
|
| 183 | + ->from('vtiger_ossmailview o') |
|
| 184 | + ->innerJoin('vtiger_crmentity', 'vtiger_crmentity.crmid = o.ossmailviewid') |
|
| 185 | + ->innerJoin('vtiger_ossmailview_relation r', 'r.ossmailviewid = o.ossmailviewid ') |
|
| 186 | + ->where(['vtiger_crmentity.deleted' => 0]) |
|
| 187 | + ->andWhere(['=', 'r.crmid', $recordId]); |
|
| 188 | + \App\PrivilegeQuery::getConditions($query, 'OSSMailView', false, $recordId); |
|
| 189 | + $queries[] = $query; |
|
| 190 | + } |
|
| 191 | + if (count($queries) == 1) { |
|
| 192 | + $sql = reset($queries); |
|
| 193 | + } else { |
|
| 194 | + $subQuery = reset($queries); |
|
| 195 | + $index = 0; |
|
| 196 | + foreach ($queries as $query) { |
|
| 197 | + if ($index !== 0) { |
|
| 198 | + $subQuery->union($query, true); |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - ++$index; |
|
| 202 | - } |
|
| 203 | - if ($subQuery) { |
|
| 204 | - $sql = (new \App\Db\Query())->from(['records' => $subQuery]); |
|
| 205 | - } else { |
|
| 206 | - return false; |
|
| 207 | - } |
|
| 208 | - } |
|
| 201 | + ++$index; |
|
| 202 | + } |
|
| 203 | + if ($subQuery) { |
|
| 204 | + $sql = (new \App\Db\Query())->from(['records' => $subQuery]); |
|
| 205 | + } else { |
|
| 206 | + return false; |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - return $sql->orderBy(['time' => SORT_DESC]); |
|
| 211 | - } |
|
| 210 | + return $sql->orderBy(['time' => SORT_DESC]); |
|
| 211 | + } |
|
| 212 | 212 | } |