function get_list_view_data() { $data = parent::get_list_view_data(); $delete = ''; $group_owner = false; $securitygroup_name = ""; if (empty($data['SECURITYGROUP_ID'])) { $securitygroup_name = "All"; } else { require_once 'modules/SecurityGroups/SecurityGroup.php'; $securitygroup = new SecurityGroup(); $securitygroup->retrieve($data['SECURITYGROUP_ID']); $securitygroup_name = $securitygroup->name; if ($securitygroup->assigned_user_id == $GLOBALS['current_user']->id) { $group_owner = true; } } if (is_admin($GLOBALS['current_user']) || $data['CREATED_BY'] == $GLOBALS['current_user']->id || $group_owner) { $delete = SugarThemeRegistry::current()->getImage('delete_inline', 'width="12" height="12" border="0" align="absmiddle" style="vertical-align: bottom;" onclick=\'Message.deleteMessage("' . $data['ID'] . '", "{this.id}")\'', null, null, '.gif', ''); } $username = ""; if (empty($data['CREATED_BY'])) { $username = "******"; } else { require_once 'modules/Users/User.php'; $user = new User(); $user->retrieve($data['CREATED_BY']); $username = $user->user_name; } $data['NAME'] = $data['DESCRIPTION']; $data['NAME'] = '<div class="list view" style="padding:5px;border:none;">' . html_entity_decode($data['NAME']); $data['NAME'] .= '<div class="byLineBox" style="padding-top: 2px"><span class="byLineLeft">' . $username . ' [' . $securitygroup_name . ']'; $data['NAME'] .= ' </span><span style="cursor: pointer;" class="byLineRight"> ' . $this->getTimeLapse($data['DATE_ENTERED']) . ' ' . $delete . '</span></div>'; return $data; }
function handle($request) { $groupIdParamName = 'group'; $groupId = Form::getField($request, $groupIdParamName); if (strlen($groupId) == 0) { die(IsatisText::getText("MissingParameter").": ".$groupIdParamName); } $g = SecurityGroup::getById($groupId); if ($g == NULL) { die(Text::getText("GroupNotFound").": '".$groupId."'"); } $allPermissions = SecurityPermission::getAll(); $allResources = SecurityResource::getAll(); foreach ($allResources as $res) { foreach ($allPermissions as $perm) { $fieldName = "res".$res->getId()."_perm".$perm->getId(); $value = Form::getField($request, $fieldName); if ($value == "on") { if (!$g->hasPermission($res, $perm)) { $g->addPermission($res, $perm); } } else { $g->removePermission($res, $perm); } } } return $g; }
function printContent() { ?> <table border="0"> <tr bgcolor=<?=BGCOLOR_ALT?>> <th>#</th> <? if (SecurityGroup::havePermission("DELETE")) { ?> <th></th> <? } ?> <th><?=Text::getText("Name")?></th> <th> </th> <th> </th> </tr> <? $bg = TRUE; ?> <? foreach ($this->groups as $g) { ?> <? $bg = !$bg; ?> <tr<? if ($bg) { ?> bgcolor=<?=BGCOLOR_ALT?><? } ?>> <td> <?=$g->getId()?> </td> <? if (SecurityGroup::havePermission("DELETE")) { ?> <td><a href="<?=$this->groupDeletePage?>?<?=$this->groupDeleteParamGroupId?>=<?=$g->getId()?>" onClick="return confirm('<?=Text::getText('ConfirmDeleteGroup')?>')"><img src="<?=$this->imgDeleteSrc?>" border="0" alt="<?=Text::getText('Delete')?>"></a></td> <? } ?> <td> <a href="<?=$this->groupEditPage?>?<?=$this->groupEditParamGroupId?>=<?=$g->getId()?>"><?=$g->getName()?></a> </td> <td> <a href="<?=$this->groupMembersPage?>?<?=$this->groupMembersParamGroupId?>=<?=$g->getId()?>"><?=Text::getText("Members")?></a> </td> <td> <a href="<?=$this->groupPermissionsPage?>?<?=$this->groupPermissionsParamGroupId?>=<?=$g->getId()?>"><?=Text::getText("Permissions")?></a> </td> </tr> <? } ?> </table> <? }
function display() { $this->fromModuleBuilder = isset($_REQUEST['MB']) || !empty($_REQUEST['view_package']) && $_REQUEST['view_package'] != 'studio'; if ($this->fromModuleBuilder) { return; //no support for MB } global $current_user; global $mod_strings; $smarty = new Sugar_Smarty(); $smarty->assign('title', $mod_strings['LBL_DEVELOPER_TOOLS']); $smarty->assign('question', $mod_strings['LBL_REMOVE_LAYOUT']); $smarty->assign('mod_strings', $mod_strings); $module_name = $_REQUEST['view_module']; $smarty->assign('view_module', $module_name); $groupLayout = $_REQUEST['grpLayout']; $smarty->assign('groupLayout', $groupLayout); require_once 'modules/SecurityGroups/SecurityGroup.php'; $groupFocus = new SecurityGroup(); $groupFocus->retrieve($groupLayout); $groupName = $groupFocus->name; // set up language files //$smarty->assign ( 'language', $parser->getLanguage() ) ; // for sugar_translate in the smarty template //$smarty->assign('from_mb',$this->fromModuleBuilder); $mb = new ModuleBuilder(); if (!isset($_REQUEST['view_package'])) { $_REQUEST['view_package'] = 'studio'; } $module =& $mb->getPackageModule($_REQUEST['view_package'], $_REQUEST['view_module']); $package = $mb->packages[$_REQUEST['view_package']]; $package->loadModuleTitles(); $ajax = new AjaxCompose(); $ajax->addCrumb(translate('LBL_STUDIO', 'ModuleBuilder'), 'ModuleBuilder.main("studio")'); $ajax->addCrumb(translate($module_name), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $module_name . '")'); $ajax->addCrumb(translate('LBL_LAYOUTS', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=addlayout&layouts=1&view_module=' . $module_name . '")'); $ajax->addCrumb(translate($groupName), ''); $ajax->addCrumb($mod_strings['LBL_REMOVE_LAYOUT'], ''); //$ajax->addSection ( 'center', $moduleName . ' ' . translate('LBL_ADD_LAYOUT'), $ajax->addSection('center', $mod_strings['LBL_ADD_LAYOUT'], $smarty->fetch('modules/ModuleBuilder/tpls/removegrouplayoutprompt.tpl')); echo $ajax->getJavascript(); }
private function getAssignableUsers() { if ($this->distributionMethod == 'singleUser') { return array(); } $distributionOptions = $this->getDistributionOptions(); if (empty($distributionOptions)) { return array(); } switch ($distributionOptions[0]) { case 'security_group': if (file_exists('modules/SecurityGroups/SecurityGroup.php')) { require_once 'modules/SecurityGroups/SecurityGroup.php'; $security_group = new SecurityGroup(); $security_group->retrieve($distributionOptions[1]); $group_users = $security_group->get_linked_beans('users', 'User'); $users = array(); $r_users = array(); if ($distributionOptions[2] != '') { $r_users = $this->getRoleUsers($distributionOptions[2]); } foreach ($group_users as $group_user) { if ($distributionOptions[2] != '' && !isset($r_users[$group_user->id])) { continue; } $users[$group_user->id] = $group_user->name; } break; } //No Security Group module found - fall through. //No Security Group module found - fall through. case 'role': $users = $this->getRoleUsers($distributionOptions[2]); break; case 'all': default: $users = get_user_array(false); break; } return $users; }
function display($preview = false) { $packageName = isset($_REQUEST['view_package']) ? $_REQUEST['view_package'] : ''; require_once 'modules/ModuleBuilder/parsers/ParserFactory.php'; $parser = ParserFactory::getParser($this->editLayout, $this->editModule, $packageName); $smarty = parent::constructSmarty($parser); $smarty->assign('action', 'searchViewSave'); $smarty->assign('view', $this->editLayout); $smarty->assign('helpName', 'searchViewEditor'); $smarty->assign('helpDefault', 'modify'); /* BEGIN - SECURITY GROUPS */ $groupLayout = ""; if (!empty($_REQUEST['grpLayout'])) { $groupLayout = $_REQUEST['grpLayout']; } global $groupName; $groupName = "Default"; if (!isset($groupLayout) || empty($groupLayout)) { $groupLayout = ""; } else { //Get group name for display require_once 'modules/SecurityGroups/SecurityGroup.php'; $groupFocus = new SecurityGroup(); $groupFocus->retrieve($groupLayout); $groupName = $groupFocus->name; } $smarty->assign('grpLayout', $groupLayout); /* END - SECURITY GROUPS */ if ($preview) { echo $smarty->fetch("modules/ModuleBuilder/tpls/Preview/listView.tpl"); } else { $ajax = $this->constructAjax(); $ajax->addSection('center', translate($this->title), $smarty->fetch("modules/ModuleBuilder/tpls/listView.tpl")); echo $ajax->getJavascript(); } }
function inherit_parent(&$focus, $isUpdate) { global $sugar_config; //new record or if update from soap api for cases or bugs //TEST FOR PORTAL NOTES //if((!$isUpdate || ($isUpdate && !empty($focus->note_id) && ($focus->object_name == "Case" || $focus->object_name == "Bug"))) if (!$isUpdate && isset($sugar_config['securitysuite_inherit_parent']) && $sugar_config['securitysuite_inherit_parent'] == true) { $focus_module_dir = $focus->module_dir; $focus_id = $focus->id; //inherit only for those that support Security Groups $groupFocus = new SecurityGroup(); $security_modules = $groupFocus->getSecurityModules(); //if(!in_array($focus_module_dir,$security_modules)) { if (!in_array($focus_module_dir, array_keys($security_modules))) { //rost fix2 return; //don't inherit for this module } //from subpanel //PHP Notice error fix $parent_type = ""; $parent_id = ""; if (isset($_REQUEST['relate_to']) && isset($_REQUEST['relate_id'])) { //relate_to is not guaranteed to be a module name anymore. //if it isn't load the relationship and find the module name that way if (!in_array($_REQUEST['relate_to'], array_keys($security_modules))) { //check to see if relate_to is the relationship name require_once 'modules/Relationships/Relationship.php'; $rel_module = Relationship::get_other_module($_REQUEST['relate_to'], $focus_module_dir, $focus->db); if (isset($rel)) { $parent_type = $rel_module; $parent_id = $_REQUEST['relate_id']; } } else { $parent_type = $_REQUEST['relate_to']; $parent_id = $_REQUEST['relate_id']; } } if (isset($_SESSION['portal_id'])) { $parent_id = $_SESSION['user_id']; //soap stores contact id in user_id field $parent_type = "Contacts"; } //from activity type creation if ((empty($parent_type) || empty($parent_id)) && isset($_REQUEST['parent_type']) && isset($_REQUEST['parent_id'])) { $parent_type = $_REQUEST['parent_type']; $parent_id = $_REQUEST['parent_id']; } //full form from subpanel if ((empty($parent_type) || empty($parent_id)) && isset($_REQUEST['return_module']) && isset($_REQUEST['return_id'])) { $parent_type = $_REQUEST['return_module']; $parent_id = $_REQUEST['return_id']; } /** need to find relate fields...for example for Cases look to see if account_id is set */ //allow inheritance for all relate field types....iterate through and inherit each related field //if(empty($parent_type) || empty($parent_id)) { foreach ($focus->field_name_map as $name => $def) { if ($def['type'] == 'relate' && isset($def['id_name']) && isset($def['module']) && strtolower($def['module']) != "users") { if (isset($_REQUEST[$def['id_name']])) { $relate_parent_id = $_REQUEST[$def['id_name']]; $relate_parent_type = $def['module']; SecurityGroup::inherit_parentQuery($focus, $relate_parent_type, $relate_parent_id, $focus_id, $focus_module_dir); } else { if (isset($_SESSION['portal_id']) && isset($_SESSION[$def['id_name']])) { //catch soap account $relate_parent_id = $_SESSION[$def['id_name']]; $relate_parent_type = $def['module']; SecurityGroup::inherit_parentQuery($focus, $relate_parent_type, $relate_parent_id, $focus_id, $focus_module_dir); } } } } //} if (!empty($parent_type) && !empty($parent_id)) { // && $parent_type != "Emails" && $parent_type != "Meetings") { SecurityGroup::inherit_parentQuery($focus, $parent_type, $parent_id, $focus_id, $focus_module_dir); } //end if parent type/id } //end if new record }
"><?php echo Text::getText("Members"); ?> </a> </td> <td> <a href="groupPermissions.php?id=<?php echo $g->getId(); ?> "><?php echo Text::getText("Permissions"); ?> </a> </td> </tr> <? } ?> </table> <? if (SecurityGroup::havePermission("ADD")) { ?> <h3><?php echo Text::getText("AddGroup"); ?> </h3> <form method="POST" action="groupAdd.php"> <input type="hidden" name="action" value="save"> <table border="0" cellpadding="2"> <tr> <th><?php echo Text::getText("Name"); ?> </th> <td><input type="text" name="name" value=""></td> </tr> <tr>
function findEmailFromBeanIds($beanIds, $beanType, $whereArr) { global $current_user; $q = ''; $whereAdd = ""; $relatedIDs = ''; if ($beanIds != '') { foreach ($beanIds as $key => $value) { $beanIds[$key] = '\'' . $value . '\''; } $relatedIDs = implode(',', $beanIds); } if ($beanType == 'accounts') { if (isset($whereArr['first_name'])) { $whereArr['name'] = $whereArr['first_name']; } unset($whereArr['last_name']); unset($whereArr['first_name']); } foreach ($whereArr as $column => $clause) { if (!empty($whereAdd)) { $whereAdd .= " OR "; } $clause = $current_user->db->quote($clause); $whereAdd .= "{$column} LIKE '{$clause}%'"; } $table = $beanType; $module = ucfirst($table); $class = substr($module, 0, strlen($module) - 1); require_once "modules/{$module}/{$class}.php"; $person = new $class(); if ($person->ACLAccess('list')) { if ($relatedIDs != '') { $where = "({$table}.deleted = 0 AND eabr.primary_address = 1 AND {$table}.id in ({$relatedIDs}))"; } else { $where = "({$table}.deleted = 0 AND eabr.primary_address = 1)"; } if (ACLController::requireOwner($module, 'list')) { $where = $where . " AND ({$table}.assigned_user_id = '{$current_user->id}')"; } // if if (!empty($whereAdd)) { $where .= " AND ({$whereAdd})"; } if ($beanType === 'accounts') { $t = "SELECT {$table}.id, '' first_name, {$table}.name last_name, eabr.primary_address, ea.email_address, '{$module}' module "; } else { $t = "SELECT {$table}.id, {$table}.first_name, {$table}.last_name, eabr.primary_address, ea.email_address, '{$module}' module "; } $t .= "FROM {$table} "; $t .= "JOIN email_addr_bean_rel eabr ON ({$table}.id = eabr.bean_id and eabr.deleted=0) "; $t .= "JOIN email_addresses ea ON (eabr.email_address_id = ea.id) "; $t .= " WHERE {$where}"; /* BEGIN - SECURITY GROUPS */ //this function may not even be used anymore. Seems like findEmailFromBeanIds is preferred now if ($person->bean_implements('ACL') && ACLController::requireSecurityGroup($module, 'list')) { require_once 'modules/SecurityGroups/SecurityGroup.php'; global $current_user; $owner_where = $person->getOwnerWhere($current_user->id); $group_where = SecurityGroup::getGroupWhere($table, $module, $current_user->id); $t .= " AND (" . $owner_where . " or " . $group_where . ") "; } /* END - SECURITY GROUPS */ } // if return $t; }
function get_bean_select_array($add_blank = true, $bean_name, $display_columns, $where = '', $order_by = '', $blank_is_none = false) { global $beanFiles; require_once $beanFiles[$bean_name]; $focus = new $bean_name(); $user_array = array(); $key = $bean_name == 'EmailTemplate' ? $bean_name : $bean_name . $display_columns . $where . $order_by; $user_array = get_register_value('select_array', $key); if (!$user_array) { $db = DBManagerFactory::getInstance(); $temp_result = array(); $query = "SELECT {$focus->table_name}.id, {$display_columns} as display from {$focus->table_name} "; $query .= "where "; if ($where != '') { $query .= $where . " AND "; } $query .= " {$focus->table_name}.deleted=0"; /* BEGIN - SECURITY GROUPS */ global $current_user, $sugar_config; if ($focus->module_dir == 'Users' && !is_admin($current_user) && isset($sugar_config['securitysuite_filter_user_list']) && $sugar_config['securitysuite_filter_user_list'] == true) { require_once 'modules/SecurityGroups/SecurityGroup.php'; $group_where = SecurityGroup::getGroupUsersWhere($current_user->id); $query .= " AND (" . $group_where . ") "; } else { if ($focus->bean_implements('ACL') && ACLController::requireSecurityGroup($focus->module_dir, 'list')) { require_once 'modules/SecurityGroups/SecurityGroup.php'; $owner_where = $focus->getOwnerWhere($current_user->id); $group_where = SecurityGroup::getGroupWhere($focus->table_name, $focus->module_dir, $current_user->id); if (!empty($owner_where)) { $query .= " AND (" . $owner_where . " or " . $group_where . ") "; } else { $query .= ' AND ' . $group_where; } } } /* END - SECURITY GROUPS */ if ($order_by != '') { $query .= " order by {$focus->table_name}.{$order_by}"; } $GLOBALS['log']->debug("get_user_array query: {$query}"); $result = $db->query($query, true, "Error filling in user array: "); if ($add_blank == true) { // Add in a blank row if ($blank_is_none == true) { // set 'blank row' to "--None--" global $app_strings; $temp_result[''] = $app_strings['LBL_NONE']; } else { $temp_result[''] = ''; } } // Get the id and the name. while ($row = $db->fetchByAssoc($result)) { $temp_result[$row['id']] = $row['display']; } $user_array = $temp_result; set_register_value('select_array', $key, $temp_result); } return $user_array; }
function build_report_access_query(SugarBean $module, $alias) { $module->table_name = $alias; $where = ''; if ($module->bean_implements('ACL') && ACLController::requireOwner($module->module_dir, 'list')) { global $current_user; $owner_where = $module->getOwnerWhere($current_user->id); $where = ' AND ' . $owner_where; } if (file_exists('modules/SecurityGroups/SecurityGroup.php')) { /* BEGIN - SECURITY GROUPS */ if ($module->bean_implements('ACL') && ACLController::requireSecurityGroup($module->module_dir, 'list')) { require_once 'modules/SecurityGroups/SecurityGroup.php'; global $current_user; $owner_where = $module->getOwnerWhere($current_user->id); $group_where = SecurityGroup::getGroupWhere($alias, $module->module_dir, $current_user->id); if (!empty($owner_where)) { $where .= " AND (" . $owner_where . " or " . $group_where . ") "; } else { $where .= ' AND ' . $group_where; } } /* END - SECURITY GROUPS */ } return $where; }
<?php require_once "config.php"; require_once RESACCMAN_BASE . "/classes/Text.php"; require_once RESACCMAN_BASE . "/classes/html/GroupPermissionsForm.php"; $title = Text::getText("GroupPermissions"); if (GroupPermissionsForm::isSubmitted($_REQUEST)) { $g = GroupPermissionsForm::handle($_REQUEST); $today = date("r"); header("Location: groupPermissions.php?id=" . $g->getId() . "&saved=" . $today); } else { if (sizeof($_REQUEST['id']) > 0) { $g = SecurityGroup::getById($id); } } if ($g == NULL) { $errMsg = Text::getText("GroupNotFound") . ": '" . $id . "'"; die($errMsg); } $title .= ": " . $g->getName(); $form = new GroupPermissionsForm($g); if (strlen($_REQUEST['saved']) > 0) { $form->setMessage(IsatisText::getText("Saved") . ": " . $_REQUEST['saved']); } include "header.php"; ?> <h2><?php echo $title; ?> </h2><? $form->printContent();
function removePermission($resource, $permission) { SecurityGroup::requirePermission("CHANGE"); $group_id = $this->getId(); $resource_id = $resource->getId(); $permission_id = $permission->getId(); $sql = "DELETE FROM security_group_permission WHERE group_id = ".Database::sqlValue($group_id)." AND resource_id = ".Database::sqlValue($resource_id)." AND permission_id = ".Database::sqlValue($permission_id); Database::query($sql); }
/** * display * This method makes the Smarty variable assignments and then displays the * generated view. * @param $showTitle boolean value indicating whether or not to show a title on the resulting page * @param $ajaxSave boolean value indicating whether or not the operation is an Ajax save request * @return HTML display for view as String */ function display($showTitle = true, $ajaxSave = false) { global $mod_strings, $sugar_config, $app_strings, $app_list_strings, $theme, $current_user; if (isset($this->defs['templateMeta']['javascript'])) { if (is_array($this->defs['templateMeta']['javascript'])) { //$this->th->ss->assign('externalJSFile', 'modules/' . $this->module . '/metadata/editvewdefs.js'); $this->th->ss->assign('externalJSFile', $this->defs['templateMeta']['javascript']); } else { $this->th->ss->assign('scriptBlocks', $this->defs['templateMeta']['javascript']); } } $this->th->ss->assign('id', $this->fieldDefs['id']['value']); $this->th->ss->assign('offset', $this->offset + 1); $this->th->ss->assign('APP', $app_strings); $this->th->ss->assign('MOD', $mod_strings); $this->th->ss->assign('fields', $this->fieldDefs); $this->th->ss->assign('sectionPanels', $this->sectionPanels); $this->th->ss->assign('config', $sugar_config); $this->th->ss->assign('returnModule', $this->returnModule); $this->th->ss->assign('returnAction', $this->returnAction); $this->th->ss->assign('returnId', $this->returnId); $this->th->ss->assign('isDuplicate', $this->isDuplicate); $this->th->ss->assign('def', $this->defs); $this->th->ss->assign('useTabs', isset($this->defs['templateMeta']['useTabs']) && isset($this->defs['templateMeta']['tabDefs']) ? $this->defs['templateMeta']['useTabs'] : false); $this->th->ss->assign('maxColumns', isset($this->defs['templateMeta']['maxColumns']) ? $this->defs['templateMeta']['maxColumns'] : 2); $this->th->ss->assign('module', $this->module); $this->th->ss->assign('headerTpl', isset($this->defs['templateMeta']['form']['headerTpl']) ? $this->defs['templateMeta']['form']['headerTpl'] : 'include/' . $this->view . '/header.tpl'); $this->th->ss->assign('footerTpl', isset($this->defs['templateMeta']['form']['footerTpl']) ? $this->defs['templateMeta']['form']['footerTpl'] : 'include/' . $this->view . '/footer.tpl'); $this->th->ss->assign('current_user', $current_user); $this->th->ss->assign('bean', $this->focus); $this->th->ss->assign('isAuditEnabled', $this->focus->is_AuditEnabled()); $this->th->ss->assign('gridline', $current_user->getPreference('gridline') == 'on' ? '1' : '0'); $this->th->ss->assign('tabDefs', isset($this->defs['templateMeta']['tabDefs']) ? $this->defs['templateMeta']['tabDefs'] : false); $this->th->ss->assign('VERSION_MARK', getVersionedPath('')); global $js_custom_version; global $sugar_version; $this->th->ss->assign('SUGAR_VERSION', $sugar_version); $this->th->ss->assign('JS_CUSTOM_VERSION', $js_custom_version); //this is used for multiple forms on one page if (!empty($this->formName)) { $form_id = $this->formName; $form_name = $this->formName; } else { $form_id = $this->view; $form_name = $this->view; } if ($ajaxSave && empty($this->formName)) { $form_id = 'form_' . $this->view . '_' . $this->module; $form_name = $form_id; $this->view = $form_name; //$this->defs['templateMeta']['form']['buttons'] = array(); //$this->defs['templateMeta']['form']['buttons']['ajax_save'] = array('id' => 'AjaxSave', 'customCode'=>'<input type="button" class="button" value="Save" onclick="this.form.action.value=\'AjaxFormSave\';return saveForm(\''.$form_name.'\', \'multiedit_form_{$module}\', \'Saving {$module}...\');"/>'); } $form_name = $form_name == 'QuickCreate' ? "QuickCreate_{$this->module}" : $form_name; $form_id = $form_id == 'QuickCreate' ? "QuickCreate_{$this->module}" : $form_id; if (isset($this->defs['templateMeta']['preForm'])) { $this->th->ss->assign('preForm', $this->defs['templateMeta']['preForm']); } if (isset($this->defs['templateMeta']['form']['closeFormBeforeCustomButtons'])) { $this->th->ss->assign('closeFormBeforeCustomButtons', $this->defs['templateMeta']['form']['closeFormBeforeCustomButtons']); } if (isset($this->defs['templateMeta']['form']['enctype'])) { $this->th->ss->assign('enctype', 'enctype="' . $this->defs['templateMeta']['form']['enctype'] . '"'); } //for SugarFieldImage, we must set form enctype to "multipart/form-data" foreach ($this->fieldDefs as $field) { if (isset($field['type']) && $field['type'] == 'image') { $this->th->ss->assign('enctype', 'enctype="multipart/form-data"'); break; } } $this->th->ss->assign('showDetailData', $this->showDetailData); $this->th->ss->assign('showSectionPanelsTitles', $this->showSectionPanelsTitles); $this->th->ss->assign('form_id', $form_id); $this->th->ss->assign('form_name', $form_name); $this->th->ss->assign('set_focus_block', get_set_focus_js()); $this->th->ss->assign('form', isset($this->defs['templateMeta']['form']) ? $this->defs['templateMeta']['form'] : null); $this->th->ss->assign('includes', isset($this->defs['templateMeta']['includes']) ? $this->defs['templateMeta']['includes'] : null); $this->th->ss->assign('view', $this->view); //Calculate time & date formatting (may need to calculate this depending on a setting) global $timedate; $this->th->ss->assign('CALENDAR_DATEFORMAT', $timedate->get_cal_date_format()); $this->th->ss->assign('USER_DATEFORMAT', $timedate->get_user_date_format()); $time_format = $timedate->get_user_time_format(); $this->th->ss->assign('TIME_FORMAT', $time_format); $date_format = $timedate->get_cal_date_format(); $time_separator = ':'; if (preg_match('/\\d+([^\\d])\\d+([^\\d]*)/s', $time_format, $match)) { $time_separator = $match[1]; } // Create Smarty variables for the Calendar picker widget $t23 = strpos($time_format, '23') !== false ? '%H' : '%I'; if (!isset($match[2]) || $match[2] == '') { $this->th->ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . '%M'); } else { $pm = $match[2] == 'pm' ? '%P' : '%p'; $this->th->ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . '%M' . $pm); } $this->th->ss->assign('CALENDAR_FDOW', $current_user->get_first_day_of_week()); $this->th->ss->assign('TIME_SEPARATOR', $time_separator); $seps = get_number_seperators(); $this->th->ss->assign('NUM_GRP_SEP', $seps[0]); $this->th->ss->assign('DEC_SEP', $seps[1]); if ($this->view == 'EditView') { $height = $current_user->getPreference('text_editor_height'); $width = $current_user->getPreference('text_editor_width'); $height = isset($height) ? $height : '300px'; $width = isset($width) ? $width : '95%'; $this->th->ss->assign('RICH_TEXT_EDITOR_HEIGHT', $height); $this->th->ss->assign('RICH_TEXT_EDITOR_WIDTH', $width); } else { $this->th->ss->assign('RICH_TEXT_EDITOR_HEIGHT', '100px'); $this->th->ss->assign('RICH_TEXT_EDITOR_WIDTH', '95%'); } $this->th->ss->assign('SHOW_VCR_CONTROL', $this->showVCRControl); $str = $this->showTitle($showTitle); //Use the output filter to trim the whitespace $this->th->ss->load_filter('output', 'trimwhitespace'); $str .= $this->th->displayTemplate($this->module, $form_name, $this->tpl, $ajaxSave, $this->defs); /* BEGIN - SECURITY GROUPS */ //if popup select add panel if user is a member of multiple groups to metadataFile global $sugar_config; if (isset($sugar_config['securitysuite_popup_select']) && $sugar_config['securitysuite_popup_select'] == true && empty($this->focus->fetched_row['id']) && $this->focus->module_dir != "Users" && $this->focus->module_dir != "SugarFeed") { //there are cases such as uploading an attachment to an email template where the request module may //not be the same as the current bean module. If that happens we can just skip it //however...let quickcreate through if ($this->view != 'QuickCreate' && (empty($_REQUEST['module']) || $_REQUEST['module'] != $this->focus->module_dir)) { return $str; } require_once 'modules/SecurityGroups/SecurityGroup.php'; $groupFocus = new SecurityGroup(); $security_modules = $groupFocus->getSecurityModules(); if (in_array($this->focus->module_dir, array_keys($security_modules))) { global $current_user; $group_count = $groupFocus->getMembershipCount($current_user->id); if ($group_count > 1) { $groups = $groupFocus->getUserSecurityGroups($current_user->id); $group_options = ''; foreach ($groups as $group) { $group_options .= '<option value="' . $group['id'] . '" label="' . $group['name'] . '" selected="selected">' . $group['name'] . '</option>'; } //multilingual support global $current_language; $ss_mod_strings = return_module_language($current_language, 'SecurityGroups'); $lbl_securitygroups_select = $ss_mod_strings['LBL_GROUP_SELECT']; $lbl_securitygroups = $ss_mod_strings['LBL_LIST_FORM_TITLE']; $group_panel = <<<EOQ <div class="edit view edit508 " id="detailpanel_securitygroups"> <h4> {$lbl_securitygroups_select} </h4> <table width="100%" cellspacing="1" cellpadding="0" border="0" class="edit view panelContainer" id="LBL_PANEL_SECURITYGROUPS"> <tbody><tr> <td width="12.5%" valign="top" scope="col" id="account_type_label"> {$lbl_securitygroups}: </td> <td width="37.5%" valign="top"> <select title="" id="securitygroup_list" name="securitygroup_list[]" multiple="multiple" size="{$group_count}"> {$group_options} </select> </td> </tr> </tbody></table> </div> EOQ; $group_panel = preg_replace("/[\r\n]+/", "", $group_panel); $group_panel_append = <<<EOQ <script> \$('#{$form_name}_tabs div:first').append(\$('{$group_panel}')); </script> EOQ; $str .= $group_panel_append; } } } /* END - SECURITY GROUPS */ return $str; }
<? require_once("config.php"); ?> <? require_once(RESACCMAN_BASE."/classes/SecurityGroup.php"); ?> <? require_once(RESACCMAN_BASE."/classes/Text.php"); ?> <? $g = new SecurityGroup(); $g->setName($name); if ($action == "save") { if (strlen($name) > 0) { $g->save(); header("Location: groups.php"); } else { $errMsg = Text::getText("MissingGroupName"); $buttonCaption = Text::getText("Save"); include("header.php"); include("groupEditForm.php"); include("footer.php"); } } else { $title = Text::getText("EditGroup"); $buttonCaption = Text::getText("Save"); include("header.php"); include("groupEditForm.php"); include("footer.php"); } ?>
function getGroupLayouts() { $views = $this->getViews(); //$defaultLayout [] = array ( 'name' => translate('LBL_DEFAULT') , 'type' => 'Folder' , 'children' => $layouts , 'action' => 'module=ModuleBuilder&action=wizard&layouts=1&view_module=' . $this->module ) ; //$layout_nodes[] = array ( 'name' => translate($groupFocus->name) , 'type' => 'Folder' , 'children' => $group_layouts , 'action' => 'module=ModuleBuilder&action=wizard&layouts=1&view_module=' . $this->module . "&grpLayout=".$groupFocus->id ) ; //translate('LBL_LAYOUTS') => array ( 'children' => 'getLayouts' , 'action' => "module=ModuleBuilder&action=wizard&view=layouts&view_module={$this->module}" , 'imageTitle' => 'Layouts' , 'help' => 'layoutsBtn' ) , $defaultLayout[] = array('name' => translate('LBL_DEFAULT'), 'type' => 'Folder', 'children' => $this->getLayouts(), 'action' => "module=ModuleBuilder&action=wizard&view=layouts&view_module={$this->module}", 'imageTitle' => 'Layouts', 'help' => 'layoutsBtn'); $layout_nodes = array(); $layout_nodes = $defaultLayout; //get security group nodes...in metadata directory in a folder named with the guid of the security group $custDirectory = "custom/modules/" . $this->module . "/metadata/"; if (is_dir($custDirectory)) { require_once 'modules/SecurityGroups/SecurityGroup.php'; $groupFocus = new SecurityGroup(); $d = dir($custDirectory); while ($f = $d->read()) { if ($f == "." || $f == "..") { continue; } if (is_dir("{$custDirectory}/{$f}")) { //see if $f is a guid for a security group $groupFocus = new SecurityGroup(); $groupFocus->retrieve($f); if (!empty($groupFocus->id) && isset($groupFocus->id)) { //found existing group layout...create node $GLOBALS['log']->debug("Found Security Group Layout for: " . $groupFocus->name); $group_layouts = array(); //remove group layout option $group_layouts[] = array('name' => translate('LBL_REMOVE_LAYOUT'), 'action' => "module=ModuleBuilder&action=removeGroupLayoutPrompt&view_module={$this->module}" . "&grpLayout=" . $groupFocus->id); foreach ($views as $def) { $group_layouts[$def['name']] = array('name' => $def['name'], 'action' => "module=ModuleBuilder&action=editLayout&view={$def['type']}&view_module={$this->module}&grpLayout=" . $groupFocus->id, 'imageTitle' => $def['image'], 'help' => "viewBtn{$def['type']}", 'size' => '48'); } if ($this->isValidDashletModule($this->module)) { $dashlets = array(); $dashlets[] = array('name' => translate('LBL_DASHLETLISTVIEW'), 'type' => 'dashlet', 'action' => 'module=ModuleBuilder&action=editLayout&view=dashlet&view_module=' . $this->module . "&grpLayout=" . $groupFocus->id); $dashlets[] = array('name' => translate('LBL_DASHLETSEARCHVIEW'), 'type' => 'dashletsearch', 'action' => 'module=ModuleBuilder&action=editLayout&view=dashletsearch&view_module=' . $this->module . "&grpLayout=" . $groupFocus->id); $group_layouts[translate('LBL_DASHLET')] = array('name' => translate('LBL_DASHLET'), 'type' => 'Folder', 'children' => $dashlets, 'imageTitle' => 'Dashlet', 'action' => 'module=ModuleBuilder&action=wizard&view=dashlet&view_module=' . $this->module . "&grpLayout=" . $groupFocus->id); } //For popup tree node $popups = array(); $popups[] = array('name' => translate('LBL_POPUPLISTVIEW'), 'type' => 'popuplistview', 'action' => 'module=ModuleBuilder&action=editLayout&view=popuplist&view_module=' . $this->module . "&grpLayout=" . $groupFocus->id); $popups[] = array('name' => translate('LBL_POPUPSEARCH'), 'type' => 'popupsearch', 'action' => 'module=ModuleBuilder&action=editLayout&view=popupsearch&view_module=' . $this->module . "&grpLayout=" . $groupFocus->id); $group_layouts[translate('LBL_POPUP')] = array('name' => translate('LBL_POPUP'), 'type' => 'Folder', 'children' => $popups, 'imageTitle' => 'Popup', 'imageName' => 'icon_Popup.gif', 'action' => 'module=ModuleBuilder&action=wizard&view=popup&view_module=' . $this->module . "&grpLayout=" . $groupFocus->id); $nodes = $this->getSearch($groupFocus->id); if (!empty($nodes)) { $group_layouts[translate('LBL_SEARCH')] = array('name' => translate('LBL_SEARCH'), 'type' => 'Folder', 'children' => $nodes, 'action' => "module=ModuleBuilder&action=wizard&view=search&view_module={$this->module}&grpLayout=" . $groupFocus->id, 'imageTitle' => 'SearchForm', 'help' => 'searchBtn', 'size' => '48'); } $layout_nodes[] = array('name' => translate($groupFocus->name), 'type' => 'Folder', 'children' => $group_layouts, 'action' => 'module=ModuleBuilder&action=wizard&&view=layouts&view_module=' . $this->module . "&grpLayout=" . $groupFocus->id); } } } //end while files/dirs } //end if directory exists //$layouts [ translate('LBL_LAYOUTS') ] = array ( 'name' => translate('LBL_LAYOUTS') , 'type' => 'Folder' , 'children' => $layout_nodes , 'action' => "module=ModuleBuilder&action=addlayout&layouts=1&view_module={$this->module}") ; //$nodes [ 'children' ] [] = array ( 'name' => translate('LBL_LAYOUTS') , 'type' => 'Folder' , 'children' => $layout_nodes , 'action' => 'module=ModuleBuilder&action=addlayout&layouts=1&view_module=' . $this->module ) ; return $layout_nodes; }
/** * @return void * @param unknown $data * @param unknown $xTemplateSection * @param unknown $html_varName * @desc INTERNAL FUNCTION handles the rows */ function process_dynamic_listview_rows($data, $parent_data, $xtemplateSection, $html_varName, $subpanel_def) { global $subpanel_item_count; global $odd_bg; global $even_bg; global $hilite_bg; global $click_bg; $this->xTemplate->assign("BG_HILITE", $hilite_bg); $this->xTemplate->assign('CHECKALL', SugarThemeRegistry::current()->getImage('blank', '', 1, 1, ".gif", '')); //$this->xTemplate->assign("BG_CLICK", $click_bg); $subpanel_item_count = 0; $oddRow = true; $count = 0; reset($data); //GETTING OFFSET $offset = $this->getOffset($html_varName); //$totaltime = 0; $processed_ids = array(); $fill_additional_fields = array(); //Either retrieve the is_fill_in_additional_fields property from the lone //subpanel or visit each subpanel's subpanels to retrieve the is_fill_in_addition_fields //property $subpanel_list = array(); if ($subpanel_def->isCollection()) { $subpanel_list = $subpanel_def->sub_subpanels; } else { $subpanel_list[] = $subpanel_def; } foreach ($subpanel_list as $this_subpanel) { if ($this_subpanel->is_fill_in_additional_fields()) { $fill_additional_fields[] = $this_subpanel->bean_name; $fill_additional_fields[$this_subpanel->bean_name] = true; } } if (empty($data)) { $this->xTemplate->assign("ROW_COLOR", 'oddListRow'); $thepanel = $subpanel_def; if ($subpanel_def->isCollection()) { $thepanel = $subpanel_def->get_header_panel_def(); } $this->xTemplate->assign("COL_COUNT", count($thepanel->get_list_fields())); $this->xTemplate->parse($xtemplateSection . ".nodata"); } while (list($aVal, $aItem) = each($data)) { $subpanel_item_count++; $aItem->check_date_relationships_load(); // TODO: expensive and needs to be removed and done better elsewhere if (!empty($fill_additional_fields[$aItem->object_name]) || $aItem->object_name == 'Case' && !empty($fill_additional_fields['aCase'])) { $aItem->fill_in_additional_list_fields(); //$aItem->fill_in_additional_detail_fields(); } //rrs bug: 25343 $aItem->call_custom_logic("process_record"); if (isset($parent_data[$aItem->id])) { $aItem->parent_name = $parent_data[$aItem->id]['parent_name']; if (!empty($parent_data[$aItem->id]['parent_name_owner'])) { $aItem->parent_name_owner = $parent_data[$aItem->id]['parent_name_owner']; $aItem->parent_name_mod = $parent_data[$aItem->id]['parent_name_mod']; } } $fields = $aItem->get_list_view_data(); if (isset($processed_ids[$aItem->id])) { continue; } else { $processed_ids[$aItem->id] = 1; } //ADD OFFSET TO ARRAY $fields['OFFSET'] = $offset + $count + 1; if ($this->shouldProcess) { if ($aItem->ACLAccess('EditView')) { $this->xTemplate->assign('PREROW', "<input type='checkbox' class='checkbox' name='mass[]' value='" . $fields['ID'] . "' />"); } else { $this->xTemplate->assign('PREROW', ''); } if ($aItem->ACLAccess('DetailView')) { $this->xTemplate->assign('TAG_NAME', 'a'); } else { $this->xTemplate->assign('TAG_NAME', 'span'); } $this->xTemplate->assign('CHECKALL', "<input type='checkbox' title='" . $GLOBALS['app_strings']['LBL_SELECT_ALL_TITLE'] . "' class='checkbox' name='massall' id='massall' value='' onclick='sListView.check_all(document.MassUpdate, \"mass[]\", this.checked);' />"); } if ($oddRow) { $ROW_COLOR = 'oddListRow'; $BG_COLOR = $odd_bg; } else { $ROW_COLOR = 'evenListRow'; $BG_COLOR = $even_bg; } $oddRow = !$oddRow; $button_contents = array(); $this->xTemplate->assign("ROW_COLOR", $ROW_COLOR); $this->xTemplate->assign("BG_COLOR", $BG_COLOR); $layout_manager = $this->getLayoutManager(); $layout_manager->setAttribute('context', 'List'); $layout_manager->setAttribute('image_path', $this->local_image_path); $layout_manager->setAttribute('module_name', $subpanel_def->_instance_properties['module']); if (!empty($this->child_focus)) { $layout_manager->setAttribute('related_module_name', $this->child_focus->module_dir); } //AG$subpanel_data = $this->list_field_defs; //$bla = array_pop($subpanel_data); //select which sub-panel to display here, the decision will be made based on the type of //the sub-panel and panel in the bean being processed. if ($subpanel_def->isCollection()) { $thepanel = $subpanel_def->sub_subpanels[$aItem->panel_name]; } else { $thepanel = $subpanel_def; } /* BEGIN - SECURITY GROUPS */ //This check is costly doing it field by field in the below foreach //instead pull up here and do once per record.... $aclaccess_is_owner = false; $aclaccess_in_group = false; global $current_user; if (is_admin($current_user)) { $aclaccess_is_owner = true; } else { $aclaccess_is_owner = $aItem->isOwner($current_user->id); } require_once "modules/SecurityGroups/SecurityGroup.php"; $aclaccess_in_group = SecurityGroup::groupHasAccess($aItem->module_dir, $aItem->id); /* END - SECURITY GROUPS */ //get data source name $linked_field = $thepanel->get_data_source_name(); $linked_field_set = $thepanel->get_data_source_name(true); static $count; if (!isset($count)) { $count = 0; } /* BEGIN - SECURITY GROUPS */ /** $field_acl['DetailView'] = $aItem->ACLAccess('DetailView'); $field_acl['ListView'] = $aItem->ACLAccess('ListView'); $field_acl['EditView'] = $aItem->ACLAccess('EditView'); $field_acl['Delete'] = $aItem->ACLAccess('Delete'); */ //pass is_owner, in_group...vars defined above $field_acl['DetailView'] = $aItem->ACLAccess('DetailView', $aclaccess_is_owner, $aclaccess_in_group); $field_acl['ListView'] = $aItem->ACLAccess('ListView', $aclaccess_is_owner, $aclaccess_in_group); $field_acl['EditView'] = $aItem->ACLAccess('EditView', $aclaccess_is_owner, $aclaccess_in_group); $field_acl['Delete'] = $aItem->ACLAccess('Delete', $aclaccess_is_owner, $aclaccess_in_group); /* END - SECURITY GROUPS */ foreach ($thepanel->get_list_fields() as $field_name => $list_field) { //add linked field attribute to the array. $list_field['linked_field'] = $linked_field; $list_field['linked_field_set'] = $linked_field_set; $usage = empty($list_field['usage']) ? '' : $list_field['usage']; if ($usage == 'query_only' && !empty($list_field['force_query_only_display'])) { //if you are here you have column that is query only but needs to be displayed as blank. This is helpful //for collections such as Activities where you have a field in only one object and wish to show it in the subpanel list $count++; $widget_contents = ' '; $this->xTemplate->assign('CLASS', ""); $this->xTemplate->assign('CELL_COUNT', $count); $this->xTemplate->assign('CELL', $widget_contents); $this->xTemplate->parse($xtemplateSection . ".row.cell"); } else { if ($usage != 'query_only') { $list_field['name'] = $field_name; $module_field = $field_name . '_mod'; $owner_field = $field_name . '_owner'; if (!empty($aItem->{$module_field})) { $list_field['owner_id'] = $aItem->{$owner_field}; $list_field['owner_module'] = $aItem->{$module_field}; } else { $list_field['owner_id'] = false; $list_field['owner_module'] = false; } if (isset($list_field['alias'])) { $list_field['name'] = $list_field['alias']; } else { $list_field['name'] = $field_name; } $list_field['fields'] = $fields; $list_field['module'] = $aItem->module_dir; $list_field['start_link_wrapper'] = $this->start_link_wrapper; $list_field['end_link_wrapper'] = $this->end_link_wrapper; $list_field['subpanel_id'] = $this->subpanel_id; $list_field += $field_acl; if (isset($aItem->field_defs[strtolower($list_field['name'])])) { require_once 'include/SugarFields/SugarFieldHandler.php'; // We need to see if a sugar field exists for this field type first, // if it doesn't, toss it at the old sugarWidgets. This is for // backwards compatibility and will be removed in a future release $vardef = $aItem->field_defs[strtolower($list_field['name'])]; if (isset($vardef['type'])) { $fieldType = isset($vardef['custom_type']) ? $vardef['custom_type'] : $vardef['type']; $tmpField = SugarFieldHandler::getSugarField($fieldType, true); } else { $tmpField = NULL; } if ($tmpField != NULL) { $widget_contents = SugarFieldHandler::displaySmarty($list_field['fields'], $vardef, 'ListView', $list_field); } else { // No SugarField for this particular type // Use the old, icky, SugarWidget for now $widget_contents = $layout_manager->widgetDisplay($list_field); } if (isset($list_field['widget_class']) && $list_field['widget_class'] == 'SubPanelDetailViewLink') { // We need to call into the old SugarWidgets for the time being, so it can generate a proper link with all the various corner-cases handled // So we'll populate the field data with the pre-rendered display for the field $list_field['fields'][$field_name] = $widget_contents; if ('full_name' == $field_name) { //bug #32465 $list_field['fields'][strtoupper($field_name)] = $widget_contents; } //vardef source is non db, assign the field name to varname for processing of column. if (!empty($vardef['source']) && $vardef['source'] == 'non-db') { $list_field['varname'] = $field_name; } $widget_contents = $layout_manager->widgetDisplay($list_field); } else { if (isset($list_field['widget_class']) && $list_field['widget_class'] == 'SubPanelEmailLink') { $widget_contents = $layout_manager->widgetDisplay($list_field); } } $count++; $this->xTemplate->assign('CELL_COUNT', $count); $this->xTemplate->assign('CLASS', ""); if (empty($widget_contents)) { $widget_contents = ' '; } $this->xTemplate->assign('CELL', $widget_contents); $this->xTemplate->parse($xtemplateSection . ".row.cell"); } else { // This handles the edit and remove buttons and icon widget if (isset($list_field['widget_class']) && $list_field['widget_class'] == "SubPanelIcon") { $count++; $widget_contents = $layout_manager->widgetDisplay($list_field); $this->xTemplate->assign('CELL_COUNT', $count); $this->xTemplate->assign('CLASS', ""); if (empty($widget_contents)) { $widget_contents = ' '; } $this->xTemplate->assign('CELL', $widget_contents); $this->xTemplate->parse($xtemplateSection . ".row.cell"); } elseif (preg_match("/button/i", $list_field['name'])) { if (($list_field['name'] === 'edit_button' && $field_acl['EditView'] || $list_field['name'] === 'close_button' && $field_acl['EditView'] || $list_field['name'] === 'remove_button' && $field_acl['Delete']) && '' != ($_content = $layout_manager->widgetDisplay($list_field))) { $button_contents[] = $_content; unset($_content); } else { $button_contents[] = ''; } } else { $count++; $this->xTemplate->assign('CLASS', ""); $widget_contents = $layout_manager->widgetDisplay($list_field); $this->xTemplate->assign('CELL_COUNT', $count); if (empty($widget_contents)) { $widget_contents = ' '; } $this->xTemplate->assign('CELL', $widget_contents); $this->xTemplate->parse($xtemplateSection . ".row.cell"); } } } } } // Make sure we have at least one button before rendering a column for // the action buttons in a list view. Relevant bugs: #51647 and #51640. if (!empty($button_contents)) { $button_contents = array_filter($button_contents); if (!empty($button_contents)) { // this is for inline buttons on listviews // bug#51275: smarty widget to help provide the action menu functionality as it is currently sprinkled throughout the app with html require_once 'include/Smarty/plugins/function.sugar_action_menu.php'; $tempid = create_guid(); array_unshift($button_contents, "<div style='display: inline' id='{$tempid}'>" . array_shift($button_contents) . "</div>"); $action_button = smarty_function_sugar_action_menu(array('id' => $tempid, 'buttons' => $button_contents, 'class' => 'clickMenu subpanel records fancymenu button', 'flat' => false), $this->xTemplate); } else { $action_button = ''; } $this->xTemplate->assign('CLASS', "inlineButtons"); $this->xTemplate->assign('CELL_COUNT', ++$count); //Bug#51275 for beta3 pre_script is not required any more $this->xTemplate->assign('CELL', $action_button); $this->xTemplate->parse($xtemplateSection . ".row.cell"); } $aItem->setupCustomFields($aItem->module_dir); $aItem->custom_fields->populateAllXTPL($this->xTemplate, 'detail', $html_varName, $fields); $count++; $this->xTemplate->parse($xtemplateSection . ".row"); } $this->xTemplate->parse($xtemplateSection); }
/** * Get array of activities * @param array $activities * @param string $user_id * @param boolean $show_tasks * @param SugarDateTime $view_start_time start date * @param SugarDateTime $view_end_time end date * @param string $view view; not used for now, left for compatibility * @param boolean $show_calls * @param boolean $show_completed use to allow filtering completed events * @return array */ function get_activities($activities, $user_id, $show_tasks, $view_start_time, $view_end_time, $view, $show_calls = true, $show_completed = true) { global $current_user; global $beanList; $act_list = array(); $seen_ids = array(); $completedCalls = ''; $completedMeetings = ''; $completedTasks = ''; if (!$show_completed) { $completedCalls = " AND calls.status = 'Planned' "; $completedMeetings = " AND meetings.status = 'Planned' "; $completedTasks = " AND tasks.status != 'Completed' "; } foreach ($activities as $key => $activity) { if (ACLController::checkAccess($key, 'list', true)) { /* END - SECURITY GROUPS */ $class = $beanList[$key]; $bean = new $class(); if ($current_user->id == $user_id) { $bean->disable_row_level_security = true; } $where = self::get_occurs_until_where_clause($bean->table_name, $bean->rel_users_table, $view_start_time, $view_end_time, $activity['start'], $activity['end'], $view); if ($key == "Meeting") { $where .= $completedMeetings; } elseif ($key == "Calls") { $where .= $completedCalls; if (!$show_calls) { continue; } } elseif ($key == "Tasks") { $where .= $completedTasks; if (!$show_tasks) { continue; } } $focus_list = build_related_list_by_user_id($bean, $user_id, $where); foreach ($focus_list as $focusBean) { if (isset($seen_ids[$focusBean->id])) { continue; } /* BEGIN - SECURITY GROUPS */ //Show as busy if current user is not in a group associated to the record require_once "modules/SecurityGroups/SecurityGroup.php"; $in_group = SecurityGroup::groupHasAccess($key, $focusBean->id, 'list'); $show_as_busy = !ACLController::checkAccess($key, 'list', $current_user->id == $user_id, 'module', $in_group); $focusBean->show_as_busy = $show_as_busy; /* END - SECURITY GROUPS */ $seen_ids[$focusBean->id] = 1; $act = new CalendarActivity($focusBean); if (!empty($act)) { $act_list[] = $act; } } } } return $act_list; }
/** * builds up a delimited string for export * @param string type the bean-type to export * @param array records an array of records if coming directly from a query * @return string delimited string for export */ function export($type, $records = null, $members = false) { global $beanList; global $beanFiles; global $current_user; global $app_strings; global $app_list_strings; global $timedate; $contact_fields = array("id" => "Contact ID", "lead_source" => "Lead Source", "date_entered" => "Date Entered", "date_modified" => "Date Modified", "first_name" => "First Name", "last_name" => "Last Name", "salutation" => "Salutation", "birthdate" => "Lead Source", "do_not_call" => "Do Not Call", "email_opt_out" => "Email Opt Out", "title" => "Title", "department" => "Department", "birthdate" => "Birthdate", "do_not_call" => "Do Not Call", "phone_home" => "Phone (Home)", "phone_mobile" => "Phone (Mobile)", "phone_work" => "Phone (Work)", "phone_other" => "Phone (Other)", "phone_fax" => "Fax", "email1" => "Email", "email2" => "Email (Other)", "assistant" => "Assistant", "assistant_phone" => "Assistant Phone", "primary_address_street" => "Primary Address Street", "primary_address_city" => "Primary Address City", "primary_address_state" => "Primary Address State", "primary_address_postalcode" => "Primary Address Postalcode", "primary_address_country" => "Primary Address Country", "alt_address_street" => "Other Address Street", "alt_address_city" => "Other Address City", "alt_address_state" => "Other Address State", "alt_address_postalcode" => "Other Address Postalcode", "alt_address_country" => "Other Address Country", "description" => "Description"); $account_fields = array("id" => "Account ID", "name" => "Account Name", "website" => "Website", "industry" => "Industry", "account_type" => "Type", "ticker_symbol" => "Ticker Symbol", "employees" => "Employees", "ownership" => "Ownership", "phone_office" => "Phone", "phone_fax" => "Fax", "phone_alternate" => "Other Phone", "email1" => "Email", "email2" => "Other Email", "rating" => "Rating", "sic_code" => "SIC Code", "annual_revenue" => "Annual Revenue", "billing_address_street" => "Billing Address Street", "billing_address_city" => "Billing Address City", "billing_address_state" => "Billing Address State", "billing_address_postalcode" => "Billing Address Postalcode", "billing_address_country" => "Billing Address Country", "shipping_address_street" => "Shipping Address Street", "shipping_address_city" => "Shipping Address City", "shipping_address_state" => "Shipping Address State", "shipping_address_postalcode" => "Shipping Address Postalcode", "shipping_address_country" => "Shipping Address Country", "description" => "Description"); $focus = 0; $content = ''; $bean = $beanList[$type]; require_once $beanFiles[$bean]; $focus = new $bean(); $searchFields = array(); $db = DBManagerFactory::getInstance(); if ($records) { $records = explode(',', $records); $records = "'" . implode("','", $records) . "'"; $where = "{$focus->table_name}.id in ({$records})"; } elseif (isset($_REQUEST['all'])) { $where = ''; } else { if (!empty($_REQUEST['current_post'])) { $ret_array = generateSearchWhere($type, $_REQUEST['current_post']); $where = $ret_array['where']; $searchFields = $ret_array['searchFields']; } else { $where = ''; } } $order_by = ""; if ($focus->bean_implements('ACL')) { if (!ACLController::checkAccess($focus->module_dir, 'export', true)) { ACLController::displayNoAccess(); sugar_die(''); } if (ACLController::requireOwner($focus->module_dir, 'export')) { if (!empty($where)) { $where .= ' AND '; } $where .= $focus->getOwnerWhere($current_user->id); } /* BEGIN - SECURITY GROUPS */ if (ACLController::requireSecurityGroup($focus->module_dir, 'export')) { require_once 'modules/SecurityGroups/SecurityGroup.php'; global $current_user; $owner_where = $focus->getOwnerWhere($current_user->id); $group_where = SecurityGroup::getGroupWhere($focus->table_name, $focus->module_dir, $current_user->id); if (!empty($owner_where)) { if (empty($where)) { $where = " (" . $owner_where . " or " . $group_where . ")"; } else { $where .= " AND (" . $owner_where . " or " . $group_where . ")"; } } else { if (!empty($where)) { $where .= ' AND '; } $where .= $group_where; } } /* END - SECURITY GROUPS */ } // Export entire list was broken because the where clause already has "where" in it // and when the query is built, it has a "where" as well, so the query was ill-formed. // Eliminating the "where" here so that the query can be constructed correctly. if ($members == true) { $query = $focus->create_export_members_query($records); } else { $beginWhere = substr(trim($where), 0, 5); if ($beginWhere == "where") { $where = substr(trim($where), 5, strlen($where)); } $ret_array = create_export_query_relate_link_patch($type, $searchFields, $where); if (!empty($ret_array['join'])) { $query = $focus->create_export_query($order_by, $ret_array['where'], $ret_array['join']); } else { $query = $focus->create_export_query($order_by, $ret_array['where']); } } $result = $db->query($query, true, $app_strings['ERR_EXPORT_TYPE'] . $type . ": <BR>." . $query); $fields_array = $db->getFieldsArray($result, true); global $sugar_config; $utf = utf8_encode("????"); $file = fopen('Export.csv', 'w'); //$val=iconv("UTF-8","WINDOWS-1255",html_entity_decode($utf,ENT_COMPAT,'utf-8')); foreach ($fields_array as $head) { $fields_array[] = array(utf8_decode($head)); } fputcsv($file, $fields_array); // setup the "header" line with proper delimiters /*$header = implode("\"".getDelimiter()."\"", array_values($fields_array)); if($members){ $header = str_replace('"ea_deleted"'.getDelimiter().'"ear_deleted"'.getDelimiter().'"primary_address"'.getDelimiter().'','',$header); } $header = "\"" .$header; $header .= "\"\r\n"; $content .= $header;*/ $pre_id = ''; while ($val = $db->fetchByAssoc($result, -1, false)) { $new_arr = array(); if ($members) { if ($pre_id == $val['id']) { continue; } if ($val['ea_deleted'] == 1 || $val['ear_deleted'] == 1) { $val['primary_email_address'] = ''; } unset($val['ea_deleted']); unset($val['ear_deleted']); unset($val['primary_address']); } $pre_id = $val['id']; $vals = array_values($val); foreach ($vals as $key => $value) { //if our value is a datetime field, then apply the users locale if (isset($focus->field_name_map[$fields_array[$key]]['type']) && ($focus->field_name_map[$fields_array[$key]]['type'] == 'datetime' || $focus->field_name_map[$fields_array[$key]]['type'] == 'datetimecombo')) { $value = $timedate->to_display_date_time($value); $value = preg_replace('/([pm|PM|am|AM]+)/', ' \\1', $value); } //kbrill Bug #16296 if (isset($focus->field_name_map[$fields_array[$key]]['type']) && $focus->field_name_map[$fields_array[$key]]['type'] == 'date') { $value = $timedate->to_display_date($value, false); } // Bug 32463 - Properly have multienum field translated into something useful for the client if (isset($focus->field_name_map[$fields_array[$key]]['type']) && $focus->field_name_map[$fields_array[$key]]['type'] == 'multienum') { $value = str_replace("^", "", $value); if (isset($focus->field_name_map[$fields_array[$key]]['options']) && isset($app_list_strings[$focus->field_name_map[$fields_array[$key]]['options']])) { $valueArray = explode(",", $value); foreach ($valueArray as $multikey => $multivalue) { if (isset($app_list_strings[$focus->field_name_map[$fields_array[$key]]['options']][$multivalue])) { $valueArray[$multikey] = $app_list_strings[$focus->field_name_map[$fields_array[$key]]['options']][$multivalue]; } } $value = implode(",", $valueArray); } } array_push($new_arr, $value); } //$line = implode("\"".getDelimiter()."\"", $new_arr); //$line = "\"" .$line; //$line .= "\"\r\n"; $row = array(); foreach ($val as $cont) { $from = mb_detect_encoding($cont); $to = 'UTF-8'; $cont = iconv("gbk", "utf-8", $cont); // array_push($row,mb_convert_encoding($cont, $from, $to)); } fputcsv($file, $row); //$content .= $line; } header('Content-Type: text/x-csv; charset="UTF-8"'); header('Content-Disposition: attachment; filename="Report_Week1.csv"'); header('Pragma: no-cache'); header('Expires: 0'); header('Location: ' . $sugar_config['site_url'] . '/Export.csv'); die; //return $content; }
function set_record(SugarBean $record, SugarBean $bean, $params = array(), $in_save = false) { global $app_list_strings, $timedate; $record_vardefs = $record->getFieldDefinitions(); if (isset($params['field'])) { foreach ($params['field'] as $key => $field) { if ($field == '') { continue; } switch ($params['value_type'][$key]) { case 'Field': if ($params['value'][$key] == '') { continue; } $data = $bean->field_defs[$params['value'][$key]]; if ($data['type'] == 'relate' && isset($data['id_name'])) { $params['value'][$key] = $data['id_name']; } $value = $bean->{$params}['value'][$key]; break; case 'Date': $dformat = 'Y-m-d H:i:s'; if ($record_vardefs[$field]['type'] == 'date') { $dformat = 'Y-m-d'; } switch ($params['value'][$key][3]) { case 'business_hours': if (file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php')) { require_once 'modules/AOBH_BusinessHours/AOBH_BusinessHours.php'; $businessHours = new AOBH_BusinessHours(); $dateToUse = $params['value'][$key][0]; $sign = $params['value'][$key][1]; $amount = $params['value'][$key][2]; if ($sign != "plus") { $amount = 0 - $amount; } if ($dateToUse == "now") { $value = $businessHours->addBusinessHours($amount); } else { if ($dateToUse == "field") { $dateToUse = $params['field'][$key]; $value = $businessHours->addBusinessHours($amount, $timedate->fromDb($bean->{$dateToUse})); } else { $value = $businessHours->addBusinessHours($amount, $timedate->fromDb($bean->{$dateToUse})); } } $value = $timedate->asDb($value); break; } $params['value'][$key][3] = 'hours'; //No business hours module found - fall through. //No business hours module found - fall through. default: if ($params['value'][$key][0] == 'now') { $date = gmdate($dformat); } else { if ($params['value'][$key][0] == 'field') { $date = $record->fetched_row[$params['field'][$key]]; } else { $date = $bean->fetched_row[$params['value'][$key][0]]; } } if ($params['value'][$key][1] != 'now') { $value = date($dformat, strtotime($date . ' ' . $app_list_strings['aow_date_operator'][$params['value'][$key][1]] . $params['value'][$key][2] . ' ' . $params['value'][$key][3])); } else { $value = date($dformat, strtotime($date)); } break; } break; case 'Round_Robin': case 'Least_Busy': case 'Random': switch ($params['value'][$key][0]) { case 'security_group': if (file_exists('modules/SecurityGroups/SecurityGroup.php')) { require_once 'modules/SecurityGroups/SecurityGroup.php'; $security_group = new SecurityGroup(); $security_group->retrieve($params['value'][$key][1]); $group_users = $security_group->get_linked_beans('users', 'User'); $users = array(); $r_users = array(); if ($params['value'][$key][2] != '') { require_once 'modules/ACLRoles/ACLRole.php'; $role = new ACLRole(); $role->retrieve($params['value'][$key][2]); $role_users = $role->get_linked_beans('users', 'User'); foreach ($role_users as $role_user) { $r_users[$role_user->id] = $role_user->name; } } foreach ($group_users as $group_user) { if ($params['value'][$key][2] != '' && !isset($r_users[$group_user->id])) { continue; } $users[$group_user->id] = $group_user->name; } break; } //No Security Group module found - fall through. //No Security Group module found - fall through. case 'role': require_once 'modules/ACLRoles/ACLRole.php'; $role = new ACLRole(); $role->retrieve($params['value'][$key][2]); $role_users = $role->get_linked_beans('users', 'User'); $users = array(); foreach ($role_users as $role_user) { $users[$role_user->id] = $role_user->name; } break; case 'all': default: $users = get_user_array(false); break; } // format the users array $users = array_values(array_flip($users)); if (empty($users)) { $value = ''; } else { if (sizeof($users) == 1) { $value = $users[0]; } else { switch ($params['value_type'][$key]) { case 'Round_Robin': $value = getRoundRobinUser($users, $this->id); break; case 'Least_Busy': $user_id = 'assigned_user_id'; if (isset($record_vardefs[$field]['id_name']) && $record_vardefs[$field]['id_name'] != '') { $user_id = $record_vardefs[$field]['id_name']; } $value = getLeastBusyUser($users, $user_id, $record); break; case 'Random': default: shuffle($users); $value = $users[0]; break; } } } setLastUser($value, $this->id); break; case 'Value': default: $value = $params['value'][$key]; break; } if ($record_vardefs[$field]['type'] == 'relate' && isset($record_vardefs[$field]['id_name'])) { $field = $record_vardefs[$field]['id_name']; } $record->{$field} = $value; } } $bean_processed = isset($record->processed) ? $record->processed : false; if ($in_save) { global $current_user; $record->processed = true; $check_notify = $record->assigned_user_id != $current_user->id && $record->assigned_user_id != $record->fetched_row['assigned_user_id']; } else { $check_notify = $record->assigned_user_id != $record->fetched_row['assigned_user_id']; } $record->process_save_dates = false; $record->new_with_id = false; $record->save($check_notify); $record->processed = $bean_processed; }
/** * Queries for the list */ function get_subscription_lists_query($focus, $additional_fields = null) { //get all prospect lists belonging to Campaigns of type newsletter $all_news_type_pl_query = "select c.name, pl.list_type, plc.campaign_id, plc.prospect_list_id"; if(is_array($additional_fields) && !empty($additional_fields)) $all_news_type_pl_query .= ', ' . implode(', ', $additional_fields); $all_news_type_pl_query .= " from prospect_list_campaigns plc , prospect_lists pl, campaigns c "; $all_news_type_pl_query .= "where plc.campaign_id = c.id "; $all_news_type_pl_query .= "and plc.prospect_list_id = pl.id "; $all_news_type_pl_query .= "and c.campaign_type = 'NewsLetter' and pl.deleted = 0 and c.deleted=0 and plc.deleted=0 "; $all_news_type_pl_query .= "and (pl.list_type like 'exempt%' or pl.list_type ='default') "; /* BEGIN - SECURITY GROUPS */ if($focus->bean_implements('ACL') && ACLController::requireSecurityGroup('Campaigns', 'list') ) { require_once('modules/SecurityGroups/SecurityGroup.php'); global $current_user; $owner_where = $focus->getOwnerWhere($current_user->id); $group_where = SecurityGroup::getGroupWhere('c','Campaigns',$current_user->id); $all_news_type_pl_query .= " AND ( c.assigned_user_id ='".$current_user->id."' or ".$group_where.") "; } /* END - SECURITY GROUPS */ $all_news_type_list =$focus->db->query($all_news_type_pl_query); //build array of all newsletter campaigns $news_type_list_arr = array(); while ($row = $focus->db->fetchByAssoc($all_news_type_list)){$news_type_list_arr[] = $row;} //now get all the campaigns that the current user is assigned to $all_plp_current = "select prospect_list_id from prospect_lists_prospects where related_id = '$focus->id' and deleted = 0 "; //build array of prospect lists that this user belongs to $current_plp =$focus->db->query($all_plp_current ); $current_plp_arr = array(); while ($row = $focus->db->fetchByAssoc($current_plp)){$current_plp_arr[] = $row;} return array('current_plp_arr' => $current_plp_arr, 'news_type_list_arr' => $news_type_list_arr); }
function template_calendar($args) { global $timedate; if (isset($args['size']) && $args['size'] == 'small') { $args['calendar']->show_activities = false; $args['calendar']->show_week_on_month_view = false; } $newargs = array(); $newargs['view'] = $args['view']; $newargs['calendar'] = $args['calendar']; if (!isset($args['size']) || $args['size'] != 'small') { template_cal_tabs($newargs); } if (isset($_REQUEST['view']) && $_REQUEST['view'] == 'shared') { global $ids; global $current_user; global $mod_strings; global $app_list_strings, $current_language, $currentModule, $action, $app_strings; $current_module_strings = return_module_language($current_language, 'Calendar'); $ids = array(); $user_ids = $current_user->getPreference('shared_ids'); //get list of user ids for which to display data if (!empty($user_ids) && count($user_ids) != 0 && !isset($_REQUEST['shared_ids'])) { $ids = $user_ids; } elseif (isset($_REQUEST['shared_ids']) && count($_REQUEST['shared_ids']) > 0) { $ids = $_REQUEST['shared_ids']; $current_user->setPreference('shared_ids', $_REQUEST['shared_ids']); } else { //$ids = get_user_array(false); //$ids = array_keys($ids); $ids = array($current_user->id); } //get team id for which to display user list $tools = '<div align="right"><a href="index.php?module=' . $currentModule . '&action=' . $action . '&view=shared" class="tabFormAdvLink"> <a href="javascript: toggleDisplay(\'shared_cal_edit\');" class="tabFormAdvLink">' . SugarThemeRegistry::current()->getImage('edit', 'alt="' . $current_module_strings['LBL_EDIT'] . '" border="0" align="absmiddle"') . ' ' . $current_module_strings['LBL_EDIT'] . '</a></div>'; echo get_form_header($mod_strings['LBL_SHARED_CAL_TITLE'], $tools, false); if (empty($_SESSION['shared_ids'])) { $_SESSION['shared_ids'] = ""; } echo "\n\t\t\t<script language=\"javascript\">\n\t\t\tfunction up(name) {\n\t\t\t\tvar td = document.getElementById(name+'_td');\n\t\t\t\tvar obj = td.getElementsByTagName('select')[0];\n\t\t\t\tobj =(typeof obj == \"string\") ? document.getElementById(obj) : obj;\n\t\t\t\tif(obj.tagName.toLowerCase() != \"select\" && obj.length < 2)\n\t\t\t\t\treturn false;\n\t\t\t\tvar sel = new Array();\n\n\t\t\t\tfor(i=0; i<obj.length; i++) {\n\t\t\t\t\tif(obj[i].selected == true) {\n\t\t\t\t\t\tsel[sel.length] = i;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor(i in sel) {\n\t\t\t\t\tif(sel[i] != 0 && !obj[sel[i]-1].selected) {\n\t\t\t\t\t\tvar tmp = new Array(obj[sel[i]-1].text, obj[sel[i]-1].value);\n\t\t\t\t\t\tobj[sel[i]-1].text = obj[sel[i]].text;\n\t\t\t\t\t\tobj[sel[i]-1].value = obj[sel[i]].value;\n\t\t\t\t\t\tobj[sel[i]].text = tmp[0];\n\t\t\t\t\t\tobj[sel[i]].value = tmp[1];\n\t\t\t\t\t\tobj[sel[i]-1].selected = true;\n\t\t\t\t\t\tobj[sel[i]].selected = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction down(name) {\n\t\t\t\tvar td = document.getElementById(name+'_td');\n\t\t\t\tvar obj = td.getElementsByTagName('select')[0];\n\t\t\t\tif(obj.tagName.toLowerCase() != \"select\" && obj.length < 2)\n\t\t\t\t\treturn false;\n\t\t\t\tvar sel = new Array();\n\t\t\t\tfor(i=obj.length-1; i>-1; i--) {\n\t\t\t\t\tif(obj[i].selected == true) {\n\t\t\t\t\t\tsel[sel.length] = i;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor(i in sel) {\n\t\t\t\t\tif(sel[i] != obj.length-1 && !obj[sel[i]+1].selected) {\n\t\t\t\t\t\tvar tmp = new Array(obj[sel[i]+1].text, obj[sel[i]+1].value);\n\t\t\t\t\t\tobj[sel[i]+1].text = obj[sel[i]].text;\n\t\t\t\t\t\tobj[sel[i]+1].value = obj[sel[i]].value;\n\t\t\t\t\t\tobj[sel[i]].text = tmp[0];\n\t\t\t\t\t\tobj[sel[i]].value = tmp[1];\n\t\t\t\t\t\tobj[sel[i]+1].selected = true;\n\t\t\t\t\t\tobj[sel[i]].selected = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t</script>\n\n\t\t\t<div id='shared_cal_edit' style='display: none;'>\n\t\t\t<form name='shared_cal' action=\"index.php\" method=\"post\" >\n\t\t\t<input type=\"hidden\" name=\"module\" value=\"" . $currentModule . "\">\n\t\t\t<input type=\"hidden\" name=\"action\" value=\"" . $action . "\">\n\t\t\t<input type=\"hidden\" name=\"view\" value=\"shared\">\n\t\t\t<input type=\"hidden\" name=\"edit\" value=\"0\">\n\t\t\t<table cellpadding=\"0\" cellspacing=\"3\" border=\"0\" align=\"center\">\n\t\t\t<tr><th valign=\"top\" align=\"center\" colspan=\"2\">\n\t\t\t"; echo $current_module_strings['LBL_SELECT_USERS']; echo "\n\t\t\t</th>\n\t\t\t</tr>\n\t\t\t<tr><td valign=\"top\">"; /** BEGIN - SECURITY GROUPS */ $securitygroup = $current_user->getPreference('securitygroup_id'); if (!empty($securitygroup) && !isset($_REQUEST['securitygroup_id'])) { $securitygroup_id = $securitygroup; } elseif (isset($_REQUEST['securitygroup_id'])) { $securitygroup_id = $_REQUEST['securitygroup_id']; $current_user->setPreference('securitygroup_id', $_REQUEST['securitygroup_id']); } else { $securitygroup_id = ''; } if (empty($_SESSION['securitygroup_id'])) { $_SESSION['securitygroup_id'] = ""; } echo "<table cellpadding=\"1\" cellspacing=\"1\" border=\"0\" class=\"chartForm\" align=\"center\">\n\t\t\t<tr>\n\t\t\t\t<td valign='top' nowrap><b>" . $current_module_strings['LBL_SECURITYGROUPS'] . "></b></td>\n\t\t\t\t<td valign='top' id=\"teams\"><select id=\"securitygroup_id\" onchange='this.form.edit.value=1; this.form.submit();' name=\"securitygroup_id\">"; global $current_user; require_once "modules/SecurityGroups/SecurityGroup.php"; $group_array[""] = ""; //for --None-- option if (is_admin($current_user)) { $securitygroups = SecurityGroup::getAllSecurityGroups(); foreach ($securitygroups as $group) { $group_array[$group['id']] = $group['name']; } } else { $securitygroups = SecurityGroup::getUserSecurityGroups($current_user->id); foreach ($securitygroups as $group) { $group_array[$group['id']] = $group['name']; } } echo get_select_options_with_id($group_array, $securitygroup_id); echo "</select></td>\n\t\t\t</tr>\n\t\t\t</table>"; /** END - SECURITY GROUPS */ echo "\n </td><td valign=\"top\">\n\n\t\t\t<table cellpadding=\"1\" cellspacing=\"1\" border=\"0\" class=\"edit view\" align=\"center\">\n\t\t\t<tr>\n\t\t\t\t<td valign='top' nowrap><b>" . $current_module_strings['LBL_USERS'] . "</b></td>\n\t\t\t\t<td valign='top' id=\"shared_ids_td\"><select id=\"shared_ids\" name=\"shared_ids[]\" multiple size='3'>"; /** BEGIN - SECURITY GROUPS */ if (!empty($securitygroup_id)) { require_once 'modules/SecurityGroups/SecurityGroup.php'; $securitygroup = new SecurityGroup(); $securitygroup->retrieve($securitygroup_id); $users_array = $securitygroup->getMembers(); $user_ids = array(); foreach ($users_array as $user) { $user_ids[$user['id']] = $user['user_name']; } echo get_select_options_with_id($user_ids, $ids); } else { echo get_select_options_with_id(get_user_array(false), $ids); } /** END - SECURITY GROUPS */ echo "\t</select></td>\n\t\t\t\t<td><a onclick=\"up('shared_ids');\">" . SugarThemeRegistry::current()->getImage('uparrow_big', 'border="0" style="margin-bottom: 1px;" alt="' . $app_strings['LBL_SORT'] . '"') . "</a><br>\n\t\t\t\t<a onclick=\"down('shared_ids');\">" . SugarThemeRegistry::current()->getImage('downarrow_big', 'border="0" style="margin-top: 1px;" alt="' . $app_strings['LBL_SORT'] . '"') . "</a></td>\n\t\t\t</tr>\n\t\t\t<tr>"; echo "<td align=\"right\" colspan=\"2\"><input class=\"button\" type=\"submit\" title=\"" . $app_strings['LBL_SELECT_BUTTON_TITLE'] . "\" accessKey=\"" . $app_strings['LBL_SELECT_BUTTON_KEY'] . "\" value=\"" . $app_strings['LBL_SELECT_BUTTON_LABEL'] . "\" /><input class=\"button\" onClick=\"javascript: toggleDisplay('shared_cal_edit');\" type=\"button\" title=\"" . $app_strings['LBL_CANCEL_BUTTON_TITLE'] . "\" accessKey=\"" . $app_strings['LBL_CANCEL_BUTTON_KEY'] . "\" value=\"" . $app_strings['LBL_CANCEL_BUTTON_LABEL'] . "\"/></td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t\t</td></tr>\n\t\t\t</table>\n\t\t\t</form>"; } // end "shared" view echo "</div></p>"; if (isset($_REQUEST['edit']) && $_REQUEST['edit']) { echo " <script language=\"javascript\"> toggleDisplay('shared_cal_edit'); </script>"; } echo "\n\t\t<table id=\"daily_cal_table_outside\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"monthBox\">\n\t\t<tr>\n\t\t<td>\n\t\t <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"monthHeader\">\n\t\t <tr>\n\t\t <td width=\"1%\" nowrap>"; if (!isset($args['size']) || $args['size'] != 'small') { template_get_previous_calendar($args); } echo "\n\t\t </td>\n\t\t <td width=\" 98 % \" align=center scope='row'>"; if (isset($args['size']) && ($args['size'] = 'small')) { ?> <a style="text-decoration: none;" href="index.php?module=Calendar&action=index&view=month<?php echo $args['calendar']->date_time->get_date_str(); ?> "> <?php } ?> <h3> <?php template_echo_date_info($args['view'], $args['calendar']->date_time); ?> </h3> <?php if (isset($args['size']) && ($args['size'] = 'small')) { echo "</a>"; } ?> </td> <td align="right" width="1%" nowrap><?php if (!isset($args['size']) || $args['size'] != 'small') { template_get_next_calendar($args); } ?> </td> </tr> </table> </td> </tr> <tr> <td class="monthCalBody"> <?php if ($args['calendar']->view == 'month') { template_calendar_month($args); } else { if ($args['calendar']->view == 'year') { template_calendar_year($args); } else { if ($args['calendar']->view == 'shared') { global $current_user, $shared_user; $shared_args = array(); foreach ($args as $key => $val) { $shared_args[$key] = $val; } $shared_args['calendar'] = $args['calendar']; $shared_user = new User(); foreach ($ids as $member) { $shared_user->retrieve($member); $shared_args['calendar']->show_tasks = true; $shared_args['calendar']->add_activities($shared_user); $shared_args['show_link'] = 'off'; if ($shared_user->id == $current_user->id) { $shared_args['show_link'] = 'on'; } echo '<h5 class="calSharedUser">' . $shared_user->full_name . '</h5>'; template_calendar_horizontal($shared_args); } } else { template_calendar_vertical($args); } } } ?> </td> </tr> <tr> <td> <table width="100%" cellspacing="0" cellpadding="0" class="monthFooter"> <tr> <td width="50%"><?php template_get_previous_calendar($args); ?> </td> <td align="right" width="50%"><?php template_get_next_calendar($args); ?> </td> </tr> </table> </td> </tr> </table> <?php }
function processSugarBean($html_varName, $seed, $offset) { global $row_count, $sugar_config; global $next_offset; global $previous_offset; global $list_view_row_count; global $current_offset; if (!empty($sugar_config['disable_vcr'])) { $seed->retrieve($_REQUEST['record']); return $seed; } $isfirstview = 0; $nav_history_set = false; $nav_history_array = array(); $nav_offset = ''; $nav_ids_visited = array(); $nav_stamp = ''; //get the session variable DETAIL_NAV_HISTORY, //the format of the variable stamp,offset, array of IDs visited. $nav_history = $this->getLocalSessionVariable($html_varName, "DETAIL_NAV_HISTORY"); if (!empty($nav_history)) { $nav_history_set = true; $nav_history_array = explode(":", $nav_history); $nav_stamp = $nav_history_array[0]; $nav_offset = $nav_history_array[1]; eval("\$nav_ids_visited= " . $nav_history_array[2] . ";"); } //from list offset is there but $bNavHistorySet is false. //from next,previous,start and end buttons offset and $bNavHistorySet is true. //from tracker offset is not there but $bNavHistorySet may or may not exist. if (isset($_REQUEST['offset']) && !empty($_REQUEST['offset'])) { //get offset values. $offset = $_REQUEST['offset']; if ($offset < 0) { $offset = 0; } //if the stamp has changed, ignore the offset and navigate to the record. //use case, search, navigate to detail, copy URL, search again, paste URL. if (!$this->isRequestFromListView($html_varName)) { $result = $seed->retrieve($_REQUEST['record']); return $result; } if ($nav_history_set) { if (isset($nav_ids_visited[$offset])) { unset($nav_ids_visited[$offset]); } } } else { if ($nav_history_set) { //try to locate the ID in the nav_history array. $key = array_search($_REQUEST['record'], $nav_ids_visited); if ($key === false) { //do not show the VCR buttons. $result = $seed->retrieve($_REQUEST['record']); return $result; } $offset = $key; $_REQUEST['offset'] = $offset; $_GET['offset'] = $offset; $_POST['offset'] = $offset; $_REQUEST['stamp'] = $nav_stamp; $_GET['stamp'] = $nav_stamp; $_POST['stamp'] = $nav_stamp; if (isset($nav_ids_visited[$offset])) { unset($nav_ids_visited[$offset]); } } else { if (!empty($seed->id)) { return $seed; } $result = $seed->retrieve($_REQUEST['record']); return $result; } } //Check if this is the first time we have viewed this record $var = $this->getLocalSessionVariable($html_varName, "IS_FIRST_VIEW"); if (!isset($var) || !$var) { $isFirstView = true; } else { $isFirstView = false; } //indicate that this is not the first time anymore $this->setLocalSessionVariable($html_varName, "IS_FIRST_VIEW", false); // All 3 databases require this because the limit query does a > db_offset comparison. $db_offset = $offset - 1; $this->populateQueryWhere($isFirstView, $html_varName); if (ACLController::requireOwner($seed->module_dir, 'view')) { global $current_user; $seed->getOwnerWhere($current_user->id); if (!empty($this->query_where)) { $this->query_where .= ' AND '; } $this->query_where .= $seed->getOwnerWhere($current_user->id); } /* BEGIN - SECURITY GROUPS */ if (ACLController::requireSecurityGroup($seed->module_dir, 'view')) { require_once 'modules/SecurityGroups/SecurityGroup.php'; global $current_user; $owner_where = $seed->getOwnerWhere($current_user->id); $group_where = SecurityGroup::getGroupWhere($seed->table_name, $seed->module_dir, $current_user->id); if (empty($this->query_where)) { $this->query_where = " (" . $owner_where . " or " . $group_where . ")"; } else { $this->query_where .= " AND (" . $owner_where . " or " . $group_where . ")"; } } /* END - SECURITY GROUPS */ $order = $this->getLocalSessionVariable($seed->module_dir . '2_' . $html_varName, "ORDER_BY"); $orderBy = ''; if (!empty($order['orderBy'])) { $orderBy = $order['orderBy']; } if (!empty($orderBy) && !empty($order['direction'])) { $orderBy .= ' ' . $order['direction']; } $this->query_orderby = $seed->process_order_by($orderBy, null); $current_offset = $_REQUEST['offset'] - 1; $response = $seed->process_detail_query(SugarVCR::retrieve($seed->module_dir), 0, -1, -1, '', $current_offset); //$response = $seed->get_detail(, $this->query_where, $db_offset); $object = $response['bean']; $row_count = $response['row_count']; $next_offset = $response['next_offset']; $previous_offset = $response['previous_offset']; $list_view_row_count = $row_count; $this->setListViewRowCount($row_count); //if the retrieved id is not same as the request ID then hide the VCR buttons. if (empty($object->id)) { $this->no_record_found = true; } if (empty($_REQUEST['InDetailNav']) and strcmp($_REQUEST['record'], $object->id) != 0) { $this->offset_key_mismatch = true; } if ($this->no_record_found or $this->offset_key_mismatch) { if ($nav_history_set) { $this->return_to_list_only = true; } $result = $seed->retrieve($_REQUEST['record']); return $result; } //update the request with correct value for the record attribute. //need only when using the VCR buttons. This is a workaround need to fix the values //set in the VCR links. $_REQUEST['record'] = $object->id; $_GET['record'] = $object->id; $_POST['record'] = $object->id; //set nav_history. if (empty($nav_stamp)) { $nav_stamp = $_GET['stamp']; } if (empty($nav_offset)) { $nav_offset = $offset; } //store a maximum of 20 entries in the nav_ids_visited array. //remove the oldest entry when this limit is reached. if (count($nav_ids_visited) >= 20) { reset($nav_ids_visited); unset($nav_ids_visited[key($nav_ids_visited)]); } $nav_ids_visited[$offset] = $object->id; $nav_history = sprintf("%s:%s:%s", $nav_stamp, $nav_offset, var_export($nav_ids_visited, true)); $this->setLocalSessionVariable($html_varName, "DETAIL_NAV_HISTORY", $nav_history); return $object; }
<? require_once("classes/SecurityGroup.php"); ?> <? require_once("classes/Text.php"); ?> <? $g = SecurityGroup::getById($_REQUEST['id']); if ($g == NULL) { $errMsg = Text::getText("GroupNotFound"); $title = Text::getText("Delete"); include("error.php"); } else { $g->delete(); header("Location: groups.php"); } ?>
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; } }
function get_email_recipients() { $params = unserialize(base64_decode($this->email_recipients)); $emails = array(); if (isset($params['email_target_type'])) { foreach ($params['email_target_type'] as $key => $field) { switch ($field) { case 'Email Address': $emails[] = $params['email'][$key]; break; case 'Specify User': $user = new User(); $user->retrieve($params['email'][$key]); $emails[] = $user->emailAddress->getPrimaryAddress($user); break; case 'Users': $users = array(); switch ($params['email'][$key][0]) { case 'security_group': if (file_exists('modules/SecurityGroups/SecurityGroup.php')) { require_once 'modules/SecurityGroups/SecurityGroup.php'; $security_group = new SecurityGroup(); $security_group->retrieve($params['email'][$key][1]); $users = $security_group->get_linked_beans('users', 'User'); $r_users = array(); if ($params['email'][$key][2] != '') { require_once 'modules/ACLRoles/ACLRole.php'; $role = new ACLRole(); $role->retrieve($params['email'][$key][2]); $role_users = $role->get_linked_beans('users', 'User'); foreach ($role_users as $role_user) { $r_users[$role_user->id] = $role_user->name; } } foreach ($users as $user_id => $user) { if ($params['email'][$key][2] != '' && !isset($r_users[$user->id])) { unset($users[$user_id]); } } break; } //No Security Group module found - fall through. //No Security Group module found - fall through. case 'role': require_once 'modules/ACLRoles/ACLRole.php'; $role = new ACLRole(); $role->retrieve($params['email'][$key][2]); $users = $role->get_linked_beans('users', 'User'); break; case 'all': default: global $db; $sql = "SELECT id from users WHERE status='Active' AND portal_only=0 "; $result = $db->query($sql); while ($row = $db->fetchByAssoc($result)) { $user = new User(); $user->retrieve($row['id']); $users[$user->id] = $user; } break; } foreach ($users as $user) { $emails[] = $user->emailAddress->getPrimaryAddress($user); } break; } } } return $emails; }
function listviewACLHelper() { $array_assign = parent::listviewACLHelper(); $is_owner = false; $in_group = false; //SECURITY GROUPS if (!empty($this->parent_name)) { if (!empty($this->parent_name_owner)) { global $current_user; $is_owner = $current_user->id == $this->parent_name_owner; } else { if (!empty($this->parent_type) && !empty($this->parent_id)) { global $current_user; $parent_bean = BeanFactory::getBean($this->parent_type, $this->parent_id); if ($parent_bean !== false) { $is_owner = $current_user->id == $parent_bean->assigned_user_id; } } } require_once "modules/SecurityGroups/SecurityGroup.php"; $in_group = SecurityGroup::groupHasAccess($this->parent_type, $this->parent_id, 'view'); /* END - SECURITY GROUPS */ } /* BEGIN - SECURITY GROUPS */ /** if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner)){ */ if (!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner, 'module', $in_group)) { /* END - SECURITY GROUPS */ $array_assign['PARENT'] = 'a'; } else { $array_assign['PARENT'] = 'span'; } $is_owner = false; $in_group = false; //SECURITY GROUPS if (!empty($this->contact_name)) { if (!empty($this->contact_name_owner)) { global $current_user; $is_owner = $current_user->id == $this->contact_name_owner; } else { global $current_user; $parent_bean = BeanFactory::getBean('Contacts', $this->contact_id); if ($parent_bean !== false) { $is_owner = $current_user->id == $parent_bean->assigned_user_id; } } require_once "modules/SecurityGroups/SecurityGroup.php"; $in_group = SecurityGroup::groupHasAccess('Contacts', $this->contact_id, 'view'); /* END - SECURITY GROUPS */ } /* BEGIN - SECURITY GROUPS */ /** if( ACLController::checkAccess('Contacts', 'view', $is_owner)){ */ if (ACLController::checkAccess('Contacts', 'view', $is_owner, 'module', $in_group)) { /* END - SECURITY GROUPS */ $array_assign['CONTACT'] = 'a'; } else { $array_assign['CONTACT'] = 'span'; } return $array_assign; }
function doSearch($index, $queryString, $start = 0, $amount = 20) { global $current_user; $cachePath = 'cache/modules/AOD_Index/QueryCache/' . md5($queryString); if (is_file($cachePath)) { $mTime = getCorrectMTime($cachePath); if ($mTime > time() - 5 * 60) { $hits = unserialize(sugar_file_get_contents($cachePath)); } } if (!isset($hits)) { $tmphits = $index->find($queryString); $hits = array(); foreach ($tmphits as $hit) { $bean = BeanFactory::getBean($hit->record_module, $hit->record_id); if (empty($bean)) { continue; } if ($bean->bean_implements('ACL') && !is_admin($current_user)) { //Annoyingly can't use the following as it always passes true for is_owner checks on list //$bean->ACLAccess('list'); $in_group = SecurityGroup::groupHasAccess($bean->module_dir, $bean->id, 'list'); $is_owner = $bean->isOwner($current_user->id); $access = ACLController::checkAccess($bean->module_dir, 'list', $is_owner, 'module', $in_group); if (!$access) { continue; } } $newHit = new stdClass(); $newHit->record_module = $hit->record_module; $newHit->record_id = $hit->record_id; $newHit->score = $hit->score; $newHit->label = getModuleLabel($bean->module_name); $newHit->name = $bean->get_summary_text(); $newHit->summary = getRecordSummary($bean); $newHit->date_entered = $bean->date_entered; $newHit->date_modified = $bean->date_modified; $hits[] = $newHit; } //Cache results so pagination is nice and snappy. cacheQuery($queryString, $hits); } $total = count($hits); $hits = array_slice($hits, $start, $amount); $res = array('total' => $total, 'hits' => $hits); return $res; }
} $xtpl->assign('securitysuite_inherit_creator', $securitysuite_inherit_creator); // securitysuite_inherit_parent $securitysuite_inherit_parent = ''; if (isset($sugar_config['securitysuite_inherit_parent']) && $sugar_config['securitysuite_inherit_parent'] == true) { $securitysuite_inherit_parent = 'CHECKED'; } $xtpl->assign('securitysuite_inherit_parent', $securitysuite_inherit_parent); // securitysuite_inherit_assigned $securitysuite_inherit_assigned = ''; if (isset($sugar_config['securitysuite_inherit_assigned']) && $sugar_config['securitysuite_inherit_assigned'] == true) { $securitysuite_inherit_assigned = 'CHECKED'; } $xtpl->assign('securitysuite_inherit_assigned', $securitysuite_inherit_assigned); //default security groups $groupFocus = new SecurityGroup(); $defaultGroups = $groupFocus->retrieveDefaultGroups(); $defaultGroup_string = ""; foreach ($defaultGroups as $default_id => $defaultGroup) { $defaultGroup_string .= "\n\t<tr>\n\t<td class='dataLabel' width='30%'>\n\t\t" . $mod_strings['LBL_GROUP'] . " " . $defaultGroup['group'] . "\n\t</td>\n\t<td class='dataField' width='30%'>\n\t\t" . $mod_strings['LBL_MODULE'] . " " . $defaultGroup['module'] . "\n\t</td>\n\t<td class='dataLabel' width='40%'>\n\t\t<input type='submit' tabindex='1' class='button' onclick=\"this.form.remove_default_id.value='" . $default_id . "'; this.form.action.value='SaveConfig'; this.form.return_module.value='SecurityGroups'; this.form.return_action.value='config';\" value='" . $mod_strings['LBL_REMOVE_BUTTON_LABEL'] . "'/>\n\t</td>\n\t</tr>"; } $xtpl->assign("DEFAULT_GROUPS", $defaultGroup_string); $groups = $groupFocus->get_list("name"); $options = array("" => ""); foreach ($groups['list'] as $group) { $options[$group->id] = $group->name; } $xtpl->assign("SECURITY_GROUP_OPTIONS", get_select_options_with_id($options, "")); //$moduleList = $app_list_strings['moduleList']; //require_once('modules/Studio/DropDowns/DropDownHelper.php'); //$dh = new DropDownHelper();
function display($preview = false) { global $mod_strings; $parser = ParserFactory::getParser($this->editLayout, $this->editModule, $this->package); $history = $parser->getHistory(); $smarty = new Sugar_Smarty(); //Add in the module we are viewing to our current mod strings if (!$this->fromModuleBuilder) { global $current_language; $editModStrings = return_module_language($current_language, $this->editModule); $mod_strings = sugarArrayMerge($editModStrings, $mod_strings); } $smarty->assign('mod', $mod_strings); $smarty->assign('MOD', $mod_strings); // assign buttons $images = array('icon_save' => 'studio_save', 'icon_publish' => 'studio_publish', 'icon_address' => 'icon_Address', 'icon_emailaddress' => 'icon_EmailAddress', 'icon_phone' => 'icon_Phone'); foreach ($images as $image => $file) { $smarty->assign($image, SugarThemeRegistry::current()->getImage($file)); } /* BEGIN - SECURITY GROUPS */ $groupLayout = ""; if (!empty($_REQUEST['grpLayout'])) { $groupLayout = $_REQUEST['grpLayout']; } $groupName = "Default"; if (!isset($groupLayout) || empty($groupLayout)) { $groupLayout = ""; } else { //Get group name for display require_once 'modules/SecurityGroups/SecurityGroup.php'; $groupFocus = new SecurityGroup(); $groupFocus->retrieve($groupLayout); $groupName = $groupFocus->name; } $smarty->assign('grpLayout', $groupLayout); /* END - SECURITY GROUPS */ $requiredFields = implode($parser->getRequiredFields(), ','); $slashedRequiredFields = addslashes($requiredFields); $buttons = array(); $disableLayout = false; if ($preview) { $smarty->assign('layouttitle', translate('LBL_LAYOUT_PREVIEW', 'ModuleBuilder')); } else { $smarty->assign('layouttitle', translate('LBL_CURRENT_LAYOUT', 'ModuleBuilder')); if ($this->editLayout == MB_DETAILVIEW || $this->editLayout == MB_QUICKCREATE) { $parser2 = ParserFactory::getParser(MB_EDITVIEW, $this->editModule, $this->package); if ($this->editLayout == MB_DETAILVIEW) { $disableLayout = $parser2->getSyncDetailEditViews(); } if (!empty($_REQUEST['copyFromEditView'])) { $editViewPanels = $parser2->convertFromCanonicalForm($parser2->_viewdefs['panels'], $parser2->_fielddefs); $parser->_viewdefs['panels'] = $editViewPanels; $parser->_fielddefs = $parser2->_fielddefs; $parser->setUseTabs($parser2->getUseTabs()); } } if (!$this->fromModuleBuilder) { $buttons[] = array('id' => 'saveBtn', 'text' => translate('LBL_BTN_SAVE'), 'actionScript' => "onclick='if(Studio2.checkGridLayout(\"{$this->editLayout}\")) Studio2.handleSave();'", 'disabled' => $disableLayout); $buttons[] = array('id' => 'publishBtn', 'text' => translate('LBL_BTN_SAVEPUBLISH'), 'actionScript' => "onclick='if(Studio2.checkGridLayout(\"{$this->editLayout}\")) Studio2.handlePublish();'", 'disabled' => $disableLayout); $buttons[] = array('id' => 'spacer', 'width' => '33px'); $buttons[] = array('id' => 'historyBtn', 'text' => translate('LBL_HISTORY'), 'actionScript' => "onclick='ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")'", 'disabled' => $disableLayout); $buttons[] = array('id' => 'historyDefault', 'text' => translate('LBL_RESTORE_DEFAULT'), 'actionScript' => "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"\")'", 'disabled' => $disableLayout); } else { $buttons[] = array('id' => 'saveBtn', 'text' => $GLOBALS['mod_strings']['LBL_BTN_SAVE'], 'actionScript' => "onclick='if(Studio2.checkGridLayout(\"{$this->editLayout}\")) Studio2.handlePublish();'", 'disabled' => $disableLayout); $buttons[] = array('id' => 'spacer', 'width' => '33px'); $buttons[] = array('id' => 'historyBtn', 'text' => translate('LBL_HISTORY'), 'actionScript' => "onclick='ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")'", 'disabled' => $disableLayout); $buttons[] = array('id' => 'historyDefault', 'text' => translate('LBL_RESTORE_DEFAULT'), 'actionScript' => "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"\")'", 'disabled' => $disableLayout); } if ($this->editLayout == MB_DETAILVIEW || $this->editLayout == MB_QUICKCREATE) { $buttons[] = array('id' => 'copyFromEditView', 'text' => translate('LBL_COPY_FROM_EDITVIEW'), 'actionScript' => "onclick='ModuleBuilder.copyFromView(\"{$this->editModule}\", \"{$this->editLayout}\")'", 'disabled' => $disableLayout); } } $html = ""; foreach ($buttons as $button) { if ($button['id'] == "spacer") { $html .= "<td style='width:{$button['width']}'> </td>"; } else { $html .= "<td><input id='{$button['id']}' type='button' valign='center' class='button' style='cursor:pointer' " . "onmousedown='this.className=\"buttonOn\";return false;' onmouseup='this.className=\"button\"' " . "onmouseout='this.className=\"button\"' {$button['actionScript']} value = '{$button['text']}'"; if (!empty($button['disabled'])) { $html .= " disabled"; } $html .= "></td>"; } } $smarty->assign('buttons', $html); // assign fields and layout $smarty->assign('available_fields', $parser->getAvailableFields()); $smarty->assign('disable_layout', $disableLayout); $smarty->assign('required_fields', $requiredFields); $smarty->assign('layout', $parser->getLayout()); $smarty->assign('field_defs', $parser->getFieldDefs()); $smarty->assign('view_module', $this->editModule); $smarty->assign('view', $this->editLayout); $smarty->assign('maxColumns', $parser->getMaxColumns()); $smarty->assign('nextPanelId', $parser->getFirstNewPanelId()); $smarty->assign('displayAsTabs', $parser->getUseTabs()); $smarty->assign('syncDetailEditViews', $parser->getSyncDetailEditViews()); $smarty->assign('fieldwidth', 150); $smarty->assign('translate', $this->fromModuleBuilder ? false : true); if ($this->fromModuleBuilder) { $smarty->assign('fromModuleBuilder', $this->fromModuleBuilder); $smarty->assign('view_package', $this->package); } $labels = array(MB_EDITVIEW => 'LBL_EDITVIEW', MB_DETAILVIEW => 'LBL_DETAILVIEW', MB_QUICKCREATE => 'LBL_QUICKCREATE'); $layoutLabel = 'LBL_LAYOUTS'; $layoutView = 'layouts'; $ajax = new AjaxCompose(); $viewType; $translatedViewType = ''; if (isset($labels[strtolower($this->editLayout)])) { $translatedViewType = translate($labels[strtolower($this->editLayout)], 'ModuleBuilder'); } if ($this->fromModuleBuilder) { $ajax->addCrumb(translate('LBL_MODULEBUILDER', 'ModuleBuilder'), 'ModuleBuilder.main("mb")'); $ajax->addCrumb($this->package, 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package=' . $this->package . '")'); $ajax->addCrumb($this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_package=' . $this->package . '&view_module=' . $this->editModule . '")'); $ajax->addCrumb(translate($layoutLabel, 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&MB=true&action=wizard&view=' . $layoutView . '&view_module=' . $this->editModule . '&view_package=' . $this->package . '")'); $ajax->addCrumb($translatedViewType, ''); } else { $ajax->addCrumb(translate('LBL_STUDIO', 'ModuleBuilder'), 'ModuleBuilder.main("studio")'); $ajax->addCrumb($this->translatedEditModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $this->editModule . '")'); $ajax->addCrumb(translate($layoutLabel, 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=' . $layoutView . '&view_module=' . $this->editModule . '")'); /* BEGIN - SECURITY GROUPS */ $ajax->addCrumb(translate($groupName), ''); /* END - SECURITY GROUPS */ $ajax->addCrumb($translatedViewType, ''); } // set up language files $smarty->assign('language', $parser->getLanguage()); // for sugar_translate in the smarty template $smarty->assign('from_mb', $this->fromModuleBuilder); $smarty->assign('calc_field_list', json_encode($parser->getCalculatedFields())); if ($this->fromModuleBuilder) { $mb = new ModuleBuilder(); $module =& $mb->getPackageModule($this->package, $this->editModule); $smarty->assign('current_mod_strings', $module->getModStrings()); } $ajax->addSection('center', $translatedViewType, $smarty->fetch('modules/ModuleBuilder/tpls/layoutView.tpl')); if ($preview) { echo $smarty->fetch('modules/ModuleBuilder/tpls/Preview/layoutView.tpl'); } else { echo $ajax->getJavascript(); } }