function template_pagination(&$args) { $smarty = new Sugar_Smarty(); $reporter = $args['reporter']; global $mod_strings; // disable export if configured to global $current_user, $sugar_config, $app_strings; $smarty->assign('mod_strings', $mod_strings); $smarty->assign('app_strings', $app_strings); $is_owner = true; if (isset($args['reporter']->saved_report) && $args['reporter']->saved_report->assigned_user_id != $current_user->id) { $is_owner = false; } // if $isExportAccess = false; if (!ACLController::checkAccess('Reports', 'export', $is_owner) || $sugar_config['disable_export'] || !empty($sugar_config['admin_export_only']) && !(is_admin($current_user) || ACLController::moduleSupportsACL($reporter->module) && ACLAction::getUserAccessLevel($current_user->id, $reporter->module, 'access') == ACL_ALLOW_ENABLED && ACLAction::getUserAccessLevel($current_user->id, $reporter->module, 'admin') == ACL_ALLOW_ADMIN)) { // no op } else { $smarty->assign('exportImagePath', SugarThemeRegistry::current()->getImage('export', " border='0' align='absmiddle'", null, null, '.gif', translate('LBL_EXPORT'))); $isExportAccess = true; } // else $smarty->assign('isExportAccess', $isExportAccess); $smarty->assign('start_link_ImagePath', SugarThemeRegistry::current()->getImage("start_off", " border='0' align='absmiddle'", null, null, '.gif', $app_strings['LNK_LIST_START'])); $smarty->assign('prev_link_ImagePath', SugarThemeRegistry::current()->getImage("previous_off", "border='0' align='absmiddle'", null, null, '.gif', $app_strings['LNK_LIST_PREVIOUS'])); $smarty->assign('end_link_ImagePath', SugarThemeRegistry::current()->getImage("end_off", "border='0' align='absmiddle'", null, null, '.gif', $app_strings['LNK_LIST_END'])); $smarty->assign('next_link_ImagePath', SugarThemeRegistry::current()->getImage("next_off", "border='0' align='absmiddle'", null, null, '.gif', $app_strings['LNK_LIST_NEXT'])); $smarty->assign('start_link_disabled', true); $smarty->assign('prev_link_disabled', true); $smarty->assign('end_link_disabled', true); $smarty->assign('next_link_disabled', true); $next = $reporter->row_end + $reporter->report_offset; if ($reporter->report_offset > 0) { $prev = $reporter->report_offset - $reporter->report_max; $smarty->assign('start_link_ImagePath', SugarThemeRegistry::current()->getImage("start", " border='0' align='absmiddle'", null, null, '.gif', $app_strings['LNK_LIST_START'])); $smarty->assign('start_link_onclick', "onClick=javascript:set_offset(0);"); $smarty->assign('start_link_disabled', false); $smarty->assign('prev_link_ImagePath', SugarThemeRegistry::current()->getImage("previous", "border='0' align='absmiddle'", null, null, '.gif', $app_strings['LNK_LIST_PREVIOUS'])); $smarty->assign('prev_link_onclick', "onClick=javascript:set_offset({$prev});"); $smarty->assign('prev_link_disabled', false); } // if if ($next < $reporter->total_count) { $end = ceil($reporter->total_count / $reporter->report_max - 1) * $reporter->report_max; $smarty->assign('end_link_ImagePath', SugarThemeRegistry::current()->getImage("end", " border='0' align='absmiddle'", null, null, '.gif', $app_strings['LNK_LIST_END'])); $smarty->assign('end_link_disabled', false); $smarty->assign('end_link_onclick', "onClick=javascript:set_offset({$end});"); $smarty->assign('next_link_ImagePath', SugarThemeRegistry::current()->getImage("next", " border='0' align='absmiddle'", null, null, '.gif', $app_strings['LNK_LIST_NEXT'])); $smarty->assign('next_link_disabled', false); $smarty->assign('next_link_onclick', "onClick=javascript:set_offset({$next});"); } // if $start_range = $reporter->report_offset > 0 ? $reporter->row_start + $reporter->report_offset : ($reporter->total_count == 0 ? 0 : 1); $end_range = $reporter->row_end + $reporter->report_offset; $smarty->assign('start_range', $start_range); $smarty->assign('end_range', $end_range); $smarty->assign('total_count', $reporter->total_count); return $smarty->fetch("modules/Reports/templates/_template_pagination.tpl"); }
/** * (non-PHPdoc) * @see SugarACLStrategy::checkAccess() */ public function checkAccess($module, $action, $context) { // Check if we have to apply team security based on ACLs // If user had admin rights then team security is disabled if ($action == "team_security") { if (isset($context['bean']) && $context['bean']->bean_implements('ACL')) { $user_id = $this->getUserID($context); if (ACLAction::getUserAccessLevel($user_id, $module, 'access') != ACL_ALLOW_ENABLED) { return true; } if (ACLAction::getUserAccessLevel($user_id, $module, 'admin') == ACL_ALLOW_ADMIN || ACLAction::getUserAccessLevel($user_id, $module, 'admin') == ACL_ALLOW_ADMIN_DEV) { // disable team security for admins return false; } return true; } else { // True means team security is enabled and it's the default return true; } } $user = $this->getCurrentUser($context); if ($user && $user->isAdmin()) { return true; } // make sure we have the correct action name $action = !empty($_REQUEST['bwcFrame']) ? strtolower($action) : $this->fixUpActionName($action); if ($action == "field") { return $this->fieldACL($module, $context['action'], $context); } if (!empty($context['bean'])) { return $this->beanACL($module, $action, $context); } if (empty($action)) { return true; } if ($module == 'Trackers') { return ACLController::checkAccessInternal($module, $action, true, 'Tracker'); } // if we're editing and we do not have the bean, if owner is allowed then action is allowed if (empty($context['bean']) && !empty(self::$edit_actions[$action]) && !isset($context['owner_override'])) { $context['owner_override'] = true; } return ACLController::checkAccessInternal($module, $action, !empty($context['owner_override'])); }
/** * Export API * * @param $api ServiceBase The API class of the request, used in cases where the API changes how the fields are pulled from the args array. * @param $args array The arguments array passed in from the API * @return String */ public function export(ServiceBase $api, array $args) { $seed = BeanFactory::newBean($args['module']); if (!$seed->ACLAccess('export')) { throw new SugarApiExceptionNotAuthorized($GLOBALS['app_strings']['ERR_EXPORT_DISABLED']); } ob_start(); global $sugar_config; global $current_user; global $app_list_strings; $theModule = clean_string($args['module']); if ($sugar_config['disable_export'] || !empty($sugar_config['admin_export_only']) && !(is_admin($current_user) || ACLController::moduleSupportsACL($theModule) && ACLAction::getUserAccessLevel($current_user->id, $theModule, 'access') == ACL_ALLOW_ENABLED && (ACLAction::getUserAccessLevel($current_user->id, $theModule, 'admin') == ACL_ALLOW_ADMIN || ACLAction::getUserAccessLevel($current_user->id, $theModule, 'admin') == ACL_ALLOW_ADMIN_DEV))) { throw new SugarApiExceptionNotAuthorized($GLOBALS['app_strings']['ERR_EXPORT_DISABLED']); } //check to see if this is a request for a sample or for a regular export if (!empty($args['sample'])) { //call special method that will create dummy data for bean as well as insert standard help message. $content = exportSampleFromApi($args); } else { $content = exportFromApi($args); } $filename = $args['module']; //use label if one is defined if (!empty($app_list_strings['moduleList'][$args['module']])) { $filename = $app_list_strings['moduleList'][$args['module']]; } //strip away any blank spaces $filename = str_replace(' ', '', $filename); if (isset($args['members']) && $args['members'] == true) { $filename .= '_' . 'members'; } /////////////////////////////////////////////////////////////////////////////// //// BUILD THE EXPORT FILE ob_end_clean(); return $this->doExport($api, $filename, $content); }
/** public static function userHasAccess($user_id, $category, $action,$type='module', $is_owner = false){ */ public static function userHasAccess($user_id, $category, $action, $type = 'module', $is_owner = false, $in_group = false) { global $current_user; if ($current_user->isAdminForModule($category) && !isset($_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'])) { return true; } //check if we don't have it set in the cache if not lets reload the cache if (ACLAction::getUserAccessLevel($user_id, $category, 'access', $type) < ACL_ALLOW_ENABLED) { return false; } if (empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { ACLAction::getUserActions($user_id, false); } if (!empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { /** return ACLAction::hasAccess($is_owner, $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess']); */ return ACLAction::hasAccess($is_owner, $in_group, $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess']); } return false; }
function process($lvsParams = array()) { global $current_user; $currentSearchFields = array(); $configureView = true; // configure view or regular view $query = false; $whereArray = array(); $lvsParams['massupdate'] = false; // apply filters if (isset($this->filters) || $this->myItemsOnly) { $whereArray = $this->buildWhere(); } $this->lvs->export = false; $this->lvs->multiSelect = false; $this->lvs->quickViewLinks = false; // columns foreach ($this->columns as $name => $val) { if (!empty($val['default']) && $val['default']) { $displayColumns[strtoupper($name)] = $val; $displayColumns[strtoupper($name)]['label'] = trim($displayColumns[strtoupper($name)]['label'], ':'); } } $this->lvs->displayColumns = $displayColumns; $this->lvs->lvd->setVariableName($this->seedBean->object_name, array()); $lvsParams['overrideOrder'] = true; $lvsParams['orderBy'] = 'date_entered'; $lvsParams['sortOrder'] = 'DESC'; $lvsParams['custom_from'] = ''; // Get the real module list if (empty($this->selectedCategories)) { $mod_list = $this->categories; } else { $mod_list = array_flip($this->selectedCategories); //27949, here the key of $this->selectedCategories is not module name, the value is module name, so array_flip it. } $external_modules = array(); $admin_modules = array(); $owner_modules = array(); $regular_modules = array(); foreach ($mod_list as $module => $ignore) { // Handle the UserFeed differently if ($module == 'UserFeed') { $regular_modules[] = 'UserFeed'; continue; } if (in_array($module, $this->externalAPIList)) { $external_modules[] = $module; } if (ACLAction::getUserAccessLevel($current_user->id, $module, 'view') <= ACL_ALLOW_NONE) { // Not enough access to view any records, don't add it to any lists continue; } if (ACLAction::getUserAccessLevel($current_user->id, $module, 'view') == ACL_ALLOW_OWNER) { $owner_modules[] = $module; } else { $regular_modules[] = $module; } } if (!empty($this->displayTpl)) { //MFH BUG #14296 $where = ''; if (!empty($whereArray)) { $where = '(' . implode(') AND (', $whereArray) . ')'; } $additional_where = ''; $module_limiter = " sugarfeed.related_module in ('" . implode("','", $regular_modules) . "')"; if (is_admin($GLOBALS['current_user'])) { $all_modules = array_merge($regular_modules, $owner_modules, $admin_modules); $module_limiter = " sugarfeed.related_module in ('" . implode("','", $all_modules) . "')"; } else { if (count($owner_modules) > 0) { $module_limiter = " ((sugarfeed.related_module IN ('" . implode("','", $regular_modules) . "') " . ") "; if (count($owner_modules) > 0) { $module_limiter .= "OR (sugarfeed.related_module IN('" . implode("','", $owner_modules) . "') AND sugarfeed.assigned_user_id = '" . $current_user->id . "' " . ") "; } $module_limiter .= ")"; } } if (!empty($where)) { $where .= ' AND '; } $where .= $module_limiter; $this->lvs->setup($this->seedBean, $this->displayTpl, $where, $lvsParams, 0, $this->displayRows, array('name', 'description', 'date_entered', 'created_by', 'related_module', 'link_url', 'link_type')); foreach ($this->lvs->data['data'] as $row => $data) { $this->lvs->data['data'][$row]['NAME'] = str_replace("{this.CREATED_BY}", get_assigned_user_name($this->lvs->data['data'][$row]['CREATED_BY']), $data['NAME']); //Translate the SugarFeeds labels if necessary. preg_match('/\\{([^\\^ }]+)\\.([^\\}]+)\\}/', $this->lvs->data['data'][$row]['NAME'], $modStringMatches); if (count($modStringMatches) == 3 && $modStringMatches[1] == 'SugarFeed' && !empty($data['RELATED_MODULE'])) { $modKey = $modStringMatches[2]; $modString = translate($modKey, $modStringMatches[1]); if (strpos($modString, '{0}') === FALSE || !isset($GLOBALS['app_list_strings']['moduleListSingular'][$data['RELATED_MODULE']])) { continue; } $modStringSingular = $GLOBALS['app_list_strings']['moduleListSingular'][$data['RELATED_MODULE']]; $modString = string_format($modString, array($modStringSingular)); $this->lvs->data['data'][$row]['NAME'] = preg_replace('/' . $modStringMatches[0] . '/', strtolower($modString), $this->lvs->data['data'][$row]['NAME']); } } // assign a baseURL w/ the action set as DisplayDashlet foreach ($this->lvs->data['pageData']['urls'] as $type => $url) { // awu Replacing action=DisplayDashlet with action=DynamicAction&DynamicAction=DisplayDashlet if ($type == 'orderBy') { $this->lvs->data['pageData']['urls'][$type] = preg_replace('/(action=.*&)/Ui', 'action=DynamicAction&DynamicAction=displayDashlet&', $url); } else { $this->lvs->data['pageData']['urls'][$type] = preg_replace('/(action=.*&)/Ui', 'action=DynamicAction&DynamicAction=displayDashlet&', $url) . '&sugar_body_only=1&id=' . $this->id; } } $this->lvs->ss->assign('dashletId', $this->id); } $td = $GLOBALS['timedate']; $needResort = false; $resortQueue = array(); $feedErrors = array(); $fetchRecordCount = $this->displayRows + $this->lvs->data['pageData']['offsets']['current']; foreach ($external_modules as $apiName) { $api = ExternalAPIFactory::loadAPI($apiName); if ($api !== FALSE) { // FIXME: Actually calculate the oldest sugar feed we can see, once we get an API that supports this sort of filter. $reply = $api->getLatestUpdates(0, $fetchRecordCount); if ($reply['success'] && count($reply['messages']) > 0) { array_splice($resortQueue, count($resortQueue), 0, $reply['messages']); } else { if (!$reply['success']) { $feedErrors[] = $reply['errorMessage']; } } } } if (count($feedErrors) > 0) { $this->lvs->ss->assign('feedErrors', $feedErrors); } // If we need to resort, get to work! foreach ($this->lvs->data['data'] as $normalMessage) { list($user_date, $user_time) = explode(' ', $normalMessage['DATE_ENTERED']); list($db_date, $db_time) = $td->to_db_date_time($user_date, $user_time); $unix_timestamp = strtotime($db_date . ' ' . $db_time); $normalMessage['sort_key'] = $unix_timestamp; $normalMessage['NAME'] = '</b>' . $normalMessage['NAME']; $resortQueue[] = $normalMessage; } usort($resortQueue, create_function('$a,$b', 'return $a["sort_key"]<$b["sort_key"];')); // Trim it down to the necessary number of records $numRecords = count($resortQueue); $numRecords = $numRecords - $this->lvs->data['pageData']['offsets']['current']; $numRecords = min($this->displayRows, $numRecords); $this->lvs->data['data'] = $resortQueue; }
function mass_assign($event, $arguments) { $action = $_REQUEST['action']; $module = $_REQUEST['module']; $no_mass_assign_list = array("Emails" => "Emails", "ACLRoles" => "ACLRoles"); //,"Users"=>"Users"); //check if security suite enabled $action = strtolower($action); if (isset($module) && ($action == "list" || $action == "index" || $action == "listview") && (!isset($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] != true) && !array_key_exists($module, $no_mass_assign_list)) { global $current_user; if (is_admin($current_user) || ACLAction::getUserAccessLevel($current_user->id, "SecurityGroups", 'access') == ACL_ALLOW_ENABLED) { require_once 'modules/SecurityGroups/SecurityGroup.php'; $groupFocus = new SecurityGroup(); $security_modules = $groupFocus->getSecurityModules(); //if(in_array($module,$security_modules)) { if (in_array($module, array_keys($security_modules))) { global $app_strings; global $current_language; $current_module_strings = return_module_language($current_language, 'SecurityGroups'); $form_header = get_form_header($current_module_strings['LBL_MASS_ASSIGN'], '', false); $groups = $groupFocus->get_list("name", "", 0, -99, -99); $options = array("" => ""); foreach ($groups['list'] as $group) { $options[$group->id] = $group->name; } $group_options = get_select_options_with_id($options, ""); $mass_assign = <<<EOQ <script type="text/javascript" language="javascript"> function confirm_massassign(del,start_string, end_string) { \tif (del == 1) { \t\treturn confirm( start_string + sugarListView.get_num_selected() + end_string); \t} \telse { \t\treturn confirm( start_string + sugarListView.get_num_selected() + end_string); \t} } function send_massassign(mode, no_record_txt, start_string, end_string, del) { \tif(!sugarListView.confirm_action(del, start_string, end_string)) \t\treturn false; \tif(document.MassAssign_SecurityGroups.massassign_group.selectedIndex == 0) { \t\talert("Please select a group and try again."); \t\treturn false;\t \t} \t \tif (document.MassUpdate.select_entire_list && \t\tdocument.MassUpdate.select_entire_list.value == 1) \t\tmode = 'entire'; \telse if (document.MassUpdate.massall.checked == true) \t\tmode = 'page'; \telse \t\tmode = 'selected'; \tvar ar = new Array(); \tif(del == 1) { \t\tvar deleteInput = document.createElement('input'); \t\tdeleteInput.name = 'Delete'; \t\tdeleteInput.type = 'hidden'; \t\tdeleteInput.value = true; \t\tdocument.MassAssign_SecurityGroups.appendChild(deleteInput); \t} \tswitch(mode) { \t\tcase 'page': \t\t\tdocument.MassAssign_SecurityGroups.uid.value = ''; \t\t\tfor(wp = 0; wp < document.MassUpdate.elements.length; wp++) { \t\t\t\tif(typeof document.MassUpdate.elements[wp].name != 'undefined' \t\t\t\t\t&& document.MassUpdate.elements[wp].name == 'mass[]' && document.MassUpdate.elements[wp].checked) { \t\t\t\t\t\t\tar.push(document.MassUpdate.elements[wp].value); \t\t\t\t} \t\t\t} \t\t\tdocument.MassAssign_SecurityGroups.uid.value = ar.join(','); \t\t\tif(document.MassAssign_SecurityGroups.uid.value == '') { \t\t\t\talert(no_record_txt); \t\t\t\treturn false; \t\t\t} \t\t\tbreak; \t\tcase 'selected': \t\t\tfor(wp = 0; wp < document.MassUpdate.elements.length; wp++) { \t\t\t\tif(typeof document.MassUpdate.elements[wp].name != 'undefined' \t\t\t\t\t&& document.MassUpdate.elements[wp].name == 'mass[]' \t\t\t\t\t\t&& document.MassUpdate.elements[wp].checked) { \t\t\t\t\t\t\tar.push(document.MassUpdate.elements[wp].value); \t\t\t\t} \t\t\t} \t\t\tif(document.MassAssign_SecurityGroups.uid.value != '') document.MassAssign_SecurityGroups.uid.value += ','; \t\t\tdocument.MassAssign_SecurityGroups.uid.value += ar.join(','); \t\t\tif(document.MassAssign_SecurityGroups.uid.value == '') { \t\t\t\talert(no_record_txt); \t\t\t\treturn false; \t\t\t} \t\t\tbreak; \t\tcase 'entire': \t\t\tvar entireInput = document.createElement('input'); \t\t\tentireInput.name = 'entire'; \t\t\tentireInput.type = 'hidden'; \t\t\tentireInput.value = 'index'; \t\t\tdocument.MassAssign_SecurityGroups.appendChild(entireInput); \t\t\t//confirm(no_record_txt); \t\t\tbreak; \t} \tdocument.MassAssign_SecurityGroups.submit(); \treturn false; } </script> \t\t<form action='index.php' method='post' name='MassAssign_SecurityGroups' id='MassAssign_SecurityGroups'> \t\t\t<input type='hidden' name='action' value='MassAssign' /> \t\t\t<input type='hidden' name='module' value='SecurityGroups' /> \t\t\t<input type='hidden' name='return_action' value='{$action}' /> \t\t\t<input type='hidden' name='return_module' value='{$module}' /> \t\t\t<textarea style='display: none' name='uid'></textarea> \t\t<div id='massassign_form'>{$form_header} \t\t<table cellpadding='0' cellspacing='0' border='0' width='100%'> \t\t<tr> \t\t<td style='padding-bottom: 2px;' class='listViewButtons'> \t\t<input type='submit' name='Assign' value='{$current_module_strings['LBL_ASSIGN']}' onclick="return send_massassign('selected', '{$app_strings['LBL_LISTVIEW_NO_SELECTED']}','{$current_module_strings['LBL_ASSIGN_CONFIRM']}','{$current_module_strings['LBL_CONFIRM_END']}',0);" class='button'> \t\t<input type='submit' name='Remove' value='{$current_module_strings['LBL_REMOVE']}' onclick="return send_massassign('selected', '{$app_strings['LBL_LISTVIEW_NO_SELECTED']}','{$current_module_strings['LBL_REMOVE_CONFIRM']}','{$current_module_strings['LBL_CONFIRM_END']}',1);" class='button'> \t\t</td></tr></table> \t\t<table cellpadding='0' cellspacing='0' border='0' width='100%' class='tabForm' id='mass_update_table'> \t\t<tr><td><table width='100%' border='0' cellspacing='0' cellpadding='0'> \t\t<tr> \t\t<td>{$current_module_strings['LBL_GROUP']}</td> \t\t<td><select name='massassign_group' id="massassign_group" tabindex='1'>{$group_options}</select></td> \t\t</tr> \t\t</table></td></tr></table></div>\t\t\t \t\t</form>\t\t EOQ; echo $mass_assign; } } } //if after a save... if (!empty($_SESSION['securitysuite_error'])) { $lbl_securitysuite_error = $_SESSION['securitysuite_error']; unset($_SESSION['securitysuite_error']); echo <<<EOQ <script> \t\t\t\t var oNewP = document.createElement("div"); oNewP.className = 'error'; var oText = document.createTextNode("{$lbl_securitysuite_error}"); oNewP.appendChild(oText); var beforeMe = document.getElementsByTagName("div")[0]; document.body.insertBefore(oNewP, beforeMe); </script> EOQ; } }
/** * @return void * @param unknown $data * @param unknown $xTemplateSection * @param unknown $html_varName * @desc INTERNAL FUNCTION process the List Navigation * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function processListNavigation($xtemplateSection, $html_varName, $current_offset, $next_offset, $previous_offset, $row_count, $sugarbean = null, $subpanel_def = null, $col_count = 20) { global $export_module; global $sugar_config; global $current_user; global $currentModule; $start_record = $current_offset + 1; if (!is_numeric($col_count)) { $col_count = 20; } if ($row_count == 0) { $start_record = 0; } $end_record = $start_record + $this->records_per_page; // back up the the last page. if ($end_record > $row_count + 1) { $end_record = $row_count + 1; } // Deterime the start location of the last page if ($row_count == 0) { $number_pages = 0; } else { $number_pages = floor(($row_count - 1) / $this->records_per_page); } $last_offset = $number_pages * $this->records_per_page; if (empty($this->query_limit) || $this->query_limit > $this->records_per_page) { $this->base_URL = $this->getBaseURL($html_varName); $dynamic_url = ''; if ($this->is_dynamic) { $dynamic_url .= '&' . $this->getSessionVariableName($html_varName, 'ORDER_BY') . '=' . $this->getSessionVariable($html_varName, 'ORDER_BY') . '&sort_order=' . $this->sort_order . '&to_pdf=true&action=SubPanelViewer&subpanel=' . $this->subpanel_module; } $current_URL = $this->base_URL . $current_offset . $dynamic_url; $start_URL = $this->base_URL . "0" . $dynamic_url; $previous_URL = $this->base_URL . $previous_offset . $dynamic_url; $next_URL = $this->base_URL . $next_offset . $dynamic_url; $end_URL = $this->base_URL . 'end' . $dynamic_url; if (!empty($this->start_link_wrapper)) { $current_URL = $this->start_link_wrapper . $current_URL . $this->end_link_wrapper; $start_URL = $this->start_link_wrapper . $start_URL . $this->end_link_wrapper; $previous_URL = $this->start_link_wrapper . $previous_URL . $this->end_link_wrapper; $next_URL = $this->start_link_wrapper . $next_URL . $this->end_link_wrapper; $end_URL = $this->start_link_wrapper . $end_URL . $this->end_link_wrapper; } $moduleString = "{$currentModule}_{$html_varName}_offset"; $moduleStringOrder = "{$currentModule}_{$html_varName}_ORDER_BY"; if ($this->shouldProcess && !$this->multi_select_popup) { // check the checkboxes onload echo "<script>YAHOO.util.Event.addListener(window, \"load\", sListView.check_boxes);</script>\n"; $massUpdateRun = isset($_REQUEST['massupdate']) && $_REQUEST['massupdate'] == 'true'; $uids = empty($_REQUEST['uid']) || $massUpdateRun ? '' : $_REQUEST['uid']; $select_entire_list = isset($_REQUEST['select_entire_list']) && !$massUpdateRun ? $_REQUEST['select_entire_list'] : 0; echo "<textarea style='display: none' name='uid'>{$uids}</textarea>\n" . "<input type='hidden' name='select_entire_list' value='{$select_entire_list}'>\n" . "<input type='hidden' name='{$moduleString}' value='0'>\n" . "<input type='hidden' name='{$moduleStringOrder}' value='0'>\n"; } $GLOBALS['log']->debug("Offsets: (start, previous, next, last)(0, {$previous_offset}, {$next_offset}, {$last_offset})"); if (0 == $current_offset) { $start_link = "<button type='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' class='button' disabled>" . SugarThemeRegistry::current()->getImage("start_off", "alt='" . $this->local_app_strings['LNK_LIST_START'] . "' border='0' align='absmiddle'") . "</button>"; $previous_link = "<button type='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' class='button' disabled>" . SugarThemeRegistry::current()->getImage("previous_off", "alt='" . $this->local_app_strings['LNK_LIST_PREVIOUS'] . "' border='0' align='absmiddle'") . "</button>"; } else { if ($this->multi_select_popup) { // nav links for multiselect popup, submit form to save checks. $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick='javascript:save_checks(0, \"{$moduleString}\");'>" . SugarThemeRegistry::current()->getImage("start", "alt='" . $this->local_app_strings['LNK_LIST_START'] . "' border='0' align='absmiddle'") . "</button>"; $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick='javascript:save_checks({$previous_offset}, \"{$moduleString}\");'>" . SugarThemeRegistry::current()->getImage("previous", "alt='" . $this->local_app_strings['LNK_LIST_PREVIOUS'] . "' border='0' align='absmiddle'") . "</button>"; } elseif ($this->shouldProcess) { $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick='location.href=\"{$start_URL}\"; sListView.save_checks(0, \"{$moduleString}\");'>" . SugarThemeRegistry::current()->getImage("start", "alt='" . $this->local_app_strings['LNK_LIST_START'] . "' border='0' align='absmiddle'") . "</button>"; $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick='location.href=\"{$previous_URL}\"; sListView.save_checks({$previous_offset}, \"{$moduleString}\");'>" . SugarThemeRegistry::current()->getImage("previous", "alt='" . $this->local_app_strings['LNK_LIST_PREVIOUS'] . "' border='0' align='absmiddle'") . "</button>"; } else { $onClick = ''; if (0 != preg_match('/javascript.*/', $start_URL)) { $onClick = "\"{$start_URL};\""; } else { $onClick = "'location.href=\"{$start_URL}\";'"; } $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick=" . $onClick . ">" . SugarThemeRegistry::current()->getImage("start", "alt='" . $this->local_app_strings['LNK_LIST_START'] . "' border='0' align='absmiddle'") . "</button>"; $onClick = ''; if (0 != preg_match('/javascript.*/', $previous_URL)) { $onClick = "\"{$previous_URL};\""; } else { $onClick = "'location.href=\"{$previous_URL}\";'"; } $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick=" . $onClick . ">" . SugarThemeRegistry::current()->getImage("previous", "alt='" . $this->local_app_strings['LNK_LIST_PREVIOUS'] . "' border='0' align='absmiddle'") . "</button>"; } } if ($last_offset <= $current_offset) { $end_link = "<button type='button' name='listViewEndButton' title='{$this->local_app_strings['LNK_LIST_END']}' class='button' disabled>" . SugarThemeRegistry::current()->getImage("end_off", "alt='" . $this->local_app_strings['LNK_LIST_END'] . "' border='0' align='absmiddle'") . "</button>"; $next_link = "<button type='button' name='listViewNextButton' title='{$this->local_app_strings['LNK_LIST_NEXT']}' class='button' disabled>" . SugarThemeRegistry::current()->getImage("next_off", "alt='" . $this->local_app_strings['LNK_LIST_NEXT'] . "' border='0' align='absmiddle'") . "</button>"; } else { if ($this->multi_select_popup) { // nav links for multiselect popup, submit form to save checks. $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick='javascript:save_checks({$last_offset}, \"{$moduleString}\");'>" . SugarThemeRegistry::current()->getImage("end", "alt='" . $this->local_app_strings['LNK_LIST_END'] . "' border='0' align='absmiddle'") . "</button>"; if (!empty($sugar_config['disable_count_query'])) { $end_link = ''; } $next_link = "<button type='button' name='listViewNextButton' title='{$this->local_app_strings['LNK_LIST_NEXT']}' class='button' onClick='javascript:save_checks({$next_offset}, \"{$moduleString}\");'>" . SugarThemeRegistry::current()->getImage("next", "alt='" . $this->local_app_strings['LNK_LIST_NEXT'] . "' border='0' align='absmiddle'") . "</button>"; } elseif ($this->shouldProcess) { $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick='location.href=\"{$end_URL}\"; sListView.save_checks(\"end\", \"{$moduleString}\");'>" . SugarThemeRegistry::current()->getImage("end", "alt='" . $this->local_app_strings['LNK_LIST_END'] . "' border='0' align='absmiddle'") . "</button>"; $next_link = "<button type='button' name='listViewNextButton' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick='location.href=\"{$next_URL}\"; sListView.save_checks({$next_offset}, \"{$moduleString}\");'>" . SugarThemeRegistry::current()->getImage("next", "alt='" . $this->local_app_strings['LNK_LIST_NEXT'] . "' border='0' align='absmiddle'") . "</button>"; } else { $onClick = ''; if (0 != preg_match('/javascript.*/', $next_URL)) { $onClick = "\"{$next_URL};\""; } else { $onClick = "'location.href=\"{$next_URL}\";'"; } $next_link = "<button type='button' name='listViewNextButton' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick=" . $onClick . ">" . SugarThemeRegistry::current()->getImage("next", "alt='" . $this->local_app_strings['LNK_LIST_NEXT'] . "' border='0' align='absmiddle'") . "</button>"; $onClick = ''; if (0 != preg_match('/javascript.*/', $end_URL)) { $onClick = "\"{$end_URL};\""; } else { $onClick = "'location.href=\"{$end_URL}\";'"; } $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick=" . $onClick . ">" . SugarThemeRegistry::current()->getImage("end", "alt='" . $this->local_app_strings['LNK_LIST_END'] . "' border='0' align='absmiddle'") . "</button>"; } } $GLOBALS['log']->info("Offset (next, current, prev)({$next_offset}, {$current_offset}, {$previous_offset})"); $GLOBALS['log']->info("Start/end records ({$start_record}, {$end_record})"); $end_record = $end_record - 1; echo "<script>\n function select_overlib() {\n return overlib('<a style=\\'width: 150px\\' name=\"thispage\" class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' onclick=\\'if (document.MassUpdate.select_entire_list.value==1){document.MassUpdate.select_entire_list.value=0;sListView.check_all(document.MassUpdate, \"mass[]\", true, {$this->records_per_page})}else {sListView.check_all(document.MassUpdate, \"mass[]\", true)};\\' href=\\'#\\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_CURRENT']} ({$this->records_per_page})‎</a>" . "<a style=\\'width: 150px\\' name=\"selectall\" class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' onclick=\\'sListView.check_entire_list(document.MassUpdate, \"mass[]\",true,{$row_count});\\' href=\\'#\\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']} ({$row_count})‎</a>" . "<a style=\\'width: 150px\\' name=\"deselect\" class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' onclick=\\'sListView.clear_all(document.MassUpdate, \"mass[]\", false);\\' href=\\'#\\'>{$this->local_app_strings['LBL_LISTVIEW_NONE']}</a>" . "', CENTER, '" . "', STICKY, MOUSEOFF, 3000, CLOSETEXT, '<img border=0 src=" . SugarThemeRegistry::current()->getImageURL('close_inline.gif') . ">', WIDTH, 150, CLOSETITLE, '" . $this->local_app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE'] . "', CLOSECLICK, FGCLASS, 'olOptionsFgClass', " . "CGCLASS, 'olOptionsCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olOptionsCapFontClass', CLOSEFONTCLASS, 'olOptionsCloseFontClass');\n }\n </script>"; if ($this->show_select_menu) { $select_link = "<a id='select_link' onclick='return select_overlib();' href=\"#\">" . $this->local_app_strings['LBL_LINK_SELECT'] . " <img src='" . SugarThemeRegistry::current()->getImageURL('MoreDetail.png') . "' width='11' height='7' border='0''>" . "</a>"; } else { $select_link = " "; } // put overlib strings into functions to avoid backslash plague! /*echo "<script> function export_overlib() { return overlib('<a style=\'width: 150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'return sListView.send_form(true, \"{$_REQUEST['module']}\", \"export.php\", \"{$this->local_app_strings['LBL_LISTVIEW_NO_SELECTED']}\")\' href=\'#\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_SELECTED']}</a>" . "<a style=\'width: 150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'return sListView.send_form(false, \"{$_REQUEST['module']}\", \"export.php\", \"{$this->local_app_strings['LBL_LISTVIEW_NO_SELECTED']}\")\' href=\'#\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_CURRENT']}</a>" . "<a style=\'width: 150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' href=\'export.php?module={$_REQUEST['module']}\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']}</a>" . "', CAPTION, '" . $this->local_app_strings['LBL_EXPORT'] . "', STICKY, MOUSEOFF, 3000, CLOSETEXT, '<img border=0 style=\'margin-left:2px; margin-right: 2px;\' src=" . $this->local_image_path . "close.gif>', WIDTH, 150, CLOSETITLE, '" . $this->local_app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE'] . "', CLOSECLICK, FGCLASS, 'olOptionsFgClass', " . "CGCLASS, 'olOptionsCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olOptionsCapFontClass', CLOSEFONTCLASS, 'olOptionsCloseFontClass'); } </script>"; */ //$export_link = "<a id='export_link' onclick='return export_overlib();' href=\"#\">".SugarThemeRegistry::current()->getImage("export","alt='".$this->local_app_strings['LBL_EXPORT']."' border='0' align='absmiddle'")." ".$this->local_app_strings['LBL_EXPORT']."</a>"; $export_link = '<input class="button" type="button" value="' . $this->local_app_strings['LBL_EXPORT'] . '" ' . 'onclick="return sListView.send_form(true, \'' . $_REQUEST['module'] . '\', \'index.php?entryPoint=export\',\'' . $this->local_app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\')">'; if ($this->show_delete_button) { $delete_link = '<input class="button" type="button" name="Delete" value="' . $this->local_app_strings['LBL_DELETE_BUTTON_LABEL'] . '" onclick="return sListView.send_mass_update(\'selected\',\'' . $this->local_app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\', 1)">'; } else { $delete_link = ' '; } $admin = new Administration(); $admin->retrieveSettings('system'); $user_merge = $current_user->getPreference('mailmerge_on'); if ($user_merge == 'on' && isset($admin->settings['system_mailmerge_on']) && $admin->settings['system_mailmerge_on']) { echo "<script>\n function mailmerge_overlib() {\n return overlib('<a style=\\'width: 150px\\' class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' onclick=\\'return sListView.send_form(true, \"MailMerge\", \"index.php\", \"{$this->local_app_strings['LBL_LISTVIEW_NO_SELECTED']}\")\\' href=\\'#\\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_SELECTED']}</a>" . "<a style=\\'width: 150px\\' class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' href=\\'index.php?action=index&module=MailMerge\\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_CURRENT']}</a>" . "<a style=\\'width: 150px\\' class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' href=\\'index.php?action=index&module=MailMerge&entire=true\\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']}</a>" . "', CAPTION, '" . $this->local_app_strings['LBL_MAILMERGE'] . "', STICKY, MOUSEOFF, 3000, CLOSETEXT, '<img border=0 style=\\'margin-left:2px; margin-right: 2px;\\' src=" . $this->local_image_path . "close.gif>', WIDTH, 150, CLOSETITLE, '" . $this->local_app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE'] . "', CLOSECLICK, FGCLASS, 'olOptionsFgClass', " . "CGCLASS, 'olOptionsCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olOptionsCapFontClass', CLOSEFONTCLASS, 'olCloseFontClass');\n }\n </script>"; $merge_link = " | <a id='mailmerge_link' onclick='return mailmerge_overlib()'; href=\"#\">" . $this->local_app_strings['LBL_MAILMERGE'] . "</a>"; } else { $merge_link = " "; } $selected_objects_span = " | {$this->local_app_strings['LBL_LISTVIEW_SELECTED_OBJECTS']}<input style='border: 0px; background: transparent; font-size: inherit; color: inherit' type='text' readonly name='selectCount[]' value='" . (!empty($select_entire_list) ? $row_count : 0) . "' />"; if ($_REQUEST['module'] == 'Home' || $this->local_current_module == 'Import' || $this->show_export_button == false || !empty($sugar_config['disable_export']) || !empty($sugar_config['admin_export_only']) && !(is_admin($current_user) || ACLController::moduleSupportsACL($_REQUEST['module']) && ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'access') == ACL_ALLOW_ENABLED && (ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'admin') == ACL_ALLOW_ADMIN || ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'admin') == ACL_ALLOW_ADMIN_DEV))) { if ($_REQUEST['module'] != 'InboundEmail' && $_REQUEST['module'] != 'EmailMan' && $_REQUEST['module'] != 'iFrames') { $selected_objects_span = ''; } $export_link = " "; $merge_link = " "; } elseif ($_REQUEST['module'] != "Accounts" && $_REQUEST['module'] != "Cases" && $_REQUEST['module'] != "Contacts" && $_REQUEST['module'] != "Leads" && $_REQUEST['module'] != "Opportunities") { $merge_link = " "; } if ($this->show_paging == true) { if (!empty($sugar_config['disable_count_query'])) { if ($row_count > $end_record) { $row_count .= '+'; } } $html_text = ''; $html_text .= "<tr class='pagination'>\n"; $html_text .= "<td COLSPAN=\"{$col_count}\" align=\"right\">\n"; //$html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\" >$export_link$merge_link$selected_objects_span</td>\n"; //$html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\" >"; if ($subpanel_def != null) { include_once 'include/SubPanel/SubPanelTiles.php'; $subpanelTiles = new SubPanelTiles($sugarbean); $html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\" >"; //attempt to get the query to recreate this subpanel if (!empty($this->response)) { $response =& $this->response; } else { $response = SugarBean::get_union_related_list($sugarbean, $this->sortby, $this->sort_order, $this->query_where, $current_offset, -1, -1, $this->query_limit, $subpanel_def); $this->response = $response; } //if query is present, then pass it in as parameter if (isset($response['query']) && !empty($response['query'])) { $html_text .= $subpanelTiles->get_buttons($subpanel_def, $response['query']); } else { $html_text .= $subpanelTiles->get_buttons($subpanel_def); } } else { $html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\" nowrap>{$select_link} {$export_link} {$delete_link} {$selected_objects_span}"; } $html_text .= "</td>\n<td nowrap align=\"right\">" . $start_link . " " . $previous_link . " <span class='pageNumbers'>(" . $start_record . " - " . $end_record . " " . $this->local_app_strings['LBL_LIST_OF'] . " " . $row_count . ")</span> " . $next_link . " " . $end_link . "</td></tr></table>\n"; $html_text .= "</td>\n"; $html_text .= "</tr>\n"; $this->xTemplate->assign("PAGINATION", $html_text); } //C.L. - Fix for 23461 if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') { $_SESSION['export_where'] = $this->query_where; } $this->xTemplate->parse($xtemplateSection . ".list_nav_row"); } }
/** * @return void * @param unknown $data * @param unknown $xTemplateSection * @param unknown $html_varName * @desc INTERNAL FUNCTION process the List Navigation * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function processListNavigation($xtemplateSection, $html_varName, $current_offset, $next_offset, $previous_offset, $row_count, $sugarbean = null, $subpanel_def = null, $col_count = 20) { global $export_module; global $sugar_config; global $current_user; global $currentModule; global $app_strings; $start_record = $current_offset + 1; if (!is_numeric($col_count)) { $col_count = 20; } if ($row_count == 0) { $start_record = 0; } $end_record = $start_record + $this->records_per_page; // back up the the last page. if ($end_record > $row_count + 1) { $end_record = $row_count + 1; } // Determine the start location of the last page if ($row_count == 0) { $number_pages = 0; } else { $number_pages = floor(($row_count - 1) / $this->records_per_page); } $last_offset = $number_pages * $this->records_per_page; if (empty($this->query_limit) || $this->query_limit > $this->records_per_page) { $this->base_URL = $this->getBaseURL($html_varName); $dynamic_url = ''; if ($this->is_dynamic) { $dynamic_url .= '&' . $this->getSessionVariableName($html_varName, 'ORDER_BY') . '=' . $this->getSessionVariable($html_varName, 'ORDER_BY') . '&sort_order=' . $this->sort_order . '&to_pdf=true&action=SubPanelViewer&subpanel=' . $this->subpanel_module; } $current_URL = htmlentities($this->base_URL . $current_offset . $dynamic_url); $start_URL = htmlentities($this->base_URL . "0" . $dynamic_url); $previous_URL = htmlentities($this->base_URL . $previous_offset . $dynamic_url); $next_URL = htmlentities($this->base_URL . $next_offset . $dynamic_url); $end_URL = htmlentities($this->base_URL . 'end' . $dynamic_url); if (!empty($this->start_link_wrapper)) { $current_URL = $this->start_link_wrapper . $current_URL . $this->end_link_wrapper; $start_URL = $this->start_link_wrapper . $start_URL . $this->end_link_wrapper; $previous_URL = $this->start_link_wrapper . $previous_URL . $this->end_link_wrapper; $next_URL = $this->start_link_wrapper . $next_URL . $this->end_link_wrapper; $end_URL = $this->start_link_wrapper . $end_URL . $this->end_link_wrapper; } $moduleString = "{$currentModule}_{$html_varName}_offset"; $moduleStringOrder = "{$currentModule}_{$html_varName}_ORDER_BY"; if ($this->shouldProcess && !$this->multi_select_popup) { // check the checkboxes onload echo "<script>YAHOO.util.Event.addListener(window, \"load\", sListView.check_boxes);</script>\n"; $massUpdateRun = isset($_REQUEST['massupdate']) && $_REQUEST['massupdate'] == 'true'; $uids = empty($_REQUEST['uid']) || $massUpdateRun ? '' : $_REQUEST['uid']; $select_entire_list = $massUpdateRun ? 0 : (isset($_POST['select_entire_list']) ? $_POST['select_entire_list'] : (isset($_REQUEST['select_entire_list']) ? $_REQUEST['select_entire_list'] : 0)); echo "<textarea style='display: none' name='uid'>{$uids}</textarea>\n" . "<input type='hidden' name='select_entire_list' value='{$select_entire_list}'>\n" . "<input type='hidden' name='{$moduleString}' value='0'>\n" . "<input type='hidden' name='{$moduleStringOrder}' value='0'>\n"; } $GLOBALS['log']->debug("Offsets: (start, previous, next, last)(0, {$previous_offset}, {$next_offset}, {$last_offset})"); if (0 == $current_offset) { $start_link = "<button type='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' class='button' disabled>" . SugarThemeRegistry::current()->getImage("start_off", "aborder='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_START']) . "</button>"; $previous_link = "<button type='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' class='button' disabled>" . SugarThemeRegistry::current()->getImage("previous_off", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_PREVIOUS']) . "</button>"; } else { if ($this->multi_select_popup) { // nav links for multiselect popup, submit form to save checks. $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick='javascript:save_checks(0, \"{$moduleString}\");'>" . SugarThemeRegistry::current()->getImage("start", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_START']) . "</button>"; $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick='javascript:save_checks({$previous_offset}, \"{$moduleString}\");'>" . SugarThemeRegistry::current()->getImage("previous", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_PREVIOUS']) . "</button>"; } elseif ($this->shouldProcess) { $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick='location.href=\"{$start_URL}\"; sListView.save_checks(0, \"{$moduleString}\");'>" . SugarThemeRegistry::current()->getImage("start", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_START']) . "</button>"; $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick='location.href=\"{$previous_URL}\"; sListView.save_checks({$previous_offset}, \"{$moduleString}\");'>" . SugarThemeRegistry::current()->getImage("previous", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_PREVIOUS']) . "</button>"; } else { $onClick = ''; if (0 != preg_match('/javascript.*/', $start_URL)) { $onClick = "\"{$start_URL};\""; } else { $onClick = "'location.href=\"{$start_URL}\";'"; } $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick=" . $onClick . ">" . SugarThemeRegistry::current()->getImage("start", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_START']) . "</button>"; $onClick = ''; if (0 != preg_match('/javascript.*/', $previous_URL)) { $onClick = "\"{$previous_URL};\""; } else { $onClick = "'location.href=\"{$previous_URL}\";'"; } $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick=" . $onClick . ">" . SugarThemeRegistry::current()->getImage("previous", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_PREVIOUS']) . "</button>"; } } if ($last_offset <= $current_offset) { $end_link = "<button type='button' name='listViewEndButton' title='{$this->local_app_strings['LNK_LIST_END']}' class='button' disabled>" . SugarThemeRegistry::current()->getImage("end_off", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_END']) . "</button>"; $next_link = "<button type='button' name='listViewNextButton' title='{$this->local_app_strings['LNK_LIST_NEXT']}' class='button' disabled>" . SugarThemeRegistry::current()->getImage("next_off", "aborder='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_NEXT']) . "</button>"; } else { if ($this->multi_select_popup) { // nav links for multiselect popup, submit form to save checks. $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick='javascript:save_checks({$last_offset}, \"{$moduleString}\");'>" . SugarThemeRegistry::current()->getImage("end", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_END']) . "</button>"; if (!empty($sugar_config['disable_count_query'])) { $end_link = ''; } $next_link = "<button type='button' name='listViewNextButton' title='{$this->local_app_strings['LNK_LIST_NEXT']}' class='button' onClick='javascript:save_checks({$next_offset}, \"{$moduleString}\");'>" . SugarThemeRegistry::current()->getImage("next", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_NEXT']) . "</button>"; } elseif ($this->shouldProcess) { $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick='location.href=\"{$end_URL}\"; sListView.save_checks(\"end\", \"{$moduleString}\");'>" . SugarThemeRegistry::current()->getImage("end", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_END']) . "</button>"; $next_link = "<button type='button' name='listViewNextButton' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick='location.href=\"{$next_URL}\"; sListView.save_checks({$next_offset}, \"{$moduleString}\");'>" . SugarThemeRegistry::current()->getImage("next", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_NEXT']) . "</button>"; } else { $onClick = ''; if (0 != preg_match('/javascript.*/', $next_URL)) { $onClick = "\"{$next_URL};\""; } else { $onClick = "'location.href=\"{$next_URL}\";'"; } $next_link = "<button type='button' name='listViewNextButton' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick=" . $onClick . ">" . SugarThemeRegistry::current()->getImage("next", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_NEXT']) . "</button>"; $onClick = ''; if (0 != preg_match('/javascript.*/', $end_URL)) { $onClick = "\"{$end_URL};\""; } else { $onClick = "'location.href=\"{$end_URL}\";'"; } $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick=" . $onClick . ">" . SugarThemeRegistry::current()->getImage("end", "border='0' align='absmiddle'", null, null, '.gif', $this->local_app_strings['LNK_LIST_END']) . "</button>"; } } $GLOBALS['log']->info("Offset (next, current, prev)({$next_offset}, {$current_offset}, {$previous_offset})"); $GLOBALS['log']->info("Start/end records ({$start_record}, {$end_record})"); $end_record = $end_record - 1; $script_href = "<a style=\\'width: 150px\\' name=\"thispage\" class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' onclick=\\'if (document.MassUpdate.select_entire_list.value==1){document.MassUpdate.select_entire_list.value=0;sListView.check_all(document.MassUpdate, \"mass[]\", true, {$this->records_per_page})}else {sListView.check_all(document.MassUpdate, \"mass[]\", true)};\\' href=\\'#\\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_CURRENT']} ({$this->records_per_page})‎</a>" . "<a style=\\'width: 150px\\' name=\"selectall\" class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' onclick=\\'sListView.check_entire_list(document.MassUpdate, \"mass[]\",true,{$row_count});\\' href=\\'#\\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']} ({$row_count})‎</a>" . "<a style=\\'width: 150px\\' name=\"deselect\" class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' onclick=\\'sListView.clear_all(document.MassUpdate, \"mass[]\", false);\\' href=\\'#\\'>{$this->local_app_strings['LBL_LISTVIEW_NONE']}</a>"; $close_inline_img = SugarThemeRegistry::current()->getImage('close_inline', 'border=0', null, null, ".gif", $app_strings['LBL_CLOSEINLINE']); echo "<script>\n function select_dialog() {\n \tvar \$dialog = \$('<div></div>')\n\t\t\t\t\t.html('<a style=\\'width: 150px\\' name=\"thispage\" class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' onclick=\\'if (document.MassUpdate.select_entire_list.value==1){document.MassUpdate.select_entire_list.value=0;sListView.check_all(document.MassUpdate, \"mass[]\", true, {$this->records_per_page})}else {sListView.check_all(document.MassUpdate, \"mass[]\", true)};\\' href=\\'javascript:void(0)\\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_CURRENT']} ({$this->records_per_page})‎</a>" . "<a style=\\'width: 150px\\' name=\"selectall\" class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' onclick=\\'sListView.check_entire_list(document.MassUpdate, \"mass[]\",true,{$row_count});\\' href=\\'javascript:void(0)\\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']} ({$row_count})‎</a>" . "<a style=\\'width: 150px\\' name=\"deselect\" class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' onclick=\\'sListView.clear_all(document.MassUpdate, \"mass[]\", false);\\' href=\\'javascript:void(0)\\'>{$this->local_app_strings['LBL_LISTVIEW_NONE']}</a>')\n\t\t\t\t\t.dialog({\n\t\t\t\t\t\tautoOpen: false,\n\t\t\t\t\t\twidth: 150\n\t\t\t\t\t});\n\t\t\t\t\t\$dialog.dialog('open');\n\n }\n </script>"; if ($this->show_select_menu) { $total_label = ""; $total = $row_count; $pageTotal = $row_count > 0 ? $end_record - $start_record + 1 : 0; if (!empty($GLOBALS['sugar_config']['disable_count_query']) && $GLOBALS['sugar_config']['disable_count_query'] === true && $total > $pageTotal) { $this->show_plus = true; $total = $pageTotal; $total_label = $total . '+'; } else { $this->show_plus = false; $total_label = $total; } echo "<input type='hidden' name='show_plus' value='{$this->show_plus}'>\n"; //Bug#52931: Replace with actionMenu //$select_link = "<a id='select_link' onclick='return select_dialog();' href=\"javascript:void(0)\">".$this->local_app_strings['LBL_LINK_SELECT']." ".SugarThemeRegistry::current()->getImage('MoreDetail', 'border=0', 11, 7, '.png', $app_strings['LBL_MOREDETAIL'])."</a>"; $menuItems = array("<input title=\"" . $app_strings['LBL_SELECT_ALL_TITLE'] . "\" type='checkbox' class='checkbox massall' name='massall' id='massall' value='' onclick='sListView.check_all(document.MassUpdate, \"mass[]\", this.checked);' /><a href='javascript: void(0);'></a>", "<a name='thispage' id='button_select_this_page' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' onclick='if (document.MassUpdate.select_entire_list.value==1){document.MassUpdate.select_entire_list.value=0;sListView.check_all(document.MassUpdate, \"mass[]\", true, {$pageTotal})}else {sListView.check_all(document.MassUpdate, \"mass[]\", true)};' href='#'>{$app_strings['LBL_LISTVIEW_OPTION_CURRENT']} ({$pageTotal})‎</a>", "<a name='selectall' id='button_select_all' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' onclick='sListView.check_entire_list(document.MassUpdate, \"mass[]\",true,{$total});' href='#'>{$app_strings['LBL_LISTVIEW_OPTION_ENTIRE']} ({$total_label})‎</a>", "<a name='deselect' id='button_deselect' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' onclick='sListView.clear_all(document.MassUpdate, \"mass[]\", false);' href='#'>{$app_strings['LBL_LISTVIEW_NONE']}</a>"); require_once 'include/Smarty/plugins/function.sugar_action_menu.php'; $select_link = smarty_function_sugar_action_menu(array('class' => 'clickMenu selectmenu', 'id' => 'selectLink', 'buttons' => $menuItems), $this->xTemplate); } else { $select_link = " "; } $export_link = '<input class="button" type="button" value="' . $this->local_app_strings['LBL_EXPORT'] . '" ' . 'onclick="return sListView.send_form(true, \'' . $_REQUEST['module'] . '\', \'index.php?entryPoint=export\',\'' . $this->local_app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\')">'; if ($this->show_delete_button) { $delete_link = '<input class="button" type="button" id="delete_button" name="Delete" value="' . $this->local_app_strings['LBL_DELETE_BUTTON_LABEL'] . '" onclick="return sListView.send_mass_update(\'selected\',\'' . $this->local_app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\', 1)">'; } else { $delete_link = ' '; } $admin = new Administration(); $admin->retrieveSettings('system'); $user_merge = $current_user->getPreference('mailmerge_on'); if ($user_merge == 'on' && isset($admin->settings['system_mailmerge_on']) && $admin->settings['system_mailmerge_on']) { echo "<script>\n function mailmerge_dialog(el) {\n \tvar \$dialog = \$('<div></div>')\n\t\t\t\t\t.html('<a style=\\'width: 150px\\' class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' onclick=\\'return sListView.send_form(true, \"MailMerge\", \"index.php\", \"{$this->local_app_strings['LBL_LISTVIEW_NO_SELECTED']}\")\\' href=\\'javascript:void(0)\\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_SELECTED']}</a>" . "<a style=\\'width: 150px\\' class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' href=\\'index.php?action=index&module=MailMerge\\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_CURRENT']}</a>" . "<a style=\\'width: 150px\\' class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' href=\\'index.php?action=index&module=MailMerge&entire=true\\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']}</a>')\n\t\t\t\t\t.dialog({\n\t\t\t\t\t\tautoOpen: false,\n\t\t\t\t\t\ttitle: '" . $this->local_app_strings['LBL_MAILMERGE'] . "',\n\t\t\t\t\t\twidth: 150,\n\t\t\t\t\t\tposition: {\n\t\t\t\t\t\t my: myPos,\n\t\t\t\t\t\t at: atPos,\n\t\t\t\t\t\t of: \$(el)\n\t\t\t\t\t \t}\n\t\t\t\t\t});\n\n }\n </script>"; $merge_link = " | <a id='mailmerge_link' onclick='return mailmerge_dialog(this)'; href=\"javascript:void(0)\">" . $this->local_app_strings['LBL_MAILMERGE'] . "</a>"; } else { $merge_link = " "; } $selected_objects_span = " | {$this->local_app_strings['LBL_LISTVIEW_SELECTED_OBJECTS']}<input style='border: 0px; background: transparent; font-size: inherit; color: inherit' type='text' readonly name='selectCount[]' value='" . (isset($_POST['mass']) ? count($_POST['mass']) : 0) . "' />"; if ($_REQUEST['module'] == 'Home' || $this->local_current_module == 'Import' || $this->show_export_button == false || !empty($sugar_config['disable_export']) || !empty($sugar_config['admin_export_only']) && !(is_admin($current_user) || ACLController::moduleSupportsACL($_REQUEST['module']) && ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'access') == ACL_ALLOW_ENABLED && (ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'admin') == ACL_ALLOW_ADMIN || ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'admin') == ACL_ALLOW_ADMIN_DEV))) { if ($_REQUEST['module'] != 'InboundEmail' && $_REQUEST['module'] != 'EmailMan' && $_REQUEST['module'] != 'iFrames') { $selected_objects_span = ''; } $export_link = " "; $merge_link = " "; } elseif ($_REQUEST['module'] != "Accounts" && $_REQUEST['module'] != "Cases" && $_REQUEST['module'] != "Contacts" && $_REQUEST['module'] != "Leads" && $_REQUEST['module'] != "Opportunities") { $merge_link = " "; } if ($this->show_paging == true) { if (!empty($sugar_config['disable_count_query'])) { if ($row_count > $end_record) { $row_count .= '+'; } } $html_text = ''; $html_text .= "<tr class='pagination' role='presentation'>\n"; $html_text .= "<td COLSPAN=\"{$col_count}\" align=\"right\">\n"; //$html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\" >$export_link$merge_link$selected_objects_span</td>\n"; //$html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\" >"; if ($subpanel_def != null) { include_once 'include/SubPanel/SubPanelTiles.php'; $subpanelTiles = new SubPanelTiles($sugarbean); $html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\" >"; //attempt to get the query to recreate this subpanel if (!empty($this->response)) { $response =& $this->response; } else { $response = SugarBean::get_union_related_list($sugarbean, $this->sortby, $this->sort_order, $this->query_where, $current_offset, -1, -1, $this->query_limit, $subpanel_def); $this->response = $response; } //if query is present, then pass it in as parameter if (isset($response['query']) && !empty($response['query'])) { $html_text .= $subpanelTiles->get_buttons($subpanel_def, $response['query']); } else { $html_text .= $subpanelTiles->get_buttons($subpanel_def); } } else { $html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\" nowrap>{$select_link} {$export_link} {$delete_link} {$selected_objects_span}"; } $html_text .= "</td>\n<td nowrap align=\"right\">" . $start_link . " " . $previous_link . " <span class='pageNumbers'>(" . $start_record . " - " . $end_record . " " . $this->local_app_strings['LBL_LIST_OF'] . " " . $row_count . ")</span> " . $next_link . " " . $end_link . "</td></tr></table>\n"; $html_text .= "</td>\n"; $html_text .= "</tr>\n"; $this->xTemplate->assign("PAGINATION", $html_text); } //C.L. - Fix for 23461 if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') { $_SESSION['export_where'] = $this->query_where; } $this->xTemplate->parse($xtemplateSection . ".list_nav_row"); } }
* In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". ********************************************************************************/ //Bug 30094, If zlib is enabled, it can break the calls to header() due to output buffering. This will only work php5.2+ ini_set('zlib.output_compression', 'Off'); ob_start(); require_once 'include/export_utils.php'; global $sugar_config; global $locale; global $current_user; global $app_list_strings; $the_module = clean_string($_REQUEST['module']); if ($sugar_config['disable_export'] || !empty($sugar_config['admin_export_only']) && !(is_admin($current_user) || ACLController::moduleSupportsACL($the_module) && ACLAction::getUserAccessLevel($current_user->id, $the_module, 'access') == ACL_ALLOW_ENABLED && (ACLAction::getUserAccessLevel($current_user->id, $the_module, 'admin') == ACL_ALLOW_ADMIN || ACLAction::getUserAccessLevel($current_user->id, $the_module, 'admin') == ACL_ALLOW_ADMIN_DEV))) { die($GLOBALS['app_strings']['ERR_EXPORT_DISABLED']); } //check to see if this is a request for a sample or for a regular export if (!empty($_REQUEST['sample'])) { //call special method that will create dummy data for bean as well as insert standard help message. $content = exportSample(clean_string($_REQUEST['module'])); } else { if (!empty($_REQUEST['uid'])) { $content = export(clean_string($_REQUEST['module']), $_REQUEST['uid'], isset($_REQUEST['members']) ? $_REQUEST['members'] : false); } else { $content = export(clean_string($_REQUEST['module'])); } } $filename = $_REQUEST['module']; //use label if one is defined
public function testgetUserAccessLevel() { //tes for accoounts module with two different actions $this->assertEquals(90, ACLAction::getUserAccessLevel('1', 'Accounts', 'list')); $this->assertEquals(89, ACLAction::getUserAccessLevel('1', 'Accounts', 'access')); //tes for users module with two different actions $this->assertEquals(90, ACLAction::getUserAccessLevel('1', 'Users', 'list')); $this->assertEquals(89, ACLAction::getUserAccessLevel('1', 'Users', 'access')); }
/** * Constructor for the bean, it performs following tasks: * * 1. Initalized a database connections * 2. Load the vardefs for the module implemeting the class. cache the entries * if needed * 3. Setup row-level security preference * All implementing classes must call this constructor using the parent::__construct() * */ public function __construct() { // FIXME: this will be removed, needed for ensuring BeanFactory is always used //$this->checkBacktrace(); global $dictionary, $current_user; $this->db = DBManagerFactory::getInstance(); if (empty($this->module_name)) { $this->module_name = $this->module_dir; } if (isset($this->disable_team_security)) { $this->disable_row_level_security = $this->disable_team_security; } // Verify that current user is not null then do an ACL check. The current user check is to support installation. if (!$this->disable_row_level_security && !empty($current_user->id) && (is_admin($current_user) || $this->bean_implements('ACL') && (ACLAction::getUserAccessLevel($current_user->id, $this->module_dir, 'access') == ACL_ALLOW_ENABLED && (ACLAction::getUserAccessLevel($current_user->id, $this->module_dir, 'admin') == ACL_ALLOW_ADMIN || ACLAction::getUserAccessLevel($current_user->id, $this->module_dir, 'admin') == ACL_ALLOW_ADMIN_DEV)))) { $this->disable_row_level_security = true; } if (false == $this->disable_vardefs && (empty(self::$loadedDefs[$this->object_name]) || !empty($GLOBALS['reload_vardefs']))) { $refresh = inDeveloperMode() || !empty($_SESSION['developerMode']); if ($refresh && !empty(VardefManager::$inReload["{$this->module_dir}:{$this->object_name}"])) { // if we're already reloading this vardef, no need to do it again $refresh = false; } VardefManager::loadVardef($this->module_dir, $this->object_name, $refresh, array("bean" => $this)); // build $this->column_fields from the field_defs if they exist if (!empty($dictionary[$this->object_name]['fields'])) { foreach ($dictionary[$this->object_name]['fields'] as $key => $value_array) { $column_fields[] = $key; if (!empty($value_array['required']) && !empty($value_array['name'])) { $this->required_fields[$value_array['name']] = 1; } } $this->column_fields = $column_fields; } //setup custom fields if (!isset($this->custom_fields) && empty($this->disable_custom_fields)) { $this->setupCustomFields($this->module_dir); } //load up field_arrays from CacheHandler; if (empty($this->list_fields)) { $this->list_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'list_fields'); } if (empty($this->column_fields)) { $this->column_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'column_fields'); } if (empty($this->required_fields)) { $this->required_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'required_fields'); } if (isset($GLOBALS['dictionary'][$this->object_name]) && !$this->disable_vardefs) { $this->field_name_map = $dictionary[$this->object_name]['fields']; $this->field_defs = $dictionary[$this->object_name]['fields']; if (isset($dictionary[$this->object_name]['name_format_map'])) { $this->name_format_map = $dictionary[$this->object_name]['name_format_map']; } if (!empty($dictionary[$this->object_name]['optimistic_locking'])) { $this->optimistic_lock = true; } if (isset($dictionary[$this->object_name]['importable'])) { $this->importable = isTruthy($dictionary[$this->object_name]['importable']); } } self::$loadedDefs[$this->object_name]['column_fields'] =& $this->column_fields; self::$loadedDefs[$this->object_name]['list_fields'] =& $this->list_fields; self::$loadedDefs[$this->object_name]['required_fields'] =& $this->required_fields; self::$loadedDefs[$this->object_name]['field_name_map'] =& $this->field_name_map; self::$loadedDefs[$this->object_name]['field_defs'] =& $this->field_defs; self::$loadedDefs[$this->object_name]['name_format_map'] =& $this->name_format_map; } else { $this->column_fields =& self::$loadedDefs[$this->object_name]['column_fields']; $this->list_fields =& self::$loadedDefs[$this->object_name]['list_fields']; $this->required_fields =& self::$loadedDefs[$this->object_name]['required_fields']; $this->field_name_map =& self::$loadedDefs[$this->object_name]['field_name_map']; $this->field_defs =& self::$loadedDefs[$this->object_name]['field_defs']; $this->name_format_map =& self::$loadedDefs[$this->object_name]['name_format_map']; $this->added_custom_field_defs = true; if (!isset($this->custom_fields) && empty($this->disable_custom_fields)) { $this->setupCustomFields($this->module_dir, false); } if (!empty($dictionary[$this->object_name]['optimistic_locking'])) { $this->optimistic_lock = true; } } // Verify that current user is not null then do an ACL check. The current user check is to support installation. if (!$this->disable_row_level_security && !empty($current_user->id) && !isset($this->disable_team_security) && !SugarACL::checkAccess($this->module_dir, 'team_security', array('bean' => $this))) { // We can disable team security for this module $this->disable_row_level_security = true; } if ($this->bean_implements('ACL')) { $this->acl_fields = isset($dictionary[$this->object_name]['acl_fields']) && $dictionary[$this->object_name]['acl_fields'] === false ? false : true; if (!empty($current_user->id)) { ACLField::loadUserFields($this->module_dir, $this->object_name, $current_user->id); } $this->addVisibilityStrategy("ACLVisibility"); } $this->populateDefaultValues(); if (isset($this->disable_team_security)) { $this->disable_row_level_security = $this->disable_team_security; } }
function process($lvsParams = array()) { global $current_user; $currentSearchFields = array(); $configureView = true; // configure view or regular view $query = false; $whereArray = array(); $lvsParams['massupdate'] = false; // apply filters if (isset($this->filters) || $this->myItemsOnly) { $whereArray = $this->buildWhere(); } $this->lvs->export = false; $this->lvs->multiSelect = false; $this->lvs->quickViewLinks = false; // columns foreach ($this->columns as $name => $val) { if (!empty($val['default']) && $val['default']) { $displayColumns[strtoupper($name)] = $val; $displayColumns[strtoupper($name)]['label'] = trim($displayColumns[strtoupper($name)]['label'], ':'); } } $this->lvs->displayColumns = $displayColumns; $this->lvs->lvd->setVariableName($this->seedBean->object_name, array()); $lvsParams['overrideOrder'] = true; $lvsParams['orderBy'] = 'date_entered'; $lvsParams['sortOrder'] = 'DESC'; // Get the real module list if (empty($this->selectedCategories)) { $mod_list = $this->categories; } else { $mod_list = array_flip($this->selectedCategories); //27949, here the key of $this->selectedCategories is not module name, the value is module name, so array_flip it. } $admin_modules = array(); $owner_modules = array(); $regular_modules = array(); foreach ($mod_list as $module => $ignore) { // Handle the UserFeed differently if ($module == 'UserFeed') { $regular_modules[] = 'UserFeed'; continue; } if (ACLAction::getUserAccessLevel($current_user->id, $module, 'view') <= ACL_ALLOW_NONE) { // Not enough access to view any records, don't add it to any lists continue; } if (ACLAction::getUserAccessLevel($current_user->id, $module, 'view') == ACL_ALLOW_OWNER) { $owner_modules[] = $module; } else { $regular_modules[] = $module; } } if (!empty($this->displayTpl)) { //MFH BUG #14296 $where = ''; if (!empty($whereArray)) { $where = '(' . implode(') AND (', $whereArray) . ')'; } $module_limiter = " sugarfeed.related_module in ('" . implode("','", $regular_modules) . "')"; if (count($owner_modules) > 0) { $module_limiter = " ((sugarfeed.related_module IN ('" . implode("','", $regular_modules) . "') " . ") "; if (count($owner_modules) > 0) { $module_limiter .= "OR (sugarfeed.related_module IN('" . implode("','", $owner_modules) . "') AND sugarfeed.assigned_user_id = '" . $current_user->id . "' " . ") "; } $module_limiter .= ")"; } if (!empty($where)) { $where .= ' AND '; } $where .= $module_limiter; $this->lvs->setup($this->seedBean, $this->displayTpl, $where, $lvsParams, 0, $this->displayRows, array('name', 'description', 'date_entered', 'created_by', 'link_url', 'link_type')); foreach ($this->lvs->data['data'] as $row => $data) { $this->lvs->data['data'][$row]['CREATED_BY'] = get_assigned_user_name($data['CREATED_BY']); $this->lvs->data['data'][$row]['NAME'] = str_replace("{this.CREATED_BY}", $this->lvs->data['data'][$row]['CREATED_BY'], $data['NAME']); } // assign a baseURL w/ the action set as DisplayDashlet foreach ($this->lvs->data['pageData']['urls'] as $type => $url) { // awu Replacing action=DisplayDashlet with action=DynamicAction&DynamicAction=DisplayDashlet if ($type == 'orderBy') { $this->lvs->data['pageData']['urls'][$type] = preg_replace('/(action=.*&)/Ui', 'action=DynamicAction&DynamicAction=displayDashlet&', $url); } else { $this->lvs->data['pageData']['urls'][$type] = preg_replace('/(action=.*&)/Ui', 'action=DynamicAction&DynamicAction=displayDashlet&', $url) . '&sugar_body_only=1&id=' . $this->id; } } $this->lvs->ss->assign('dashletId', $this->id); } }
/** * static function userHasAccess($user_id, $category, $action, $is_owner = false) * * @param GUID $user_id the user id who you want to check access for * @param STRING $category the category you would like to check access for * @param STRING $action the action of that category you would like to check access for * @param BOOLEAN OPTIONAL $is_owner if the object is owned by the user you are checking access for */ function userHasAccess($user_id, $category, $action, $type = 'module', $is_owner = false) { //check if we don't have it set in the cache if not lets reload the cache if (ACLAction::getUserAccessLevel($user_id, $category, 'access') < ACL_ALLOW_ENABLED) { return false; } if (empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { ACLAction::getUserActions($user_id, false); } if (!empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { return ACLAction::hasAccess($is_owner, $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess']); } return false; }
/** * static function userHasAccess($user_id, $category, $action, $is_owner = false) * * @param GUID $user_id the user id who you want to check access for * @param STRING $category the category you would like to check access for * @param STRING $action the action of that category you would like to check access for * @param BOOLEAN OPTIONAL $is_owner if the object is owned by the user you are checking access for */ public static function userHasAccess($user_id, $category, $action, $type = 'module', $is_owner = false) { global $current_user; //check if we don't have it set in the cache if not lets reload the cache if (ACLAction::getUserAccessLevel($user_id, $category, 'access', $type) < ACL_ALLOW_ENABLED) { return false; } if (empty(self::$acls[$user_id][$category][$type][$action])) { ACLAction::getUserActions($user_id, false); } if (!empty(self::$acls[$user_id][$category][$type][$action])) { if ($action == 'access' && self::$acls[$user_id][$category][$type][$action]['aclaccess'] == ACL_ALLOW_ENABLED) { return true; } return ACLAction::hasAccess($is_owner, self::$acls[$user_id][$category][$type][$action]['aclaccess']); } return false; }
/** * @return void * @param unknown $data * @param unknown $xTemplateSection * @param unknown $html_varName * @desc INTERNAL FUNCTION process the List Navigation * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function processListNavigation($xtemplateSection, $html_varName, $current_offset, $next_offset, $previous_offset, $row_count) { global $image_path, $export_module, $sugar_config, $current_user, $currentModule; $start_record = $current_offset + 1; if ($row_count == 0) { $start_record = 0; } $end_record = $start_record + $this->records_per_page; // back up the the last page. if ($end_record > $row_count + 1) { $end_record = $row_count + 1; } // Deterime the start location of the last page if ($row_count == 0) { $number_pages = 0; } else { $number_pages = floor(($row_count - 1) / $this->records_per_page); } $last_offset = $number_pages * $this->records_per_page; if (empty($this->query_limit) || $this->query_limit > $this->records_per_page) { $this->base_URL = $this->getBaseURL($html_varName); $dynamic_url = ''; if ($this->is_dynamic) { $dynamic_url .= '&' . $this->getSessionVariableName('CELL', 'ORDER_BY') . '=' . $this->getSessionVariable('CELL', 'ORDER_BY') . '&sort_order=' . $this->sort_order . '&to_pdf=true&action=SubPanelViewer&subpanel=' . $this->subpanel_module; } $current_URL = $this->base_URL . $current_offset . $dynamic_url; $start_URL = $this->base_URL . "0" . $dynamic_url; $previous_URL = $this->base_URL . $previous_offset . $dynamic_url; $next_URL = $this->base_URL . $next_offset . $dynamic_url; $end_URL = $this->base_URL . '-100' . $dynamic_url; if (!empty($this->start_link_wrapper)) { $current_URL = $this->start_link_wrapper . $current_URL . $this->end_link_wrapper; $start_URL = $this->start_link_wrapper . $start_URL . $this->end_link_wrapper; $previous_URL = $this->start_link_wrapper . $previous_URL . $this->end_link_wrapper; $next_URL = $this->start_link_wrapper . $next_URL . $this->end_link_wrapper; $end_URL = $this->start_link_wrapper . $end_URL . $this->end_link_wrapper; } $moduleString = "{$currentModule}_{$html_varName}_offset"; if ($this->shouldProcess && !$this->multi_select_popup) { // check the checkboxes onload echo '<script>YAHOO.util.Event.addListener(window, "load", sListView.check_boxes);</script>'; $uids = empty($_REQUEST['uid']) || !empty($_REQUEST['massupdate']) && $_REQUEST['massupdate'] == 'true' ? '' : $_REQUEST['uid']; echo "<textarea style='display: none' name='uid'>{$uids}</textarea>\n\t\t\t<input type='hidden' name='{$moduleString}' value='0'>"; } $GLOBALS['log']->debug("Offsets: (start, previous, next, last)(0, {$previous_offset}, {$next_offset}, {$last_offset})"); if (0 == $current_offset) { $start_link = get_image($image_path . "start_off", "alt='" . $this->local_app_strings['LNK_LIST_START'] . "' border='0' align='absmiddle'") . " " . $this->local_app_strings['LNK_LIST_START']; $previous_link = get_image($image_path . "previous_off", "alt='" . $this->local_app_strings['LNK_LIST_PREVIOUS'] . "' border='0' align='absmiddle'") . " " . $this->local_app_strings['LNK_LIST_PREVIOUS']; } else { if ($this->multi_select_popup) { // nav links for multiselect popup, submit form to save checks. $start_link = "<a href=\"#\" onclick=\"javascript:save_checks(0, '{$moduleString}')\" class=\"listViewPaginationLinkS1\">" . get_image($image_path . "start", "alt='" . $this->local_app_strings['LNK_LIST_START'] . "' border='0' align='absmiddle'") . " " . $this->local_app_strings['LNK_LIST_START'] . "</a>"; $previous_link = "<a href=\"#\" onclick=\"javascript:save_checks({$previous_offset}, '{$moduleString}')\" class=\"listViewPaginationLinkS1\">" . get_image($image_path . "previous", "alt='" . $this->local_app_strings['LNK_LIST_PREVIOUS'] . "' border='0' align='absmiddle'") . " " . $this->local_app_strings['LNK_LIST_PREVIOUS'] . "</a>"; } elseif ($this->shouldProcess) { // TODO: make popups / listview check saving the same $start_link = "<a href=\"{$start_URL}\" onclick=\"javascript:return sListView.save_checks(0, '{$moduleString}')\" class=\"listViewPaginationLinkS1\">" . get_image($image_path . "start", "alt='" . $this->local_app_strings['LNK_LIST_START'] . "' border='0' align='absmiddle'") . " " . $this->local_app_strings['LNK_LIST_START'] . "</a>"; $previous_link = "<a href=\"{$previous_URL}\" onclick=\"javascript:return sListView.save_checks({$previous_offset}, '{$moduleString}')\" class=\"listViewPaginationLinkS1\">" . get_image($image_path . "previous", "alt='" . $this->local_app_strings['LNK_LIST_PREVIOUS'] . "' border='0' align='absmiddle'") . " " . $this->local_app_strings['LNK_LIST_PREVIOUS'] . "</a>"; } else { $start_link = "<a href=\"{$start_URL}\" class=\"listViewPaginationLinkS1\">" . get_image($image_path . "start", "alt='" . $this->local_app_strings['LNK_LIST_START'] . "' border='0' align='absmiddle'") . " " . $this->local_app_strings['LNK_LIST_START'] . "</a>"; $previous_link = "<a href=\"{$previous_URL}\" class=\"listViewPaginationLinkS1\">" . get_image($image_path . "previous", "alt='" . $this->local_app_strings['LNK_LIST_PREVIOUS'] . "' border='0' align='absmiddle'") . " " . $this->local_app_strings['LNK_LIST_PREVIOUS'] . "</a>"; } } if ($last_offset <= $current_offset) { $end_link = $this->local_app_strings['LNK_LIST_END'] . " " . get_image($image_path . "end_off", "alt='" . $this->local_app_strings['LNK_LIST_END'] . "' border='0' align='absmiddle'"); $next_link = $this->local_app_strings['LNK_LIST_NEXT'] . " " . get_image($image_path . "next_off", "alt='" . $this->local_app_strings['LNK_LIST_NEXT'] . "' border='0' align='absmiddle'"); } else { if ($this->multi_select_popup) { // nav links for multiselect popup, submit form to save checks. $end_link = "<a href=\"#\" onclick=\"javascript:save_checks({$last_offset}, '{$moduleString}')\" class=\"listViewPaginationLinkS1\">" . $this->local_app_strings['LNK_LIST_END'] . " " . get_image($image_path . "end", "alt='" . $this->local_app_strings['LNK_LIST_END'] . "' border='0' align='absmiddle'") . "</a>"; if (!empty($sugar_config['disable_count_query'])) { $end_link = ''; } $next_link = "<a href=\"#\" onclick=\"javascript:save_checks({$next_offset}, '{$moduleString}')\" class=\"listViewPaginationLinkS1\">" . $this->local_app_strings['LNK_LIST_NEXT'] . " " . get_image($image_path . "next", "alt='" . $this->local_app_strings['LNK_LIST_NEXT'] . "' border='0' align='absmiddle'") . "</a>"; } elseif ($this->shouldProcess) { $end_link = "<a href=\"{$end_URL}\" onclick=\"javascript:return sListView.save_checks({$last_offset}, '{$moduleString}')\" class=\"listViewPaginationLinkS1\">" . $this->local_app_strings['LNK_LIST_END'] . " " . get_image($image_path . "end", "alt='" . $this->local_app_strings['LNK_LIST_END'] . "' border='0' align='absmiddle'") . "</a>"; $next_link = "<a href=\"{$next_URL}\" onclick=\"javascript:return sListView.save_checks({$next_offset}, '{$moduleString}')\" class=\"listViewPaginationLinkS1\">" . $this->local_app_strings['LNK_LIST_NEXT'] . " " . get_image($image_path . "next", "alt='" . $this->local_app_strings['LNK_LIST_NEXT'] . "' border='0' align='absmiddle'") . "</a>"; } else { $end_link = "<a href=\"{$end_URL}\" class=\"listViewPaginationLinkS1\">" . $this->local_app_strings['LNK_LIST_END'] . " " . get_image($image_path . "end", "alt='" . $this->local_app_strings['LNK_LIST_END'] . "' border='0' align='absmiddle'") . "</a>"; $next_link = "<a href=\"{$next_URL}\" class=\"listViewPaginationLinkS1\">" . $this->local_app_strings['LNK_LIST_NEXT'] . " " . get_image($image_path . "next", "alt='" . $this->local_app_strings['LNK_LIST_NEXT'] . "' border='0' align='absmiddle'") . "</a>"; } } $GLOBALS['log']->info("Offset (next, current, prev)({$next_offset}, {$current_offset}, {$previous_offset})"); $GLOBALS['log']->info("Start/end records ({$start_record}, {$end_record})"); $end_record = $end_record - 1; // put overlib strings into functions to avoid backslash plague! echo "<script> \n\t\t\tfunction export_overlib() {\n\t\t\t\treturn overlib('<a style=\\'width: 150px\\' class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' onclick=\\'return sListView.send_form(true, \"{$_REQUEST['module']}\", \"export.php\", \"{$this->local_app_strings['LBL_LISTVIEW_NO_SELECTED']}\")\\' href=\\'#\\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_SELECTED']}</a>" . "<a style=\\'width: 150px\\' class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' onclick=\\'return sListView.send_form(false, \"{$_REQUEST['module']}\", \"export.php\", \"{$this->local_app_strings['LBL_LISTVIEW_NO_SELECTED']}\")\\' href=\\'#\\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_CURRENT']}</a>" . "<a style=\\'width: 150px\\' class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' href=\\'export.php?module={$_REQUEST['module']}\\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']}</a>" . "', CAPTION, '" . $this->local_app_strings['LBL_EXPORT'] . "', STICKY, MOUSEOFF, 3000, CLOSETEXT, '<img border=0 src=" . $this->local_image_path . "close_inline.gif>', WIDTH, 150, CLOSETITLE, '" . $this->local_app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE'] . "', CLOSECLICK, FGCLASS, 'olOptionsFgClass', " . "CGCLASS, 'olOptionsCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olOptionsCapFontClass', CLOSEFONTCLASS, 'olOptionsCloseFontClass');\n\t\t\t}\n\t\t\t</script>"; $export_link = "<a id='export_link' onclick='return export_overlib();' href=\"#\" class=\"listViewPaginationLinkS1\">" . get_image($image_path . "export", "alt='" . $this->local_app_strings['LBL_EXPORT'] . "' border='0' align='absmiddle'") . " " . $this->local_app_strings['LBL_EXPORT'] . "</a>"; require_once "modules/Administration/Administration.php"; $admin = new Administration(); $admin->retrieveSettings('system'); $user_merge = $current_user->getPreference('mailmerge_on'); if ($user_merge == 'on' && isset($admin->settings['system_mailmerge_on']) && $admin->settings['system_mailmerge_on']) { echo "<script>\n\t\t\t\tfunction mailmerge_overlib() {\n\t\t\t\t\treturn overlib('<a style=\\'width: 150px\\' class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' onclick=\\'return sListView.send_form(true, \"MailMerge\", \"index.php\", \"{$this->local_app_strings['LBL_LISTVIEW_NO_SELECTED']}\")\\' href=\\'#\\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_SELECTED']}</a>" . "<a style=\\'width: 150px\\' class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' href=\\'index.php?action=index&module=MailMerge\\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_CURRENT']}</a>" . "<a style=\\'width: 150px\\' class=\\'menuItem\\' onmouseover=\\'hiliteItem(this,\"yes\");\\' onmouseout=\\'unhiliteItem(this);\\' href=\\'index.php?action=index&module=MailMerge&entire=true\\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']}</a>" . "', CAPTION, '" . $this->local_app_strings['LBL_MAILMERGE'] . "', STICKY, MOUSEOFF, 3000, CLOSETEXT, '<img border=0 src=" . $this->local_image_path . "close_inline.gif>', WIDTH, 150, CLOSETITLE, '" . $this->local_app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE'] . "', CLOSECLICK, FGCLASS, 'olOptionsFgClass', " . "CGCLASS, 'olOptionsCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olOptionsCapFontClass', CLOSEFONTCLASS, 'olCloseFontClass');\n\t\t\t\t}\t\t\t\t\n\t\t\t</script>"; $merge_link = " | <a id='mailmerge_link' onclick='return mailmerge_overlib()'; href=\"#\" class=\"listViewPaginationLinkS1\">" . $this->local_app_strings['LBL_MAILMERGE'] . "</a>"; } else { $merge_link = " "; } $selected_objects_span = " | {$this->local_app_strings['LBL_LISTVIEW_SELECTED_OBJECTS']}<input class='listViewPaginationTdS1' style='border: 0px; background: transparent; font-size: inherit; color: inherit' type='text' readonly name='selectCount[]' value='0' />"; if ($_REQUEST['module'] == 'Home' || $this->local_current_module == 'Import' || $this->show_export_button == false || !empty($sugar_config['disable_export']) || !empty($sugar_config['admin_export_only']) && !(is_admin($current_user) || ACLController::moduleSupportsACL($_REQUEST['module']) && ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'access') == ACL_ALLOW_ENABLED && ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'admin') == ACL_ALLOW_ADMIN)) { $selected_objects_span = ''; $export_link = " "; $merge_link = " "; } else { if ($_REQUEST['module'] != "Accounts" && $_REQUEST['module'] != "Cases" && $_REQUEST['module'] != "Contacts" && $_REQUEST['module'] != "Leads" && $_REQUEST['module'] != "Opportunities") { $merge_link = " "; } } if ($this->show_paging == true) { if (!empty($sugar_config['disable_count_query'])) { if ($row_count > $end_record) { $row_count .= '+'; } } $html_text = ''; $html_text .= "<tr>\n"; $html_text .= "<td COLSPAN=\"20\" align=\"right\">\n"; $html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\" class=\"listViewPaginationTdS1\">{$export_link}{$merge_link}{$selected_objects_span}</td>\n"; $html_text .= "<td nowrap align=\"right\" class=\"listViewPaginationTdS1\" id='listViewPaginationButtons'>" . $start_link . " " . $previous_link . " <span class='pageNumbers'>(" . $start_record . " - " . $end_record . " " . $this->local_app_strings['LBL_LIST_OF'] . " " . $row_count . ")</span> " . $next_link . " " . $end_link . "</td></tr></table>\n"; $html_text .= "</td>\n"; $html_text .= "</tr>\n"; $this->xTemplate->assign("PAGINATION", $html_text); } $_SESSION['export_where'] = $this->query_where; $this->xTemplate->parse($xtemplateSection . ".list_nav_row"); } }
function create_query($query_name = 'query', $field_list_name = 'select_fields') { $query = "SELECT "; $field_list_name_array = $this->{$field_list_name}; foreach ($field_list_name_array as $field) { $field = trim($field); if (strstr($field, ',')) { $fields = explode(',', $field); foreach ($fields as $field_in_field) { $field_not_null[] = $this->wrapIfNull($field_in_field); } } else { $field_not_null[] = $this->wrapIfNull($field); } } $this->{$field_list_name} = $field_not_null; $query .= implode(",", $this->{$field_list_name}); $query .= $this->from . "\n"; $where_auto = " " . $this->focus->table_name . ".deleted=0 \n"; // Start ACL check global $current_user, $mod_strings; if (!is_admin($current_user)) { $list_action = ACLAction::getUserAccessLevel($current_user->id, $this->focus->module_dir, 'list', $type = 'module'); $view_action = ACLAction::getUserAccessLevel($current_user->id, $this->focus->module_dir, 'view', $type = 'module'); if ($list_action == ACL_ALLOW_NONE || $view_action == ACL_ALLOW_NONE) { $this->handleException($mod_strings['LBL_NO_ACCESS']); } if ($list_action == ACL_ALLOW_OWNER || $view_action == ACL_ALLOW_OWNER) { $where_auto .= " AND " . $this->focus->table_name . ".assigned_user_id='" . $current_user->id . "' \n"; } } // End ACL check if (!empty($this->where)) { $query .= " WHERE ({$this->where}) \nAND " . $where_auto; } else { $query .= " WHERE " . $where_auto; } if (!empty($this->group_order_by_arr) && is_array($this->group_order_by_arr) && $query_name != 'summary_query') { foreach ($this->group_order_by_arr as $group_order_by) { array_unshift($this->order_by_arr, $group_order_by); } } else { if (!empty($this->group_order_by_arr) && is_array($this->group_order_by_arr) && $query_name == 'summary_query' && empty($this->summary_order_by_arr)) { foreach ($this->group_order_by_arr as $group_order_by) { array_unshift($this->summary_order_by_arr, $group_order_by); } } } // if we are doing the details part of a summary query.. we need the details // to be sorted by the group by if (!empty($this->group_by_arr) && is_array($this->group_by_arr) && $query_name != 'total_query') { $groups = array(); // FIXME: see if we need to handle NULLs on GROUP BY // foreach ( $this->group_by_arr as $group_by ) { // $groups[] = $this->db->convert($group_by, "IFNULL", array("''")); // } // to be sorted by the group by $query .= " GROUP BY " . join(",", $this->group_by_arr); } if ($query_name == 'summary_query') { if (!empty($this->summary_order_by_arr)) { $this->summary_order_by_arr = array_unique($this->summary_order_by_arr); $query .= " ORDER BY " . implode(',', $this->summary_order_by_arr); } } else { if ($query_name == 'query') { if (!empty($this->order_by_arr)) { $this->order_by_arr = array_unique($this->order_by_arr); $query .= " ORDER BY " . implode(',', $this->order_by_arr); } } } $this->{$query_name} = $query; array_push($this->query_list, $this->{$query_name}); }