acp_modules::make_module_select PHP Метод

make_module_select() публичный Метод

Simple version of jumpbox, just lists modules
public make_module_select ( $select_id = false, $ignore_id = false, $ignore_acl = false, $ignore_nonpost = false, $ignore_emptycat = true, $ignore_noncat = false )
    function make_module_select($select_id = false, $ignore_id = false, $ignore_acl = false, $ignore_nonpost = false, $ignore_emptycat = true, $ignore_noncat = false)
    {
        global $db, $user;
        $sql = 'SELECT module_id, module_enabled, module_basename, parent_id, module_langname, left_id, right_id, module_auth
			FROM ' . MODULES_TABLE . "\n\t\t\tWHERE module_class = '" . $db->sql_escape($this->module_class) . "'\n\t\t\tORDER BY left_id ASC";
        $result = $db->sql_query($sql);
        $right = $iteration = 0;
        $padding_store = array('0' => '');
        $module_list = $padding = '';
        while ($row = $db->sql_fetchrow($result)) {
            if ($row['left_id'] < $right) {
                $padding .= '&nbsp; &nbsp;';
                $padding_store[$row['parent_id']] = $padding;
            } else {
                if ($row['left_id'] > $right + 1) {
                    $padding = isset($padding_store[$row['parent_id']]) ? $padding_store[$row['parent_id']] : '';
                }
            }
            $right = $row['right_id'];
            if (!$ignore_acl && $row['module_auth']) {
                // We use zero as the forum id to check - global setting.
                if (!p_master::module_auth($row['module_auth'], 0)) {
                    continue;
                }
            }
            // ignore this module?
            if (is_array($ignore_id) && in_array($row['module_id'], $ignore_id) || $row['module_id'] == $ignore_id) {
                continue;
            }
            // empty category
            if (!$row['module_basename'] && $row['left_id'] + 1 == $row['right_id'] && $ignore_emptycat) {
                continue;
            }
            // ignore non-category?
            if ($row['module_basename'] && $ignore_noncat) {
                continue;
            }
            $selected = is_array($select_id) ? in_array($row['module_id'], $select_id) ? ' selected="selected"' : '' : ($row['module_id'] == $select_id ? ' selected="selected"' : '');
            $langname = $user->lang($row['module_langname']);
            $module_list .= '<option value="' . $row['module_id'] . '"' . $selected . (!$row['module_enabled'] ? ' class="disabled"' : '') . '>' . $padding . $langname . '</option>';
            $iteration++;
        }
        $db->sql_freeresult($result);
        unset($padding_store);
        return $module_list;
    }