当前位置: 首页>>代码示例>>PHP>>正文


PHP Vtiger_Util_Helper::getGroupsIdsForUsers方法代码示例

本文整理汇总了PHP中Vtiger_Util_Helper::getGroupsIdsForUsers方法的典型用法代码示例。如果您正苦于以下问题:PHP Vtiger_Util_Helper::getGroupsIdsForUsers方法的具体用法?PHP Vtiger_Util_Helper::getGroupsIdsForUsers怎么用?PHP Vtiger_Util_Helper::getGroupsIdsForUsers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vtiger_Util_Helper的用法示例。


在下文中一共展示了Vtiger_Util_Helper::getGroupsIdsForUsers方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initializeListViewContents


//.........这里部分代码省略.........
         $searchParmams = array();
     }
     $transformedSearchParams = $this->transferListSearchParamsToFilterCondition($searchParmams, $listViewModel->getModule());
     $listViewModel->set('search_params', $transformedSearchParams);
     //To make smarty to get the details easily accesible
     foreach ($searchParmams as $fieldListGroup) {
         foreach ($fieldListGroup as $fieldSearchInfo) {
             $fieldSearchInfo['searchValue'] = $fieldSearchInfo[2];
             $fieldSearchInfo['fieldName'] = $fieldName = $fieldSearchInfo[0];
             $searchParmams[$fieldName] = $fieldSearchInfo;
         }
     }
     if (!$this->listViewHeaders) {
         $this->listViewHeaders = $listViewModel->getListViewHeaders();
     }
     if (!$this->listViewEntries) {
         $this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
     }
     $noOfEntries = count($this->listViewEntries);
     $viewer->assign('MODULE', $moduleName);
     if (!$this->listViewLinks) {
         $this->listViewLinks = $listViewModel->getListViewLinks($linkParams);
     }
     $viewer->assign('LISTVIEW_LINKS', $this->listViewLinks);
     $viewer->assign('LISTVIEW_MASSACTIONS', $linkModels['LISTVIEWMASSACTION']);
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('PAGE_NUMBER', $pageNumber);
     $viewer->assign('ORDER_BY', $orderBy);
     $viewer->assign('SORT_ORDER', $sortOrder);
     $viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
     $viewer->assign('SORT_IMAGE', $sortImage);
     $viewer->assign('COLUMN_NAME', $orderBy);
     if ($moduleName == 'SalesOrder') {
         /**
          * красим поле "сумма счета" (cf_773) или "оплата водителю"(cf_791)
          * по полям "дата оплаты счета"(cf_819) и  "водитель оплачен"/"водитель поставлен на оплату" (cf_892/897 )
          */
         $filterFields = $listViewModel->get('query_generator')->getFields();
         if (in_array('cf_773', $filterFields) || in_array('cf_791', $filterFields)) {
             $analysisFields = $listViewModel->getFieldsForPainting($this->listViewEntries);
             foreach ($this->listViewEntries as $key => &$entry) {
                 $rawData = $entry->getRawData();
                 $billPayedAt = $analysisFields[$rawData['salesorderid']]['cf_819'];
                 $driverQueue = $analysisFields[$rawData['salesorderid']]['cf_897'];
                 $driverPayed = $analysisFields[$rawData['salesorderid']]['cf_892'];
                 //дополняем значениями
                 if (!empty($billPayedAt)) {
                     $rawData['colored_bill'] = 'rgb(73, 215, 73)';
                     //нам оплатили
                 } else {
                     $rawData['colored_bill'] = '';
                     //нам не оплатили
                 }
                 if ($driverPayed == '1') {
                     $rawData['colored_driver'] = 'rgb(249, 81, 81)';
                     //если оплатили
                 } elseif ($driverQueue == '1') {
                     $rawData['colored_driver'] = 'yellow';
                     //поставлен в очередь на оплату
                 } else {
                     $rawData['colored_driver'] = 'white';
                     //должны
                 }
                 $this->listViewEntries[$key]->setRawData($rawData);
             }
         }
         /**
          * прописываем ширины для некоторых столбцов
          */
         $fieldsWidth = array('bill_street' => 120, 'ship_street' => 120, 'cf_864' => 120, 'smownerid' => 120, 'description' => 200);
         foreach ($this->listViewHeaders as $key => $header) {
             if (isset($fieldsWidth[$header->get('column')])) {
                 $this->listViewHeaders[$key]->set('listviewwidth', $fieldsWidth[$header->get('column')]);
             } else {
                 $this->listViewHeaders[$key]->set('listviewwidth', '');
             }
         }
     }
     $viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
         if (!$this->listViewCount) {
             $this->listViewCount = $listViewModel->getListViewCount();
         }
         $totalCount = $this->listViewCount;
         $pageLimit = $pagingModel->getPageLimit();
         $pageCount = ceil((int) $totalCount / (int) $pageLimit);
         if ($pageCount == 0) {
             $pageCount = 1;
         }
         $viewer->assign('PAGE_COUNT', $pageCount);
         $viewer->assign('LISTVIEW_COUNT', $totalCount);
     }
     $viewer->assign('LIST_VIEW_MODEL', $listViewModel);
     $viewer->assign('GROUPS_IDS', Vtiger_Util_Helper::getGroupsIdsForUsers($currentUser->getId()));
     $viewer->assign('IS_MODULE_EDITABLE', $listViewModel->getModule()->isPermitted('EditView'));
     $viewer->assign('IS_MODULE_DELETABLE', $listViewModel->getModule()->isPermitted('Delete'));
     $viewer->assign('SEARCH_DETAILS', $searchParmams);
 }
开发者ID:wsLapshin,项目名称:charter_crm,代码行数:101,代码来源:List.php

示例2: getCalendarActivities

 /**
  * Function returns the Calendar Events for the module
  * @param <String> $mode - upcoming/overdue mode
  * @param <Vtiger_Paging_Model> $pagingModel - $pagingModel
  * @param <String> $user - all/userid
  * @param <String> $recordId - record id
  * @return <Array>
  */
 function getCalendarActivities($mode, $pagingModel, $user, $recordId = false)
 {
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $db = PearDatabase::getInstance();
     if (!$user) {
         $user = $currentUser->getId();
     }
     $nowInUserFormat = Vtiger_Datetime_UIType::getDisplayDateValue(date('Y-m-d H:i:s'));
     $nowInDBFormat = Vtiger_Datetime_UIType::getDBDateTimeValue($nowInUserFormat);
     list($currentDate, $currentTime) = explode(' ', $nowInDBFormat);
     $query = "SELECT vtiger_crmentity.crmid, crmentity2.crmid AS parent_id, vtiger_crmentity.smownerid, vtiger_crmentity.setype, vtiger_activity.* FROM vtiger_activity\n\t\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_activity.activityid\n\t\t\t\t\tINNER JOIN vtiger_seactivityrel ON vtiger_seactivityrel.activityid = vtiger_activity.activityid\n\t\t\t\t\tINNER JOIN vtiger_crmentity AS crmentity2 ON vtiger_seactivityrel.crmid = crmentity2.crmid AND crmentity2.deleted = 0 AND crmentity2.setype = ?\n\t\t\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
     $query .= Users_Privileges_Model::getNonAdminAccessControlQuery('Calendar');
     $query .= " WHERE vtiger_crmentity.deleted=0\n\t\t\t\t\tAND (vtiger_activity.activitytype NOT IN ('Emails'))\n\t\t\t\t\tAND (vtiger_activity.status is NULL OR vtiger_activity.status NOT IN ('Completed', 'Deferred'))\n\t\t\t\t\tAND (vtiger_activity.eventstatus is NULL OR vtiger_activity.eventstatus NOT IN ('Held'))";
     if ($recordId) {
         $query .= " AND vtiger_seactivityrel.crmid = ?";
     } elseif ($mode === 'upcoming') {
         $query .= " AND due_date >= '{$currentDate}'";
     } elseif ($mode === 'overdue') {
         $query .= " AND due_date < '{$currentDate}'";
     }
     $params = array($this->getName());
     if ($user != 'all' && $user != '') {
         if ($user === $currentUser->id) {
             $query .= " AND vtiger_crmentity.smownerid = ?";
             array_push($params, $user);
         }
     }
     $query .= " ORDER BY date_start, time_start LIMIT " . $pagingModel->getStartIndex() . ", " . ($pagingModel->getPageLimit() + 1);
     if ($recordId) {
         array_push($params, $recordId);
     }
     $result = $db->pquery($query, $params);
     $numOfRows = $db->num_rows($result);
     $groupsIds = Vtiger_Util_Helper::getGroupsIdsForUsers($currentUser->getId());
     $activities = array();
     for ($i = 0; $i < $numOfRows; $i++) {
         $newRow = $db->query_result_rowdata($result, $i);
         $model = Vtiger_Record_Model::getCleanInstance('Calendar');
         $ownerId = $newRow['smownerid'];
         $currentUser = Users_Record_Model::getCurrentUserModel();
         $visibleFields = array('activitytype', 'date_start', 'time_start', 'due_date', 'time_end', 'assigned_user_id', 'visibility', 'smownerid', 'crmid');
         $visibility = true;
         if (in_array($ownerId, $groupsIds)) {
             $visibility = false;
         } else {
             if ($ownerId == $currentUser->getId()) {
                 $visibility = false;
             }
         }
         if (!$currentUser->isAdminUser() && $newRow['activitytype'] != 'Task' && $newRow['visibility'] == 'Private' && $ownerId && $visibility) {
             foreach ($newRow as $data => $value) {
                 if (in_array($data, $visibleFields) != -1) {
                     unset($newRow[$data]);
                 }
             }
             $newRow['subject'] = vtranslate('Busy', 'Events') . '*';
         }
         if ($newRow['activitytype'] == 'Task') {
             unset($newRow['visibility']);
         }
         $model->setData($newRow);
         $model->setId($newRow['crmid']);
         $activities[] = $model;
     }
     $pagingModel->calculatePageRange($activities);
     if ($numOfRows > $pagingModel->getPageLimit()) {
         array_pop($activities);
         $pagingModel->set('nextPageExists', true);
     } else {
         $pagingModel->set('nextPageExists', false);
     }
     return $activities;
 }
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:81,代码来源:Module.php

示例3: getEntries

 public function getEntries($pagingModel)
 {
     $db = PearDatabase::getInstance();
     $parentModule = $this->getParentRecordModel()->getModule();
     $relationModel = $this->getRelationModel();
     $relationModule = $relationModel->getRelationModuleModel();
     $relatedColumnFields = $relationModel->getRelationFields(true, true);
     $relationModuleName = $relationModule->get('name');
     if (count($relatedColumnFields) <= 0) {
         $relatedColumnFields = $relationModule->getConfigureRelatedListFields();
     }
     if (count($relatedColumnFields) <= 0) {
         $relatedColumnFields = $relationModule->getRelatedListFields();
     }
     if ($relationModuleName == 'Calendar') {
         //Adding visibility in the related list, showing records based on the visibility
         $relatedColumnFields['visibility'] = 'visibility';
     }
     if ($relationModuleName == 'PriceBooks') {
         //Adding fields in the related list
         $relatedColumnFields['unit_price'] = 'unit_price';
         $relatedColumnFields['listprice'] = 'listprice';
         $relatedColumnFields['currency_id'] = 'currency_id';
     }
     if ($relationModuleName == 'Documents') {
         $relatedColumnFields['filelocationtype'] = 'filelocationtype';
         $relatedColumnFields['filestatus'] = 'filestatus';
     }
     $query = $this->getRelationQuery();
     if ($this->get('whereCondition')) {
         $query = $this->updateQueryWithWhereCondition($query);
     }
     $startIndex = $pagingModel->getStartIndex();
     $pageLimit = $pagingModel->getPageLimit();
     $orderBy = $this->getForSql('orderby');
     $sortOrder = $this->getForSql('sortorder');
     if ($orderBy) {
         $orderByFieldModuleModel = $relationModule->getFieldByColumn($orderBy);
         if ($orderByFieldModuleModel && $orderByFieldModuleModel->isReferenceField()) {
             //If reference field then we need to perform a join with crmentity with the related to field
             $queryComponents = $split = spliti(' where ', $query);
             $selectAndFromClause = $queryComponents[0];
             $whereCondition = $queryComponents[1];
             $qualifiedOrderBy = 'vtiger_crmentity' . $orderByFieldModuleModel->get('column');
             $selectAndFromClause .= ' LEFT JOIN vtiger_crmentity AS ' . $qualifiedOrderBy . ' ON ' . $orderByFieldModuleModel->get('table') . '.' . $orderByFieldModuleModel->get('column') . ' = ' . $qualifiedOrderBy . '.crmid ';
             $query = $selectAndFromClause . ' WHERE ' . $whereCondition;
             $query .= ' ORDER BY ' . $qualifiedOrderBy . '.label ' . $sortOrder;
         } elseif ($orderByFieldModuleModel && $orderByFieldModuleModel->isOwnerField()) {
             $query .= ' ORDER BY COALESCE(CONCAT(vtiger_users.first_name,vtiger_users.last_name),vtiger_groups.groupname) ' . $sortOrder;
         } else {
             // Qualify the the column name with table to remove ambugity
             $qualifiedOrderBy = $orderBy;
             $orderByField = $relationModule->getFieldByColumn($orderBy);
             if ($orderByField) {
                 $qualifiedOrderBy = $relationModule->getOrderBySql($qualifiedOrderBy);
             }
             $query = "{$query} ORDER BY {$qualifiedOrderBy} {$sortOrder}";
         }
     }
     $limitQuery = $query . ' LIMIT ' . $startIndex . ',' . $pageLimit;
     $result = $db->pquery($limitQuery, array());
     $relatedRecordList = array();
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $groupsIds = Vtiger_Util_Helper::getGroupsIdsForUsers($currentUser->getId());
     while ($row = $db->fetchByAssoc($result)) {
         $recordId = $row['crmid'];
         $newRow = array();
         foreach ($row as $col => $val) {
             if (array_key_exists($col, $relatedColumnFields)) {
                 if ($relationModuleName == 'Documents' && $col == 'filename') {
                     $fileName = $row['filename'];
                     $downloadType = $row['filelocationtype'];
                     $status = $row['filestatus'];
                     $fileIdQuery = "select attachmentsid from vtiger_seattachmentsrel where crmid=?";
                     $fileIdRes = $db->pquery($fileIdQuery, array($recordId));
                     $fileId = $db->query_result($fileIdRes, 0, 'attachmentsid');
                     if ($fileName != '' && $status == 1) {
                         if ($downloadType == 'I') {
                             $val = '<a onclick="Javascript:Documents_Index_Js.updateDownloadCount(\'index.php?module=Documents&action=UpdateDownloadCount&record=' . $recordId . '\');"' . ' href="index.php?module=Documents&action=DownloadFile&record=' . $recordId . '&fileid=' . $fileId . '"' . ' title="' . getTranslatedString('LBL_DOWNLOAD_FILE', $relationModuleName) . '" >' . textlength_check($val) . '</a>';
                         } elseif ($downloadType == 'E') {
                             $val = '<a onclick="Javascript:Documents_Index_Js.updateDownloadCount(\'index.php?module=Documents&action=UpdateDownloadCount&record=' . $recordId . '\');"' . ' href="' . $fileName . '" target="_blank"' . ' title="' . getTranslatedString('LBL_DOWNLOAD_FILE', $relationModuleName) . '" >' . textlength_check($val) . '</a>';
                         } else {
                             $val = ' --';
                         }
                     }
                 }
                 $newRow[$relatedColumnFields[$col]] = $val;
             }
         }
         //To show the value of "Assigned to"
         $ownerId = $row['smownerid'];
         $newRow['assigned_user_id'] = $row['smownerid'];
         if ($relationModuleName == 'Calendar') {
             $visibleFields = array('activitytype', 'date_start', 'time_start', 'due_date', 'time_end', 'assigned_user_id', 'visibility', 'smownerid', 'parent_id');
             $visibility = true;
             if (in_array($ownerId, $groupsIds)) {
                 $visibility = false;
             } else {
                 if ($ownerId == $currentUser->getId()) {
                     $visibility = false;
//.........这里部分代码省略.........
开发者ID:vinzdrance,项目名称:YetiForceCRM,代码行数:101,代码来源:RelationListView.php

示例4: getCalendarActivities

 /**
  * Function returns the Calendar Events for the module
  * @param <String> $mode - upcoming/overdue mode
  * @param <Vtiger_Paging_Model> $pagingModel - $pagingModel
  * @param <String> $user - all/userid
  * @param <String> $recordId - record id
  * @return <Array>
  */
 function getCalendarActivities($mode, $pagingModel, $user, $recordId = false)
 {
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $db = PearDatabase::getInstance();
     if (!$user) {
         $user = $currentUser->getId();
     }
     $currentActivityLabels = Calendar_Module_Model::getComponentActivityStateLabel('current');
     $nowInUserFormat = Vtiger_Datetime_UIType::getDisplayDateValue(date('Y-m-d H:i:s'));
     $nowInDBFormat = Vtiger_Datetime_UIType::getDBDateTimeValue($nowInUserFormat);
     list($currentDate, $currentTime) = explode(' ', $nowInDBFormat);
     if (in_array($this->getName(), ['Accounts', 'Leads', 'Contacts', 'Vendors', 'OSSEmployees'])) {
         $relationField = 'link';
     }
     if (in_array($this->getName(), ['Campaigns', 'HelpDesk', 'Potentials', 'Project', 'ServiceContracts'])) {
         $relationField = 'process';
     }
     $query = "SELECT vtiger_crmentity.crmid, crmentity2.crmid AS parent_id, vtiger_crmentity.description as description, vtiger_crmentity.smownerid, vtiger_crmentity.smcreatorid, vtiger_crmentity.setype, vtiger_activity.* FROM vtiger_activity\n\t\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_activity.activityid\n\t\t\t\t\tINNER JOIN vtiger_crmentity AS crmentity2 ON vtiger_activity." . $relationField . " = crmentity2.crmid AND crmentity2.deleted = 0 AND crmentity2.setype = ?\n\t\t\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid WHERE vtiger_crmentity.deleted=0";
     $params = [$this->getName()];
     if ($recordId) {
         $query .= ' AND vtiger_activity.' . $relationField . ' = ?';
         array_push($params, $recordId);
     }
     if ($mode === 'current') {
         $query .= " AND (vtiger_activity.activitytype NOT IN ('Emails') AND vtiger_activity.status IN (" . generateQuestionMarks($currentActivityLabels) . "))";
         $params = array_merge($params, $currentActivityLabels);
     } elseif ($mode === 'history') {
         $query .= " AND (vtiger_activity.activitytype NOT IN ('Emails') AND vtiger_activity.status NOT IN (" . generateQuestionMarks($currentActivityLabels) . "))";
         $params = array_merge($params, $currentActivityLabels);
     } elseif ($mode === 'upcoming') {
         $query .= " AND (vtiger_activity.activitytype NOT IN ('Emails'))\n\t\t\t\t\tAND (vtiger_activity.status is NULL OR vtiger_activity.status NOT IN ('Completed', 'Deferred'))";
         $query .= " AND due_date >= '{$currentDate}'";
     } elseif ($mode === 'overdue') {
         $query .= " AND (vtiger_activity.activitytype NOT IN ('Emails'))\n\t\t\t\t\tAND (vtiger_activity.status is NULL OR vtiger_activity.status NOT IN ('Completed', 'Deferred'))";
         $query .= " AND due_date < '{$currentDate}'";
     }
     if ($user != 'all' && $user != '') {
         if ($user === $currentUser->id) {
             $query .= " AND vtiger_crmentity.smownerid = ?";
             array_push($params, $user);
         }
     }
     $moduleName = 'Calendar';
     $instance = CRMEntity::getInstance($moduleName);
     $securityParameter = $instance->getUserAccessConditionsQuerySR($moduleName, $currentUser, $recordId);
     if ($securityParameter != '') {
         $query .= $securityParameter;
     }
     $query .= " ORDER BY date_start, time_start LIMIT " . $pagingModel->getStartIndex() . ", " . ($pagingModel->getPageLimit() + 1);
     $result = $db->pquery($query, $params);
     $numOfRows = $db->num_rows($result);
     $groupsIds = Vtiger_Util_Helper::getGroupsIdsForUsers($currentUser->getId());
     $activities = array();
     for ($i = 0; $i < $numOfRows; $i++) {
         $newRow = $db->query_result_rowdata($result, $i);
         $model = Vtiger_Record_Model::getCleanInstance('Calendar');
         $ownerId = $newRow['smownerid'];
         $currentUser = Users_Record_Model::getCurrentUserModel();
         $visibleFields = array('activitytype', 'date_start', 'time_start', 'due_date', 'time_end', 'assigned_user_id', 'visibility', 'smownerid', 'crmid');
         $visibility = true;
         if (in_array($ownerId, $groupsIds)) {
             $visibility = false;
         } else {
             if ($ownerId == $currentUser->getId()) {
                 $visibility = false;
             }
         }
         if (!$currentUser->isAdminUser() && $newRow['activitytype'] != 'Task' && $newRow['visibility'] == 'Private' && $ownerId && $visibility) {
             foreach ($newRow as $data => $value) {
                 if (in_array($data, $visibleFields) != -1) {
                     unset($newRow[$data]);
                 }
             }
             $newRow['subject'] = vtranslate('Busy', 'Events') . '*';
         }
         if ($newRow['activitytype'] == 'Task') {
             unset($newRow['visibility']);
         }
         $sql = "SELECT * FROM vtiger_invitees WHERE activityid = '" . $newRow['crmid'] . "'";
         $result_invitees = $db->query($sql);
         while ($recordinfo = $db->fetch_array($result_invitees)) {
             $newRow['selectedusers'][] = $recordinfo['inviteeid'];
         }
         $model->setData($newRow);
         $model->setId($newRow['crmid']);
         $activities[] = $model;
     }
     $pagingModel->calculatePageRange($activities);
     if ($numOfRows > $pagingModel->getPageLimit()) {
         array_pop($activities);
         $pagingModel->set('nextPageExists', true);
     } else {
//.........这里部分代码省略.........
开发者ID:noclav,项目名称:UpdatePackages,代码行数:101,代码来源:Module.php

示例5: getListViewEntries


//.........这里部分代码省略.........
     //To combine date and time fields for sorting
     if ($orderBy == 'date_start') {
         $orderBy = "str_to_date(concat(date_start,time_start),'%Y-%m-%d %H:%i:%s')";
     } else {
         if ($orderBy == 'due_date') {
             $orderBy = "str_to_date(concat(due_date,time_end),'%Y-%m-%d %H:%i:%s')";
         }
     }
     $listQuery = $this->getQuery();
     if ($searchResult && $searchResult != '' && is_array($searchResult)) {
         $listQuery .= " AND vtiger_crmentity.crmid IN (" . implode(', ', $searchResult) . ") ";
     }
     unset($searchResult);
     $sourceModule = $this->get('src_module');
     if (!empty($sourceModule)) {
         if (method_exists($moduleModel, 'getQueryByModuleField')) {
             $overrideQuery = $moduleModel->getQueryByModuleField($sourceModule, $this->get('src_field'), $this->get('src_record'), $listQuery);
             if (!empty($overrideQuery)) {
                 $listQuery = $overrideQuery;
             }
         }
     }
     $startIndex = $pagingModel->getStartIndex();
     $pageLimit = $pagingModel->getPageLimit();
     if (!empty($orderBy)) {
         if ($orderByFieldModel && $orderByFieldModel->isReferenceField()) {
             $referenceModules = $orderByFieldModel->getReferenceList();
             $referenceNameFieldOrderBy = array();
             foreach ($referenceModules as $referenceModuleName) {
                 $referenceModuleModel = Vtiger_Module_Model::getInstance($referenceModuleName);
                 $referenceNameFields = $referenceModuleModel->getNameFields();
                 $columnList = array();
                 foreach ($referenceNameFields as $nameField) {
                     $fieldModel = $referenceModuleModel->getField($nameField);
                     $columnList[] = $fieldModel->get('table') . $orderByFieldModel->getName() . '.' . $fieldModel->get('column');
                 }
                 if (count($columnList) > 1) {
                     $referenceNameFieldOrderBy[] = getSqlForNameInDisplayFormat(array('first_name' => $columnList[0], 'last_name' => $columnList[1]), 'Users') . ' ' . $sortOrder;
                 } else {
                     $referenceNameFieldOrderBy[] = implode('', $columnList) . ' ' . $sortOrder;
                 }
             }
             $listQuery .= ' ORDER BY ' . implode(', ', $referenceNameFieldOrderBy);
         } else {
             $listQuery .= ' ORDER BY ' . $orderBy . ' ' . $sortOrder;
         }
     }
     $viewid = ListViewSession::getCurrentView($moduleName);
     if (empty($viewid)) {
         $viewid = $pagingModel->get('viewid');
     }
     $_SESSION['lvs'][$moduleName][$viewid]['start'] = $pagingModel->get('page');
     ListViewSession::setSessionQuery($moduleName, $listQuery, $viewid);
     $listQueryWithNoLimit = $listQuery;
     $listQuery .= " LIMIT {$startIndex}," . ($pageLimit + 1);
     $listResult = $db->pquery($listQuery, array());
     $listViewRecordModels = array();
     $listViewEntries = $listViewContoller->getListViewRecords($moduleFocus, $moduleName, $listResult);
     $pagingModel->calculatePageRange($listViewEntries);
     if ($db->num_rows($listResult) > $pageLimit) {
         array_pop($listViewEntries);
         $pagingModel->set('nextPageExists', true);
     } else {
         $pagingModel->set('nextPageExists', false);
     }
     $groupsIds = Vtiger_Util_Helper::getGroupsIdsForUsers($currentUser->getId());
     $index = 0;
     foreach ($listViewEntries as $recordId => $record) {
         $rawData = $db->query_result_rowdata($listResult, $index++);
         $visibleFields = array('activitytype', 'date_start', 'due_date', 'assigned_user_id', 'visibility', 'smownerid');
         $ownerId = $rawData['smownerid'];
         $visibility = true;
         if (in_array($ownerId, $groupsIds)) {
             $visibility = false;
         } else {
             if ($ownerId == $currentUser->getId()) {
                 $visibility = false;
             }
         }
         if (!$currentUser->isAdminUser() && $rawData['activitytype'] != 'Task' && $rawData['visibility'] == 'Private' && $ownerId && $visibility) {
             foreach ($record as $data => $value) {
                 if (in_array($data, $visibleFields) != -1) {
                     unset($rawData[$data]);
                     unset($record[$data]);
                 }
             }
             $record['subject'] = vtranslate('Busy', 'Events') . '*';
         }
         if ($record['activitytype'] == 'Task') {
             unset($record['visibility']);
             unset($rawData['visibility']);
         }
         $record['id'] = $recordId;
         $listViewRecordModels[$recordId] = $moduleModel->getRecordFromArray($record, $rawData);
         $listViewRecordModels[$recordId]->lockEditView = Users_Privileges_Model::checkLockEdit($moduleName, $recordId);
         $listViewRecordModels[$recordId]->isPermittedToEditView = Users_Privileges_Model::isPermitted($moduleName, 'EditView  ', $recordId);
         $listViewRecordModels[$recordId]->colorList = Settings_DataAccess_Module_Model::executeColorListHandlers($moduleName, $recordId, $listViewRecordModels[$recordId]);
     }
     return $listViewRecordModels;
 }
开发者ID:reeid,项目名称:YetiForceCRM,代码行数:101,代码来源:ListView.php

示例6: getEntries

 public function getEntries($pagingModel)
 {
     $db = PearDatabase::getInstance();
     $parentModule = $this->getParentRecordModel()->getModule();
     $relationModel = $this->getRelationModel();
     $relationModule = $relationModel->getRelationModuleModel();
     $relatedColumnFields = $relationModel->getRelationFields(true, true);
     $relationModuleName = $relationModule->get('name');
     if (count($relatedColumnFields) <= 0) {
         $relatedColumnFields = $relationModule->getConfigureRelatedListFields();
     }
     if (count($relatedColumnFields) <= 0) {
         $relatedColumnFields = $relationModule->getRelatedListFields();
     }
     if ($relationModuleName == 'Calendar') {
         //Adding visibility in the related list, showing records based on the visibility
         $relatedColumnFields['visibility'] = 'visibility';
     }
     if ($relationModuleName == 'PriceBooks') {
         //Adding fields in the related list
         $relatedColumnFields['unit_price'] = 'unit_price';
         $relatedColumnFields['listprice'] = 'listprice';
         $relatedColumnFields['currency_id'] = 'currency_id';
     }
     $query = $this->getRelationQuery();
     if ($this->get('whereCondition')) {
         $query = $this->updateQueryWithWhereCondition($query);
     }
     $startIndex = $pagingModel->getStartIndex();
     $pageLimit = $pagingModel->getPageLimit();
     $orderBy = $this->getForSql('orderby');
     $sortOrder = $this->getForSql('sortorder');
     if ($orderBy) {
         $orderByFieldModuleModel = $relationModule->getFieldByColumn($orderBy);
         if ($orderByFieldModuleModel && $orderByFieldModuleModel->isReferenceField()) {
             //If reference field then we need to perform a join with crmentity with the related to field
             $queryComponents = $split = spliti(' where ', $query);
             $selectAndFromClause = $queryComponents[0];
             $whereCondition = $queryComponents[1];
             $qualifiedOrderBy = 'vtiger_crmentity' . $orderByFieldModuleModel->get('column');
             $selectAndFromClause .= ' LEFT JOIN vtiger_crmentity AS ' . $qualifiedOrderBy . ' ON ' . $orderByFieldModuleModel->get('table') . '.' . $orderByFieldModuleModel->get('column') . ' = ' . $qualifiedOrderBy . '.crmid ';
             $query = $selectAndFromClause . ' WHERE ' . $whereCondition;
             $query .= ' ORDER BY ' . $qualifiedOrderBy . '.label ' . $sortOrder;
         } elseif ($orderByFieldModuleModel && $orderByFieldModuleModel->isOwnerField()) {
             $query .= ' ORDER BY COALESCE(CONCAT(vtiger_users.first_name,vtiger_users.last_name),vtiger_groups.groupname) ' . $sortOrder;
         } else {
             // Qualify the the column name with table to remove ambugity
             $qualifiedOrderBy = $orderBy;
             $orderByField = $relationModule->getFieldByColumn($orderBy);
             if ($orderByField) {
                 $qualifiedOrderBy = $relationModule->getOrderBySql($qualifiedOrderBy);
             }
             $query = "{$query} ORDER BY {$qualifiedOrderBy} {$sortOrder}";
         }
     }
     $limitQuery = $query . ' LIMIT ' . $startIndex . ',' . $pageLimit;
     $result = $db->pquery($limitQuery, array());
     $relatedRecordList = array();
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $groupsIds = Vtiger_Util_Helper::getGroupsIdsForUsers($currentUser->getId());
     for ($i = 0; $i < $db->num_rows($result); $i++) {
         $row = $db->fetch_row($result, $i);
         $newRow = array();
         foreach ($row as $col => $val) {
             if (array_key_exists($col, $relatedColumnFields)) {
                 $newRow[$relatedColumnFields[$col]] = $val;
             }
         }
         //To show the value of "Assigned to"
         $ownerId = $row['smownerid'];
         $newRow['assigned_user_id'] = $row['smownerid'];
         if ($relationModuleName == 'Calendar') {
             $visibleFields = array('activitytype', 'date_start', 'time_start', 'due_date', 'time_end', 'assigned_user_id', 'visibility', 'smownerid', 'parent_id');
             $visibility = true;
             if (in_array($ownerId, $groupsIds)) {
                 $visibility = false;
             } else {
                 if ($ownerId == $currentUser->getId()) {
                     $visibility = false;
                 }
             }
             if (!$currentUser->isAdminUser() && $newRow['activitytype'] != 'Task' && $newRow['visibility'] == 'Private' && $ownerId && $visibility) {
                 foreach ($newRow as $data => $value) {
                     if (in_array($data, $visibleFields) != -1) {
                         unset($newRow[$data]);
                     }
                 }
                 $newRow['subject'] = vtranslate('Busy', 'Events') . '*';
             }
             if ($newRow['activitytype'] == 'Task') {
                 unset($newRow['visibility']);
             }
         }
         $record = Vtiger_Record_Model::getCleanInstance($relationModule->get('name'));
         $record->setData($newRow)->setModuleFromInstance($relationModule);
         $record->setId($row['crmid']);
         $relatedRecordList[$row['crmid']] = $record;
     }
     $pagingModel->calculatePageRange($relatedRecordList);
     $nextLimitQuery = $query . ' LIMIT ' . ($startIndex + $pageLimit) . ' , 1';
//.........这里部分代码省略.........
开发者ID:rcrrich,项目名称:UpdatePackages,代码行数:101,代码来源:RelationListView.php

示例7: initializeListViewContents


//.........这里部分代码省略.........
			$nextSortOrder = "ASC";
			$sortImage = "glyphicon glyphicon-chevron-up";
		}

		if (empty($pageNumber)) {
			$pageNumber = '1';
		}

		$listViewModel = Vtiger_ListView_Model::getInstance($moduleName, $cvId);
		$currentUser = Users_Record_Model::getCurrentUserModel();

		$linkParams = array('MODULE' => $moduleName, 'ACTION' => $request->get('view'), 'CVID' => $cvId);
		$linkModels = $listViewModel->getListViewMassActions($linkParams);

		$pagingModel = new Vtiger_Paging_Model();
		$pagingModel->set('page', $pageNumber);
		$pagingModel->set('viewid', $request->get('viewname'));

		if (!empty($orderBy)) {
			$listViewModel->set('orderby', $orderBy);
			$listViewModel->set('sortorder', $sortOrder);
		}

		$searchKey = $request->get('search_key');
		$searchValue = $request->get('search_value');
		$operator = $request->get('operator');
		if (!empty($operator)) {
			$listViewModel->set('operator', $operator);
			$viewer->assign('OPERATOR', $operator);
			$viewer->assign('ALPHABET_VALUE', $searchValue);
		}
		if (!empty($searchKey) && !empty($searchValue)) {
			$listViewModel->set('search_key', $searchKey);
			$listViewModel->set('search_value', $searchValue);
		}

		$searchParmams = $request->get('search_params');
		if (empty($searchParmams) || !is_array($searchParmams)) {
			$searchParmams = [];
		}
		$transformedSearchParams = $this->transferListSearchParamsToFilterCondition($searchParmams, $listViewModel->getModule());
		$listViewModel->set('search_params', $transformedSearchParams);

		//To make smarty to get the details easily accesible
		foreach ($searchParmams as $fieldListGroup) {
			foreach ($fieldListGroup as $fieldSearchInfo) {
				$fieldSearchInfo['searchValue'] = $fieldSearchInfo[2];
				$fieldSearchInfo['fieldName'] = $fieldName = $fieldSearchInfo[0];
				$fieldSearchInfo['specialOption'] = $fieldSearchInfo[3];
				$searchParmams[$fieldName] = $fieldSearchInfo;
			}
		}

		if (!$this->listViewHeaders) {
			$this->listViewHeaders = $listViewModel->getListViewHeaders();
		}
		if (!$this->listViewEntries) {
			$this->listViewEntries = $listViewModel->getListViewEntries($pagingModel, $searchResult);
		}
		$noOfEntries = count($this->listViewEntries);

		$viewer->assign('MODULE', $moduleName);

		if (!$this->listViewLinks) {
			$this->listViewLinks = $listViewModel->getListViewLinks($linkParams);
		}
		$viewer->assign('LISTVIEW_LINKS', $this->listViewLinks);

		$viewer->assign('LISTVIEW_MASSACTIONS', $linkModels['LISTVIEWMASSACTION']);

		$viewer->assign('PAGING_MODEL', $pagingModel);
		$viewer->assign('PAGE_NUMBER', $pageNumber);

		$viewer->assign('ORDER_BY', $orderBy);
		$viewer->assign('SORT_ORDER', $sortOrder);
		$viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
		$viewer->assign('SORT_IMAGE', $sortImage);
		$viewer->assign('COLUMN_NAME', $orderBy);

		$viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
		$viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
		$viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);

		if (!$this->listViewCount) {
			$this->listViewCount = $listViewModel->getListViewCount();
		}
		$totalCount = $this->listViewCount;
		$pagingModel->set('totalCount', (int) $totalCount);
		$pageCount = $pagingModel->getPageCount();
		$startPaginFrom = $pagingModel->getStartPagingFrom();

		$viewer->assign('PAGE_COUNT', $pageCount);
		$viewer->assign('LISTVIEW_COUNT', $totalCount);
		$viewer->assign('START_PAGIN_FROM', $startPaginFrom);
		$viewer->assign('LIST_VIEW_MODEL', $listViewModel);
		$viewer->assign('GROUPS_IDS', Vtiger_Util_Helper::getGroupsIdsForUsers($currentUser->getId()));
		$viewer->assign('IS_MODULE_EDITABLE', $listViewModel->getModule()->isPermitted('EditView'));
		$viewer->assign('IS_MODULE_DELETABLE', $listViewModel->getModule()->isPermitted('Delete'));
		$viewer->assign('SEARCH_DETAILS', $searchParmams);
	}
开发者ID:rubichcube,项目名称:YetiForceCRM,代码行数:101,代码来源:List.php


注:本文中的Vtiger_Util_Helper::getGroupsIdsForUsers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。