Example #1
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('catalogues')) {
         return new ocp_tempcode();
     }
     require_lang('catalogues');
     $fields = new ocp_tempcode();
     $test = $GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_name', array('c_name' => 'hosted'));
     if (!is_null($test)) {
         $fields->attach(form_input_tick(do_lang_tempcode('HAVE_DEFAULT_CATALOGUES_HOSTING'), do_lang_tempcode('DESCRIPTION_HAVE_DEFAULT_CATALOGUES_HOSTING'), 'have_default_catalogues_hosting', array_key_exists('have_default_catalogues_hosting', $field_defaults) ? $field_defaults['have_default_catalogues_hosting'] == '1' : false));
     }
     $test = $GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_name', array('c_name' => 'projects'));
     if (!is_null($test)) {
         $fields->attach(form_input_tick(do_lang_tempcode('HAVE_DEFAULT_CATALOGUES_PROJECTS'), do_lang_tempcode('DESCRIPTION_HAVE_DEFAULT_CATALOGUES_PROJECTS'), 'have_default_catalogues_projects', array_key_exists('have_default_catalogues_projects', $field_defaults) ? $field_defaults['have_default_catalogues_projects'] == '1' : false));
     }
     $test = $GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_name', array('c_name' => 'faqs'));
     if (!is_null($test)) {
         $fields->attach(form_input_tick(do_lang_tempcode('HAVE_DEFAULT_CATALOGUES_FAQS'), do_lang_tempcode('DESCRIPTION_HAVE_DEFAULT_CATALOGUES_FAQS'), 'have_default_catalogues_faqs', array_key_exists('have_default_catalogues_faqs', $field_defaults) ? $field_defaults['have_default_catalogues_faqs'] == '1' : true));
     }
     $test = $GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_name', array('c_name' => 'links'));
     if (!is_null($test)) {
         $fields->attach(form_input_tick(do_lang_tempcode('HAVE_DEFAULT_CATALOGUES_LINKS'), do_lang_tempcode('DESCRIPTION_HAVE_DEFAULT_CATALOGUES_LINKS'), 'have_default_catalogues_links', array_key_exists('have_default_catalogues_links', $field_defaults) ? $field_defaults['have_default_catalogues_links'] == '1' : true));
     }
     $test = $GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_name', array('c_name' => 'modifications'));
     if (!is_null($test)) {
         $fields->attach(form_input_tick(do_lang_tempcode('HAVE_DEFAULT_CATALOGUES_MODIFICATIONS'), do_lang_tempcode('DESCRIPTION_HAVE_DEFAULT_CATALOGUES_MODIFICATIONS'), 'have_default_catalogues_modifications', array_key_exists('have_default_catalogues_modifications', $field_defaults) ? $field_defaults['have_default_catalogues_modifications'] == '1' : false));
     }
     $test = $GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_name', array('c_name' => 'contacts'));
     if (!is_null($test)) {
         $fields->attach(form_input_tick(do_lang_tempcode('HAVE_DEFAULT_CATALOGUES_CONTACTS'), do_lang_tempcode('DESCRIPTION_HAVE_DEFAULT_CATALOGUES_CONTACTS'), 'have_default_catalogues_contacts', array_key_exists('have_default_catalogues_contacts', $field_defaults) ? $field_defaults['have_default_catalogues_contacts'] == '1' : true));
     }
     return $fields;
 }
Example #2
0
 /**
  * Standard modular render function for profile tabs edit hooks.
  *
  * @param  MEMBER			The ID of the member who is being viewed
  * @param  MEMBER			The ID of the member who is doing the viewing
  * @param  boolean		Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later
  * @return ?array			A tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set)
  */
 function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false)
 {
     $title = do_lang_tempcode('DELETE_MEMBER');
     $order = 200;
     // Actualiser
     $delete_account = post_param_integer('delete', 0);
     if ($delete_account == 1) {
         if (is_guest($member_id_of)) {
             warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
         }
         ocf_delete_member($member_id_of);
         inform_exit(do_lang_tempcode('SUCCESS'));
     }
     if ($leave_to_ajax_if_possible) {
         return NULL;
     }
     // UI fields
     $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
     $text = do_lang_tempcode('_DELETE_MEMBER' . ($member_id_of == get_member() ? '_SUICIDAL' : ''), escape_html($username));
     $fields = new ocp_tempcode();
     require_code('form_templates');
     $fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false));
     $javascript = '';
     return array($title, $fields, $text, $javascript, $order);
 }
Example #3
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 (get_forum_type() != 'ocf') {
         return new ocp_tempcode();
     }
     require_lang('ocf');
     $fields = new ocp_tempcode();
     $dbs_back = $GLOBALS['NO_DB_SCOPE_CHECK'];
     $GLOBALS['NO_DB_SCOPE_CHECK'] = true;
     $test = $GLOBALS['SITE_DB']->query_value_null_ok('f_groups', 'id', array('id' => db_get_first_id() + 7));
     if (!is_null($test)) {
         $fields->attach(form_input_tick(do_lang_tempcode('HAVE_DEFAULT_RANK_SET'), do_lang_tempcode('DESCRIPTION_HAVE_DEFAULT_RANK_SET'), 'have_default_rank_set', array_key_exists('have_default_rank_set', $field_defaults) ? $field_defaults['have_default_rank_set'] == '1' : false));
     }
     $test = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'f_emoticons WHERE e_code<>\':P\' AND e_code<>\';)\' AND e_code<>\':)\' AND e_code<>\':)\' AND e_code<>\':\\\'(\'');
     if (count($test) != 0) {
         $fields->attach(form_input_tick(do_lang_tempcode('HAVE_DEFAULT_FULL_EMOTICON_SET'), do_lang_tempcode('DESCRIPTION_HAVE_DEFAULT_FULL_EMOTICON_SET'), 'have_default_full_emoticon_set', array_key_exists('have_default_full_emoticon_set', $field_defaults) ? $field_defaults['have_default_full_emoticon_set'] == '1' : true));
     }
     $fields_l = array('im_aim', 'im_msn', 'im_jabber', 'im_yahoo', 'im_skype', 'interests', 'location', 'occupation', 'sn_google', 'sn_facebook', 'sn_twitter');
     foreach ($fields_l as $field) {
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('f_custom_fields f LEFT JOIN ' . get_table_prefix() . 'translate t ON t.id=f.cf_name', 'f.id', array('text_original' => do_lang('DEFAULT_CPF_' . $field . '_NAME')));
         if (!is_null($test)) {
             $fields->attach(form_input_tick(do_lang_tempcode('HAVE_DEFAULT_CPF_SET'), do_lang_tempcode('DESCRIPTION_HAVE_DEFAULT_CPF_SET'), 'have_default_cpf_set', array_key_exists('have_default_cpf_set', $field_defaults) ? $field_defaults['have_default_cpf_set'] == '1' : false));
             break;
         }
     }
     $GLOBALS['NO_DB_SCOPE_CHECK'] = $dbs_back;
     return $fields;
 }
Example #4
0
 /**
  * Standard modular run function for features in the setup wizard.
  *
  * @return tempcode	An input field.
  */
 function get_fields()
 {
     require_lang('wordfilter');
     $fields = new ocp_tempcode();
     $fields->attach(form_input_tick(do_lang_tempcode('KEEP_WORD_FILTER'), do_lang_tempcode('DESCRIPTION_HAVE_DEFAULT_WORDFILTER'), 'have_default_wordfilter', true));
     return $fields;
 }
Example #5
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('galleries')) {
         return new ocp_tempcode();
     }
     require_lang('galleries');
     return form_input_tick(do_lang_tempcode('KEEP_PERSONAL_GALLERIES'), do_lang_tempcode('DESCRIPTION_KEEP_PERSONAL_GALLERIES'), 'keep_personal_galleries', array_key_exists('keep_personal_galleries', $field_defaults) ? $field_defaults['keep_personal_galleries'] == '1' : false);
 }
 /**
  * Get tempcode for a forum category template adding/editing form.
  *
  * @param  SHORT_TEXT	The title (name) of the forum category
  * @param  LONG_TEXT		The description for the category
  * @param  BINARY			Whether the category is expanded by default when shown in the forum view
  * @return tempcode		The input fields
  */
 function get_form_fields($title = '', $description = '', $expanded_by_default = 1)
 {
     $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_line(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', $description, false));
     $fields->attach(form_input_tick(do_lang_tempcode('EXPANDED_BY_DEFAULT'), do_lang_tempcode('DESCRIPTION_EXPANDED_BY_DEFAULT'), 'expanded_by_default', $expanded_by_default == 1));
     return $fields;
 }
Example #7
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;
}
Example #8
0
 /**
  * Get syndication field UI.
  *
  * @return tempcode		Syndication fields (or empty)
  */
 function get_syndication_option_fields()
 {
     $fields = new ocp_tempcode();
     if (has_specific_permission(get_member(), 'syndicate_site_activity') && has_external_site_wide_syndication()) {
         require_lang('activities');
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('SYNDICATION'))));
         $fields->attach(form_input_tick(do_lang_tempcode('SYNDICATE_THIS'), do_lang_tempcode('DESCRIPTION_SYNDICATE_THIS'), 'syndicate_this', true));
     }
     return $fields;
 }
Example #9
0
 /**
  * Standard actualisation stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action_done()
 {
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     $title = get_page_title('OCGIFTS_TITLE');
     require_code('form_templates');
     $fields = new ocp_tempcode();
     $fields->attach(form_input_username(do_lang_tempcode('TO_USERNAME'), do_lang_tempcode('MEMBER_TO_GIVE'), 'username', get_param('username', ''), true));
     $fields->attach(form_input_text(do_lang_tempcode('GIFT_MESSAGE'), do_lang_tempcode('DESCRIPTION_GIFT_MESSAGE'), 'gift_message', '', true));
     $fields->attach(form_input_tick(do_lang_tempcode('ANONYMOUS'), do_lang_tempcode('DESCRIPTION_ANONYMOUS'), 'anonymous', false));
     $submit_name = do_lang_tempcode('SEND_GIFT');
     $text = paragraph(do_lang_tempcode('CHOOSE_MEMBER'));
     $post_url = build_url(array('page' => 'pointstore', 'type' => 'action_done2', 'id' => 'ocgifts', 'gift' => get_param('gift', 0)), '_SEARCH');
     return do_template('FORM_SCREEN', array('SKIP_VALIDATION' => true, 'STAFF_HELP_URL' => '', 'HIDDEN' => '', 'TITLE' => $title, 'FIELDS' => $fields, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url));
 }
Example #10
0
 /**
  * Standard pointstore item configuration function.
  *
  * @return ?array		A tuple: list of [fields to shown, hidden fields], title for add form, add form (NULL: disabled)
  */
 function config()
 {
     $rows = $GLOBALS['SITE_DB']->query_select('pstore_customs', array('*'), NULL, 'ORDER BY id');
     $out = array();
     foreach ($rows as $i => $row) {
         $fields = new ocp_tempcode();
         $hidden = new ocp_tempcode();
         $fields->attach($this->get_fields('_' . strval($i), get_translated_text($row['c_title']), get_translated_text($row['c_description']), $row['c_enabled'], $row['c_cost'], $row['c_one_per_member']));
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
         $fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete_custom_' . strval($i), false));
         $hidden->attach(form_input_hidden('custom_' . strval($i), strval($row['id'])));
         $out[] = array($fields, $hidden, do_lang_tempcode('EDIT_CUSTOM_PRODUCT'));
     }
     return array($out, do_lang_tempcode('ADD_NEW_CUSTOM_PRODUCT'), $this->get_fields());
 }
Example #11
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('news')) {
         return new ocp_tempcode();
     }
     require_lang('news');
     $fields = new ocp_tempcode();
     $fields->attach(form_input_tick(do_lang_tempcode('KEEP_BLOGS'), do_lang_tempcode('DESCRIPTION_KEEP_BLOGS'), 'keep_blogs', false));
     $news_cats = $GLOBALS['SITE_DB']->query_select('news_categories', array('id'), array('nc_owner' => NULL));
     foreach ($news_cats as $news_cat) {
         if ($news_cat['id'] > db_get_first_id() && $news_cat['id'] < db_get_first_id() + 7) {
             $fields->attach(form_input_tick(do_lang_tempcode('EXTENDED_NEWS_CATEGORIES_SET'), do_lang_tempcode('DESCRIPTION_KEEP_DEFAULT_NEWS_CATEGORIES'), 'keep_news_categories', array_key_exists('keep_news_categories', $field_defaults) ? $field_defaults['keep_news_categories'] == '1' : false));
             break;
         }
     }
     return $fields;
 }
Example #12
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('banners')) {
         return new ocp_tempcode();
     }
     require_lang('banners');
     $fields = new ocp_tempcode();
     $test = $GLOBALS['SITE_DB']->query_value_null_ok('banners', 'name', array('name' => 'donate'));
     if (!is_null($test)) {
         $fields->attach(form_input_tick(do_lang_tempcode('HAVE_DEFAULT_BANNERS_DONATION'), do_lang_tempcode('DESCRIPTION_HAVE_DEFAULT_BANNERS_DONATION'), 'have_default_banners_donation', array_key_exists('have_default_banners_donation', $field_defaults) ? $field_defaults['have_default_banners_donation'] == '1' : false));
     }
     $test = $GLOBALS['SITE_DB']->query_value_null_ok('banners', 'name', array('name' => 'advertise_here'));
     if (!is_null($test)) {
         $fields->attach(form_input_tick(do_lang_tempcode('HAVE_DEFAULT_BANNERS_ADVERTISING'), do_lang_tempcode('DESCRIPTION_HAVE_DEFAULT_BANNERS_ADVERTISING'), 'have_default_banners_advertising', array_key_exists('have_default_banners_advertising', $field_defaults) ? $field_defaults['have_default_banners_advertising'] == '1' : false));
     }
     return $fields;
 }
Example #13
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;
 }
 /**
  * Get tempcode for adding/editing form.
  *
  * @param  SHORT_TEXT	The name of the custom profile field
  * @param  LONG_TEXT		The description of the field
  * @param  LONG_TEXT		The default value of the field
  * @param  BINARY			Whether the field is publicly viewable
  * @param  BINARY			Whether the field may be viewed by the owner
  * @param  BINARY			Whether the owner may set the value of the field
  * @param  BINARY			Whether the field is encrypted
  * @param  ID_TEXT		The type of the field
  * @set    short_text long_text short_trans long_trans integer upload picture url list tick
  * @param  BINARY			Whether the field is required to be filled in
  * @param  BINARY			Whether the field is to be shown on the join form
  * @param  BINARY			Whether the field is shown in posts
  * @param  BINARY			Whether the field is shown in post previews
  * @param  ?integer		The order the field is given relative to the order of the other custom profile fields (NULL: last)
  * @param  LONG_TEXT  	The usergroups that this field is confined to (comma-separated list).
  * @param  BINARY			Whether the field is locked
  * @return array			A pair: the tempcode for the visible fields, and the tempcode for the hidden fields
  */
 function get_form_fields($name = '', $description = '', $default = '', $public_view = 1, $owner_view = 1, $owner_set = 1, $encrypted = 0, $type = 'long_text', $required = 0, $show_on_join_form = 0, $show_in_posts = 0, $show_in_post_previews = 0, $order = NULL, $only_group = '', $locked = 0)
 {
     $fields = new ocp_tempcode();
     $hidden = new ocp_tempcode();
     require_code('form_templates');
     require_code('encryption');
     require_lang('fields');
     if ($locked == 0) {
         $fields->attach(form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'name', $name, true));
     } else {
         $hidden->attach(form_input_hidden('name', $name));
     }
     $fields->attach(form_input_line_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', $description, false));
     $fields->attach(form_input_line(do_lang_tempcode('DEFAULT_VALUE'), do_lang_tempcode('DESCRIPTION_DEFAULT_VALUE_CPF'), 'default', $default, false, NULL, 10000));
     $fields->attach(form_input_tick(do_lang_tempcode('OWNER_VIEW'), do_lang_tempcode('DESCRIPTION_OWNER_VIEW'), 'owner_view', $owner_view == 1));
     $fields->attach(form_input_tick(do_lang_tempcode('OWNER_SET'), do_lang_tempcode('DESCRIPTION_OWNER_SET'), 'owner_set', $owner_set == 1));
     $fields->attach(form_input_tick(do_lang_tempcode('PUBLIC_VIEW'), do_lang_tempcode('DESCRIPTION_PUBLIC_VIEW'), 'public_view', $public_view == 1));
     if (is_encryption_enabled() && $name == '') {
         $fields->attach(form_input_tick(do_lang_tempcode('ENCRYPTED'), do_lang_tempcode('DESCRIPTION_ENCRYPTED'), 'encrypted', $encrypted == 1));
     }
     require_code('fields');
     $type_list = nice_get_field_type($type, $name != '');
     $fields->attach(form_input_list(do_lang_tempcode('TYPE'), do_lang_tempcode('DESCRIPTION_FIELD_TYPE'), 'type', $type_list));
     $fields->attach(form_input_tick(do_lang_tempcode('REQUIRED'), do_lang_tempcode('DESCRIPTION_REQUIRED'), 'required', $required == 1));
     $fields->attach(form_input_tick(do_lang_tempcode('SHOW_ON_JOIN_FORM'), do_lang_tempcode('DESCRIPTION_SHOW_ON_JOIN_FORM'), 'show_on_join_form', $show_on_join_form == 1));
     $orderlist = new ocp_tempcode();
     $num_cpfs = $GLOBALS['FORUM_DB']->query_value('f_custom_fields', 'COUNT(*)');
     if ($name == '') {
         $num_cpfs++;
     }
     $selected_one = false;
     for ($i = 0; $i < (is_null($order) ? $num_cpfs : max($num_cpfs, $order)); $i++) {
         $selected = $i === $order || $name == '' && $i == $num_cpfs - 1;
         if ($selected) {
             $selected_one = true;
         }
         $orderlist->attach(form_input_list_entry(strval($i), $selected, integer_format($i + 1)));
     }
     if (!$selected_one) {
         $orderlist->attach(form_input_list_entry(strval($order), true, integer_format($order + 1)));
     }
     $fields->attach(form_input_list(do_lang_tempcode('ORDER'), do_lang_tempcode('DESCRIPTION_FIELD_ORDER'), 'order', $orderlist));
     $fields->attach(form_input_tick(do_lang_tempcode('SHOW_IN_POSTS'), do_lang_tempcode('DESCRIPTION_SHOW_IN_POSTS'), 'show_in_posts', $show_in_posts == 1));
     $fields->attach(form_input_tick(do_lang_tempcode('SHOW_IN_POST_PREVIEWS'), do_lang_tempcode('DESCRIPTION_SHOW_IN_POST_PREVIEWS'), 'show_in_post_previews', $show_in_post_previews == 1));
     $rows = $GLOBALS['FORUM_DB']->query_select('f_groups', array('id', 'g_name', 'g_is_super_admin'), array('g_is_private_club' => 0));
     if ($locked == 0) {
         $groups = new ocp_tempcode();
         //$groups=form_input_list_entry('-1',false,do_lang_tempcode('_ALL'));
         foreach ($rows as $group) {
             if ($group['id'] != db_get_first_id()) {
                 $groups->attach(form_input_list_entry(strval($group['id']), count(array_intersect(array($group['id']), explode(',', $only_group))) != 0, get_translated_text($group['g_name'], $GLOBALS['FORUM_DB'])));
             }
         }
         $fields->attach(form_input_multi_list(do_lang_tempcode('GROUP'), do_lang_tempcode('DESCRIPTION_FIELD_ONLY_GROUP'), 'only_group', $groups));
     } else {
         $hidden->attach(form_input_hidden('only_group', ''));
     }
     return array($fields, $hidden);
 }
Example #15
0
 /**
  * Interface to edit a test section.
  *
  * @return tempcode	The result of execution.
  */
 function _ed()
 {
     $title = get_page_title('EDIT_TEST_SECTION');
     check_specific_permission('edit_own_tests');
     $id = get_param_integer('id');
     $rows = $GLOBALS['SITE_DB']->query_select('test_sections', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         warn_exit('MISSING_RESOURCE');
     }
     $section = $rows[0];
     if (!(has_specific_permission(get_member(), 'edit_own_tests') && ($section['s_assigned_to'] == get_member() || $GLOBALS['FORUM_DRIVER']->is_staff(get_member())))) {
         access_denied('ACCESS_DENIED');
     }
     $fields = $this->get_test_section_form_fields($section['s_section'], $section['s_notes'], $section['s_assigned_to'], $section['s_inheritable']);
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
     $fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false));
     $add_template = do_template('TESTER_TEST_GROUP_NEW', array('_GUID' => '3d0e12fdff0aef8f8aa5818e441238ee', 'ID' => 'add_-REPLACEME-', 'FIELDS' => $this->get_test_form_fields('add_-REPLACEME-')));
     $_tests = $GLOBALS['SITE_DB']->query_select('tests', array('*'), array('t_section' => $id));
     $tests = new ocp_tempcode();
     foreach ($_tests as $test) {
         $_fields = $this->get_test_form_fields('edit_' . strval($test['id']), $test['t_test'], $test['t_assigned_to'], $test['t_enabled'], $test['t_inherit_section']);
         $_fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
         $_fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'edit_' . strval($test['id']) . '_delete', false));
         $_test = do_template('TESTER_TEST_GROUP', array('_GUID' => '620b45c5ff5bf26417442865e6bcb045', 'ID' => 'edit_' . strval($test['id']), 'FIELDS' => $_fields));
         $tests->attach($_test);
     }
     $post_url = build_url(array('page' => '_SELF', 'type' => '__ed', 'id' => $id), '_SELF');
     return do_template('TESTER_ADD_SECTION_SCREEN', array('_GUID' => 'ee10a568b6dacd8baf1efeac3e7bcb40', 'TITLE' => $title, 'SUBMIT_NAME' => do_lang_tempcode('SAVE'), 'TESTS' => $tests, 'URL' => $post_url, 'FIELDS' => $fields, 'ADD_TEMPLATE' => $add_template));
 }
Example #16
0
 /**
  * Standard modular UI to edit an entry.
  *
  * @return tempcode	The UI
  */
 function _ed()
 {
     $doing = 'EDIT_' . $this->lang_type;
     if ($this->catalogue && get_param('catalogue_name', '') != '') {
         $catalogue_title = get_translated_text($GLOBALS['SITE_DB']->query_value('catalogues', 'c_title', array('c_name' => get_param('catalogue_name'))));
         if ($this->type_code == 'd') {
             $doing = do_lang('CATALOGUE_GENERIC_EDIT', escape_html($catalogue_title));
         } elseif ($this->type_code == 'c') {
             $doing = do_lang('CATALOGUE_GENERIC_EDIT_CATEGORY', escape_html($catalogue_title));
         }
     }
     $title = get_page_title($doing);
     //$submit_name=(strpos($doing,' ')!==false)?protect_from_escaping($doing):do_lang($doing);
     //if (!is_null($this->edit_submit_name)) $submit_name=$this->edit_submit_name;
     $submit_name = do_lang_tempcode('SAVE');
     //$test=$this->choose_catalogue($title);
     //if (!is_null($test)) return $test;
     $id = mixed();
     // Define type as mixed
     $id = $this->non_integer_id ? get_param('id', false, true) : strval(get_param_integer('id'));
     $map = array('page' => '_SELF', 'type' => '__e' . $this->type_code, 'id' => $id);
     if (get_param('catalogue_name', '') != '') {
         $map['catalogue_name'] = get_param('catalogue_name');
     }
     if (!is_null(get_param('redirect', NULL))) {
         $map['redirect'] = get_param('redirect');
     }
     if (!is_null(get_param('continue', NULL))) {
         $map['continue'] = get_param('continue');
     }
     if (!is_null($this->upload) || $this->possibly_some_kind_of_upload) {
         $map['uploading'] = 1;
     }
     $post_url = build_url($map, '_SELF');
     if (multi_lang() && has_actual_page_access(get_member(), 'admin_lang') && user_lang() != get_site_default_lang()) {
         require_code('lang2');
         $switch_url = get_self_url(false, false, array('keep_lang' => get_site_default_lang()));
         attach_message(do_lang_tempcode('lang:EDITING_CONTENT_IN_LANGUAGE_STAFF', escape_html(lookup_language_full_name(user_lang())), escape_html(lookup_language_full_name(get_site_default_lang())), escape_html($switch_url->evaluate())), 'warn');
     }
     if (method_exists($this, 'get_submitter')) {
         list($submitter, $date_and_time) = $this->get_submitter($id);
     } else {
         $submitter = NULL;
         $date_and_time = NULL;
     }
     if (!is_null($this->permissions_require)) {
         check_edit_permission($this->permissions_require, $submitter, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? NULL : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? NULL : $this->get_cat_b($id)), $this->permission_page_name);
     }
     if (!is_null($this->permissions_cat_require) && !has_category_access(get_member(), $this->permissions_cat_require, $this->get_cat($id))) {
         access_denied('CATEGORY_ACCESS');
     }
     if (!is_null($this->permissions_cat_require_b) && !has_category_access(get_member(), $this->permissions_cat_require_b, $this->get_cat_b($id))) {
         access_denied('CATEGORY_ACCESS');
     }
     $bits = $this->fill_in_edit_form($id);
     $delete_fields = new ocp_tempcode();
     $all_delete_fields_given = false;
     $fields2 = new ocp_tempcode();
     if (is_array($bits)) {
         $fields = $bits[0];
         $hidden = $bits[1];
         if (array_key_exists(2, $bits) && !is_null($bits[2])) {
             $delete_fields = $bits[2];
         }
         if (array_key_exists(3, $bits) && !is_null($bits[3])) {
             $this->edit_text = $bits[3];
         }
         if (array_key_exists(4, $bits) && $bits[4]) {
             $all_delete_fields_given = true;
         }
         if (array_key_exists(5, $bits) && !is_null($bits[5])) {
             $this->posting_form_text = $bits[5];
         }
         if (array_key_exists(6, $bits) && !is_null($bits[6])) {
             $fields2 = $bits[6];
         }
         if (array_key_exists(7, $bits)) {
             $this->posting_form_text_parsed = $bits[7];
         }
     } else {
         $fields = $bits;
         $hidden = new ocp_tempcode();
     }
     // Add in custom fields
     if ($this->has_tied_catalogue()) {
         require_code('fields');
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('MORE'))));
         append_form_custom_fields($this->award_type, $id, $fields, $hidden);
     }
     // SEO?
     if (!is_null($this->seo_type)) {
         require_code('seo2');
         $fields2->attach(seo_get_fields($this->seo_type, $id));
     }
     // Awards?
     if (addon_installed('awards')) {
         if (!is_null($this->award_type)) {
             require_code('awards');
             $fields2->attach(get_award_fields($this->award_type, $id));
         }
     }
     // Action fields / deletion options
     $delete_permission = true;
     if (!is_null($this->permissions_require)) {
         $delete_permission = has_delete_permission($this->permissions_require, get_member(), $submitter, is_null($this->permission_page_name) ? get_page_name() : $this->permission_page_name, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? NULL : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? NULL : $this->get_cat_b($id)));
     }
     $may_delete = (!method_exists($this, 'may_delete_this') || $this->may_delete_this($id)) && (!is_numeric($id) || intval($id) >= db_get_first_id() + $this->protect_first) && $delete_permission;
     // Deletion options
     $action_fields = new ocp_tempcode();
     if ($may_delete) {
         if (!$all_delete_fields_given) {
             $action_fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false));
         }
         if (addon_installed('points') && !is_null($submitter) && !is_null($date_and_time)) {
             $points_test = $GLOBALS['SITE_DB']->query_value_null_ok('gifts', 'id', array('date_and_time' => $date_and_time, 'gift_to' => $submitter, 'gift_from' => $GLOBALS['FORUM_DRIVER']->get_guest_id()));
             if (!is_null($points_test)) {
                 require_lang('points');
                 $action_fields->attach(form_input_tick(do_lang_tempcode('REVERSE_TITLE'), do_lang_tempcode('REVERSE_TITLE_DESCRIPTION'), 'reverse_point_transaction', false));
             }
         }
         $action_fields->attach($delete_fields);
     }
     if (!$this->appended_actions_already && !$action_fields->is_empty()) {
         $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
     }
     $fields2->attach($action_fields);
     if (!is_object($this->edit_text)) {
         $this->edit_text = make_string_tempcode(is_null($this->edit_text) ? '' : $this->edit_text);
     }
     if (!is_null($this->upload)) {
         if ($this->upload == 'image') {
             require_code('images');
             $max = floatval(get_max_image_size()) / floatval(1024 * 1024);
             if ($max < 3.0) {
                 require_code('files2');
                 $config_url = get_upload_limit_config_url();
                 $this->edit_text->attach(paragraph(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max)), escape_html(is_null($config_url) ? '' : $config_url))));
             }
         } else {
             require_code('files2');
             $max = floatval(get_max_file_size()) / floatval(1024 * 1024);
             if ($max < 30.0) {
                 $config_url = get_upload_limit_config_url();
                 $this->edit_text->attach(paragraph(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max)), escape_html(is_null($config_url) ? '' : $config_url))));
             }
         }
     }
     if (get_param('type', '_ed') == '_edit_catalogue') {
         require_javascript('javascript_catalogues');
         // Existing fields
         $field_count = 0;
         $c_name = get_param('id', false, true);
         $rows = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('*'), array('c_name' => $c_name), 'ORDER BY cf_order');
         $fields_existing = new ocp_tempcode();
         foreach ($rows as $i => $myrow) {
             $name = get_translated_text($myrow['cf_name']);
             $description = get_translated_text($myrow['cf_description']);
             $prefix = 'existing_field_' . strval($myrow['id']) . '_';
             list($_fields_existing, $_fields_hidden) = $this->get_field_fields($i == 0 && substr($c_name, 0, 1) != '_', count($rows) + 10, $prefix, $field_count, $name, $description, $myrow['cf_type'], $myrow['cf_defines_order'], $myrow['cf_visible'], $myrow['cf_searchable'], $myrow['cf_default'], $myrow['cf_required'], $myrow['cf_put_in_category'], $myrow['cf_put_in_search']);
             if (!is_ecommerce_catalogue($c_name) || $i > 9) {
                 $_fields_existing->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
                 $_fields_existing->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), $prefix . 'delete', false));
             }
             $temp = do_template('FORM_FIELD_SET_GROUPER', array('_GUID' => '1492d973db45cbecff892ad4ac1af28f' . get_class($this), 'NAME' => $name, 'ID' => 'FIELD_' . strval($i + 1), 'FIELDS' => $_fields_existing->evaluate()));
             $fields_existing->attach($temp);
             $hidden->attach($_fields_hidden);
             $field_count++;
         }
         // New field
         $fields_new = new ocp_tempcode();
         for ($i = 0; $i < 5; $i++) {
             list($_fields_new, $_fields_hidden) = $this->get_field_fields(false, count($rows) + 10, 'new_field_' . strval($i) . '_', $field_count);
             $temp = do_template('FORM_FIELD_SET_GROUPER', array('_GUID' => '8b9a632eafae003ccc6b007eefb0ce3d' . get_class($this), 'NAME' => do_lang_tempcode('NEW_FIELD', strval($i + 1)), 'ID' => 'NEW_FIELD_' . strval($i + 1), 'FIELDS' => $_fields_new->evaluate()));
             $fields_new->attach($temp);
             $hidden->attach($_fields_hidden);
             $field_count++;
         }
         $fields->attach($fields2);
         return do_template('CATALOGUE_EDITING_SCREEN', array('_GUID' => '584d7dc7c2c13939626102374f13f508' . get_class($this), 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => $this->add_text, 'URL' => $post_url, 'FIELDS' => $fields->evaluate(), 'FIELDS_EXISTING' => $fields_existing->evaluate(), 'FIELDS_NEW' => $fields_new->evaluate(), 'SUBMIT_NAME' => $submit_name, 'JAVASCRIPT' => $this->javascript));
     }
     list($warning_details, $ping_url) = handle_conflict_resolution();
     if (!is_null($this->posting_form_title)) {
         $posting_form = get_posting_form($submit_name, $this->posting_form_text, $post_url, $hidden, $fields, $this->posting_form_title, '', $fields2, $this->posting_form_text_parsed, $this->javascript, NULL, $this->posting_field_required);
         return do_template('POSTING_SCREEN', array('_GUID' => '841b9af3aa80bcab86b907e4b942786a' . get_class($this), 'PREVIEW' => $this->do_preview, 'TITLE' => $title, 'SEPARATE_PREVIEW' => $this->second_stage_preview, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TEXT' => $this->add_text, 'POSTING_FORM' => $posting_form->evaluate(), 'JAVASCRIPT' => $this->javascript));
     } else {
         $fields->attach($fields2);
         return do_template('FORM_SCREEN', array('_GUID' => '2d70be34595a16c6f170d966b894bfe2' . get_class($this), 'PREVIEW' => $this->do_preview, 'SEPARATE_PREVIEW' => $this->second_stage_preview, 'TITLE' => $title, 'SKIP_VALIDATION' => $this->skip_validation, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'HIDDEN' => $hidden, 'TEXT' => $this->edit_text, 'URL' => $post_url, 'FIELDS' => $fields->evaluate(), 'SUBMIT_NAME' => $submit_name, 'JAVASCRIPT' => $this->javascript));
     }
 }
Example #17
0
 /**
  * The UI to send a newsletter.
  *
  * @param  LONG_TEXT		Default newsletter to put in
  * @return tempcode		The UI
  */
 function send_gui($_existing = '')
 {
     // If this is a periodic newsletter, we make some changes to the regular
     // language strings.
     $periodic_action_raw = post_param('periodic_choice', '');
     $periodic_subject = '';
     $defaults = mixed();
     switch (preg_replace('#\\_\\d+$#', '', $periodic_action_raw)) {
         case 'remove_existing':
             // Remove whatever is already set. We don't need any changes for
             // this, but we do need a hidden form field.
             $periodic_action = 'remove';
             break;
         case 'replace_existing':
             // Make the current newsletter periodic. This requires language
             // fiddling.
             $periodic_action = 'replace';
             $periodic_subject = do_lang('PERIODIC_SUBJECT_HELP');
             $periodic_id = intval(preg_replace('#^[^\\d]+#', '', $periodic_action_raw));
             $_defaults = $GLOBALS['SITE_DB']->query_select('newsletter_periodic', array('*'), array('id' => $periodic_id), '', 1);
             if (!array_key_exists(0, $_defaults)) {
                 warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
             }
             $defaults = $_defaults[0];
             break;
         case 'make_periodic':
             // Make the current newsletter periodic. This requires language
             // fiddling.
             $periodic_action = 'make';
             $periodic_subject = do_lang('PERIODIC_SUBJECT_HELP');
             break;
         case 'no_change':
         default:
             // The default action is to leave the current settings as-is.
             $periodic_action = 'none';
             break;
     }
     $title = get_page_title('NEWSLETTER_SEND');
     $lang = choose_language($title);
     if (is_object($lang)) {
         return $lang;
     }
     $comcode_given = $_existing != '' && strpos($_existing, '<html') !== false;
     $_existing = post_param('message', $_existing);
     if ($_existing == '') {
         $from_news = get_param_integer('from_news', -1);
         if ($from_news != -1 && addon_installed('news')) {
             $rows = $GLOBALS['SITE_DB']->query_select('news', array('*'), array('id' => $from_news), 'ORDER BY id DESC', 1);
             if (!array_key_exists(0, $rows)) {
                 require_lang('news');
                 return warn_screen(get_page_title('NEWS'), do_lang_tempcode('MISSING_RESOURCE'));
             }
             $myrow = $rows[0];
             $_existing = get_translated_text($myrow['news_article'], NULL, $lang);
             if ($_existing == '') {
                 $_existing = get_translated_text($myrow['news'], NULL, $lang);
             }
         }
         $existing = do_template('NEWSLETTER_DEFAULT', array('_GUID' => '53c02947915806e519fe14c318813f42', 'CONTENT' => $_existing, 'LANG' => $lang));
     } else {
         $default = do_template('NEWSLETTER_DEFAULT', array('_GUID' => '53c02947915806e519fe14c318813f44', 'CONTENT' => $_existing, 'LANG' => $lang));
         if (strpos($default->evaluate(), '<html') !== false) {
             if ($comcode_given) {
                 $default = do_template('NEWSLETTER_DEFAULT', array('_GUID' => '53c02947915806e519fe14c318813f46', 'CONTENT' => comcode_to_tempcode($_existing), 'LANG' => $lang));
             }
             $existing = $default;
         } else {
             $existing = make_string_tempcode($_existing);
         }
     }
     $post_url = build_url(array('page' => '_SELF', 'type' => 'confirm', 'old_type' => get_param('type', '')), '_SELF');
     $submit_name = do_lang_tempcode('PREVIEW');
     $hidden = new ocp_tempcode();
     $hidden->attach(form_input_hidden('lang', $lang));
     // Build up form
     $fields = new ocp_tempcode();
     require_code('form_templates');
     $default_subject = get_option('newsletter_title');
     if (!is_null($defaults)) {
         $default_subject = $defaults['np_subject'];
     }
     if ($periodic_action != 'make' && $periodic_action != 'replace') {
         $default_subject .= ' - ' . get_timezoned_date(time(), false, false, false, true);
     }
     $default_subject = post_param('subject', $default_subject);
     $fields->attach(form_input_line_comcode(do_lang_tempcode('SUBJECT'), do_lang_tempcode('NEWSLETTER_DESCRIPTION_TITLE', $periodic_subject), 'subject', $default_subject, true));
     $in_full = post_param_integer('in_full', 0);
     $chosen_categories = post_param('chosen_categories', '');
     if ($periodic_action == 'make' || $periodic_action == 'replace') {
         // We are making a periodic newsletter. This means we need to pass
         // through the chosen categories
         if (!is_null($defaults)) {
             $chosen_categories = $defaults['np_message'];
             $in_full = $defaults['np_in_full'];
             $fields->attach(form_input_tick(do_lang_tempcode('EMBED_FULL_ARTICLES'), do_lang_tempcode('DESCRIPTION_EMBED_FULL_ARTICLES'), 'in_full', $in_full == 1));
             $fields->attach(form_input_huge(do_lang_tempcode('NEWSLETTER_CONTENT'), do_lang('NEWSLETTER_CONTENT_SELECT'), 'chosen_categories', $chosen_categories, true));
         } else {
             $hidden->attach(form_input_hidden('chosen_categories', $chosen_categories));
             $hidden->attach(form_input_hidden('in_full', strval($in_full)));
         }
         $hidden->attach(form_input_hidden('cutoff_day', post_param('cutoff_day')));
         $hidden->attach(form_input_hidden('cutoff_month', post_param('cutoff_month')));
         $hidden->attach(form_input_hidden('cutoff_year', post_param('cutoff_year')));
         $hidden->attach(form_input_hidden('cutoff_hour', post_param('cutoff_hour')));
         $hidden->attach(form_input_hidden('cutoff_minute', post_param('cutoff_minute')));
         $hidden->attach(form_input_hidden('message', $existing->evaluate()));
     } else {
         $hidden->attach(form_input_hidden('in_full', strval($in_full)));
         if (strpos($existing->evaluate(), '<html') === false) {
             $fields->attach(form_input_huge_comcode(do_lang_tempcode('MESSAGE'), do_lang_tempcode('DESCRIPTION_MESSAGE_NEWSLETTER'), 'message', $existing->evaluate(), true));
         } else {
             $fields->attach(form_input_huge(do_lang_tempcode('MESSAGE'), do_lang_tempcode('DESCRIPTION_MESSAGE_NEWSLETTER'), 'message', $existing->evaluate(), true));
         }
     }
     if (addon_installed('calendar') && $periodic_action == 'none' && cron_installed()) {
         $fields->attach(form_input_date__scheduler(do_lang_tempcode('DEFER_TIME'), do_lang_tempcode('DESCRIPTION_DEFER_TIME'), 'schedule', true, true, true));
     }
     $from_email = post_param('from_email', get_option('staff_address'));
     if (!is_null($defaults)) {
         $from_email = post_param('from_email', $defaults['np_from_email']);
     }
     $fields->attach(form_input_email(do_lang_tempcode('FROM_EMAIL'), do_lang_tempcode('DESCRIPTION_NEWSLETTER_FROM_EMAIL'), 'from_email', $from_email, true));
     $from_name = post_param('from_name', get_site_name());
     if (!is_null($defaults)) {
         $from_name = post_param('from_name', $defaults['np_from_name']);
     }
     $fields->attach(form_input_line(do_lang_tempcode('FROM_NAME'), do_lang_tempcode('DESCRIPTION_NEWSLETTER_FROM_NAME'), 'from_name', $from_name, true));
     $_html_only = post_param_integer('html_only', NULL);
     if (is_null($_html_only)) {
         $html_only = strpos($existing->evaluate(), '<html') !== false;
         if (!is_null($defaults)) {
             $html_only = $defaults['np_html_only'];
         }
     } else {
         $html_only = $_html_only == 1;
     }
     if (get_value('force_html_only') === '1') {
         $hidden->attach(form_input_hidden('html_only', '1'));
     } else {
         $fields->attach(form_input_tick(do_lang_tempcode('HTML_ONLY'), do_lang_tempcode('DESCRIPTION_HTML_ONLY'), 'html_only', $html_only));
     }
     $l = new ocp_tempcode();
     $priority = post_param_integer('priority', 3);
     if (!is_null($defaults)) {
         $priority = post_param_integer('priority', $defaults['np_priority']);
     }
     for ($i = 1; $i <= 5; $i++) {
         $l->attach(form_input_list_entry(strval($i), $i == $priority, do_lang_tempcode('PRIORITY_' . strval($i))));
     }
     $fields->attach(form_input_list(do_lang_tempcode('PRIORITY'), do_lang_tempcode('DESCRIPTION_NEWSLETTER_PRIORITY'), 'priority', $l));
     // Where to send to
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('CHOOSE_SEND_TO'))));
     $newsletters = $GLOBALS['SITE_DB']->query_select('newsletters', array('*'));
     foreach ($newsletters as $newsletter) {
         $level = post_param_integer(strval($newsletter['id']), post_param_integer('level', -1));
         $c4 = $this->count_level($newsletter['id'], 4, $lang);
         $c3 = $this->count_level($newsletter['id'], 3, $lang);
         $c2 = $this->count_level($newsletter['id'], 2, $lang);
         $c1 = $this->count_level($newsletter['id'], 1, $lang);
         if ($c1 != 0) {
             $newsletter_title = get_translated_text($newsletter['title']);
             $newsletter_description = get_translated_text($newsletter['description']);
             if ($c1 == $c2 && $c1 == $c3 && $c1 == $c4) {
                 $fields->attach(form_input_tick(do_lang_tempcode('NEWSLETTER_PREFIX', escape_html($newsletter_title)), do_lang_tempcode('DESCRIPTION_NOSUBSCRIPTION_LEVEL', escape_html(integer_format($c4)), escape_html($newsletter_description)), strval($newsletter['id']), $level >= 1, NULL, '4'));
             } else {
                 $l = new ocp_tempcode();
                 $l->attach(form_input_list_entry('0', $level == 0, do_lang_tempcode('NNR', do_lang_tempcode('NEWSLETTER_0_ALT'), do_lang_tempcode('NUM_READERS', integer_format(0)))));
                 $l->attach(form_input_list_entry('1', $level == 1, do_lang_tempcode('NNR', do_lang_tempcode('NEWSLETTER_1'), do_lang_tempcode('NUM_READERS', integer_format($c1)))));
                 $l->attach(form_input_list_entry('2', $level == 2, do_lang_tempcode('NNR', do_lang_tempcode('NEWSLETTER_2'), do_lang_tempcode('NUM_READERS', integer_format($c2)))));
                 $l->attach(form_input_list_entry('3', $level == 3, do_lang_tempcode('NNR', do_lang_tempcode('NEWSLETTER_3'), do_lang_tempcode('NUM_READERS', integer_format($c3)))));
                 $l->attach(form_input_list_entry('4', $level == 4, do_lang_tempcode('NNR', do_lang_tempcode('NEWSLETTER_4'), do_lang_tempcode('NUM_READERS', integer_format($c4)))));
                 $fields->attach(form_input_list(do_lang_tempcode('SUBSCRIPTION_LEVEL_FOR', escape_html($newsletter_title)), do_lang_tempcode('DESCRIPTION_SUBSCRIPTION_LEVEL', escape_html($newsletter_description)), strval($newsletter['id']), $l));
             }
         }
     }
     if (get_forum_type() == 'ocf') {
         $c5 = $this->count_level(-1, 5, $lang);
         $fields->attach(form_input_tick(do_lang_tempcode('NEWSLETTER_OCF'), do_lang_tempcode('NUM_READERS', integer_format($c5)), '-1', false));
         $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list();
         foreach ($groups as $group_id => $group) {
             if ($group_id != db_get_first_id()) {
                 $map = array();
                 $map['g' . strval($group_id)] = 1;
                 $_c = newsletter_who_send_to($map, $lang, 0, 0);
                 $c6 = $_c[6]['g' . strval($group_id)];
                 if ($c6 != 0) {
                     $fields->attach(form_input_tick(do_lang_tempcode('THIS_WITH', do_lang_tempcode('GROUP'), make_string_tempcode(escape_html($group))), do_lang_tempcode('NUM_READERS', integer_format($c6)), 'g' . strval($group_id), post_param_integer('g' . strval($group_id), 0) == 1));
                 }
             }
         }
     }
     $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD_CSV'), 'file', false, NULL, NULL, true, 'csv,txt'));
     //if ($fields->is_empty()) inform_exit(do_lang_tempcode('NOBODY_TO_SEND_TO'));
     handle_max_file_size($hidden);
     $template_choices = new ocp_tempcode();
     $dh = opendir(get_custom_file_base() . '/themes/default/templates_custom');
     while (($f = readdir($dh)) !== false) {
         if (preg_match('#^MAIL.*\\.tpl$#', $f) != 0) {
             $tpl = basename($f, '.tpl');
             $template_choices->attach(form_input_list_entry($tpl, post_param('template', 'MAIL') == $tpl, $tpl));
         }
     }
     if (!file_exists(get_custom_file_base() . '/themes/default/templates_custom/MAIL.tpl')) {
         $template_choices->attach(form_input_list_entry('MAIL', true, 'MAIL'));
     }
     closedir($dh);
     $fields->attach(form_input_list(do_lang_tempcode('NEWSLETTER_TEMPLATE'), do_lang_tempcode('DESCRIPTION_NEWSLETTER_TEMPLATE'), 'template', $template_choices, NULL, false, true));
     // If we're making a periodic newsletter then we need to know when it
     // should be sent
     if ($periodic_action == 'make' || $periodic_action == 'replace') {
         $hidden->attach(form_input_hidden('make_periodic', '1'));
         $hidden->attach(form_input_hidden('periodic_choice', post_param('periodic_choice')));
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang('PERIODIC_WHEN'), 'HELP' => do_lang('PERIODIC_WHEN_HELP'))));
         // The choices are given as radio buttons: weekly or bi-weekly or monthly?
         // In the labels for these radio buttons, we put a dropdown for day of
         // the week and day of the month.
         $frequency = post_param('periodic_when', 'weekly');
         if (!is_null($defaults)) {
             $frequency = post_param('periodic_when', $defaults['np_frequency']);
         }
         $current_day_weekly = post_param_integer('periodic_weekly', 5);
         if (!is_null($defaults)) {
             $current_day_weekly = post_param_integer('periodic_weekly', $defaults['np_day']);
         }
         $current_day_biweekly = post_param_integer('periodic_biweekly', 5);
         if (!is_null($defaults)) {
             $current_day_biweekly = post_param_integer('periodic_biweekly', $defaults['np_day']);
         }
         $current_day_of_month = post_param_integer('periodic_monthly', 1);
         if (!is_null($defaults)) {
             $current_day_of_month = post_param_integer('periodic_monthly', $defaults['np_day']);
         }
         $radios = new ocp_tempcode();
         $week_days_weekly = new ocp_tempcode();
         $week_days_biweekly = new ocp_tempcode();
         require_lang('dates');
         $week_days = array(1 => do_lang('MONDAY'), 2 => do_lang('TUESDAY'), 3 => do_lang('WEDNESDAY'), 4 => do_lang('THURSDAY'), 5 => do_lang('FRIDAY'), 6 => do_lang('SATURDAY'), 7 => do_lang('SUNDAY'));
         foreach ($week_days as $i => $this_day) {
             $week_days_weekly->attach(form_input_list_entry(strval($i), $i == $current_day_weekly, $this_day, false, false));
             $week_days_biweekly->attach(form_input_list_entry(strval($i), $i == $current_day_biweekly, $this_day, false, false));
         }
         $weekly_desc = new ocp_tempcode();
         $weekly_desc->attach(do_lang('PERIODIC_WEEKLY_ON'));
         $weekly_desc->attach(do_template('FORM_SCREEN_INPUT_LIST', array('TABINDEX' => strval(get_form_field_tabindex(NULL)), 'REQUIRED' => '0', 'NAME' => 'periodic_weekday_weekly', 'CONTENT' => $week_days_weekly, 'INLINE_LIST' => '0')));
         $radios->attach(form_input_radio_entry('periodic_when', 'weekly', $frequency == 'weekly', $weekly_desc, NULL, ''));
         $weekly_desc = new ocp_tempcode();
         $weekly_desc->attach(do_lang('PERIODIC_BIWEEKLY_ON'));
         $weekly_desc->attach(do_template('FORM_SCREEN_INPUT_LIST', array('TABINDEX' => strval(get_form_field_tabindex(NULL)), 'REQUIRED' => '0', 'NAME' => 'periodic_weekday_biweekly', 'CONTENT' => $week_days_biweekly, 'INLINE_LIST' => '0')));
         $radios->attach(form_input_radio_entry('periodic_when', 'biweekly', $frequency == 'biweekly', $weekly_desc, NULL, ''));
         $month_days = new ocp_tempcode();
         foreach (range(1, 28) as $this_day) {
             $suffix = gmdate('S', gmmktime(0, 0, 0, 1, $this_day, 1990));
             $month_days->attach(form_input_list_entry(strval($this_day), $this_day == 1, strval($this_day) . $suffix, $current_day_of_month == $this_day));
         }
         $monthly_desc = new ocp_tempcode();
         $monthly_desc->attach(do_lang('PERIODIC_MONTHLY_ON'));
         $monthly_desc->attach(do_template('FORM_SCREEN_INPUT_LIST', array('TABINDEX' => strval(get_form_field_tabindex(NULL)), 'REQUIRED' => '0', 'NAME' => 'periodic_monthly', 'CONTENT' => $month_days, 'INLINE_LIST' => '0')));
         $radios->attach(form_input_radio_entry('periodic_when', 'monthly', $frequency == 'monthly', $monthly_desc, NULL, ''));
         $fields->attach(form_input_radio(do_lang('PERIODIC_WHEN_CHOICE'), '', 'periodic_when', $radios, true));
         $radios = new ocp_tempcode();
         $radios->attach(form_input_radio_entry('periodic_for', 'all', false, do_lang_tempcode('CREATE_PERIODIC_FOR_ALL'), NULL, ''));
         $radios->attach(form_input_radio_entry('periodic_for', 'future', true, do_lang_tempcode('CREATE_PERIODIC_FOR_FUTURE'), NULL, ''));
         $fields->attach(form_input_radio(do_lang('CREATE_PERIODIC_FOR'), '', 'periodic_for', $radios, true));
     }
     return do_template('FORM_SCREEN', array('_GUID' => '0b2a4825ec586d9ff557026d9a1e0cca', 'TITLE' => $title, 'TEXT' => $periodic_action == 'make' || $periodic_action == 'replace' ? do_lang_tempcode('PERIODIC_NO_EDIT') : do_lang_tempcode('NEWSLETTER_SEND_TEXT'), 'HIDDEN' => $hidden, 'FIELDS' => $fields->evaluate(), 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url));
 }
Example #18
0
 /**
  * The UI for the second stage of recommending the site - when CSV file is posted
  *
  * @return tempcode	The UI.
  */
 function gui2()
 {
     require_code('form_templates');
     $submit_name = do_lang_tempcode('PROCEED');
     $post_url = build_url(array('page' => '_SELF', 'type' => 'actual'), '_SELF');
     $fields = new ocp_tempcode();
     $hidden = new ocp_tempcode();
     $already = array();
     $email_counter = 0;
     foreach ($_POST as $key => $input_value) {
         //stripslashes if necessary
         if (get_magic_quotes_gpc()) {
             $input_value = stripslashes($input_value);
         }
         if (substr($key, 0, 14) == 'email_address_') {
             $already[] = $input_value;
             //email address
             $email_counter++;
             $hidden->attach(form_input_hidden($key, $input_value));
         } else {
             //add hidden field to the form
             if ($key != 'upload') {
                 $hidden->attach(form_input_hidden($key, $input_value));
             }
         }
     }
     $hidden->attach(form_input_hidden('select_contacts_page', '1'));
     $text = do_lang_tempcode('RECOMMEND_SITE_TEXT_CHOOSE_CONTACTS');
     $page_title = get_param('page_title', NULL, true);
     if (!is_null(get_param('from', NULL, true))) {
         if (is_null($page_title)) {
             $title = get_page_title('RECOMMEND_LINK');
         } else {
             $title = get_page_title($page_title, false);
         }
     } else {
         if (is_null($page_title)) {
             $title = get_page_title('_RECOMMEND_SITE', true, array(escape_html(get_site_name())));
         } else {
             $title = get_page_title($page_title, false);
         }
         $hidden->attach(form_input_hidden('wrap_message', '1'));
     }
     $success_read = false;
     //start processing CSV file
     if (get_value('disable_csv_recommend') !== '1' && !is_guest()) {
         if (array_key_exists('upload', $_FILES)) {
             if (is_uploaded_file($_FILES['upload']['tmp_name']) && preg_match('#\\.csv#', $_FILES['upload']['name']) != 0) {
                 $possible_email_fields = array('E-mail', 'Email', 'E-mail address', 'Email address', 'Primary Email');
                 $possible_name_fields = array('Name', 'Forename', 'First Name', 'Display Name', 'First');
                 $fixed_contents = unixify_line_format(file_get_contents($_FILES['upload']['tmp_name']));
                 $myfile = @fopen($_FILES['upload']['tmp_name'], 'wb');
                 if ($myfile !== false) {
                     fwrite($myfile, $fixed_contents);
                     fclose($myfile);
                 }
                 $myfile = fopen($_FILES['upload']['tmp_name'], 'rb');
                 $del = ',';
                 $csv_header_line_fields = fgetcsv($myfile, 10240, $del);
                 if (count($csv_header_line_fields) == 1 && strpos($csv_header_line_fields[0], ';') !== false) {
                     $del = ';';
                     rewind($myfile);
                     $csv_header_line_fields = fgetcsv($myfile, 10240, $del);
                 }
                 $skip_next_process = false;
                 if (function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding') && strlen(mb_detect_encoding($csv_header_line_fields[0], "ASCII,UTF-8,UTF-16,UTF16")) == 0) {
                     //test string just for Apple mail detection
                     $test_unicode = utf8_decode(mb_convert_encoding($csv_header_line_fields[0], "UTF-8", "UTF-16"));
                     if (preg_match('#\\?\\?ame#u', $test_unicode) != 0) {
                         //THIS SHOULD BE APPLE MAIL
                         foreach ($csv_header_line_fields as $key => $value) {
                             $csv_header_line_fields[$key] = utf8_decode(mb_convert_encoding($csv_header_line_fields[$key], "UTF-8", "UTF-16"));
                             $found_email_address = '';
                             $found_name = '';
                             $first_row_exploded = explode(';', $csv_header_line_fields[0]);
                             $email_index = 1;
                             //by default
                             $name_index = 0;
                             //by default
                             foreach ($csv_header_line_fields as $key2 => $value2) {
                                 if (preg_match('#\\?\\?ame#', $value2) != 0) {
                                     $name_index = $key2;
                                 }
                                 //Windows mail
                                 if (preg_match('#E\\-mail#', $value2) != 0) {
                                     $email_index = $key2;
                                 }
                                 //both
                             }
                             while (($csv_line = fgetcsv($myfile, 10240, $del)) !== false) {
                                 foreach ($csv_line as $key2 => $value2) {
                                     $csv_line[$key2] = utf8_decode(mb_convert_encoding($value2, "UTF-8", "UTF-16"));
                                 }
                                 $found_email_address = array_key_exists($email_index, $csv_line) && strlen($csv_line[$email_index]) > 0 ? $csv_line[$email_index] : '';
                                 $found_email_address = preg_match('#.*\\@.*\\..*#', $found_email_address) != 0 ? preg_replace("#\"#", '', $found_email_address) : '';
                                 $found_name = $found_email_address;
                                 if (strlen($found_email_address) > 0) {
                                     $skip_next_process = true;
                                     //Add to the list what we've found
                                     $fields->attach(form_input_tick($found_name, $found_email_address, 'use_details_' . strval($email_counter), true));
                                     $hidden->attach(form_input_hidden('details_email_' . strval($email_counter), $found_email_address));
                                     $hidden->attach(form_input_hidden('details_name_' . strval($email_counter), $found_name));
                                     $email_counter++;
                                     $success_read = true;
                                 }
                             }
                         }
                     }
                 }
                 if (!$skip_next_process) {
                     //there is a strange symbol that appears at start of the Windows Mail file, so we need to convert the first file line to catch these
                     if (function_exists('mb_check_encoding') && mb_check_encoding($csv_header_line_fields[0], 'UTF-8')) {
                         $csv_header_line_fields[0] = utf8_decode($csv_header_line_fields[0]);
                     }
                     //this means that we need to import from Windows mail (also for Outlook Express) export file, which is different from others csv export formats
                     if (array_key_exists(0, $csv_header_line_fields) && (preg_match('#\\?Name#', $csv_header_line_fields[0]) != 0 || preg_match('#Name\\;E\\-mail\\sAddress#', $csv_header_line_fields[0]) != 0)) {
                         $found_email_address = '';
                         $found_name = '';
                         $first_row_exploded = explode(';', $csv_header_line_fields[0]);
                         $email_index = 1;
                         //by default
                         $name_index = 0;
                         //by default
                         foreach ($first_row_exploded as $key => $value) {
                             if (preg_match('#\\?Name#', $value) != 0) {
                                 $name_index = $key;
                             }
                             //Windows mail
                             if (preg_match('#^Name$#', $value) != 0) {
                                 $name_index = $key;
                             }
                             //Outlook Express
                             if (preg_match('#E\\-mail\\sAddress#', $value) != 0) {
                                 $email_index = $key;
                             }
                             //both
                         }
                         while (($csv_line = fgetcsv($myfile, 10240, $del)) !== false) {
                             $row_exploded = array_key_exists(0, $csv_line) && strlen($csv_line['0']) > 0 ? explode(';', $csv_line[0]) : array('', '');
                             $found_email_address = strlen($row_exploded[$email_index]) > 0 ? $row_exploded[$email_index] : '';
                             $found_name = strlen($row_exploded[$name_index]) > 0 ? $row_exploded[$name_index] : '';
                             if (strlen($found_email_address) > 0) {
                                 //Add to the list what we've found
                                 $fields->attach(form_input_tick($found_name, do_lang_tempcode('RECOMMENDING_TO_LINE', escape_html($found_name), escape_html($found_email_address)), 'use_details_' . strval($email_counter), true));
                                 $hidden->attach(form_input_hidden('details_email_' . strval($email_counter), $found_email_address));
                                 $hidden->attach(form_input_hidden('details_name_' . strval($email_counter), $found_name));
                                 $email_counter++;
                                 $success_read = true;
                             }
                         }
                     } else {
                         while (($csv_line = fgetcsv($myfile, 10240, $del)) !== false) {
                             $found_email_address = '';
                             $found_name = '';
                             foreach ($possible_email_fields as $field) {
                                 foreach ($csv_header_line_fields as $i => $header_field) {
                                     if (strtolower($header_field) == strtolower($field) && array_key_exists($i, $csv_line) && $csv_line[$i] != '') {
                                         $found_email_address = $csv_line[$i];
                                         $success_read = true;
                                     }
                                 }
                             }
                             foreach ($possible_name_fields as $field) {
                                 foreach ($csv_header_line_fields as $i => $header_field) {
                                     if (strtolower($header_field) == strtolower($field) && array_key_exists($i, $csv_line) && $csv_line[$i] != '') {
                                         $found_name = $csv_line[$i];
                                     }
                                 }
                             }
                             if (strlen($found_email_address) > 0) {
                                 //Add to the list what we've found
                                 $fields->attach(form_input_tick($found_name, do_lang_tempcode('RECOMMENDING_TO_LINE', escape_html($found_name), escape_html($found_email_address)), 'use_details_' . strval($email_counter), true));
                                 $hidden->attach(form_input_hidden('details_email_' . strval($email_counter), $found_email_address));
                                 $hidden->attach(form_input_hidden('details_name_' . strval($email_counter), $found_name));
                                 $email_counter++;
                             }
                         }
                     }
                 }
                 fclose($myfile);
             }
         }
     }
     if (!$success_read) {
         warn_exit(do_lang_tempcode('ERROR_NO_CONTACTS_SELECTED'));
     }
     return do_template('FORM_SCREEN', array('PREVIEW' => true, 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name, 'TEXT' => $text));
 }
Example #19
0
 function get_form_fields($id = NULL, $name = '', $image = '', $cure = '', $cure_price = 10, $immunization = '', $immunization_price = 5, $spread_rate = 12, $points_per_spread = 10, $enabled = 0)
 {
     $fields = new ocp_tempcode();
     $hidden = new ocp_tempcode();
     require_code('form_templates');
     $fields->attach(form_input_line(do_lang_tempcode('DISEASE'), do_lang_tempcode('DESCRIPTION_DISEASE'), 'name', $name, true));
     $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'image', 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'), 'url', $image, false));
     handle_max_file_size($hidden, 'image');
     $fields->attach(form_input_line(do_lang_tempcode('CURE'), do_lang_tempcode('DESCRIPTION_CURE'), 'cure', $cure, true));
     $fields->attach(form_input_line(do_lang_tempcode('CURE_PRICE'), '', 'cure_price', strval($cure_price), true));
     $fields->attach(form_input_line(do_lang_tempcode('IMMUNIZATION'), do_lang_tempcode('DESCRIPTION_IMMUNIZATION'), 'immunization', $immunization, true));
     $fields->attach(form_input_line(do_lang_tempcode('IMMUNIZATION_PRICE'), '', 'immunization_price', strval($immunization_price), true));
     $fields->attach(form_input_line(do_lang_tempcode('SPREAD_RATE'), do_lang_tempcode('DESCRIPTION_SPREAD_RATE'), 'spread_rate', strval($spread_rate), true));
     $fields->attach(form_input_line(do_lang_tempcode('POINTS_PER_SPREAD'), do_lang_tempcode('DESCRIPTION_POINTS_PER_SPREAD'), 'points_per_spread', strval($points_per_spread), true));
     $fields->attach(form_input_tick(do_lang_tempcode('DISEASE_ENABLED'), do_lang_tempcode('DESCRIPTION_DISEASE_ENABLED'), 'enabled', $enabled == 1));
     return array($fields, $hidden);
 }
Example #20
0
/**
 * Gather the permissions for the specified page as form field inputs.
 *
 * @param  ID_TEXT		The ID code for the zone
 * @param  ID_TEXT		The ID code for the page
 * @param  ?tempcode		Extra help to show in interface (NULL: none)
 * @return tempcode		The form fields
 */
function get_page_permissions_for_environment($zone, $page, $help = NULL)
{
    require_lang('permissions');
    $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups();
    $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true, true);
    // View access
    $access = array();
    foreach (array_keys($groups) as $id) {
        $access[$id] = 0;
    }
    $access_rows = $GLOBALS['SITE_DB']->query_select('group_page_access', array('group_id'), array('zone_name' => $zone, 'page_name' => $page));
    foreach ($access_rows as $row) {
        $access[$row['group_id']] = 1;
    }
    // Interface
    $fields = new ocp_tempcode();
    $temp = do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('PERMISSIONS'), 'HELP' => $help, 'SECTION_HIDDEN' => true));
    $fields->attach($temp);
    foreach ($groups as $id => $group_name) {
        if (!in_array($id, $admin_groups)) {
            $perhaps = $access[$id];
            $overrides = array();
            $temp = form_input_tick(do_lang_tempcode('ACCESS_FOR', escape_html($group_name)), do_lang_tempcode('DESCRIPTION_ACCESS_FOR', escape_html($group_name)), 'access_' . strval($id), $perhaps == 0);
            $fields->attach($temp);
        }
    }
    return $fields;
}
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 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;
 }
 /**
  * Get tempcode for a post template adding/editing form.
  *
  * @param  SHORT_TEXT	The emoticon code
  * @param  SHORT_TEXT	The theme image code
  * @param  integer		The relevance level of the emoticon
  * @range  0 4
  * @param  BINARY			Whether the emoticon is usable as a topic emoticon
  * @param  BINARY			Whether this may only be used by privileged members
  * @return array			A pair: The input fields, Hidden fields
  */
 function get_form_fields($code = ':-]', $theme_img_code = '', $relevance_level = 1, $use_topics = 1, $is_special = 0)
 {
     $fields = new ocp_tempcode();
     $hidden = new ocp_tempcode();
     $fields->attach(form_input_line(do_lang_tempcode('CODE'), do_lang_tempcode('DESCRIPTION_EMOTICON_CODE'), 'code', $code, true));
     if (get_base_url() == get_forum_base_url()) {
         $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images'))));
         handle_max_file_size($hidden, 'image');
     }
     require_code('themes2');
     $ids = get_all_image_ids_type('ocf_emoticons', false, $GLOBALS['FORUM_DB']);
     $fields->attach(form_input_picture_choose_specific(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('STOCK')), do_lang_tempcode('DESCRIPTION_ALTERNATE_STOCK'), 'theme_img_code', $ids, NULL, $theme_img_code, NULL, true, $GLOBALS['FORUM_DB']));
     $list = new ocp_tempcode();
     for ($i = 0; $i <= 4; $i++) {
         $list->attach(form_input_list_entry(strval($i), $i == $relevance_level, do_lang_tempcode('EMOTICON_RELEVANCE_LEVEL_' . strval($i))));
     }
     $fields->attach(form_input_list(do_lang_tempcode('RELEVANCE_LEVEL'), do_lang_tempcode('DESCRIPTION_RELEVANCE_LEVEL'), 'relevance_level', $list));
     $fields->attach(form_input_tick(do_lang_tempcode('USE_TOPICS'), do_lang_tempcode('DESCRIPTION_USE_TOPICS'), 'use_topics', $use_topics == 1));
     $fields->attach(form_input_tick(do_lang_tempcode('EMOTICON_IS_SPECIAL'), do_lang_tempcode('DESCRIPTION_EMOTICON_IS_SPECIAL'), 'is_special', $is_special == 1));
     return array($fields, $hidden);
 }
Example #24
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;
 }
Example #25
0
 /**
  * The UI for choosing caches to empty.
  *
  * @return tempcode		The UI
  */
 function choose_cache_type()
 {
     $hooks = find_all_hooks('modules', 'admin_cleanup');
     $title = get_page_title('CLEANUP_TOOLS');
     $url = build_url(array('page' => '_SELF', 'type' => 'rebuild'), '_SELF');
     require_code('form_templates');
     $fields_cache = new ocp_tempcode();
     $fields_optimise = new ocp_tempcode();
     foreach (array_keys($hooks) as $hook) {
         require_code('hooks/modules/admin_cleanup/' . filter_naughty_harsh($hook));
         $object = object_factory('Hook_' . filter_naughty_harsh($hook), true);
         if (is_null($object)) {
             continue;
         }
         $output = $object->info();
         if (!is_null($output)) {
             $tick = form_input_tick($output['title'], $output['description'], $hook, false);
             if ($output['type'] == 'cache') {
                 $fields_cache->attach($tick);
             } else {
                 $fields_optimise->attach($tick);
             }
         }
     }
     $fields = new ocp_tempcode();
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('CACHES_PAGE_EXP_OPTIMISERS'), 'HELP' => '')));
     $fields->attach($fields_optimise);
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('CACHES_PAGE_EXP_CACHES'), 'HELP' => do_lang_tempcode('CACHES_PAGE_CACHES'))));
     $fields->attach($fields_cache);
     return do_template('FORM_SCREEN', array('_GUID' => '85bfdf171484604594a157aa8983f920', 'SKIP_VALIDATION' => true, 'TEXT' => do_lang_tempcode('CACHES_PAGE'), 'SUBMIT_NAME' => do_lang_tempcode('PROCEED'), 'HIDDEN' => '', 'TITLE' => $title, 'FIELDS' => $fields, 'URL' => $url));
 }
Example #26
0
 /**
  * The UI to edit a zone.
  *
  * @return tempcode		The UI
  */
 function _edit_zone()
 {
     $title = get_page_title('EDIT_ZONE');
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/zones';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_structure';
     $zone = get_param('id', '');
     // '' needed for short URLs
     if ($zone == '/') {
         $zone = '';
     }
     $rows = $GLOBALS['SITE_DB']->query_select('zones', array('*'), array('zone_name' => $zone), '', 1);
     if (!array_key_exists(0, $rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $row = $rows[0];
     $header_text = get_translated_text($row['zone_header_text']);
     list($fields, $hidden, $javascript) = $this->get_form_fields(false, get_translated_text($row['zone_title']), $row['zone_default_page'], $header_text, $row['zone_theme'], $row['zone_wide'], $row['zone_require_session'], $row['zone_displayed_in_menu'], $zone);
     $hidden->attach(form_input_hidden('zone', $zone));
     $no_delete_zones = get_forum_type() == 'ocf' ? array('', 'adminzone', 'forum') : array('', 'adminzone');
     $no_rename_zones = array('', 'adminzone', 'forum');
     $no_rename = in_array($zone, $no_rename_zones) || get_file_base() != get_custom_file_base();
     if ($no_rename) {
         $hidden->attach(form_input_hidden('new_zone', $zone));
     } else {
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
         $rename_label = 'DESCRIPTION_ZONE_RENAME';
         if (in_array($zone, array('site', 'cms', 'collaboration'))) {
             $rename_label = 'DESCRIPTION_ZONE_RENAME_DEFAULT_ZONE';
         }
         $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode($rename_label), 'new_zone', $zone, true));
     }
     if (!in_array($zone, $no_delete_zones) && get_file_base() == get_custom_file_base()) {
         if ($no_rename) {
             $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
         }
         $fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false));
     }
     $map = array('page' => '_SELF', 'type' => '__edit');
     $url = get_param('redirect', NULL);
     if (!is_null($url)) {
         $map['redirect'] = $url;
     }
     $post_url = build_url($map, '_SELF');
     $submit_name = do_lang_tempcode('SAVE');
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('ZONES')), array('_SELF:_SELF:edit_zone', do_lang_tempcode('CHOOSE'))));
     return do_template('FORM_SCREEN', array('_GUID' => '54a578646aed86da06f30c459c9586c2', 'JAVASCRIPT' => $javascript, 'HIDDEN' => $hidden, 'SUBMIT_NAME' => $submit_name, 'TITLE' => $title, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => ''));
 }
Example #27
0
 /**
  * The UI for deleting all the messages in a room.
  *
  * @return tempcode	The UI.
  */
 function chat_delete_all_messages()
 {
     $title = get_page_title('DELETE_ALL_MESSAGES');
     $id = get_param_integer('id');
     check_chatroom_access($id);
     $room_details = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $room_details)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $row = $room_details[0];
     $has_mod_access = has_specific_permission(get_member(), 'edit_lowrange_content', 'cms_chat', array('chat', $id)) || $row['room_owner'] == get_member() && has_specific_permission(get_member(), 'moderate_my_private_rooms');
     if (!$has_mod_access) {
         access_denied('SPECIFIC_PERMISSION', 'edit_lowrange_content');
     }
     $fields = new ocp_tempcode();
     require_code('form_templates');
     $fields->attach(form_input_tick(do_lang_tempcode('PROCEED'), do_lang_tempcode('Q_SURE'), 'continue_delete', false));
     $text = paragraph(do_lang_tempcode('CONFIRM_DELETE_ALL_MESSAGES', escape_html(get_chatroom_name($id))));
     $post_url = build_url(array('page' => '_SELF', 'type' => '_delete', 'id' => $id), '_SELF');
     $submit_name = do_lang_tempcode('DELETE');
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHOOSE')), array('_SELF:_SELF:room:id=' . strval($id), do_lang_tempcode('CHAT_MOD_PANEL'))));
     return do_template('FORM_SCREEN', array('_GUID' => '31b488e5d4ff52ffd5e097876c0b13c7', 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'TITLE' => $title, 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'TEXT' => $text));
 }
Example #28
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);
 }
Example #29
0
 /**
  * The UI to delete all chat rooms.
  *
  * @return tempcode		The UI
  */
 function delete_all()
 {
     $title = get_page_title('DELETE_ALL_ROOMS');
     $fields = new ocp_tempcode();
     require_code('form_templates');
     $fields->attach(form_input_tick(do_lang_tempcode('PROCEED'), do_lang_tempcode('Q_SURE'), 'continue_delete', false));
     $posting_name = do_lang_tempcode('PROCEED');
     //$posting_url=build_url(array('page'=>'_SELF','mode'=>$mode,'type'=>'private_add'),'_SELF');
     $posting_url = build_url(array('page' => '_SELF', 'type' => '_delete_all'), '_SELF');
     $text = paragraph(do_lang_tempcode('CONFIRM_DELETE_ALL_ROOMS'));
     return do_template('FORM_SCREEN', array('_GUID' => 'fdf02f5b3a3b9ce6d1abaccf0970ed73', 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'TITLE' => $title, 'FIELDS' => $fields, 'SUBMIT_NAME' => $posting_name, 'URL' => $posting_url, 'TEXT' => $text));
 }
 /**
  * Get tempcode for a custom comcode tag adding/editing form.
  *
  * @param  SHORT_TEXT	The title (name) of the custom comcode tag
  * @param  LONG_TEXT		The description of the tag
  * @param  BINARY			Whether the tag is enabled
  * @param  ID_TEXT		The actual tag code
  * @param  LONG_TEXT		What to replace the tag with
  * @param  LONG_TEXT		Example usage
  * @param  SHORT_TEXT	Comma-separated list of accepted parameters
  * @param  BINARY			Whether it is a dangerous tag
  * @param  BINARY			Whether it is a block tag
  * @param  BINARY			Whether it is a textual tag
  * @return tempcode		The input fields
  */
 function get_form_fields($title = '', $description = '', $enabled = 1, $tag = 'this', $replace = '<span class="example" style="color: {color}">{content}</span>', $example = '[this color="red"]blah[/this]', $parameters = 'color=black', $dangerous_tag = 0, $block_tag = 0, $textual_tag = 1)
 {
     $fields = new ocp_tempcode();
     require_code('comcode_text');
     $fields->attach(form_input_codename(do_lang_tempcode('COMCODE_TAG'), do_lang_tempcode('DESCRIPTION_COMCODE_TAG'), 'tag', $tag, true, NULL, MAX_COMCODE_TAG_LOOK_AHEAD_LENGTH));
     $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TAG_TITLE'), 'title', $title, true));
     $fields->attach(form_input_line(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', $description, true));
     $fields->attach(form_input_text(do_lang_tempcode('COMCODE_REPLACE'), do_lang_tempcode('DESCRIPTION_COMCODE_REPLACE'), 'replace', $replace, true));
     $fields->attach(form_input_line(do_lang_tempcode('PARAMETERS'), do_lang_tempcode('DESCRIPTION_COMCODE_PARAMETERS'), 'parameters', $parameters, false));
     $fields->attach(form_input_tick(do_lang_tempcode('DANGEROUS_TAG'), do_lang_tempcode('DESCRIPTION_DANGEROUS_TAG'), 'dangerous_tag', $dangerous_tag == 1));
     $fields->attach(form_input_tick(do_lang_tempcode('BLOCK_TAG'), do_lang_tempcode('DESCRIPTION_BLOCK_TAG'), 'block_tag', $block_tag == 1));
     $fields->attach(form_input_tick(do_lang_tempcode('TEXTUAL_TAG'), do_lang_tempcode('DESCRIPTION_TEXTUAL_TAG'), 'textual_tag', $textual_tag == 1));
     $fields->attach(form_input_line(do_lang_tempcode('EXAMPLE'), do_lang_tempcode('DESCRIPTION_COMCODE_EXAMPLE'), 'example', $example, true));
     $fields->attach(form_input_tick(do_lang_tempcode('ENABLED'), '', 'enabled', $enabled == 1));
     return $fields;
 }