/**
  * Generates list of available canned messages.
  *
  * @param Request $request
  * @return string Rendered page content
  */
 public function indexAction(Request $request)
 {
     $operator = $this->getOperator();
     $page = array('errors' => array());
     // Build list of available locales
     $all_locales = get_available_locales();
     $locales_with_label = array();
     foreach ($all_locales as $id) {
         $locale_info = get_locale_info($id);
         $locales_with_label[] = array('id' => $id, 'name' => $locale_info ? $locale_info['name'] : $id);
     }
     $page['locales'] = $locales_with_label;
     // Get selected locale, if any.
     $lang = $this->extractLocale($request);
     if (!$lang) {
         $lang = in_array(get_current_locale(), $all_locales) ? get_current_locale() : $all_locales[0];
     }
     // Get selected group ID, if any.
     $group_id = $this->extractGroupId($request);
     if ($group_id) {
         $group = group_by_id($group_id);
         if (!$group) {
             $page['errors'][] = getlocal('No such group');
             $group_id = false;
         }
     }
     // Build list of available groups
     $all_groups = in_isolation($operator) ? get_groups_for_operator($operator) : get_all_groups();
     $page['groups'] = array();
     $page['groups'][] = array('groupid' => '', 'vclocalname' => getlocal('-all operators-'), 'level' => 0);
     foreach ($all_groups as $g) {
         $page['groups'][] = $g;
     }
     // Get messages and setup pagination
     $canned_messages = load_canned_messages($lang, $group_id);
     foreach ($canned_messages as &$message) {
         $message['vctitle'] = $message['vctitle'];
         $message['vcvalue'] = $message['vcvalue'];
     }
     unset($message);
     $pagination = setup_pagination($canned_messages);
     $page['pagination'] = $pagination['info'];
     $page['pagination.items'] = $pagination['items'];
     // Buil form values
     $page['formlang'] = $lang;
     $page['formgroup'] = $group_id;
     // Set other needed page values and render the response
     $page['title'] = getlocal('Canned Messages');
     $page['menuid'] = 'canned';
     $page = array_merge($page, prepare_menu($operator));
     return $this->render('canned_messages', $page);
 }
示例#2
0
文件: getcode.php 项目: kuell/chat
function get_groups_list()
{
    global $settings;
    $result = array();
    if ($settings['enablegroups'] == '1') {
        $link = connect();
        $allgroups = get_all_groups($link);
        mysql_close($link);
        $result[] = array('groupid' => '', 'vclocalname' => getlocal("page.gen_button.default_group"));
        foreach ($allgroups as $g) {
            $result[] = $g;
        }
    }
    return $result;
}
示例#3
0
if (!$lang || !in_array($lang, $all_locales)) {
    $lang = in_array($current_locale, $all_locales) ? $current_locale : $all_locales[0];
}
# groups
$groupid = "";
if ($settings['enablegroups'] == '1') {
    $groupid = verifyparam("group", "/^\\d{0,8}\$/", "");
    if ($groupid) {
        $group = group_by_id($groupid);
        if (!$group) {
            $errors[] = getlocal("page.group.no_such");
            $groupid = "";
        }
    }
    $link = connect();
    $allgroups = get_all_groups($link);
    mysql_close($link);
    $page['groups'] = array();
    $page['groups'][] = array('groupid' => '', 'vclocalname' => getlocal("page.gen_button.default_group"));
    foreach ($allgroups as $g) {
        $page['groups'][] = $g;
    }
}
# delete
if (isset($_GET['act']) && $_GET['act'] == 'delete') {
    $key = isset($_GET['key']) ? $_GET['key'] : "";
    if (!preg_match("/^\\d+\$/", $key)) {
        $errors[] = "Wrong key";
    }
    if (count($errors) == 0) {
        $link = connect();
示例#4
0
							<dt>
								<label for="edit_chatroom_group">Disallowed Group(s)</label>
							</dt>
							<dd>
								<?php 
            $disallowed_groups = unserialize($row['disallowed_groups']);
            ?>
								<select multiple="multiple" id="edit_chatroom_group" name="edit_chatroom_group[]" style="width: 440px; height: 125px;">
									<option value="acg" <?php 
            if (in_array('acg', $disallowed_groups)) {
                echo 'selected="selected"';
            }
            ?>
>ArrowChat Guests (acg)</option>
								<?php 
            $groups_list = get_all_groups();
            if (!is_null($groups_list)) {
                foreach ($groups_list as $val) {
                    ?>
									<option value="<?php 
                    echo $val[0];
                    ?>
" <?php 
                    if (in_array($val[0], $disallowed_groups)) {
                        echo 'selected="selected"';
                    }
                    ?>
><?php 
                    echo $val[1];
                    ?>
 (<?php 
示例#5
0
require_once '../libs/operator_settings.php';
$operator = check_login();
function update_operator_groups($operatorid, $newvalue)
{
    global $mysqlprefix;
    $link = connect();
    perform_query("delete from {$mysqlprefix}chatgroupoperator where operatorid = {$operatorid}", $link);
    foreach ($newvalue as $groupid) {
        perform_query("insert into {$mysqlprefix}chatgroupoperator (groupid, operatorid) values ({$groupid},{$operatorid})", $link);
    }
    mysql_close($link);
}
$opId = verifyparam("op", "/^\\d{1,9}\$/");
$page = array('opid' => $opId);
$link = connect();
$page['groups'] = get_all_groups($link);
mysql_close($link);
$errors = array();
$canmodify = $opId == $operator['operatorid'] && is_capable($can_modifyprofile, $operator) || is_capable($can_administrate, $operator);
$op = operator_by_id($opId);
if (!$op) {
    $errors[] = getlocal("no_such_operator");
} else {
    if (isset($_POST['op'])) {
        if (!$canmodify) {
            $errors[] = getlocal('page_agent.cannot_modify');
        }
        if (count($errors) == 0) {
            $new_groups = array();
            foreach ($page['groups'] as $group) {
                if (verifyparam("group" . $group['groupid'], "/^on\$/", "") == "on") {
    function main($id, $mode)
    {
        global $db, $user, $auth, $template, $cache;
        global $config, $SID, $phpbb_root_path, $phpbb_admin_path, $phpEx;
        $store = '';
        $user->add_lang('acp/k_menus');
        $this->tpl_name = 'acp_k_menus';
        $this->page_title = 'ACP_MENUS';
        $form_key = 'acp_k_menus';
        add_form_key($form_key);
        //$action	= request_var('action', '');
        $submit = isset($_POST['submit']) ? true : false;
        if ($submit && !check_form_key($form_key)) {
            $submit = false;
            $mode = '';
            trigger_error('Error! ' . $user->lang['FORM_INVALID'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
        }
        $menuitem = request_var('menuitem', '');
        $template->assign_vars(array('U_BACK' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_menus&amp;mode=nav", 'U_EDIT' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_menus&amp;mode=edit" . '&amp;menu=' . $menuitem, 'U_UP' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_menus&amp;mode=up" . '&amp;menu=' . $menuitem, 'U_DOWN' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_menus&amp;mode=down" . '&amp;menu=' . $menuitem, 'U_DELETE' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_menus&amp;mode=delete" . '&amp;menu=' . $menuitem));
        // Set up general vars
        //$action = request_var('action', '');
        $mode = request_var('mode', '');
        $menu = request_var('menu', 0);
        $menuitem = request_var('menuitem', '');
        $u_action = append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$id}&amp;mode={$mode}");
        if ($mode == '') {
            $mode = 'head';
        }
        if ($submit) {
            $store = $mode;
        }
        switch ($mode) {
            case 'head':
                get_menu(0);
                $template->assign_var('S_OPTIONS', 'head');
                break;
            case 'nav':
                get_menu(1);
                $template->assign_var('S_OPTIONS', 'nav');
                break;
            case 'sub':
                get_menu(2);
                $template->assign_var('S_OPTIONS', 'sub');
                break;
            case 'all':
                get_menu(90);
                $template->assign_var('S_OPTIONS', 'all');
                break;
            case 'unalloc':
                get_menu(99);
                $template->assign_var('S_OPTIONS', 'unalloc');
                break;
            case 'edit':
                if ($submit) {
                    $m_id = request_var('m_id', 0);
                    $ndx = request_var('ndx', 0);
                    $menu_type = request_var('menu_type', '');
                    $menu_icon = request_var('menu_icon', '');
                    $name = utf8_normalize_nfc(request_var('name', '', true));
                    $link_to = request_var('link_to', '');
                    $append_sid = request_var('append_sid', 0);
                    $append_uid = request_var('append_uid', 0);
                    $extern = request_var('extern', 0);
                    $soft_hr = request_var('soft_hr', 0);
                    $sub_heading = request_var('sub_heading', 0);
                    $view_by = request_var('view_by', 1);
                    $view_all = request_var('view_all', 1);
                    $view_groups = request_var('view_groups', '');
                    if ($view_all) {
                        $view_by = 1;
                        $view_groups = '';
                    }
                    if (strstr($menu_icon, '..')) {
                        $menu_icon = 'default.png';
                    }
                    //echo $menu_icon;
                    $sql_ary = array('menu_type' => $menu_type, 'ndx' => $ndx, 'menu_icon' => $menu_icon, 'name' => $name, 'link_to' => $link_to, 'append_sid' => $append_sid, 'append_uid' => $append_uid, 'extern' => $extern, 'soft_hr' => $soft_hr, 'sub_heading' => $sub_heading, 'view_all' => $view_all, 'view_by' => $view_by, 'view_groups' => $view_groups);
                    $sql = 'UPDATE ' . K_MENUS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE m_id = " . (int) $m_id;
                    if (!($result = $db->sql_query($sql))) {
                        trigger_error($user->lang['ERROR_PORTAL_MENUS'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                    }
                    $cache->destroy('sql', K_MENUS_TABLE);
                    switch ($menu_type) {
                        case 1:
                            $mode = 'nav';
                            break;
                        case 2:
                            $mode = 'sub';
                            break;
                        default:
                            $mode = 'manage';
                            break;
                    }
                    $template->assign_vars(array('L_MENU_REPORT' => $user->lang['DATA_IS_BEING_SAVED'] . '</font><br />', 'S_OPTIONS' => 'save'));
                    meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=k_menus&amp;mode=' . $mode));
                    break;
                }
                // get all groups and fill array //
                get_all_groups();
                // A simple fix to allow delete
                if ($menu > 99) {
                    $menu = $menu / 100;
                }
                if ($submit == 1) {
                    get_menu_item($m_id);
                } else {
                    get_menu_item($menu);
                }
                $template->assign_var('S_OPTIONS', 'edit');
                get_menu_icons();
                break;
            case 'delete':
                if (!$menu) {
                    trigger_error($user->lang['MUST_SELECT_VALID_MENU_DATA'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                if (confirm_box(true)) {
                    $sql = 'SELECT name, m_id
						FROM ' . K_MENUS_TABLE . '
						WHERE m_id = ' . (int) $menu;
                    $result = $db->sql_query($sql);
                    $name = (string) $db->sql_fetchfield('name');
                    $id = (int) $db->sql_fetchfield('m_id');
                    $db->sql_freeresult($result);
                    $name .= ' Menu ';
                    $sql = 'DELETE FROM ' . K_MENUS_TABLE . "\n\t\t\t\t\t\tWHERE m_id = " . (int) $menu;
                    $db->sql_query($sql);
                    $template->assign_var('L_MENU_REPORT', $name . $user->lang['DELETED'] . '</font><br />');
                    $cache->destroy('sql', K_MENUS_TABLE);
                    meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=k_menus&amp;mode=all'));
                    break;
                } else {
                    confirm_box(false, $user->lang['CONFIRM_OPERATION_MENUS'], build_hidden_fields(array('i' => $id, 'mode' => $mode, 'action' => 'delete')));
                }
                $template->assign_var('L_MENU_REPORT', $user->lang['ACTION_CANCELLED']);
                meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=k_menus&amp;mode=all'));
                break;
            case 'up':
            case 'down':
                $to_move = $move_to = '';
                // get current menu data //
                $sql = "SELECT m_id, ndx, menu_type FROM " . K_MENUS_TABLE . "\n\t\t\t\t\tWHERE m_id = " . (int) $menu . " LIMIT 1";
                if (!($result = $db->sql_query($sql))) {
                    trigger_error($user->lang['ERROR_PORTAL_MENUS'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                }
                $row = $db->sql_fetchrow($result);
                $to_move['m_id'] = $row['m_id'];
                $to_move['ndx'] = $temp = $row['ndx'];
                $type = $row['menu_type'];
                if ($mode == 'up') {
                    $temp = $temp - 1;
                }
                if ($mode == 'down') {
                    $temp = $temp + 1;
                }
                // get move_to menu data//
                $sql = "SELECT m_id, ndx, menu_type FROM " . K_MENUS_TABLE . "\n\t\t\t\t\tWHERE ndx =  {$temp}\n\t\t\t\t\t\tAND menu_type = '" . $db->sql_escape($type) . "' LIMIT 1";
                if (!($result = $db->sql_query($sql))) {
                    trigger_error($user->lang['MENU_MOVE_ERROR'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                }
                $row = $db->sql_fetchrow($result);
                $move_to['m_id'] = $row['m_id'];
                $move_to['ndx'] = $row['ndx'];
                if ($move_to['ndx'] != $temp) {
                    trigger_error($user->lang['MENU_MOVE_ERROR'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                }
                if ($mode == 'up') {
                    // sql is not duplicated
                    $sql = "UPDATE " . K_MENUS_TABLE . " SET ndx = " . (int) $to_move['ndx'] . " WHERE m_id = " . (int) $move_to['m_id'];
                    if (!($result = $db->sql_query($sql))) {
                        trigger_error($user->lang['MENU_MOVE_ERROR'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                    }
                    $sql = "UPDATE " . K_MENUS_TABLE . " SET ndx = " . (int) $move_to['ndx'] . " WHERE m_id = " . (int) $to_move['m_id'];
                    if (!($result = $db->sql_query($sql))) {
                        trigger_error($user->lang['MENU_MOVE_ERROR'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                    }
                }
                if ($mode == 'down') {
                    // sql is not duplicated
                    $sql = "UPDATE " . K_MENUS_TABLE . " SET ndx = " . (int) $move_to['ndx'] . " WHERE m_id = " . (int) $to_move['m_id'];
                    if (!($result = $db->sql_query($sql))) {
                        trigger_error($user->lang['MENU_MOVE_ERROR'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                    }
                    $sql = "UPDATE " . K_MENUS_TABLE . " SET ndx = " . (int) $to_move['ndx'] . " WHERE m_id = " . (int) $move_to['m_id'];
                    if (!($result = $db->sql_query($sql))) {
                        trigger_error($user->lang['MENU_MOVE_ERROR'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                    }
                }
                $template->assign_vars(array('L_MENU_REPORT' => $user->lang['SORT_ORDER_UPDATING'], 'S_OPTIONS' => 'updn'));
                $mode = 'nav';
                $cache->destroy('sql', K_MENUS_TABLE);
                meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=k_menus&amp;mode=nav'));
                break;
            case 'create':
                if ($submit) {
                    //$m_id		=request_var('m_id', '');
                    //$ndx    	= request_var('ndx', '');
                    $menu_type = request_var('menu_type', '');
                    $menu_icon = request_var('menu_icon', '');
                    $name = utf8_normalize_nfc(request_var('name', '', true));
                    $link_to = request_var('link_to', '');
                    $append_sid = request_var('append_sid', 0);
                    $append_uid = request_var('append_uid', 0);
                    $extern = request_var('extern', 0);
                    $soft_hr = request_var('soft_hr', 0);
                    $sub_heading = request_var('sub_heading', 0);
                    $view_by = request_var('view_by', 1);
                    $view_all = request_var('view_all', 1);
                    $view_groups = request_var('view_groups', '');
                    if ($menu_type == NULL || $name == NULL) {
                        // catch all we check menu_type, $name, view_by)
                        $template->assign_vars(array('L_MENU_REPORT' => $user->lang['MISSING_DATA'], 'S_OPTIONS' => 'updn'));
                        return;
                    }
                    if (strstr($menu_icon, '..') && !$sub_heading) {
                        $menu_icon = 'default.png';
                    }
                    $ndx = get_next_ndx($menu_type);
                    if ($view_all) {
                        $view_by = 1;
                        $view_groups = '';
                    }
                    $sql_array = array('menu_type' => $menu_type, 'ndx' => $ndx, 'menu_icon' => $menu_icon, 'name' => $name, 'link_to' => $link_to, 'append_sid' => $append_sid, 'append_uid' => $append_uid, 'extern' => $extern, 'soft_hr' => $soft_hr, 'sub_heading' => $sub_heading, 'view_all' => $view_all, 'view_by' => $view_by, 'view_groups' => $view_groups);
                    $db->sql_query('INSERT INTO ' . K_MENUS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_array));
                    $cache->destroy('sql', K_MENUS_TABLE);
                    //fix for the different menus...
                    meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=k_menus&amp;mode=' . $store));
                    $template->assign_var('L_MENU_REPORT', $user->lang['MENU_CREATED']);
                    break;
                    //return;
                } else {
                    // get all groups and fill array //
                    get_all_groups();
                    get_menu_icons();
                    $template->assign_var('S_OPTIONS', 'add');
                    break;
                }
            case 'icons':
                $dirslist = '';
                $i = get_menu_icons();
                $template->assign_vars(array('S_OPTIONS' => 'icons', 'S_HIDE' => 'HIDE', 'L_ICONS_REPORT' => '', 'S_MENU_ICON_COUNT' => $i, 'S_MENU_ICONS_LIST' => $dirslist));
                break;
            case 'manage':
                $template->assign_var('L_MENU_REPORT', $user->lang['FUTURE_DEVELOPMENT'] . '</font><br />');
                $template->assign_var('S_OPTIONS', 'manage');
                break;
            case 'sync':
                $template->assign_vars('L_MENU_REPORT', $user->lang['NOT_ASSIGNED'] . '</font><br />');
                $template->assign_var('S_OPTIONS', 'sync');
                break;
            case 'tools':
                $template->assign_var('S_OPTIONS', 'tools');
                break;
            case 'default':
        }
        $template->assign_var('U_ACTION', $u_action);
    }
示例#7
0
}

?>

<fieldset>
<legend>Current Groups </legend>

<p> To Change or Delete a group, select it ... </p>
<?

# Setting a session token
$_SESSION["token"] = rand (0, 10000); 
$token = $_SESSION["token"];

$allgroups = get_all_groups();
if (count ($allgroups)) {
    
    $allGroups = "";    
    echo "<TABLE class=\"report\">";
    echo "<TR><TH>Group Name</TH><TH>Users</TH><TH>Right</TH></TR>";

    foreach ($allgroups as $indGroup) {
        
        $indGroup = trim ($indGroup);
        if ($indGroup == "") {
            next;
        }
        $indGroup = str_replace ("___", "\M", $indGroup);
        $indGroupArray = explode ("\M", $indGroup);
        if (($indGroupArray[0] == $id) && ($indGroupArray[2] != "")) {
    function main($id, $mode)
    {
        global $db, $user, $auth, $template, $cache;
        global $config, $k_config, $phpbb_root_path, $phpbb_admin_path, $phpEx, $SID;
        include $phpbb_root_path . 'includes/sgp_functions_admin.' . $phpEx;
        // Define Switches for html file //
        $user->add_lang('acp/k_blocks');
        $this->tpl_name = 'acp_k_blocks';
        $this->page_title = 'ACP_BLOCKS';
        $form_key = 'acp_k_blocks';
        add_form_key($form_key);
        $action = request_var('action', '');
        $submit = isset($_POST['submit']) ? true : false;
        if ($submit && !check_form_key($form_key)) {
            $submit = false;
            $mode = '';
            trigger_error($user->lang['FORM_INVALID']);
        }
        // Can not use append_sid here, the $block_id is assigned to the html but unknow to this code //
        // Would require I add a form element and use request_var to retrieve it //
        // The global $SID is available so I make use of it...?
        $template->assign_vars(array('U_BACK' => $this->u_action, 'U_EDIT2' => "{$phpbb_admin_path}index.{$phpEx}{$SID}&amp;i=k_blocks&amp;mode=edit&amp;block=", 'U_UP' => "{$phpbb_admin_path}index.{$phpEx}{$SID}&amp;i=k_blocks&amp;mode=up&amp;block=", 'U_DOWN' => "{$phpbb_admin_path}index.{$phpEx}{$SID}&amp;i=k_blocks&amp;mode=down&amp;block=", 'U_DELETE' => "{$phpbb_admin_path}index.{$phpEx}{$SID}&amp;i=k_blocks&amp;mode=delete&amp;block=", 'U_SET_VARS_W' => "{$phpbb_admin_path}index.{$phpEx}{$SID}&amp;i=k_modules&amp;mode=welcome&amp;block=", 'U_SET_VARS' => "{$phpbb_admin_path}index.{$phpEx}{$SID}&amp;i=k_vars&amp;mode=config&amp;block=", 'U_LINK_MINIMOD' => "{$phpbb_admin_path}index.{$phpEx}{$SID}&amp;i=k_modules&mode=edit&amp;module=", 'U_MANAGE_PAGES' => "{$phpbb_admin_path}index.{$phpEx}{$SID}&amp;i=k_pages&mode=manage"));
        // Set up general vars
        $mode = request_var('mode', '');
        $block = request_var('block', '');
        // bold current row text so things are easier to follow when moving/editing etc... //
        if ($block ? $block : 0) {
            $sql = 'UPDATE ' . K_BLOCKS_CONFIG_VAR_TABLE . ' SET config_value = ' . (int) $block . ' WHERE config_name = "adm_block"';
            $db->sql_query($sql);
        } else {
            $wheresql = ' WHERE config_name = "adm_block"';
            $sql = 'SELECT config_name, config_value
				FROM ' . K_BLOCKS_CONFIG_VAR_TABLE . $wheresql;
            $result = $db->sql_query($sql);
            $row = $db->sql_fetchrow($result);
            $k_config[$row['config_name']] = $row['config_value'];
        }
        $template->assign_var('ADM_BLOCK', $k_config['adm_block']);
        //$u_action = append_sid("{$phpbb_admin_path}index.$phpEx" , "i=$id&amp;mode=" . strtolower($mode));
        $u_action = append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$id}&amp;mode=" . $mode);
        switch ($mode) {
            case 'up':
            case 'down':
                $to_move = $move_to = array();
                // get current block data//
                $sql = "SELECT id, ndx, position FROM " . K_BLOCKS_TABLE . "\n\t\t\t\t\tWHERE id = " . (int) $block . " LIMIT 1";
                if (!($result = $db->sql_query($sql))) {
                    trigger_error($user->lang['ERROR_PORTAL_BLOCKS'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                }
                // Added function to reindex blocks after a block deletion Dicky
                if (isset($current_position) && $current_position != $position) {
                    $index_start = get_lowest_ndx($current_position);
                    reindex_column($current_position, $index_start);
                }
                $row = $db->sql_fetchrow($result);
                $to_move['id'] = $row['id'];
                $to_move['ndx'] = $temp = $row['ndx'];
                // position is char 'L', 'R', 'C' (char) //
                $position = $row['position'];
                if ($mode == 'up') {
                    $temp = $temp - 1;
                }
                if ($mode == 'down') {
                    $temp = $temp + 1;
                }
                // get move_to block data//
                $sql = "SELECT id, ndx, position FROM " . K_BLOCKS_TABLE . "\n\t\t\t\t\tWHERE ndx =  '" . (int) $temp . "' AND position = '" . $db->sql_escape($position) . "' LIMIT 1";
                if (!($result = $db->sql_query($sql))) {
                    trigger_error($user->lang['BLOCK_MOVE_ERROR'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                }
                $row = $db->sql_fetchrow($result);
                $move_to['id'] = $row['id'];
                $move_to['ndx'] = $row['ndx'];
                if ($move_to['ndx'] != $temp || $move_to['id'] == '') {
                    trigger_error($user->lang['BLOCK_MOVE_ERROR'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                }
                if ($mode == 'up') {
                    // sql is not duplicated
                    $sql = "UPDATE " . K_BLOCKS_TABLE . " SET ndx = " . $to_move['ndx'] . " WHERE id = " . $move_to['id'];
                    if (!($result = $db->sql_query($sql))) {
                        trigger_error($user->lang['BLOCK_MOVE_ERROR'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                    }
                    $sql = "UPDATE " . K_BLOCKS_TABLE . " SET ndx = " . $move_to['ndx'] . " WHERE id = " . $to_move['id'];
                    if (!($result = $db->sql_query($sql))) {
                        trigger_error($user->lang['BLOCK_MOVE_ERROR'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                    }
                }
                if ($mode == 'down') {
                    // sql is not duplicated
                    $sql = "UPDATE " . K_BLOCKS_TABLE . " SET ndx = " . $move_to['ndx'] . " WHERE id = " . $to_move['id'];
                    if (!($result = $db->sql_query($sql))) {
                        trigger_error($user->lang['BLOCK_MOVE_ERROR'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                    }
                    $sql = "UPDATE " . K_BLOCKS_TABLE . " SET ndx = " . $to_move['ndx'] . " WHERE id = " . $move_to['id'];
                    if (!($result = $db->sql_query($sql))) {
                        trigger_error($user->lang['BLOCK_MOVE_ERROR'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                    }
                }
                $template->assign_var('BLOCK_REPORT', $user->lang['BLOCK_UPDATING']);
                if ($position) {
                    $mode = $position;
                } else {
                    $mode = 'manage';
                }
                $cache->destroy('sql', K_BLOCKS_TABLE);
                meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=k_blocks&amp;mode=' . $mode));
                break;
            case 'add':
            case 'ADD':
                if ($submit) {
                    if (request_var('html_file_name', '') == "" or request_var('title', '') == "") {
                        $message = $user->lang['MISSING_BLOCK_DATA'];
                        $template->assign_var('BLOCK_REPORT', $message . '<br />');
                        meta_refresh(2, append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=k_blocks&amp;mode=add'));
                        return;
                    }
                    //$id				= request_var('m_id']; // auto assigned
                    //$ndx				= request_var('ndx'];  // we calculate this
                    $title = utf8_normalize_nfc(request_var('title', '', true));
                    $position = request_var('position', '');
                    $active = request_var('active', 1);
                    $type = request_var('type', '');
                    $scroll = request_var('scroll', 0);
                    $view_by = request_var('view_by', 1);
                    $view_groups = request_var('view_groups', '');
                    $view_all = request_var('view_all', 1);
                    $view_pages = request_var('view_pages', '');
                    $html_file_name = request_var('html_file_name', '');
                    $var_file_name = request_var('var_file_name', '');
                    $img_file_name = request_var('img_file_name', '');
                    $has_vars = request_var('has_vars', 0);
                    $minimod_based = request_var('minimod_based', 0);
                    $mod_block_id = request_var('mod_block_id', 0);
                    $block_cache_time = request_var('block_cache_time', 300);
                    if ($view_all) {
                        $view_by = 1;
                    }
                    if ($img_file_name == '') {
                        $img_file_name = 'default.gif';
                    }
                    if ($has_vars == 0) {
                        $var_file_name = '';
                    }
                    if ($minimod_based == 0) {
                        $mod_block_id = '0';
                    }
                    $view_page_id = request_var('view_page_id', array(0));
                    for ($i = 0; $i < count($view_page_id); $i++) {
                        $view_pages .= $view_page_id[$i];
                        if ($i < count($view_page_id) - 1) {
                            $view_pages .= ',';
                        }
                    }
                    $ndx = get_next_ndx($position);
                    // get the next ndx to use for this position	//
                    $sql_array = array('ndx' => $ndx, 'title' => $title, 'active' => $active, 'html_file_name' => $html_file_name, 'var_file_name' => $var_file_name, 'img_file_name' => $img_file_name, 'position' => $position, 'view_by' => $view_by, 'view_groups' => $view_groups, 'view_all' => $view_all, 'view_pages' => $view_pages, 'scroll' => $scroll, 'has_vars' => $has_vars, 'minimod_based' => $minimod_based, 'mod_block_id' => $mod_block_id, 'block_cache_time' => $block_cache_time);
                    if (!$db->sql_query('INSERT INTO ' . K_BLOCKS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_array))) {
                        trigger_error($user->lang['COULD_NOT_ADD_BLOCK'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                    } else {
                        $message = $user->lang['BLOCK_ADDED'];
                        $template->assign_var('BLOCK_REPORT', $title . $message . '</font><br />');
                    }
                    $cache->destroy('sql', K_BLOCKS_TABLE);
                    meta_refresh(2, append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=k_blocks&amp;mode=manage'));
                    return;
                } else {
                    // get all groups and fill array //
                    get_all_groups();
                    get_all_pages(0);
                    get_all_minimods();
                    get_all_vars_files($block);
                    //Get all installed blocks//
                    $data = '';
                    $c = 0;
                    $sql = 'SELECT * FROM ' . K_BLOCKS_TABLE;
                    if ($result = $db->sql_query($sql)) {
                        while ($row = $db->sql_fetchrow($result)) {
                            $data .= $row['id'];
                            $data .= ' ';
                            $c++;
                        }
                    }
                    $dirslist = '';
                    $dirs = dir($phpbb_root_path . 'styles/_portal_common/template/blocks');
                    while ($file = $dirs->read()) {
                        if (!stripos($file, ".bak")) {
                            $dirslist .= "{$file} ";
                        }
                    }
                    closedir($dirs->handle);
                    $dirslist = explode(" ", $dirslist);
                    sort($dirslist);
                    for ($i = 0; $i < sizeof($dirslist); $i++) {
                        if ($dirslist[$i] != '') {
                            $template->assign_block_vars('html_file_name', array('S_BLOCK_FILE_HTML' => $dirslist[$i]));
                        }
                    }
                    $dirslist = '.. ';
                    $dirs = dir($phpbb_root_path . 'images/block_images/block');
                    while ($file = $dirs->read()) {
                        if (stripos($file, ".gif") || stripos($file, ".png")) {
                            $dirslist .= "{$file} ";
                        }
                    }
                    closedir($dirs->handle);
                    $dirslist = explode(" ", $dirslist);
                    sort($dirslist);
                    for ($i = 0; $i < sizeof($dirslist); $i++) {
                        if ($dirslist[$i] != '') {
                            $template->assign_block_vars('img_file_name', array('S_BLOCK_FILE_I' => $dirslist[$i]));
                        }
                    }
                    $dirslist = '';
                    $template->assign_var('S_OPTIONS', strtoupper($mode));
                }
                break;
            case 'edit':
            case 'EDIT':
                if ($submit) {
                    $id = request_var('id', 0);
                    $ndx = request_var('ndx', 0);
                    $title = utf8_normalize_nfc(request_var('title', '', true));
                    $position = request_var('position', '');
                    $type = request_var('type', '');
                    $active = request_var('active', 1);
                    $view_by = request_var('view_by', 1);
                    $view_groups = request_var('view_groups', '');
                    $view_all = request_var('view_all', 1);
                    $view_pages = request_var('view_pages', '');
                    $scroll = request_var('scroll', 0);
                    $has_vars = request_var('has_vars', 0);
                    $minimod_based = request_var('minimod_based', 0);
                    $mod_block_id = request_var('mod_block_id', 0);
                    $html_file_name = request_var('html_file_name', '');
                    $var_file_name = request_var('var_file_name', '');
                    $img_file_name = request_var('img_file_name', '');
                    $block_cache_time = request_var('block_cache_time', 300);
                    $view_page_id = request_var('view_page_id', array(0));
                    for ($i = 0; $i < count($view_page_id); $i++) {
                        $view_pages .= $view_page_id[$i];
                        if ($i < count($view_page_id) - 1) {
                            $view_pages .= ',';
                        }
                    }
                    // this shoud not happen but just in case //
                    if (!$id) {
                        $template->assign_var('BLOCK_REPORT', $user->lang['UNKNOWN_ERROR']);
                        $submit = false;
                        return;
                    }
                    if ($type == 1) {
                        $type = 'H';
                    } else {
                        $type = 'B';
                    }
                    if ($view_by == '' && !$view_all) {
                        $view_by = 0;
                    } else {
                        if ($view_all) {
                            $view_by = 1;
                        }
                    }
                    if ($img_file_name == '') {
                        $img_file_name = 'default.gif';
                    }
                    if ($has_vars == 0) {
                        $var_file_name = '';
                    }
                    if ($minimod_based == 0) {
                        $mod_block_id = '0';
                    }
                    // get the current block position //
                    $current_position = get_current_position($id);
                    // if moving block position (column) //
                    if ($current_position != $position) {
                        $ndx = get_next_ndx($position);
                    }
                    // change to build array later
                    $sql = "UPDATE " . K_BLOCKS_TABLE . "\n\t\t\t\t\t\tSET\n\t\t\t\t\t\t\tndx\t\t\t\t\t= '" . (int) $ndx . "',\n\t\t\t\t\t\t\tactive\t\t\t\t= '" . (int) $active . "',\n\t\t\t\t\t\t\ttitle\t\t\t\t= '" . $db->sql_escape($title) . "',\n\t\t\t\t\t\t\tposition\t\t\t= '" . $db->sql_escape($position) . "',\n\t\t\t\t\t\t\ttype\t\t\t\t= '" . $db->sql_escape($type) . "',\n\t\t\t\t\t\t\thtml_file_name\t\t= '" . $db->sql_escape($html_file_name) . "',\n\t\t\t\t\t\t\tvar_file_name\t\t= '" . $db->sql_escape($var_file_name) . "',\n\t\t\t\t\t\t\timg_file_name\t\t= '" . $db->sql_escape($img_file_name) . "',\n\t\t\t\t\t\t\tview_groups\t\t\t= '" . $db->sql_escape($view_groups) . "',\n\t\t\t\t\t\t\tview_pages\t\t\t= '" . $db->sql_escape($view_pages) . "',\n\t\t\t\t\t\t\tview_by\t\t\t\t= '" . $db->sql_escape($view_by) . "',\n\t\t\t\t\t\t\tview_all\t\t\t= '" . (int) $view_all . "',\n\t\t\t\t\t\t\tscroll\t\t\t\t= '" . (int) $scroll . "',\n\t\t\t\t\t\t\thas_vars\t\t\t= '" . (int) $has_vars . "',\n\t\t\t\t\t\t\tminimod_based\t\t= '" . (int) $minimod_based . "',\n\t\t\t\t\t\t\tmod_block_id\t\t= '" . (int) $mod_block_id . "',\n\t\t\t\t\t\t\tblock_cache_time\t= '" . (int) $block_cache_time . "'\n\t\t\t\t\t\t\tWHERE id = '{$id}'";
                    if (!($result = $db->sql_query($sql))) {
                        trigger_error($user->lang['COULD_NOT_EDIT_BLOCK'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                    }
                    $template->assign_var('BLOCK_REPORT', $user->lang['SAVING']);
                    $cache->destroy('sql', K_BLOCKS_TABLE);
                    delete_this_block_cached_file($html_file_name);
                    if ($position) {
                        $mode = $position;
                    } else {
                        $mode = 'manage';
                    }
                    meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=k_blocks&amp;mode=' . $mode));
                    return;
                }
                // get all available html files, note.. we search the admin styles folder //
                $dirslist = '.. ';
                $dirs = dir($phpbb_root_path . 'styles/_portal_common/template/blocks');
                while ($file = $dirs->read()) {
                    if (!stripos($file, ".bak")) {
                        $dirslist .= "{$file} ";
                    }
                }
                closedir($dirs->handle);
                $dirslist = explode(" ", $dirslist);
                sort($dirslist);
                for ($i = 0; $i < sizeof($dirslist); $i++) {
                    if ($dirslist[$i] != '') {
                        $template->assign_block_vars('html_file_name', array('S_BLOCK_FILE_HTML' => $dirslist[$i]));
                    }
                }
                // get all available block images //
                $dirslist = '.. ';
                $dirs = dir($phpbb_root_path . 'images/block_images/block');
                while ($file = $dirs->read()) {
                    if (stripos($file, ".gif") || stripos($file, ".png")) {
                        $dirslist .= "{$file} ";
                    }
                }
                closedir($dirs->handle);
                $dirslist = explode(" ", $dirslist);
                sort($dirslist);
                for ($i = 0; $i < sizeof($dirslist); $i++) {
                    if ($dirslist[$i] != '') {
                        $template->assign_block_vars('img_file_name', array('S_BLOCK_FILE_I' => $dirslist[$i]));
                    }
                }
                $dirslist = '';
                $template->assign_var('S_OPTIONS', 'ADD');
                // not a language var //
                if ($block == '' || $block == 0) {
                    trigger_error($user->lang['NO_BLOCK_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                $sql = 'SELECT * FROM ' . K_BLOCKS_TABLE . ' WHERE id=' . (int) $block;
                if ($result = $db->sql_query($sql)) {
                    $row = $db->sql_fetchrow($result);
                }
                if ($row['img_file_name'] == '') {
                    $row['img_file_name'] = 'default.gif';
                }
                $template->assign_vars(array('S_ID' => $row['id'], 'S_NDX' => $row['ndx'], 'S_TITLE' => $row['title'], 'S_POSITION' => $row['position'], 'S_ACTIVE' => $row['active'], 'S_TYPE' => $row['type'], 'S_FNAME_H' => $row['html_file_name'], 'S_FNAME_V' => $row['var_file_name'], 'S_FNAME_I' => $row['img_file_name'], 'S_VIEW_BY' => $row['view_by'], 'S_VIEW_GROUPS' => $row['view_groups'], 'S_VIEW_ALL' => $row['view_all'], 'S_VIEW_PAGES' => $row['view_pages'], 'S_SCROLL' => $row['scroll'], 'S_HAS_VARS' => $row['has_vars'], 'S_MINIMOD_BASED' => $row['minimod_based'], 'S_MOD_BLOCK_ID' => $row['mod_block_id'], 'BLOCK_CACHE_TIME' => $row['block_cache_time']));
                // get all groups and fill array //
                get_all_pages($block);
                get_all_groups();
                get_all_minimods();
                get_all_vars_files($block);
                $db->sql_freeresult($result);
                $template->assign_var('S_OPTIONS', strtoupper($mode));
                break;
            case 'delete':
                if (!$block) {
                    trigger_error($user->lang['MUST_SELECT_VALID_BLOCK_DATA'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                if (confirm_box(true)) {
                    $sql = 'SELECT title, id, position
						FROM ' . K_BLOCKS_TABLE . '
						WHERE id = ' . (int) $block;
                    $result = $db->sql_query($sql);
                    $row = $db->sql_fetchrow($result);
                    $title = $row['title'];
                    $id = $row['id'];
                    $position = $row['position'];
                    $db->sql_freeresult($result);
                    // Get lowest ndx for current position block Dicky
                    $index_start = get_lowest_ndx($position);
                    $sql = "DELETE FROM " . K_BLOCKS_TABLE . "\n\t\t\t\t\t\tWHERE id = " . (int) $block;
                    $db->sql_query($sql);
                    // Added function to reindex blocks after a block deletion
                    reindex_column($position, $index_start);
                    $template->assign_var('BLOCK_REPORT', $title . $user->lang['BLOCK_DELETED'] . '</font><br />');
                    $cache->destroy('sql', K_BLOCKS_TABLE);
                    meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=k_blocks&amp;mode=manage'));
                    break;
                } else {
                    confirm_box(false, $user->lang['CONFIRM_OPERATION_BLOCKS'], build_hidden_fields(array('i' => $id, 'mode' => $mode, 'action' => 'delete')));
                }
                $template->assign_var('BLOCK_REPORT', $user->lang['ACTION_CANCELLED']);
                meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=k_blocks&amp;mode=manage'));
                break;
            case 'reindex':
                $index_no = 1;
                if (confirm_box(true)) {
                    $thispos = $newpos = '';
                    $list = array();
                    $sql = 'SELECT * FROM ' . K_BLOCKS_TABLE . ' ORDER by position, ndx';
                    if ($result = $db->sql_query($sql)) {
                        while ($row = $db->sql_fetchrow($result)) {
                            $thispos = $row['position'];
                            if ($thispos == $newpos) {
                                $index_no++;
                            } else {
                                $index_no = 1;
                            }
                            $sql = "UPDATE " . K_BLOCKS_TABLE . " SET ndx = '" . (int) $index_no . "' WHERE id = " . (int) $row['id'];
                            //reset ndx to 1 when position changes
                            $newpos = $row['position'];
                            $results = $db->sql_query($sql);
                            if (!$results) {
                                trigger_error($user->lang['RE-INDEXING BLOCKS'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                            }
                        }
                    }
                    $db->sql_freeresult($result);
                    $template->assign_vars(array('S_BUTTON_HIDE' => true, 'BLOCK_REPORT' => $user->lang['BLOCKS_REINDEXED']));
                    $cache->destroy('sql', K_BLOCKS_TABLE);
                    meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=k_blocks&amp;mode=manage'));
                    break;
                } else {
                    confirm_box(false, $user->lang['CONFIRM_OPERATION_BLOCKS_REINDEX'], build_hidden_fields(array('i' => $id, 'mode' => $mode, 'action' => 'reindex')));
                }
                $template->assign_var('BLOCK_REPORT', $user->lang['ACTION_CANCELLED']);
                meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=k_blocks&amp;mode=manage'));
                break;
            case 'tools':
                $template->assign_var('S_OPTIONS', 'TOOLS');
                // not  language var //
                break;
            case 'L':
            case 'C':
            case 'R':
            case '1':
            case '2':
            case '3':
                $template->assign_var('S_TYPE', $mode);
            case 'manage':
                if ($mode != 'manage') {
                    $sql = "SELECT * FROM " . K_BLOCKS_TABLE . " WHERE position = '" . $db->sql_escape($mode) . "' ORDER by ndx, type";
                } else {
                    $sql = 'SELECT * FROM ' . K_BLOCKS_TABLE . ' ORDER by position, ndx';
                }
                $l_b_first = $r_b_first = $c_b_first = $l_b_last = $r_b_last = $c_b_last = 1;
                if ($result = $db->sql_query($sql)) {
                    while ($row = $db->sql_fetchrow($result)) {
                        if ($row['img_file_name'] == '') {
                            $row['img_file_name'] = 'default.gif';
                        }
                        if ($mode == 'manage') {
                            if ($row['position'] == 'L') {
                                $l_b_last = $l_b_last + 1;
                            } else {
                                if ($row['position'] == 'R') {
                                    $r_b_last = $r_b_last + 1;
                                } else {
                                    if ($row['position'] == 'C') {
                                        $c_b_last = $c_b_last + 1;
                                    }
                                }
                            }
                        }
                        $template->assign_block_vars('bdata', array('S_ID' => $row['id'], 'S_NDX' => $row['ndx'], 'S_TITLE' => $row['title'], 'S_POSITION' => $row['position'], 'S_ACTIVE' => $row['active'], 'S_TYPE' => $row['type'], 'S_FNAME_H' => $row['html_file_name'], 'S_FNAME_V' => $row['var_file_name'], 'S_FNAME_I' => $row['img_file_name'], 'S_VIEW_BY' => which_group($row['view_by']), 'S_VIEW_GROUPS' => $row['view_groups'], 'S_VIEW_ALL' => $row['view_all'], 'S_VIEW_PAGES' => $row['view_pages'], 'S_SCROLL' => $row['scroll'], 'S_HAS_VARS' => $row['has_vars'], 'S_MINIMOD_BASED' => $row['minimod_based'], 'S_MOD_BLOCK_ID' => $row['mod_block_id'], 'S_BLOCK_CACHE_TIME' => $row['block_cache_time'], 'S_BLOCK' => $row['id'] == $block ? $block : '.....'));
                    }
                    $db->sql_freeresult($result);
                }
                $template->assign_vars(array('S_OPTIONS' => strtoupper($mode), 'S_LBL' => $l_b_last - 1, 'S_RBL' => $r_b_last - 1, 'S_CBL' => $c_b_last - 1, 'S_LRC' => '1'));
                break;
            case 'default':
                break;
        }
        $template->assign_var('U_ACTION', $u_action);
    }
 /**
  * Prepares list of group options.
  *
  * @return array Each element of the resultion array is an array with group
  *   info. See {@link get_all_groups()} description for more details.
  */
 protected function getGroupsList()
 {
     $result = array();
     $all_groups = get_all_groups();
     $result[] = array('groupid' => '', 'vclocalname' => getlocal("-all operators-"), 'level' => 0);
     foreach ($all_groups as $g) {
         $result[] = $g;
     }
     return $result;
 }
示例#10
0
    function main($id, $mode)
    {
        global $db, $user, $auth, $template, $cache;
        global $k_config, $SID, $phpbb_root_path, $phpbb_admin_path, $phpEx;
        include $phpbb_root_path . 'includes/sgp_functions.' . $phpEx;
        include $phpbb_root_path . 'includes/sgp_functions_admin.' . $phpEx;
        $user->add_lang('acp/k_vars');
        $this->tpl_name = 'acp_k_vars';
        $this->page_title = 'ACP_K_VARS_CONFIG';
        $form_key = 'acp_k_vars';
        add_form_key($form_key);
        $choice = request_var('switch', '');
        $block = request_var('block', '');
        $mode = request_var('mode', '');
        $switch = request_var('switch', '');
        if ($block == '') {
            $block = 0;
        }
        if ($mode = 'config' && $choice == '') {
            $choice = 'config';
        }
        if (isset($block)) {
            $sql = "SELECT id, title, var_file_name\n\t\t\t\tFROM " . K_BLOCKS_TABLE . "\n\t\t\t\tWHERE id = " . (int) $block;
            $result = $db->sql_query($sql);
            $row = $db->sql_fetchrow($result);
            $title = strtoupper($row['title']);
            $title = str_replace(' ', '_', $row['title']);
            $block_id = $row['id'];
            $var_file_name = $row['var_file_name'];
            $db->sql_freeresult($result);
            get_all_groups();
        }
        $block = !empty($block) ? $block : 0;
        $action = request_var('action', '');
        $submit = isset($_POST['submit']) ? true : false;
        // swicth to other var setups 11 March 2010
        if ($switch) {
            get_reserved_words();
            $var_file_name = $switch;
        }
        $template->assign_vars(array('S_SWITCH' => $var_file_name));
        if ($submit && !check_form_key($form_key)) {
            $submit = false;
            $mode = '';
            trigger_error($user->lang['FORM_INVALID']);
        }
        //$wheresql = ' WHERE block_id = ' .  $block;
        $wheresql = '';
        $sql = 'SELECT config_name, config_value
			FROM ' . K_BLOCKS_CONFIG_VAR_TABLE . $wheresql;
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            $k_config[$row['config_name']] = $row['config_value'];
            $template->assign_var('S_' . strtoupper($row['config_name']), $row['config_value']);
        }
        $db->sql_freeresult($result);
        $template->assign_vars(array('S_OPT' => 'config', 'MESSAGE' => ''));
        if ($submit) {
            $mode = 'save';
        } else {
            $mode = 'reset';
        }
        switch ($mode) {
            case 'save':
                //$news_forum_id							= $_POST['news_forum_id'];
                $allow_acronyms = request_var('allow_acronyms', 1);
                $allow_announce = request_var('allow_announce', '');
                $allow_bot_display = request_var('allow_bot_display', '');
                $allow_footer_images = request_var('allow_footer_images', '');
                $allow_news = request_var('allow_news', '');
                $allow_rotating_logos = request_var('allow_rotating_logos', '');
                $announce_type = request_var('announce_type', '');
                $display_blocks_global = request_var('display_blocks_global', '');
                $link_forum_id = request_var('link_forum_id', '');
                $link_to_us_image = request_var('link_to_us_image', '');
                $max_announce_item_length = request_var('max_announce_item_length', '');
                $max_news_item_length = request_var('max_news_item_length', '');
                $news_type = request_var('news_type', '');
                $number_of_announce_items_to_display = request_var('number_of_announce_items_to_display', '');
                $number_of_bots_to_display = request_var('number_of_bots_to_display', '');
                $number_of_links_to_display = request_var('number_of_links_to_display', '');
                $number_of_news_items_to_display = request_var('number_of_news_items_to_display', '');
                $number_of_recent_topics_to_display = request_var('number_of_recent_topics_to_display', '');
                $number_of_topics_per_forum = request_var('number_of_topics_per_forum', '');
                $number_of_team_members_to_display = request_var('number_of_team_members_to_display', '');
                $number_of_top_posters_to_display = request_var('number_of_top_posters_to_display', '');
                $number_of_top_referrals_to_display = request_var('number_of_top_referrals_to_display', '');
                $teams_to_display = request_var('teams_to_display', '');
                $recent_topics_search_exclude = request_var('recent_topics_search_exclude', '');
                $mini_mod_style_count = request_var('mini_mod_style_count', '');
                $mini_mod_block_count = request_var('mini_mod_block_count', '');
                $mini_mod_mod_count = request_var('mini_mod_mod_count', '');
                $teamspeak_pw = request_var('teamspeak_pw', '');
                $teamspeak_connection = request_var('teamspeak_connection', '');
                $k_show_smilies = request_var('k_show_smilies', 1);
                $rand_banner = request_var('rand_banner', '');
                $rand_header = request_var('rand_header', '');
                $use_cookies = request_var('use_cookies', '');
                $opt_irc_channels = request_var('opt_irc_channels', '');
                $search_days = request_var('search_days', '');
                $post_types = request_var('post_types', '');
                $max_last_online = request_var('max_last_online', '');
                $max_top_topics = request_var('max_top_topics', '');
                $days_top_topics = request_var('days_top_topics', '');
                $age_range_interval = request_var('age_range_interval', '');
                $age_range_start = request_var('age_range_start', '');
                $age_upper_limit = request_var('age_upper_limit', '');
                $cloud_max_tags = request_var('cloud_max_tags', '');
                $cloud_movie = request_var('cloud_movie', '');
                $cloud_tcolour = request_var('cloud_tcolour', '');
                $cloud_tcolour2 = request_var('cloud_tcolour2', '');
                $cloud_hicolour = request_var('cloud_hicolour', '');
                $cloud_width = request_var('cloud_width', '');
                $cloud_height = request_var('cloud_height', '');
                $cloud_bg_colour = request_var('cloud_bg_colour', '');
                $cloud_speed = request_var('cloud_speed', '');
                $cloud_mode = request_var('cloud_mode', '');
                $cloud_wmode = request_var('cloud_wmode', '');
                $cloud_distr = request_var('cloud_distr', '');
                $cloud_search_allow = request_var('cloud_search_allow', 1);
                $cloud_search_cache = request_var('cloud_search_cache', 0);
                $teamspeak_pw = request_var('teamspeak_pw', '');
                $teamspeak_connection = request_var('teamspeak_connection', '');
                $sgp_quick_reply = request_var('sgp_quick_reply', 1);
                $k_yourtube_link = request_var('k_yourtube_link', '');
                $block_cache_time_default = request_var('block_cache_time_default', '');
                $block_recent_cache_time = request_var('block_recent_cache_time', '');
                switch ($announce_type) {
                    case 2:
                        $announce_type = POST_ANNOUNCE;
                        break;
                    case 3:
                        $announce_type = POST_GLOBAL;
                        break;
                    default:
                        $announce_type = 0;
                        break;
                }
                switch ($news_type) {
                    case 4:
                        $news_type = POST_NEWS;
                        break;
                    case 5:
                        $news_type = POST_NEWS_GLOBAL;
                        break;
                    default:
                        $news_type = 0;
                        break;
                }
                // all data is escaped in sgp_acp_set_config //
                //sgp_acp_set_config('news_forum_id', $news_forum_id);
                sgp_acp_set_config('allow_acronyms', $allow_acronyms);
                sgp_acp_set_config('allow_announce', $allow_announce);
                sgp_acp_set_config('allow_bot_display', $allow_bot_display);
                sgp_acp_set_config('allow_footer_images', $allow_footer_images);
                sgp_acp_set_config('allow_news', $allow_news);
                sgp_acp_set_config('allow_rotating_logos', $allow_rotating_logos);
                sgp_acp_set_config('announce_type', $announce_type);
                sgp_acp_set_config('display_blocks_global', $display_blocks_global);
                sgp_acp_set_config('k_show_smilies', $k_show_smilies);
                sgp_acp_set_config('link_to_us_image', $link_to_us_image);
                sgp_acp_set_config('link_forum_id', $link_forum_id);
                sgp_acp_set_config('news_type', $news_type, true);
                sgp_acp_set_config('number_of_announce_items_to_display', $number_of_announce_items_to_display);
                sgp_acp_set_config('number_of_bots_to_display', $number_of_bots_to_display);
                sgp_acp_set_config('number_of_links_to_display', $number_of_links_to_display);
                sgp_acp_set_config('number_of_news_items_to_display', $number_of_news_items_to_display);
                sgp_acp_set_config('max_news_item_length', $max_news_item_length);
                sgp_acp_set_config('max_announce_item_length', $max_announce_item_length);
                sgp_acp_set_config('number_of_recent_topics_to_display', $number_of_recent_topics_to_display);
                sgp_acp_set_config('number_of_topics_per_forum', $number_of_topics_per_forum);
                sgp_acp_set_config('number_of_team_members_to_display', $number_of_team_members_to_display);
                sgp_acp_set_config('number_of_top_posters_to_display', $number_of_top_posters_to_display);
                sgp_acp_set_config('number_of_top_referrals_to_display', $number_of_top_referrals_to_display);
                sgp_acp_set_config('teams_to_display', $teams_to_display);
                sgp_acp_set_config('recent_topics_search_exclude', $recent_topics_search_exclude);
                sgp_acp_set_config('rand_banner', $rand_banner);
                sgp_acp_set_config('rand_header', $rand_header);
                sgp_acp_set_config('use_cookies', $use_cookies);
                sgp_acp_set_config('opt_irc_channels', $opt_irc_channels);
                sgp_acp_set_config('search_days', $search_days);
                sgp_acp_set_config('post_types', $post_types);
                sgp_acp_set_config('max_last_online', $max_last_online);
                sgp_acp_set_config('max_top_topics', $max_top_topics);
                sgp_acp_set_config('days_top_topics', $days_top_topics);
                sgp_acp_set_config('age_range_interval', $age_range_interval);
                sgp_acp_set_config('age_range_start', $age_range_start);
                sgp_acp_set_config('age_upper_limit', $age_upper_limit);
                sgp_acp_set_config('mini_mod_style_count', $mini_mod_style_count);
                sgp_acp_set_config('mini_mod_block_count', $mini_mod_block_count);
                sgp_acp_set_config('mini_mod_mod_count', $mini_mod_mod_count);
                sgp_acp_set_config('cloud_tcolour', $cloud_tcolour);
                sgp_acp_set_config('cloud_tcolour2', $cloud_tcolour2);
                sgp_acp_set_config('cloud_hicolour', $cloud_hicolour);
                sgp_acp_set_config('cloud_width', $cloud_width);
                sgp_acp_set_config('cloud_height', $cloud_height);
                sgp_acp_set_config('cloud_bg_colour', $cloud_bg_colour);
                sgp_acp_set_config('cloud_speed', $cloud_speed);
                sgp_acp_set_config('cloud_mode', $cloud_mode);
                sgp_acp_set_config('cloud_wmode', $cloud_wmode);
                sgp_acp_set_config('cloud_distr', $cloud_distr);
                sgp_acp_set_config('cloud_search_allow', $cloud_search_allow);
                sgp_acp_set_config('cloud_search_cache', $cloud_search_cache);
                sgp_acp_set_config('teamspeak_pw', $teamspeak_pw);
                sgp_acp_set_config('teamspeak_connection', $teamspeak_connection);
                sgp_acp_set_config('sgp_quick_reply', $sgp_quick_reply);
                sgp_acp_set_config('k_yourtube_link', $k_yourtube_link);
                sgp_acp_set_config('block_cache_time_default', $block_cache_time_default);
                sgp_acp_set_config('block_recent_cache_time', $block_recent_cache_time);
                $mode = 'reset';
                $template->assign_vars(array('S_OPT' => $user->lang['SAVING'], 'MESSAGE' => $user->lang['SAVED']));
                $cache->destroy('sql', K_BLOCKS_CONFIG_VAR_TABLE);
                if ($block) {
                    meta_refresh(2, append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=k_vars&amp;mode=config&amp;block=" . $block));
                } else {
                    meta_refresh(2, append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=k_vars&amp;mode=config&amp;switch=" . $switch));
                }
                return;
            case 'default':
                break;
        }
        switch ($action) {
            case 'submit':
                $mode = 'reset';
                break;
            case 'default':
                break;
        }
    }
示例#11
0
 /**
  * Processes submitting of the form which is generated in
  * {@link \Mibew\Controller\Operator\GroupsController::showFormAction()}
  * method.
  *
  * @param Request $request Incoming request.
  * @return string Rendered page content.
  * @throws NotFoundException If the operator with specified ID is not found
  *   in the system.
  */
 public function submitFormAction(Request $request)
 {
     csrf_check_token($request);
     $operator = $this->getOperator();
     $operator_in_isolation = in_isolation($operator);
     $op_id = $request->attributes->getInt('operator_id');
     // Check if the target operator exists
     $op = operator_by_id($op_id);
     if (!$op) {
         throw new NotFoundException('The operator is not found.');
     }
     // Get all groups that are available for the target operator.
     $groups = $operator_in_isolation ? get_groups_for_operator($operator) : get_all_groups();
     // Build list of operator's new groups.
     $new_groups = array();
     foreach ($groups as $group) {
         if ($request->request->get('group' . $group['groupid']) == 'on') {
             $new_groups[] = $group['groupid'];
         }
     }
     // Update operator's group and redirect the current operator to the same
     // page using GET method.
     update_operator_groups($op['operatorid'], $new_groups);
     $redirect_to = $this->generateUrl('operator_groups', array('operator_id' => $op_id, 'stored' => true));
     return $this->redirect($redirect_to);
 }