/**
* Returns a list of <option> tags representing the list of forums
*
* @param	integer	Selected forum ID
* @param	boolean	Whether or not to display the 'Select Forum' option
* @param	string	If specified, name for the optional top element - no name, no display
* @param	string	Text to be used in sprintf() to indicate a 'category' forum, eg: '%s (Category)'. Leave blank for no category indicator
*
* @return	string	List of <option> tags
*/
function construct_forum_chooser($selectedid = -1, $displayselectforum = false, $topname = null, $category_phrase = null)
{
    return construct_select_options(construct_forum_chooser_options($displayselectforum, $topname, $category_phrase), $selectedid);
}
Example #2
0
File: ad.php Project: Kheros/MMOver
    foreach ($vbulletin->usergroupcache as $usergroupid => $usergroup) {
        $usergroup_options["{$usergroupid}"] = $usergroup['title'];
    }
    // build list of style names
    require_once DIR . '/includes/adminfunctions_template.php';
    cache_styles();
    $style_options = array();
    foreach ($stylecache as $style) {
        $style_options["{$style['styleid']}"] = $style['title'];
        $style_options["{$style['styleid']}"] = construct_depth_mark($style['depth'], '--') . ' ' . $style['title'];
    }
    // build the list of criteria options
    $criteria_options = array('in_usergroup_x' => array('<select name="criteria[in_usergroup_x][condition1]" tabindex="1">' . construct_select_options($usergroup_options, empty($criteria_cache['in_usergroup_x']) ? 2 : $criteria_cache['in_usergroup_x']['condition1']) . '</select>'), 'not_in_usergroup_x' => array('<select name="criteria[not_in_usergroup_x][condition1]" tabindex="1">' . construct_select_options($usergroup_options, empty($criteria_cache['not_in_usergroup_x']) ? 6 : $criteria_cache['not_in_usergroup_x']['condition1']) . '</select>'), 'browsing_content_page' => array('<select name="criteria[browsing_content_page][condition1]" tabindex="1">
				<option value="1"' . (empty($criteria_cache['browsing_content_page']['condition1']) ? ' selected="selected"' : '') . '>' . $vbphrase['content'] . '</option>
				<option value="0"' . ($criteria_cache['browsing_content_page']['condition1'] == 0 ? ' selected="selected"' : '') . '>' . $vbphrase['non_content'] . '</option>
			</select>'), 'browsing_forum_x' => array('<select name="criteria[browsing_forum_x][condition1]" tabindex="1">' . construct_select_options(construct_forum_chooser_options(), $criteria_cache['browsing_forum_x']['condition1']) . '</select>'), 'browsing_forum_x_and_children' => array('<select name="criteria[browsing_forum_x_and_children][condition1]" tabindex="1">' . construct_select_options(construct_forum_chooser_options(), $criteria_cache['browsing_forum_x_and_children']['condition1']) . '</select>'), 'style_is_x' => array('<select name="criteria[style_is_x][condition1]" tabindex="1">' . construct_select_options($style_options, $criteria_cache['style_is_x']['condition1']) . '</select>'), 'no_visit_in_x_days' => array('<input type="text" name="criteria[no_visit_in_x_days][condition1]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['no_visit_in_x_days']) ? 30 : intval($criteria_cache['no_visit_in_x_days']['condition1'])) . '" />'), 'no_posts_in_x_days' => array('<input type="text" name="criteria[no_posts_in_x_days][condition1]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['no_posts_in_x_days']) ? 30 : intval($criteria_cache['no_posts_in_x_days']['condition1'])) . '" />'), 'has_x_postcount' => array('<input type="text" name="criteria[has_x_postcount][condition1]" size="5" class="bginput" tabindex="1" value="' . $criteria_cache['has_x_postcount']['condition1'] . '" />', '<input type="text" name="criteria[has_x_postcount][condition2]" size="5" class="bginput" tabindex="1" value="' . $criteria_cache['has_x_postcount']['condition2'] . '" />'), 'has_never_posted' => array(), 'has_x_reputation' => array('<input type="text" name="criteria[has_x_reputation][condition1]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['has_x_reputation']) ? 100 : $criteria_cache['has_x_reputation']['condition1']) . '" />', '<input type="text" name="criteria[has_x_reputation][condition2]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['has_x_reputation']) ? 200 : $criteria_cache['has_x_reputation']['condition2']) . '" />'), 'pm_storage_x_percent_full' => array('<input type="text" name="criteria[pm_storage_x_percent_full][condition1]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['pm_storage_x_percent_full']) ? 90 : $criteria_cache['pm_storage_x_percent_full']['condition1']) . '" />', '<input type="text" name="criteria[pm_storage_x_percent_full][condition2]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['pm_storage_x_percent_full']) ? 100 : $criteria_cache['pm_storage_x_percent_full']['condition2']) . '" />'), 'came_from_search_engine' => array(), 'is_date' => array('<input type="text" name="criteria[is_date][condition1]" size="10" class="bginput" tabindex="1" value="' . (empty($criteria_cache['is_date']['condition1']) ? vbdate('d-m-Y', TIMENOW, false, false) : $criteria_cache['is_date']['condition1']) . '" />', '<select name="criteria[is_date][condition2]" tabindex="1">
				<option value="0"' . (empty($criteria_cache['is_date']['condition2']) ? ' selected="selected"' : '') . '>' . $vbphrase['user_timezone'] . '</option>
				<option value="1"' . ($criteria_cache['is_date']['condition2'] == 1 ? ' selected="selected"' : '') . '>' . $vbphrase['utc_universal_time'] . '</option>
			</select>'), 'is_time' => array('<input type="text" name="criteria[is_time][condition1]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['is_time']['condition1']) ? vbdate('H:i', TIMENOW, false, false) : $criteria_cache['is_time']['condition1']) . '" />', '<input type="text" name="criteria[is_time][condition2]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['is_time']['condition2']) ? intval(vbdate('H', TIMENOW, false, false)) + 1 . vbdate(':i', TIMENOW, false, false) : $criteria_cache['is_time']['condition2']) . '" />', '<select name="criteria[is_time][condition3]" tabindex="1">
				<option value="0"' . (empty($criteria_cache['is_time']['condition3']) ? ' selected="selected"' : '') . '>' . $vbphrase['user_timezone'] . '</option>
				<option value="1"' . ($criteria_cache['is_time']['condition3'] == 1 ? ' selected="selected"' : '') . '>' . $vbphrase['utc_universal_time'] . '</option>
			</select>'));
    if (sizeof($ad_name_cache)) {
        $criteria_options['ad_x_not_displayed'] = array('<select name="criteria[ad_x_not_displayed][condition1]" tabindex="1">' . construct_select_options($ad_name_cache, $criteria_cache['ad_x_not_displayed']['condition1']) . '</select>');
    }
    // hook to allow third-party additions of criteria
    ($hook = vBulletinHook::fetch_hook('ads_list_criteria')) ? eval($hook) : false;
    // build the editor form
    print_form_header('ad', 'update');
    construct_hidden_code('adid', $vbulletin->GPC['adid']);
    if ($vbulletin->GPC['ad_location_orig']) {
Example #3
0
    // build list of usergroup titles
    $usergroup_options = array();
    foreach ($vbulletin->usergroupcache as $usergroupid => $usergroup) {
        $usergroup_options["{$usergroupid}"] = $usergroup['title'];
    }
    // build list of style names
    require_once DIR . '/includes/adminfunctions_template.php';
    cache_styles();
    $style_options = array();
    foreach ($stylecache as $style) {
        $masterset = $vbphrase[$style['type'] . '_styles'];
        $style_options[$masterset]["{$style['styleid']}"] = $style['title'];
        $style_options[$masterset]["{$style['styleid']}"] = construct_depth_mark($style['depth'], '--') . ' ' . $style['title'];
    }
    // build the list of criteria options
    $criteria_options = array('in_usergroup_x' => array('<select name="criteria[in_usergroup_x][condition1]" tabindex="1">' . construct_select_options($usergroup_options, empty($criteria_cache['in_usergroup_x']) ? 2 : $criteria_cache['in_usergroup_x']['condition1']) . '</select>'), 'not_in_usergroup_x' => array('<select name="criteria[not_in_usergroup_x][condition1]" tabindex="1">' . construct_select_options($usergroup_options, empty($criteria_cache['not_in_usergroup_x']) ? 6 : $criteria_cache['not_in_usergroup_x']['condition1']) . '</select>'), 'browsing_forum_x' => array('<select name="criteria[browsing_forum_x][condition1]" tabindex="1">' . construct_select_options(construct_forum_chooser_options(), $criteria_cache['browsing_forum_x']['condition1']) . '</select>'), 'browsing_forum_x_and_children' => array('<select name="criteria[browsing_forum_x_and_children][condition1]" tabindex="1">' . construct_select_options(construct_forum_chooser_options(), $criteria_cache['browsing_forum_x_and_children']['condition1']) . '</select>'), 'style_is_x' => array('<select name="criteria[style_is_x][condition1]" tabindex="1">' . construct_select_options($style_options, $criteria_cache['style_is_x']['condition1']) . '</select>'), 'no_visit_in_x_days' => array('<input type="text" name="criteria[no_visit_in_x_days][condition1]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['no_visit_in_x_days']) ? 30 : intval($criteria_cache['no_visit_in_x_days']['condition1'])) . '" />'), 'no_posts_in_x_days' => array('<input type="text" name="criteria[no_posts_in_x_days][condition1]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['no_posts_in_x_days']) ? 30 : intval($criteria_cache['no_posts_in_x_days']['condition1'])) . '" />'), 'has_x_postcount' => array('<input type="text" name="criteria[has_x_postcount][condition1]" size="5" class="bginput" tabindex="1" value="' . $criteria_cache['has_x_postcount']['condition1'] . '" />', '<input type="text" name="criteria[has_x_postcount][condition2]" size="5" class="bginput" tabindex="1" value="' . $criteria_cache['has_x_postcount']['condition2'] . '" />'), 'has_never_posted' => array(), 'has_x_reputation' => array('<input type="text" name="criteria[has_x_reputation][condition1]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['has_x_reputation']) ? 100 : $criteria_cache['has_x_reputation']['condition1']) . '" />', '<input type="text" name="criteria[has_x_reputation][condition2]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['has_x_reputation']) ? 200 : $criteria_cache['has_x_reputation']['condition2']) . '" />'), 'has_x_infraction_points' => array('<input type="text" name="criteria[has_x_infraction_points][condition1]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['has_x_infraction_points']) ? 5 : $criteria_cache['has_x_infraction_points']['condition1']) . '" />', '<input type="text" name="criteria[has_x_infraction_points][condition2]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['has_x_infraction_points']) ? 10 : $criteria_cache['has_x_infraction_points']['condition2']) . '" />'), 'pm_storage_x_percent_full' => array('<input type="text" name="criteria[pm_storage_x_percent_full][condition1]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['pm_storage_x_percent_full']) ? 90 : $criteria_cache['pm_storage_x_percent_full']['condition1']) . '" />', '<input type="text" name="criteria[pm_storage_x_percent_full][condition2]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['pm_storage_x_percent_full']) ? 100 : $criteria_cache['pm_storage_x_percent_full']['condition2']) . '" />'), 'username_is' => array('<input type="text" name="criteria[username_is][condition1]" size="20" class="bginput" tabindex="1" value="' . (empty($criteria_cache['username_is']) ? $vbulletin->userinfo['username'] : htmlspecialchars_uni($criteria_cache['username_is']['condition1'])) . '" />'), 'is_birthday' => array(), 'came_from_search_engine' => array(), 'in_coventry' => array(), 'is_date' => array('<input type="text" name="criteria[is_date][condition1]" size="10" class="bginput" tabindex="1" value="' . (empty($criteria_cache['is_date']['condition1']) ? vbdate('d-m-Y', TIMENOW, false, false) : $criteria_cache['is_date']['condition1']) . '" />', '<select name="criteria[is_date][condition2]" tabindex="1">
				<option value="0"' . (empty($criteria_cache['is_date']['condition2']) ? ' selected="selected"' : '') . '>' . $vbphrase['user_timezone'] . '</option>
				<option value="1"' . ($criteria_cache['is_date']['condition2'] == 1 ? ' selected="selected"' : '') . '>' . $vbphrase['utc_universal_time'] . '</option>
			</select>'), 'is_time' => array('<input type="text" name="criteria[is_time][condition1]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['is_time']['condition1']) ? vbdate('H:i', TIMENOW, false, false) : $criteria_cache['is_time']['condition1']) . '" />', '<input type="text" name="criteria[is_time][condition2]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['is_time']['condition2']) ? intval(vbdate('H', TIMENOW, false, false)) + 1 . vbdate(':i', TIMENOW, false, false) : $criteria_cache['is_time']['condition2']) . '" />', '<select name="criteria[is_time][condition3]" tabindex="1">
				<option value="0"' . (empty($criteria_cache['is_time']['condition3']) ? ' selected="selected"' : '') . '>' . $vbphrase['user_timezone'] . '</option>
				<option value="1"' . ($criteria_cache['is_time']['condition3'] == 1 ? ' selected="selected"' : '') . '>' . $vbphrase['utc_universal_time'] . '</option>
			</select>'));
    if (!empty($notice_name_cache)) {
        $criteria_options['notice_x_not_displayed'] = array('<select name="criteria[notice_x_not_displayed][condition1]" tabindex="1">' . construct_select_options($notice_name_cache, $criteria_cache['notice_x_not_displayed']['condition1']) . '</select>');
    }
    // hook to allow third-party additions of criteria
    ($hook = vBulletinHook::fetch_hook('notices_list_criteria')) ? eval($hook) : false;
    // build the editor form
    print_form_header('notice', 'update');
    construct_hidden_code('noticeid', $vbulletin->GPC['noticeid']);
    print_table_header($table_title);
Example #4
0
/**
* Prints a setting row for use in options.php?do=options
*
* @param	array	Settings array
* @param	array	Phrases
*/
function print_setting_row($setting, $settingphrase, $option_config = true)
{
    global $vbulletin, $vbphrase, $bgcounter, $settingphrase;
    $settingid = $setting['varname'];
    echo '<tbody>';
    print_description_row(iif($vbulletin->debug and $option_config, '<div class="smallfont" style="float:' . vB_Template_Runtime::fetchStyleVar('right') . '">' . construct_link_code($vbphrase['edit'], "options.php?" . $vbulletin->session->vars['sessionurl'] . "do=editsetting&amp;varname={$setting['varname']}") . construct_link_code($vbphrase['delete'], "options.php?" . $vbulletin->session->vars['sessionurl'] . "do=removesetting&amp;varname={$setting['varname']}") . '</div>') . '<div>' . $settingphrase["setting_{$setting['varname']}_title"] . "<a name=\"{$setting['varname']}\"></a></div>", 0, 2, 'optiontitle' . ($vbulletin->debug ? "\" title=\"\$vbulletin->options['" . $setting['varname'] . "']" : ''));
    echo "</tbody><tbody id=\"tbody_{$settingid}\">\r\n";
    // make sure all rows use the alt1 class
    $bgcounter--;
    $description = "<div class=\"smallfont\"" . ($vbulletin->debug ? "title=\"\$vbulletin->options['{$setting['varname']}']\"" : '') . ">" . $settingphrase["setting_{$setting['varname']}_desc"] . '</div>';
    $name = "setting[{$setting['varname']}]";
    $right = "<span class=\"smallfont\">{$vbphrase['error']}</span>";
    $width = 40;
    $rows = 8;
    if (preg_match('#^input:?(\\d+)$#s', $setting['optioncode'], $matches)) {
        $width = $matches[1];
        $setting['optioncode'] = '';
    } else {
        if (preg_match('#^textarea:?(\\d+)(,(\\d+))?$#s', $setting['optioncode'], $matches)) {
            $rows = $matches[1];
            if ($matches[2]) {
                $width = $matches[3];
            }
            $setting['optioncode'] = 'textarea';
        } else {
            if (preg_match('#^bitfield:(.*)$#siU', $setting['optioncode'], $matches)) {
                $setting['optioncode'] = 'bitfield';
                $setting['bitfield'] =& fetch_bitfield_definitions($matches[1]);
            } else {
                if (preg_match('#^(select|selectmulti|radio):(piped|eval)(\\r\\n|\\n|\\r)(.*)$#siU', $setting['optioncode'], $matches)) {
                    $setting['optioncode'] = "{$matches['1']}:{$matches['2']}";
                    $setting['optiondata'] = trim($matches[4]);
                } else {
                    if (preg_match('#^usergroup:?(\\d+)$#s', $setting['optioncode'], $matches)) {
                        $size = intval($matches[1]);
                        $setting['optioncode'] = 'usergroup';
                    } else {
                        if (preg_match('#^(usergroupextra)(\\r\\n|\\n|\\r)(.*)$#siU', $setting['optioncode'], $matches)) {
                            $setting['optioncode'] = 'usergroupextra';
                            $setting['optiondata'] = trim($matches[3]);
                        } else {
                            if (preg_match('#^profilefield:?([a-z0-9,;=]*)(?:\\r\\n|\\n|\\r)(.*)$#siU', $setting['optioncode'], $matches)) {
                                $setting['optioncode'] = 'profilefield';
                                $setting['optiondata'] = array('constraints' => trim($matches[1]), 'extraoptions' => trim($matches[2]));
                            } else {
                                if (preg_match('#^apipostidmanage(?:\\r\\n|\\n|\\r)(.*)$#siU', $setting['optioncode'], $matches)) {
                                    $setting['optioncode'] = 'apipostidmanage';
                                    $setting['optiondata'] = preg_split("#(\r\n|\n|\r)#s", $matches[1], -1, PREG_SPLIT_NO_EMPTY);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    switch ($setting['optioncode']) {
        // input type="text"
        case '':
            print_input_row($description, $name, $setting['value'], 1, $width);
            break;
            // input type="radio"
        // input type="radio"
        case 'yesno':
            print_yes_no_row($description, $name, $setting['value']);
            break;
            // textarea
        // textarea
        case 'textarea':
            print_textarea_row($description, $name, $setting['value'], $rows, "{$width}\" style=\"width:90%");
            break;
            // bitfield
        // bitfield
        case 'bitfield':
            $setting['value'] = intval($setting['value']);
            $setting['html'] = '';
            if ($setting['bitfield'] === NULL) {
                print_label_row($description, construct_phrase("<strong>{$vbphrase['settings_bitfield_error']}</strong>", implode(',', vB_Bitfield_Builder::fetch_errors())), '', 'top', $name, 40);
            } else {
                #$setting['html'] .= "<fieldset><legend>$vbphrase[yes] / $vbphrase[no]</legend>";
                $setting['html'] .= "<div id=\"ctrl_setting[{$setting['varname']}]\" class=\"smallfont\">\r\n";
                $setting['html'] .= "<input type=\"hidden\" name=\"setting[{$setting['varname']}][0]\" value=\"0\" />\r\n";
                foreach ($setting['bitfield'] as $key => $value) {
                    $value = intval($value);
                    $setting['html'] .= "<table style=\"width:175px; float:" . vB_Template_Runtime::fetchStyleVar('left') . "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr valign=\"top\">\n\t\t\t\t\t<td><input type=\"checkbox\" name=\"setting[{$setting['varname']}][{$value}]\" id=\"setting[{$setting['varname']}]_{$key}\" value=\"{$value}\"" . ($setting['value'] & $value ? ' checked="checked"' : '') . " /></td>\n\t\t\t\t\t<td width=\"100%\" style=\"padding-top:4px\"><label for=\"setting[{$setting['varname']}]_{$key}\" class=\"smallfont\">" . fetch_phrase_from_key($key) . "</label></td>\r\n</tr></table>\r\n";
                }
                $setting['html'] .= "</div>\r\n";
                #$setting['html'] .= "</fieldset>";
                print_label_row($description, $setting['html'], '', 'top', $name, 40);
            }
            break;
            // select:piped
        // select:piped
        case 'select:piped':
            print_select_row($description, $name, fetch_piped_options($setting['optiondata']), $setting['value']);
            break;
            // radio:piped
        // radio:piped
        case 'radio:piped':
            print_radio_row($description, $name, fetch_piped_options($setting['optiondata']), $setting['value'], 'smallfont');
            break;
            // select:eval
        // select:eval
        case 'select:eval':
            $options = null;
            eval($setting['optiondata']);
            if (is_array($options) and !empty($options)) {
                print_select_row($description, $name, $options, $setting['value']);
            } else {
                print_input_row($description, $name, $setting['value']);
            }
            break;
            // select:eval
        // select:eval
        case 'selectmulti:eval':
            $options = null;
            eval($setting['optiondata']);
            if (is_array($options) and !empty($options)) {
                print_select_row($description, $name . '[]', $options, $setting['value'], false, 5, true);
            } else {
                print_input_row($description, $name, $setting['value']);
            }
            break;
            // radio:eval
        // radio:eval
        case 'radio:eval':
            $options = null;
            eval($setting['optiondata']);
            if (is_array($options) and !empty($options)) {
                print_radio_row($description, $name, $options, $setting['value'], 'smallfont');
            } else {
                print_input_row($description, $name, $setting['value']);
            }
            break;
        case 'username':
            if (intval($setting['value']) and $userinfo = $vbulletin->db->query_first("SELECT username FROM " . TABLE_PREFIX . "user WHERE userid = " . intval($setting['value']))) {
                print_input_row($description, $name, $userinfo['username'], false);
            } else {
                print_input_row($description, $name);
            }
            break;
        case 'usergroup':
            $usergrouplist = array();
            foreach ($vbulletin->usergroupcache as $usergroup) {
                $usergrouplist["{$usergroup['usergroupid']}"] = $usergroup['title'];
            }
            if ($size > 1) {
                print_select_row($description, $name . '[]', array(0 => '') + $usergrouplist, unserialize($setting['value']), false, $size, true);
            } else {
                print_select_row($description, $name, $usergrouplist, $setting['value']);
            }
            break;
        case 'usergroupextra':
            $usergrouplist = fetch_piped_options($setting['optiondata']);
            foreach ($vbulletin->usergroupcache as $usergroup) {
                $usergrouplist["{$usergroup['usergroupid']}"] = $usergroup['title'];
            }
            print_select_row($description, $name, $usergrouplist, $setting['value']);
            break;
        case 'profilefield':
            static $profilefieldlistcache = array();
            $profilefieldlisthash = md5(serialize($setting['optiondata']));
            if (!isset($profilefieldlistcache[$profilefieldlisthash])) {
                $profilefieldlist = fetch_piped_options($setting['optiondata']['extraoptions']);
                $constraints = preg_split('#;#', $setting['optiondata']['constraints'], -1, PREG_SPLIT_NO_EMPTY);
                $where = array();
                foreach ($constraints as $constraint) {
                    $constraint = explode('=', $constraint);
                    switch ($constraint[0]) {
                        case 'editablegt':
                            $where[] = 'editable > ' . intval($constraint[1]);
                            break;
                        case 'types':
                            $constraint[1] = preg_split('#,#', $constraint[1], -1, PREG_SPLIT_NO_EMPTY);
                            if (!empty($constraint[1])) {
                                $where[] = "type IN('" . implode("', '", array_map(array($vbulletin->db, 'escape_string'), $constraint[1])) . "')";
                            }
                            break;
                    }
                }
                $profilefields = $vbulletin->db->query_read_slave("\n\t\t\t\t\tSELECT *\n\t\t\t\t\tFROM " . TABLE_PREFIX . "profilefield\n\t\t\t\t\t" . (!empty($where) ? 'WHERE ' . implode(' AND ', $where) : '') . "\n\t\t\t\t\tORDER BY displayorder\n\t\t\t\t");
                while ($profilefield = $vbulletin->db->fetch_array($profilefields)) {
                    $fieldname = "field{$profilefield['profilefieldid']}";
                    $profilefieldlist[$fieldname] = construct_phrase($vbphrase['profilefield_x_fieldid_y'], fetch_phrase_from_key("{$fieldname}_title"), $fieldname);
                }
                $profilefieldlistcache[$profilefieldlisthash] = $profilefieldlist;
                unset($profilefieldlist, $constraints, $constraint, $where, $profilefields, $profilefield, $fieldname);
            }
            print_select_row($description, $name, $profilefieldlistcache[$profilefieldlisthash], $setting['value']);
            break;
            // arbitrary number of <input type="text" />
        // arbitrary number of <input type="text" />
        case 'multiinput':
            $setting['html'] = "<div id=\"ctrl_{$setting['varname']}\"><fieldset id=\"multi_input_fieldset_{$setting['varname']}\" style=\"padding:4px\">";
            $setting['values'] = unserialize($setting['value']);
            $setting['values'] = is_array($setting['values']) ? $setting['values'] : array();
            $setting['values'][] = '';
            foreach ($setting['values'] as $key => $value) {
                $setting['html'] .= "<div id=\"multi_input_container_{$setting['varname']}_{$key}\">" . ($key + 1) . " <input type=\"text\" class=\"bginput\" name=\"setting[{$setting['varname']}][{$key}]\" id=\"multi_input_{$setting['varname']}_{$key}\" size=\"40\" value=\"" . htmlspecialchars_uni($value) . "\" tabindex=\"1\" /></div>";
            }
            $i = sizeof($setting['values']);
            if ($i == 0) {
                $setting['html'] .= "<div><input type=\"text\" class=\"bginput\" name=\"setting[{$setting['varname']}][{$i}]\" size=\"40\" tabindex=\"1\" /></div>";
            }
            $setting['html'] .= "\n\t\t\t\t</fieldset>\n\t\t\t\t<div class=\"smallfont\"><a href=\"#\" onclick=\"return multi_input['{$setting['varname']}'].add()\">Add Another Option</a></div>\n\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t<!--\n\t\t\t\tmulti_input['{$setting['varname']}'] = new vB_Multi_Input('{$setting['varname']}', {$i}, '" . $vbulletin->options['cpstylefolder'] . "');\n\t\t\t\t//-->\n\t\t\t\t</script>\n\t\t\t";
            print_label_row($description, $setting['html']);
            break;
            // activity stream options
        // activity stream options
        case 'activitystream':
            $options = array();
            $activities = $vbulletin->db->query_read("\n\t\t\t\tSELECT\n\t\t\t\t\ttypeid, section, type, enabled\n\t\t\t\tFROM " . TABLE_PREFIX . "activitystreamtype AS a\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "package AS p ON (p.packageid = a.packageid)\n\t\t\t\tORDER BY section, type\n\t\t\t");
            while ($activity = $vbulletin->db->fetch_array($activities)) {
                $options["{$activity['section']}_{$activity['type']}"] = $activity;
            }
            $setting['html'] = '';
            $setting['html'] .= "<div id=\"ctrl_setting[{$setting['varname']}]\" class=\"smallfont\">\r\n";
            $setting['html'] .= "<input type=\"hidden\" name=\"setting[{$setting['varname']}][0]\" value=\"0\" />\r\n";
            foreach ($options as $key => $activity) {
                $setting['html'] .= "<table style=\"width:175px; float:" . vB_Template_Runtime::fetchStyleVar('left') . "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr valign=\"top\">\n\t\t\t\t<td><input type=\"checkbox\" name=\"setting[{$setting['varname']}][{$activity['typeid']}]\" id=\"setting[{$setting['varname']}]_{$key}\" value=\"1\"" . ($activity['enabled'] ? ' checked="checked"' : '') . " /></td>\n\t\t\t\t<td width=\"100%\" style=\"padding-top:4px\"><label for=\"setting[{$setting['varname']}]_{$key}\" class=\"smallfont\">" . fetch_phrase_from_key($key) . "</label></td>\r\n</tr></table>\r\n";
            }
            print_label_row($description, $setting['html'], '', 'top', $name, 40);
            break;
            // default registration options
        // default registration options
        case 'defaultregoptions':
            $setting['value'] = intval($setting['value']);
            $checkbox_options = array('receiveemail' => 'display_email', 'adminemail' => 'receive_admin_emails', 'invisiblemode' => 'invisible_mode', 'vcard' => 'allow_vcard_download', 'signature' => 'display_signatures', 'avatar' => 'display_avatars', 'image' => 'display_images', 'showreputation' => 'display_reputation', 'enablepm' => 'receive_private_messages', 'emailonpm' => 'send_notification_email_when_a_private_message_is_received', 'pmpopup' => 'pop_up_notification_box_when_a_private_message_is_received');
            $setting['value'] = intval($setting['value']);
            $setting['html'] = '';
            #$setting['html'] .= "<fieldset><legend>$vbphrase[yes] / $vbphrase[no]</legend>";
            $setting['html'] .= "<div id=\"ctrl_setting[{$setting['varname']}]\" class=\"smallfont\">\r\n";
            $setting['html'] .= "<input type=\"hidden\" name=\"setting[{$setting['varname']}][0]\" value=\"0\" />\r\n";
            foreach ($checkbox_options as $key => $phrase) {
                $value = $vbulletin->bf_misc_regoptions["{$key}"];
                $setting['html'] .= "<table style=\"width:175px; float:" . vB_Template_Runtime::fetchStyleVar('left') . "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr valign=\"top\">\n\t\t\t\t<td><input type=\"checkbox\" name=\"setting[{$setting['varname']}][{$value}]\" id=\"setting[{$setting['varname']}]_{$key}\" value=\"{$value}\"" . ($setting['value'] & $value ? ' checked="checked"' : '') . " /></td>\n\t\t\t\t<td width=\"100%\" style=\"padding-top:4px\"><label for=\"setting[{$setting['varname']}]_{$key}\" class=\"smallfont\">" . fetch_phrase_from_key($phrase) . "</label></td>\r\n</tr></table>\r\n";
            }
            #$setting['html'] .= "</fieldset>";
            print_label_row($description, $setting['html'], '', 'top', $name, 40);
            break;
            // cp folder options
        // cp folder options
        case 'cpstylefolder':
            if ($folders = fetch_cpcss_options() and !empty($folders)) {
                print_select_row($description, $name, $folders, $setting['value'], 1, 6);
            } else {
                print_input_row($description, $name, $setting['value'], 1, 40);
            }
            break;
        case 'apipostidmanage':
            $setting['html'] = "<div id=\"ctrl_apipostidmanage\"><fieldset id=\"multi_input_fieldset_apipostidmanage}\" style=\"padding:4px\">";
            $setting['values'] = unserialize($setting['value']);
            $setting['values'] = is_array($setting['values']) ? $setting['values'] : array();
            $setting['html'] .= "\n\t\t\t\t<div style=\"padding:4px\">\n\t\t\t\t\t<span style=\"display:block\">{$vbphrase['apipostidmanage_enable']}</span>\n\t\t\t\t\t<label for=\"multi_input_apipostidmanage_enable1\" />\n\t\t\t\t\t\t<input type=\"radio\"" . ($setting['values']['enable'] ? ' checked="checked" ' : '') . "class=\"bginput\" name=\"setting[apipostidmanage][enable]\" id=\"multi_input_apipostidmanage_enable1\"  value=\"1\" tabindex=\"1\" />\n\t\t\t\t\t\t{$vbphrase['yes']}\n\t\t\t\t\t</label>\n\t\t\t\t\t<label for=\"multi_input_{$setting['varname']}_enable2\" />\n\t\t\t\t\t\t<input type=\"radio\"" . (!$setting['values']['enable'] ? ' checked="checked" ' : '') . "class=\"bginput\" name=\"setting[apipostidmanage][enable]\" id=\"multi_input_apipostidmanage_enable2\"  value=\"0\" tabindex=\"1\" />\n\t\t\t\t\t\t{$vbphrase['no']}\n\t\t\t\t\t</label>\n\t\t\t\t</div>";
            foreach ($setting['optiondata'] as $device) {
                if (!$vbphrase['apipostidmanage_' . $device]) {
                    continue;
                }
                $setting['html'] .= "<div style=\"padding:4px\">\n\t\t\t\t\t<span style=\"display:block\">" . $vbphrase['apipostidmanage_' . $device] . "</span>\n\t\t\t\t\t<input type=\"text\" class=\"bginput\" name=\"setting[apipostidmanage][{$device}]\" id=\"multi_input_apipostidmanage_{$device}\" size=\"50\" value=\"" . htmlspecialchars_uni($setting['values'][$device]) . "\" tabindex=\"1\" />\n\t\t\t\t</div>";
            }
            $setting['html'] .= "</fieldset></div>";
            print_label_row($description, $setting['html'], '', 'top', 'apipostidmanage');
            break;
            break;
            // cookiepath / cookiedomain options
        // cookiepath / cookiedomain options
        case 'cookiepath':
        case 'cookiedomain':
            $func = 'fetch_valid_' . $setting['optioncode'] . 's';
            $cookiesettings = $func($setting['optioncode'] == 'cookiepath' ? $vbulletin->script : $_SERVER['HTTP_HOST'], $vbphrase['blank']);
            $setting['found'] = in_array($setting['value'], array_keys($cookiesettings));
            $setting['html'] = "\n\t\t\t<div id=\"ctrl_{$setting['varname']}\">\n\t\t\t<fieldset>\n\t\t\t\t<legend>{$vbphrase['suggested_settings']}</legend>\n\t\t\t\t<div style=\"padding:4px\">\n\t\t\t\t\t<select name=\"setting[{$setting['varname']}]\" tabindex=\"1\" class=\"bginput\">" . construct_select_options($cookiesettings, $setting['value']) . "\n\t\t\t\t\t</select>\n\t\t\t\t</div>\n\t\t\t</fieldset>\n\t\t\t<br />\n\t\t\t<fieldset>\n\t\t\t\t<legend>{$vbphrase['custom_setting']}</legend>\n\t\t\t\t<div style=\"padding:4px\">\n\t\t\t\t\t<label for=\"{$settingid}o\"><input type=\"checkbox\" id=\"{$settingid}o\" name=\"setting[{$settingid}_other]\" tabindex=\"1\" value=\"1\"" . ($setting['found'] ? '' : ' checked="checked"') . " />{$vbphrase['use_custom_setting']}\n\t\t\t\t\t</label><br />\n\t\t\t\t\t<input type=\"text\" class=\"bginput\" size=\"25\" name=\"setting[{$settingid}_value]\" value=\"" . ($setting['found'] ? '' : $setting['value']) . "\" />\n\t\t\t\t</div>\n\t\t\t</fieldset>\n\t\t\t</div>";
            print_label_row($description, $setting['html'], '', 'top', $name, 50);
            break;
        case 'facebooksslcheck':
            require_once DIR . '/includes/class_vurl.php';
            $vurl = new vB_vURL($vbulletin);
            $result = $vurl->test_ssl();
            print_label_row($description, $result ? $vbphrase['supported'] : $vbphrase['not_supported']);
            break;
        case 'usergroups:none':
            $array = build_usergroup_list($vbphrase['none'], 0);
            $size = sizeof($array);
            print_select_row($description, $name . '[]', $array, unserialize($setting['value']), false, $size > 10 ? 10 : $size, true);
            break;
        case 'usergroups:all':
            $array = build_usergroup_list($vbphrase['all'], -1);
            $size = sizeof($array);
            print_select_row($description, $name . '[]', $array, unserialize($setting['value']), false, $size > 10 ? 10 : $size, true);
            break;
        case 'forums:all':
            $array = construct_forum_chooser_options(-1, $vbphrase['all']);
            $size = sizeof($array);
            $vbphrase[forum_is_closed_for_posting] = $vbphrase[closed];
            print_select_row($description, $name . '[]', $array, unserialize($setting['value']), false, $size > 10 ? 10 : $size, true);
            break;
        case 'forums:none':
            $array = construct_forum_chooser_options(0, $vbphrase['none']);
            $size = sizeof($array);
            $vbphrase[forum_is_closed_for_posting] = $vbphrase[closed];
            print_select_row($description, $name . '[]', $array, unserialize($setting['value']), false, $size > 10 ? 10 : $size, true);
            break;
            // just a label
        // just a label
        default:
            $handled = false;
            ($hook = vBulletinHook::fetch_hook('admin_options_print')) ? eval($hook) : false;
            if (!$handled) {
                eval("\$right = \"<div id=\\\"ctrl_setting[{$setting['varname']}]\\\">{$setting['optioncode']}</div>\";");
                print_label_row($description, $right, '', 'top', $name, 50);
            }
            break;
    }
    echo "</tbody>\r\n";
    $valid = exec_setting_validation_code($setting['varname'], $setting['value'], $setting['validationcode']);
    echo "<tbody id=\"tbody_error_{$settingid}\" style=\"display:" . (($valid === 1 or $valid === true) ? 'none' : '') . "\"><tr><td class=\"alt1 smallfont\" colspan=\"2\"><div style=\"padding:4px; border:solid 1px red; background-color:white; color:black\"><strong>{$vbphrase['error']}</strong>:<div id=\"span_error_{$settingid}\">{$valid}</div></div></td></tr></tbody>";
}
/**
* Prints a setting row for use in options.php?do=options
*
* @param	array	Settings array
* @param	array	Phrases
*/
function print_setting_row($setting, $settingphrase, $option_config = true, $userContext = false)
{
    global $vbulletin, $bgcounter, $vbphrase;
    $settingid = $setting['varname'];
    if (empty($userContext)) {
        $userContext = vB::getUserContext();
    }
    echo '<tbody>';
    $vb5_config = vB::getConfig();
    print_description_row(iif($vb5_config['Misc']['debug'] and $option_config and $userContext->hasAdminPermission('canadminsettingsall'), '<div class="smallfont" style="float:' . vB_Template_Runtime::fetchStyleVar('right') . '">' . construct_link_code($vbphrase['edit'], "options.php?" . vB::getCurrentSession()->get('sessionurl') . "do=editsetting&amp;varname={$setting['varname']}") . construct_link_code($vbphrase['delete'], "options.php?" . vB::getCurrentSession()->get('sessionurl') . "do=removesetting&amp;varname={$setting['varname']}") . '</div>') . '<div>' . $settingphrase["setting_{$setting['varname']}_title"] . "<a name=\"{$setting['varname']}\"></a></div>", 0, 2, 'optiontitle' . ($vb5_config['Misc']['debug'] ? "\" title=\"\$vbulletin->options['" . $setting['varname'] . "']" : ''));
    echo "</tbody><tbody id=\"tbody_{$settingid}\">\r\n";
    // make sure all rows use the alt1 class
    $bgcounter--;
    $description = "<div class=\"smallfont\"" . ($vb5_config['Misc']['debug'] ? " title=\"\$vbulletin->options['{$setting['varname']}']\"" : '') . ">" . $settingphrase["setting_{$setting['varname']}_desc"] . '</div>';
    $name = "setting[{$setting['varname']}]";
    $right = "<span class=\"smallfont\">{$vbphrase['error']}</span>";
    $width = 40;
    $rows = 8;
    if (preg_match('#^input:?(\\d+)$#s', $setting['optioncode'], $matches)) {
        $width = $matches[1];
        $setting['optioncode'] = '';
    } else {
        if (preg_match('#^textarea:?(\\d+)(,(\\d+))?$#s', $setting['optioncode'], $matches)) {
            $rows = $matches[1];
            if ($matches[2]) {
                $width = $matches[3];
            }
            $setting['optioncode'] = 'textarea';
        } else {
            if (preg_match('#^bitfield:(.*)$#siU', $setting['optioncode'], $matches)) {
                $setting['optioncode'] = 'bitfield';
                $setting['bitfield'] =& fetch_bitfield_definitions($matches[1]);
            } else {
                if (preg_match('#^(select|selectmulti|radio):(piped|eval)(\\r\\n|\\n|\\r)(.*)$#siU', $setting['optioncode'], $matches)) {
                    $setting['optioncode'] = "{$matches['1']}:{$matches['2']}";
                    $setting['optiondata'] = trim($matches[4]);
                } else {
                    if (preg_match('#^usergroup:?(\\d+)$#s', $setting['optioncode'], $matches)) {
                        $size = intval($matches[1]);
                        $setting['optioncode'] = 'usergroup';
                    } else {
                        if (preg_match('#^(usergroupextra)(\\r\\n|\\n|\\r)(.*)$#siU', $setting['optioncode'], $matches)) {
                            $setting['optioncode'] = 'usergroupextra';
                            $setting['optiondata'] = trim($matches[3]);
                        } else {
                            if (preg_match('#^profilefield:?([a-z0-9,;=]*)(?:\\r\\n|\\n|\\r)(.*)$#siU', $setting['optioncode'], $matches)) {
                                $setting['optioncode'] = 'profilefield';
                                $setting['optiondata'] = array('constraints' => trim($matches[1]), 'extraoptions' => trim($matches[2]));
                            }
                        }
                    }
                }
            }
        }
    }
    // Make setting's value the default value if it's null
    if ($setting['value'] === NULL) {
        $setting['value'] = $setting['defaultvalue'];
    }
    switch ($setting['optioncode']) {
        // input type="text"
        case '':
            print_input_row($description, $name, $setting['value'], 1, $width);
            break;
            // input type="radio"
        // input type="radio"
        case 'yesno':
            print_yes_no_row($description, $name, $setting['value']);
            break;
            // textarea
        // textarea
        case 'textarea':
            print_textarea_row($description, $name, $setting['value'], $rows, "{$width}\" style=\"width:90%");
            break;
            // bitfield
        // bitfield
        case 'bitfield':
            $setting['value'] = intval($setting['value']);
            $setting['html'] = '';
            if ($setting['bitfield'] === NULL) {
                print_label_row($description, construct_phrase("<strong>{$vbphrase['settings_bitfield_error']}</strong>", implode(',', vB_Bitfield_Builder::fetch_errors())), '', 'top', $name, 40);
            } else {
                #$setting['html'] .= "<fieldset><legend>$vbphrase[yes] / $vbphrase[no]</legend>";
                $setting['html'] .= "<div id=\"ctrl_setting[{$setting['varname']}]\" class=\"smallfont\">\r\n";
                $setting['html'] .= "<input type=\"hidden\" name=\"setting[{$setting['varname']}][0]\" value=\"0\" />\r\n";
                foreach ($setting['bitfield'] as $key => $value) {
                    $value = intval($value);
                    $setting['html'] .= "<table style=\"width:175px; float:" . vB_Template_Runtime::fetchStyleVar('left') . "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr valign=\"top\">\n\t\t\t\t\t<td><input type=\"checkbox\" name=\"setting[{$setting['varname']}][{$value}]\" id=\"setting[{$setting['varname']}]_{$key}\" value=\"{$value}\"" . ($setting['value'] & $value ? ' checked="checked"' : '') . " /></td>\n\t\t\t\t\t<td width=\"100%\" style=\"padding-top:4px\"><label for=\"setting[{$setting['varname']}]_{$key}\" class=\"smallfont\">" . fetch_phrase_from_key($key) . "</label></td>\r\n</tr></table>\r\n";
                }
                $setting['html'] .= "</div>\r\n";
                #$setting['html'] .= "</fieldset>";
                print_label_row($description, $setting['html'], '', 'top', $name, 40);
            }
            break;
            // select:piped
        // select:piped
        case 'select:piped':
            print_select_row($description, $name, fetch_piped_options($setting['optiondata']), $setting['value']);
            break;
            // radio:piped
        // radio:piped
        case 'radio:piped':
            print_radio_row($description, $name, fetch_piped_options($setting['optiondata']), $setting['value'], 'smallfont');
            break;
            // select:eval
        // select:eval
        case 'select:eval':
            $options = null;
            eval($setting['optiondata']);
            if (is_array($options) and !empty($options)) {
                print_select_row($description, $name, $options, $setting['value'], true);
            } else {
                print_input_row($description, $name, $setting['value']);
            }
            break;
            // select:eval
        // select:eval
        case 'selectmulti:eval':
            $options = null;
            eval($setting['optiondata']);
            if (is_array($options) and !empty($options)) {
                print_select_row($description, $name . '[]', $options, $setting['value'], false, 5, true);
            } else {
                print_input_row($description, $name, $setting['value']);
            }
            break;
            // radio:eval
        // radio:eval
        case 'radio:eval':
            $options = null;
            eval($setting['optiondata']);
            if (is_array($options) and !empty($options)) {
                print_radio_row($description, $name, $options, $setting['value'], 'smallfont');
            } else {
                print_input_row($description, $name, $setting['value']);
            }
            break;
        case 'username':
            $userinfo = vB::getDbAssertor()->assertQuery('user', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'userid' => $setting['value']));
            if (intval($setting['value']) and $userinfo and $userinfo->valid()) {
                $userInfo = $userinfo->current();
                print_input_row($description, $name, $userInfo['username'], false);
            } else {
                print_input_row($description, $name);
            }
            break;
        case 'usergroup':
            $usergrouplist = array();
            $usergroupcache = vB::getDatastore()->get_value('usergroupcache');
            foreach ($usergroupcache as $usergroup) {
                $usergrouplist["{$usergroup['usergroupid']}"] = $usergroup['title'];
            }
            if ($size > 1) {
                print_select_row($description, $name . '[]', array(0 => '') + $usergrouplist, unserialize($setting['value']), false, $size, true);
            } else {
                print_select_row($description, $name, $usergrouplist, $setting['value']);
            }
            break;
        case 'usergroupextra':
            $usergrouplist = fetch_piped_options($setting['optiondata']);
            $usergroupcache = vB::getDatastore()->get_value('usergroupcache');
            foreach ($usergroupcache as $usergroup) {
                $usergrouplist["{$usergroup['usergroupid']}"] = $usergroup['title'];
            }
            print_select_row($description, $name, $usergrouplist, $setting['value']);
            break;
        case 'profilefield':
            static $profilefieldlistcache = array();
            $profilefieldlisthash = md5(serialize($setting['optiondata']));
            if (!isset($profilefieldlistcache[$profilefieldlisthash])) {
                $profilefieldlist = fetch_piped_options($setting['optiondata']['extraoptions']);
                $constraints = preg_split('#;#', $setting['optiondata']['constraints'], -1, PREG_SPLIT_NO_EMPTY);
                //$where = array();
                $conditions = array();
                foreach ($constraints as $constraint) {
                    $constraint = explode('=', $constraint);
                    switch ($constraint[0]) {
                        case 'editablegt':
                            //$where[] = 'editable > ' . intval($constraint[1]);
                            $conditions[] = array('field' => 'editable', 'value' => intval($constraint[1]), 'operator' => vB_dB_Query::OPERATOR_GT);
                            break;
                        case 'types':
                            $constraint[1] = preg_split('#,#', $constraint[1], -1, PREG_SPLIT_NO_EMPTY);
                            if (!empty($constraint[1])) {
                                $conditions[] = array('field' => 'type', 'value' => $constraint[1], 'operator' => vB_dB_Query::OPERATOR_EQ);
                            }
                            break;
                    }
                }
                $profilefields = vB::getDbAssertor()->assertQuery('vBForum:profilefield', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, vB_dB_Query::CONDITIONS_KEY => $conditions), array('field' => 'displayorder', 'direction' => vB_dB_Query::SORT_ASC));
                foreach ($profilefields as $profilefield) {
                    $fieldname = "field{$profilefield['profilefieldid']}";
                    $profilefieldlist[$fieldname] = construct_phrase($vbphrase['profilefield_x_fieldid_y'], fetch_phrase_from_key("{$fieldname}_title"), $fieldname);
                }
                $profilefieldlistcache[$profilefieldlisthash] = $profilefieldlist;
                unset($profilefieldlist, $constraints, $constraint, $where, $profilefields, $profilefield, $fieldname);
            }
            print_select_row($description, $name, $profilefieldlistcache[$profilefieldlisthash], $setting['value']);
            break;
            // arbitrary number of <input type="text" />
        // arbitrary number of <input type="text" />
        case 'multiinput':
            $setting['html'] = "<div id=\"ctrl_{$setting['varname']}\"><fieldset id=\"multi_input_fieldset_{$setting['varname']}\" style=\"padding:4px\">";
            $setting['values'] = unserialize($setting['value']);
            $setting['values'] = is_array($setting['values']) ? $setting['values'] : array();
            $setting['values'][] = '';
            foreach ($setting['values'] as $key => $value) {
                $setting['html'] .= "<div id=\"multi_input_container_{$setting['varname']}_{$key}\">" . ($key + 1) . " <input type=\"text\" class=\"bginput\" name=\"setting[{$setting['varname']}][{$key}]\" id=\"multi_input_{$setting['varname']}_{$key}\" size=\"40\" value=\"" . htmlspecialchars_uni($value) . "\" tabindex=\"1\" /></div>";
            }
            $i = sizeof($setting['values']);
            if ($i == 0) {
                $setting['html'] .= "<div><input type=\"text\" class=\"bginput\" name=\"setting[{$setting['varname']}][{$i}]\" size=\"40\" tabindex=\"1\" /></div>";
            }
            $setting['html'] .= "\n\t\t\t\t</fieldset>\n\t\t\t\t<div class=\"smallfont\"><a href=\"#\" onclick=\"return multi_input['{$setting['varname']}'].add()\">Add Another Option</a></div>\n\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t<!--\n\t\t\t\tmulti_input['{$setting['varname']}'] = new vB_Multi_Input('{$setting['varname']}', {$i}, '" . vB::getDatastore()->getOption('cpstylefolder') . "');\n\t\t\t\t//-->\n\t\t\t\t</script>\n\t\t\t";
            print_label_row($description, $setting['html']);
            break;
            // default registration options
        // default registration options
        case 'defaultregoptions':
            $setting['value'] = intval($setting['value']);
            $checkbox_options = array('receiveemail' => 'display_email_gcpuser', 'adminemail' => 'receive_admin_emails_guser', 'invisiblemode' => 'invisible_mode_guser', 'vcard' => 'allow_vcard_download_guser', 'signature' => 'display_signatures_gcpuser', 'avatar' => 'display_avatars_gcpuser', 'image' => 'display_images_gcpuser', 'showreputation' => 'display_reputation_gcpuser', 'enablepm' => 'receive_private_messages_guser', 'emailonpm' => 'send_notification_email_when_a_private_message_is_received_guser', 'pmpopup' => 'pop_up_notification_box_when_a_private_message_is_received');
            $setting['value'] = intval($setting['value']);
            $setting['html'] = '';
            #$setting['html'] .= "<fieldset><legend>$vbphrase[yes] / $vbphrase[no]</legend>";
            $setting['html'] .= "<div id=\"ctrl_setting[{$setting['varname']}]\" class=\"smallfont\">\r\n";
            $setting['html'] .= "<input type=\"hidden\" name=\"setting[{$setting['varname']}][0]\" value=\"0\" />\r\n";
            foreach ($checkbox_options as $key => $phrase) {
                $bf_misc_regoptions = vB::getDatastore()->getValue('bf_misc_regoptions');
                $value = $bf_misc_regoptions["{$key}"];
                $setting['html'] .= "<table style=\"width:175px; float:" . vB_Template_Runtime::fetchStyleVar('left') . "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr valign=\"top\">\n\t\t\t\t<td><input type=\"checkbox\" name=\"setting[{$setting['varname']}][{$value}]\" id=\"setting[{$setting['varname']}]_{$key}\" value=\"{$value}\"" . ($setting['value'] & $value ? ' checked="checked"' : '') . " /></td>\n\t\t\t\t<td width=\"100%\" style=\"padding-top:4px\"><label for=\"setting[{$setting['varname']}]_{$key}\" class=\"smallfont\">" . fetch_phrase_from_key($phrase) . "</label></td>\r\n</tr></table>\r\n";
            }
            #$setting['html'] .= "</fieldset>";
            print_label_row($description, $setting['html'], '', 'top', $name, 40);
            break;
            // cp folder options
        // cp folder options
        case 'cpstylefolder':
            if ($folders = fetch_cpcss_options() and !empty($folders)) {
                print_select_row($description, $name, $folders, $setting['value'], 1, 6);
            } else {
                print_input_row($description, $name, $setting['value'], 1, 40);
            }
            break;
            // cookiepath / cookiedomain options
        // cookiepath / cookiedomain options
        case 'cookiepath':
        case 'cookiedomain':
            $func = 'fetch_valid_' . $setting['optioncode'] . 's';
            $cookiesettings = $func($setting['optioncode'] == 'cookiepath' ? $vbulletin->script : $_SERVER['HTTP_HOST'], $vbphrase['blank']);
            $setting['found'] = in_array($setting['value'], array_keys($cookiesettings));
            $setting['html'] = "\n\t\t\t<div id=\"ctrl_{$setting['varname']}\">\n\t\t\t<fieldset>\n\t\t\t\t<legend>{$vbphrase['suggested_settings']}</legend>\n\t\t\t\t<div style=\"padding:4px\">\n\t\t\t\t\t<select name=\"setting[{$setting['varname']}]\" tabindex=\"1\" class=\"bginput\">" . construct_select_options($cookiesettings, $setting['value']) . "\n\t\t\t\t\t</select>\n\t\t\t\t</div>\n\t\t\t</fieldset>\n\t\t\t<br />\n\t\t\t<fieldset>\n\t\t\t\t<legend>{$vbphrase['custom_setting']}</legend>\n\t\t\t\t<div style=\"padding:4px\">\n\t\t\t\t\t<label for=\"{$settingid}o\"><input type=\"checkbox\" id=\"{$settingid}o\" name=\"setting[{$settingid}_other]\" tabindex=\"1\" value=\"1\"" . ($setting['found'] ? '' : ' checked="checked"') . " />{$vbphrase['use_custom_setting']}\n\t\t\t\t\t</label><br />\n\t\t\t\t\t<input type=\"text\" class=\"bginput\" size=\"25\" name=\"setting[{$settingid}_value]\" value=\"" . ($setting['found'] ? '' : $setting['value']) . "\" />\n\t\t\t\t</div>\n\t\t\t</fieldset>\n\t\t\t</div>";
            print_label_row($description, $setting['html'], '', 'top', $name, 50);
            break;
        case 'forums:all':
            $array = construct_forum_chooser_options(-1, $vbphrase['all']);
            $size = sizeof($array);
            $vbphrase['forum_is_closed_for_posting'] = $vbphrase['closed'];
            print_select_row($description, $name . '[]', $array, unserialize($setting['value']), false, $size > 10 ? 10 : $size, true);
            break;
        case 'forums:none':
            $array = construct_forum_chooser_options(0, $vbphrase['none']);
            $size = sizeof($array);
            $vbphrase['forum_is_closed_for_posting'] = $vbphrase['closed'];
            print_select_row($description, $name . '[]', $array, unserialize($setting['value']), false, $size > 10 ? 10 : $size, true);
            break;
            // just a label
        // just a label
        default:
            $handled = false;
            // Legacy Hook 'admin_options_print' Removed //
            if (!$handled) {
                eval("\$right = \"<div id=\\\"ctrl_setting[{$setting['varname']}]\\\">{$setting['optioncode']}</div>\";");
                print_label_row($description, $right, '', 'top', $name, 50);
            }
            break;
    }
    echo "</tbody>\r\n";
    $valid = exec_setting_validation_code($setting['varname'], $setting['value'], $setting['validationcode']);
    echo "<tbody id=\"tbody_error_{$settingid}\" style=\"display:" . (($valid === 1 or $valid === true) ? 'none' : '') . "\"><tr><td class=\"alt1 smallfont\" colspan=\"2\"><div style=\"padding:4px; border:solid 1px red; background-color:white; color:black\"><strong>{$vbphrase['error']}</strong>:<div id=\"span_error_{$settingid}\">{$valid}</div></div></td></tr></tbody>";
}
Example #6
0
			'</select>'
		),
		'browsing_content_page' => array(
			'<select name="criteria[browsing_content_page][condition1]" tabindex="1">
				<option value="1"' . (empty($criteria_cache['browsing_content_page']['condition1']) ? ' selected="selected"' : '') . '>' . $vbphrase['content'] . '</option>
				<option value="0"' . ($criteria_cache['browsing_content_page']['condition1'] == 0 ? ' selected="selected"' : '') . '>' . $vbphrase['non_content'] . '</option>
			</select>'
		),
		'browsing_forum_x' => array(
			'<select name="criteria[browsing_forum_x][condition1]" tabindex="1">' .
				construct_select_options(construct_forum_chooser_options(), $criteria_cache['browsing_forum_x']['condition1']) .
			'</select>'
		),
		'browsing_forum_x_and_children' => array(
			'<select name="criteria[browsing_forum_x_and_children][condition1]" tabindex="1">' .
				construct_select_options(construct_forum_chooser_options(), $criteria_cache['browsing_forum_x_and_children']['condition1']) .
			'</select>'
		),
		'style_is_x' => array(
			'<select name="criteria[style_is_x][condition1]" tabindex="1">' .
				construct_select_options($style_options, $criteria_cache['style_is_x']['condition1']) .
			'</select>'
		),
		'no_visit_in_x_days' => array(
			'<input type="text" name="criteria[no_visit_in_x_days][condition1]" size="5" class="bginput" tabindex="1" value="' .
				(empty($criteria_cache['no_visit_in_x_days']) ? 30 : intval($criteria_cache['no_visit_in_x_days']['condition1'])) .
			'" />'
		),
		'no_posts_in_x_days' => array(
			'<input type="text" name="criteria[no_posts_in_x_days][condition1]" size="5" class="bginput" tabindex="1" value="' .
				(empty($criteria_cache['no_posts_in_x_days']) ? 30 : intval($criteria_cache['no_posts_in_x_days']['condition1'])) .
Example #7
0
    /**
     * Fetches display options HTML
     *
     * @param  int    $adid   (optional) Ad ID
     *
     * @return string $output Display Options HTML
     */
    public function fetchDisplayoptionsHtml($adid = 0)
    {
        $adid = vB::getCleaner()->clean($adid, vB_Cleaner::TYPE_UINT);
        try {
            $this->checkHasAdminPermission('canadminads');
        } catch (vB_Exception_Api $e) {
            // No permission, return empty string
            return '';
        }
        require_once DIR . '/includes/adminfunctions.php';
        $criteria_cache = array();
        // TODO: Fetch criteria cache by adid
        $usergroups = vB_Api::instanceInternal('usergroup')->fetchUsergroupList();
        $usergroup_options = array();
        foreach ($usergroups as $usergroup) {
            $usergroup_options[$usergroup['usergroupid']] = $usergroup['title'];
        }
        $vbphrase = vB_Api::instanceInternal('phrase')->fetch(array('in_usergroup_x_criteria', 'not_in_usergroup_x_criteria', 'browsing_content_page_criteria', 'content', 'non_content', 'browsing_forum_x_criteria', 'browsing_forum_x_and_children_criteria', 'no_visit_in_x_days_criteria', 'no_posts_in_x_days_criteria', 'has_x_postcount_criteria', 'has_never_posted_criteria', 'has_x_reputation_criteria', 'pm_storage_x_percent_full_criteria', 'came_from_search_engine_criteria', 'is_date_criteria', 'user_timezone', 'utc_universal_time', 'is_time_criteria', 'select_forum', 'forum_is_closed_for_posting'));
        $timenow = vB::getRequest()->getTimeNow();
        $criteria_options = array('in_usergroup_x' => array('<select name="data[criteria][in_usergroup_x][condition1]" tabindex="1">' . construct_select_options($usergroup_options, empty($criteria_cache['in_usergroup_x']) ? 2 : $criteria_cache['in_usergroup_x']['condition1']) . '</select>'), 'not_in_usergroup_x' => array('<select name="data[criteria][not_in_usergroup_x][condition1]" tabindex="1">' . construct_select_options($usergroup_options, empty($criteria_cache['not_in_usergroup_x']) ? 6 : $criteria_cache['not_in_usergroup_x']['condition1']) . '</select>'), 'browsing_content_page' => array('<select name="data[criteria][browsing_content_page][condition1]" tabindex="1">
					<option value="1"' . (empty($criteria_cache['browsing_content_page']['condition1']) ? ' selected="selected"' : '') . '>' . $vbphrase['content'] . '</option>
					<option value="0"' . ($criteria_cache['browsing_content_page']['condition1'] == 0 ? ' selected="selected"' : '') . '>' . $vbphrase['non_content'] . '</option>
				</select>'), 'browsing_forum_x' => array('<select name="data[criteria][browsing_forum_x][condition1]" tabindex="1">' . construct_select_options(construct_forum_chooser_options(), $criteria_cache['browsing_forum_x']['condition1']) . '</select>'), 'browsing_forum_x_and_children' => array('<select name="data[criteria][browsing_forum_x_and_children][condition1]" tabindex="1">' . construct_select_options(construct_forum_chooser_options(), $criteria_cache['browsing_forum_x_and_children']['condition1']) . '</select>'), 'no_visit_in_x_days' => array('<input type="text" name="data[criteria][no_visit_in_x_days][condition1]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['no_visit_in_x_days']) ? 30 : intval($criteria_cache['no_visit_in_x_days']['condition1'])) . '" />'), 'no_posts_in_x_days' => array('<input type="text" name="data[criteria][no_posts_in_x_days][condition1]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['no_posts_in_x_days']) ? 30 : intval($criteria_cache['no_posts_in_x_days']['condition1'])) . '" />'), 'has_x_postcount' => array('<input type="text" name="data[criteria][has_x_postcount][condition1]" size="5" class="bginput" tabindex="1" value="' . $criteria_cache['has_x_postcount']['condition1'] . '" />', '<input type="text" name="data[criteria][has_x_postcount][condition2]" size="5" class="bginput" tabindex="1" value="' . $criteria_cache['has_x_postcount']['condition2'] . '" />'), 'has_never_posted' => array(), 'has_x_reputation' => array('<input type="text" name="data[criteria][has_x_reputation][condition1]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['has_x_reputation']) ? 100 : $criteria_cache['has_x_reputation']['condition1']) . '" />', '<input type="text" name="data[criteria][has_x_reputation][condition2]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['has_x_reputation']) ? 200 : $criteria_cache['has_x_reputation']['condition2']) . '" />'), 'came_from_search_engine' => array(), 'is_date' => array('<input type="text" name="data[criteria][is_date][condition1]" size="10" class="bginput" tabindex="1" value="' . (empty($criteria_cache['is_date']['condition1']) ? vbdate('d-m-Y', $timenow, false, false) : $criteria_cache['is_date']['condition1']) . '" />', '<select name="data[criteria][is_date][condition2]" tabindex="1">
					<option value="0"' . (empty($criteria_cache['is_date']['condition2']) ? ' selected="selected"' : '') . '>' . $vbphrase['user_timezone'] . '</option>
					<option value="1"' . ($criteria_cache['is_date']['condition2'] == 1 ? ' selected="selected"' : '') . '>' . $vbphrase['utc_universal_time'] . '</option>
				</select>'), 'is_time' => array('<input type="text" name="data[criteria][is_time][condition1]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['is_time']['condition1']) ? vbdate('H:i', $timenow, false, false) : $criteria_cache['is_time']['condition1']) . '" />', '<input type="text" name="data[criteria][is_time][condition2]" size="5" class="bginput" tabindex="1" value="' . (empty($criteria_cache['is_time']['condition2']) ? intval(vbdate('H', $timenow, false, false)) + 1 . vbdate(':i', $timenow, false, false) : $criteria_cache['is_time']['condition2']) . '" />', '<select name="data[criteria][is_time][condition3]" tabindex="1">
					<option value="0"' . (empty($criteria_cache['is_time']['condition3']) ? ' selected="selected"' : '') . '>' . $vbphrase['user_timezone'] . '</option>
					<option value="1"' . ($criteria_cache['is_time']['condition3'] == 1 ? ' selected="selected"' : '') . '>' . $vbphrase['utc_universal_time'] . '</option>
				</select>'));
        $output = '';
        foreach ($criteria_options as $criteria_option_id => $criteria_option) {
            // the criteria options can't trigger the checkbox to change, we need to break out of the label
            $criteria_text = '<label>' . sprintf($vbphrase[$criteria_option_id . '_criteria'], "</label>{$criteria_option['0']}<label>", "</label>{$criteria_option['1']}<label>", "</label>{$criteria_option['2']}<label>") . '</label>';
            $criteria_text = str_replace('<label>', "<label for=\"cb_{$criteria_option_id}\">", $criteria_text);
            $output .= "<div class=\"optionrow\"><input type=\"checkbox\" id=\"cb_{$criteria_option_id}\" tabindex=\"1\" name=\"data[criteria][{$criteria_option_id}][active]\" title=\"{$vbphrase['criterion_is_active']}\" value=\"1\"" . (empty($criteria_cache["{$criteria_option_id}"]) ? '' : ' checked="checked"') . " />" . "<span id=\"span_{$criteria_option_id}\">{$criteria_text}</span></div>";
        }
        return $output;
    }