Ejemplo n.º 1
0
function bpminbox_get_username_by_id($userid)
{
    if (empty($userid)) {
        return false;
    }
    $user = SugarModule::get('Users')->loadBean();
    $user->retrieve($userid);
    if ($userid != $user->id) {
        return false;
    }
    if (showFullName()) {
        return $user->full_name;
    } else {
        return $user->user_name;
    }
}
Ejemplo n.º 2
0
 /**
  * Displays the header on section of the page; basically everything before the content
  */
 public function displayHeader($retModTabs = false)
 {
     global $theme;
     global $max_tabs;
     global $app_strings;
     global $current_user;
     global $sugar_config;
     global $app_list_strings;
     global $mod_strings;
     global $current_language;
     $GLOBALS['app']->headerDisplayed = true;
     $themeObject = SugarThemeRegistry::current();
     $theme = $themeObject->__toString();
     $ss = new Sugar_Smarty();
     $ss->assign("APP", $app_strings);
     $ss->assign("THEME", $theme);
     $ss->assign("THEME_IE6COMPAT", $themeObject->ie6compat ? 'true' : 'false');
     $ss->assign("MODULE_NAME", $this->module);
     $ss->assign("langHeader", get_language_header());
     // set ab testing if exists
     $testing = isset($_REQUEST["testing"]) ? $_REQUEST['testing'] : "a";
     $ss->assign("ABTESTING", $testing);
     // get browser title
     $ss->assign("SYSTEM_NAME", $this->getBrowserTitle());
     // get css
     $css = $themeObject->getCSS();
     if ($this->_getOption('view_print')) {
         $css .= '<link rel="stylesheet" type="text/css" href="' . $themeObject->getCSSURL('print.css') . '" media="all" />';
     }
     $ss->assign("SUGAR_CSS", $css);
     // get javascript
     ob_start();
     $this->renderJavascript();
     $ss->assign("SUGAR_JS", ob_get_contents() . $themeObject->getJS());
     ob_end_clean();
     // get favicon
     if (isset($GLOBALS['sugar_config']['default_module_favicon'])) {
         $module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
     } else {
         $module_favicon = false;
     }
     $favicon = $this->getFavicon();
     $ss->assign('FAVICON_URL', $favicon['url']);
     // build the shortcut menu
     $shortcut_menu = array();
     foreach ($this->getMenu() as $key => $menu_item) {
         $shortcut_menu[$key] = array("URL" => $menu_item[0], "LABEL" => $menu_item[1], "MODULE_NAME" => $menu_item[2], "IMAGE" => $themeObject->getImage($menu_item[2], "border='0' align='absmiddle'", null, null, '.gif', $menu_item[1]));
     }
     $ss->assign("SHORTCUT_MENU", $shortcut_menu);
     // handle rtl text direction
     if (isset($_REQUEST['RTL']) && $_REQUEST['RTL'] == 'RTL') {
         $_SESSION['RTL'] = true;
     }
     if (isset($_REQUEST['LTR']) && $_REQUEST['LTR'] == 'LTR') {
         unset($_SESSION['RTL']);
     }
     if (isset($_SESSION['RTL']) && $_SESSION['RTL']) {
         $ss->assign("DIR", 'dir="RTL"');
     }
     // handle resizing of the company logo correctly on the fly
     $companyLogoURL = $themeObject->getImageURL('company_logo.png');
     $companyLogoURL_arr = explode('?', $companyLogoURL);
     $companyLogoURL = $companyLogoURL_arr[0];
     $company_logo_attributes = sugar_cache_retrieve('company_logo_attributes');
     if (!empty($company_logo_attributes)) {
         $ss->assign("COMPANY_LOGO_MD5", $company_logo_attributes[0]);
         $ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes[1]);
         $ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes[2]);
     } else {
         // Always need to md5 the file
         $ss->assign("COMPANY_LOGO_MD5", md5_file($companyLogoURL));
         list($width, $height) = getimagesize($companyLogoURL);
         if ($width > 212 || $height > 40) {
             $resizePctWidth = ($width - 212) / 212;
             $resizePctHeight = ($height - 40) / 40;
             if ($resizePctWidth > $resizePctHeight) {
                 $resizeAmount = $width / 212;
             } else {
                 $resizeAmount = $height / 40;
             }
             $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1 / $resizeAmount)));
             $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1 / $resizeAmount)));
         } else {
             $ss->assign("COMPANY_LOGO_WIDTH", $width);
             $ss->assign("COMPANY_LOGO_HEIGHT", $height);
         }
         // Let's cache the results
         sugar_cache_put('company_logo_attributes', array($ss->get_template_vars("COMPANY_LOGO_MD5"), $ss->get_template_vars("COMPANY_LOGO_WIDTH"), $ss->get_template_vars("COMPANY_LOGO_HEIGHT")));
     }
     $ss->assign("COMPANY_LOGO_URL", getJSPath($companyLogoURL) . "&logo_md5=" . $ss->get_template_vars("COMPANY_LOGO_MD5"));
     // get the global links
     $gcls = array();
     $global_control_links = array();
     require "include/globalControlLinks.php";
     foreach ($global_control_links as $key => $value) {
         if ($key == 'users') {
             //represents logout link.
             $ss->assign("LOGOUT_LINK", $value['linkinfo'][key($value['linkinfo'])]);
             $ss->assign("LOGOUT_LABEL", key($value['linkinfo']));
             //key value for first element.
             continue;
         }
         foreach ($value as $linkattribute => $attributevalue) {
             // get the main link info
             if ($linkattribute == 'linkinfo') {
                 $gcls[$key] = array("LABEL" => key($attributevalue), "URL" => current($attributevalue), "SUBMENU" => array());
                 if (substr($gcls[$key]["URL"], 0, 11) == "javascript:") {
                     $gcls[$key]["ONCLICK"] = substr($gcls[$key]["URL"], 11);
                     $gcls[$key]["URL"] = "javascript:void(0)";
                 }
             }
             // and now the sublinks
             if ($linkattribute == 'submenu' && is_array($attributevalue)) {
                 foreach ($attributevalue as $submenulinkkey => $submenulinkinfo) {
                     $gcls[$key]['SUBMENU'][$submenulinkkey] = array("LABEL" => key($submenulinkinfo), "URL" => current($submenulinkinfo));
                 }
                 if (substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 0, 11) == "javascript:") {
                     $gcls[$key]['SUBMENU'][$submenulinkkey]["ONCLICK"] = substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 11);
                     $gcls[$key]['SUBMENU'][$submenulinkkey]["URL"] = "javascript:void(0)";
                 }
             }
         }
     }
     $ss->assign("GCLS", $gcls);
     $ss->assign("SEARCH", isset($_REQUEST['query_string']) ? $_REQUEST['query_string'] : '');
     if ($this->action == "EditView" || $this->action == "Login") {
         $ss->assign("ONLOAD", 'onload="set_focus()"');
     }
     $ss->assign("AUTHENTICATED", isset($_SESSION["authenticated_user_id"]));
     // get other things needed for page style popup
     if (isset($_SESSION["authenticated_user_id"])) {
         // get the current user name and id
         $ss->assign("CURRENT_USER", $current_user->full_name == '' || !showFullName() ? $current_user->user_name : $current_user->full_name);
         $ss->assign("CURRENT_USER_ID", $current_user->id);
         // get the last viewed records
         $tracker = new Tracker();
         $history = $tracker->get_recently_viewed($current_user->id);
         $ss->assign("recentRecords", $this->processRecentRecords($history));
     }
     $bakModStrings = $mod_strings;
     if (isset($_SESSION["authenticated_user_id"])) {
         // get the module list
         $moduleTopMenu = array();
         $max_tabs = $current_user->getPreference('max_tabs');
         // Attempt to correct if max tabs count is extremely high.
         if (!isset($max_tabs) || $max_tabs <= 0 || $max_tabs > 10) {
             $max_tabs = $GLOBALS['sugar_config']['default_max_tabs'];
             $current_user->setPreference('max_tabs', $max_tabs, 0, 'global');
         }
         /*$moduleTab = $this->_getModuleTab();
           $ss->assign('MODULE_TAB',$moduleTab);*/
         // See if they are using grouped tabs or not (removed in 6.0, returned in 6.1)
         $user_navigation_paradigm = $current_user->getPreference('navigation_paradigm');
         if (!isset($user_navigation_paradigm)) {
             $user_navigation_paradigm = $GLOBALS['sugar_config']['default_navigation_paradigm'];
         }
         // Get the full module list for later use
         foreach (query_module_access_list($current_user) as $module) {
             // Bug 25948 - Check for the module being in the moduleList
             if (isset($app_list_strings['moduleList'][$module])) {
                 $fullModuleList[$module] = $app_list_strings['moduleList'][$module];
             }
         }
         if (!should_hide_iframes()) {
             $iFrame = new iFrame();
             $frames = $iFrame->lookup_frames('tab');
             foreach ($frames as $key => $values) {
                 $fullModuleList[$key] = $values;
             }
         } elseif (isset($fullModuleList['iFrames'])) {
             unset($fullModuleList['iFrames']);
         }
         if ($user_navigation_paradigm == 'gm' && isset($themeObject->group_tabs) && $themeObject->group_tabs) {
             // We are using grouped tabs
             require_once 'include/GroupedTabs/GroupedTabStructure.php';
             $groupedTabsClass = new GroupedTabStructure();
             $modules = query_module_access_list($current_user);
             //handle with submoremodules
             $max_tabs = $current_user->getPreference('max_tabs');
             // If the max_tabs isn't set incorrectly, set it within the range, to the default max sub tabs size
             if (!isset($max_tabs) || $max_tabs <= 0 || $max_tabs > 10) {
                 // We have a default value. Use it
                 if (isset($GLOBALS['sugar_config']['default_max_tabs'])) {
                     $max_tabs = $GLOBALS['sugar_config']['default_max_tabs'];
                 } else {
                     $max_tabs = 8;
                 }
             }
             $subMoreModules = false;
             $groupTabs = $groupedTabsClass->get_tab_structure(get_val_array($modules));
             // We need to put this here, so the "All" group is valid for the user's preference.
             $groupTabs[$app_strings['LBL_TABGROUP_ALL']]['modules'] = $fullModuleList;
             // Setup the default group tab.
             $allGroup = $app_strings['LBL_TABGROUP_ALL'];
             $ss->assign('currentGroupTab', $allGroup);
             $currentGroupTab = $allGroup;
             $usersGroup = $current_user->getPreference('theme_current_group');
             // Figure out which tab they currently have selected (stored as a user preference)
             if (!empty($usersGroup) && isset($groupTabs[$usersGroup])) {
                 $currentGroupTab = $usersGroup;
             } else {
                 $current_user->setPreference('theme_current_group', $currentGroupTab);
             }
             $ss->assign('currentGroupTab', $currentGroupTab);
             $usingGroupTabs = true;
         } else {
             // Setup the default group tab.
             $ss->assign('currentGroupTab', $app_strings['LBL_TABGROUP_ALL']);
             $usingGroupTabs = false;
             $groupTabs[$app_strings['LBL_TABGROUP_ALL']]['modules'] = $fullModuleList;
         }
         $topTabList = array();
         // Now time to go through each of the tab sets and fix them up.
         foreach ($groupTabs as $tabIdx => $tabData) {
             $topTabs = $tabData['modules'];
             if (!is_array($topTabs)) {
                 $topTabs = array();
             }
             $extraTabs = array();
             // Split it in to the tabs that go across the top, and the ones that are on the extra menu.
             if (count($topTabs) > $max_tabs) {
                 $extraTabs = array_splice($topTabs, $max_tabs);
             }
             // Make sure the current module is accessable through one of the top tabs
             if (!isset($topTabs[$moduleTab])) {
                 // Nope, we need to add it.
                 // First, take it out of the extra menu, if it's there
                 if (isset($extraTabs[$moduleTab])) {
                     unset($extraTabs[$moduleTab]);
                 }
                 if (count($topTabs) >= $max_tabs - 1) {
                     // We already have the maximum number of tabs, so we need to shuffle the last one
                     // from the top to the first one of the extras
                     $lastElem = array_splice($topTabs, $max_tabs - 1);
                     $extraTabs = $lastElem + $extraTabs;
                 }
                 if (!empty($moduleTab)) {
                     $topTabs[$moduleTab] = $app_list_strings['moduleList'][$moduleTab];
                 }
             }
             /*
             // This was removed, but I like the idea, so I left the code in here in case we decide to turn it back on
             // If we are using group tabs, add all the "hidden" tabs to the end of the extra menu
             if ( $usingGroupTabs ) {
                 foreach($fullModuleList as $moduleKey => $module ) {
                     if ( !isset($topTabs[$moduleKey]) && !isset($extraTabs[$moduleKey]) ) {
                         $extraTabs[$moduleKey] = $module;
                     }
                 }
             }
             */
             // Get a unique list of the top tabs so we can build the popup menus for them
             foreach ($topTabs as $moduleKey => $module) {
                 $topTabList[$moduleKey] = $module;
             }
             $groupTabs[$tabIdx]['modules'] = $topTabs;
             $groupTabs[$tabIdx]['extra'] = $extraTabs;
         }
     }
     if (isset($topTabList) && is_array($topTabList)) {
         // Adding shortcuts array to menu array for displaying shortcuts associated with each module
         $shortcutTopMenu = array();
         foreach ($topTabList as $module_key => $label) {
             global $mod_strings;
             $mod_strings = return_module_language($current_language, $module_key);
             foreach ($this->getMenu($module_key) as $key => $menu_item) {
                 $shortcutTopMenu[$module_key][$key] = array("URL" => $menu_item[0], "LABEL" => $menu_item[1], "MODULE_NAME" => $menu_item[2], "IMAGE" => $themeObject->getImage($menu_item[2], "border='0' align='absmiddle'", null, null, '.gif', $menu_item[1]), "ID" => $menu_item[2] . "_link");
             }
         }
         $ss->assign("groupTabs", $groupTabs);
         $ss->assign("shortcutTopMenu", $shortcutTopMenu);
         $ss->assign('USE_GROUP_TABS', $usingGroupTabs);
         // This is here for backwards compatibility, someday, somewhere, it will be able to be removed
         $ss->assign("moduleTopMenu", $groupTabs[$app_strings['LBL_TABGROUP_ALL']]['modules']);
         $ss->assign("moduleExtraMenu", $groupTabs[$app_strings['LBL_TABGROUP_ALL']]['extra']);
     }
     if (isset($extraTabs) && is_array($extraTabs)) {
         // Adding shortcuts array to extra menu array for displaying shortcuts associated with each module
         $shortcutExtraMenu = array();
         foreach ($extraTabs as $module_key => $label) {
             global $mod_strings;
             $mod_strings = return_module_language($current_language, $module_key);
             foreach ($this->getMenu($module_key) as $key => $menu_item) {
                 $shortcutExtraMenu[$module_key][$key] = array("URL" => $menu_item[0], "LABEL" => $menu_item[1], "MODULE_NAME" => $menu_item[2], "IMAGE" => $themeObject->getImage($menu_item[2], "border='0' align='absmiddle'", null, null, '.gif', $menu_item[1]), "ID" => $menu_item[2] . "_link");
             }
         }
         $ss->assign("shortcutExtraMenu", $shortcutExtraMenu);
     }
     if (!empty($current_user)) {
         $ss->assign("max_tabs", $current_user->getPreference("max_tabs"));
     }
     $imageURL = SugarThemeRegistry::current()->getImageURL("dashboard.png");
     $homeImage = "<img src='{$imageURL}'>";
     $ss->assign("homeImage", $homeImage);
     global $mod_strings;
     $mod_strings = $bakModStrings;
     $headerTpl = $themeObject->getTemplate('header.tpl');
     if (inDeveloperMode()) {
         $ss->clear_compiled_tpl($headerTpl);
     }
     if ($retModTabs) {
         return $ss->fetch($themeObject->getTemplate('_headerModuleList.tpl'));
     } else {
         $ss->display($headerTpl);
         $this->includeClassicFile('modules/Administration/DisplayWarnings.php');
         $errorMessages = SugarApplication::getErrorMessages();
         if (!empty($errorMessages)) {
             foreach ($errorMessages as $error_message) {
                 echo '<p class="error">' . $error_message . '</p>';
             }
         }
     }
 }
Ejemplo n.º 3
0
    /**
     * Add a generic widget to lookup Users.
     * @param displayname Name to display in the popup window
     * @param varname name of the variable
     * @param id_name name of the id in vardef
     * @param mod_type name of the module, either "Contact" or "Releases" currently
     */
    function addUserName($displayname, $varname, $id_name = '', $mod_type)
    {
        global $app_strings;
        if (empty($id_name)) {
            $id_name = strtolower($mod_type) . "_id";
        }
        ///////////////////////////////////////
        ///
        /// SETUP POPUP
        $reportsDisplayName = showFullName() ? 'name' : 'user_name';
        $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'MassUpdate', 'field_to_name_array' => array('id' => "{$id_name}", "{$reportsDisplayName}" => "{$varname}"));
        $json = getJSONobj();
        $encoded_popup_request_data = $json->encode($popup_request_data);
        $qsName = array('form' => 'MassUpdate', 'method' => 'get_user_array', 'modules' => array("{$mod_type}"), 'group' => 'or', 'field_list' => array('user_name', 'id'), 'populate_list' => array("mass_{$varname}", "mass_{$id_name}"), 'conditions' => array(array('name' => 'name', 'op' => 'like_custom', 'end' => '%', 'value' => '')), 'limit' => '30', 'no_match_text' => $app_strings['ERR_SQS_NO_MATCH']);
        $qsName = $json->encode($qsName);
        //
        ///////////////////////////////////////
        return <<<EOHTML
<td width='15%'  scope='row' class='dataLabel'>{$displayname}</td>
<td width='35%' class='dataField'>
    <input name='{$varname}' id='mass_{$varname}' class='sqsEnabled' autocomplete='off' type='text' value=''>
    <input name='{$id_name}' id='mass_{$id_name}' type='hidden' value=''>&nbsp;
    <input title='{$app_strings['LBL_SELECT_BUTTON_TITLE']}'
        accessKey='{$app_strings['LBL_SELECT_BUTTON_KEY']}'
        type='button' class='button' value='{$app_strings['LBL_SELECT_BUTTON_LABEL']}' name='button'
        onclick='open_popup("{$mod_type}", 600, 400, "", true, false, {$encoded_popup_request_data});'
        />
</td>
<script type="text/javascript">
<!--
if(typeof sqs_objects == 'undefined'){
    var sqs_objects = new Array;
}
sqs_objects['MassUpdate_{$varname}'] = {$qsName};
registerSingleSmartInputListener(document.getElementById('mass_{$varname}'));
addToValidateBinaryDependency('MassUpdate', '{$varname}', 'alpha', false, '{$app_strings['ERR_SQS_NO_MATCH_FIELD']} {$app_strings['LBL_ASSIGNED_TO']}','{$id_name}');
-->
</script>
EOHTML;
    }
Ejemplo n.º 4
0
 function display($end = true)
 {
     global $app_strings;
     if (!is_file(sugar_cached("jsLanguage/{$GLOBALS['current_language']}.js"))) {
         require_once 'include/language/jsLanguage.php';
         jsLanguage::createAppStringsCache($GLOBALS['current_language']);
     }
     $jsLang = getVersionedScript("cache/jsLanguage/{$GLOBALS['current_language']}.js", $GLOBALS['sugar_config']['js_lang_version']);
     $this->th->ss->assign('data', $this->data['data']);
     $this->data['pageData']['offsets']['lastOffsetOnPage'] = $this->data['pageData']['offsets']['current'] + count($this->data['data']);
     $this->th->ss->assign('pageData', $this->data['pageData']);
     $navStrings = array('next' => $GLOBALS['app_strings']['LNK_LIST_NEXT'], 'previous' => $GLOBALS['app_strings']['LNK_LIST_PREVIOUS'], 'end' => $GLOBALS['app_strings']['LNK_LIST_END'], 'start' => $GLOBALS['app_strings']['LNK_LIST_START'], 'of' => $GLOBALS['app_strings']['LBL_LIST_OF']);
     $this->th->ss->assign('navStrings', $navStrings);
     $associated_row_data = array();
     //C.L. - Bug 44324 - Override the NAME entry to not display salutation so that the data returned from the popup can be searched on correctly
     $searchNameOverride = !empty($this->seed) && $this->seed instanceof Person && (isset($this->data['data'][0]['FIRST_NAME']) && isset($this->data['data'][0]['LAST_NAME'])) ? true : false;
     global $locale;
     foreach ($this->data['data'] as $val) {
         $associated_row_data[$val['ID']] = $val;
         if ($searchNameOverride) {
             $associated_row_data[$val['ID']]['NAME'] = $locale->getLocaleFormattedName($val['FIRST_NAME'], $val['LAST_NAME']);
         }
     }
     $is_show_fullname = showFullName() ? 1 : 0;
     $json = getJSONobj();
     $this->th->ss->assign('jsLang', $jsLang);
     $this->th->ss->assign('lang', substr($GLOBALS['current_language'], 0, 2));
     $this->th->ss->assign('headerTpl', $this->headerTpl);
     $this->th->ss->assign('footerTpl', $this->footerTpl);
     $this->th->ss->assign('ASSOCIATED_JAVASCRIPT_DATA', 'var associated_javascript_data = ' . $json->encode($associated_row_data) . '; var is_show_fullname = ' . $is_show_fullname . ';');
     $this->th->ss->assign('module', $this->seed->module_dir);
     $request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data'];
     $this->th->ss->assign('request_data', $request_data);
     $this->th->ss->assign('fields', $this->fieldDefs);
     $this->th->ss->assign('formData', $this->formData);
     $this->th->ss->assign('APP', $GLOBALS['app_strings']);
     $this->th->ss->assign('MOD', $GLOBALS['mod_strings']);
     if (isset($this->_popupMeta['create']['createButton'])) {
         $this->_popupMeta['create']['createButton'] = translate($this->_popupMeta['create']['createButton']);
     }
     $this->th->ss->assign('popupMeta', $this->_popupMeta);
     $this->th->ss->assign('current_query', base64_encode(serialize($_REQUEST)));
     $this->th->ss->assign('customFields', $this->customFieldDefs);
     $this->th->ss->assign('numCols', NUM_COLS);
     $this->th->ss->assign('massUpdateData', $this->massUpdateData);
     $this->th->ss->assign('sugarVersion', $GLOBALS['sugar_version']);
     $this->th->ss->assign('should_process', $this->should_process);
     if ($this->_create) {
         $this->th->ss->assign('ADDFORM', $this->getQuickCreate());
         //$this->_getAddForm());
         $this->th->ss->assign('ADDFORMHEADER', $this->_getAddFormHeader());
         $this->th->ss->assign('object_name', $this->seed->object_name);
     }
     $this->th->ss->assign('LIST_HEADER', get_form_header($GLOBALS['mod_strings']['LBL_LIST_FORM_TITLE'], '', false));
     $this->th->ss->assign('SEARCH_FORM_HEADER', get_form_header($GLOBALS['mod_strings']['LBL_SEARCH_FORM_TITLE'], '', false));
     $str = $this->th->displayTemplate($this->seed->module_dir, $this->view, $this->tpl);
     return $str;
 }
Ejemplo n.º 5
0
 /**
  * @return void
  * @param unknown $data
  * @param unknown $xTemplateSection
  * @param unknown $html_varName
  * @desc INTERNAL FUNCTION handles the rows
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
  * Contributor(s): ______________________________________..
  */
 function processListRows($data, $xtemplateSection, $html_varName)
 {
     global $odd_bg;
     global $even_bg;
     global $hilite_bg;
     global $app_strings, $sugar_version, $sugar_config;
     global $currentModule;
     static $overlib_included;
     if (!$overlib_included) {
         echo '<script type="text/javascript" src="include/javascript/sugar_grp_overlib.js"></script>
             <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>';
         $overlib_included = true;
     }
     $this->xTemplate->assign('BG_HILITE', $hilite_bg);
     $this->xTemplate->assign('CHECKALL', "<img src='" . SugarThemeRegistry::current()->getImageURL('blank.gif') . "' width=\"1\" height=\"1\" alt=\"\" />");
     //$this->xTemplate->assign("BG_CLICK", $click_bg);
     $oddRow = true;
     $count = 0;
     reset($data);
     //GETTING OFFSET
     $offset = $this->getOffset($html_varName);
     $timeStamp = $this->unique_id();
     $_SESSION[$html_varName . "_FROM_LIST_VIEW"] = $timeStamp;
     $associated_row_data = array();
     //mail merge list
     $mergeList = array();
     $module = '';
     //todo what is this?  It is using an array as a boolean
     while (list($aVal, $aItem) = each($data)) {
         if (isset($this->data_array)) {
             $fields = $this->data_array;
         } else {
             $aItem->check_date_relationships_load();
             $fields = $aItem->get_list_view_data();
         }
         if (is_object($aItem)) {
             // cn: bug 5349
             //add item id to merge list, if the button is clicked
             $mergeList[] = $aItem->id;
             if (empty($module)) {
                 $module = $aItem->module_dir;
             }
         }
         //ADD OFFSET TO ARRAY
         $fields['OFFSET'] = $offset + $count + 1;
         $fields['STAMP'] = $timeStamp;
         if ($this->shouldProcess) {
             $prerow = '';
             if (!isset($this->data_array)) {
                 $prerow .= "<input onclick='sListView.check_item(this, document.MassUpdate)' type='checkbox' class='checkbox' name='mass[]' value='" . $fields['ID'] . "'>";
             }
             $this->xTemplate->assign('PREROW', $prerow);
             $this->xTemplate->assign('CHECKALL', "<input type='checkbox' class='checkbox' name='massall' id='massall' value='' onclick='sListView.check_all(document.MassUpdate, \"mass[]\", this.checked)'>");
         }
         if (!isset($this->data_array)) {
             $tag = $aItem->listviewACLHelper();
             $this->xTemplate->assign('TAG', $tag);
         }
         if ($oddRow) {
             $ROW_COLOR = 'oddListRow';
             $BG_COLOR = $odd_bg;
         } else {
             $ROW_COLOR = 'evenListRow';
             $BG_COLOR = $even_bg;
         }
         $oddRow = !$oddRow;
         $this->xTemplate->assign('ROW_COLOR', $ROW_COLOR);
         $this->xTemplate->assign('BG_COLOR', $BG_COLOR);
         if (isset($this->data_array)) {
             $this->xTemplate->assign('KEY', $aVal);
             $this->xTemplate->assign('VALUE', $aItem);
             $this->xTemplate->assign('INDEX', $count);
         } else {
             //AED -- some modules do not have their additionalDetails.php established. Add a check to ensure require_once does not fail
             // Bug #2786
             if ($this->_additionalDetails && $aItem->ACLAccess('DetailView') && (file_exists('modules/' . $aItem->module_dir . '/metadata/additionalDetails.php') || file_exists('custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php'))) {
                 $additionalDetailsFile = 'modules/' . $aItem->module_dir . '/metadata/additionalDetails.php';
                 if (file_exists('custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php')) {
                     $additionalDetailsFile = 'custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php';
                 }
                 require_once $additionalDetailsFile;
                 $ad_function = (empty($this->additionalDetailsFunction) ? 'additionalDetails' : $this->additionalDetailsFunction) . $aItem->object_name;
                 $results = $ad_function($fields);
                 $results['string'] = str_replace(array("&#039", "'"), '\\&#039', $results['string']);
                 // no xss!
                 if (trim($results['string']) == '') {
                     $results['string'] = $app_strings['LBL_NONE'];
                 }
                 $fields[$results['fieldToAddTo']] = $fields[$results['fieldToAddTo']] . '</a>';
             }
             //fixes bug for IE where empty list view rows causes IE to not display bottom border
             if (isset($fields['DESCRIPTION']) && empty($fields['DESCRIPTION'])) {
                 $fields['DESCRIPTION'] = "&nbsp;";
             }
             if (isset($fields['LIST_ORDER']) && empty($fields['LIST_ORDER'])) {
                 $fields['LIST_ORDER'] = "&nbsp;";
             }
             $this->xTemplate->assign($html_varName, $fields);
             $aItem->setupCustomFields($aItem->module_dir);
             $aItem->custom_fields->populateAllXTPL($this->xTemplate, 'detail', $html_varName, $fields);
         }
         if (!isset($this->data_array) && $aItem->ACLAccess('DetailView')) {
             $count++;
         }
         if (isset($this->data_array)) {
             $count++;
         }
         if (!isset($this->data_array)) {
             $aItem->list_view_parse_additional_sections($this->xTemplate, $xtemplateSection);
             if ($this->xTemplate->exists($xtemplateSection . '.row.pro')) {
                 $this->xTemplate->parse($xtemplateSection . '.row.pro');
             }
         }
         $this->xTemplate->parse($xtemplateSection . '.row');
         if (isset($fields['ID'])) {
             $associated_row_data[$fields['ID']] = $fields;
             // Bug 38908: cleanup data for JS to avoid having &nbsp; shuffled around
             foreach ($fields as $key => $value) {
                 if ($value == '&nbsp;') {
                     $associated_row_data[$fields['ID']][$key] = '';
                 }
             }
         }
     }
     $_SESSION['MAILMERGE_RECORDS'] = $mergeList;
     $_SESSION['MAILMERGE_MODULE_FROM_LISTVIEW'] = $module;
     if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
         $_SESSION['MAILMERGE_MODULE'] = $module;
     }
     if ($this->process_for_popups) {
         $json = getJSONobj();
         $is_show_fullname = showFullName() ? 1 : 0;
         $associated_javascript_data = '<script type="text/javascript">' . "\n" . 'var associated_javascript_data = ' . $json->encode($associated_row_data) . ";\n" . 'var is_show_fullname = ' . $is_show_fullname . ";\n" . '</script>';
         $this->xTemplate->assign('ASSOCIATED_JAVASCRIPT_DATA', $associated_javascript_data);
     }
     $this->xTemplate->parse($xtemplateSection);
 }
Ejemplo n.º 6
0
/* Функции без параметри / аргументи
		======================================*/
function createDinamicHtmlTags()
{
    // функция за изграждане на динамично съдържание.
    echo "<header>" . "<h1>" . "Заглавие" . "</h1>" . "</header>";
}
createDinamicHtmlTags();
// извикване на функция/изпълнение.
/* Функции с параметри / аргументи
		======================================*/
function showFullName($firstname, $lastName)
{
    echo "My full name is: " . $firstname . " " . $lastName;
}
showFullName("Svetoslav", "Toshkin");
/* Капсолиране на имената на променливите като ги дефинираме в тялото на функцията
		===================================================================================*/
function fooArguments()
{
    $a = 5;
    $b = 10;
    $result = $a + $b;
    echo $result;
}
//echo $result; ако се опитаме да изведем $result ще получим грешка undefinded variable / недефинирана променлива.
// Единствения начин да достъпим променливата е като извикаме функцията.
echo fooArguments();
/* Оператор return
		======================================*/
function fooReturn($myCar, $myByke)
Ejemplo n.º 7
0
/**
 * get_user_array
 *
 * This is a helper function to return an Array of users depending on the parameters passed into the function.
 * This function uses the get_register_value function by default to use a caching layer where supported.
 * This function has been updated return the array sorted by user preference of name display (bug 62712)
 *
 * @param bool $add_blank Boolean value to add a blank entry to the array results, true by default
 * @param string $status String value indicating the status to filter users by, "Active" by default
 * @param string $user_id String value to specify a particular user id value (searches the id column of users table), blank by default
 * @param bool $use_real_name Boolean value indicating whether or not results should include the full name or just user_name, false by default
 * @param String $user_name_filter String value indicating the user_name filter (searches the user_name column of users table) to optionally search with, blank by default
 * @param string $portal_filter String query filter for portal users (defaults to searching non-portal users), change to blank if you wish to search for all users including portal users
 * @param bool $from_cache Boolean value indicating whether or not to use the get_register_value function for caching, true by default
 * @return array Array of users matching the filter criteria that may be from cache (if similar search was previously run)
 */
function get_user_array($add_blank = true, $status = "Active", $user_id = '', $use_real_name = false, $user_name_filter = '', $portal_filter = ' AND portal_only=0 ', $from_cache = true)
{
    global $locale, $sugar_config, $current_user;
    if (empty($locale)) {
        $locale = new Localization();
    }
    if ($from_cache) {
        $key_name = $add_blank . $status . $user_id . $use_real_name . $user_name_filter . $portal_filter;
        $user_array = get_register_value('user_array', $key_name);
    }
    if (empty($user_array)) {
        $db = DBManagerFactory::getInstance();
        $temp_result = array();
        // Including deleted users for now.
        if (empty($status)) {
            $query = "SELECT id, first_name, last_name, user_name from users WHERE 1=1" . $portal_filter;
        } else {
            $query = "SELECT id, first_name, last_name, user_name from users WHERE status='{$status}'" . $portal_filter;
        }
        /* BEGIN - SECURITY GROUPS */
        global $current_user, $sugar_config;
        if (!is_admin($current_user) && isset($sugar_config['securitysuite_filter_user_list']) && $sugar_config['securitysuite_filter_user_list'] == true && (empty($_REQUEST['module']) || $_REQUEST['module'] != 'Home') && (empty($_REQUEST['action']) || $_REQUEST['action'] != 'DynamicAction')) {
            require_once 'modules/SecurityGroups/SecurityGroup.php';
            global $current_user;
            $group_where = SecurityGroup::getGroupUsersWhere($current_user->id);
            $query .= " AND (" . $group_where . ") ";
        }
        /* END - SECURITY GROUPS */
        if (!empty($user_name_filter)) {
            $user_name_filter = $db->quote($user_name_filter);
            $query .= " AND user_name LIKE '{$user_name_filter}%' ";
        }
        if (!empty($user_id)) {
            $query .= " OR id='{$user_id}'";
        }
        //get the user preference for name formatting, to be used in order by
        $order_by_string = ' user_name ASC ';
        if (!empty($current_user) && !empty($current_user->id)) {
            $formatString = $current_user->getPreference('default_locale_name_format');
            //create the order by string based on position of first and last name in format string
            $order_by_string = ' user_name ASC ';
            $firstNamePos = strpos($formatString, 'f');
            $lastNamePos = strpos($formatString, 'l');
            if ($firstNamePos !== false || $lastNamePos !== false) {
                //its possible for first name to be skipped, check for this
                if ($firstNamePos === false) {
                    $order_by_string = 'last_name ASC';
                } else {
                    $order_by_string = $lastNamePos < $firstNamePos ? "last_name, first_name ASC" : "first_name, last_name ASC";
                }
            }
        }
        $query = $query . ' ORDER BY ' . $order_by_string;
        $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
            $temp_result[''] = '';
        }
        // Get the id and the name.
        while ($row = $db->fetchByAssoc($result)) {
            if ($use_real_name == true || showFullName()) {
                if (isset($row['last_name'])) {
                    // cn: we will ALWAYS have both first_name and last_name (empty value if blank in db)
                    $temp_result[$row['id']] = $locale->getLocaleFormattedName($row['first_name'], $row['last_name']);
                } else {
                    $temp_result[$row['id']] = $row['user_name'];
                }
            } else {
                $temp_result[$row['id']] = $row['user_name'];
            }
        }
        $user_array = $temp_result;
        if ($from_cache) {
            set_register_value('user_array', $key_name, $temp_result);
        }
    }
    return $user_array;
}
Ejemplo n.º 8
0
 function display($end = true)
 {
     global $app_strings;
     if (!is_file($GLOBALS['sugar_config']['cache_dir'] . 'jsLanguage/' . $GLOBALS['current_language'] . '.js')) {
         require_once 'include/language/jsLanguage.php';
         jsLanguage::createAppStringsCache($GLOBALS['current_language']);
     }
     $jsLang = '<script type="text/javascript" src="' . $GLOBALS['sugar_config']['cache_dir'] . 'jsLanguage/' . $GLOBALS['current_language'] . '.js?s=' . $GLOBALS['sugar_version'] . '&c=' . $GLOBALS['sugar_config']['js_custom_version'] . '&j=' . $GLOBALS['sugar_config']['js_lang_version'] . '"></script>';
     $this->th->ss->assign('data', $this->data['data']);
     $this->data['pageData']['offsets']['lastOffsetOnPage'] = $this->data['pageData']['offsets']['current'] + count($this->data['data']);
     $this->th->ss->assign('pageData', $this->data['pageData']);
     $navStrings = array('next' => $GLOBALS['app_strings']['LNK_LIST_NEXT'], 'previous' => $GLOBALS['app_strings']['LNK_LIST_PREVIOUS'], 'end' => $GLOBALS['app_strings']['LNK_LIST_END'], 'start' => $GLOBALS['app_strings']['LNK_LIST_START'], 'of' => $GLOBALS['app_strings']['LBL_LIST_OF']);
     $this->th->ss->assign('navStrings', $navStrings);
     $associated_row_data = array();
     foreach ($this->data['data'] as $val) {
         $associated_row_data[$val['ID']] = $val;
     }
     $is_show_fullname = showFullName() ? 1 : 0;
     $json = getJSONobj();
     $this->th->ss->assign('jsLang', $jsLang);
     $this->th->ss->assign('lang', substr($GLOBALS['current_language'], 0, 2));
     $this->th->ss->assign('headerTpl', 'include/Popups/tpls/header.tpl');
     $this->th->ss->assign('footerTpl', 'include/Popups/tpls/footer.tpl');
     $this->th->ss->assign('ASSOCIATED_JAVASCRIPT_DATA', 'var associated_javascript_data = ' . $json->encode($associated_row_data) . '; var is_show_fullname = ' . $is_show_fullname . ';');
     $this->th->ss->assign('module', $this->seed->module_dir);
     $request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data'];
     $this->th->ss->assign('request_data', $request_data);
     $this->th->ss->assign('fields', $this->fieldDefs);
     $this->th->ss->assign('formData', $this->formData);
     $this->th->ss->assign('APP', $GLOBALS['app_strings']);
     $this->th->ss->assign('MOD', $GLOBALS['mod_strings']);
     $this->th->ss->assign('popupMeta', $this->_popupMeta);
     $this->th->ss->assign('current_query', base64_encode(serialize($_REQUEST)));
     $this->th->ss->assign('customFields', $this->customFieldDefs);
     $this->th->ss->assign('numCols', NUM_COLS);
     $this->th->ss->assign('massUpdateData', $this->massUpdateData);
     $this->th->ss->assign('jsCustomVersion', $GLOBALS['sugar_config']['js_custom_version']);
     $this->th->ss->assign('sugarVersion', $GLOBALS['sugar_version']);
     $this->th->ss->assign('should_process', $this->should_process);
     if ($this->_create) {
         $this->th->ss->assign('ADDFORM', $this->getQuickCreate());
         //$this->_getAddForm());
         $this->th->ss->assign('ADDFORMHEADER', $this->_getAddFormHeader());
         $this->th->ss->assign('object_name', $this->seed->object_name);
     }
     $this->th->ss->assign('LIST_HEADER', get_form_header($GLOBALS['mod_strings']['LBL_LIST_FORM_TITLE'], '', false));
     $this->th->ss->assign('SEARCH_FORM_HEADER', get_form_header($GLOBALS['mod_strings']['LBL_SEARCH_FORM_TITLE'], '', false));
     $str = $this->th->displayTemplate($this->seed->module_dir, $this->view, $this->tpl);
     return $str;
 }
 /**
  * Returns the list of users, faster than using query method for Users module
  * 
  * @param array $args arguments used to construct query, see query() for example
  * 
  * @return array list of users returned
  */
 function get_user_array($args)
 {
     global $json;
     $json = getJSONobj();
     $response = array();
     if (showFullName()) {
         // utils.php, if system is configured to show full name
         $user_array = getUserArrayFromFullName($args['conditions'][0]['value'], true);
     } else {
         $user_array = get_user_array(false, "Active", '', false, $args['conditions'][0]['value'], ' AND portal_only=0 ', false);
     }
     $response['totalCount'] = count($user_array);
     $response['fields'] = array();
     $i = 0;
     foreach ($user_array as $id => $name) {
         array_push($response['fields'], array('id' => (string) $id, 'user_name' => $name, 'module' => 'Users'));
         $i++;
     }
     return $json->encodeReal($response);
 }
Ejemplo n.º 10
0
/**
 * retrieves Users matching passed criteria
 */
function json_get_user_array($request_id, &$params)
{
    global $json;
    $args = $params[0];
    //decode condition parameter values..
    if (is_array($args['conditions'])) {
        foreach ($args['conditions'] as $key => $condition) {
            if (!empty($condition['value'])) {
                $args['conditions'][$key]['value'] = $json->decode($condition['value']);
            }
        }
    }
    $response = array();
    $response['id'] = $request_id;
    $response['result'] = array();
    $response['result']['list'] = array();
    if (showFullName()) {
        $user_array = getUserArrayFromFullName($args['conditions'][0]['value']);
    } else {
        $user_array = get_user_array(false, "Active", $focus->assigned_user_id, false, $args['conditions'][0]['value']);
    }
    foreach ($user_array as $id => $name) {
        array_push($response['result']['list'], array('fields' => array('id' => $id, 'user_name' => $name), 'module' => 'Users'));
    }
    print $json->encode($response);
    exit;
}
Ejemplo n.º 11
0
    $sugar_smarty->assign("mail_smtpdisplay", $mail_smtpdisplay);
    $sugar_smarty->assign("mail_smtpserver", $mail_smtpserver);
    $sugar_smarty->assign("mail_smtpuser", $mail_smtpuser);
    $sugar_smarty->assign("mail_smtppass", "");
    $sugar_smarty->assign("mail_haspass", empty($systemOutboundEmail->mail_smtppass) ? 0 : 1);
    $sugar_smarty->assign("mail_smtpauth_req", $mail_smtpauth_req);
    $sugar_smarty->assign('MAIL_SMTPPORT', $mail_smtpport);
    $sugar_smarty->assign('MAIL_SMTPSSL', $mail_smtpssl);
}
$sugar_smarty->assign('HIDE_IF_CAN_USE_DEFAULT_OUTBOUND', $hide_if_can_use_default);
$reports_to_change_button_html = '';
if ($is_current_admin) {
    //////////////////////////////////////
    ///
    /// SETUP USER POPUP
    $reportsDisplayName = showFullName() ? 'name' : 'user_name';
    $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array('id' => 'reports_to_id', "{$reportsDisplayName}" => 'reports_to_name'));
    $json = getJSONobj();
    $encoded_popup_request_data = $json->encode($popup_request_data);
    $sugar_smarty->assign('encoded_popup_request_data', $encoded_popup_request_data);
    //
    ///////////////////////////////////////
    $reports_to_change_button_html = '<input type="button"' . " title=\"{$app_strings['LBL_SELECT_BUTTON_TITLE']}\"" . " accesskey=\"{$app_strings['LBL_SELECT_BUTTON_KEY']}\"" . " value=\"{$app_strings['LBL_SELECT_BUTTON_LABEL']}\"" . ' tabindex="5" class="button" name="btn1"' . " onclick='open_popup(\"Users\", 600, 400, \"\", true, false, {$encoded_popup_request_data});'" . "' />";
} else {
    $sugar_smarty->assign('IS_ADMIN_DISABLED', 'disabled="disabled"');
}
$sugar_smarty->assign('REPORTS_TO_CHANGE_BUTTON', $reports_to_change_button_html);
/* Module Tab Chooser */
require_once 'include/templates/TemplateGroupChooser.php';
require_once 'modules/MySettings/TabController.php';
$chooser = new TemplateGroupChooser();
 public function display()
 {
     global $current_user, $app_strings, $sugar_config, $currentModule, $sugar_version;
     //load license validation config
     require_once 'modules/' . $currentModule . '/license/config.php';
     echo $this->getModuleTitle();
     $GLOBALS['log']->info("License Configuration");
     //$this->ss->assign("MOD", $mod_strings);
     //$this->ss->assign("APP", $app_strings);
     //todo: redirect appropriately
     $this->ss->assign("RETURN_MODULE", "Administration");
     $this->ss->assign("RETURN_ACTION", "index");
     $this->ss->assign("MODULE", $currentModule);
     $license_strings = ViewLicense::loadLicenseStrings();
     $this->ss->assign("LICENSE", $license_strings);
     if (!empty($sugar_config['outfitters_licenses']) && !empty($sugar_config['outfitters_licenses'][$outfitters_config['shortname']])) {
         $this->ss->assign("license_key", $sugar_config['outfitters_licenses'][$outfitters_config['shortname']]);
     }
     $this->ss->assign("continue_url", $outfitters_config['continue_url']);
     $this->ss->assign("file_path", getJSPath("modules/" . $currentModule . "/license/lib/jquery-1.7.1.min.js"));
     if (preg_match("/^6.*/", $sugar_version)) {
         $this->ss->assign("IS_SUGAR_6", true);
     } else {
         $this->ss->assign("IS_SUGAR_6", false);
     }
     if (!function_exists('curl_init')) {
         global $current_language;
         $admin_mod_strings = return_module_language($current_language, 'Administration');
         $curl_not_enabled = $admin_mod_strings['ERR_ENABLE_CURL'];
         $this->ss->assign("CURL_NOT_ENABLED", $curl_not_enabled);
     }
     if (isset($outfitters_config['validate_users']) && $outfitters_config['validate_users'] == true) {
         $this->ss->assign("validate_users", true);
         //get user count for all active, non-portal, non-group users
         $active_users = get_user_array(FALSE, 'Active', '', false, '', ' AND portal_only=0 AND is_group=0');
         $this->ss->assign("current_users", count($active_users));
         $this->ss->assign("user_count_param", "user_count: '" . count($active_users) . "'");
     } else {
         $this->ss->assign("validate_users", false);
         $this->ss->assign("current_users", '');
         $this->ss->assign("user_count_param", '');
     }
     if (isset($outfitters_config['manage_licensed_users']) && $outfitters_config['manage_licensed_users'] == true) {
         $this->ss->assign("manage_licensed_users", true);
         $this->ss->assign("validation_required", true);
         //check if here is a key already...if so then validate to ensure latest licensed user count is pulled in
         require_once 'modules/Administration/Administration.php';
         $administration = new Administration();
         $administration->retrieveSettings();
         $last_validation = $administration->settings['SugarOutfitters_' . $outfitters_config['shortname']];
         $trimmed_last = trim($last_validation);
         //only run a license check if one has been done in the past
         if (!empty($trimmed_last)) {
             //if new then don't do
             require_once 'modules/' . $currentModule . '/license/OutfittersLicense.php';
             $validated = OutfittersLicense::doValidate($currentModule);
             $store = array('last_ran' => time(), 'last_result' => $validated);
             $serialized = base64_encode(serialize($store));
             $administration->saveSetting('SugarOutfitters', $outfitters_config['shortname'], $serialized);
             $licensed_users = 0;
             //check last validation
             if (!empty($validated['result'])) {
                 $licensed_users = $validated['result']['licensed_user_count'];
                 if (!is_numeric($licensed_users)) {
                     $licensed_users = 0;
                 }
                 $this->ss->assign("validation_required", false);
             }
         }
         $this->ss->assign("licensed_users", $licensed_users);
         require_once 'include/templates/TemplateGroupChooser.php';
         $chooser = new TemplateGroupChooser();
         $chooser->args['id'] = 'edit_licensed_users';
         $chooser->args['values_array'] = array();
         $chooser->args['values_array'][0] = get_user_array(false, 'Active', '', false, '', " AND is_group=0");
         $chooser->args['values_array'][1] = array();
         $used_licenses = 0;
         global $db, $locale;
         $result = $db->query("SELECT users.id, users.user_name, users.first_name, users.last_name FROM so_users INNER JOIN users ON so_users.user_id = users.id WHERE shortname = '" . $db->quote($outfitters_config['shortname']) . "'", false);
         while ($row = $db->fetchByAssoc($result)) {
             $used_licenses++;
             $display_name = $row['user_name'];
             if (showFullName()) {
                 if (isset($row['last_name'])) {
                     // cn: we will ALWAYS have both first_name and last_name (empty value if blank in db)
                     $display_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name']);
                 }
             }
             $chooser->args['values_array'][1][$row['id']] = $display_name;
             unset($chooser->args['values_array'][0][$row['id']]);
         }
         $this->ss->assign("available_licensed_users", $licensed_users - $used_licenses);
         $chooser->args['left_name'] = 'unlicensed_users';
         $chooser->args['right_name'] = 'licensed_users';
         $chooser->args['left_label'] = $license_strings['LBL_UNLICENSED_USER_LIST'];
         $chooser->args['right_label'] = $license_strings['LBL_LICENSED_USER_LIST'];
         $chooser->args['title'] = '';
         $this->ss->assign('USER_CHOOSER', $chooser->display());
         $this->ss->assign('CHOOSER_SCRIPT', 'set_chooser();');
         $this->ss->assign('CHOOSE_WHICH', '');
     } else {
         $this->ss->assign("manage_licensed_users", false);
     }
     $this->ss->display('modules/' . $currentModule . '/license/tpls/license.tpl');
 }
Ejemplo n.º 13
0
/**
 * get_user_array
 *
 * This is a helper function to return an Array of users depending on the parameters passed into the function.
 * This function uses the get_register_value function by default to use a caching layer where supported.
 *
 * @param bool $add_blank Boolean value to add a blank entry to the array results, true by default
 * @param string $status String value indicating the status to filter users by, "Active" by default
 * @param string $user_id String value to specify a particular user id value (searches the id column of users table), blank by default
 * @param bool $use_real_name Boolean value indicating whether or not results should include the full name or just user_name, false by default
 * @param String $user_name_filter String value indicating the user_name filter (searches the user_name column of users table) to optionally search with, blank by default
 * @param string $portal_filter String query filter for portal users (defaults to searching non-portal users), change to blank if you wish to search for all users including portal users
 * @param bool $from_cache Boolean value indicating whether or not to use the get_register_value function for caching, true by default
 * @return array Array of users matching the filter criteria that may be from cache (if similar search was previously run)
 */
function get_user_array($add_blank = true, $status = "Active", $user_id = '', $use_real_name = false, $user_name_filter = '', $portal_filter = ' AND portal_only=0 ', $from_cache = true)
{
    global $locale, $current_user;
    if (empty($locale)) {
        $locale = Localization::getObject();
    }
    $db = DBManagerFactory::getInstance();
    // Pre-build query for use as cache key
    // Including deleted users for now.
    if (empty($status)) {
        $query = "SELECT id, first_name, last_name, user_name FROM users ";
        $where = "1=1" . $portal_filter;
    } else {
        $query = "SELECT id, first_name, last_name, user_name FROM users ";
        $where = "status='{$status}'" . $portal_filter;
    }
    $user = BeanFactory::getBean('Users');
    $user->addVisibilityFrom($query);
    $query .= " WHERE {$where} ";
    $user->addVisibilityWhere($query);
    if (!empty($user_name_filter)) {
        $user_name_filter = $db->quote($user_name_filter);
        $query .= " AND user_name LIKE '{$user_name_filter}%' ";
    }
    if (!empty($user_id)) {
        $query .= " OR id='{$user_id}'";
    }
    //get the user preference for name formatting, to be used in order by
    $order_by_string = ' user_name ASC ';
    if (!empty($current_user) && !empty($current_user->id)) {
        $formatString = $current_user->getPreference('default_locale_name_format');
        //create the order by string based on position of first and last name in format string
        $firstNamePos = strpos($formatString, 'f');
        $lastNamePos = strpos($formatString, 'l');
        if ($firstNamePos !== false || $lastNamePos !== false) {
            //its possible for first name to be skipped, check for this
            if ($firstNamePos === false) {
                $order_by_string = 'last_name ASC';
            } else {
                $order_by_string = $lastNamePos < $firstNamePos ? "last_name, first_name ASC" : "first_name, last_name ASC";
            }
        }
    }
    $query = $query . ' ORDER BY ' . $order_by_string;
    if ($from_cache) {
        $key_name = $query . $status . $user_id . $use_real_name . $user_name_filter . $portal_filter;
        $key_name = md5($key_name);
        $user_array = get_register_value('user_array', $key_name);
    }
    if (empty($user_array)) {
        $temp_result = array();
        $GLOBALS['log']->debug("get_user_array query: {$query}");
        $result = $db->query($query, true, "Error filling in user array: ");
        // Get the id and the name.
        while ($row = $db->fetchByAssoc($result)) {
            if ($use_real_name == true || showFullName()) {
                if (isset($row['last_name'])) {
                    // cn: we will ALWAYS have both first_name and last_name (empty value if blank in db)
                    $temp_result[$row['id']] = $locale->formatName('Users', $row);
                } else {
                    $temp_result[$row['id']] = $row['user_name'];
                }
            } else {
                $temp_result[$row['id']] = $row['user_name'];
            }
        }
        $user_array = $temp_result;
        if ($from_cache) {
            set_register_value('user_array', $key_name, $temp_result);
        }
    }
    if ($add_blank) {
        $user_array[''] = '';
    }
    return $user_array;
}
Ejemplo n.º 14
0
 /**
  * Displays the header on section of the page; basically everything before the content
  * @deprecated since 7.0, will be removed from 7.2.
  */
 public function displayHeader($retModTabs = false)
 {
     global $theme;
     global $max_tabs;
     global $app_strings;
     global $current_user;
     global $app_list_strings;
     global $mod_strings;
     global $current_language;
     $GLOBALS['app']->headerDisplayed = true;
     $themeObject = SugarThemeRegistry::current();
     $theme = $themeObject->__toString();
     $ss = new Sugar_Smarty();
     $ss->assign("APP", $app_strings);
     $ss->assign("THEME", $theme);
     $ss->assign("THEME_IE6COMPAT", $themeObject->ie6compat ? 'true' : 'false');
     $ss->assign("MODULE_NAME", $this->module);
     $ss->assign("langHeader", get_language_header());
     $ss->assign('use_table_container', isset($this->options['use_table_container']) ? $this->options['use_table_container'] : false);
     // set ab testing if exists
     $testing = isset($_REQUEST["testing"]) ? $_REQUEST['testing'] : "a";
     $ss->assign("ABTESTING", $testing);
     // get browser title
     $ss->assign("SYSTEM_NAME", $this->getBrowserTitle());
     // get css
     $ss->assign("SUGAR_CSS", $this->getThemeCss());
     // get javascript
     ob_start();
     $this->renderJavascript();
     $ss->assign("SUGAR_JS", ob_get_contents() . $themeObject->getJS());
     ob_end_clean();
     $favicon = $this->getFavicon();
     $ss->assign('FAVICON_URL', $favicon['url']);
     // build the shortcut menu
     $shortcut_menu = array();
     foreach ($this->getMenu() as $key => $menu_item) {
         $shortcut_menu[$key] = array("URL" => $menu_item[0], "LABEL" => $menu_item[1], "MODULE_NAME" => $menu_item[2], "IMAGE" => $themeObject->getImage($menu_item[2], "border='0' align='absmiddle'", null, null, '.gif', $menu_item[1]));
     }
     $ss->assign("SHORTCUT_MENU", $shortcut_menu);
     // handle rtl text direction
     if (isset($_REQUEST['RTL']) && $_REQUEST['RTL'] == 'RTL') {
         $_SESSION['RTL'] = true;
     }
     if (isset($_REQUEST['LTR']) && $_REQUEST['LTR'] == 'LTR') {
         unset($_SESSION['RTL']);
     }
     if (isset($_SESSION['RTL']) && $_SESSION['RTL']) {
         $ss->assign("DIR", 'dir="RTL"');
     }
     // handle resizing of the company logo correctly on the fly
     $companyLogoURL = $themeObject->getImageURL('company_logo.png', true, true);
     $companyLogoURL_arr = explode('?', $companyLogoURL);
     $companyLogoURL = $companyLogoURL_arr[0];
     $company_logo_attributes = sugar_cache_retrieve('company_logo_attributes');
     if (!empty($company_logo_attributes)) {
         $ss->assign("COMPANY_LOGO_MD5", $company_logo_attributes[0]);
         $ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes[1]);
         $ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes[2]);
     } else {
         // Always need to md5 the file
         $ss->assign("COMPANY_LOGO_MD5", md5_file($companyLogoURL));
         list($width, $height) = getimagesize($companyLogoURL);
         if ($width > 212 || $height > 40) {
             $resizePctWidth = ($width - 212) / 212;
             $resizePctHeight = ($height - 40) / 40;
             if ($resizePctWidth > $resizePctHeight) {
                 $resizeAmount = $width / 212;
             } else {
                 $resizeAmount = $height / 40;
             }
             $ss->assign("COMPANY_LOGO_WIDTH", round($width * (1 / $resizeAmount)));
             $ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1 / $resizeAmount)));
         } else {
             $ss->assign("COMPANY_LOGO_WIDTH", $width);
             $ss->assign("COMPANY_LOGO_HEIGHT", $height);
         }
         // Let's cache the results
         sugar_cache_put('company_logo_attributes', array($ss->get_template_vars("COMPANY_LOGO_MD5"), $ss->get_template_vars("COMPANY_LOGO_WIDTH"), $ss->get_template_vars("COMPANY_LOGO_HEIGHT")));
     }
     $ss->assign("COMPANY_LOGO_URL", getJSPath($companyLogoURL) . "&logo_md5=" . $ss->get_template_vars("COMPANY_LOGO_MD5"));
     // get the global links (Currently not used, since we hardcoded the metadata for profileactions
     // and upon upgrade, we convert global link in metadataconverter to create custom metadata
     // for profileactions, Thus, code below can be removed in the future)
     $gcls = array();
     $global_control_links = array();
     require "include/globalControlLinks.php";
     foreach ($global_control_links as $key => $value) {
         if ($key == 'users') {
             //represents logout link.
             $ss->assign("LOGOUT_LINK", $value['linkinfo'][key($value['linkinfo'])]);
             $ss->assign("LOGOUT_LABEL", key($value['linkinfo']));
             //key value for first element.
             continue;
         }
         foreach ($value as $linkattribute => $attributevalue) {
             // get the main link info
             if ($linkattribute == 'linkinfo') {
                 $gcls[$key] = array("LABEL" => key($attributevalue), "URL" => current($attributevalue), "SUBMENU" => array());
                 if (substr($gcls[$key]["URL"], 0, 11) == "javascript:") {
                     $gcls[$key]["ONCLICK"] = substr($gcls[$key]["URL"], 11);
                     $gcls[$key]["URL"] = "javascript:void(0)";
                 }
             }
             // and now the sublinks
             if ($linkattribute == 'submenu' && is_array($attributevalue)) {
                 foreach ($attributevalue as $submenulinkkey => $submenulinkinfo) {
                     $gcls[$key]['SUBMENU'][$submenulinkkey] = array("LABEL" => key($submenulinkinfo), "URL" => current($submenulinkinfo));
                 }
                 if (substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 0, 11) == "javascript:") {
                     $gcls[$key]['SUBMENU'][$submenulinkkey]["ONCLICK"] = substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 11);
                     $gcls[$key]['SUBMENU'][$submenulinkkey]["URL"] = "javascript:void(0)";
                 }
             }
         }
     }
     $ss->assign("GCLS", $gcls);
     $ss->assign("SEARCH", isset($_REQUEST['query_string']) ? $_REQUEST['query_string'] : '');
     if ($this->action == "EditView" || $this->action == "Login") {
         $ss->assign("ONLOAD", 'onload="set_focus()"');
     }
     $ss->assign("AUTHENTICATED", isset($_SESSION["authenticated_user_id"]));
     $ss->assign("ISPRINT", isset($_REQUEST['print']));
     //this will be used by header.tpl to hide the megamenu bar when its 'print' view
     // get other things needed for page style popup
     if (isset($_SESSION["authenticated_user_id"])) {
         // get the current user name and id
         $ss->assign("CURRENT_USER", $current_user->full_name == '' || !showFullName() ? $current_user->user_name : $current_user->full_name);
         $ss->assign("CURRENT_USER_ID", $current_user->id);
         // get the last viewed records
         $tracker = BeanFactory::getBean('Trackers');
         $history = $tracker->get_recently_viewed($current_user->id);
         $ss->assign("recentRecords", $this->processRecentRecords($history));
     }
     $bakModStrings = $mod_strings;
     $imageURL = SugarThemeRegistry::current()->getImageURL("dashboard.png");
     $homeImage = "<img src='{$imageURL}'>";
     $ss->assign("homeImage", $homeImage);
     global $mod_strings;
     $mod_strings = $bakModStrings;
     /******************DC MENU*********************/
     // DEPRECATED since 7.0, will be removed from 7.2
     //		if(!empty($current_user->id) && !$this->_getOption('view_print')){
     //			require_once('include/DashletContainer/DCFactory.php');
     //            require_once('include/SugarSearchEngine/SugarSearchEngineFactory.php');
     //			$dcm = DCFactory::getContainer(null, 'DCMenu');
     //			$notifData = $dcm->getNotifications();
     //			$dcjs = getVersionedScript('include/DashletContainer/Containers/DCMenu.js');
     //			$ss->assign('NOTIFCLASS', $notifData['class']);
     //			$ss->assign('NOTIFCODE', $notifData['code']);
     //			$ss->assign('NOTIFICON', $notifData['icon']);
     //			$ss->assign('DCSCRIPT', $dcm->getScript());
     //			$ss->assign('ICONSEARCH', $dcm->getSearchIcon());
     //			$ss->assign('DCACTIONS',$dcm->getMenus());
     //			$ss->assign('PICTURE', $current_user->picture);
     //            $ftsAutocompleteEnable = TRUE;
     //            $searchEngine = SugarSearchEngineFactory::getInstance();
     //            if( ($searchEngine instanceOf SugarSearchEngine) || (isset($GLOBALS['sugar_config']['full_text_engine'])
     //                && isset($GLOBALS['sugar_config']['full_text_engine']['disable_autocomplete']) && $GLOBALS['sugar_config']['full_text_engine']['disable_autocomplete'] )
     //                )
     //                    $ftsAutocompleteEnable = FALSE;
     //
     //            if (SugarSearchEngineAbstractBase::isSearchEngineDown()) {
     //                $ftsAutocompleteEnable = false;
     //            }
     //            $ss->assign('FTS_AUTOCOMPLETE_ENABLE', $ftsAutocompleteEnable);
     //			$ss->assign('AJAX', isset($_REQUEST['ajax_load'])?$_REQUEST['ajax_load']:"0");
     //			$ss->assign('ACTION', isset($_REQUEST['action'])?$_REQUEST['action']:"");
     //			$ss->assign('FULL', isset($_REQUEST['full'])?$_REQUEST['full']:"false");
     //			if(is_admin($GLOBALS['current_user'])){
     //				$ss->assign('ISADMIN', true);
     //			} else {
     //				$ss->assign('ISADMIN', false);
     //			}
     //			$ss->assign('SUGAR_DCJS', $dcjs);
     //			//$ss->assign('SUGAR_DCMENU', $data['html']);
     //		}
     /******************END DC MENU*********************/
     $headerTpl = $themeObject->getTemplate('header.tpl');
     if (inDeveloperMode()) {
         $ss->clear_compiled_tpl($headerTpl);
     }
     $ss->display($headerTpl);
     $this->includeClassicFile('modules/Administration/DisplayWarnings.php');
     $errorMessages = SugarApplication::getErrorMessages();
     if (!empty($errorMessages)) {
         foreach ($errorMessages as $error_message) {
             echo '<p class="error">' . $error_message . '</p>';
         }
     }
 }
Ejemplo n.º 15
0
 /**
  * Returns user array
  *
  * @param string $condition
  * @return array
  */
 protected function getUserArray($condition)
 {
     return showFullName() ? getUserArrayFromFullName($condition, true) : get_user_array(false, 'Active', '', false, $condition, ' AND portal_only=0 ', false);
 }
Ejemplo n.º 16
0
 /**
  * @return void
  * @param unknown $data
  * @param unknown $xTemplateSection
  * @param unknown $html_varName
  * @desc INTERNAL FUNCTION handles the rows
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
  * Contributor(s): ______________________________________..
  */
 function processListRows($data, $xtemplateSection, $html_varName)
 {
     global $odd_bg;
     global $even_bg;
     global $hilite_bg;
     global $app_strings, $sugar_version, $sugar_config;
     global $currentModule;
     $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);
     $oddRow = true;
     $count = 0;
     reset($data);
     //GETTING OFFSET
     $offset = $this->getOffset($html_varName);
     $timeStamp = $this->unique_id();
     $_SESSION[$html_varName . "_FROM_LIST_VIEW"] = $timeStamp;
     $associated_row_data = array();
     //mail merge list
     $mergeList = array();
     $module = '';
     //todo what is this?  It is using an array as a boolean
     while (list($aVal, $aItem) = each($data)) {
         if (isset($this->data_array)) {
             $fields = $this->data_array;
         } else {
             $aItem->check_date_relationships_load();
             $fields = $aItem->get_list_view_data();
         }
         if (is_object($aItem)) {
             // cn: bug 5349
             //add item id to merge list, if the button is clicked
             $mergeList[] = $aItem->id;
             if (empty($module)) {
                 $module = $aItem->module_dir;
             }
         }
         //ADD OFFSET TO ARRAY
         $fields['OFFSET'] = $offset + $count + 1;
         $fields['STAMP'] = $timeStamp;
         if ($this->shouldProcess) {
             $prerow = '';
             if (!isset($this->data_array)) {
                 $prerow .= "<input onclick='sListView.check_item(this, document.MassUpdate)' type='checkbox' class='checkbox' name='mass[]' value='" . $fields['ID'] . "'>";
             }
             $this->xTemplate->assign('PREROW', $prerow);
             $this->xTemplate->assign('CHECKALL', "<input type='checkbox' class='checkbox'  title='" . $GLOBALS['app_strings']['LBL_SELECT_ALL_TITLE'] . "'  name='massall' id='massall' value='' onclick='sListView.check_all(document.MassUpdate, \"mass[]\", this.checked)'>");
         }
         if (!isset($this->data_array)) {
             $tag = $aItem->listviewACLHelper();
             $this->xTemplate->assign('TAG', $tag);
         }
         if ($oddRow) {
             $ROW_COLOR = 'oddListRow';
             $BG_COLOR = $odd_bg;
         } else {
             $ROW_COLOR = 'evenListRow';
             $BG_COLOR = $even_bg;
         }
         $oddRow = !$oddRow;
         $this->xTemplate->assign('ROW_COLOR', $ROW_COLOR);
         $this->xTemplate->assign('BG_COLOR', $BG_COLOR);
         if (isset($this->data_array)) {
             $this->xTemplate->assign('KEY', $aVal);
             $this->xTemplate->assign('VALUE', $aItem);
             $this->xTemplate->assign('INDEX', $count);
         } else {
             //AED -- some modules do not have their additionalDetails.php established. Add a check to ensure require_once does not fail
             // Bug #2786
             if ($this->_additionalDetails && $aItem->ACLAccess('DetailView') && (file_exists('modules/' . $aItem->module_dir . '/metadata/additionalDetails.php') || file_exists('custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php'))) {
                 $additionalDetailsFile = 'modules/' . $aItem->module_dir . '/metadata/additionalDetails.php';
                 if (file_exists('custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php')) {
                     $additionalDetailsFile = 'custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php';
                 }
                 require_once $additionalDetailsFile;
                 $ad_function = (empty($this->additionalDetailsFunction) ? 'additionalDetails' : $this->additionalDetailsFunction) . $aItem->object_name;
                 $results = $ad_function($fields);
                 $results['string'] = str_replace(array("&#039", "'"), '\\&#039', $results['string']);
                 // no xss!
                 if (trim($results['string']) == '') {
                     $results['string'] = $app_strings['LBL_NONE'];
                 }
                 $fields[$results['fieldToAddTo']] = $fields[$results['fieldToAddTo']] . '</a>';
             }
             if ($aItem->ACLAccess('Delete')) {
                 $delete = '<a class="listViewTdToolsS1" onclick="return confirm(\'' . $this->local_app_strings['NTC_DELETE_CONFIRMATION'] . '\')" href="' . 'index.php?action=Delete&module=' . $aItem->module_dir . '&record=' . $fields['ID'] . '&return_module=' . $aItem->module_dir . '&return_action=index&return_id=">' . $this->local_app_strings['LBL_DELETE_INLINE'] . '</a>';
                 require_once 'include/Smarty/plugins/function.sugar_action_menu.php';
                 $fields['DELETE_BUTTON'] = smarty_function_sugar_action_menu(array('id' => $aItem->module_dir . '_' . $fields['ID'] . '_create_button', 'buttons' => array($delete)), $this);
             }
             $this->xTemplate->assign($html_varName, $fields);
             $aItem->setupCustomFields($aItem->module_dir);
             $aItem->custom_fields->populateAllXTPL($this->xTemplate, 'detail', $html_varName, $fields);
         }
         if (!isset($this->data_array) && $aItem->ACLAccess('DetailView')) {
             $count++;
         }
         if (isset($this->data_array)) {
             $count++;
         }
         if (!isset($this->data_array)) {
             $aItem->list_view_parse_additional_sections($this->xTemplate, $xtemplateSection);
             if ($this->xTemplate->exists($xtemplateSection . '.row.pro')) {
                 $this->xTemplate->parse($xtemplateSection . '.row.pro');
             }
         }
         $this->xTemplate->parse($xtemplateSection . '.row');
         if (isset($fields['ID'])) {
             $associated_row_data[$fields['ID']] = $fields;
             // Bug 38908: cleanup data for JS to avoid having &nbsp; shuffled around
             foreach ($fields as $key => $value) {
                 if ($value == '&nbsp;') {
                     $associated_row_data[$fields['ID']][$key] = '';
                 }
             }
         }
     }
     $_SESSION['MAILMERGE_RECORDS'] = $mergeList;
     $_SESSION['MAILMERGE_MODULE_FROM_LISTVIEW'] = $module;
     if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
         $_SESSION['MAILMERGE_MODULE'] = $module;
     }
     if ($this->process_for_popups) {
         $json = getJSONobj();
         $is_show_fullname = showFullName() ? 1 : 0;
         $associated_javascript_data = '<script type="text/javascript">' . "\n" . 'var associated_javascript_data = ' . $json->encode($associated_row_data) . ";\n" . 'var is_show_fullname = ' . $is_show_fullname . ";\n" . '</script>';
         $this->xTemplate->assign('ASSOCIATED_JAVASCRIPT_DATA', $associated_javascript_data);
     }
     $this->xTemplate->parse($xtemplateSection);
 }
Ejemplo n.º 17
0
function get_user_array($add_blank = true, $status = "Active", $assigned_user = "", $use_real_name = false, $user_name_begins = null, $is_group = ' AND portal_only=0 ', $from_cache = true)
{
    global $locale;
    global $sugar_config;
    if (empty($locale)) {
        $locale = new Localization();
    }
    if ($from_cache) {
        $user_array = get_register_value('user_array', $add_blank . $status . $assigned_user);
    }
    if (!isset($user_array)) {
        $db = DBManagerFactory::getInstance();
        $temp_result = array();
        // Including deleted users for now.
        if (empty($status)) {
            $query = "SELECT id, first_name, last_name, user_name from users WHERE 1=1" . $is_group;
        } else {
            $query = "SELECT id, first_name, last_name, user_name from users WHERE status='{$status}'" . $is_group;
        }
        if (!empty($user_name_begins)) {
            $query .= " AND user_name LIKE '{$user_name_begins}%' ";
        }
        if (!empty($assigned_user)) {
            $query .= " OR id='{$assigned_user}'";
        }
        $query = $query . ' ORDER BY user_name ASC';
        $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
            $temp_result[''] = '';
        }
        // Get the id and the name.
        while ($row = $db->fetchByAssoc($result)) {
            if ($use_real_name == true || showFullName()) {
                if (isset($row['last_name'])) {
                    // cn: we will ALWAYS have both first_name and last_name (empty value if blank in db)
                    $temp_result[$row['id']] = $locale->getLocaleFormattedName($row['first_name'], $row['last_name']);
                } else {
                    $temp_result[$row['id']] = $row['user_name'];
                }
            } else {
                $temp_result[$row['id']] = $row['user_name'];
            }
        }
        $user_array = $temp_result;
        if ($from_cache) {
            set_register_value('user_array', $add_blank . $status . $assigned_user, $temp_result);
        }
    }
    return $user_array;
}
Ejemplo n.º 18
0
function get_username_by_id($userid)
{
    if (empty($userid)) {
        return false;
    }
    $user = BeanFactory::getBean('Users');
    $user->retrieve($userid);
    if ($userid != $user->id) {
        return false;
    }
    if (showFullName()) {
        return $user->full_name;
    } else {
        return $user->user_name;
    }
}