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 }
/** * 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; }
function SubpanelQuickCreate($module, $view = 'QuickCreate', $proccessOverride = false) { // locate the best viewdefs to use: 1. custom/module/quickcreatedefs.php 2. module/quickcreatedefs.php 3. custom/module/editviewdefs.php 4. module/editviewdefs.php $base = 'modules/' . $module . '/metadata/'; $source = 'custom/' . $base . strtolower($view) . 'defs.php'; /* BEGIN - SECURITY GROUPS */ //get group ids of current user and check to see if a layout exists for that group global $current_user; require_once 'modules/SecurityGroups/SecurityGroup.php'; $groupFocus = new SecurityGroup(); $groupList = $groupFocus->getUserSecurityGroups($current_user->id); //reorder by precedence.... $foundViewDefs = false; foreach ($groupList as $groupItem) { $GLOBALS['log']->fatal("Looking for: " . 'custom/modules/' . $module . '/metadata/' . $groupItem['id'] . '/' . strtolower($view) . 'defs.php'); if (file_exists('custom/modules/' . $module . '/metadata/' . $groupItem['id'] . '/' . strtolower($view) . 'defs.php')) { $_SESSION['groupLayout'] = $groupItem['id']; $source = 'custom/modules/' . $module . '/metadata/' . $groupItem['id'] . '/' . strtolower($view) . 'defs.php'; $foundViewDefs = true; } } if ($foundViewDefs == true) { //just a way to avoid the if statement below... } else { /* END - SECURITY GROUPS */ if (!file_exists($source)) { $source = $base . strtolower($view) . 'defs.php'; if (!file_exists($source)) { //if our view does not exist default to EditView $view = 'EditView'; $source = 'custom/' . $base . 'editviewdefs.php'; if (!file_exists($source)) { $source = $base . 'editviewdefs.php'; } } } } $this->ev = new EditView(); $this->ev->view = $view; $this->ev->ss = new Sugar_Smarty(); //$_REQUEST['return_action'] = 'SubPanelViewer'; $this->ev->setup($module, null, $source); $this->ev->defs['templateMeta']['form']['headerTpl'] = 'include/EditView/header.tpl'; $this->ev->defs['templateMeta']['form']['footerTpl'] = 'include/EditView/footer.tpl'; $this->ev->defs['templateMeta']['form']['buttons'] = array('SUBPANELSAVE', 'SUBPANELCANCEL', 'SUBPANELFULLFORM'); $viewEditSource = 'modules/' . $module . '/views/view.edit.php'; if (file_exists('custom/' . $viewEditSource)) { $viewEditSource = 'custom/' . $viewEditSource; } if (file_exists($viewEditSource) && !$proccessOverride) { include $viewEditSource; $c = $module . 'ViewEdit'; if (class_exists($c)) { $view = new $c(); if ($view->useForSubpanel) { $this->defaultProcess = false; //Check if we shold use the module's QuickCreate.tpl file if ($view->useModuleQuickCreateTemplate && file_exists('modules/' . $module . '/tpls/QuickCreate.tpl')) { $this->ev->defs['templateMeta']['form']['headerTpl'] = 'modules/' . $module . '/tpls/QuickCreate.tpl'; } $view->ev =& $this->ev; $view->ss =& $this->ev->ss; $class = $GLOBALS['beanList'][$module]; if (!empty($GLOBALS['beanFiles'][$class])) { require_once $GLOBALS['beanFiles'][$class]; $bean = new $class(); $view->bean = $bean; } $this->ev->formName = 'form_Subpanel' . $this->ev->view . '_' . $module; $view->showTitle = false; // Do not show title since this is for subpanel $view->display(); } } } //if if ($this->defaultProcess && !$proccessOverride) { $this->process($module); } }
/** * * @return the form for users posting group messages */ function getPostForm() { global $current_user; require_once 'modules/SecurityGroups/SecurityGroup.php'; $securitygroups = SecurityGroup::getUserSecurityGroups($current_user->id); if (!is_admin($GLOBALS['current_user']) && sizeof($securitygroups) == 0) { return; } //$options = array(""=>""); $options = array(); if (is_admin($GLOBALS['current_user'])) { $options = array("" => "All"); } foreach ($securitygroups as $group) { $options[$group['id']] = $group['name']; } global $current_user; $user_name = ucfirst($GLOBALS['current_user']->user_name); $moreimg = get_image($GLOBALS['image_path'] . '/advanced_search', ''); // , 'onclick="toggleDisplay(\'more_' . $this->id . '\'); toggleDisplay(\'more_img_'.$this->id.'\'); toggleDisplay(\'less_img_'.$this->id.'\');"'); $lessimg = get_image($GLOBALS['image_path'] . '/basic_search', ''); // , 'onclick="toggleDisplay(\'more_' . $this->id . '\'); toggleDisplay(\'more_img_'.$this->id.'\'); toggleDisplay(\'less_img_'.$this->id.'\');"'); $ss = new Sugar_Smarty(); $ss->assign('LBL_MAKE_POST', translate('LBL_MAKE_POST', 'SecurityGroups')); $ss->assign('LBL_POST', translate('LBL_POST', 'SecurityGroups')); $ss->assign('LBL_SELECT_GROUP', translate('LBL_SELECT_GROUP', 'SecurityGroups')); $ss->assign('GROUP_OPTIONS', get_select_options_with_id($options, "")); $ss->assign('id', $this->id); $ss->assign('more_img', $moreimg); $ss->assign('less_img', $lessimg); return $ss->fetch('modules/SecurityGroups/Dashlets/MessageDashlet/UserPostForm.tpl'); }
function preDisplay() { /* BEGIN - SECURITY GROUPS */ $metadataFile = null; $foundViewDefs = false; if (empty($_SESSION['groupLayout'])) { //get group ids of current user and check to see if a layout exists for that group global $current_user; require_once 'modules/SecurityGroups/SecurityGroup.php'; $groupFocus = new SecurityGroup(); $groupList = $groupFocus->getUserSecurityGroups($current_user->id); //reorder by precedence.... foreach ($groupList as $groupItem) { $GLOBALS['log']->debug("Looking for: " . 'custom/modules/' . $this->module . '/metadata/' . $groupItem['id'] . '/detailviewdefs.php'); if (file_exists('custom/modules/' . $this->module . '/metadata/' . $groupItem['id'] . '/detailviewdefs.php')) { $_SESSION['groupLayout'] = $groupItem['id']; $metadataFile = 'custom/modules/' . $this->module . '/metadata/' . $groupItem['id'] . '/detailviewdefs.php'; break; } } } else { if (file_exists('custom/modules/' . $this->module . '/metadata/' . $_SESSION['groupLayout'] . '/detailviewdefs.php')) { $metadataFile = 'custom/modules/' . $this->module . '/metadata/' . $_SESSION['groupLayout'] . '/detailviewdefs.php'; } } if (isset($metadataFile)) { $foundViewDefs = true; } else { $metadataFile = $this->getMetaDataFile(); } /* END - SECURITY GROUPS */ $this->dv = new DetailView2(); $this->dv->ss =& $this->ss; $this->dv->setup($this->module, $this->bean, $metadataFile, 'modules/ContractAppendixs/tpls/DetailView/' . $this->bean->type . '.tpl'); }
public function testgetUserSecurityGroups() { //unset and reconnect Db to resolve mysqli fetch exeception global $db; unset($db->database); $db->checkConnection(); $securityGroup = new SecurityGroup(); $result = $securityGroup->getUserSecurityGroups('1'); $this->assertTrue(is_array($result)); }