/**
 * Get a netlink block / direct to a netlink site.
 *
 * @param  URLPATH		The URL we grab our netlink from. If this is not blank, instead of getting a netlink block, we direct to a netlink site.
 * @return tempcode		The netlink block
 */
function do_netlink($redir_url = '')
{
    header('Content-type: text/plain; charset=' . get_charset());
    // If we are redirecting
    if ($redir_url != '') {
        if (strpos($redir_url, chr(10)) !== false || strpos($redir_url, chr(13)) !== false) {
            log_hack_attack_and_exit('HEADER_SPLIT_HACK');
        }
        header('Location: ' . $redir_url);
        exit;
    }
    // Ok we're displaying a netlink, which will be dumped right into the body of the reading site
    //  - this isn't actually a weburl that is actually displayed, its loaded by ocPortal and embedded-inline
    // For all the names in our network
    require_code('textfiles');
    $lines = explode(chr(10), read_text_file('netlink', NULL, true));
    if (count($lines) == 0) {
        return new ocp_tempcode();
    }
    $content = new ocp_tempcode();
    foreach ($lines as $line) {
        $parts = explode('=', $line, 2);
        if (count($parts) != 2) {
            continue;
        }
        $name = rtrim($parts[0]);
        $url = trim($parts[1]);
        // Are we looking at the source site in the network?
        $selected = strtolower($url) == strtolower(get_param('source', ''));
        $content->attach(form_input_list_entry(base64_encode($url), $selected, $name));
    }
    return do_template('NETLINK', array('_GUID' => '180321222dc5dc99a231597c803f0726', 'CONTENT' => $content));
}
Example #2
0
/**
 * Get a nice list for selection from the usergroups. Suitable for admin use only (does not check hidden status).
 *
 * @param  ?AUTO_LINK	Usergroup selected by default (NULL: no specific default).
 * @return tempcode		The list.
 */
function ocf_nice_get_usergroups($it = NULL)
{
    $group_count = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)');
    $_m = $GLOBALS['FORUM_DB']->query_select('f_groups', array('id', 'g_name'), $group_count > 200 ? array('g_is_private_club' => 0) : NULL, 'ORDER BY g_order');
    $entries = new ocp_tempcode();
    foreach ($_m as $m) {
        $entries->attach(form_input_list_entry(strval($m['id']), $it === $m['id'], get_translated_text($m['g_name'], $GLOBALS['FORUM_DB'])));
    }
    return $entries;
}
Example #3
0
/**
 * Get a nice list for selection from the forum categories.
 *
 * @param  ?AUTO_LINK	Category to avoid putting in the list (NULL: don't avoid any).
 * @param  ?AUTO_LINK	Category selected by default (NULL: no specific default).
 * @return tempcode		The list.
 */
function ocf_nice_get_categories($avoid = NULL, $it = NULL)
{
    $_m = $GLOBALS['FORUM_DB']->query_select('f_categories', array('*'));
    $entries = new ocp_tempcode();
    foreach ($_m as $m) {
        if ($m['id'] !== $avoid) {
            $entries->attach(form_input_list_entry(strval($m['id']), $it === $m['id'], $m['c_title']));
        }
    }
    return $entries;
}
Example #4
0
/**
 * Get a tempcode list of the available mail domains.
 *
 * @param  ID_TEXT		The type of mail domain
 * @set    pop3 forw
 * @param  integer		Description
 * @return tempcode		The tempcode list of available domains
 */
function get_mail_domains($type, $points_left)
{
    $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'prices WHERE name LIKE \'' . db_encode_like($type . '%') . '\'');
    $list = new ocp_tempcode();
    foreach ($rows as $row) {
        $address = substr($row['name'], strlen($type));
        //If we can't afford the mail, turn the text red
        $red = $points_left < $row['price'];
        $list->attach(form_input_list_entry($address, false, '@' . $address . ' ' . do_lang('PRICE_GIVE', integer_format($row['price'])), $red));
    }
    return $list;
}
Example #5
0
 /**
  * Function for administrators to pick an identifier (only used by admins, usually the identifier would be picked via some other means in the wider ocPortal codebase).
  *
  * @param  ID_TEXT		Product type code.
  * @return ?tempcode		Input field in standard Tempcode format for fields (NULL: no identifier).
  */
 function get_identifier_manual_field_inputter($type_code)
 {
     $list = new ocp_tempcode();
     $rows = $GLOBALS['SITE_DB']->query_select('invoices', array('*'), array('i_type_code' => $type_code), 'ORDER BY id DESC');
     foreach ($rows as $row) {
         $username = $GLOBALS['FORUM_DRIVER']->get_username($row['i_member_id']);
         if (is_null($username)) {
             $username = do_lang('UNKNOWN');
         }
         $list->attach(form_input_list_entry(strval($row['id']), false, do_lang('INVOICE_OF', strval($row['id']), $username)));
     }
     return form_input_list(do_lang_tempcode('INVOICE'), '', 'purchase_id', $list);
 }
Example #6
0
 /**
  * Get special Tempcode for inputting this field.
  *
  * @param  array			The row for the field to input
  * @return ?array			List of specially encoded input detail rows (NULL: nothing special)
  */
 function get_search_inputter($row)
 {
     $fields = array();
     $type = '_LIST';
     $special = new ocp_tempcode();
     $special->attach(form_input_list_entry('', get_param('option_' . strval($row['id']), '') == '', '---'));
     $list = explode('|', $row['cf_default']);
     $display = array_key_exists('trans_name', $row) ? $row['trans_name'] : get_translated_text($row['cf_name']);
     // 'trans_name' may have been set in CPF retrieval API, might not correspond to DB lookup if is an internal field
     foreach ($list as $l) {
         $special->attach(form_input_list_entry($l, get_param('option_' . strval($row['id']), '') == $l));
     }
     $fields[] = array('NAME' => strval($row['id']), 'DISPLAY' => $display, 'TYPE' => $type, 'SPECIAL' => $special);
     return $fields;
 }
Example #7
0
 /**
  * Function for administrators to pick an identifier (only used by admins, usually the identifier would be picked via some other means in the wider ocPortal codebase).
  *
  * @param  ID_TEXT		Product type code.
  * @return ?tempcode		Input field in standard Tempcode format for fields (NULL: no identifier).
  */
 function get_identifier_manual_field_inputter($type_code)
 {
     require_code('catalogues');
     require_lang('classifieds');
     $list = new ocp_tempcode();
     $rows = $GLOBALS['SITE_DB']->query_select('catalogue_entries e JOIN ' . get_table_prefix() . 'classifieds_prices c ON c.c_catalogue_name=e.c_name', array('e.*'), NULL, 'GROUP BY e.id ORDER BY ce_add_date DESC');
     foreach ($rows as $row) {
         $data_map = get_catalogue_entry_map($row, NULL, 'CATEGORY', 'DEFAULT', NULL, NULL, array(0));
         $ad_title = $data_map['FIELD_0'];
         $username = $GLOBALS['FORUM_DRIVER']->get_username($row['ce_submitter']);
         if (is_null($username)) {
             $username = do_lang('UNKNOWN');
         }
         $list->attach(form_input_list_entry(strval($row['id']), get_param_integer('id', NULL) === $row['id'], do_lang('CLASSIFIED_OF', strval($row['id']), $username, $ad_title)));
     }
     return form_input_list(do_lang_tempcode('ENTRY'), '', 'purchase_id', $list);
 }
Example #8
0
 /**
  * Interface to import/export.
  *
  * @return tempcode	The interface.
  */
 function ui()
 {
     $title = get_page_title('XML_DATA_MANAGEMENT');
     require_code('form_templates');
     $import_url = build_url(array('page' => '_SELF', 'type' => '_import'), '_SELF');
     $import_fields = new ocp_tempcode();
     $import_fields->attach(form_input_huge(do_lang_tempcode('XML_DATA'), '', 'xml', '', true));
     $import_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'URL' => $import_url, 'HIDDEN' => '', 'TEXT' => do_lang_tempcode('XML_IMPORT_TEXT'), 'FIELDS' => $import_fields, 'SUBMIT_NAME' => do_lang_tempcode('IMPORT')));
     $all_tables = find_all_xml_tables();
     $export_url = build_url(array('page' => '_SELF', 'type' => '_export'), '_SELF');
     $export_fields = new ocp_tempcode();
     $nice_tables = new ocp_tempcode();
     foreach ($all_tables as $table) {
         $nice_tables->attach(form_input_list_entry($table));
     }
     $export_fields->attach(form_input_multi_list(do_lang_tempcode('TABLES'), do_lang_tempcode('DESCRIPTION_TABLES'), 'tables', $nice_tables, NULL, 15));
     $export_fields->attach(form_input_tick(do_lang_tempcode('EXPORT_WITH_COMCODE_XML'), do_lang_tempcode('DESCRIPTION_EXPORT_WITH_COMCODE_XML'), 'comcode_xml', false));
     $export_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'URL' => $export_url, 'HIDDEN' => '', 'TEXT' => do_lang_tempcode('XML_EXPORT_TEXT'), 'FIELDS' => $export_fields, 'SUBMIT_NAME' => do_lang_tempcode('EXPORT')));
     return do_template('XML_STORAGE_SCREEN', array('TITLE' => $title, 'IMPORT_FORM' => $import_form, 'EXPORT_FORM' => $export_form));
 }
 /**
  * Standard modular simple function for ajax-tree hooks. Returns a normal <select> style <option>-list, for fallback purposes
  *
  * @param  ?ID_TEXT		The ID to do under (NULL: root) - not always supported
  * @param  array			Options being passed through
  * @param  ?ID_TEXT		The ID to select by default (NULL: none)
  * @param  string			Prefix titles with this
  * @return tempcode		The nice list
  */
 function simple($id, $options, $it = NULL, $prefix = '')
 {
     $file = $this->get_file($id);
     $list = new ocp_tempcode();
     if (is_null($id)) {
         // Root, needs an NA option
         $list->attach(form_input_list_entry('', false, do_lang_tempcode('NA_EM')));
     }
     $matches = array();
     $num_matches = preg_match_all('#<entry id="(\\d+)"[^<>]* title="([^"]+)"#', $file, $matches);
     for ($i = 0; $i < $num_matches; $i++) {
         $list->attach(form_input_list_entry('http://ocportal.com/site/dload.php?id=' . $matches[1][$i], $matches[1][$i] === $it, $prefix . $matches[2][$i]));
     }
     $num_matches = preg_match_all('#<category id="(\\d+)" title="([^"]+)"#', $file, $matches);
     for ($i = 0; $i < $num_matches; $i++) {
         $list2 = $this->simple($matches[1][$i], $options, $it, $matches[2][$i] . ' > ');
         $list->attach($list2);
     }
     return $list;
 }
Example #10
0
/**
 * Get the form to add a bookmark / set breadcrumbs.
 *
 * @param  mixed			Where the form should go to
 * @return tempcode		The form
 */
function add_bookmark_form($post_url)
{
    $title = get_page_title('ADD_BOOKMARK');
    require_lang('zones');
    require_code('character_sets');
    $url = base64_decode(get_param('url', '', true));
    $url = convert_to_internal_encoding($url, 'UTF-8');
    // Note that this is intentionally passed in to not be a short URL
    $page_link = convert_to_internal_encoding(url_to_pagelink($url, false, false), 'UTF-8');
    $default_title = get_param('title', '', true);
    $default_title = convert_to_internal_encoding($default_title, 'UTF-8');
    $default_title = preg_replace('#\\s.\\s' . str_replace('#', '\\#', preg_quote(get_site_name())) . '$#s', '', $default_title);
    $default_title = preg_replace('#^' . str_replace('#', '\\#', preg_quote(get_site_name())) . '\\s.\\s#s', '', $default_title);
    $default_title_2 = @preg_replace('#\\s.\\s' . str_replace('#', '\\#', preg_quote(get_site_name())) . '$#su', '', $default_title);
    $default_title_2 = @preg_replace('#^' . str_replace('#', '\\#', preg_quote(get_site_name())) . '\\s.\\s#su', '', $default_title_2);
    if ($default_title_2 !== false) {
        $default_title = $default_title_2;
    }
    if (!is_string($default_title)) {
        $default_title = '';
    }
    require_code('form_templates');
    $rows = $GLOBALS['SITE_DB']->query_select('bookmarks', array('DISTINCT b_folder'), array('b_owner' => get_member()), 'ORDER BY b_folder');
    $list = new ocp_tempcode();
    $list->attach(form_input_list_entry('', false, do_lang_tempcode('NA_EM')));
    $list->attach(form_input_list_entry('!', true, do_lang_tempcode('ROOT_EM')));
    foreach ($rows as $row) {
        if ($row['b_folder'] != '') {
            $list->attach(form_input_list_entry($row['b_folder']));
        }
    }
    $fields = new ocp_tempcode();
    $fields->attach(form_input_list(do_lang_tempcode('OLD_BOOKMARK_FOLDER'), do_lang_tempcode('DESCRIPTION_OLD_BOOKMARK_FOLDER'), 'folder', $list, NULL, false, false));
    $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('NEW_BOOKMARK_FOLDER')), do_lang_tempcode('DESCRIPTION_NEW_BOOKMARK_FOLDER'), 'folder_new', '', false));
    $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $default_title == '' ? '' : substr($default_title, 0, 200), true));
    $fields->attach(form_input_line(do_lang_tempcode('PAGE_LINK'), do_lang_tempcode('DESCRIPTION_PAGE_LINK_BOOKMARK'), 'page_link', $page_link, true));
    $submit_name = do_lang_tempcode('ADD_BOOKMARK');
    breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_BOOKMARKS'))));
    $javascript = 'standardAlternateFields(\'folder\',\'folder_new\'); var title=document.getElementById(\'title\'); if (((title.value==\'\') || (title.value==\'0\')) && (window.opener)) title.value=getInnerHTML(window.opener.document.getElementsByTagName(\'title\')[0]); ';
    return do_template('FORM_SCREEN', array('_GUID' => '7e94bb97008de4fa0fffa2b5f91c95eb', 'TITLE' => $title, 'HIDDEN' => '', 'TEXT' => '', 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name, 'JAVASCRIPT' => $javascript));
}
Example #11
0
 /**
  * Standard import function to get extra fields to ask for when starting the import.
  *
  * @return tempcode		Extra fields
  */
 function get_extra_fields()
 {
     // Give user options
     //  - where to copy files from [actually this field is in admin_import.php]
     //  - theme to save into (advise they should use Theme Wizard to create a theme with similar colour first)
     //  - whether to Comcode-convert
     //  - whether to fix invalid XHTML
     //  - the base URL to use to turn absolute URLs into relative URLs
     $fields = new ocp_tempcode();
     $themes = new ocp_tempcode();
     require_code('themes2');
     $_themes = find_all_themes();
     require_code('form_templates');
     foreach ($_themes as $theme => $theme_title) {
         $themes->attach(form_input_list_entry($theme, $theme == $GLOBALS['FORUM_DRIVER']->get_theme(), $theme_title));
     }
     $fields = form_input_list(do_lang_tempcode('THEME'), do_lang_tempcode('THEME_TO_SAVE_INTO'), 'theme', $themes, NULL, true);
     $fields->attach(form_input_tick(do_lang_tempcode('WHETHER_CONVERT_COMCODE'), do_lang_tempcode('DESCRIPTION_WHETHER_CONVERT_COMCODE'), 'convert_to_comcode', false));
     $fields->attach(form_input_tick(do_lang_tempcode('FIX_INVALID_HTML'), do_lang_tempcode('DESCRIPTION_FIX_INVALID_HTML'), 'fix_html', true));
     $fields->attach(form_input_line(do_lang_tempcode('BASE_URL'), do_lang_tempcode('DESCRIPTION_IMPORT_BASE_URL'), 'base_url', get_base_url(), true));
     return $fields;
 }
Example #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)
  * @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)
 {
     $default = $field['cf_default'];
     $list = $default == '' ? array() : explode('|', $default);
     $_list = new ocp_tempcode();
     if ($field['cf_required'] == 0 || $actual_value == '' || is_null($actual_value)) {
         $_list->attach(form_input_list_entry('', true, do_lang_tempcode('NA_EM')));
     }
     foreach ($list as $l) {
         $_list->attach(form_input_list_entry($l, $l == $actual_value));
     }
     return form_input_list($_cf_name, $_cf_description, 'field_' . strval($field['id']), $_list, NULL, false, $field['cf_required'] == 1);
 }
Example #13
0
 /**
  * Get tempcode for a test adding/editing form.
  *
  * @param  string			A short stub to prefix the field name
  * @param  SHORT_TEXT	The text of the test
  * @param  ?MEMBER		The member the test is assigned to (NULL: test section member)
  * @param  BINARY			Whether the test is enabled
  * @param  string			The section this test inherits from (blank: none)
  * @return tempcode		The tempcode for the visible fields
  */
 function get_test_form_fields($stub, $test = '', $assigned_to = NULL, $enabled = 1, $inherit_from = '')
 {
     require_code('form_templates');
     $fields = new ocp_tempcode();
     $fields->attach(form_input_line(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), $stub . '_test', $test, true));
     $list = $this->get_tester_list($assigned_to);
     $fields->attach(form_input_list(do_lang_tempcode('TESTER'), do_lang_tempcode('DESCRIPTION_TESTER_2'), $stub . '_assigned_to', $list));
     $fields->attach(form_input_tick(do_lang_tempcode('ENABLED'), do_lang_tempcode('DESCRIPTION_ENABLED'), $stub . '_enabled', $enabled == 1));
     $list2 = form_input_list_entry('-1', is_null($inherit_from), do_lang_tempcode('NA_EM'));
     $list2->attach($this->get_section_list($inherit_from, true));
     $fields->attach(form_input_list(do_lang_tempcode('INHERIT_FROM'), do_lang_tempcode('DESCRIPTION_INHERIT_FROM'), $stub . '_inherit_section', $list2));
     return $fields;
 }
Example #14
0
 /**
  * Standard modular entry list fetcher.
  *
  * @return tempcode		The selection list
  */
 function nice_get_entries()
 {
     list($_entries, ) = $this->get_entry_rows();
     $entries = new ocp_tempcode();
     foreach ($_entries as $key => $row) {
         $readable = $row['_readable'];
         $entries->attach(form_input_list_entry($key, $key === get_param('id', NULL, true), $readable));
     }
     return $entries;
 }
Example #15
0
 /**
  * The UI to choose a language.
  *
  * @param  tempcode		The title to show when choosing a language
  * @param  boolean		Whether to also choose a language file
  * @param  boolean		Whether the user may add a language
  * @param  mixed			Text message to show (Tempcode or string)
  * @param  boolean		Whether to provide an N/A choice
  * @param  ID_TEXT		The name of the parameter for specifying language
  * @return tempcode		The UI
  */
 function choose_lang($title, $choose_lang_file = false, $add_lang = false, $text = '', $provide_na = true, $param_name = 'lang')
 {
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/language';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_intl';
     require_code('form_templates');
     $langs = new ocp_tempcode();
     if ($provide_na) {
         $langs->attach(form_input_list_entry('', false, do_lang_tempcode('NA')));
     }
     $langs->attach(nice_get_langs(NULL, $add_lang));
     $fields = form_input_list(do_lang_tempcode('LANGUAGE'), do_lang_tempcode('DESCRIPTION_LANGUAGE'), $param_name, $langs, NULL, false, false);
     $javascript = '';
     if ($add_lang) {
         $fields->attach(form_input_codename(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('LANGUAGE')), do_lang_tempcode('DESCRIPTION_NEW_LANG'), 'lang_new', '', false));
         $javascript .= 'standardAlternateFields(\'lang\',\'lang_new\');';
     }
     if ($choose_lang_file) {
         $lang_files = new ocp_tempcode();
         $lang_files->attach(form_input_list_entry('', false, do_lang_tempcode('NA_EM')));
         $lang_files->attach(nice_get_lang_files());
         $fields->attach(form_input_list(do_lang_tempcode('LANGUAGE_FILE'), do_lang_tempcode('DESCRIPTION_LANGUAGE_FILE'), 'lang_file', $lang_files, NULL, true));
         $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang('SEARCH')), '', 'search', '', false));
         $javascript .= 'standardAlternateFields(\'lang_file\',\'search\');';
     }
     $post_url = get_self_url(false, false, NULL, false, true);
     return do_template('FORM_SCREEN', array('_GUID' => 'ee6bdea3661cb4736173cac818a769e5', 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'SUBMIT_NAME' => do_lang_tempcode('CHOOSE'), 'TITLE' => $title, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'JAVASCRIPT' => $javascript));
 }
Example #16
0
 /**
  * Standard aed_module list function.
  *
  * @return tempcode		The selection list
  */
 function nice_get_entries()
 {
     $_m = $GLOBALS['SITE_DB']->query_select('newsletters', array('id', 'title'));
     $entries = new ocp_tempcode();
     foreach ($_m as $m) {
         $entries->attach(form_input_list_entry(strval($m['id']), false, get_translated_text($m['title'], $GLOBALS['SITE_DB'])));
     }
     return $entries;
 }
Example #17
0
 /**
  * Get a preview(s) of a (group of) template(s), as a full standalone piece of HTML in Tempcode format.
  * Uses sources/lorem.php functions to place appropriate stock-text. Should not hard-code things, as the code is intended to be declaritive.
  * Assumptions: You can assume all Lang/CSS/Javascript files in this addon have been pre-required.
  *
  * @return array			Array of previews, each is Tempcode. Normally we have just one preview, but occasionally it is good to test templates are flexible (e.g. if they use IF_EMPTY, we can test with and without blank data).
  */
 function tpl_preview__block_side_personal_stats()
 {
     $content = new ocp_tempcode();
     $links = new ocp_tempcode();
     $content->attach(do_lorem_template('BLOCK_SIDE_PERSONAL_STATS_LINE', array('KEY' => lorem_word(), 'VALUE' => placeholder_number())));
     $links->attach(do_lorem_template('BLOCK_SIDE_PERSONAL_STATS_LINK_2', array('NAME' => lorem_word_2(), 'DESCRIPTION' => lorem_phrase(), 'URL' => placeholder_url())));
     $links->attach(do_lorem_template('BLOCK_SIDE_PERSONAL_STATS_LINK', array('NAME' => lorem_word(), 'URL' => placeholder_url(), 'REL' => 'me')));
     $links->attach(do_lorem_template('BLOCK_SIDE_PERSONAL_STATS_LOGOUT', array('NAME' => do_lang_tempcode('LOGOUT'), 'URL' => placeholder_url())));
     $content->attach(do_lorem_template('BLOCK_SIDE_PERSONAL_STATS_LINE_COMPLEX', array('KEY' => do_lang_tempcode('GROUP'), 'VALUE' => placeholder_link())));
     $staff_actions = new ocp_tempcode();
     $staff_actions->attach(form_input_list_entry(lorem_word(), true, lorem_phrase()));
     return array(lorem_globalise(do_lorem_template('BLOCK_SIDE_PERSONAL_STATS', array('AVATAR_URL' => placeholder_avatar(), 'LINKS' => $links, 'HAS_SU' => true, 'CONTENT' => $content, 'USERNAME' => lorem_word(), 'STAFF_ACTIONS' => $staff_actions)), NULL, '', true));
 }
 /**
  * Show value statistics for a custom profile field (choose).
  *
  * @return tempcode		The UI
  */
 function stats()
 {
     $title = get_page_title('CUSTOM_PROFILE_FIELD_STATS');
     breadcrumb_set_parents(array());
     $fields = new ocp_tempcode();
     $rows = $GLOBALS['FORUM_DB']->query_select('f_custom_fields', array('id', 'cf_name', 'cf_type'));
     require_code('form_templates');
     require_code('fields');
     $list = new ocp_tempcode();
     $_list = array();
     foreach ($rows as $row) {
         $ob = get_fields_hook($row['cf_type']);
         list(, , $storage_type) = $ob->get_field_value_row_bits(NULL);
         if (strpos($storage_type, '_trans') === false) {
             $id = $row['id'];
             $text = get_translated_text($row['cf_name'], $GLOBALS['FORUM_DB']);
             $_list[$id] = $text;
         }
     }
     asort($_list);
     foreach ($_list as $id => $text) {
         $list->attach(form_input_list_entry(strval($id), false, $text));
     }
     if ($list->is_empty()) {
         return inform_screen($title, do_lang_tempcode('NO_ENTRIES'));
     }
     require_lang('dates');
     $fields->attach(form_input_list(do_lang_tempcode('NAME'), '', 'id', $list));
     $fields->attach(form_input_date(do_lang_tempcode('FROM'), do_lang_tempcode('DESCRIPTION_MEMBERS_JOINED_FROM'), 'start', true, false, false, time() - 60 * 60 * 24 * 30, 10, intval(date('Y')) - 10));
     $fields->attach(form_input_date(do_lang_tempcode('TO'), do_lang_tempcode('DESCRIPTION_MEMBERS_JOINED_TO'), 'end', true, false, false, time(), 10, intval(date('Y')) - 10));
     $post_url = build_url(array('page' => '_SELF', 'type' => '_stats'), '_SELF', NULL, false, true);
     $submit_name = do_lang_tempcode('CUSTOM_PROFILE_FIELD_STATS');
     return do_template('FORM_SCREEN', array('_GUID' => '393bac2180c9e135ae9c31565ddf7761', 'GET' => true, 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'HIDDEN' => '', 'FIELDS' => $fields, 'TEXT' => '', 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name));
 }
Example #19
0
 /**
  * Choose survey to view results of.
  *
  * @return tempcode	The result of execution.
  */
 function survey_results()
 {
     $title = get_page_title('SURVEY_RESULTS');
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/survey_results';
     require_code('form_templates');
     $_m = $GLOBALS['SITE_DB']->query_select('quizzes', array('*'), array('q_type' => 'SURVEY'), 'ORDER BY q_validated DESC,q_add_date DESC', 300);
     $entries = new ocp_tempcode();
     foreach ($_m as $m) {
         $entries->attach(form_input_list_entry(strval($m['id']), false, get_translated_text($m['q_name'])));
     }
     if ($entries->is_empty()) {
         warn_exit(do_lang_tempcode('NO_ENTRIES'));
     }
     $fields = new ocp_tempcode();
     $fields->attach(form_input_list(do_lang_tempcode('SURVEY'), '', 'id', $entries, NULL, true));
     $post_url = build_url(array('page' => '_SELF', 'type' => '_survey_results'), '_SELF', NULL, false, true);
     $submit_name = do_lang_tempcode('SURVEY_RESULTS');
     breadcrumb_set_self(do_lang_tempcode('CHOOSE'));
     return do_template('FORM_SCREEN', array('SKIP_VALIDATION' => true, 'HIDDEN' => '', 'GET' => true, 'TITLE' => $title, 'TEXT' => '', 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name));
 }
Example #20
0
 /**
  * UI to add an invoice.
  *
  * @return tempcode	The interface.
  */
 function ad()
 {
     $title = get_page_title('CREATE_INVOICE');
     breadcrumb_set_parents(array(array('_SEARCH:admin_ecommerce:ecom_usage', do_lang_tempcode('ECOMMERCE')), array('_SELF:_SELF:misc', do_lang_tempcode('INVOICES'))));
     require_code('form_templates');
     $to = get_param('to', '');
     $products = find_all_products();
     $list = new ocp_tempcode();
     foreach ($products as $product => $details) {
         if ($details[0] == PRODUCT_INVOICE) {
             $text = do_lang_tempcode('CUSTOM_PRODUCT_' . $product);
             if ($details[1] != '?') {
                 $text->attach(escape_html(' (' . $details[1] . ' ' . get_option('currency') . ')'));
             }
             $list->attach(form_input_list_entry($product, false, $text));
         }
     }
     if ($list->is_empty()) {
         inform_exit(do_lang_tempcode('NOTHING_TO_INVOICE_FOR'));
     }
     $fields = new ocp_tempcode();
     $fields->attach(form_input_list(do_lang_tempcode('PRODUCT'), '', 'product', $list));
     $fields->attach(form_input_username(do_lang_tempcode('USERNAME'), do_lang_tempcode('DESCRIPTION_INVOICE_FOR'), 'to', $to, true));
     $fields->attach(form_input_float(do_lang_tempcode('AMOUNT'), do_lang_tempcode('INVOICE_AMOUNT_TEXT', escape_html(get_option('currency'))), 'amount', NULL, false));
     $fields->attach(form_input_line(do_lang_tempcode('INVOICE_SPECIAL'), do_lang_tempcode('DESCRIPTION_INVOICE_SPECIAL'), 'special', '', false));
     $fields->attach(form_input_text(do_lang_tempcode('INVOICE_NOTE'), do_lang_tempcode('DESCRIPTION_INVOICE_NOTE'), 'note', '', false));
     $post_url = build_url(array('page' => '_SELF', 'type' => '_ad'), '_SELF');
     $submit_name = do_lang_tempcode('CREATE_INVOICE');
     return do_template('FORM_SCREEN', array('HIDDEN' => '', 'TITLE' => $title, 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'TEXT' => do_lang_tempcode('DESCRIPTION_INVOICE_PAGE')));
 }
Example #21
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')));
 }
Example #22
0
/**
 * Get a nice, formatted XHTML list to select a download licence
 *
 * @param  ?AUTO_LINK	The currently selected licence (NULL: none selected)
 * @param  boolean		Whether to allow an N/A selection
 * @return tempcode		The list of categories
 */
function nice_get_download_licences($it = NULL, $allow_na = false)
{
    $list = new ocp_tempcode();
    if ($allow_na) {
        $list->attach(form_input_list_entry('-1', false, do_lang_tempcode('NA_EM')));
    }
    $rows = $GLOBALS['SITE_DB']->query_select('download_licences', array('id', 'l_title'));
    foreach ($rows as $row) {
        $list->attach(form_input_list_entry(strval($row['id']), $it == $row['id'], $row['l_title']));
    }
    return $list;
}
Example #23
0
 /**
  * Get a list of card types.
  *
  * @param  ?string	The card type to select by default (NULL: don't care)
  * @return tempcode	The list
  */
 function nice_get_card_types($it = NULL)
 {
     $list = new ocp_tempcode();
     $array = array('Visa', 'Master Card', 'Switch', 'UK Maestro', 'Maestro', 'Solo', 'Delta', 'American Express', 'Diners Card', 'JCB');
     foreach ($array as $x) {
         $list->attach(form_input_list_entry($x, $it == $x));
     }
     return $list;
 }
Example #24
0
 /**
  * The UI to accept the rules of joining.
  *
  * @return tempcode		The UI
  */
 function step1()
 {
     if (!is_guest()) {
         warn_exit(do_lang_tempcode('NO_JOIN_LOGGED_IN'));
     }
     $title = get_page_title('_JOIN');
     // Show rules
     $rules = request_page('rules', true, get_comcode_zone('rules'), NULL, true);
     $map = array('page' => '_SELF', 'type' => 'step2');
     $email_address = trim(get_param('email_address', ''));
     if ($email_address != '') {
         $map['email_address'] = $email_address;
     }
     $redirect = get_param('redirect', '');
     if ($redirect != '') {
         $map['redirect'] = $redirect;
     }
     $url = build_url($map, '_SELF');
     $group_select = new ocp_tempcode();
     $rows = $GLOBALS['FORUM_DB']->query_select('f_groups', array('id', 'g_name', 'g_is_default'), array('g_is_presented_at_install' => 1), 'ORDER BY g_order');
     if (count($rows) > 1) {
         foreach ($rows as $group) {
             if (get_param_integer('usergroup', -1) == -1) {
                 $selected = $group['g_is_default'] == 1;
             } else {
                 $selected = $group['id'] == get_param_integer('usergroup');
             }
             $group_select->attach(form_input_list_entry(strval($group['id']), $selected, get_translated_text($group['g_name'], $GLOBALS['FORUM_DB'])));
         }
     }
     breadcrumb_set_self(do_lang_tempcode('_JOIN'));
     $generate_host = '';
     //if ((get_option('allow_member_integration')!='off') && (get_option('allow_member_integration')!='hidden')) $generate_host=ocp_srv('HTTP_HOST');
     return do_template('OCF_JOIN_STEP1_SCREEN', array('_GUID' => '3776e89f3b18e4bd9dd532defe6b1e9e', 'TITLE' => $title, 'GENERATE_HOST' => $generate_host, 'RULES' => $rules, 'URL' => $url, 'GROUP_SELECT' => $group_select));
 }
Example #25
0
/**
 * Shows an HTML page of all attachments we can access with selection buttons.
 */
function attachment_popup_script()
{
    require_lang('comcode');
    require_javascript('javascript_editing');
    $connection = get_page_name() == 'topics' ? $GLOBALS['FORUM_DB'] : $GLOBALS['SITE_DB'];
    $members = array();
    if (!is_guest()) {
        $members[get_member()] = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
    }
    if (has_specific_permission(get_member(), 'reuse_others_attachments')) {
        $_members = $connection->query_select('attachments', array('DISTINCT a_member_id'));
        foreach ($_members as $_member) {
            $members[$_member['a_member_id']] = $GLOBALS['FORUM_DRIVER']->get_username($_member['a_member_id']);
        }
    }
    asort($members);
    $member_now = post_param_integer('member_id', get_member());
    if (!array_key_exists($member_now, $members)) {
        access_denied('REUSE_ATTACHMENT');
    }
    $list = new ocp_tempcode();
    foreach ($members as $member_id => $username) {
        $list->attach(form_input_list_entry(strval($member_id), $member_id == $member_now, $username));
    }
    $field_name = get_param('field_name', 'post');
    $keep = symbol_tempcode('KEEP', array(0, 1));
    $post_url = find_script('attachment_popup') . '?field_name=' . $field_name . $keep->evaluate();
    if (get_param('utheme', '') != '') {
        $post_url .= '&utheme=' . get_param('utheme');
    }
    $rows = $connection->query_select('attachments', array('*'), array('a_member_id' => $member_now));
    $content = new ocp_tempcode();
    foreach ($rows as $myrow) {
        $myrow['description'] = $myrow['a_description'];
        $tpl = render_attachment('attachment', array(), $myrow, uniqid('', true), get_member(), false, $connection, NULL, get_member());
        $content->attach(do_template('ATTACHMENTS_BROWSER_ATTACHMENT', array('_GUID' => '64356d30905c99325231d3bbee92128c', 'FIELD_NAME' => $field_name, 'TPL' => $tpl, 'DESCRIPTION' => $myrow['a_description'], 'DELETE_URL' => $post_url, 'ID' => strval($myrow['id']))));
    }
    $content = do_template('ATTACHMENTS_BROWSER', array('_GUID' => '7773aad46fb0bfe563a142030beb1a36', 'LIST' => $list, 'CONTENT' => $content, 'URL' => $post_url));
    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('ATTACHMENT_POPUP'), 'CONTENT' => $content));
    $echo->evaluate_echo();
}
Example #26
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     require_lang('unvalidated');
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/unvalidated';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_censor';
     $_title = get_page_title('UNVALIDATED_RESOURCES');
     $out = new ocp_tempcode();
     require_code('form_templates');
     $_hooks = find_all_hooks('modules', 'admin_unvalidated');
     foreach (array_keys($_hooks) as $hook) {
         require_code('hooks/modules/admin_unvalidated/' . filter_naughty_harsh($hook));
         $object = object_factory('Hook_unvalidated_' . filter_naughty_harsh($hook), true);
         if (is_null($object)) {
             continue;
         }
         $info = $object->info();
         if (is_null($info)) {
             continue;
         }
         $identifier_select = is_array($info['db_identifier']) ? implode(',', $info['db_identifier']) : $info['db_identifier'];
         $db = array_key_exists('db', $info) ? $info['db'] : $GLOBALS['SITE_DB'];
         $rows = $db->query('SELECT ' . $identifier_select . (array_key_exists('db_title', $info) ? ',' . $info['db_title'] : '') . ' FROM ' . $db->get_table_prefix() . $info['db_table'] . ' WHERE ' . $info['db_validated'] . '=0', 100);
         $content = new ocp_tempcode();
         foreach ($rows as $row) {
             if (is_array($info['db_identifier'])) {
                 $id = '';
                 foreach ($info['db_identifier'] as $_id) {
                     if ($id != '') {
                         $id .= ':';
                     }
                     $id .= $row[$_id];
                 }
             } else {
                 $id = $row[$info['db_identifier']];
             }
             if (array_key_exists('db_title', $info)) {
                 $title = $row[$info['db_title']];
                 if ($info['db_title_dereference']) {
                     $title = get_translated_text($title, $db);
                 }
                 // May actually be comcode (can't be certain), but in which case it will be shown as source
             } else {
                 $title = '#' . (is_integer($id) ? strval($id) : $id);
             }
             if ($title == '') {
                 $title = '#' . strval($id);
             }
             $content->attach(form_input_list_entry(is_integer($id) ? strval($id) : $id, false, strip_comcode($title)));
         }
         if (array_key_exists('uses_workflow', $info) && $info['uses_workflow']) {
             // Content that uses a workflow is validated via its view screen
             $post_url = build_url(array('page' => $info['view_module'], 'type' => $info['view_type'], 'validated' => 1), get_module_zone($info['view_module']), NULL, false, true);
         } else {
             // Content which isn't in a workflow is validated via its edit screen
             $post_url = build_url(array('page' => $info['edit_module'], 'type' => $info['edit_type'], 'validated' => 1), get_module_zone($info['edit_module']), NULL, false, true);
         }
         $fields = form_input_list(do_lang_tempcode('EDIT'), do_lang_tempcode('DESCRIPTION_EDIT'), $info['edit_identifier'], $content);
         if (!$content->is_empty()) {
             // Could debate whether to include "'TARGET'=>'_blank',". However it does redirect back, so it's a nice linear process like this. If it was new window it could be more efficient, but also would confuse people with a lot of new windows opening and not closing.
             $content = do_template('FORM', array('_GUID' => '51dcee39273a0fee29569190344f2e41', 'GET' => true, 'HIDDEN' => '', 'SUBMIT_NAME' => do_lang_tempcode('EDIT'), 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => ''));
         }
         $out->attach(do_template('UNVALIDATED_SECTION', array('_GUID' => '838240008e190b9cbaa0280fbddd6baf', 'TITLE' => $info['title'], 'CONTENT' => $content)));
     }
     return do_template('UNVALIDATED_SCREEN', array('_GUID' => '4e971f1c8851b821af030b5c7bbcb3fb', 'TITLE' => $_title, 'SECTIONS' => $out));
 }
Example #27
0
/**
 * Helper function. Get a nice formatted XHTML list of all the children beneath the specified CEDI page. This function is recursive.
 *
 * @param  array			A list of pages we've already seen (we don't repeat them in multiple list positions)
 * @param  ?AUTO_LINK	The CEDI page to select by default (NULL: none)
 * @param  AUTO_LINK		The CEDI page to look beneath
 * @param  string			Tree built up so far, in recursion (blank: starting recursion)
 * @param  SHORT_TEXT	The title of the CEDI page to look beneath
 * @param  boolean		Whether to create a compound list (gets pairs: tempcode, and comma-separated list of children)
 * @param  boolean		Whether to use titles in IDs after a ! (used on tree edit page)
 * @return mixed			Tempcode for the list / pair of tempcode and compound
 */
function _cedi_show_tree(&$cedi_seen, $select, $id, $tree, $title, $use_compound_list = false, $ins_format = false)
{
    $cedi_seen[] = $id;
    $sub_tree = $tree == '' ? $title . ' > ' : $tree . $title . ' > ';
    $rows = $GLOBALS['SITE_DB']->query_select('seedy_children', array('*'), array('parent_id' => $id), 'ORDER BY title', 300);
    $compound_list = strval($id) . ',';
    $_below = new ocp_tempcode();
    foreach ($rows as $i => $myrow) {
        if (!in_array($myrow['child_id'], $cedi_seen)) {
            if (!has_category_access(get_member(), 'seedy_page', strval($myrow['child_id']))) {
                continue;
            }
            if (is_null($myrow['title'])) {
                $temp_rows = $GLOBALS['SITE_DB']->query_select('seedy_pages', array('title'), array('id' => $myrow['child_id']), '', 1);
                $myrow['title'] = get_translated_text($temp_rows[0]['title']);
                $rows[$i]['title'] = $myrow['title'];
                $GLOBALS['SITE_DB']->query_update('seedy_children', array('title' => $myrow['title']), array('parent_id' => $id, 'child_id' => $myrow['child_id']));
            }
            //			$out->attach(_cedi_show_tree($cedi_seen,$select,$myrow['child_id'],do_template('CEDI_LIST_TREE_DEPTH',array('_GUID'=>'7a416b76aebd74a59abec8f9aed7e82f','BEFORE'=>$tree)),$myrow['title']));
            $below = _cedi_show_tree($cedi_seen, $select, $myrow['child_id'], $sub_tree, $myrow['title'], $use_compound_list, $ins_format);
            if ($use_compound_list) {
                list($below, $_compound_list) = $below;
                $compound_list .= $_compound_list;
            }
            $_below->attach($below);
        }
    }
    //	$out=form_input_list_entry(strval($id),($select==$id),do_template('CEDI_LIST_TREE_LINE',array('_GUID'=>'d9d4a951df598edd3f08f87be634965b','DEPTH'=>$tree,'TITLE'=>$title,'ID'=>$id)));
    //	$out='<option value="'.(!$use_compound_list?$id:$compound_list).'">'.$tree.$title.'</option>';
    //	$out.=$_below;
    $out = form_input_list_entry((!$use_compound_list ? strval($id) : $compound_list) . ($ins_format ? '!' . $title : ''), false, $tree . $title);
    $out->attach($_below);
    if ($use_compound_list) {
        return array($out, $compound_list);
    } else {
        return $out;
    }
}
Example #28
0
/**
 * Return list entry of common order statuses of orders
 *
 * @return  tempcode		Order status list entries
 */
function get_order_status_list()
{
    $status_list = new ocp_tempcode();
    $status = array('ORDER_STATUS_awaiting_payment' => do_lang_tempcode('ORDER_STATUS_awaiting_payment'), 'ORDER_STATUS_payment_received' => do_lang_tempcode('ORDER_STATUS_payment_received'), 'ORDER_STATUS_dispatched' => do_lang_tempcode('ORDER_STATUS_dispatched'), 'ORDER_STATUS_onhold' => do_lang_tempcode('ORDER_STATUS_onhold'), 'ORDER_STATUS_cancelled' => do_lang_tempcode('ORDER_STATUS_cancelled'), 'ORDER_STATUS_returned' => do_lang_tempcode('ORDER_STATUS_returned'));
    $status_list->attach(form_input_list_entry('all', false, do_lang_tempcode('NA')));
    foreach ($status as $key => $values) {
        $status_list->attach(form_input_list_entry($key, false, $values));
    }
    return $status_list;
}
Example #29
0
 /**
  * Standard aed_module list function.
  *
  * @return tempcode		The selection list
  */
 function nice_get_entries()
 {
     $rows = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('*'), array('is_im' => 0), 'ORDER BY room_name DESC', 500);
     if (count($rows) == 500) {
         warn_exit(do_lang_tempcode('TOO_MANY_TO_CHOOSE_FROM'));
     }
     $fields = new ocp_tempcode();
     foreach ($rows as $row) {
         if (!handle_chatroom_pruning($row)) {
             $fields->attach(form_input_list_entry(strval($row['id']), false, $row['room_name']));
         }
     }
     return $fields;
 }
Example #30
0
 /**
  * Standard aed_module list function.
  *
  * @return tempcode		The selection list
  */
 function nice_get_entries()
 {
     $fields = new ocp_tempcode();
     $rows = $GLOBALS['SITE_DB']->query_select('diseases', array('*'), NULL);
     foreach ($rows as $row) {
         $fields->attach(form_input_list_entry(strval($row['id']), false, $row['name']));
     }
     return $fields;
 }