/** * Function returns comments and recent activities across module * @param <Vtiger_Paging_Model> $pagingModel * @param <String> $type - comments, updates or all * @return <Array> */ public function getHistory($pagingModel, $type = false) { if (empty($type)) { $type = 'all'; } //TODO: need to handle security $comments = array(); if ($type == 'all' || $type == 'comments') { $modCommentsModel = Vtiger_Module_Model::getInstance('ModComments'); if ($modCommentsModel->isPermitted('DetailView')) { $comments = $this->getComments($pagingModel); } if ($type == 'comments') { return $comments; } } //As getComments api is used to get comment infomation,no need of getting //comment information again,so avoiding from modtracker //updateActivityQuery api is used to update a query to fetch a only activity if ($type == 'updates' || $type == 'all') { $db = PearDatabase::getInstance(); $queryforActivity = $this->getActivityQuery($type); $result = $db->pquery('SELECT vtiger_modtracker_basic.* FROM vtiger_modtracker_basic INNER JOIN vtiger_crmentity ON vtiger_modtracker_basic.crmid = vtiger_crmentity.crmid AND deleted = 0 ' . $queryforActivity . ' ORDER BY vtiger_modtracker_basic.id DESC LIMIT ?, ?', array($pagingModel->getStartIndex(), $pagingModel->getPageLimit())); $activites = array(); for ($i = 0; $i < $db->num_rows($result); $i++) { $row = $db->query_result_rowdata($result, $i); $moduleName = $row['module']; $recordId = $row['crmid']; if (Users_Privileges_Model::isPermitted($moduleName, 'DetailView', $recordId)) { $modTrackerRecorModel = new ModTracker_Record_Model(); $modTrackerRecorModel->setData($row)->setParent($recordId, $moduleName); $time = $modTrackerRecorModel->get('changedon'); $activites[$time] = $modTrackerRecorModel; } } } $history = array_merge($activites, $comments); $dateTime = array(); foreach ($history as $time => $model) { $dateTime[] = $time; } if (!empty($history)) { array_multisort($dateTime, SORT_DESC, SORT_STRING, $history); return $history; } return false; }
/** * Function returns comments and recent activities across module * @param <Vtiger_Paging_Model> $pagingModel * @param <String> $type - comments, updates or all * @return <Array> */ public function getHistory($pagingModel, $type = false) { global $log; $log->debug("Entering ./models/Module.php::getHistory"); if (empty($type)) { $type = 'all'; } //TODO: need to handle security $comments = array(); if ($type == 'all' || $type == 'comments') { $modCommentsModel = Vtiger_Module_Model::getInstance('ModComments'); if ($modCommentsModel->isPermitted('DetailView')) { $comments = $this->getComments($pagingModel); } if ($type == 'comments') { return $comments; } } $db = PearDatabase::getInstance(); $result = $db->pquery('SELECT vtiger_modtracker_basic.* FROM vtiger_modtracker_basic INNER JOIN vtiger_crmentity ON vtiger_modtracker_basic.crmid = vtiger_crmentity.crmid AND deleted = 0 AND module = ? ORDER BY vtiger_modtracker_basic.id DESC LIMIT ?, ?', array($this->getName(), $pagingModel->getStartIndex(), $pagingModel->getPageLimit())); $activites = array(); for ($i = 0; $i < $db->num_rows($result); $i++) { $row = $db->query_result_rowdata($result, $i); if (Users_Privileges_Model::isPermitted($row['module'], 'DetailView', $row['crmid'])) { $modTrackerRecorModel = new ModTracker_Record_Model(); $modTrackerRecorModel->setData($row)->setParent($row['crmid'], $row['module']); $time = $modTrackerRecorModel->get('changedon'); $activites[$time] = $modTrackerRecorModel; } } $history = array_merge($activites, $comments); $dateTime = array(); foreach ($history as $time => $model) { $dateTime[] = $time; } if (!empty($history)) { array_multisort($dateTime, SORT_DESC, SORT_STRING, $history); return $history; } $log->debug("Exiting ./models/Module.php::getHistory"); return false; }
/** * Function returns comments and recent activities across CRM * @param <Vtiger_Paging_Model> $pagingModel * @param <String> $type - comments, updates or all * @return <Array> */ public function getHistory($pagingModel, $type = false) { if (empty($type)) { $type = 'all'; } //TODO: need to handle security $comments = array(); if ($type == 'comments') { $modCommentsModel = Vtiger_Module_Model::getInstance('ModComments'); if ($modCommentsModel->isPermitted('DetailView')) { $comments = $this->getComments($pagingModel); } if ($type == 'comments') { return $comments; } } else { if ($type == 'updates' || $type == 'all') { $db = PearDatabase::getInstance(); $queryforActivity = $this->getActivityQuery($type); $result = $db->pquery('SELECT vtiger_modtracker_basic.* FROM vtiger_modtracker_basic INNER JOIN vtiger_crmentity ON vtiger_modtracker_basic.crmid = vtiger_crmentity.crmid AND deleted = 0 ' . $queryforActivity . ' ORDER BY vtiger_modtracker_basic.id DESC LIMIT ?, ?', array($pagingModel->getStartIndex(), $pagingModel->getPageLimit())); $history = array(); for ($i = 0; $i < $db->num_rows($result); $i++) { $row = $db->query_result_rowdata($result, $i); $moduleName = $row['module']; $recordId = $row['crmid']; if (Users_Privileges_Model::isPermitted($moduleName, 'DetailView', $recordId)) { $modTrackerRecorModel = new ModTracker_Record_Model(); $modTrackerRecorModel->setData($row)->setParent($recordId, $moduleName); $time = $modTrackerRecorModel->get('changedon'); $history[$time] = $modTrackerRecorModel; } } return $history; } } return false; }
/** * Function returns comments and recent activities across module * @param <Vtiger_Paging_Model> $pagingModel * @param <String> $type - comments, updates or all * @return <Array> */ public function getHistory($pagingModel, $type = false) { if (empty($type)) { $type = 'all'; } //TODO: need to handle security $comments = array(); if ($type == 'all' || $type == 'comments') { $comments = $this->getComments($pagingModel); if ($type == 'comments') { return $comments; } } $nonAdminAccessQuery = Users_Privileges_Model::getNonAdminAccessControlQuery('ModComments'); $db = PearDatabase::getInstance(); $result = $db->pquery('SELECT vtiger_modtracker_basic.* FROM vtiger_modtracker_basic INNER JOIN vtiger_crmentity ON vtiger_modtracker_basic.crmid = vtiger_crmentity.crmid AND deleted = 0 AND module = ? INNER JOIN vtiger_crmentity crmentity2 ON vtiger_modcomments.related_to = crmentity2.crmid AND crmentity2.deleted = 0 INNER JOIN vtiger_crmentity crmentity3 ON vtiger_modcomments.customer = crmentity3.crmid AND crmentity3.deleted = 0 ' . $nonAdminAccessQuery . ' ORDER BY vtiger_modtracker_basic.id DESC LIMIT ?, ?', array($this->getName(), $pagingModel->getStartIndex(), $pagingModel->getPageLimit())); $activites = array(); for ($i = 0; $i < $db->num_rows($result); $i++) { $row = $db->query_result_rowdata($result, $i); if (Users_Privileges_Model::isPermitted($row['module'], 'DetailView', $row['crmid'])) { $modTrackerRecorModel = new ModTracker_Record_Model(); $modTrackerRecorModel->setData($row)->setParent($row['crmid'], $row['module']); $time = $modTrackerRecorModel->get('changedon'); $activites[$time] = $modTrackerRecorModel; } } $history = array_merge($activites, $comments); $dateTime = array(); foreach ($history as $time => $model) { $dateTime[] = $time; } if (!empty($history)) { array_multisort($dateTime, SORT_DESC, SORT_STRING, $history); return $history; } return false; }