Profile::dropdownUnder PHP Method

dropdownUnder() static public method

Dropdown profiles which have rights under the active one
static public dropdownUnder ( $options = [] )
$options array of possible options: - name : string / name of the select (default is profiles_id) - value : integer / preselected value (default 0)
    static function dropdownUnder($options = array())
    {
        global $DB;
        $p['name'] = 'profiles_id';
        $p['value'] = '';
        if (is_array($options) && count($options)) {
            foreach ($options as $key => $val) {
                $p[$key] = $val;
            }
        }
        $query = "SELECT *\n                FROM `glpi_profiles` " . self::getUnderActiveProfileRestrictRequest("WHERE") . "\n                ORDER BY `name`";
        $res = $DB->query($query);
        //New rule -> get the next free ranking
        if ($DB->numrows($res)) {
            while ($data = $DB->fetch_assoc($res)) {
                $profiles[$data['id']] = $data['name'];
            }
        }
        Dropdown::showFromArray($p['name'], $profiles, array('value' => $p['value'], 'display_emptychoice' => true));
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @see CommonDBTM::showSpecificMassiveActionsParameters()
  **/
 function showSpecificMassiveActionsParameters($input = array())
 {
     global $CFG_GLPI;
     switch ($input['action']) {
         case "change_authtype":
             $rand = Auth::dropdown(array('name' => 'authtype'));
             $paramsmassaction = array('authtype' => '__VALUE__');
             Ajax::updateItemOnSelectEvent("dropdown_authtype{$rand}", "show_massiveaction_field", $CFG_GLPI["root_doc"] . "/ajax/dropdownMassiveActionAuthMethods.php", $paramsmassaction);
             echo "<span id='show_massiveaction_field'><br><br>";
             echo "<input type='submit' name='massiveaction' class='submit' value='" . _sx('button', 'Post') . "'>";
             echo "</span>\n";
             return true;
         case "add_user_group":
             $gu = new Group_User();
             return $gu->showSpecificMassiveActionsParameters($input);
         case "add_userprofile":
             Entity::dropdown(array('entity' => $_SESSION['glpiactiveentities']));
             echo ".&nbsp;" . _n('Profile', 'Profiles', 1) . "&nbsp;";
             Profile::dropdownUnder();
             echo ".&nbsp;" . __('Recursive') . "&nbsp;";
             Dropdown::showYesNo("is_recursive", 0);
             echo "<br><br><input type='submit' name='massiveaction' class='submit' value='" . _sx('button', 'Add') . "'>";
             return true;
         default:
             return parent::showSpecificMassiveActionsParameters($input);
     }
     return false;
 }
All Usage Examples Of Profile::dropdownUnder