Beispiel #1
0
 /**
  * Standard interface stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action()
 {
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     if (get_option('is_on_' . $class . '_buy') == '0') {
         return new ocp_tempcode();
     }
     $title = get_page_title('TOPIC_PINNING');
     $cost = intval(get_option($class));
     $next_url = build_url(array('page' => '_SELF', 'type' => 'action_done', 'id' => $class), '_SELF');
     $points_left = available_points(get_member());
     // Check points
     if ($points_left < $cost && !has_specific_permission(get_member(), 'give_points_self')) {
         return warn_screen($title, do_lang_tempcode('_CANT_AFFORD', integer_format($cost), integer_format($points_left)));
     }
     require_code('form_templates');
     $fields = new ocp_tempcode();
     if (get_forum_type() == 'ocf') {
         $fields->attach(form_input_tree_list(do_lang_tempcode('FORUM_TOPIC'), '', 'select_topic_id', NULL, 'choose_forum_topic', array(), false));
         $fields->attach(form_input_integer(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('FORUM_TOPIC')), do_lang_tempcode('DESCRIPTION_FORUM_TOPIC_ID'), 'manual_topic_id', NULL, false));
     } else {
         $fields->attach(form_input_integer(do_lang_tempcode('FORUM_TOPIC'), do_lang_tempcode('ENTER_TOPIC_ID_MANUALLY'), 'manual_topic_id', NULL, false));
     }
     $text = do_lang_tempcode('PIN_TOPIC_A', integer_format($cost), integer_format($points_left - $cost));
     return do_template('FORM_SCREEN', array('_GUID' => '8cabf882d5cbe4d354cc6efbcf92ebf9', 'TITLE' => $title, 'TEXT' => $text, 'URL' => $next_url, 'FIELDS' => $fields, 'HIDDEN' => '', 'SUBMIT_NAME' => do_lang_tempcode('PURCHASE'), 'JAVASCRIPT' => 'standardAlternateFields(\'select_topic_id\',\'manual_topic_id\');'));
 }
Beispiel #2
0
 /**
  * Standard interface stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action()
 {
     require_code('database_action');
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     //if (get_option('is_on_'.$class.'_buy')=='0') return new ocp_tempcode();
     $tablename_exists = $GLOBALS['SITE_DB']->table_exists('bank');
     if (!$tablename_exists) {
         $GLOBALS['SITE_DB']->create_table('bank', array('id' => '*AUTO', 'user_id' => 'INTEGER', 'amount' => 'INTEGER', 'divident' => 'INTEGER', 'add_time' => '?TIME'));
     }
     $_bank_dividend = get_option('bank_divident', true);
     if (is_null($_bank_dividend)) {
         //add option and default value
         add_config_option('BANK_DIVIDEND', 'bank_divident', 'integer', 'return \'40\';', 'POINTSTORE', 'BANKING');
         // TODO: Fix spelling
         // IDEA: Make 30 days a config option too, or even have multiple products?
         // IDEA: Send email saying bank returned money?
         // IDEA: Have the bank do marketing to people? http://ocportal.com/forum/topicview/misc/addons/ocbank_4.htm?redirected=1#post_87711
         $bank_dividend = 4;
     } else {
         $bank_dividend = intval($_bank_dividend);
     }
     $title = get_page_title('BANKING');
     $points_left = available_points(get_member());
     $next_url = build_url(array('page' => '_SELF', 'type' => 'action_done', 'id' => $class), '_SELF');
     // Check points
     if ($points_left < 0 && !has_specific_permission(get_member(), 'give_points_self')) {
         return warn_screen($title, do_lang_tempcode('_CANT_AFFORD_BANK'));
     }
     require_code('form_templates');
     $fields = new ocp_tempcode();
     $fields->attach(form_input_integer(do_lang_tempcode('AMOUNT'), do_lang_tempcode('DESCRIPTION_BANK_AMOUNT', integer_format($points_left)), 'amount', $points_left, true));
     $text = do_lang_tempcode('BANK_A', integer_format($points_left));
     return do_template('FORM_SCREEN', array('_GUID' => 'ae703225db618f2bc938290fbae4d6d8', 'TITLE' => $title, 'TEXT' => $text, 'URL' => $next_url, 'FIELDS' => $fields, 'HIDDEN' => '', 'SUBMIT_NAME' => do_lang_tempcode('PROCEED')));
 }
Beispiel #3
0
 /**
  * Get fields for adding/editing one of these.
  *
  * @param  string			What to place onto the end of the field name
  * @param  SHORT_TEXT	Title
  * @param  LONG_TEXT		Description
  * @param  BINARY			Whether it is enabled
  * @param  ?integer		The cost in points (NULL: not set)
  * @param  BINARY			Whether it is restricted to one per member
  * @return tempcode		The fields
  */
 function get_fields($name_suffix = '', $title = '', $description = '', $enabled = 1, $cost = NULL, $one_per_member = 0)
 {
     require_lang('points');
     $fields = new ocp_tempcode();
     $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'custom_title' . $name_suffix, $title, true));
     $fields->attach(form_input_text(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'custom_description' . $name_suffix, $description, true));
     $fields->attach(form_input_integer(do_lang_tempcode('COST'), do_lang_tempcode('HOW_MUCH_THIS_COSTS'), 'custom_cost' . $name_suffix, $cost, true));
     $fields->attach(form_input_tick(do_lang_tempcode('ONE_PER_MEMBER'), do_lang_tempcode('DESCRIPTION_ONE_PER_MEMBER'), 'custom_one_per_member' . $name_suffix, $one_per_member == 1));
     $fields->attach(form_input_tick(do_lang_tempcode('ENABLED'), '', 'custom_enabled' . $name_suffix, $enabled == 1));
     return $fields;
 }
Beispiel #4
0
 /**
  * Standard modular run function for features in the setup wizard.
  *
  * @param  array		Default values for the fields, from the install-profile.
  * @return tempcode	An input field.
  */
 function get_fields($field_defaults)
 {
     if (!addon_installed('stats')) {
         return new ocp_tempcode();
     }
     $stats_store_time = get_option('stats_store_time');
     require_lang('stats');
     $fields = new ocp_tempcode();
     $fields->attach(form_input_integer(do_lang_tempcode('STORE_TIME'), do_lang_tempcode('CONFIG_OPTION_stats_store_time'), 'stats_store_time', intval($stats_store_time), true));
     return $fields;
 }
Beispiel #5
0
 /**
  * Standard stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function _text()
 {
     if (get_option('is_on_flagrant_buy') == '0') {
         return new ocp_tempcode();
     }
     $title = get_page_title('TITLE_NEWTEXT');
     // Build up fields
     require_code('form_templates');
     $fields = form_input_line_comcode(do_lang_tempcode('MESSAGE'), do_lang_tempcode('MESSAGE_DESCRIPTION'), 'message', '', true);
     $fields->attach(form_input_integer(do_lang_tempcode('NUMBER_DAYS'), do_lang_tempcode('NUMBER_DAYS_DESCRIPTION'), 'days', 1, true));
     $price = intval(get_option('text'));
     $text = paragraph(do_lang_tempcode('FLAGRANT_GUIDE', integer_format($price)));
     // Return template
     $post_url = build_url(array('page' => '_SELF', 'type' => '__text', 'id' => 'flagrant'), '_SELF');
     return do_template('FORM_SCREEN', array('_GUID' => '3584ba6a16c9a51829dc3b25b58067f6', 'HIDDEN' => '', 'TITLE' => $title, 'ACTION' => do_lang_tempcode('TITLE_NEWTEXT'), 'TEXT' => $text, 'URL' => $post_url, 'SUBMIT_NAME' => do_lang_tempcode('PURCHASE'), 'FIELDS' => $fields));
 }
Beispiel #6
0
 /**
  * Standard interface stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action()
 {
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     if (get_option('is_on_' . $class . '_buy') == '0') {
         return new ocp_tempcode();
     }
     $title = get_page_title('GAMBLING');
     $cost = intval(get_option('minimum_gamble_amount'));
     $points_left = available_points(get_member());
     $max = min(intval(get_option('maximum_gamble_amount')), $points_left);
     $next_url = build_url(array('page' => '_SELF', 'type' => 'action_done', 'id' => $class), '_SELF');
     // Check points
     if ($points_left < $cost && !has_specific_permission(get_member(), 'give_points_self')) {
         return warn_screen($title, do_lang_tempcode('_CANT_AFFORD', integer_format($cost), integer_format($points_left)));
     }
     require_code('form_templates');
     $fields = new ocp_tempcode();
     $fields->attach(form_input_integer(do_lang_tempcode('AMOUNT'), do_lang_tempcode('DESCRIPTION_GAMBLE_AMOUNT', integer_format($cost), integer_format($max)), 'amount', $cost, true));
     $text = do_lang_tempcode('GAMBLE_A', integer_format($cost), integer_format($max), integer_format($points_left));
     return do_template('FORM_SCREEN', array('_GUID' => 'ae703225db618f2bc938290fbae4d6d8', 'TITLE' => $title, 'TEXT' => $text, 'URL' => $next_url, 'FIELDS' => $fields, 'HIDDEN' => '', 'SUBMIT_NAME' => do_lang_tempcode('PROCEED')));
 }
Beispiel #7
0
 /**
  * The UI to choose session details.
  *
  * @return tempcode		The UI
  */
 function choose_session2()
 {
     $title = get_page_title('IMPORT');
     /* Three cases:
     			  1) We are continuing (therefore do nothing)
     			  2) We are resuming a prior session, after our session changed (therefore remap old session-data to current session)
     			  3) We are starting afresh (therefore delete all previous import sessions)
     			  4) As per '3', except OCF imports are maintained as we're now importing a satellite site
     		*/
     $session = either_param_integer('session', get_session_id());
     if ($session == -1 || $session == -2) {
         // Delete all others
         $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'import_session');
         if ($session == -1) {
             $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'import_parts_done');
             $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'import_id_remap');
         } else {
             $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'import_parts_done WHERE imp_id NOT LIKE \'' . db_encode_like('ocf_%') . '\'');
             $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'import_id_remap WHERE (id_type NOT LIKE \'' . db_encode_like('ocf_%') . '\'' . ') AND ' . db_string_not_equal_to('id_type', 'category') . ' AND ' . db_string_not_equal_to('id_type', 'forum') . ' AND ' . db_string_not_equal_to('id_type', 'topic') . ' AND ' . db_string_not_equal_to('id_type', 'post') . ' AND ' . db_string_not_equal_to('id_type', 'f_poll') . ' AND ' . db_string_not_equal_to('id_type', 'group') . ' AND ' . db_string_not_equal_to('id_type', 'member'));
         }
         $session = get_session_id();
     }
     if ($session != get_session_id()) {
         // Remap given to current
         $GLOBALS['SITE_DB']->query_delete('import_session', array('imp_session' => get_session_id()), '', 1);
         $GLOBALS['SITE_DB']->query_delete('import_parts_done', array('imp_session' => get_session_id()));
         $GLOBALS['SITE_DB']->query_delete('import_id_remap', array('id_session' => get_session_id()));
         $GLOBALS['SITE_DB']->query_update('import_session', array('imp_session' => get_session_id()), array('imp_session' => $session), '', 1);
         $GLOBALS['SITE_DB']->query_update('import_parts_done', array('imp_session' => get_session_id()), array('imp_session' => $session));
         $GLOBALS['SITE_DB']->query_update('import_id_remap', array('id_session' => get_session_id()), array('id_session' => $session));
     }
     // Get details from the session row
     $importer = filter_naughty(get_param('importer'));
     require_code('hooks/modules/admin_import/' . filter_naughty_harsh($importer));
     $object = object_factory('Hook_' . filter_naughty_harsh($importer));
     $info = $object->info();
     $session_row = $GLOBALS['SITE_DB']->query_select('import_session', array('*'), array('imp_session' => get_session_id()), '', 1);
     if (array_key_exists(0, $session_row)) {
         $old_base_dir = $session_row[0]['imp_old_base_dir'];
         $db_name = $session_row[0]['imp_db_name'];
         $db_user = $session_row[0]['imp_db_user'];
         $db_table_prefix = $session_row[0]['imp_db_table_prefix'];
         $refresh_time = $session_row[0]['imp_refresh_time'];
     } else {
         $old_base_dir = get_file_base() . '/old';
         $db_name = get_db_site();
         $db_user = get_db_site_user();
         $db_table_prefix = array_key_exists('prefix', $info) ? $info['prefix'] : $GLOBALS['SITE_DB']->get_table_prefix();
         $refresh_time = 15;
     }
     // Build the form
     $fields = new ocp_tempcode();
     require_code('form_templates');
     if (!method_exists($object, 'probe_db_access')) {
         $fields->attach(form_input_line(do_lang_tempcode('DATABASE_NAME'), do_lang_tempcode('_FROM_IMPORTING_SYSTEM'), 'db_name', $db_name, true));
         $fields->attach(form_input_line(do_lang_tempcode('DATABASE_USERNAME'), do_lang_tempcode('_FROM_IMPORTING_SYSTEM'), 'db_user', $db_user, true));
         $fields->attach(form_input_password(do_lang_tempcode('DATABASE_PASSWORD'), do_lang_tempcode('_FROM_IMPORTING_SYSTEM'), 'db_password', false));
         // Not required as there may be a blank password
         $fields->attach(form_input_line(do_lang_tempcode('TABLE_PREFIX'), do_lang_tempcode('_FROM_IMPORTING_SYSTEM'), 'db_table_prefix', $db_table_prefix, true));
     }
     $fields->attach(form_input_line(do_lang_tempcode('FILE_BASE'), do_lang_tempcode('FROM_IMPORTING_SYSTEM'), 'old_base_dir', $old_base_dir, true));
     if (intval(ini_get('safe_mode')) == 0) {
         $fields->attach(form_input_integer(do_lang_tempcode('REFRESH_TIME'), do_lang_tempcode('DESCRIPTION_REFRESH_TIME'), 'refresh_time', $refresh_time, true));
     }
     if (method_exists($object, 'get_extra_fields')) {
         $fields->attach($object->get_extra_fields());
     }
     $url = build_url(array('page' => '_SELF', 'type' => 'hook', 'session' => $session, 'importer' => $importer), '_SELF');
     $message = array_key_exists('message', $info) ? $info['message'] : '';
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('IMPORT')), array('_SELF:_SELF:session', do_lang_tempcode('IMPORT_SESSION'))));
     return do_template('FORM_SCREEN', array('_GUID' => '15f2c855acf0d365a2e6329bec692dc8', 'TEXT' => $message, 'TITLE' => $title, 'FIELDS' => $fields, 'URL' => $url, 'HIDDEN' => '', 'SUBMIT_NAME' => do_lang_tempcode('PROCEED')));
 }
Beispiel #8
0
/**
 * Shows an HTML page for making block Comcode.
 */
function block_helper_script()
{
    require_lang('comcode');
    require_lang('blocks');
    require_code('zones2');
    require_code('zones3');
    check_specific_permission('comcode_dangerous');
    $title = get_page_title('BLOCK_HELPER');
    require_code('form_templates');
    require_all_lang();
    $type_wanted = get_param('block_type', 'main');
    $type = get_param('type', 'step1');
    $content = new ocp_tempcode();
    if ($type == 'step1') {
        // Find what addons all our block files are in, and icons if possible
        $hooks = find_all_hooks('systems', 'addon_registry');
        $hook_keys = array_keys($hooks);
        $hook_files = array();
        foreach ($hook_keys as $hook) {
            $path = get_file_base() . '/sources_custom/hooks/systems/addon_registry/' . filter_naughty_harsh($hook) . '.php';
            if (!file_exists($path)) {
                $path = get_file_base() . '/sources/hooks/systems/addon_registry/' . filter_naughty_harsh($hook) . '.php';
            }
            $hook_files[$hook] = file_get_contents($path);
        }
        unset($hook_keys);
        $addon_icons = array();
        $addons_blocks = array();
        foreach ($hook_files as $addon_name => $hook_file) {
            $matches = array();
            if (preg_match('#function get_file_list\\(\\)\\s*\\{([^\\}]*)\\}#', $hook_file, $matches) != 0) {
                if (!defined('HIPHOP_PHP')) {
                    $addon_files = eval($matches[1]);
                } else {
                    require_code('hooks/systems/addon_registry/' . $addon_name);
                    $hook_ob = object_factory('Hook_addon_registry_' . $addon_name);
                    $addon_files = $hook_ob->get_file_list();
                }
                foreach ($addon_files as $file) {
                    if (substr($file, 0, 31) == 'themes/default/images/bigicons/' && !array_key_exists($addon_name, $addon_icons)) {
                        $addon_icons[$addon_name] = find_theme_image('bigicons/' . basename($file, '.png'), false, true);
                    }
                    if (substr($file, 0, 21) == 'sources_custom/blocks/' || substr($file, 0, 15) == 'sources/blocks/') {
                        if ($addon_name == 'staff_messaging') {
                            $addon_name = 'core_feedback_features';
                        }
                        $addons_blocks[basename($file, '.php')] = $addon_name;
                    }
                }
            }
        }
        // Find where blocks have been used
        $block_usage = array();
        $zones = find_all_zones(false, true);
        foreach ($zones as $_zone) {
            $zone = $_zone[0];
            $pages = find_all_pages_wrap($zone, true);
            foreach ($pages as $filename => $type) {
                if (substr(strtolower($filename), -4) == '.txt') {
                    $matches = array();
                    $contents = file_get_contents(zone_black_magic_filterer((substr($type, 0, 15) == 'comcode_custom/' ? get_custom_file_base() : get_file_base()) . '/' . ($zone == '' ? '' : $zone . '/') . 'pages/' . $type . '/' . $filename));
                    //$fallback=get_file_base().'/'.(($zone=='')?'':($zone.'/')).'pages/comcode/'.fallback_lang().'/'.$filename;
                    //if (file_exists($fallback)) $contents.=file_get_contents($fallback);
                    $num_matches = preg_match_all('#\\[block[^\\]]*\\](.*)\\[/block\\]#U', $contents, $matches);
                    for ($i = 0; $i < $num_matches; $i++) {
                        $block_used = $matches[1][$i];
                        if (!array_key_exists($block_used, $block_usage)) {
                            $block_usage[$block_used] = array();
                        }
                        $block_usage[$block_used][] = $zone . ':' . basename($filename, '.txt');
                    }
                }
            }
        }
        // Show block list
        $links = new ocp_tempcode();
        $blocks = find_all_blocks();
        $dh = @opendir(get_file_base() . '/sources_custom/miniblocks');
        if ($dh !== false) {
            while (($file = readdir($dh)) !== false) {
                if (substr($file, -4) == '.php' && preg_match('#^[\\w\\-]*$#', substr($file, 0, strlen($file) - 4)) != 0) {
                    $blocks[substr($file, 0, strlen($file) - 4)] = 'sources_custom';
                }
            }
            closedir($dh);
        }
        $block_types = array();
        $block_types_icon = array();
        $keep = symbol_tempcode('KEEP');
        foreach (array_keys($blocks) as $block) {
            if (array_key_exists($block, $addons_blocks)) {
                $addon_name = $addons_blocks[$block];
                $addon_icon = array_key_exists($addon_name, $addon_icons) ? $addon_icons[$addon_name] : NULL;
                $addon_name = preg_replace('#^core\\_#', '', $addon_name);
            } else {
                $addon_name = NULL;
                $addon_icon = NULL;
            }
            $this_block_type = is_null($addon_name) || strpos($addon_name, 'block') !== false || $addon_name == 'core' ? substr($block, 0, strpos($block, '_') === false ? strlen($block) : strpos($block, '_')) : $addon_name;
            if (!array_key_exists($this_block_type, $block_types)) {
                $block_types[$this_block_type] = new ocp_tempcode();
            }
            if (!is_null($addon_icon)) {
                $block_types_icon[$this_block_type] = $addon_icon;
            }
            $block_description = do_lang('BLOCK_' . $block . '_DESCRIPTION', NULL, NULL, NULL, NULL, false);
            $block_use = do_lang('BLOCK_' . $block . '_USE', NULL, NULL, NULL, NULL, false);
            if (is_null($block_description)) {
                $block_description = '';
            }
            if (is_null($block_use)) {
                $block_use = '';
            }
            $descriptiont = $block_description == '' && $block_use == '' ? new ocp_tempcode() : do_lang_tempcode('BLOCK_HELPER_1X', $block_description, $block_use);
            $url = find_script('block_helper') . '?type=step2&block=' . urlencode($block) . '&field_name=' . get_param('field_name') . $keep->evaluate();
            if (get_param('utheme', '') != '') {
                $url .= '&utheme=' . get_param('utheme');
            }
            $url .= '&block_type=' . $type_wanted;
            $link_caption = do_lang_tempcode('NICE_BLOCK_NAME', escape_html(cleanup_block_name($block)), $block);
            $usage = array_key_exists($block, $block_usage) ? $block_usage[$block] : array();
            $block_types[$this_block_type]->attach(do_template('BLOCK_HELPER_BLOCK_CHOICE', array('USAGE' => $usage, 'DESCRIPTION' => $descriptiont, 'URL' => $url, 'LINK_CAPTION' => $link_caption)));
        }
        /*if (array_key_exists($type_wanted,$block_types)) We don't do this now, as we structure by addon name
        		{
        			$x=$block_types[$type_wanted];
        			unset($block_types[$type_wanted]);
        			$block_types=array_merge(array($type_wanted=>$x),$block_types);
        		}*/
        ksort($block_types);
        // We sort now instead
        $move_after = $block_types['adminzone_frontpage'];
        unset($block_types['adminzone_frontpage']);
        $block_types['adminzone_frontpage'] = $move_after;
        foreach ($block_types as $block_type => $_links) {
            switch ($block_type) {
                case 'side':
                case 'main':
                case 'bottom':
                    $type_title = do_lang_tempcode('BLOCKS_TYPE_' . $block_type);
                    $img = NULL;
                    break;
                default:
                    $type_title = do_lang_tempcode('BLOCKS_TYPE_ADDON', escape_html(cleanup_block_name($block_type)));
                    $img = array_key_exists($block_type, $block_types_icon) ? $block_types_icon[$block_type] : NULL;
                    break;
            }
            $links->attach(do_template('BLOCK_HELPER_BLOCK_GROUP', array('IMG' => $img, 'TITLE' => $type_title, 'LINKS' => $_links)));
        }
        $content = do_template('BLOCK_HELPER_START', array('_GUID' => 'd2d6837cdd8b19d80ea95ab9f5d09c9a', 'GET' => true, 'TITLE' => $title, 'LINKS' => $links));
    } elseif ($type == 'step2') {
        require_code('comcode_text');
        $defaults = parse_single_comcode_tag(get_param('parse_defaults', '', true), 'block');
        $block = trim(get_param('block'));
        $title = get_page_title('_BLOCK_HELPER', true, array(escape_html($block)));
        $fields = new ocp_tempcode();
        $parameters = get_block_parameters($block);
        $parameters[] = 'failsafe';
        $parameters[] = 'cache';
        $parameters[] = 'quick_cache';
        if (!isset($defaults['cache'])) {
            $defaults['cache'] = block_cache_default($block);
        }
        if (is_null($parameters)) {
            $parameters = array();
        }
        $advanced_ind = do_lang('BLOCK_IND_ADVANCED');
        $param_classes = array('normal' => array(), 'advanced' => array());
        foreach ($parameters as $parameter) {
            $param_class = 'normal';
            if ($parameter == 'cache' || $parameter == 'quick_cache' || $parameter == 'failsafe' || strpos(do_lang('BLOCK_' . $block . '_PARAM_' . $parameter), $advanced_ind) !== false) {
                $param_class = 'advanced';
            }
            $param_classes[$param_class][] = $parameter;
        }
        foreach ($param_classes as $param_class => $parameters) {
            if (count($parameters) == 0) {
                if ($param_class == 'normal') {
                    $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => false, 'TITLE' => do_lang_tempcode('PARAMETERS'), 'HELP' => protect_from_escaping(paragraph(do_lang_tempcode('BLOCK_HELPER_NO_PARAMETERS'), '', 'nothing_here')))));
                }
                continue;
            }
            if ($param_class == 'advanced') {
                $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('ADVANCED'))));
            }
            foreach ($parameters as $parameter) {
                $matches = array();
                switch ($parameter) {
                    case 'quick_cache':
                    case 'cache':
                    case 'failsafe':
                        $description = do_lang('BLOCK_PARAM_' . $parameter);
                        break;
                    default:
                        $description = do_lang('BLOCK_' . $block . '_PARAM_' . $parameter);
                        break;
                }
                $description = str_replace(do_lang('BLOCK_IND_STRIPPABLE_1'), '', $description);
                $description = trim(str_replace(do_lang('BLOCK_IND_ADVANCED'), '', $description));
                // Work out default value for field
                $default = '';
                if (preg_match('#' . do_lang('BLOCK_IND_DEFAULT') . ': ["\']([^"]*)["\']#Ui', $description, $matches) != 0) {
                    $default = $matches[1];
                    $has_default = true;
                    $description = preg_replace('#\\s*' . do_lang('BLOCK_IND_DEFAULT') . ': ["\']([^"]*)["\'](?-U)\\.?(?U)#Ui', '', $description);
                } else {
                    $has_default = false;
                }
                if (isset($defaults[$parameter])) {
                    $default = $defaults[$parameter];
                    $has_default = true;
                }
                // Show field
                if ($block . ':' . $parameter == 'side_stored_menu:type') {
                    $matches = array();
                    $dh = opendir(get_file_base() . '/themes/default/templates/');
                    $options = array();
                    while (($file = readdir($dh)) !== false) {
                        if (preg_match('^MENU\\_([a-z]+)\\.tpl$^', $file, $matches) != 0) {
                            $options[] = $matches[1];
                        }
                    }
                    closedir($dh);
                    $dh = opendir(get_custom_file_base() . '/themes/default/templates_custom/');
                    while (($file = readdir($dh)) !== false) {
                        if (preg_match('^MENU\\_([a-z]+)\\.tpl$^', $file, $matches) != 0 && !file_exists(get_file_base() . '/themes/default/templates/' . $file)) {
                            $options[] = $matches[1];
                        }
                    }
                    closedir($dh);
                    sort($options);
                    $list = new ocp_tempcode();
                    foreach ($options as $option) {
                        $list->attach(form_input_list_entry($option, $has_default && $option == $default));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($block . ':' . $parameter == 'side_stored_menu:param') {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('menu_items', array('DISTINCT i_menu'), NULL, 'ORDER BY i_menu');
                    foreach ($rows as $row) {
                        $list->attach(form_input_list_entry($row['i_menu'], $has_default && $row['i_menu'] == $default));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($block . ':' . $parameter == 'side_shoutbox:param') {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('id', 'room_name'), array('is_im' => 0), '', 100);
                    foreach ($rows as $row) {
                        $list->attach(form_input_list_entry(strval($row['id']), $has_default && strval($row['id']) == $default, $row['room_name']));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($block . ':' . $parameter == 'main_poll:param') {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('poll', array('id', 'question'), NULL, 'ORDER BY id DESC', 100);
                    $list->attach(form_input_list_entry('', false, do_lang('NA')));
                    foreach ($rows as $row) {
                        $list->attach(form_input_list_entry(strval($row['id']), $has_default && strval($row['id']) == $default, get_translated_text($row['question'])));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($block . ':' . $parameter == 'main_awards:param') {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('award_types', array('id', 'a_title'));
                    foreach ($rows as $row) {
                        $list->attach(form_input_list_entry(strval($row['id']), $has_default && strval($row['id']) == $default, get_translated_text($row['a_title'])));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'zone' || $parameter == 'param' && $block == 'main_as_zone_access') {
                    $list = new ocp_tempcode();
                    $list->attach(form_input_list_entry('_SEARCH', $default == ''));
                    $list->attach(nice_get_zones($default == '' ? NULL : $default));
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif (($parameter == 'forum' || $parameter == 'param' && in_array($block, array('main_forum_topics'))) && get_forum_type() == 'ocf') {
                    require_code('ocf_forums');
                    require_code('ocf_forums2');
                    if (!addon_installed('ocf_forum')) {
                        warn_exit(do_lang_tempcode('NO_FORUM_INSTALLED'));
                    }
                    $list = ocf_get_forum_tree_secure(NULL, NULL, true, explode(',', $default));
                    $fields->attach(form_input_multi_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list));
                } elseif ($parameter == 'param' && in_array($block, array('side_root_galleries', 'main_gallery_tease', 'main_gallery_embed', 'main_image_fader'))) {
                    require_code('galleries');
                    $list = nice_get_gallery_tree($default);
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_download_category'))) {
                    require_code('downloads');
                    $list = nice_get_download_category_tree($default == '' ? NULL : intval($default));
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_contact_catalogues')) || $parameter == 'catalogue' && in_array($block, array('main_recent_cc_entries'))) {
                    require_code('catalogues');
                    $list = nice_get_catalogues($default, false);
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_cc_embed')) && $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'COUNT(*)') < 500) {
                    $list = new ocp_tempcode();
                    $categories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('id', 'cc_title', 'c_name'), NULL, 'ORDER BY c_name,id');
                    $last_cat = mixed();
                    foreach ($categories as $cat) {
                        if (is_null($last_cat) || $cat['c_name'] != $last_cat) {
                            $list->attach(form_input_list_entry($cat['c_name'], $has_default && $cat['c_name'] == $default, $cat['c_name'], false, true));
                            $last_cat = $cat['c_name'];
                        }
                        $list->attach(form_input_list_entry(strval($cat['id']), $has_default && strval($cat['id']) == $default, get_translated_text($cat['cc_title'])));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_banner_wave', 'main_topsites'))) {
                    require_code('banners');
                    $list = nice_get_banner_types($default);
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_newsletter_signup'))) {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('newsletters', array('id', 'title'));
                    foreach ($rows as $newsletter) {
                        $list->attach(form_input_list_entry(strval($newsletter['id']), $has_default && strval($newsletter['id']) == $default, get_translated_text($newsletter['title'])));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'filter' && in_array($block, array('bottom_news', 'main_news', 'side_news', 'side_news_archive'))) {
                    require_code('news');
                    $list = nice_get_news_categories($default == '' ? -1 : intval($default));
                    $fields->attach(form_input_multi_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list));
                } elseif ($parameter == 'font') {
                    $fonts = array();
                    $dh = opendir(get_file_base() . '/data/fonts');
                    while ($f = readdir($dh)) {
                        if (substr($f, -4) == '.ttf') {
                            $fonts[] = substr($f, 0, strlen($f) - 4);
                        }
                    }
                    closedir($dh);
                    $dh = opendir(get_custom_file_base() . '/data_custom/fonts');
                    while ($f = readdir($dh)) {
                        if (substr($f, -4) == '.ttf') {
                            $fonts[] = substr($f, 0, strlen($f) - 4);
                        }
                    }
                    closedir($dh);
                    $fonts = array_unique($fonts);
                    sort($fonts);
                    $list = new ocp_tempcode();
                    foreach ($fonts as $font) {
                        $list->attach(form_input_list_entry($font, $font == $default));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif (preg_match('#' . do_lang('BLOCK_IND_EITHER') . ' (.+)#i', $description, $matches) != 0) {
                    $description = preg_replace('# \\(' . do_lang('BLOCK_IND_EITHER') . '.*\\)#U', '', $description);
                    $list = new ocp_tempcode();
                    $matches2 = array();
                    $num_matches = preg_match_all('#\'([^\']*)\'="([^"]*)"#', $matches[1], $matches2);
                    if ($num_matches != 0) {
                        for ($i = 0; $i < $num_matches; $i++) {
                            $list->attach(form_input_list_entry($matches2[1][$i], $matches2[1][$i] == $default, $matches2[2][$i]));
                        }
                    } else {
                        $num_matches = preg_match_all('#\'([^\']*)\'#', $matches[1], $matches2);
                        for ($i = 0; $i < $num_matches; $i++) {
                            $list->attach(form_input_list_entry($matches2[1][$i], $matches2[1][$i] == $default));
                        }
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif (preg_match('#\\(' . do_lang('BLOCK_IND_HOOKTYPE') . ': \'([^\'/]*)/([^\'/]*)\'\\)#i', $description, $matches) != 0) {
                    $description = preg_replace('#\\s*\\(' . do_lang('BLOCK_IND_HOOKTYPE') . ': \'([^\'/]*)/([^\'/]*)\'\\)#i', '', $description);
                    $list = new ocp_tempcode();
                    $hooks = find_all_hooks($matches[1], $matches[2]);
                    ksort($hooks);
                    if ($default == '' && $has_default) {
                        $list->attach(form_input_list_entry('', true));
                    }
                    foreach (array_keys($hooks) as $hook) {
                        if ($block == 'side_tag_cloud') {
                            if (substr($hook, -1) == 'y') {
                                $hook .= ',' . substr($hook, 0, strlen($hook) - 1) . 'ies';
                            } elseif (substr($hook, -1) != 's' && $hook != 'quiz') {
                                $hook .= ',' . $hook . 's';
                            }
                        }
                        $list->attach(form_input_list_entry($hook, $hook == $default));
                    }
                    if ($block == 'main_search' && $parameter == 'limit_to' || $block == 'side_tag_cloud') {
                        $fields->attach(form_input_multi_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, 0));
                    } else {
                        $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                    }
                } elseif (($default == '0' || $default == '1' || strpos($description, '\'0\'') !== false || strpos($description, '\'1\'') !== false) && do_lang('BLOCK_IND_WHETHER') != '' && strpos(strtolower($description), do_lang('BLOCK_IND_WHETHER')) !== false) {
                    $fields->attach(form_input_tick(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $default == '1'));
                } elseif (do_lang('BLOCK_IND_NUMERIC') != '' && strpos($description, do_lang('BLOCK_IND_NUMERIC')) !== false) {
                    $fields->attach(form_input_integer(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $default == '' ? NULL : intval($default), false));
                } else {
                    $fields->attach(form_input_line(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $default, false));
                }
            }
        }
        $keep = symbol_tempcode('KEEP');
        $post_url = find_script('block_helper') . '?type=step3&field_name=' . get_param('field_name') . $keep->evaluate();
        if (get_param('utheme', '') != '') {
            $post_url .= '&utheme=' . get_param('utheme');
        }
        $post_url .= '&block_type=' . $type_wanted;
        if (get_param('save_to_id', '') != '') {
            $post_url .= '&save_to_id=' . urlencode(get_param('save_to_id'));
            $submit_name = do_lang_tempcode('SAVE');
            // Allow remove option
            $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => false, 'TITLE' => do_lang_tempcode('ACTIONS'), 'HELP' => '')));
            $fields->attach(form_input_tick(do_lang_tempcode('REMOVE'), '', '_delete', false));
        } else {
            $submit_name = do_lang_tempcode('USE');
        }
        $block_description = do_lang('BLOCK_' . $block . '_DESCRIPTION', NULL, NULL, NULL, NULL, false);
        if (is_null($block_description)) {
            $block_description = '';
        }
        $block_use = do_lang('BLOCK_' . $block . '_USE', NULL, NULL, NULL, NULL, false);
        if (is_null($block_use)) {
            $block_use = '';
        }
        if ($block_description == '' && $block_use == '') {
            $text = new ocp_tempcode();
        } else {
            $text = do_lang_tempcode('BLOCK_HELPER_2', escape_html(cleanup_block_name($block)), escape_html($block_description), escape_html($block_use));
        }
        $hidden = form_input_hidden('block', $block);
        $content = do_template('FORM_SCREEN', array('_GUID' => '270058349d048a8be6570bba97c81fa2', 'TITLE' => $title, 'TARGET' => '_self', 'SKIP_VALIDATION' => true, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name, 'HIDDEN' => $hidden, 'PREVIEW' => true, 'THEME' => $GLOBALS['FORUM_DRIVER']->get_theme()));
        if ($fields->is_empty()) {
            $type = 'step3';
        }
    }
    if ($type == 'step3') {
        require_javascript('javascript_posting');
        require_javascript('javascript_editing');
        $field_name = get_param('field_name');
        $bparameters = '';
        $bparameters_xml = '';
        $bparameters_tempcode = '';
        $block = trim(either_param('block'));
        $parameters = get_block_parameters($block);
        $parameters[] = 'failsafe';
        $parameters[] = 'cache';
        $parameters[] = 'quick_cache';
        if (in_array('param', $parameters)) {
            $_parameters = array('param');
            unset($parameters[array_search('param', $parameters)]);
            $parameters = array_merge($_parameters, $parameters);
        }
        foreach ($parameters as $parameter) {
            $value = post_param($parameter, NULL);
            if (is_null($value)) {
                if (post_param_integer('tick_on_form__' . $parameter, NULL) === NULL) {
                    continue;
                }
                // If not on form, continue, otherwise must be 0
                $value = '0';
            }
            if ($value != '' && ($parameter != 'failsafe' || $value == '1') && ($parameter != 'cache' || $value != block_cache_default($block)) && ($parameter != 'quick_cache' || $value == '1')) {
                if ($parameter == 'param') {
                    $bparameters .= '="' . str_replace('"', '\\"', $value) . '"';
                } else {
                    $bparameters .= ' ' . $parameter . '="' . str_replace('"', '\\"', $value) . '"';
                }
                $bparameters_xml = '<blockParam key="' . escape_html($parameter) . '" val="' . escape_html($value) . '" />';
                $bparameters_tempcode .= ',' . $parameter . '=' . str_replace(',', '\\,', $value);
            }
        }
        $comcode = '[block' . $bparameters . ']' . $block . '[/block]';
        $comcode_xml = '<block>' . $bparameters_xml . $block . '</block>';
        $tempcode = '{$BLOCK,block=' . $block . $bparameters_tempcode . '}';
        if ($type_wanted == 'template') {
            $comcode = $tempcode;
        }
        // This is what will be written in
        $comcode_semihtml = comcode_to_tempcode($comcode, NULL, false, 60, NULL, NULL, true, false, false);
        $content = do_template('BLOCK_HELPER_DONE', array('_GUID' => '575d6c8120d6001c8156560be518f296', 'TITLE' => $title, 'FIELD_NAME' => $field_name, 'BLOCK' => $block, 'COMCODE_XML' => $comcode_xml, 'COMCODE' => $comcode, 'COMCODE_SEMIHTML' => $comcode_semihtml));
    }
    global $EXTRA_HEAD;
    if (!isset($EXTRA_HEAD)) {
        $EXTRA_HEAD = new ocp_tempcode();
    }
    $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />');
    // XHTMLXHTML
    $echo = do_template('POPUP_HTML_WRAP', array('TITLE' => do_lang_tempcode('BLOCK_HELPER'), 'CONTENT' => $content));
    $echo->handle_symbol_preprocessing();
    $echo->evaluate_echo();
}
Beispiel #9
0
 /**
  * Get the form fields for an event input form.
  *
  * @param  ?AUTO_LINK		The event type (NULL: default)
  * @param  ?integer			The year the event starts at (NULL: default)
  * @param  ?integer			The month the event starts at (NULL: default)
  * @param  ?integer			The day the event starts at (NULL: default)
  * @param  ?integer			The hour the event starts at (NULL: default)
  * @param  ?integer			The minute the event starts at (NULL: default)
  * @param  SHORT_TEXT		The title of the event
  * @param  LONG_TEXT			The full text describing the event
  * @param  SHORT_TEXT		The recurrence code
  * @param  ?integer			The number of recurrences (NULL: none/infinite)
  * @param  BINARY				Whether to segregate the comment-topics/rating/trackbacks per-recurrence
  * @param  BINARY				Whether it is a public event
  * @param  integer			The priority
  * @range  1 5
  * @param  ?integer			The year the event ends at (NULL: not a multi day event)
  * @param  ?integer			The month the event ends at (NULL: not a multi day event)
  * @param  ?integer			The day the event ends at (NULL: not a multi day event)
  * @param  ?integer			The hour the event ends at (NULL: not a multi day event)
  * @param  ?integer			The minute the event ends at (NULL: not a multi day event)
  * @param  ?ID_TEXT			The timezone for the event (NULL: current user's timezone)
  * @param  BINARY				Whether the time should be presented in the viewer's own timezone
  * @param  BINARY				Whether the event is validated
  * @param  ?BINARY			Whether rating is allowed (NULL: decide statistically, based on existing choices)
  * @param  ?SHORT_INTEGER	Whether comments are allowed (0=no, 1=yes, 2=review style) (NULL: decide statistically, based on existing choices)
  * @param  ?BINARY			Whether trackbacks are allowed (NULL: decide statistically, based on existing choices)
  * @param  LONG_TEXT			Notes
  * @return array				A tuple of: (fields, hidden-fields, delete-fields, edit-text, whether all delete fields are specified, posting form text, more fields)
  */
 function get_form_fields($type = NULL, $start_year = NULL, $start_month = NULL, $start_day = NULL, $start_hour = NULL, $start_minute = NULL, $title = '', $content = '', $recurrence = 'none', $recurrences = NULL, $seg_recurrences = 0, $is_public = 1, $priority = 3, $end_year = NULL, $end_month = NULL, $end_day = NULL, $end_hour = NULL, $end_minute = NULL, $timezone = NULL, $do_timezone_conv = 0, $validated = 1, $allow_rating = NULL, $allow_comments = NULL, $allow_trackbacks = NULL, $notes = '')
 {
     list($allow_rating, $allow_comments, $allow_trackbacks) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, $allow_trackbacks);
     unset($content);
     if (is_null($timezone) || $timezone == '') {
         $timezone = get_users_timezone();
     }
     require_code('form_templates');
     if (is_null($type)) {
         global $NON_CANONICAL_PARAMS;
         $NON_CANONICAL_PARAMS[] = 'date';
         $NON_CANONICAL_PARAMS[] = 'e_type';
         $NON_CANONICAL_PARAMS[] = 'validated';
         $date = get_param('date', '');
         $start_hour = NULL;
         $start_minute = NULL;
         if ($date != '') {
             $date2 = explode(' ', $date);
             $exploded = explode('-', $date2[0]);
             //if (count($exploded)!=3) warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
             $start_year = intval($exploded[0]);
             $start_month = intval($exploded[1]);
             $start_day = intval($exploded[2]);
             if (array_key_exists(1, $date2)) {
                 $exploded = explode(':', $date2[1]);
                 //if (count($exploded)!=2) warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
                 $start_hour = intval($exploded[0]);
                 $start_minute = intval($exploded[1]);
             }
         } else {
             list($start_year, $start_month, $start_day) = array(NULL, NULL, NULL);
         }
         $type = get_param_integer('e_type', -1);
         if ($type == -1) {
             $type = NULL;
         }
         $adding = true;
     } else {
         $adding = false;
     }
     if (is_null($type)) {
         $type = db_get_first_id() + 1;
     }
     if (is_null($start_month)) {
         $start_year = intval(date('Y'));
         $start_month = intval(date('m'));
         $start_day = intval(date('d'));
         $start_hour = NULL;
         $start_minute = NULL;
     }
     if ((is_null($end_year) || is_null($end_month) || is_null($end_day)) && $adding) {
         $end_year = NULL;
         //$start_year;
         $end_month = NULL;
         //$start_month;
         $end_day = NULL;
         //$start_day;
         $end_hour = NULL;
         $end_minute = NULL;
     }
     $fields = new ocp_tempcode();
     $hidden = new ocp_tempcode();
     $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true));
     //$fields->attach(form_input_text_comcode(do_lang_tempcode('EVENT_TEXT'),do_lang_tempcode('DESCRIPTION_EVENT_TEXT'),'content',$content,false));
     // Type
     $type_list = nice_get_event_types($type);
     $fields->attach(form_input_list(do_lang_tempcode('TYPE'), do_lang_tempcode('DESCRIPTION_EVENT_TYPE'), 'type', $type_list));
     // Dates
     $fields->attach(form_input_tick(do_lang_tempcode('ALL_DAY_EVENT'), do_lang_tempcode('DESCRIPTION_ALL_DAY_EVENT'), 'all_day_event', is_null($start_hour)));
     $fields->attach(form_input_date(do_lang_tempcode('DATE_TIME'), '', 'start', false, false, true, array(is_null($start_minute) ? find_timezone_start_minute_in_utc($timezone, $start_year, $start_month, $start_day) : $start_minute, is_null($start_hour) ? find_timezone_start_hour_in_utc($timezone, $start_year, $start_month, $start_day) : $start_hour, $start_month, $start_day, $start_year), 120, intval(date('Y')) - 100, NULL, NULL, true, $timezone, get_param('date', '') == ''));
     $fields->attach(form_input_date(do_lang_tempcode('END_DATE_AND_TIME'), do_lang_tempcode('DESCRIPTION_END_DATE_AND_TIME'), 'end', true, is_null($end_year), true, array(is_null($end_minute) ? find_timezone_end_minute_in_utc($timezone, $end_year, $end_month, $end_day) : $end_minute, is_null($end_hour) ? find_timezone_end_hour_in_utc($timezone, $end_year, $end_month, $end_day) : $end_hour, $end_month, $end_day, $end_year), 120, intval(date('Y')) - 100, NULL, NULL, true, $timezone));
     if ($validated == 0) {
         $validated = get_param_integer('validated', 0);
     }
     if (has_some_cat_specific_permission(get_member(), 'bypass_validation_' . $this->permissions_require . 'range_content', NULL, $this->permissions_cat_require)) {
         if (addon_installed('unvalidated')) {
             $fields->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated == 1));
         }
     }
     $fields2 = new ocp_tempcode();
     $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('ADVANCED'))));
     // More date stuff
     $list = '';
     foreach (get_timezone_list() as $_timezone => $timezone_nice) {
         $list .= static_evaluate_tempcode(form_input_list_entry($_timezone, $_timezone == $timezone, $timezone_nice));
     }
     $fields2->attach(form_input_list(do_lang_tempcode('EVENT_TIMEZONE'), do_lang_tempcode('DESCRIPTION_EVENT_TIMEZONE'), 'timezone', make_string_tempcode($list)));
     $fields2->attach(form_input_tick(do_lang_tempcode('DO_TIMEZONE_CONV'), do_lang_tempcode('DESCRIPTION_DO_TIMEZONE_CONV'), 'do_timezone_conv', $do_timezone_conv == 1));
     if (has_specific_permission(get_member(), 'add_public_events')) {
         $fields2->attach(form_input_tick(do_lang_tempcode('IS_PUBLIC'), do_lang_tempcode('DESCRIPTION_IS_PUBLIC'), 'is_public', $is_public == 1));
     }
     // Priority
     $priority_list = new ocp_tempcode();
     $priority_list->attach(form_input_list_entry('1', $priority == 1, do_lang_tempcode('PRIORITY_1')));
     $priority_list->attach(form_input_list_entry('2', $priority == 2, do_lang_tempcode('PRIORITY_2')));
     $priority_list->attach(form_input_list_entry('3', $priority == 3, do_lang_tempcode('PRIORITY_3')));
     $priority_list->attach(form_input_list_entry('4', $priority == 4, do_lang_tempcode('PRIORITY_4')));
     $priority_list->attach(form_input_list_entry('5', $priority == 5, do_lang_tempcode('PRIORITY_5')));
     $fields2->attach(form_input_list(do_lang_tempcode('PRIORITY'), '', 'priority', $priority_list));
     // Recurrence
     $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('RECURRENCE'))));
     if (strpos($recurrence, ' ') === false) {
         $recurrence_main = $recurrence;
         $recurrence_pattern = '';
     } else {
         list($recurrence_main, $recurrence_pattern) = explode(' ', $recurrence);
     }
     $radios = form_input_radio_entry('recurrence', 'none', true, do_lang_tempcode('NA_EM'));
     $radios->attach(form_input_radio_entry('recurrence', 'daily', $recurrence_main == 'daily', do_lang_tempcode('DAILY')));
     $radios->attach(form_input_radio_entry('recurrence', 'weekly', $recurrence_main == 'weekly', do_lang_tempcode('WEEKLY')));
     $radios->attach(form_input_radio_entry('recurrence', 'monthly', $recurrence_main == 'monthly', do_lang_tempcode('MONTHLY')));
     $radios->attach(form_input_radio_entry('recurrence', 'yearly', $recurrence_main == 'yearly', do_lang_tempcode('YEARLY')));
     $fields2->attach(form_input_radio(do_lang_tempcode('RECURRENCE'), do_lang_tempcode('DESCRIPTION_RECURRENCE'), 'recurrence', $radios));
     // xth_dotw_of_monthly
     $fields2->attach(form_input_line(do_lang_tempcode('RECURRENCE_PATTERN'), do_lang_tempcode('DESCRIPTION_RECURRENCE_PATTERN'), 'recurrence_pattern', $recurrence_pattern, false));
     $fields2->attach(form_input_integer(do_lang_tempcode('RECURRENCES'), do_lang_tempcode('DESCRIPTION_RECURRENCES'), 'recurrences', $recurrences, false));
     $fields2->attach(form_input_tick(do_lang_tempcode('SEG_RECURRENCES'), do_lang_tempcode('DESCRIPTION_SEG_RECURRENCES'), 'seg_recurrences', $seg_recurrences == 1));
     if ($adding && cron_installed()) {
         $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('REMINDERS'))));
         $fields2->attach(form_input_tick(do_lang_tempcode('SIGN_UP_REMINDER'), do_lang_tempcode('DESCRIPTION_SIGN_UP_REMINDER'), 'sign_up_reminder', true));
         if (has_specific_permission(get_member(), 'add_public_events')) {
             $usergroup_list = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true);
             if (get_forum_type() == 'ocf') {
                 unset($usergroup_list[db_get_first_id()]);
             }
             $t_usergroup_list = new ocp_tempcode();
             foreach ($usergroup_list as $id => $name) {
                 $t_usergroup_list->attach(form_input_list_entry(strval($id), false, $name));
             }
             $fields2->attach(form_input_all_and_not(do_lang_tempcode('SIGN_UP_REMINDER_GROUPS'), do_lang_tempcode('DESCRIPTION_SIGN_UP_REMINDER_GROUPS'), 'sign_up_reminder_groups', $t_usergroup_list));
         }
         $fields2->attach(form_input_float(do_lang_tempcode('REMINDER_TIME'), do_lang_tempcode('DESCRIPTION_REMINDER_TIME'), 'hours_before', 1.0, true));
     }
     require_code('feedback2');
     $fields2->attach(feedback_fields($allow_rating == 1, $allow_comments == 1, $allow_trackbacks == 1, false, $notes, $allow_comments == 2));
     $fields2->attach(get_syndication_option_fields());
     return array($fields, $hidden, NULL, NULL, true, NULL, $fields2);
 }
Beispiel #10
0
 /**
  * The UI to select an IMAP server for bounce filtering.
  *
  * @return tempcode		The UI
  */
 function bounce_filter_a()
 {
     $title = get_page_title('BOUNCE_FILTER');
     if (!function_exists('imap_open')) {
         warn_exit(do_lang_tempcode('IMAP_NEEDED'));
     }
     $fields = new ocp_tempcode();
     require_code('form_templates');
     $fields->attach(form_input_line(do_lang_tempcode('HOST'), new ocp_tempcode(), 'server', 'localhost', true));
     $fields->attach(form_input_line(do_lang_tempcode('USERNAME'), new ocp_tempcode(), 'username', '', true));
     $fields->attach(form_input_password(do_lang_tempcode('PASSWORD'), new ocp_tempcode(), 'password', true));
     $fields->attach(form_input_integer(do_lang_tempcode('PORT'), new ocp_tempcode(), 'port', 143, true));
     $submit_name = do_lang_tempcode('PROCEED');
     $post_url = get_self_url();
     $post_url = build_url(array('page' => '_SELF', 'type' => 'bounce_filter_b'), '_SELF');
     return do_template('FORM_SCREEN', array('SKIP_VALIDATION' => true, 'HIDDEN' => '', 'TITLE' => $title, 'TEXT' => do_lang_tempcode('ENTER_IMAP_DETAILS'), 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url));
 }
Beispiel #11
0
 /**
  * The actualiser for setting up account confirmation.
  *
  * @return tempcode		The UI
  */
 function step4()
 {
     $title = get_page_title('_JOIN');
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('_JOIN'))));
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     // Check confirm code correct
     $_code = get_param('code', '-1');
     // -1 allowed because people often seem to mess the e-mail link up
     $code = intval($_code);
     if ($code <= 0) {
         require_code('form_templates');
         $fields = new ocp_tempcode();
         $fields->attach(form_input_email(do_lang_tempcode('EMAIL_ADDRESS'), '', 'email', '', true));
         $fields->attach(form_input_integer(do_lang_tempcode('CODE'), '', 'code', NULL, true));
         $submit_name = do_lang_tempcode('PROCEED');
         return do_template('FORM_SCREEN', array('_GUID' => 'e2c8c3762a308ac7489ec3fb32cc0cf8', 'TITLE' => $title, 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'URL' => get_self_url(false, false, NULL, false, true), 'FIELDS' => $fields, 'TEXT' => do_lang_tempcode('MISSING_CONFIRM_CODE'), 'SUBMIT_NAME' => $submit_name));
     }
     $rows = $GLOBALS['FORUM_DB']->query_select('f_members', array('id', 'm_validated'), array('m_validated_email_confirm_code' => strval($code), 'm_email_address' => trim(get_param('email'))));
     if (!array_key_exists(0, $rows)) {
         $rows = $GLOBALS['FORUM_DB']->query_select('f_members', array('id', 'm_validated'), array('m_validated_email_confirm_code' => '', 'm_email_address' => trim(get_param('email'))));
         if (!array_key_exists(0, $rows)) {
             warn_exit(do_lang_tempcode('INCORRECT_CONFIRM_CODE'));
         } else {
             $redirect = get_param('redirect', '');
             $map = array('page' => 'login', 'type' => 'misc');
             if ($redirect != '') {
                 $map['redirect'] = $redirect;
             }
             $url = build_url($map, get_module_zone('login'));
             return redirect_screen($title, $url, do_lang_tempcode('ALREADY_CONFIRMED_THIS'));
         }
     }
     $id = $rows[0]['id'];
     $validated = $rows[0]['m_validated'];
     // Activate user
     $GLOBALS['FORUM_DB']->query_update('f_members', array('m_validated_email_confirm_code' => ''), array('id' => $id), '', 1);
     if ($validated == 0) {
         return inform_screen($title, do_lang_tempcode('AWAITING_MEMBER_VALIDATION'));
     }
     // Alert user to situation
     $redirect = get_param('redirect', '');
     $map = array('page' => 'login', 'type' => 'misc');
     if ($redirect != '') {
         $map['redirect'] = $redirect;
     }
     $url = build_url($map, get_module_zone('login'));
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESSFUL_CONFIRM'));
 }
Beispiel #12
0
 /**
  * Get form inputter.
  *
  * @param  string			The field name
  * @param  string			The field description
  * @param  array			The field details
  * @param  ?string		The actual current value of the field (NULL: none)
  * @param  boolean		Whether this is for a new entry
  * @return ?tempcode		The Tempcode for the input field (NULL: skip the field - it's not input)
  */
 function get_field_inputter($_cf_name, $_cf_description, $field, $actual_value, $new)
 {
     if ($new) {
         return NULL;
     }
     return form_input_integer($_cf_name, $_cf_description, 'field_' . strval($field['id']), is_null($actual_value) ? NULL : intval($actual_value), $field['cf_required'] == 1);
 }
Beispiel #13
0
 /**
  * Get tempcode for a flagrant-message adding/editing form.
  *
  * @param  SHORT_TEXT	The message
  * @param  integer		The number of days to display for
  * @param  LONG_TEXT		Notes
  * @param  BINARY			Whether the message is for immediate use
  * @return tempcode		The tempcode for the fields
  */
 function get_form_fields($message = '', $days = 1, $notes = '', $validated = 0)
 {
     $fields = new ocp_tempcode();
     require_code('form_templates');
     $fields->attach(form_input_line_comcode(do_lang_tempcode('MESSAGE'), do_lang_tempcode('DESCRIPTION_MESSAGE'), 'message', $message, true));
     $fields->attach(form_input_integer(do_lang_tempcode('NUMBER_DAYS'), do_lang_tempcode('NUMBER_DAYS_DESCRIPTION'), 'days', $days, true));
     if (get_value('disable_staff_notes') !== '1') {
         $fields->attach(form_input_text(do_lang_tempcode('NOTES'), do_lang_tempcode('DESCRIPTION_NOTES'), 'notes', $notes, false));
     }
     $fields->attach(form_input_tick(do_lang_tempcode('IMMEDIATE_USE'), do_lang_tempcode('DESCRIPTION_IMMEDIATE_USE'), 'validated', $validated == 1));
     return $fields;
 }
Beispiel #14
0
 /**
  * Get tempcode for a adding/editing form.
  *
  * @param  SHORT_TEXT	The name of the quiz
  * @param  ?integer		The number of minutes allowed for completion (NULL: NA)
  * @param  LONG_TEXT		The text shown at the start of the quiz
  * @param  LONG_TEXT		The text shown at the end of the quiz
  * @param  LONG_TEXT		The text shown at the end of the quiz on failure
  * @param  LONG_TEXT		Notes
  * @param  integer		Percentage correctness required for competition
  * @param  ?TIME			The time the quiz is opened (NULL: now)
  * @param  ?TIME			The time the quiz is closed (NULL: never)
  * @param  integer		The number of winners for this if it is a competition
  * @param  ?integer		The minimum number of hours between attempts (NULL: no restriction)
  * @param  ID_TEXT		The type
  * @set    SURVEY COMPETITION TEST
  * @param  BINARY			Whether this is validated
  * @param  ?string		Text for questions (NULL: default)
  * @param  integer		The number of points awarded for completing/passing the quiz/test
  * @param  ?AUTO_LINK	Newsletter for which a member must be on to enter (NULL: none)
  * @return tempcode		The form fields
  */
 function get_form_fields($name = '', $timeout = NULL, $start_text = '', $end_text = '', $end_text_fail = '', $notes = '', $percentage = 70, $open_time = NULL, $close_time = NULL, $num_winners = 2, $redo_time = NULL, $type = 'COMPETITION', $validated = 1, $text = NULL, $points_for_passing = 0, $tied_newsletter = NULL)
 {
     if (is_null($open_time)) {
         $open_time = time();
     }
     if (is_null($text)) {
         $text = do_lang('EXAMPLE_QUESTIONS');
     }
     $fields = new ocp_tempcode();
     $fields->attach(form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'name', $name, true));
     $list = new ocp_tempcode();
     $list->attach(form_input_list_entry('SURVEY', $type == 'SURVEY', do_lang_tempcode('SURVEY')));
     $list->attach(form_input_list_entry('TEST', $type == 'TEST', do_lang_tempcode('TEST')));
     $list->attach(form_input_list_entry('COMPETITION', $type == 'COMPETITION', do_lang_tempcode('COMPETITION')));
     $fields->attach(form_input_list(do_lang_tempcode('TYPE'), do_lang_tempcode('DESCRIPTION_QUIZ_TYPE'), 'type', $list, NULL, true));
     $fields->attach(form_input_huge(do_lang_tempcode('QUESTIONS'), do_lang_tempcode('IMPORT_QUESTIONS_TEXT'), 'text', $text, true));
     if ($validated == 0) {
         global $NON_CANONICAL_PARAMS;
         $NON_CANONICAL_PARAMS[] = 'validated';
         $validated = get_param_integer('validated', 0);
         if ($validated == 1) {
             attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING'));
         }
     }
     if (addon_installed('unvalidated')) {
         $fields->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED_SIMPLE'), 'validated', $validated == 1));
     }
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('TEST'))));
     $fields->attach(form_input_integer(do_lang_tempcode('COMPLETION_PERCENTAGE'), do_lang_tempcode('DESCRIPTION_COMPLETION_PERCENTAGE'), 'percentage', $percentage, true));
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('TEXT'), 'SECTION_HIDDEN' => true)));
     $fields->attach(form_input_text_comcode(do_lang_tempcode('QUIZ_START_TEXT'), do_lang_tempcode('DESCRIPTION_QUIZ_START_TEXT'), 'start_text', $start_text, false));
     $fields->attach(form_input_text_comcode(do_lang_tempcode('QUIZ_END_TEXT'), do_lang_tempcode('DESCRIPTION_QUIZ_END_TEXT'), 'end_text', $end_text, false));
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('COMPETITION'))));
     $fields->attach(form_input_integer(do_lang_tempcode('NUM_WINNERS'), do_lang_tempcode('DESCRIPTION_NUM_WINNERS'), 'num_winners', $num_winners, true));
     $fields->attach(form_input_text_comcode(do_lang_tempcode('QUIZ_END_TEXT_FAIL'), do_lang_tempcode('DESCRIPTION_QUIZ_END_TEXT_FAIL'), 'end_text_fail', $end_text_fail, false));
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => is_null($redo_time) && is_null($timeout) && (is_null($open_time) || $open_time <= time()) && is_null($close_time) && $points_for_passing == 0 && is_null($tied_newsletter) && $notes == '', 'TITLE' => do_lang_tempcode('ADVANCED'))));
     $fields->attach(form_input_integer(do_lang_tempcode('REDO_TIME'), do_lang_tempcode('DESCRIPTION_REDO_TIME'), 'redo_time', $redo_time, false));
     $fields->attach(form_input_integer(do_lang_tempcode('TIMEOUT'), do_lang_tempcode('DESCRIPTION_QUIZ_TIMEOUT'), 'timeout', $timeout, false));
     $fields->attach(form_input_date(do_lang_tempcode('OPEN_TIME'), do_lang_tempcode('DESCRIPTION_OPEN_TIME'), 'open_time', false, false, true, $open_time, 2));
     $fields->attach(form_input_date(do_lang_tempcode('CLOSE_TIME'), do_lang_tempcode('DESCRIPTION_CLOSE_TIME'), 'close_time', true, is_null($close_time), true, is_null($close_time) ? NULL : $close_time, 2));
     if (addon_installed('points')) {
         $fields->attach(form_input_integer(do_lang_tempcode('POINTS_FOR_COMPLETING'), do_lang_tempcode('DESCRIPTION_POINTS_FOR_COMPLETING'), 'points_for_passing', $points_for_passing, true));
     }
     if (addon_installed('newsletter')) {
         $newsletters = new ocp_tempcode();
         $newsletters->attach(form_input_list_entry('', false, do_lang_tempcode('NONE_EM')));
         $_newsletters = $GLOBALS['SITE_DB']->query_select('newsletters', array('*'), NULL, 'ORDER BY id');
         foreach ($_newsletters as $n) {
             $newsletters->attach(form_input_list_entry(strval($n['id']), $tied_newsletter == $n['id'], get_translated_text($n['title'])));
         }
         if (!$newsletters->is_empty()) {
             $fields->attach(form_input_list(do_lang_tempcode('TIED_TO_NEWSLETTER'), do_lang_tempcode('DESCRIPTION_TIED_TO_NEWSLETTER'), 'tied_newsletter', $newsletters, NULL, false, false));
         }
     }
     if (get_value('disable_staff_notes') !== '1') {
         $fields->attach(form_input_text(do_lang_tempcode('NOTES'), do_lang_tempcode('DESCRIPTION_NOTES'), 'notes', $notes, false));
     }
     return $fields;
 }
Beispiel #15
0
 /**
  * Get tempcode for a catalogue adding/editing form.
  *
  * @param  ID_TEXT			The name of the catalogue
  * @param  SHORT_TEXT		The human readable name/title of the catalogue
  * @param  LONG_TEXT			The description
  * @param  SHORT_INTEGER	The display type
  * @param  BINARY				Whether the catalogue uses a hierarchy
  * @param  LONG_TEXT			Admin notes
  * @param  integer			How many points are given to a member that submits to the catalogue
  * @param  BINARY				Whether the catalogue is an eCommerce catalogue
  * @param  ID_TEXT			How to send view reports
  * @set    never daily weekly monthly quarterly
  * @return array				A tuple: the tempcode for the visible fields, and the tempcode for the hidden fields, ..., and action fields
  */
 function get_form_fields($name = '', $title = '', $description = '', $display_type = 0, $is_tree = 1, $notes = '', $submit_points = 0, $ecommerce = 0, $send_view_reports = 'never')
 {
     $fields = new ocp_tempcode();
     $hidden = new ocp_tempcode();
     require_code('form_templates');
     if ($name == '') {
         $name = get_param('id', '');
     }
     $tied_to_content_type = substr($name, 0, 1) == '_' && (file_exists(get_file_base() . '/sources_custom/hooks/systems/awards/' . substr($name, 1) . '.php') || file_exists(get_file_base() . '/sources/hooks/systems/awards/' . substr($name, 1) . '.php'));
     if ($tied_to_content_type) {
         $content_type = substr($name, 1);
         require_code('hooks/systems/awards/' . $content_type);
         $ob = object_factory('Hook_awards_' . $content_type);
         $info = $ob->info();
         $title = do_lang('CUSTOM_FIELDS_FOR', $info['title']->evaluate());
         $hidden->attach(form_input_hidden('title', $title));
         $hidden->attach(form_input_hidden('name', $name));
         $hidden->attach(form_input_hidden('description', ''));
         $hidden->attach(form_input_hidden('notes', ''));
         $hidden->attach(form_input_hidden('auto_fill', ''));
         $hidden->attach(form_input_hidden('display_type', '0'));
         $hidden->attach(form_input_hidden('submit_points', '0'));
         $hidden->attach(form_input_hidden('send_view_reports', 'never'));
         attach_message(do_lang_tempcode('EDITING_CUSTOM_FIELDS_HELP', $info['title']));
         $actions = new ocp_tempcode();
     } else {
         $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true));
         $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_CODENAME'), 'name', $name, true));
         $fields->attach(form_input_text_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_CATALOGUE_DESCRIPTION'), 'description', $description, false));
         $display_types = new ocp_tempcode();
         $display_types->attach(form_input_list_entry(strval(0), $display_type == 0, do_lang_tempcode('DT_MAPS')));
         $display_types->attach(form_input_list_entry(strval(1), $display_type == 1, do_lang_tempcode('DT_LIST')));
         $display_types->attach(form_input_list_entry(strval(2), $display_type == 2, do_lang_tempcode('DT_MATRIX')));
         $fields->attach(form_input_list(do_lang_tempcode('DISPLAY_TYPE'), do_lang_tempcode('DESCRIPTION_DISPLAY_TYPE'), 'display_type', $display_types));
         if (addon_installed('shopping')) {
             if ($ecommerce == 1) {
                 if (get_forum_type() != 'ocf') {
                     warn_exit(do_lang_tempcode('NO_OCF'));
                 }
             }
             $fields->attach(form_input_tick(do_lang_tempcode('CAT_ECOMMERCE'), do_lang_tempcode('DESCRIPTION_CAT_ECOMMERCE'), 'ecommerce', $ecommerce == 1));
         }
         $fields->attach(form_input_tick(do_lang_tempcode('IS_TREE'), do_lang_tempcode('DESCRIPTION_IS_TREE'), 'is_tree', $is_tree == 1));
         if ($name == '') {
             $fields->attach(form_input_line(do_lang_tempcode('AUTO_FILL'), do_lang_tempcode('DESCRIPTION_AUTO_FILL'), 'auto_fill', '', false, NULL, 10000));
         }
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $notes == '' && $submit_points == 0 && $send_view_reports == 'never', 'TITLE' => do_lang_tempcode('ADVANCED'))));
         if (get_value('disable_staff_notes') !== '1') {
             $fields->attach(form_input_text(do_lang_tempcode('NOTES'), do_lang_tempcode('DESCRIPTION_NOTES'), 'notes', $notes, false));
         }
         if (addon_installed('points')) {
             $fields->attach(form_input_integer(do_lang_tempcode('SUBMIT_POINTS'), do_lang_tempcode('DESCRIPTION_SUBMIT_POINTS'), 'submit_points', $submit_points, false));
         }
         $view_report_types = new ocp_tempcode();
         $view_report_types->attach(form_input_list_entry('never', $send_view_reports == 'never', do_lang_tempcode('VR_NEVER')));
         $view_report_types->attach(form_input_list_entry('daily', $send_view_reports == 'daily', do_lang_tempcode('VR_DAILY')));
         $view_report_types->attach(form_input_list_entry('weekly', $send_view_reports == 'weekly', do_lang_tempcode('VR_WEEKLY')));
         $view_report_types->attach(form_input_list_entry('monthly', $send_view_reports == 'monthly', do_lang_tempcode('VR_MONTHLY')));
         $view_report_types->attach(form_input_list_entry('quarterly', $send_view_reports == 'quarterly', do_lang_tempcode('VR_QUARTERLY')));
         $fields->attach(form_input_list(do_lang_tempcode('VIEW_REPORTS'), do_lang_tempcode('DESCRIPTION_VIEW_REPORTS'), 'send_view_reports', $view_report_types));
         // Permissions
         $fields->attach($this->get_permission_fields($name, NULL, $name == ''));
         $actions = new ocp_tempcode();
         if ($name != '' && get_value('disable_cat_cat_perms') !== '1') {
             $actions->attach(form_input_tick(do_lang_tempcode('RESET_CATEGORY_PERMISSIONS'), do_lang_tempcode('DESCRIPTION_RESET_CATEGORY_PERMISSIONS'), 'reset_category_permissions', false));
         }
         if ($name == '') {
             $actions->attach(form_input_tick(do_lang_tempcode('ADD_TO_MENU'), do_lang_tempcode('DESCRIPTION_ADD_TO_MENU'), 'add_to_menu', true));
         }
     }
     return array($fields, $hidden, NULL, NULL, false, NULL, $actions);
 }
Beispiel #16
0
/**
 * Outputs a Comcode tag helper dialog.
 */
function comcode_helper_script()
{
    require_lang('comcode');
    $type = get_param('type', 'step1');
    list($tag_list, $custom_tag_list) = _get_details_comcode_tags();
    require_code('comcode_text');
    global $DANGEROUS_TAGS, $TEXTUAL_TAGS;
    if ($type == 'step1') {
        $title = get_page_title('COMCODE_TAG');
        $keep = symbol_tempcode('KEEP');
        $comcode_groups = '';
        $groups = _get_group_tags();
        $non_wysiwyg_tags = _get_non_wysiwyg_tags();
        $in_wysiwyg = get_param_integer('in_wysiwyg', 0) == 1;
        foreach ($groups as $groupname => $grouptags) {
            sort($grouptags);
            $comcode_types = '';
            foreach ($grouptags as $tag) {
                $custom = array_key_exists($tag, $custom_tag_list);
                if ($in_wysiwyg && !$custom && !in_array($tag, $non_wysiwyg_tags)) {
                    continue;
                }
                if (array_key_exists($tag, $DANGEROUS_TAGS) && !has_specific_permission(get_member(), 'comcode_dangerous')) {
                    continue;
                }
                if ($custom) {
                    $description = make_string_tempcode(escape_html(is_integer($custom_tag_list[$tag]['tag_description']) ? get_translated_text($custom_tag_list[$tag]['tag_description']) : $custom_tag_list[$tag]['tag_description']));
                } else {
                    $description = do_lang_tempcode('COMCODE_TAG_' . $tag);
                }
                $url = find_script('comcode_helper') . '?type=step2&tag=' . urlencode($tag) . '&field_name=' . get_param('field_name') . $keep->evaluate();
                if (get_param('utheme', '') != '') {
                    $url .= '&utheme=' . get_param('utheme');
                }
                $link_caption = escape_html($tag);
                $usage = '';
                $comcode_types .= static_evaluate_tempcode(do_template('BLOCK_HELPER_BLOCK_CHOICE', array('USAGE' => $usage, 'DESCRIPTION' => $description, 'URL' => $url, 'LINK_CAPTION' => $link_caption)));
            }
            if ($comcode_types != '') {
                $comcode_groups .= static_evaluate_tempcode(do_template('BLOCK_HELPER_BLOCK_GROUP', array('IMG' => NULL, 'TITLE' => do_lang_tempcode('COMCODE_GROUP_' . $groupname), 'LINKS' => $comcode_types)));
            }
        }
        $content = do_template('BLOCK_HELPER_START', array('_GUID' => 'd2d6837cdd8b19d80ea95ab9f5d09c9a', 'GET' => true, 'TITLE' => $title, 'LINKS' => $comcode_groups));
    } elseif ($type == 'step2') {
        require_code('form_templates');
        $actual_tag = get_param('tag');
        if (!isset($tag_list[$actual_tag]) && !isset($custom_tag_list[$actual_tag])) {
            warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
        }
        $tag = $actual_tag;
        if ($tag == 'attachment_safe') {
            $tag = 'attachment';
        }
        $title = get_page_title('_COMCODE_HELPER', true, array($tag));
        $fields = new ocp_tempcode();
        $fields_advanced = new ocp_tempcode();
        $done_tag_contents = false;
        $hidden = new ocp_tempcode();
        $javascript = '';
        $preview = true;
        require_code('comcode_text');
        $defaults = parse_single_comcode_tag(get_param('parse_defaults', '', true), $actual_tag);
        $default_embed = array_key_exists('', $defaults) ? '[semihtml]' . $defaults[''] . '[/semihtml]' : get_param('default', '');
        $embed_required = true;
        if ($tag == 'contents') {
            $embed_required = false;
        }
        if (isset($custom_tag_list[$tag]['tag_description'])) {
            $tag_description = protect_from_escaping($custom_tag_list[$tag]['tag_description']);
        } else {
            $tag_description = protect_from_escaping(do_lang('COMCODE_TAG_' . $tag));
        }
        if (array_key_exists($tag, $tag_list)) {
            $params = $tag_list[$tag];
            if ($tag == 'include') {
                $default_embed = array_key_exists('', $defaults) ? $defaults[''] : get_param('default', '');
                if (strpos($default_embed, ':') === false) {
                    $default_embed = ':' . $default_embed;
                }
                $fields->attach(form_input_page_link(do_lang_tempcode('PAGE'), '', 'tag_contents', $default_embed, true, NULL, 'comcode'));
                $done_tag_contents = true;
            } elseif ($tag == 'concepts') {
                foreach ($params as $param) {
                    $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                    $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), 1));
                }
            } elseif ($tag == 'jumping') {
                foreach ($params as $param) {
                    $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                    $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), 2));
                }
            } elseif ($tag == 'shocker') {
                foreach ($params as $param) {
                    $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                    if ($param == 'left' || $param == 'right') {
                        $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), 2));
                    } else {
                        $fields->attach(form_input_line(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, '', false));
                    }
                }
            } elseif ($tag == 'random') {
                foreach ($params as $param) {
                    $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                    $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), $param != 'X' ? 2 : 0));
                }
            } elseif ($tag == 'sections') {
                foreach ($params as $param) {
                    if ($param == 'default') {
                        $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                        $default = array_key_exists($param, $defaults) ? $defaults[$param] : get_param('default_' . $param, '1');
                        $fields->attach(form_input_integer(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, intval($default), false));
                    } elseif ($param == 'name') {
                        $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                        $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), 2));
                    }
                }
            } elseif ($tag == 'big_tabs') {
                foreach ($params as $param) {
                    if ($param == 'default') {
                        $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                        $default = array_key_exists($param, $defaults) ? $defaults[$param] : get_param('default_' . $param, '1');
                        $fields->attach(form_input_integer(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, intval($default), false));
                    } elseif ($param == 'name') {
                        $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                        $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), 2));
                    } elseif ($param == 'switch_time') {
                        $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                        $default = array_key_exists($param, $defaults) ? $defaults[$param] : get_param('default_' . $param, '6000');
                        $fields->attach(form_input_integer(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, intval($default), false));
                    }
                }
            } elseif ($tag == 'tabs') {
                foreach ($params as $param) {
                    if ($param == 'default') {
                        $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                        $default = array_key_exists($param, $defaults) ? $defaults[$param] : get_param('default_' . $param, '1');
                        $fields->attach(form_input_integer(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, intval($default), false));
                    } elseif ($param == 'name') {
                        $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                        $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), 2));
                    }
                }
            } else {
                if (count($params) > 0) {
                    require_code('form_templates');
                    foreach ($params as $param) {
                        $parameter_name = do_lang('COMCODE_TAG_' . $tag . '_NAME_OF_PARAM_' . $param, NULL, NULL, NULL, NULL, false);
                        if (is_null($parameter_name)) {
                            $parameter_name = ucwords(str_replace('_', ' ', $param));
                        }
                        $descriptiont = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param);
                        $supports_comcode = strpos($descriptiont, do_lang('BLOCK_IND_SUPPORTS_COMCODE')) !== false;
                        $descriptiont = trim(str_replace(do_lang('BLOCK_IND_SUPPORTS_COMCODE'), '', $descriptiont));
                        $is_advanced = strpos($descriptiont, do_lang('BLOCK_IND_ADVANCED')) !== false;
                        $descriptiont = trim(str_replace(do_lang('BLOCK_IND_ADVANCED'), '', $descriptiont));
                        $default = array_key_exists($param, $defaults) ? $defaults[$param] : get_param('default_' . $param, '');
                        if (!array_key_exists($param, $defaults)) {
                            $matches = array();
                            if (preg_match('#' . do_lang('BLOCK_IND_DEFAULT') . ': ["\']([^"]*)["\']#Ui', $descriptiont, $matches) != 0) {
                                $default = $matches[1];
                            }
                        }
                        $descriptiont = preg_replace('#\\s*' . do_lang('BLOCK_IND_DEFAULT') . ': ["\']([^"]*)["\'](?-U)\\.?(?U)#Ui', '', $descriptiont);
                        if ($tag == 'page' && $param == 'param' && substr_count($default, ':') == 1) {
                            $fields->attach(form_input_page_link($parameter_name, protect_from_escaping($descriptiont), $param, $default, true, NULL));
                        } elseif ($tag == 'attachment' && $param == 'thumb_url' && addon_installed('filedump')) {
                            $field = form_input_tree_list(do_lang_tempcode('THUMBNAIL'), do_lang_tempcode('COMCODE_TAG_attachment_PARAM_thumb_url'), 'thumb_url', '', 'choose_filedump_file', array('only_images' => true), false, $default, false);
                            $fields_advanced->attach($field);
                        } else {
                            if (substr($descriptiont, 0, 12) == '0|1 &ndash; ') {
                                $field = form_input_tick($parameter_name, protect_from_escaping(ucfirst(substr($descriptiont, 12))), $param, $default == '1');
                            } elseif (substr($descriptiont, -1) != '.' && strpos($descriptiont, '|') !== false) {
                                $list = new ocp_tempcode();
                                if (substr($descriptiont, 0, 1) != '=') {
                                    $list->attach(form_input_list_entry(''));
                                }
                                foreach (explode('|', $descriptiont) as $item) {
                                    if (strpos($item, '=') !== false) {
                                        list($item, $label) = explode('=', $item, 2);
                                        // Simplify the choices
                                        if ($tag == 'attachment') {
                                            if ($item == 'inline_extract' && get_param_integer('is_archive', NULL) === 0) {
                                                continue;
                                            }
                                            if ($item == 'island_extract' && get_param_integer('is_archive', NULL) === 0) {
                                                continue;
                                            }
                                            if ($item == 'inline' && get_param_integer('is_image', NULL) === 0) {
                                                continue;
                                            }
                                            if ($item == 'island' && get_param_integer('is_image', NULL) === 0) {
                                                continue;
                                            }
                                            if ($item == 'code' && (get_param_integer('is_image', NULL) === 1 || get_param_integer('is_archive', NULL) === 1)) {
                                                continue;
                                            }
                                            if ($item == 'mail' && get_param('default_type', NULL) !== NULL) {
                                                continue;
                                            }
                                        }
                                        $list->attach(form_input_list_entry($item, $item == $default, protect_from_escaping($label)));
                                    } else {
                                        $list->attach(form_input_list_entry($item, $item == $default));
                                    }
                                }
                                $field = form_input_list($parameter_name, '', $param, $list, NULL, false, false);
                            } elseif ($param == 'width' || $param == 'height') {
                                $field = form_input_integer($parameter_name, protect_from_escaping($descriptiont), $param, $default == '' ? NULL : intval($default), false);
                            } else {
                                if ($supports_comcode) {
                                    $field = form_input_line_comcode($parameter_name, protect_from_escaping($descriptiont), $param, $default, false);
                                } else {
                                    $field = form_input_line($parameter_name, protect_from_escaping($descriptiont), $param, $default, false);
                                }
                            }
                            if ($is_advanced) {
                                $fields_advanced->attach($field);
                            } else {
                                $fields->attach($field);
                            }
                        }
                    }
                    if ($tag == 'attachment') {
                        if (get_option('eager_wysiwyg') == '0') {
                            $field = form_input_tick(do_lang_tempcode('COMCODE_TAG_attachment_safe'), do_lang_tempcode('COMCODE_TAG_attachment_safe_DESCRIPTION'), '_safe', $actual_tag == 'attachment_safe' || $actual_tag == 'attachment2');
                            $fields_advanced->attach($field);
                        }
                    }
                }
            }
        } else {
            $_params = $custom_tag_list[$tag];
            $params = explode(',', $_params['tag_parameters']);
            foreach ($params as $param) {
                $description = new ocp_tempcode();
                $fields->attach(form_input_line(preg_replace('#=.*$#', '', ucwords(str_replace('_', ' ', $param))), protect_from_escaping($description), preg_replace('#=.*$#', '', $param), preg_replace('#^.*=#U', '', $param), false));
            }
            $tag_description = new ocp_tempcode();
            $tag_description->attach(is_integer($_params['tag_description']) ? get_translated_text($_params['tag_description']) : $_params['tag_description']);
            $tag_description->attach(paragraph(is_integer($_params['tag_example']) ? get_translated_text($_params['tag_example']) : $_params['tag_example']));
        }
        if ($tag == 'attachment') {
            if (get_option('eager_wysiwyg') == '0') {
                $javascript .= "document.getElementById('type').onchange=function() { document.getElementById('_safe').checked=(this.options[this.selectedIndex].value=='inline'); };";
            }
            if ($default_embed != '' || !addon_installed('filedump')) {
                $hidden->attach(form_input_hidden('tag_contents', $default_embed));
                $tag_description = new ocp_tempcode();
                if (substr($default_embed, 0, 4) == 'new_') {
                    $preview = NULL;
                }
            } else {
                $filedump_url = build_url(array('page' => 'filedump'), get_module_zone('filedump'));
                $fields->attach(form_input_tree_list(do_lang_tempcode('FILE'), do_lang_tempcode('COMCODE_TAG_attachment_EMBED_FILE', escape_html($filedump_url->evaluate())), 'tag_contents', '', 'choose_filedump_file', array('attachment_ready' => true), true, '', false));
            }
        } elseif ($tag == 'sections' || $tag == 'big_tabs' || $tag == 'tabs' || $tag == 'list') {
            $fields->attach(form_input_text_multi(do_lang_tempcode('TAG_CONTENTS'), protect_from_escaping(do_lang('COMCODE_TAG_' . $tag . '_EMBED')), 'tag_contents', explode(',', $default_embed), 2));
        } elseif (array_key_exists($tag, $TEXTUAL_TAGS) || $tag == 'menu') {
            if ($tag == 'menu' && $default_embed == '') {
                $default_embed = '-contracted section
 +expanded section
  page = URL
  page = URL
+expanded section
 page = URL
 page = URL';
            }
            $descriptiont = do_lang('COMCODE_TAG_' . $tag . '_EMBED');
            $descriptiont = trim(str_replace(do_lang('BLOCK_IND_SUPPORTS_COMCODE'), '', $descriptiont));
            $fields->attach(form_input_text_comcode(do_lang_tempcode('TAG_CONTENTS'), protect_from_escaping(do_lang('COMCODE_TAG_' . $tag . '_EMBED')), 'tag_contents', $default_embed, $embed_required, NULL, true));
        } else {
            if (!$done_tag_contents) {
                $descriptiont = do_lang('COMCODE_TAG_' . $tag . '_EMBED', NULL, NULL, NULL, NULL, false);
                if (is_null($descriptiont)) {
                    $descriptiont = '';
                }
                $supports_comcode = strpos($descriptiont, do_lang('BLOCK_IND_SUPPORTS_COMCODE')) !== false;
                $descriptiont = trim(str_replace(do_lang('BLOCK_IND_SUPPORTS_COMCODE'), '', $descriptiont));
                if ($supports_comcode) {
                    $fields->attach(form_input_line_comcode(do_lang_tempcode('TAG_CONTENTS'), protect_from_escaping($descriptiont), 'tag_contents', $default_embed, $embed_required));
                } else {
                    $fields->attach(form_input_line(do_lang_tempcode('TAG_CONTENTS'), protect_from_escaping($descriptiont), 'tag_contents', $default_embed, $embed_required));
                }
            }
        }
        if (!$fields_advanced->is_empty()) {
            $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('ADVANCED'))));
            $fields->attach($fields_advanced);
        }
        $keep = symbol_tempcode('KEEP');
        $post_url = find_script('comcode_helper') . '?type=step3&field_name=' . get_param('field_name') . $keep->evaluate();
        if (get_param('utheme', '') != '') {
            $post_url .= '&utheme=' . get_param('utheme');
        }
        if (get_param('save_to_id', '') != '') {
            $post_url .= '&save_to_id=' . urlencode(get_param('save_to_id'));
            $submit_name = do_lang_tempcode('SAVE');
            // Allow remove option
            $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => false, 'TITLE' => do_lang_tempcode('ACTIONS'), 'HELP' => '')));
            $fields->attach(form_input_tick(do_lang_tempcode('REMOVE'), '', '_delete', false));
        } else {
            $submit_name = do_lang_tempcode('USE');
        }
        $text = $tag_description->is_empty() ? new ocp_tempcode() : do_lang_tempcode('COMCODE_HELPER_2', escape_html($tag), $tag_description);
        $hidden->attach(form_input_hidden('tag', $tag));
        $content = do_template('FORM_SCREEN', array('_GUID' => '270058349d048a8be6570bba97c81fa2', 'TITLE' => $title, 'JAVASCRIPT' => $javascript, 'TARGET' => '_self', 'SKIP_VALIDATION' => true, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name, 'HIDDEN' => $hidden, 'PREVIEW' => $preview, 'THEME' => $GLOBALS['FORUM_DRIVER']->get_theme()));
    } elseif ($type == 'step3') {
        require_javascript('javascript_posting');
        require_javascript('javascript_editing');
        $field_name = get_param('field_name');
        $tag = post_param('tag');
        $title = get_page_title('_COMCODE_HELPER', true, array($tag));
        if (get_option('eager_wysiwyg') == '0') {
            if ($tag == 'attachment' && post_param_integer('_safe', 0) == 1) {
                $tag = 'attachment_safe';
            }
        }
        list($comcode, $bparameters) = _get_preview_environment_comcode($tag);
        if ($tag == 'sections' || $tag == 'big_tabs' || $tag == 'tabs' || $tag == 'list') {
            $comcode_xml = $bparameters;
        } else {
            $comcode_xml = '<' . $tag . $bparameters . '>' . post_param('tag_contents', '') . '</' . $tag . '>';
        }
        $comcode_semihtml = comcode_to_tempcode($comcode, NULL, false, 60, NULL, NULL, true, false, false);
        $content = do_template('BLOCK_HELPER_DONE', array('TITLE' => $title, 'FIELD_NAME' => $field_name, 'BLOCK' => $tag, 'COMCODE_XML' => $comcode_xml, 'COMCODE' => $comcode, 'COMCODE_SEMIHTML' => $comcode_semihtml));
    }
    $content->handle_symbol_preprocessing();
    $echo = do_template('POPUP_HTML_WRAP', array('TITLE' => do_lang_tempcode('COMCODE_HELPER'), 'EXTRA_HEAD' => $GLOBALS['EXTRA_HEAD'], 'EXTRA_FOOT' => $GLOBALS['EXTRA_FOOT'], 'CONTENT' => $content));
    exit($echo->evaluate());
    $echo->handle_symbol_preprocessing();
    $echo->evaluate_echo();
}
Beispiel #17
0
 /**
  * Get tempcode for a video adding/editing form.
  *
  * @param  SHORT_TEXT		The title
  * @param  ID_TEXT			The gallery
  * @param  LONG_TEXT			The video description
  * @param  URLPATH			The URL to the video file (blank: not yet added)
  * @param  URLPATH			The URL to the thumbnail
  * @param  BINARY				Video validation status
  * @param  ?BINARY			Whether rating is allowed (NULL: decide statistically, based on existing choices)
  * @param  ?SHORT_INTEGER	Whether comments are allowed (0=no, 1=yes, 2=review style) (NULL: decide statistically, based on existing choices)
  * @param  ?BINARY			Whether trackbacks are allowed (NULL: decide statistically, based on existing choices)
  * @param  LONG_TEXT			Notes for the video
  * @param  ?integer			The length of the video (NULL: not yet added, so not yet known)
  * @param  ?integer			The width of the video (NULL: not yet added, so not yet known)
  * @param  ?integer			The height of the video (NULL: not yet added, so not yet known)
  * @return array				A pair: the tempcode for the visible fields, and the tempcode for the hidden fields
  */
 function get_form_fields($title = '', $cat = '', $comments = '', $url = '', $thumb_url = '', $validated = 1, $allow_rating = NULL, $allow_comments = NULL, $allow_trackbacks = NULL, $notes = '', $video_length = NULL, $video_width = NULL, $video_height = NULL)
 {
     list($allow_rating, $allow_comments, $allow_trackbacks) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, $allow_trackbacks);
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'cat';
     $NON_CANONICAL_PARAMS[] = 'validated';
     $no_thumb_needed = get_option('ffmpeg_path') != '' || class_exists('ffmpeg_movie');
     if (!$no_thumb_needed) {
         $this->javascript = 'standardAlternateFields(\'file\',\'url\'); standardAlternateFields(\'file2\',\'thumb_url\',null,true);';
     } else {
         $this->javascript = 'standardAlternateFields(\'file\',\'url\');';
     }
     if ($cat == '') {
         $cat = get_param('cat', '');
     }
     $fields = new ocp_tempcode();
     $hidden = new ocp_tempcode();
     require_code('form_templates');
     handle_max_file_size($hidden);
     if (strpos($cat, '?') !== false) {
         $cat = str_replace('?', strval(get_member()), $cat);
     }
     $fields->attach(form_input_line(do_lang_tempcode('TITLE', do_lang_tempcode('TITLE')), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, false));
     $fields->attach(form_input_tree_list(do_lang_tempcode('GALLERY'), do_lang_tempcode('DESCRIPTION_GALLERY'), 'cat', NULL, 'choose_gallery', array('filter' => 'only_conventional_galleries', 'must_accept_videos' => true, 'addable_filter' => true), true, $cat));
     $supported = get_allowed_video_file_types();
     $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'file', false, NULL, NULL, true, $supported));
     $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'url', $url, false));
     if ($validated == 0) {
         $validated = get_param_integer('validated', 0);
         if ($validated == 1) {
             attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING'));
         }
     }
     $thumb_width = intval(get_option('thumb_width'));
     $validated_field = new ocp_tempcode();
     if (has_some_cat_specific_permission(get_member(), 'bypass_validation_' . $this->permissions_require . 'range_content', NULL, $this->permissions_cat_require)) {
         if (addon_installed('unvalidated')) {
             $validated_field = form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated == 1);
         }
     }
     $description_field = form_input_text_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION_ACCESSIBILITY'), 'comments', $comments, false);
     if ($no_thumb_needed) {
         $fields->attach($description_field);
         $fields->attach($validated_field);
         $temp = do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ADVANCED'), 'SECTION_HIDDEN' => true));
         $fields->attach($temp);
     }
     $fields->attach(form_input_upload(do_lang_tempcode('THUMBNAIL'), do_lang_tempcode('_DESCRIPTION_THUMBNAIL', integer_format($thumb_width)), 'file2', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images'))));
     $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'thumb_url', $thumb_url, false));
     if (!$no_thumb_needed) {
         $fields->attach($description_field);
     }
     $fields->attach(form_input_integer(do_lang_tempcode('VIDEO_LENGTH'), do_lang_tempcode('DESCRIPTION_VIDEO_LENGTH'), 'video_length', $video_length, false));
     $fields->attach(form_input_integer(do_lang_tempcode('WIDTH'), do_lang_tempcode('DESCRIPTION_VIDEO_WIDTH'), 'video_width', $video_width, false));
     $fields->attach(form_input_integer(do_lang_tempcode('HEIGHT'), do_lang_tempcode('DESCRIPTION_VIDEO_HEIGHT'), 'video_height', $video_height, false));
     if (!$no_thumb_needed) {
         $fields->attach($validated_field);
     }
     require_code('feedback2');
     $fields->attach(feedback_fields($allow_rating == 1, $allow_comments == 1, $allow_trackbacks == 1, false, $notes, $allow_comments == 2));
     return array($fields, $hidden);
 }
Beispiel #18
0
$groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true, true);
$done_something = false;
foreach (array_keys($groups) as $group_id) {
    $points_one_off = post_param_integer('points_one_off_' . strval($group_id), NULL);
    $points_per_month = post_param_integer('points_per_month_' . strval($group_id), NULL);
    if ($points_one_off !== NULL) {
        $GLOBALS['SITE_DB']->query_delete('group_points', array('p_group_id' => $group_id), '', 1);
        $GLOBALS['SITE_DB']->query_insert('group_points', array('p_group_id' => $group_id, 'p_points_one_off' => $points_one_off, 'p_points_per_month' => $points_per_month));
        $done_something = true;
    }
}
if ($done_something) {
    attach_message('New point bonuses saved.', 'inform');
}
$group_points = get_group_points();
$fields = new ocp_tempcode();
foreach ($groups as $group_id => $group_name) {
    if ($group_id == db_get_first_id()) {
        continue;
    }
    if (isset($group_points[$group_id])) {
        $points = $group_points[$group_id];
    } else {
        $points = array('p_points_one_off' => 0, 'p_points_per_month' => 0);
    }
    $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => $group_name)));
    $fields->attach(form_input_integer('One-off bonus', '', 'points_one_off_' . strval($group_id), $points['p_points_one_off'], true));
    $fields->attach(form_input_integer('Points per month', '', 'points_per_month_' . strval($group_id), $points['p_points_per_month'], true));
}
$form = do_template('FORM_SCREEN', array('TITLE' => $title, 'HIDDEN' => '', 'TEXT' => paragraph('Enter how many points being in each usergroup is worth. For the one-off bonuses, ocPortal will look at all the usergroups each member is in, and count these numbers within the point totals. The monthly points are assigned to members as system gifts, on the 1st of each month (the CRON scheduler must be enabled).'), 'FIELDS' => $fields, 'SUBMIT_NAME' => 'Set points', 'URL' => get_self_url()));
$form->evaluate_echo();
Beispiel #19
0
 /**
  * Get tempcode for adding/editing form.
  *
  * @param  SHORT_TEXT	The title
  * @param  LONG_TEXT		The description
  * @param  SHORT_TEXT	The cost
  * @param  integer		The length
  * @param  SHORT_TEXT	The units for the length
  * @set    y m d w
  * @param  ?GROUP			The usergroup that purchasing gains membership to (NULL: super members)
  * @param  BINARY			Whether this is applied to primary usergroup membership
  * @param  BINARY			Whether this is currently enabled
  * @param  ?LONG_TEXT	The text of the e-mail to send out when a subscription is start (NULL: default)
  * @param  ?LONG_TEXT	The text of the e-mail to send out when a subscription is ended (NULL: default)
  * @param  ?LONG_TEXT	The text of the e-mail to send out when a subscription cannot be renewed because the subproduct is gone (NULL: default)
  * @param  ?AUTO_LINK	ID of existing subscription (NULL: new)
  * @return array			Tuple: The input fields, The hidden fields, The delete fields
  */
 function get_form_fields($title = '', $description = '', $cost = '9.99', $length = 12, $length_units = 'm', $group_id = NULL, $uses_primary = 0, $enabled = 1, $mail_start = NULL, $mail_end = NULL, $mail_uhoh = NULL, $id = NULL)
 {
     if ($title == '' && get_forum_type() == 'ocf') {
         $add_usergroup_url = build_url(array('page' => 'admin_ocf_groups', 'type' => 'ad'), get_module_zone('admin_ocf_groups'));
         attach_message(do_lang_tempcode('ADD_USER_GROUP_FIRST', escape_html($add_usergroup_url->evaluate())), 'inform');
     }
     if (is_null($group_id)) {
         $group_id = get_param_integer('group_id', db_get_first_id() + 3);
     }
     if (is_null($mail_start)) {
         $mail_start = do_lang('_PAID_SUBSCRIPTION_STARTED', get_option('site_name'));
     }
     if (is_null($mail_end)) {
         $_purchase_url = build_url(array('page' => 'purchase'), get_module_zone('purchase'), NULL, false, false, true);
         $purchase_url = $_purchase_url->evaluate();
         $mail_end = do_lang('_PAID_SUBSCRIPTION_ENDED', get_option('site_name'), $purchase_url);
     }
     if (is_null($mail_uhoh)) {
         $mail_uhoh = do_lang('_PAID_SUBSCRIPTION_UHOH', get_option('site_name'));
     }
     $fields = new ocp_tempcode();
     $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_USERGROUP_SUBSCRIPTION_TITLE'), 'title', $title, true));
     $fields->attach(form_input_text_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_USERGROUP_SUBSCRIPTION_DESCRIPTION'), 'description', $description, true));
     $fields->attach(form_input_float(do_lang_tempcode('COST'), do_lang_tempcode('DESCRIPTION_USERGROUP_SUBSCRIPTION_COST'), 'cost', floatval($cost), true));
     $list = new ocp_tempcode();
     foreach (array('d', 'w', 'm', 'y') as $unit) {
         $list->attach(form_input_list_entry($unit, $unit == $length_units, do_lang_tempcode('LENGTH_UNIT_' . $unit)));
     }
     $fields->attach(form_input_list(do_lang_tempcode('LENGTH_UNITS'), do_lang_tempcode('DESCRIPTION_LENGTH_UNITS'), 'length_units', $list));
     $list = new ocp_tempcode();
     $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list();
     foreach ($groups as $id => $group) {
         $list->attach(form_input_list_entry(strval($id), $id == $group_id, $group));
     }
     $fields->attach(form_input_integer(do_lang_tempcode('SUBSCRIPTION_LENGTH'), do_lang_tempcode('DESCRIPTION_USERGROUP_SUBSCRIPTION_LENGTH'), 'length', $length, true));
     $fields->attach(form_input_list(do_lang_tempcode('GROUP'), do_lang_tempcode('DESCRIPTION_USERGROUP_SUBSCRIPTION_GROUP'), 'group_id', $list));
     $fields->attach(form_input_tick(do_lang_tempcode('USES_PRIMARY'), do_lang_tempcode('DESCRIPTION_USES_PRIMARY'), 'uses_primary', $uses_primary == 1));
     $fields->attach(form_input_tick(do_lang_tempcode('ENABLED'), do_lang_tempcode('DESCRIPTION_USERGROUP_SUBSCRIPTION_ENABLED'), 'enabled', $enabled == 1));
     $fields->attach(form_input_text_comcode(do_lang_tempcode('MAIL_START'), do_lang_tempcode('DESCRIPTION_USERGROUP_SUBSCRIPTION_MAIL_START'), 'mail_start', $mail_start, true, NULL, true));
     $fields->attach(form_input_text_comcode(do_lang_tempcode('MAIL_END'), do_lang_tempcode('DESCRIPTION_USERGROUP_SUBSCRIPTION_MAIL_END'), 'mail_end', $mail_end, true, NULL, true));
     $fields->attach(form_input_text_comcode(do_lang_tempcode('MAIL_UHOH'), do_lang_tempcode('DESCRIPTION_USERGROUP_SUBSCRIPTION_MAIL_UHOH'), 'mail_uhoh', $mail_uhoh, false, NULL, true));
     $delete_fields = NULL;
     if ($GLOBALS['SITE_DB']->query_value('subscriptions', 'COUNT(*)', array('s_type_code' => 'USERGROUP' . strval($id))) > 0) {
         $delete_fields = new ocp_tempcode();
         $delete_fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE_USERGROUP_SUB_DANGER'), 'delete', false));
     }
     return array($fields, new ocp_tempcode(), $delete_fields, NULL, !is_null($delete_fields));
 }
 /**
  * Get tempcode for adding/editing form.
  *
  * @param  SHORT_TEXT	A name for the Welcome E-mail
  * @param  SHORT_TEXT	The subject of the Welcome E-mail
  * @param  LONG_TEXT		The message body of the Welcome E-mail
  * @param  integer		The number of hours before sending the e-mail
  * @param  ?AUTO_LINK	What newsletter to send out to instead of members (NULL: none)
  * @return tempcode		The input fields
  */
 function get_form_fields($name = '', $subject = '', $text = '', $send_time = 0, $newsletter = 0)
 {
     $fields = new ocp_tempcode();
     $fields->attach(form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME_REFERENCE'), 'name', $name, true));
     $fields->attach(form_input_line(do_lang_tempcode('SUBJECT'), do_lang_tempcode('DESCRIPTION_WELCOME_EMAIL_SUBJECT'), 'subject', $subject, true));
     $fields->attach(form_input_huge_comcode(do_lang_tempcode('TEXT'), do_lang_tempcode('DESCRIPTION_WELCOME_EMAIL_TEXT'), 'text', $text, true));
     $fields->attach(form_input_integer(do_lang_tempcode('SEND_TIME'), do_lang_tempcode('DESCRIPTION_SEND_TIME'), 'send_time', $send_time, true));
     if (addon_installed('newsletter')) {
         require_lang('newsletter');
         if (get_value('welcome_nw_choice') === '1') {
             $newsletters = new ocp_tempcode();
             $rows = $GLOBALS['SITE_DB']->query_select('newsletters', array('id', 'title'));
             if (get_forum_type() == 'ocf') {
                 $newsletters->attach(form_input_list_entry('', is_null($newsletter), do_lang_tempcode('NEWSLETTER_OCF')));
             }
             foreach ($rows as $_newsletter) {
                 $newsletters->attach(form_input_list_entry(strval($_newsletter['id']), $_newsletter['id'] === $newsletter, get_translated_text($_newsletter['title'])));
             }
             if (!$newsletters->is_empty()) {
                 $fields->attach(form_input_list(do_lang_tempcode('NEWSLETTER'), '', 'newsletter', $newsletters, NULL, false, false));
             }
         } else {
             if (get_forum_type() == 'ocf') {
                 require_lang('newsletter');
                 $fields->attach(form_input_tick(do_lang_tempcode('NEWSLETTER'), do_lang_tempcode('DESCRIPTION_NEWSLETTER_INSTEAD'), 'newsletter', $newsletter == 1));
             }
         }
     }
     return $fields;
 }
Beispiel #21
0
 /**
  * The UI to delete a topic.
  *
  * @return tempcode		The UI
  */
 function delete_topic()
 {
     $topic_id = get_param_integer('id');
     $post_url = build_url(array('page' => '_SELF', 'type' => '_delete_topic', 'id' => $topic_id), '_SELF');
     $topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('*'), array('id' => $topic_id), '', 1);
     if (!array_key_exists(0, $topic_info)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $this->handle_topic_breadcrumbs($topic_info[0]['t_forum_id'], $topic_id, $topic_info[0]['t_cache_first_title'], do_lang_tempcode('DELETE_TOPIC'));
     $this->check_has_mod_access($topic_id);
     // Certain aspects relating to the posting system
     $fields = new ocp_tempcode();
     $hidden = new ocp_tempcode();
     $hidden->attach(build_keep_post_fields());
     $hidden->attach(build_keep_form_fields());
     $fields->attach(form_input_tree_list(do_lang_tempcode('DESTINATION_TOPIC'), do_lang_tempcode('DESCRIPTION_DESTINATION_TOPIC'), 'select_topic_id', NULL, 'choose_forum_topic', array(), false));
     $fields->attach(form_input_integer(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('DESTINATION_TOPIC_ID')), do_lang_tempcode('DESCRIPTION_DESTINATION_TOPIC'), 'manual_topic_id', NULL, false));
     $fields->attach(form_input_line(do_lang_tempcode('REASON'), do_lang_tempcode('DESCRIPTION_REASON'), 'reason', '', false));
     $topic_title = $GLOBALS['FORUM_DB']->query_value('f_topics', 't_cache_first_title', array('id' => $topic_id));
     $title = get_page_title('_DELETE_TOPIC', true, array(escape_html($topic_title)));
     $submit_name = do_lang_tempcode('DELETE');
     $text = paragraph(do_lang_tempcode('DELETE_TOPIC_TEXT'));
     return do_template('FORM_SCREEN', array('_GUID' => '00b84f337de3683bfcdb60ea3086afa0', 'SKIP_VALIDATION' => true, 'STAFF_HELP_URL' => brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_mod', 'HIDDEN' => $hidden, 'TITLE' => $title, 'FIELDS' => $fields, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url));
 }
Beispiel #22
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	Results
  */
 function run()
 {
     require_lang('stats');
     require_lang('dates');
     $delete_older_than = post_param_integer('delete_older_than', NULL);
     if (is_null($delete_older_than)) {
         @ob_end_clean();
         $delete_older_than = intval(get_option('stats_store_time'));
         require_code('form_templates');
         $fields = form_input_integer(do_lang_tempcode('DPLU_DAYS'), do_lang_tempcode('DESCRIPTION_DELETE_DAYS'), 'delete_older_than', $delete_older_than, true);
         $post_url = get_self_url(false, false, NULL, false, true);
         $submit_name = do_lang_tempcode('DELETE');
         $hidden = build_keep_post_fields();
         $title = get_page_title('PAGE_STATS_DELETE');
         $tpl = do_template('FORM_SCREEN', array('SKIP_VALIDATION' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('DELETE_DATA_AVAILABLE'), 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name));
         $echo = globalise($tpl, NULL, '', true);
         $echo->evaluate_echo();
         exit;
     }
     if (function_exists('set_time_limit')) {
         @set_time_limit(0);
     }
     // Write install.php file
     $template = get_custom_file_base() . '/data_custom/modules/admin_cleanup/page_stats.php.pre';
     if (!file_exists($template)) {
         $template = get_file_base() . '/data/modules/admin_cleanup/page_stats.php.pre';
     }
     $_install_php_file = file_get_contents($template);
     $install_php_file = ocp_tempnam('ps');
     $tmpfile = fopen($install_php_file, 'wb');
     fwrite($tmpfile, substr($_install_php_file, 0, strpos($_install_php_file, '{!!DB!!}')));
     // Get old data
     do {
         $or_list = '';
         $data = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'stats WHERE date_and_time<' . strval(time() - 60 * 60 * 24 * $delete_older_than), 500);
         foreach ($data as $d) {
             $list = '';
             foreach ($d as $name => $value) {
                 if (is_null($value)) {
                     continue;
                 }
                 if ($list != '') {
                     $list .= ',';
                 }
                 $list .= "'" . (is_string($name) ? $name : strval($name)) . "'=>";
                 if (!is_integer($value)) {
                     $list .= "'" . str_replace('\'', '\\\'', $value) . "'";
                 } else {
                     $list .= strval($value);
                 }
             }
             fwrite($tmpfile, "\t\$GLOBALS['SITE_DB']->query_insert('stats',array({$list}));\n");
             if ($or_list != '') {
                 $or_list .= ' OR ';
             }
             $or_list .= 'id=' . strval($d['id']);
         }
         if ($or_list != '') {
             $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'stats WHERE ' . $or_list);
         }
     } while ($data != array());
     fwrite($tmpfile, substr($_install_php_file, strpos($_install_php_file, '{!!DB!!}') + 8));
     // Make tar
     require_code('tar');
     $file = 'stats-leading-to-' . date('Y-m-d', utctime_to_usertime(time() - 60 * 60 * 24 * $delete_older_than));
     $stats_backup_url = get_custom_base_url() . '/exports/backups/' . $file . '.tar';
     $myfile = tar_open(get_custom_file_base() . '/exports/backups/' . $file . '.tar', 'wb');
     tar_add_file($myfile, $file . '.php', $install_php_file, 0664, time(), true);
     tar_close($myfile);
     fclose($tmpfile);
     @unlink($install_php_file);
     $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'stats WHERE date_and_time<' . strval(time() - 60 * 60 * 24 * $delete_older_than));
     return do_template('CLEANUP_PAGE_STATS', array('_GUID' => '1df213eee7c5c6b97168e5a34e92d3b0', 'STATS_BACKUP_URL' => $stats_backup_url));
 }
Beispiel #23
0
 /**
  * Get tempcode for a post template adding/editing form.
  *
  * @param  ID_TEXT		The ID of the banner type
  * @param  BINARY			Whether this is a textual banner
  * @param  integer		The image width (ignored for textual banners)
  * @param  integer		The image height (ignored for textual banners)
  * @param  integer		The maximum file size for the banners (this is a string length for textual banners)
  * @param  BINARY			Whether the banner will be automatically shown via Comcode hot-text (this can only happen if banners of the title are given title-text)
  * @return array			A pair: the tempcode for the visible fields, and the tempcode for the hidden fields
  */
 function get_form_fields($id = '', $is_textual = 0, $image_width = 160, $image_height = 600, $max_file_size = 70, $comcode_inline = 0)
 {
     $fields = new ocp_tempcode();
     $hidden = new ocp_tempcode();
     $fields->attach(form_input_line(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_BANNER_TYPE_2'), 'new_id', $id, false));
     if ($id != '') {
         $hidden->attach(form_input_hidden('is_textual', strval($is_textual)));
     } else {
         $fields->attach(form_input_tick(do_lang_tempcode('BANNER_IS_TEXTUAL'), do_lang_tempcode('DESCRIPTION_BANNER_IS_TEXTUAL'), 'is_textual', $is_textual == 1));
     }
     $fields->attach(form_input_integer(do_lang_tempcode('WIDTH'), do_lang_tempcode('DESCRIPTION_BANNER_WIDTH'), 'image_width', $image_width, true));
     $fields->attach(form_input_integer(do_lang_tempcode('HEIGHT'), do_lang_tempcode('DESCRIPTION_BANNER_HEIGHT'), 'image_height', $image_height, true));
     $fields->attach(form_input_integer(do_lang_tempcode('_FILE_SIZE'), do_lang_tempcode('DESCRIPTION_BANNER_FILE_SIZE'), 'max_file_size', $max_file_size, true));
     $fields->attach(form_input_tick(do_lang_tempcode('COMCODE_INLINE'), do_lang_tempcode('DESCRIPTION_COMCODE_INLINE'), 'comcode_inline', $comcode_inline == 1));
     return array($fields, $hidden);
 }
Beispiel #24
0
 /**
  * The UI for choosing delurk criteria.
  *
  * @return tempcode		The UI
  */
 function delurk()
 {
     $title = get_page_title('DELETE_LURKERS');
     breadcrumb_set_parents(array(array('_SEARCH:admin_ocf_join:menu', do_lang_tempcode('MEMBERS'))));
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/deletelurkers';
     require_code('form_templates');
     require_lang('ocf_lurkers');
     $hidden = new ocp_tempcode();
     $_max_posts = get_value('delurk__max_posts');
     $_max_points = get_value('delurk__max_points');
     $_max_logged_actions = get_value('delurk__max_logged_actions');
     $_min_days_since_login = get_value('delurk__min_days_since_login');
     $_min_days_since_join = get_value('delurk__min_days_since_join');
     $_usergroups = get_value('delurk__usergroups');
     if (is_null($_max_posts)) {
         $max_posts = 2;
     } else {
         $max_posts = intval($_max_posts);
     }
     if (is_null($_max_points)) {
         $max_points = 150;
     } else {
         $max_points = intval($_max_points);
     }
     if (is_null($_max_logged_actions)) {
         $max_logged_actions = 2;
     } else {
         $max_logged_actions = intval($_max_logged_actions);
     }
     if (is_null($_min_days_since_login)) {
         $min_days_since_login = 60;
     } else {
         $min_days_since_login = intval($_min_days_since_login);
     }
     if (is_null($_min_days_since_join)) {
         $min_days_since_join = 90;
     } else {
         $min_days_since_join = intval($_min_days_since_join);
     }
     if (is_null($_usergroups)) {
         $usergroups = array();
     } else {
         $temp = explode(',', $_usergroups);
         $usergroups = array();
         foreach ($temp as $t) {
             $usergroups[] = intval($t);
         }
     }
     $fields = new ocp_tempcode();
     $fields->attach(form_input_integer(do_lang_tempcode('DELURK_MAX_POSTS'), do_lang_tempcode('DELURK_MAX_POSTS_DESCRIPTION'), 'max_posts', $max_posts, true));
     if (addon_installed('points')) {
         $fields->attach(form_input_integer(do_lang_tempcode('DELURK_MAX_POINTS'), do_lang_tempcode('DELURK_MAX_POINTS_DESCRIPTION'), 'max_points', $max_points, true));
     } else {
         $hidden->attach(form_input_hidden('max_points', '0'));
     }
     $fields->attach(form_input_integer(do_lang_tempcode('DELURK_MAX_LOGGED_ACTIONS'), do_lang_tempcode('DELURK_MAX_LOGGED_ACTIONS_DESCRIPTION'), 'max_logged_actions', $max_logged_actions, true));
     $fields->attach(form_input_integer(do_lang_tempcode('DELURK_MIN_DAYS_SINCE_LOGIN'), do_lang_tempcode('DELURK_MIN_DAYS_SINCE_LOGIN_DESCRIPTION'), 'min_days_since_login', $min_days_since_login, true));
     $fields->attach(form_input_integer(do_lang_tempcode('DELURK_MIN_DAYS_SINCE_JOIN'), do_lang_tempcode('DELURK_MIN_DAYS_SINCE_JOIN_DESCRIPTION'), 'min_days_since_join', $min_days_since_join, true));
     $groups = new ocp_tempcode();
     $group_count = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)');
     $rows = $GLOBALS['FORUM_DB']->query_select('f_groups', array('id', 'g_name'), $group_count > 200 ? array('g_is_private_club' => 0) : NULL);
     foreach ($rows as $row) {
         if ($row['id'] != db_get_first_id()) {
             $groups->attach(form_input_list_entry(strval($row['id']), in_array($row['id'], $usergroups), get_translated_text($row['g_name'], $GLOBALS['FORUM_DB'])));
         }
     }
     $fields->attach(form_input_multi_list(do_lang_tempcode('EXCEPT_IN_USERGROUPS'), do_lang_tempcode('DELURK_USERGROUPS_DESCRIPTION'), 'usergroups', $groups));
     $submit_name = do_lang_tempcode('PROCEED');
     $post_url = build_url(array('page' => '_SELF', 'type' => '_delurk'), '_SELF');
     $text = do_lang_tempcode('CHOOSE_DELURK_CRITERIA');
     return do_template('FORM_SCREEN', array('_GUID' => 'f911fc5be2865bdd065abf7c636530d4', 'TITLE' => $title, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name));
 }
Beispiel #25
0
 /**
  * Get tempcode for adding/editing form.
  *
  * @param  ?AUTO_LINK	The ID of the award (NULL: not added yet)
  * @param  SHORT_TEXT	The title
  * @param  LONG_TEXT		The description
  * @param  integer		How many points are given to the awardee
  * @param  ID_TEXT		The content type the award type is for
  * @param  BINARY			Whether to not show the awardee when displaying this award
  * @param  integer		The approximate time in hours between awards (e.g. 168 for a week)
  * @return tempcode		The input fields
  */
 function get_form_fields($id = NULL, $title = '', $description = '', $points = 0, $content_type = 'download', $hide_awardee = 0, $update_time_hours = 168)
 {
     $fields = new ocp_tempcode();
     $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true));
     $fields->attach(form_input_text_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', $description, true));
     if (addon_installed('points')) {
         $fields->attach(form_input_integer(do_lang_tempcode('POINTS'), do_lang_tempcode('DESCRIPTION_AWARD_POINTS'), 'points', $points, true));
     }
     $list = new ocp_tempcode();
     $_hooks = array();
     $hooks = find_all_hooks('systems', 'awards');
     foreach (array_keys($hooks) as $hook) {
         require_code('hooks/systems/awards/' . $hook);
         $hook_object = object_factory('Hook_awards_' . $hook, true);
         if (is_null($hook_object)) {
             continue;
         }
         $hook_info = $hook_object->info();
         if (!is_null($hook_info)) {
             $_hooks[$hook] = $hook_info['title']->evaluate();
         }
     }
     asort($_hooks);
     foreach ($_hooks as $hook => $hook_title) {
         $list->attach(form_input_list_entry($hook, $hook == $content_type, protect_from_escaping($hook_title)));
     }
     if ($list->is_empty()) {
         inform_exit(do_lang_tempcode('NO_CATEGORIES'));
     }
     $fields->attach(form_input_list(do_lang_tempcode('CONTENT_TYPE'), do_lang_tempcode('DESCRIPTION_CONTENT_TYPE'), 'content_type', $list));
     $fields->attach(form_input_tick(do_lang_tempcode('HIDE_AWARDEE'), do_lang_tempcode('DESCRIPTION_HIDE_AWARDEE'), 'hide_awardee', $hide_awardee == 1));
     $fields->attach(form_input_integer(do_lang_tempcode('AWARD_UPDATE_TIME_HOURS'), do_lang_tempcode('DESCRIPTION_AWARD_UPDATE_TIME_HOURS'), 'update_time_hours', $update_time_hours, true));
     // Permissions
     $fields->attach($this->get_permission_fields(is_null($id) ? NULL : strval($id), do_lang_tempcode('AWARD_PERMISSION_HELP'), false, do_lang_tempcode('GIVE_AWARD')));
     return $fields;
 }
Beispiel #26
0
/**
 * Get the tempcode for the form to add a banner, with the information passed along to it via the parameters already added in.
 *
 * @param  boolean			Whether to simplify the banner interface (for the point-store buy process)
 * @param  ID_TEXT			The name of the banner
 * @param  URLPATH			The URL to the banner image
 * @param  URLPATH			The URL to the site the banner leads to
 * @param  SHORT_TEXT		The caption of the banner
 * @param  LONG_TEXT			Any notes associated with the banner
 * @param  integer			The banners "importance modulus"
 * @range  1 max
 * @param  ?integer			The number of hits the banner may have (NULL: not applicable for this banner type)
 * @range  0 max
 * @param  SHORT_INTEGER	The type of banner (0=permanent, 1=campaign, 2=default)
 * @set    0 1 2
 * @param  ?TIME				The banner expiry date (NULL: never expires)
 * @param  ?ID_TEXT			The username of the banners submitter (NULL: current member)
 * @param  BINARY				Whether the banner has been validated
 * @param  ID_TEXT			The banner type (can be anything, where blank means 'normal')
 * @param  SHORT_TEXT		The title text for the banner (only used for text banners, and functions as the 'trigger text' if the banner type is shown inline)
 * @return tempcode			The input field tempcode
 */
function get_banner_form_fields($simplified = false, $name = '', $image_url = '', $site_url = '', $caption = '', $notes = '', $importancemodulus = 3, $campaignremaining = 50, $the_type = 1, $expiry_date = NULL, $submitter = NULL, $validated = 1, $b_type = '', $title_text = '')
{
    require_code('images');
    $fields = new ocp_tempcode();
    require_code('form_templates');
    $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_BANNER_NAME'), 'name', $name, true));
    $fields->attach(form_input_line(do_lang_tempcode('DESTINATION_URL'), do_lang_tempcode('DESCRIPTION_BANNER_URL'), 'site_url', $site_url, false));
    // Blank implies iframe
    if (!$simplified) {
        $types = nice_get_banner_types($b_type);
        if ($types->is_empty()) {
            warn_exit(do_lang_tempcode('NO_CATEGORIES'));
        }
        $fields->attach(form_input_list(do_lang_tempcode('_BANNER_TYPE'), do_lang_tempcode('_DESCRIPTION_BANNER_TYPE'), 'b_type', $types, NULL, false, false));
    } else {
        $fields->attach(form_input_hidden('b_type', $b_type));
    }
    if (has_specific_permission(get_member(), 'full_banner_setup')) {
        $fields->attach(form_input_username(do_lang_tempcode('OWNER'), do_lang_tempcode('DESCRIPTION_SUBMITTER'), 'submitter', is_null($submitter) ? $GLOBALS['FORUM_DRIVER']->get_username(get_member()) : $submitter, false));
    }
    if (get_value('disable_staff_notes') !== '1') {
        $fields->attach(form_input_text(do_lang_tempcode('NOTES'), do_lang_tempcode('DESCRIPTION_NOTES'), 'notes', $notes, false));
    }
    if (has_specific_permission(get_member(), 'bypass_validation_midrange_content', 'cms_banners')) {
        if ($validated == 0) {
            $validated = get_param_integer('validated', 0);
            if ($validated == 1) {
                attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING'));
            }
        }
        if (addon_installed('unvalidated')) {
            $fields->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated == 1));
        }
    }
    $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('SOURCE_MEDIA'))));
    $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD_BANNER'), 'file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images') . ',swf')));
    $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('IMAGE_URL')), do_lang_tempcode('DESCRIPTION_URL_BANNER'), 'image_url', $image_url, false));
    $fields->attach(form_input_line_comcode(do_lang_tempcode('BANNER_TITLE_TEXT'), do_lang_tempcode('DESCRIPTION_BANNER_TITLE_TEXT'), 'title_text', $title_text, false));
    $fields->attach(form_input_line_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_BANNER_DESCRIPTION'), 'caption', $caption, false));
    $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('DEPLOYMENT_DETERMINATION'))));
    if (has_specific_permission(get_member(), 'full_banner_setup')) {
        $radios = new ocp_tempcode();
        $radios->attach(form_input_radio_entry('the_type', strval(BANNER_PERMANENT), $the_type == BANNER_PERMANENT, do_lang_tempcode('BANNER_PERMANENT')));
        $radios->attach(form_input_radio_entry('the_type', strval(BANNER_CAMPAIGN), $the_type == BANNER_CAMPAIGN, do_lang_tempcode('BANNER_CAMPAIGN')));
        $radios->attach(form_input_radio_entry('the_type', strval(BANNER_DEFAULT), $the_type == BANNER_DEFAULT, do_lang_tempcode('BANNER_DEFAULT')));
        $fields->attach(form_input_radio(do_lang_tempcode('DEPLOYMENT_AGREEMENT'), do_lang_tempcode('DESCRIPTION_BANNER_TYPE'), 'the_type', $radios));
        $fields->attach(form_input_integer(do_lang_tempcode('HITS_ALLOCATED'), do_lang_tempcode('DESCRIPTION_HITS_ALLOCATED'), 'campaignremaining', $campaignremaining, false));
        $total_importance = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT SUM(importance_modulus) FROM ' . get_table_prefix() . 'banners WHERE ' . db_string_not_equal_to('name', $name));
        if (is_null($total_importance)) {
            $total_importance = 0;
        }
        $fields->attach(form_input_integer(do_lang_tempcode('IMPORTANCE_MODULUS'), do_lang_tempcode('DESCRIPTION_IMPORTANCE_MODULUS', strval($total_importance), strval($importancemodulus)), 'importancemodulus', $importancemodulus, true));
    }
    $fields->attach(form_input_date(do_lang_tempcode('EXPIRY_DATE'), do_lang_tempcode('DESCRIPTION_EXPIRY_DATE'), 'expiry_date', true, is_null($expiry_date), true, $expiry_date, 2));
    return $fields;
}
Beispiel #27
0
 /**
  * The UI to edit a configuration page.
  *
  * @return tempcode		The UI
  */
 function config_category()
 {
     require_javascript('javascript_validation');
     /*$GLOBALS['HELPER_PANEL_PIC']='pagepics/config';
     		$GLOBALS['HELPER_PANEL_TUTORIAL']='tut_adv_configuration';*/
     $page = get_param('id');
     $title = get_page_title(do_lang_tempcode('CONFIG_CATEGORY_' . $page), false);
     $post_url = build_url(array('page' => '_SELF', 'type' => 'set', 'id' => $page, 'redirect' => get_param('redirect', NULL)), '_SELF');
     $category_description = do_lang_tempcode('CONFIG_CATEGORY_DESCRIPTION__' . $page);
     $rows = $GLOBALS['SITE_DB']->query_select('config', array('*'), array('the_page' => $page));
     // Addin special ones
     if ($page == 'SITE') {
         $rows[] = array('the_name' => 'timezone', 'human_name' => 'TIME_ZONE', 'config_value' => '', 'the_type' => 'special', 'eval' => '', 'the_page' => 'SITE', 'section' => 'GENERAL', 'explanation' => '', 'shared_hosting_restricted' => 0);
     }
     /*global $M_SORT_KEY;	This is a lame sort - it doesn't preserve internal order
     		$M_SORT_KEY='section';
     		usort($rows,'multi_sort');*/
     // Better sort
     $all_known_groups = array();
     foreach ($rows as $myrow) {
         $_group = do_lang($myrow['section'], NULL, NULL, NULL, NULL, false);
         if (is_null($_group)) {
             $_group = $myrow['section'];
         }
         $_group = strtolower(trim(preg_replace('#(&.*;)|[^\\w\\d\\s]#U', '', $_group)));
         if (array_key_exists($_group, $all_known_groups) && $all_known_groups[$_group] != $myrow['section']) {
             $_group = 'std_' . $myrow['section'];
         }
         // If cat names translate to same things or are in non-latin characters like Cyrillic
         $all_known_groups[$_group] = $myrow['section'];
     }
     $old_rows = $rows;
     $rows = array();
     ksort($all_known_groups);
     foreach ($all_known_groups as $group_codename) {
         foreach ($old_rows as $myrow) {
             if ($myrow['section'] == $group_codename) {
                 $rows[] = $myrow;
             }
         }
     }
     // Move advanced group options to the end
     $rows2 = array();
     foreach ($rows as $i => $row) {
         if ($row['section'] == 'ADVANCED') {
             $rows2[] = $row;
             unset($rows[$i]);
         }
     }
     $rows = array_merge($rows, $rows2);
     // UI hooks
     $ui_hooks = find_all_hooks('modules', 'admin_config');
     $upload_max_filesize = ini_get('upload_max_filesize') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('upload_max_filesize')));
     $post_max_size = ini_get('post_max_size') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('post_max_size')));
     $groups = new ocp_tempcode();
     require_code('form_templates');
     $current_group = '';
     $out = '';
     $_groups = array();
     foreach ($rows as $myrow) {
         if ($myrow['eval'] != '' && $myrow['the_name'] != 'detect_lang_forum') {
             if (defined('HIPHOP_PHP')) {
                 require_code('hooks/systems/config_default/' . $myrow['the_name']);
                 $hook = object_factory('Hook_config_default_' . $myrow['the_name']);
                 if (is_null($hook->get_default())) {
                     continue;
                 }
             } else {
                 $GLOBALS['REQUIRE_LANG_LOOP'] = 10;
                 // LEGACY Workaround for corrupt webhost installers
                 if (is_null(@eval($myrow['eval'] . ';'))) {
                     continue;
                 }
                 // @'d in case default is corrupt, don't want it to give errors forever
                 $GLOBALS['REQUIRE_LANG_LOOP'] = 0;
                 // LEGACY
             }
         }
         $_group = do_lang($myrow['section'], NULL, NULL, NULL, NULL, false);
         $name = do_lang($myrow['human_name'], NULL, NULL, NULL, NULL, false);
         $_group_tempcode = is_null($_group) ? make_string_tempcode($myrow['section']) : do_lang_tempcode($myrow['section']);
         $name_tempcode = is_null($name) ? make_string_tempcode($myrow['human_name']) : do_lang_tempcode($myrow['human_name']);
         if (get_forum_type() == 'ocf' && $myrow['explanation'] == 'CONFIG_OPTION_forum_in_portal') {
             $exp_string = $myrow['explanation'] . '__ocf';
         } else {
             $exp_string = $myrow['explanation'];
         }
         $_explanation = do_lang($exp_string, NULL, NULL, NULL, NULL, false);
         if (is_null($_explanation)) {
             $_explanation = do_lang('CONFIG_GROUP_DEFAULT_DESCRIP_' . $myrow['section'], NULL, NULL, NULL, NULL, false);
             if (is_null($_explanation)) {
                 $explanation = new ocp_tempcode();
             } else {
                 $explanation = do_lang_tempcode('CONFIG_GROUP_DEFAULT_DESCRIP_' . $myrow['section']);
             }
         } else {
             $explanation = do_lang_tempcode($exp_string);
         }
         if ($myrow['shared_hosting_restricted'] == 1 && !is_null($GLOBALS['CURRENT_SHARE_USER'])) {
             continue;
         }
         if ($myrow['section'] != $current_group && $current_group != '') {
             $_current_group = do_lang_tempcode($current_group);
             $_group_description = do_lang('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize), NULL, NULL, false);
             if (is_null($_group_description)) {
                 $group_description = new ocp_tempcode();
             } else {
                 $group_description = do_lang_tempcode('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize));
             }
             $group = do_template('CONFIG_GROUP', array('_GUID' => 'af4c31daa1bc39714ab83b11bd6d3e51', 'GROUP_DESCRIPTION' => $group_description, 'GROUP_NAME' => $current_group, 'GROUP' => $out, 'CURRENT_GROUP' => $_current_group));
             $groups->attach($group->evaluate());
             $out = '';
         }
         $_groups[$myrow['section']] = $_group_tempcode;
         switch ($myrow['the_type']) {
             case 'special':
                 switch ($myrow['the_name']) {
                     case 'timezone':
                         $list = '';
                         $timezone = get_site_timezone();
                         foreach (get_timezone_list() as $_timezone => $timezone_nice) {
                             $list .= static_evaluate_tempcode(form_input_list_entry($_timezone, $_timezone == $timezone, $timezone_nice));
                         }
                         $out .= static_evaluate_tempcode(form_input_list(do_lang_tempcode('TIME_ZONE'), do_lang_tempcode('DESCRIPTION_TIMEZONE_SITE'), 'timezone', make_string_tempcode($list)));
                         break;
                     default:
                         require_code('hooks/modules/admin_config/' . filter_naughty_harsh($myrow['the_name']));
                         $hook_ob = object_factory('Hook_admin_config_' . filter_naughty_harsh($myrow['the_name']));
                         $out .= static_evaluate_tempcode($hook_ob->run($myrow));
                         break;
                 }
                 break;
             case 'integer':
                 $out .= static_evaluate_tempcode(form_input_integer($name_tempcode, $explanation, $myrow['the_name'], intval(get_option($myrow['the_name'])), false));
                 break;
             case 'line':
                 if (strpos($myrow['the_name'], 'colour') !== false && substr(get_option($myrow['the_name']), 0, 1) == '#') {
                     $out .= static_evaluate_tempcode(form_input_colour($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false, NULL, true));
                 } elseif ($myrow['the_name'] == 'currency') {
                     $list = '';
                     require_code('currency');
                     $currencies = array_keys(get_currency_map());
                     foreach ($currencies as $currency) {
                         $list .= static_evaluate_tempcode(form_input_list_entry($currency, $currency == get_option($myrow['the_name'])));
                     }
                     $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], make_string_tempcode($list)));
                 } elseif ($myrow['the_name'] == 'payment_gateway') {
                     $list = '';
                     $all_via = find_all_hooks('systems', 'ecommerce_via');
                     foreach (array_keys($all_via) as $via) {
                         $list .= static_evaluate_tempcode(form_input_list_entry($via, $via == get_option($myrow['the_name'])));
                     }
                     $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], make_string_tempcode($list)));
                 } else {
                     /*if (strpos($myrow['the_name'],'password')!==false)  password fields can't take defaults
                     			$out.=static_evaluate_tempcode(form_input_password($name_tempcode,$explanation,$myrow['the_name'],get_option($myrow['the_name']),false));
                     		else
                     			*/
                     $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false));
                 }
                 break;
             case 'list':
                 $list = '';
                 $_value = get_option($myrow['the_name']);
                 $values = explode('|', $myrow['c_data']);
                 foreach ($values as $value) {
                     $_option_text = do_lang('CONFIG_OPTION_' . $myrow['the_name'] . '_VALUE_' . $value, NULL, NULL, NULL, NULL, false);
                     if (!is_null($_option_text)) {
                         $option_text = do_lang_tempcode('CONFIG_OPTION_' . $myrow['the_name'] . '_VALUE_' . $value);
                     } else {
                         $option_text = make_string_tempcode($value);
                     }
                     $list .= static_evaluate_tempcode(form_input_list_entry($value, $_value == $value, $option_text));
                 }
                 $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], make_string_tempcode($list), NULL, false, false));
                 break;
             case 'transline':
                 $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false));
                 break;
             case 'text':
                 $out .= static_evaluate_tempcode(form_input_text($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false, NULL, true));
                 break;
             case 'transtext':
                 $out .= static_evaluate_tempcode(form_input_text($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false, NULL, true));
                 break;
             case 'float':
                 $out .= static_evaluate_tempcode(form_input_float($name_tempcode, $explanation, $myrow['the_name'], floatval(get_option($myrow['the_name'])), false));
                 break;
             case 'tick':
                 $out .= static_evaluate_tempcode(form_input_tick($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']) == '1'));
                 break;
             case 'date':
                 $out .= static_evaluate_tempcode(form_input_date($name_tempcode, $explanation, $myrow['the_name'], false, false, false, intval(get_option($myrow['the_name'])), 40, intval(date('Y')) - 20, NULL, false));
                 break;
             case 'forum':
             case '?forum':
                 if (get_forum_type() == 'ocf' && addon_installed('ocf_forum')) {
                     $current_setting = get_option($myrow['the_name']);
                     if (!is_numeric($current_setting)) {
                         $_current_setting = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'id', array('f_name' => $current_setting));
                         if (is_null($_current_setting)) {
                             if ($myrow['the_type'] == '?forum') {
                                 $current_setting = NULL;
                             } else {
                                 $current_setting = strval(db_get_first_id());
                                 attach_message(do_lang_tempcode('FORUM_CURRENTLY_UNSET', $name_tempcode), 'notice');
                             }
                         } else {
                             $current_setting = strval($_current_setting);
                         }
                     }
                     $out .= static_evaluate_tempcode(form_input_tree_list($name_tempcode, $explanation, $myrow['the_name'], NULL, 'choose_forum', array(), false, $current_setting));
                 } else {
                     $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false));
                 }
                 break;
             case 'category':
                 if (get_forum_type() == 'ocf') {
                     $tmp_value = $GLOBALS['FORUM_DB']->query_value_null_ok('f_categories', 'id', array('c_title' => get_option($myrow['the_name'])));
                     require_code('ocf_forums2');
                     $_list = ocf_nice_get_categories(NULL, $tmp_value);
                     $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], $_list));
                 } else {
                     $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false));
                 }
                 break;
             case 'usergroup':
                 if (get_forum_type() == 'ocf') {
                     $tmp_value = $GLOBALS['FORUM_DB']->query_value_null_ok('f_groups g LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON t.id=g.g_name', 'g.id', array('text_original' => get_option($myrow['the_name'])));
                     require_code('ocf_groups');
                     $_list = ocf_nice_get_usergroups($tmp_value);
                     $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], $_list));
                 } else {
                     $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false));
                 }
                 break;
         }
         $current_group = $myrow['section'];
     }
     if ($out != '') {
         $_group_description = do_lang('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize), NULL, NULL, false);
         if (is_null($_group_description)) {
             $group_description = new ocp_tempcode();
         } else {
             $group_description = do_lang_tempcode('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize));
         }
         $group = do_template('CONFIG_GROUP', array('_GUID' => '84c0db86002a33a383a7c2e195dd3913', 'GROUP_DESCRIPTION' => $group_description, 'GROUP_NAME' => $current_group, 'GROUP' => $out, 'CURRENT_GROUP' => $_group_tempcode));
         $groups->attach($group->evaluate());
     }
     list($warning_details, $ping_url) = handle_conflict_resolution();
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CONFIGURATION'))));
     breadcrumb_set_self(do_lang_tempcode('CONFIG_CATEGORY_' . $page));
     return do_template('CONFIG_CATEGORY_SCREEN', array('_GUID' => 'd01b28b71c38bbb52b6aaf877c7f7b0e', 'CATEGORY_DESCRIPTION' => $category_description, '_GROUPS' => $_groups, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TITLE' => $title, 'URL' => $post_url, 'GROUPS' => $groups, 'SUBMIT_NAME' => do_lang_tempcode('SAVE')));
 }
Beispiel #28
0
 /**
  * The UI and actualisation for: accepting code if it is correct (and not ''), and setting password to something random, emailing it
  *
  * @return tempcode		The UI
  */
 function step3()
 {
     $title = get_page_title('RESET_PASSWORD');
     $code = get_param('code', '');
     if ($code == '') {
         require_code('form_templates');
         $fields = new ocp_tempcode();
         $fields->attach(form_input_username(do_lang_tempcode('USERNAME'), '', 'username', NULL, true));
         $fields->attach(form_input_integer(do_lang_tempcode('CODE'), '', 'code', NULL, true));
         $submit_name = do_lang_tempcode('PROCEED');
         return do_template('FORM_SCREEN', array('_GUID' => '6e4db5c6f3c75faa999251339533d22a', 'TITLE' => $title, 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'URL' => get_self_url(false, false, NULL, false, true), 'FIELDS' => $fields, 'TEXT' => do_lang_tempcode('MISSING_CONFIRM_CODE'), 'SUBMIT_NAME' => $submit_name));
     }
     $username = get_param('username', NULL);
     if (!is_null($username)) {
         $username = trim($username);
         $member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($username);
         if (is_null($member)) {
             warn_exit(do_lang_tempcode('PASSWORD_RESET_ERROR_2'));
         }
     } else {
         $member = get_param_integer('member');
     }
     $correct_code = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member, 'm_password_change_code');
     if ($correct_code == '') {
         $_reset_url = build_url(array('page' => '_SELF', 'username' => $GLOBALS['FORUM_DRIVER']->get_username($member)), '_SELF');
         $reset_url = $_reset_url->evaluate();
         warn_exit(do_lang_tempcode('PASSWORD_ALREADY_RESET', escape_html($reset_url), get_site_name()));
     }
     if ($code != $correct_code) {
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('adminlogs', 'date_and_time', array('the_type' => 'RESET_PASSWORD', 'param_a' => strval($member), 'param_b' => $code));
         if (!is_null($test)) {
             warn_exit(do_lang_tempcode('INCORRECT_PASSWORD_RESET_CODE'));
         }
         log_hack_attack_and_exit('HACK_ATTACK_PASSWORD_CHANGE');
     }
     $email = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member, 'm_email_address');
     $new_password = get_rand_password();
     // Send password in mail
     $_login_url = build_url(array('page' => 'login', 'username' => $GLOBALS['FORUM_DRIVER']->get_username($member)), get_module_zone('login'), NULL, false, false, true);
     $login_url = $_login_url->evaluate();
     $message = do_lang('MAIL_NEW_PASSWORD', comcode_escape($new_password), $login_url, get_site_name());
     require_code('mail');
     mail_wrap(do_lang('RESET_PASSWORD'), $message, array($email), $GLOBALS['FORUM_DRIVER']->get_username($member), '', '', 3, NULL, false, NULL, false, false, false, 'MAIL', true);
     if (get_value('no_password_hashing') === '1') {
         $password_compatibility_scheme = 'plain';
         $new = $new_password;
     } else {
         $password_compatibility_scheme = '';
         $salt = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member, 'm_pass_salt');
         $new = md5($salt . md5($new_password));
     }
     unset($_GET['code']);
     $GLOBALS['FORUM_DB']->query_update('f_members', array('m_validated_email_confirm_code' => '', 'm_password_compat_scheme' => $password_compatibility_scheme, 'm_password_change_code' => '', 'm_pass_hash_salted' => $new), array('id' => $member), '', 1);
     return inform_screen($title, do_lang_tempcode('NEW_PASSWORD_MAILED', escape_html($email)));
 }
Beispiel #29
0
 /**
  * Standard stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function buyquota()
 {
     if (get_option('is_on_pop3_buy') == '0') {
         return new ocp_tempcode();
     }
     $title = get_page_title('TITLE_QUOTA');
     $member_id = get_member();
     $pointsleft = available_points($member_id);
     $price = intval(get_option('quota'));
     $topamount = intval(get_option('max_quota'));
     if ($price == 0) {
         $topamount = $pointsleft;
     } else {
         $topamount = intval(round($pointsleft / $price));
     }
     $details = $GLOBALS['SITE_DB']->query_select('sales', array('details', 'details2'), array('memberid' => $member_id, 'purchasetype' => 'pop3'), '', 1);
     // If we don't own a POP3 account, stop right here.
     if (!array_key_exists(0, $details)) {
         return warn_screen($title, do_lang_tempcode('NO_POP3'));
     }
     $prefix = $details[0]['details'];
     $suffix = $details[0]['details2'];
     // Screen
     $submit_name = do_lang_tempcode('TITLE_QUOTA');
     $post_url = build_url(array('page' => '_SELF', 'type' => '_buyquota', 'id' => 'pop3'), '_SELF');
     $text = do_template('POINTSTORE_QUOTA', array('_GUID' => '1282fae968b4919bcd0ba1e3ca169fe8', 'POINTS_LEFT' => integer_format($pointsleft), 'PRICE' => integer_format($price), 'TOP_AMOUNT' => integer_format($topamount), 'EMAIL' => $prefix . $suffix));
     require_code('form_templates');
     $fields = form_input_integer(do_lang_tempcode('QUOTA'), do_lang_tempcode('QUOTA_DESCRIPTION'), 'quota', 100, true);
     return do_template('FORM_SCREEN', array('_GUID' => '1c82c713beaa03d1e3045e50295c722c', 'HIDDEN' => '', 'URL' => $post_url, 'TITLE' => $title, 'FIELDS' => $fields, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name));
 }
Beispiel #30
0
 /**
  * Get tempcode for a warning adding/editing form.
  *
  * @param  boolean		Whether it is a new warning/punishment record
  * @param  LONG_TEXT		The explanation for the warning/punishment record
  * @param  BINARY			Whether to make this a formal warning
  * @param  ?MEMBER		The member the warning is for (NULL: get from environment)
  * @return array			A pair: the tempcode for the visible fields, and the tempcode for the hidden fields
  */
 function get_form_fields($new = true, $explanation = '', $is_warning = 0, $member_id = NULL)
 {
     if (is_null($member_id)) {
         $member_id = get_param_integer('id', get_member());
     }
     $hidden = new ocp_tempcode();
     $fields = new ocp_tempcode();
     require_code('form_templates');
     // Information about their history, and the rules - to educate the warner/punisher
     if ($new) {
         $post_id = get_param_integer('post_id', NULL);
         $hidden->attach(form_input_hidden('member_id', strval($member_id)));
         $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id);
         $num_warnings = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_cache_warnings');
         $_rules_url = build_url(array('page' => 'rules'), '_SEARCH');
         $rules_url = $_rules_url->evaluate();
         $_history_url = build_url(array('page' => '_SELF', 'type' => 'history', 'id' => $member_id), '_SELF');
         $history_url = $_history_url->evaluate();
         $profile_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id, false, true);
         if (is_object($profile_url)) {
             $profile_url = $profile_url->evaluate();
         }
         $this->add_text = do_lang_tempcode('HAS_ALREADY_X_WARNINGS', escape_html($username), integer_format($num_warnings), array(escape_html(get_site_name()), escape_html($rules_url), escape_html($history_url), escape_html($profile_url)));
     }
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('MODULE_TRANS_NAME_warnings'))));
     $fields->attach(form_input_tick(do_lang_tempcode('WHETHER_MAKE_WARNING'), do_lang_tempcode('DESCRIPTION_WHETHER_MAKE_WARNING'), 'is_warning', $is_warning == 1));
     // Punitive actions
     if ($new) {
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('PUNITIVE_ACTIONS'))));
         if (!is_null($post_id)) {
             $topic_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_posts', 'p_topic_id', array('id' => $post_id));
             if (!is_null($topic_id)) {
                 $forum_id = $GLOBALS['FORUM_DB']->query_value('f_topics', 't_forum_id', array('id' => $topic_id));
                 $hidden->attach(form_input_hidden('topic_id', strval($topic_id)));
                 $hidden->attach(form_input_hidden('forum_id', strval($forum_id)));
                 $silence_topic_time = NULL;
                 //time()+60*60*24*7;
                 $silence_forum_time = NULL;
                 //time()+60*60*24*7;
                 $active_until = $GLOBALS['SITE_DB']->query_value_null_ok('msp', 'active_until', array('member_id' => $member_id, 'specific_permission' => 'submit_lowrange_content', 'the_page' => '', 'module_the_name' => 'topics', 'category_name' => strval($topic_id)));
                 if (!is_null($active_until)) {
                     $silence_topic_time = $active_until;
                 }
                 $active_until = $GLOBALS['SITE_DB']->query_value_null_ok('msp', 'active_until', array('member_id' => $member_id, 'specific_permission' => 'submit_lowrange_content', 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($forum_id)));
                 if (!is_null($active_until)) {
                     $silence_forum_time = $active_until;
                 }
                 $fields->attach(form_input_date(do_lang_tempcode('SILENCE_FROM_TOPIC'), do_lang_tempcode('DESCRIPTION_SILENCE_FROM_TOPIC'), 'silence_from_topic', true, true, true, $silence_topic_time, 2));
                 $fields->attach(form_input_date(do_lang_tempcode('SILENCE_FROM_FORUM'), do_lang_tempcode('DESCRIPTION_SILENCE_FROM_FORUM'), 'silence_from_forum', true, true, true, $silence_forum_time, 2));
             }
         }
         if (has_specific_permission(get_member(), 'probate_members')) {
             $fields->attach(form_input_integer(do_lang_tempcode('EXTEND_PROBATION'), do_lang_tempcode('DESCRIPTION_EXTEND_PROBATION'), 'probation', 0, true));
         }
         if (addon_installed('securitylogging')) {
             if (has_actual_page_access(get_member(), 'admin_ipban')) {
                 $fields->attach(form_input_tick(do_lang_tempcode('WHETHER_BANNED_IP'), do_lang_tempcode('DESCRIPTION_WHETHER_BANNED_IP'), 'banned_ip', false));
             }
         }
         if (addon_installed('points')) {
             if (has_actual_page_access(get_member(), 'admin_points')) {
                 require_code('points');
                 $num_points_currently = available_points($member_id);
                 $fields->attach(form_input_integer(do_lang_tempcode('CHARGED_POINTS'), do_lang_tempcode('DESCRIPTION_CHARGED_POINTS', escape_html(integer_format($num_points_currently))), 'charged_points', 0, true));
             }
         }
         if (has_specific_permission(get_member(), 'member_maintenance')) {
             $fields->attach(form_input_tick(do_lang_tempcode('BANNED_MEMBER'), do_lang_tempcode('DESCRIPTION_BANNED_MEMBER'), 'banned_member', false));
             $rows = $GLOBALS['FORUM_DB']->query_select('f_groups', array('id', 'g_name'), array('g_is_private_club' => 0));
             $groups = new ocp_tempcode();
             $groups->attach(form_input_list_entry('-1', false, do_lang_tempcode('NA_EM')));
             foreach ($rows as $group) {
                 if ($group['id'] != db_get_first_id()) {
                     $groups->attach(form_input_list_entry(strval($group['id']), false, get_translated_text($group['g_name'], $GLOBALS['FORUM_DB'])));
                 }
             }
             $fields->attach(form_input_list(do_lang_tempcode('CHANGE_USERGROUP_TO'), do_lang_tempcode('DESCRIPTION_CHANGE_USERGROUP_TO'), 'changed_usergroup_from', $groups));
         }
     }
     // Explanatory text
     $keep = symbol_tempcode('KEEP');
     $load_url = find_script('warnings') . '?type=load' . $keep->evaluate();
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('EXPLANATORY_TEXT'), 'HELP' => do_lang_tempcode('LOAD_SAVED_WARNING', escape_html($load_url)))));
     $fields->attach(form_input_line_comcode(do_lang_tempcode('EXPLANATION'), do_lang_tempcode('DESCRIPTION_EXPLANATION'), 'explanation', $explanation, true));
     if ($new) {
         $message = '';
         if (!is_null($post_id)) {
             $_postdetails_text = $GLOBALS['FORUM_DB']->query_value_null_ok('f_posts', 'p_post', array('id' => $post_id));
             if (!is_null($_postdetails_text)) {
                 $message = '[quote="' . $username . '"]' . chr(10) . get_translated_text($_postdetails_text) . chr(10) . '[/quote]';
             }
         }
         $fields->attach(form_input_text_comcode(do_lang_tempcode('MESSAGE'), do_lang_tempcode('DESCRIPTION_PP_MESSAGE'), 'message', $message, false));
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
         $fields->attach(form_input_line(do_lang_tempcode('SAVE_WARNING_DETAILS'), do_lang_tempcode('DESCRIPTION_SAVE_WARNING_DETAILS'), 'save', '', false));
     }
     return array($fields, $hidden);
 }