Beispiel #1
0
function get_bean_select_array($add_blank = true, $bean_name, $display_columns, $where = '', $order_by = '', $blank_is_none = false)
{
    global $beanFiles;
    require_once $beanFiles[$bean_name];
    $focus = new $bean_name();
    $user_array = array();
    $key = $bean_name == 'EmailTemplate' ? $bean_name : $bean_name . $display_columns . $where . $order_by;
    $user_array = get_register_value('select_array', $key);
    if (!$user_array) {
        $db = DBManagerFactory::getInstance();
        $temp_result = array();
        $query = "SELECT {$focus->table_name}.id, {$display_columns} as display from {$focus->table_name} ";
        $query .= "where ";
        if ($where != '') {
            $query .= $where . " AND ";
        }
        $query .= " {$focus->table_name}.deleted=0";
        if ($order_by != '') {
            $query .= " order by {$focus->table_name}.{$order_by}";
        }
        $GLOBALS['log']->debug("get_user_array query: {$query}");
        $result = $db->query($query, true, "Error filling in user array: ");
        if ($add_blank == true) {
            // Add in a blank row
            if ($blank_is_none == true) {
                // set 'blank row' to "--None--"
                global $app_strings;
                $temp_result[''] = $app_strings['LBL_NONE'];
            } else {
                $temp_result[''] = '';
            }
        }
        // Get the id and the name.
        while ($row = $db->fetchByAssoc($result)) {
            $temp_result[$row['id']] = $row['display'];
        }
        $user_array = $temp_result;
        set_register_value('select_array', $key, $temp_result);
    }
    return $user_array;
}
 function get_script($prefix = '')
 {
     $count = get_register_value('dyn_layout', 'field_counter');
     if (empty($count)) {
         $count = 0;
     }
     return '<script>' . $this->script . "\n{$prefix}" . "field_count_MSI+={$count};" . '</script>';
 }
Beispiel #3
0
function get_bean_select_array($add_blank = true, $bean_name, $display_columns, $where = '', $order_by = '', $blank_is_none = false)
{
    global $beanFiles;
    require_once $beanFiles[$bean_name];
    $focus = new $bean_name();
    $user_array = array();
    $key = $bean_name == 'EmailTemplate' ? $bean_name : $bean_name . $display_columns . $where . $order_by;
    $user_array = get_register_value('select_array', $key);
    if (!$user_array) {
        $db = DBManagerFactory::getInstance();
        $temp_result = array();
        $query = "SELECT {$focus->table_name}.id, {$display_columns} as display from {$focus->table_name} ";
        $query .= "where ";
        if ($where != '') {
            $query .= $where . " AND ";
        }
        $query .= " {$focus->table_name}.deleted=0";
        /* BEGIN - SECURITY GROUPS */
        global $current_user, $sugar_config;
        if ($focus->module_dir == 'Users' && !is_admin($current_user) && isset($sugar_config['securitysuite_filter_user_list']) && $sugar_config['securitysuite_filter_user_list'] == true) {
            require_once 'modules/SecurityGroups/SecurityGroup.php';
            $group_where = SecurityGroup::getGroupUsersWhere($current_user->id);
            $query .= " AND (" . $group_where . ") ";
        } else {
            if ($focus->bean_implements('ACL') && ACLController::requireSecurityGroup($focus->module_dir, 'list')) {
                require_once 'modules/SecurityGroups/SecurityGroup.php';
                $owner_where = $focus->getOwnerWhere($current_user->id);
                $group_where = SecurityGroup::getGroupWhere($focus->table_name, $focus->module_dir, $current_user->id);
                if (!empty($owner_where)) {
                    $query .= " AND (" . $owner_where . " or " . $group_where . ") ";
                } else {
                    $query .= ' AND ' . $group_where;
                }
            }
        }
        /* END - SECURITY GROUPS */
        if ($order_by != '') {
            $query .= " order by {$focus->table_name}.{$order_by}";
        }
        $GLOBALS['log']->debug("get_user_array query: {$query}");
        $result = $db->query($query, true, "Error filling in user array: ");
        if ($add_blank == true) {
            // Add in a blank row
            if ($blank_is_none == true) {
                // set 'blank row' to "--None--"
                global $app_strings;
                $temp_result[''] = $app_strings['LBL_NONE'];
            } else {
                $temp_result[''] = '';
            }
        }
        // Get the id and the name.
        while ($row = $db->fetchByAssoc($result)) {
            $temp_result[$row['id']] = $row['display'];
        }
        $user_array = $temp_result;
        set_register_value('select_array', $key, $temp_result);
    }
    return $user_array;
}
Beispiel #4
0
function get_category_array($add_blank = true, $from_cache = false)
{
    if ($from_cache) {
        $key_name = "xinventory xcategory";
        $category_array = get_register_value('category_array', $key_name);
    }
    if (empty($category_array)) {
        $db = DBManagerFactory::getInstance();
        $temp_result = array();
        // Including deleted users for now.
        $query = "SELECT id, name from xcategories WHERE deleted='0'";
        $query = $query . ' ORDER BY name ASC';
        $GLOBALS['log']->debug("get_category_array query: {$query}");
        $result = $db->query($query, true, "Error filling in category array: ");
        if ($add_blank == true) {
            // Add in a blank row
            $temp_result[''] = '';
        }
        // Get the id and the name.
        while ($row = $db->fetchByAssoc($result)) {
            $temp_result[$row['id']] = $row['name'];
        }
        $category_array = $temp_result;
        if ($from_cache) {
            set_register_value('category_array', $key_name, $temp_result);
        }
    }
    return $category_array;
}