Ejemplo n.º 1
0
/**
 * Get a splurghified version of the specified item.
 *
 * @param  string			The name of what the key we want to reference is in our array of maps (e.g. 'id')
 * @param  array			A row of maps for data we are splurghing; this is probably just the result of $GLOBALS['SITE_DB']->query_select
 * @param  URLPATH		The stub that links will be passed through
 * @param  ID_TEXT		The page name we will be saving customised HTML under
 * @param  TIME			The time we did our last change to the data being splurghed (so it can see if we can simply decache instead of deriving)
 * @param  ?AUTO_LINK	The ID that is at the root of our tree (NULL: db_get_first_id)
 * @return string			A string of HTML that represents our splurghing (will desplurgh in the users browser)
 */
function splurgh_master_build($key_name, $map, $url_stub, $_cache_file, $last_change_time, $first_id = NULL)
{
    if (is_null($first_id)) {
        $first_id = db_get_first_id();
    }
    if (!array_key_exists($first_id, $map)) {
        return '';
    }
    if (!has_js()) {
        warn_exit(do_lang_tempcode('MSG_JS_NEEDED'));
    }
    require_javascript('javascript_splurgh');
    if (is_browser_decacheing()) {
        $last_change_time = time();
    }
    $cache_file = zone_black_magic_filterer(get_custom_file_base() . '/' . get_zone_name() . '/pages/html_custom/' . filter_naughty(user_lang()) . '/' . filter_naughty($_cache_file) . '.htm');
    if (!file_exists($cache_file) || is_browser_decacheing() || filesize($cache_file) == 0 || $last_change_time > filemtime($cache_file)) {
        $myfile = @fopen($cache_file, 'wt');
        if ($myfile === false) {
            intelligent_write_error($cache_file);
        }
        $fulltable = array();
        $splurgh = _splurgh_do_node($map, $first_id, '', $fulltable, 0);
        $page = do_template('SPLURGH', array('_GUID' => '8775edfc5a386fdf2cec69b0fc889952', 'KEY_NAME' => $key_name, 'URL_STUB' => $url_stub, 'SPLURGH' => str_replace('"', '\'', $splurgh)));
        $ev = $page->evaluate();
        if (fwrite($myfile, $ev) < strlen($ev)) {
            warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
        }
        fclose($myfile);
        fix_permissions($cache_file);
        sync_file($cache_file);
        return $ev;
    }
    return file_get_contents($cache_file, FILE_TEXT);
}
Ejemplo n.º 2
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_code('catalogues');
     require_lang('catalogues');
     require_css('catalogues');
     $number = array_key_exists('param', $map) ? intval($map['param']) : 10;
     $catalogue = array_key_exists('catalogue', $map) ? $map['catalogue'] : 'faqs';
     $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('catalogues');
     $root = array_key_exists('root', $map) && $map['root'] != '' ? intval($map['root']) : NULL;
     $catalogues = $GLOBALS['SITE_DB']->query_select('catalogues', array('*'), array('c_name' => $catalogue), '', 1);
     if (!array_key_exists(0, $catalogues)) {
         return do_lang_tempcode('MISSING_RESOURCE', escape_html($catalogue));
     }
     $catalogue_row = $catalogues[0];
     $entries = $GLOBALS['SITE_DB']->query_select('catalogue_entries', array('*'), array('c_name' => $catalogue, 'ce_validated' => 1), 'ORDER BY ce_add_date DESC', $number);
     $tpl_set = $catalogue;
     $display_type = array_key_exists('display_type', $map) ? intval($map['display_type']) : NULL;
     list($content, , ) = get_catalogue_category_entry_buildup(db_get_first_id(), $catalogue, $catalogue_row, 'SEARCH', $tpl_set, $number, 0, NULL, $root, $display_type, false, $entries);
     $catalogue_title = get_translated_text($catalogue_row['c_title']);
     if ($content->is_empty()) {
         if (has_actual_page_access(NULL, 'cms_catalogues', NULL, NULL) && has_submit_permission('mid', get_member(), get_ip_address(), 'cms_catalogues')) {
             $submit_url = build_url(array('page' => 'cms_catalogues', 'type' => 'add_entry', 'catalogue_name' => $catalogue, 'redirect' => SELF_REDIRECT), get_module_zone('cms_catalogues'));
         } else {
             $submit_url = new ocp_tempcode();
         }
         return do_template('BLOCK_NO_ENTRIES', array('HIGH' => false, 'TITLE' => do_lang_tempcode('RECENT', escape_html(integer_format($number)), escape_html($catalogue_title)), 'MESSAGE' => do_lang_tempcode('NO_ENTRIES'), 'ADD_NAME' => do_lang_tempcode('CATALOGUE_GENERIC_ADD', escape_html($catalogue_title)), 'SUBMIT_URL' => $submit_url));
     }
     return do_template('BLOCK_MAIN_RECENT_CC_ENTRIES', array('_GUID' => 'a57fa1b83d1b6fe3acbceb2b618e6d7f', 'CATALOGUE_TITLE' => $catalogue_title, 'CATALOGUE' => $catalogue, 'CONTENT' => $content, 'NUMBER' => integer_format($number)));
 }
Ejemplo n.º 3
0
 function setUp()
 {
     parent::setUp();
     require_code('ecommerce');
     require_code('autosave');
     require_code('shopping');
     require_code('form_templates');
     require_lang('ecommerce');
     $this->access_mapping = array(db_get_first_id() => 4);
     // Creating cms catalogues object
     require_code('adminzone/pages/modules/admin_ecommerce.php');
     $this->admin_ecom = new Module_admin_ecommerce();
     /*require_code('adminzone/pages/modules/admin_shipping.php');
     		$this->admin_shipping	=	new Module_admin_shipping();
     		$this->admin_shipping->run_start('misc');*/
     /*require_code('adminzone/pages/modules_custom/admin_credits.php');
     		$this->admin_credits		=	new Module_admin_credits();*/
     require_code('adminzone/pages/modules/admin_orders.php');
     $this->admin_orders = new Module_admin_orders();
     $this->admin_orders->run();
     $GLOBALS['SITE_DB']->query_insert('shopping_order', array('c_member' => get_member(), 'session_id' => get_session_id(), 'add_date' => time(), 'tot_price' => 0.0, 'order_status' => 'NEW', 'notes' => '', 'transaction_id' => 'ddfsfdsdfsdfs', 'purchase_through' => 'paypal', 'tax_opted_out' => 0));
     /*require_code('adminzone/pages/modules/admin_permissions_products.php');
     		$this->admin_permission_products		=	new Module_admin_permissions_products();
     		$this->admin_permission_products->run();*/
 }
Ejemplo n.º 4
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'max';
     $category_id = array_key_exists('param', $map) ? intval($map['param']) : db_get_first_id();
     $max = get_param_integer('max', array_key_exists('max', $map) ? intval($map['max']) : 30);
     $start = get_param_integer('start', 0);
     $root = array_key_exists('root', $map) && $map['root'] != '' ? intval($map['root']) : get_param_integer('root', NULL);
     $sort = array_key_exists('sort', $map) ? $map['sort'] : '';
     $search = array_key_exists('search', $map) ? $map['search'] : '';
     require_lang('catalogues');
     require_code('catalogues');
     require_code('feedback');
     require_css('catalogues');
     $select = NULL;
     if (!is_null($map) && array_key_exists('select', $map)) {
         require_code('ocfiltering');
         $select = ocfilter_to_sqlfragment($map['select'], 'e.id', 'catalogue_categories', 'cc_parent_id', 'cc_id', 'id');
     }
     $categories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('*'), array('id' => $category_id), '', 1);
     if (!array_key_exists(0, $categories)) {
         return do_lang_tempcode('MISSING_RESOURCE');
     }
     $category = $categories[0];
     $catalogue_name = $category['c_name'];
     $catalogues = $GLOBALS['SITE_DB']->query_select('catalogues', array('*'), array('c_name' => $catalogue_name), '', 1);
     $catalogue = $catalogues[0];
     $tpl_set = array_key_exists('template_set', $map) ? $map['template_set'] : $catalogue_name;
     $display_type = array_key_exists('display_type', $map) ? intval($map['display_type']) : NULL;
     list($entry_buildup, , , ) = get_catalogue_category_entry_buildup(is_null($select) ? $category_id : NULL, $catalogue_name, $catalogue, 'CATEGORY', $tpl_set, $max, $start, $select, $root, $display_type, true, NULL, $search, $sort);
     return do_template('CATALOGUE_' . $tpl_set . '_CATEGORY_EMBED', array('ROOT' => strval($root), 'CATALOGUE' => $catalogue_name, 'ENTRIES' => $entry_buildup), NULL, false, 'CATALOGUE_DEFAULT_CATEGORY_EMBED');
 }
Ejemplo n.º 5
0
 /**
  * Standard modular run function for RSS hooks.
  *
  * @param  string			A list of categories we accept from
  * @param  TIME			Cutoff time, before which we do not show results from
  * @param  string			Prefix that represents the template set we use
  * @set    RSS_ ATOM_
  * @param  string			The standard format of date to use for the syndication type represented in the prefix
  * @param  integer		The maximum number of entries to return, ordering by date
  * @return ?array			A pair: The main syndication section, and a title (NULL: error)
  */
 function run($_filters, $cutoff, $prefix, $date_string, $max)
 {
     if (!addon_installed('cedi')) {
         return NULL;
     }
     if (!has_actual_page_access(get_member(), 'cedi')) {
         return NULL;
     }
     $filters = ocfilter_to_sqlfragment($_filters, 'id', 'seedy_children', 'parent_id', 'parent_id', 'child_id');
     $content = new ocp_tempcode();
     $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'seedy_pages WHERE ' . $filters . ' AND add_date>' . strval((int) $cutoff) . ' ORDER BY add_date DESC', $max);
     foreach ($rows as $row) {
         $id = strval($row['id']);
         if (!has_category_access(get_member(), 'seedy_page', strval($row['id']))) {
             continue;
         }
         $author = '';
         $news_date = date($date_string, $row['add_date']);
         $edit_date = '';
         $news_title = xmlentities(escape_html(get_translated_text($row['title'])));
         $_summary = get_translated_tempcode($row['description']);
         $summary = xmlentities($_summary->evaluate());
         $news = '';
         $category = '';
         $category_raw = '';
         $view_url = build_url(array('page' => 'cedi', 'type' => 'misc', 'id' => $row['id'] == db_get_first_id() ? NULL : $row['id']), get_module_zone('cedi'), NULL, false, false, true);
         $if_comments = new ocp_tempcode();
         $content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date)));
     }
     require_lang('cedi');
     return array($content, do_lang('CEDI_PAGES'));
 }
Ejemplo n.º 6
0
 /**
  * Standard modular run function for setting features from the setup wizard.
  */
 function set_fields()
 {
     if (!addon_installed('news')) {
         return;
     }
     $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups();
     $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
     $GLOBALS['SITE_DB']->query_delete('gsp', array('specific_permission' => 'have_personal_category', 'the_page' => 'cms_news'));
     if (post_param_integer('keep_blogs', 0) == 1) {
         foreach (array_keys($groups) as $group_id) {
             if (!in_array($group_id, $admin_groups)) {
                 $GLOBALS['SITE_DB']->query_insert('gsp', array('specific_permission' => 'have_personal_category', 'group_id' => $group_id, 'module_the_name' => '', 'category_name' => '', 'the_page' => 'cms_news', 'the_value' => 1));
             }
         }
     }
     if (post_param_integer('keep_news_categories', 0) == 0) {
         $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) {
                 require_code('news');
                 delete_news_category($news_cat['id']);
             }
         }
     }
 }
Ejemplo n.º 7
0
 function setUp()
 {
     parent::setUp();
     require_code('ecommerce');
     require_code('catalogues');
     require_code('catalogues2');
     require_code('shopping');
     require_lang('catalogues');
     require_lang('shopping');
     require_lang('ecommerce');
     if (!is_null($GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_name', array('c_name' => 'storetesting' . strval(get_member()))))) {
         actual_delete_catalogue('storetesting' . strval(get_member()));
     }
     $this->access_mapping = array(db_get_first_id() => 4);
     // Creating cms catalogues object
     require_code('cms/pages/modules/cms_catalogues.php');
     $this->cms_cat = new Module_cms_catalogues();
     //Creating Shopping cart object
     require_code('site/pages/modules/shopping.php');
     $this->shopping_cart = new Module_shopping();
     $username = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
     $this->category_id = actual_add_catalogue('storetesting' . strval(get_member()), insert_lang(do_lang('DEFAULT_CATALOGUE_PRODUCTS_TITLE'), 2), '', 0, 1, '', 0, 1);
     $fields = array(array('ECOM_CAT_product_title', 'DESCRIPTION_TITLE', 'short_trans', 1, 1, 1, 1), array('ECOM_CAT_item_code', 'ECOM_CATD_item_code', 'random', 0, 1, 1, 1), array('ECOM_CAT_price_pre_tax', 'ECOM_CATD_price_pre_tax', 'float', 0, 1, 1, 1), array('ECOM_CAT_stock_level', 'ECOM_CATD_stock_level', 'integer', 0, 0, 1, 0), array('ECOM_CAT_stock_level_warn_at', 'ECOM_CATD_stock_level_warn_at', 'integer', 0, 0, 0, 0), array('ECOM_CAT_stock_level_maintain', 'ECOM_CATD_stock_level_maintain', 'tick', 0, 1, 0, 0), array('ECOM_CAT_tax_type', 'ECOM_CATD_tax_type', 'list', 0, 1, 0, 0, "0%|5%|17.5%", 0), array('ECOM_CAT_image', 'ECOM_CATD_image', 'picture', 0, 0, 1, 1), array('ECOM_CAT_weight', 'ECOM_CATD_weight', 'float', 0, 1, 0, 0), array('ECOM_CAT_description', 'DESCRIPTION_DESCRIPTION', 'long_trans', 0, 1, 1, 1));
     foreach ($fields as $i => $field) {
         actual_add_catalogue_field('storetesting' . strval(get_member()), lang_code_to_default_content($field[0], false, 3), lang_code_to_default_content($field[1], true, 3), $field[2] == 'tick' ? 'list' : $field[2], $i, $field[3], $field[5], $field[6], $field[2] == 'tick' ? do_lang('NO') . '|' . do_lang('YES') : (array_key_exists(7, $field) ? $field[7] : ''), $field[4], array_key_exists(5, $field) ? $field[5] : 0, array_key_exists(5, $field) ? $field[5] : 0);
     }
     $catalogue_name = 'storetesting' . strval(get_member());
     //Set Sample post values
     $fields = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('*'), array('c_name' => $catalogue_name));
     foreach ($fields as $key => $val) {
         $type = $val['cf_type'];
         $id = $val['id'];
         switch ($type) {
             case 'integer':
                 $_POST['field_' . strval($id)] = 4;
                 break;
             case 'short_trans':
                 $_POST['field_' . strval($id)] = 'Test field value';
                 break;
             case 'long_trans':
                 $_POST['field_' . strval($id)] = 'Test field value';
                 break;
             case 'float':
                 $_POST['field_' . strval($id)] = 68.34999999999999;
                 break;
             case 'list':
                 if ($val['cf_order'] = 6) {
                     //Order 6 is tax
                     $_POST['field_' . strval($id)] = 'Arizona=7.8%';
                 } elseif ($val['cf_order'] = 5) {
                     //Order 5 yes keep stock "yes/no"
                     $_POST['field_' . strval($id)] = 'yes';
                 }
                 break;
         }
     }
     $map = $this->cms_cat->get_set_field_map($catalogue_name);
     $this->product_id = actual_add_catalogue_entry($this->category_id, $validated = 0, $notes = 'test note', $allow_rating = 1, $allow_comments = 1, $allow_trackbacks = 1, $map);
 }
Ejemplo n.º 8
0
 /**
  * Standard modular listing function for OcCLE FS hooks.
  *
  * @param  array	The current meta-directory path
  * @param  string  The root node of the current meta-directory
  * @param  array	The current directory listing
  * @param  array	A reference to the OcCLE filesystem object
  * @return ~array  The final directory listing (false: failure)
  */
 function listing($meta_dir, $meta_root_node, $current_dir, &$occle_fs)
 {
     if (get_forum_type() != 'ocf') {
         return false;
     }
     $listing = array();
     if (count($meta_dir) < 1) {
         //We're listing the users
         $cnt = $GLOBALS['SITE_DB']->query_value('f_members', 'COUNT(*)');
         if ($cnt > 1000) {
             return false;
         }
         // Too much to process
         $users = $GLOBALS['SITE_DB']->query_select('f_members', array('m_username'));
         foreach ($users as $user) {
             $listing[$user['m_username']] = array();
         }
     } elseif (count($meta_dir) == 1) {
         //We're listing the profile fields and custom profile fields of the specified member
         $username = $meta_dir[0];
         $member_data = $GLOBALS['SITE_DB']->query_select('f_members', array('*'), array('m_username' => $username), '', 1);
         if (!array_key_exists(0, $member_data)) {
             return false;
         }
         $member_data = $member_data[0];
         $listing = array('theme', 'avatar', 'validated', 'timezone_offset', 'primary_group', 'signature', 'banned', 'preview_posts', 'dob_day', 'dob_month', 'dob_year', 'reveal_age', 'e-mail', 'title', 'photo', 'photo_thumb', 'view_signatures', 'auto_monitor_contrib_content', 'language', 'allow_e-mails', 'notes', 'wide', 'max_attach_size');
         $listing['groups'] = array();
         //Custom profile fields
         $member_custom_fields = $GLOBALS['SITE_DB']->query_select('f_member_custom_fields', array('*'), array('mf_member_id' => $member_data['id']));
         if (!array_key_exists(0, $member_custom_fields)) {
             return false;
         }
         $member_custom_fields = $member_custom_fields[0];
         $i = db_get_first_id();
         while (array_key_exists('field_' . strval($i), $member_custom_fields)) {
             if ($member_custom_fields['field_' . strval($i)] != '') {
                 $listing[] = get_translated_text($GLOBALS['SITE_DB']->query_value('f_custom_fields', 'cf_name', array('id' => $i)));
             }
             $i++;
         }
     } elseif (count($meta_dir) == 2) {
         if ($meta_dir[1] != 'groups') {
             return false;
         }
         //List the member's usergroups
         $groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($GLOBALS['FORUM_DRIVER']->get_member_from_username($meta_dir[0]));
         $group_names = $GLOBALS['FORUM_DRIVER']->get_usergroup_list();
         foreach ($groups as $group) {
             if (array_key_exists($group, $group_names)) {
                 $listing[] = $group_names[$group];
             }
         }
     } else {
         return false;
     }
     // Directory doesn't exist
     return $listing;
 }
Ejemplo n.º 9
0
 /**
  * Standard modular run function for award hooks. Renders a content box for an award/randomisation.
  *
  * @param  array		The database row for the content
  * @param  ID_TEXT	The zone to display in
  * @return tempcode	Results
  */
 function run($row, $zone)
 {
     unset($zone);
     $view_map = array('page' => 'forumview');
     if ($row['id'] != db_get_first_id()) {
         $view_map['id'] = $row['id'];
     }
     $url = build_url($view_map, get_module_zone('forumview'));
     return put_in_standard_box(do_template('SIMPLE_PREVIEW_BOX', array('SUMMARY' => get_translated_tempcode($row['f_description'], $GLOBALS['FORUM_DB']), 'URL' => $url)), $row['f_name']);
 }
Ejemplo n.º 10
0
 /**
  * Standard function to create the standardised category tree
  *
  * @param  ID_TEXT		Notification code
  * @param  ?ID_TEXT		The ID of where we're looking under (NULL: N/A)
  * @return array 			Tree structure
  */
 function create_category_tree($notification_code, $id)
 {
     $pagelinks = array();
     $types = $GLOBALS['SITE_DB']->query_select('calendar_types', array('id', 't_title'));
     foreach ($types as $type) {
         if (has_category_access(get_member(), 'calendar', strval($type['id'])) && $type['id'] != db_get_first_id()) {
             $pagelinks[] = array('id' => $type['id'], 'title' => get_translated_text($type['t_title']));
         }
     }
     global $M_SORT_KEY;
     $M_SORT_KEY = 'title';
     usort($pagelinks, 'multi_sort');
     return $pagelinks;
 }
Ejemplo n.º 11
0
/**
 * Get a list of maps containing all the topics, and path information, under the specified forum - and those beneath it, recursively.
 *
 * @param  ?AUTO_LINK	The forum being at the root of our recursion (NULL: true root forum)
 * @param  ?string		The tree up to this point in the recursion (NULL: blank, as we are starting the recursion)
 * @param  ?ID_TEXT		The forum name of the $forum_id we are currently going through (NULL: look it up). This is here for efficiency reasons, as finding children IDs to recurse to also reveals the childs title
 * @param  ?integer		The number of recursive levels to search (NULL: all)
 * @return array			A list of maps for all forums. Each map entry containins the fields 'id' (forum ID) and 'tree' (tree path to the forum, including the forums own title), and more.
 */
function ocf_get_topic_tree($forum_id = NULL, $tree = NULL, $title = NULL, $levels = NULL)
{
    if (is_null($forum_id)) {
        $forum_id = db_get_first_id();
    }
    if (is_null($tree)) {
        $tree = '';
    }
    if (!has_category_access(get_member(), 'forums', strval($forum_id))) {
        return array();
    }
    // Put our title onto our tree
    if (is_null($title)) {
        $title = $GLOBALS['FORUM_DB']->query_value('f_forums', 'f_name', array('id' => $forum_id));
    }
    $tree .= $title;
    // We'll be putting all children in this entire tree into a single list
    $children = array();
    $children[0] = array();
    $children[0]['id'] = $forum_id;
    $children[0]['title'] = $title;
    $children[0]['tree'] = $tree;
    // Children of this category
    $rows = $GLOBALS['FORUM_DB']->query_select('f_forums', array('id', 'f_name'), array('f_parent_forum' => $forum_id), 'ORDER BY f_category_id,f_position', 200);
    if (count($rows) == 200) {
        $rows = array();
    }
    // Too many, this method will suck
    $tmap = array('t_forum_id' => $forum_id);
    if (!has_specific_permission(get_member(), 'see_unvalidated')) {
        $tmap['t_validated'] = 1;
    }
    $children[0]['entries'] = collapse_2d_complexity('id', 't_cache_first_title', $GLOBALS['FORUM_DB']->query_select('f_topics', array('id', 't_cache_first_title'), $tmap, 'ORDER BY t_cache_first_time DESC', 12));
    $children[0]['child_entry_count'] = count($children[0]['entries']);
    if ($levels === 0) {
        $children[0]['entries'] = array();
    }
    $children[0]['child_count'] = count($rows);
    $tree .= ' > ';
    if ($levels !== 0) {
        foreach ($rows as $child) {
            $child_id = $child['id'];
            $child_title = $child['f_name'];
            $child_tree = $tree;
            $child_children = ocf_get_topic_tree($child_id, $child_tree, $child_title, is_null($levels) ? NULL : max(0, $levels - 1));
            $children = array_merge($children, $child_children);
        }
    }
    return $children;
}
Ejemplo n.º 12
0
 function setUp()
 {
     parent::setUp();
     require_code('ocf_polls_action');
     require_code('ocf_polls_action2');
     require_code('ocf_topics_action');
     require_code('ocf_topics_action2');
     require_code('ocf_topics');
     require_code('ocf_forums');
     $this->establish_admin_session();
     $this->topic_id = ocf_make_topic(db_get_first_id(), 'Test');
     $this->poll_id = ocf_make_poll($this->topic_id, $question = 'Who are you ?', $is_private = 0, $is_open = 0, $minimum_selections = 2, $maximum_selections = 4, $requires_reply = 0, $answers = array('a', 'b', 'c'), $check_permissions = true);
     // Test the forum was actually created
     $this->assertTrue('Who are you ?' == $GLOBALS['FORUM_DB']->query_value('f_polls', 'po_question ', array('id' => $this->poll_id)));
 }
Ejemplo n.º 13
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     add_config_option('_MESSAGING_FORUM_NAME', 'messaging_forum_name', 'forum', 'return do_lang(\'MESSAGING_FORUM_NAME\',\'\',\'\',\'\',get_site_default_lang());', 'FEATURE', 'CONTACT_US_MESSAGING');
     if (get_forum_type() == 'ocf' && !running_script('upgrader')) {
         $moderator_groups = $GLOBALS['FORUM_DRIVER']->get_moderator_groups();
         $staff_access = array();
         foreach ($moderator_groups as $id) {
             $staff_access[$id] = 5;
         }
         ocf_require_all_forum_stuff();
         require_code('ocf_forums_action');
         require_code('ocf_forums_action2');
         $GLOBALS['OCF_DRIVER'] = $GLOBALS['FORUM_DRIVER'];
         ocf_make_forum(do_lang('MESSAGING_FORUM_NAME'), '', db_get_first_id() + 1, $staff_access, db_get_first_id());
     }
 }
Ejemplo n.º 14
0
 function setUp()
 {
     parent::setUp();
     require_code('ocf_topics');
     require_code('ocf_posts');
     require_code('ocf_forums');
     require_code('ocf_posts_action');
     require_code('ocf_posts_action2');
     require_code('ocf_posts_action3');
     require_code('ocf_topics_action');
     require_code('ocf_topics_action2');
     $this->establish_admin_session();
     $this->topic_id = ocf_make_topic(db_get_first_id(), 'Test');
     $this->post_id = ocf_make_post($this->topic_id, $title = 'welcome', $post = 'welcome to the posts', $skip_sig = 0, $is_starter = false, $validated = NULL, $is_emphasised = 0, $poster_name_if_guest = NULL, $ip_address = NULL, $time = NULL, $poster = NULL, $intended_solely_for = NULL, $last_edit_time = NULL, $last_edit_by = NULL, $check_permissions = true, $update_cacheing = true, $forum_id = NULL, $support_attachments = true, $topic_title = '', $sunk = 0, $id = NULL, $anonymous = false, $skip_post_checks = false, $is_pt = false);
     // Test the forum was actually created
     $this->assertTrue('welcome' == $GLOBALS['FORUM_DB']->query_value('f_posts', 'p_title ', array('id' => $this->post_id)));
 }
Ejemplo n.º 15
0
 /**
  * Standard modular run function for setting features from the setup wizard.
  */
 function set_fields()
 {
     if (get_forum_type() != 'ocf') {
         return;
     }
     $dbs_back = $GLOBALS['NO_DB_SCOPE_CHECK'];
     $GLOBALS['NO_DB_SCOPE_CHECK'] = true;
     require_lang('ocf');
     if (post_param_integer('have_default_rank_set', 0) == 0) {
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('f_groups', 'id', array('id' => db_get_first_id() + 8));
         if (!is_null($test)) {
             $promotion_target = ocf_get_group_property(db_get_first_id() + 8, 'promotion_target');
             if (!is_null($promotion_target)) {
                 $GLOBALS['SITE_DB']->query_update('f_groups', array('g_promotion_target' => NULL, 'g_promotion_threshold' => NULL, 'g_rank_image' => ''), array('id' => db_get_first_id() + 8), '', 1);
                 for ($i = db_get_first_id() + 4; $i < db_get_first_id() + 8; $i++) {
                     require_code('ocf_groups_action');
                     require_code('ocf_groups_action2');
                     ocf_delete_group($i);
                 }
             }
             $_name = ocf_get_group_property(db_get_first_id() + 8, 'name');
             if (is_integer($_name)) {
                 lang_remap($_name, do_lang('MEMBER'));
             }
         }
     }
     if (post_param_integer('have_default_full_emoticon_set', 0) == 0) {
         $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'f_emoticons WHERE e_code<>\':P\' AND e_code<>\';)\' AND e_code<>\':)\' AND e_code<>\':)\' AND e_code<>\':\\\'(\'');
     }
     if (post_param_integer('have_default_cpf_set', 0) == 0) {
         $fields = array('im_aim', 'im_msn', 'im_yahoo', 'im_skype', 'interests', 'location', 'occupation');
         foreach ($fields 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)) {
                 require_code('ocf_members_action');
                 require_code('ocf_members_action2');
                 ocf_delete_custom_field($test);
             }
         }
     }
     $GLOBALS['NO_DB_SCOPE_CHECK'] = $dbs_back;
 }
Ejemplo n.º 16
0
 function setUp()
 {
     parent::setUp();
     $this->establish_admin_session();
     require_code('feedback');
     require_code('files2');
     require_code('autosave');
     require_code('permissions2');
     $this->access_mapping = array(db_get_first_id() => 4);
     // Creating cms catalogues object
     if (file_exists(get_file_base() . '/cms/pages/modules_custom/cms_galleries.php')) {
         require_code('cms/pages/modules_custom/cms_galleries.php');
     } else {
         require_code('cms/pages/modules/cms_galleries.php');
     }
     $this->cms_gal = new Module_cms_galleries();
     $this->cms_gal->run_start('misc');
     $this->cms_gal_alt = new Module_cms_galleries_alt();
     $this->cms_gal_category = new Module_cms_galleries_cat();
 }
Ejemplo n.º 17
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_code('downloads');
     require_css('downloads');
     require_lang('downloads');
     $category_id = array_key_exists('param', $map) ? intval($map['param']) : db_get_first_id();
     $title = array_key_exists('title', $map) ? $map['title'] : do_lang('SECTION_DOWNLOADS');
     $order = array_key_exists('order', $map) ? $map['order'] : NULL;
     $cat_order = array_key_exists('cat_order', $map) ? $map['cat_order'] : NULL;
     if (!is_null($order) && strpos($order, ' ') === false) {
         $order .= ' ASC';
     }
     if (!is_null($cat_order) && strpos($cat_order, ' ') === false) {
         $cat_order .= ' ASC';
     }
     if (!is_null($order)) {
         if ($order != 't.text_original ASC' && $order != 't.text_original DESC' && $order != 't.text_original ASC' && $order != 't.text_original DESC' && $order != 'file_size ASC' && $order != 'file_size DESC' && $order != 'num_downloads DESC' && $order != 'add_date ASC' && $order != 'add_date DESC') {
             $order = NULL;
         }
     }
     if (!is_null($cat_order)) {
         if ($cat_order != 't.text_original ASC' && $cat_order != 't.text_original DESC' && $cat_order != 'add_date ASC' && $order != 'add_date DESC') {
             $cat_order = NULL;
         }
     }
     $subcategories = get_download_sub_categories($category_id, NULL, NULL, $cat_order);
     $downloads = get_category_downloads($category_id, $category_id, $order);
     if ($subcategories->is_empty() && $downloads->is_empty()) {
         if (has_actual_page_access(NULL, 'cms_downloads', NULL, NULL) && has_submit_permission('mid', get_member(), get_ip_address(), 'cms_downloads')) {
             $submit_url = build_url(array('page' => 'cms_downloads', 'type' => 'ad', 'cat' => $category_id, 'redirect' => SELF_REDIRECT), get_module_zone('cms_downloads'));
         } else {
             $submit_url = new ocp_tempcode();
         }
         return do_template('BLOCK_NO_ENTRIES', array('_GUID' => '1e7be43cf5074821854d64458202b09d', 'HIGH' => false, 'TITLE' => $title, 'MESSAGE' => do_lang_tempcode('NO_ENTRIES'), 'ADD_NAME' => do_lang_tempcode('ADD_DOWNLOAD'), 'SUBMIT_URL' => $submit_url));
     }
     $submit_url = new ocp_tempcode();
     if (has_actual_page_access(NULL, 'cms_downloads', NULL, NULL) && has_submit_permission('high', get_member(), get_ip_address(), 'cms_downloads')) {
         $submit_url = build_url(array('page' => 'cms_downloads', 'type' => 'ad', 'cat' => $category_id, 'redirect' => SELF_REDIRECT), get_module_zone('cms_downloads'));
     }
     return do_template('BLOCK_MAIN_DOWNLOAD_CATEGORY', array('_GUID' => '518c63ef968e3b452d3b5cfa2e9505ec', 'SUBMIT_URL' => $submit_url, 'SUBCATEGORIES' => $subcategories, 'DOWNLOADS' => $downloads, 'TITLE' => $title));
 }
Ejemplo n.º 18
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     if (!is_null($upgrade_from) && $upgrade_from < 3) {
         delete_specific_permission('choose_dotw');
         delete_config_option('dotw_update_time');
         $GLOBALS['SITE_DB']->rename_table('dotw', 'award_archive');
         $GLOBALS['SITE_DB']->add_table_field('award_archive', 'a_type_id', 'AUTO_LINK', db_get_first_id());
         $GLOBALS['SITE_DB']->alter_table_field('award_archive', 'id', 'ID_TEXT', 'content_id');
         $GLOBALS['SITE_DB']->add_table_field('award_archive', 'member_id', 'USER', $GLOBALS['FORUM_DRIVER']->get_guest_id());
         $GLOBALS['SITE_DB']->change_primary_key('award_archive', array('a_type_id', 'date_and_time'));
     }
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('award_archive', array('a_type_id' => '*AUTO_LINK', 'date_and_time' => '*TIME', 'content_id' => 'ID_TEXT', 'member_id' => 'USER'));
     }
     $GLOBALS['SITE_DB']->create_index('award_archive', 'awardquicksearch', array('content_id'));
     if (!is_null($upgrade_from) && $upgrade_from < 3 || is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('award_types', array('id' => '*AUTO', 'a_title' => 'SHORT_TRANS', 'a_description' => 'LONG_TRANS', 'a_points' => 'INTEGER', 'a_content_type' => 'ID_TEXT', 'a_hide_awardee' => 'BINARY', 'a_update_time_hours' => 'INTEGER'));
         require_lang('awards');
         $GLOBALS['SITE_DB']->query_insert('award_types', array('a_title' => lang_code_to_default_content('DOTW'), 'a_description' => lang_code_to_default_content('DESCRIPTION_DOTW'), 'a_points' => 0, 'a_content_type' => 'download', 'a_hide_awardee' => 1, 'a_update_time_hours' => 168));
     }
 }
Ejemplo n.º 19
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_lang('newsletter');
     require_lang('javascript');
     $newsletter_id = array_key_exists('param', $map) ? intval($map['param']) : db_get_first_id();
     $_newsletter_title = $GLOBALS['SITE_DB']->query_value_null_ok('newsletters', 'title', array('id' => $newsletter_id));
     if (is_null($_newsletter_title)) {
         return paragraph(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $newsletter_title = get_translated_text($_newsletter_title);
     $address = post_param('address' . strval($newsletter_id), '');
     if ($address != '') {
         require_code('newsletter');
         require_code('type_validation');
         if (!is_valid_email_address($address)) {
             $msg = do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('INVALID_EMAIL_ADDRESS')));
             return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP', array('URL' => get_self_url(), 'MSG' => $msg));
         }
         if (!array_key_exists('path', $map)) {
             $map['path'] = 'uploads/website_specific/signup.txt';
         }
         require_code('character_sets');
         $password = basic_newsletter_join($address, 4, NULL, !file_exists(get_custom_file_base() . '/' . $map['path']), $newsletter_id, post_param('firstname' . strval($newsletter_id), ''), post_param('lastname' . strval($newsletter_id), ''));
         if ($password == '') {
             return do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('NEWSLETTER_THIS_ALSO')));
         }
         if ($password == do_lang('NA')) {
             $manage_url = build_url(array('page' => 'newsletter', 'email' => $address), get_module_zone('newsletter'));
             return do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('ALREADY_EMAIL_ADDRESS', escape_html($manage_url->evaluate()))));
         }
         require_code('mail');
         if (file_exists(get_custom_file_base() . '/' . $map['path'])) {
             $url = (url_is_local($map['path']) ? get_custom_base_url() . '/' : '') . $map['path'];
             mail_wrap(array_key_exists('subject', $map) ? $map['subject'] : do_lang('WELCOME'), convert_to_internal_encoding(http_download_file($url)), array($address), array_key_exists('to', $map) ? $map['to'] : '', '', '', 3, NULL, false, NULL, true);
         }
         return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP_DONE', array('_GUID' => '9953c83685df4970de8f23fcd5dd15bb', 'NEWSLETTER_TITLE' => $newsletter_title, 'NID' => strval($newsletter_id), 'PASSWORD' => $password));
     } else {
         return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP', array('NEWSLETTER_TITLE' => $newsletter_title, 'NID' => strval($newsletter_id), 'URL' => get_self_url()));
     }
 }
Ejemplo n.º 20
0
/**
 * Add to the newsletter, in the simplest way.
 *
 * @param  EMAIL				The email address of the subscriber
 * @param  integer			The interest level
 * @range  1 4
 * @param  ?LANGUAGE_NAME	The language (NULL: users)
 * @param  boolean			Whether to require a confirmation mail
 * @param  ?AUTO_LINK		The newsletter to join (NULL: the first)
 * @param  string				Subscribers forename
 * @param  string				Subscribers surname
 * @return string				Newsletter password
 */
function basic_newsletter_join($email, $interest_level = 4, $lang = NULL, $get_confirm_mail = false, $newsletter_id = NULL, $forename = '', $surname = '')
{
    if (is_null($lang)) {
        $lang = user_lang();
    }
    if (is_null($newsletter_id)) {
        $newsletter_id = db_get_first_id();
    }
    $password = get_rand_password();
    $code_confirm = $get_confirm_mail ? mt_rand(1, 9999999) : 0;
    $test = $GLOBALS['SITE_DB']->query_value_null_ok('newsletter_subscribe', 'the_level', array('newsletter_id' => $newsletter_id, 'email' => $email));
    if ($test === 0) {
        $GLOBALS['SITE_DB']->query_delete('newsletter_subscribe', array('newsletter_id' => $newsletter_id, 'email' => $email), '', 1);
        $test = NULL;
    }
    if (is_null($test)) {
        require_lang('newsletter');
        $test = $GLOBALS['SITE_DB']->query_value_null_ok('newsletter', 'email', array('email' => $email));
        if (is_null($test)) {
            $salt = produce_salt();
            $GLOBALS['SITE_DB']->query_insert('newsletter', array('n_forename' => $forename, 'n_surname' => $surname, 'join_time' => time(), 'email' => $email, 'code_confirm' => $code_confirm, 'pass_salt' => $salt, 'the_password' => md5($password . $salt), 'language' => $lang), false, true);
            // race condition
            if ($get_confirm_mail) {
                $_url = build_url(array('page' => 'newsletter', 'type' => 'confirm', 'email' => $email, 'confirm' => $code_confirm), get_module_zone('newsletter'));
                $url = $_url->evaluate();
                $message = do_lang('NEWSLETTER_SIGNUP_TEXT', comcode_escape($url), comcode_escape($password), array($forename, $surname, $email, get_site_name()), $lang);
                require_code('mail');
                mail_wrap(do_lang('NEWSLETTER_SIGNUP', NULL, NULL, NULL, $lang), $message, array($email));
            }
        } else {
            $GLOBALS['SITE_DB']->query_update('newsletter', array('join_time' => time()), array('email' => $email), '', 1);
            $password = '';
        }
        $GLOBALS['SITE_DB']->query_insert('newsletter_subscribe', array('newsletter_id' => $newsletter_id, 'the_level' => $interest_level, 'email' => $email), false, true);
        // race condition
        return $password;
    }
    return do_lang('NA');
}
Ejemplo n.º 21
0
 /**
  * Standard modular render function for profile tab 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 triple: The tab title, the tab contents, the suggested tab order
  */
 function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false)
 {
     $title = do_lang_tempcode('PERSONAL_TOPICS_INBOX');
     $order = 80;
     if ($leave_to_ajax_if_possible) {
         return array($title, NULL, $order);
     }
     require_code('ocf_forumview');
     require_code('ocf_topics');
     require_code('ocf_general');
     require_lang('ocf');
     $id = NULL;
     $current_filter_cat = get_param('category', '');
     $root = get_param_integer('keep_forum_root', db_get_first_id());
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'start';
     $max = get_param_integer('max', 10);
     $start = get_param_integer('start', get_param_integer('kfs', 0));
     $root = db_get_first_id();
     list($content, , , ) = ocf_render_forumview($id, $current_filter_cat, $max, $start, $root, $member_id_of);
     return array($title, $content, $order);
 }
Ejemplo n.º 22
0
/**
 * Invite a member to a PT.
 *
 * @param  MEMBER			Member getting access
 * @param  AUTO_LINK		The topic
 */
function ocf_invite_to_pt($member_id, $topic_id)
{
    $topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('*'), array('id' => $topic_id), '', 1);
    if (!array_key_exists(0, $topic_info)) {
        warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
    }
    if ($topic_info[0]['t_pt_from'] != get_member() && $topic_info[0]['t_pt_to'] != get_member() && !has_specific_permission(get_member(), 'view_other_pt')) {
        warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
    }
    if ($topic_info[0]['t_pt_from'] == $member_id || $topic_info[0]['t_pt_to'] == $member_id) {
        warn_exit(do_lang_tempcode('NO_INVITE_SENSE'));
    }
    $test = $GLOBALS['FORUM_DB']->query_value_null_ok('f_special_pt_access', 's_member_id', array('s_member_id' => $member_id, 's_topic_id' => $topic_id));
    if (!is_null($test)) {
        warn_exit(do_lang_tempcode('NO_INVITE_SENSE_ALREADY'));
    }
    $GLOBALS['FORUM_DB']->query_insert('f_special_pt_access', array('s_member_id' => $member_id, 's_topic_id' => $topic_id));
    $current_username = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
    $_topic_url = build_url(array('page' => 'topicview', 'type' => 'view', 'id' => $topic_id), get_module_zone('topicview'), NULL, false, false, true);
    $topic_url = $_topic_url->evaluate();
    $topic_title = $topic_info[0]['t_cache_first_title'];
    require_code('ocf_posts_action');
    $post = do_lang('INVITED_TO_PT', $GLOBALS['FORUM_DRIVER']->get_username($member_id), $current_username);
    ocf_make_post($topic_id, '', $post, 0, false, 1, 1, do_lang('SYSTEM'), NULL, NULL, db_get_first_id(), NULL, NULL, NULL, false);
    require_code('notifications');
    $subject = do_lang('INVITED_TO_TOPIC_SUBJECT', get_site_name(), $topic_title, get_lang($member_id));
    $mail = do_lang('INVITED_TO_TOPIC_BODY', get_site_name(), comcode_escape($topic_title), array(comcode_escape($current_username), $topic_url), get_lang($member_id));
    dispatch_notification('ocf_topic_invite', NULL, $subject, $mail, array($member_id));
}
Ejemplo n.º 23
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_calendar($db, $table_prefix, $file_base)
 {
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'calendar');
     foreach ($rows as $row) {
         if (import_check_if_imported('event', strval($row['event_id']))) {
             continue;
         }
         $submitter = import_id_remap_get('member', strval($row['user_id']), true);
         if (is_null($submitter)) {
             $submitter = $GLOBALS['OCF_DRIVER']->get_guest_id();
         }
         $recurrence = 'none';
         $recurrences = NULL;
         if ($row['event_recurrence'] == 1) {
             $bits = explode('|', $row['event_recurrence_settings']);
             // $num_units, $every, $days_of_week (e.g. 1,2,5 (sunday is 0)), $which_week, $recurrence_ends
             if ($bits[3] == 'd' || $bits[3] == 'l') {
                 $bits[3] = '1';
             }
             $recurrence_part = str_repeat('0', intval($bits[3]) - 1) . '1';
             switch ($bits[1]) {
                 case 'd':
                     $recurrence = 'daily';
                     if ($bits[4] != '') {
                         $recurrences = (strtotime($bits[4]) - strtotime($row['event_start'])) / (60 * 60 * 24 * $bits[0] * (is_numeric($bits[3]) ? intval($bits[3]) : 1));
                     }
                     break;
                 case 'w':
                     if ($bits[2] == '') {
                         $recurrence = 'weekly';
                     } else {
                         $days = explode(',', $bits[2]);
                         $string = '0000000';
                         foreach ($days as $day) {
                             $string[$day] = '1';
                         }
                         $recurrence = 'weekly';
                         $recurrence_part = str_repeat('0000000', intval($bits[3]) - 1) . $string;
                     }
                     if ($bits[4] != '') {
                         $recurrences = (strtotime($bits[4]) - strtotime($row['event_start'])) / (60 * 60 * 24 * 7 * $bits[0] * (is_numeric($bits[3]) ? intval($bits[3]) : 1));
                     }
                     break;
                 case 'm':
                     $recurrence = 'monthly';
                     if ($bits[4] != '') {
                         $recurrences = (strtotime($bits[4]) - strtotime($row['event_start'])) / (60 * 60 * 24 * 32 * $bits[0] * (is_numeric($bits[3]) ? intval($bits[3]) : 1));
                     }
                     break;
                 case 'y':
                     $recurrence = 'yearly';
                     if ($bits[4] != '') {
                         $recurrences = (strtotime($bits[4]) - strtotime($row['event_start'])) / (60 * 60 * 24 * 365 * $bits[0] * (is_numeric($bits[3]) ? intval($bits[3]) : 1));
                     }
                     break;
             }
             $string = str_pad('', strlen($recurrence_part) * intval($bits[0]));
             for ($i = 0; $i < strlen($string); $i++) {
                 $string[$i] = $recurrence_part[$i / intval($bits[0])];
             }
             $recurrence .= ' ' . $string;
         }
         list($start_year, $start_month, $start_day, $start_hour, $start_minute) = explode('-', date('Y-m-d-h-i', strtotime($row['event_start'])));
         list($end_year, $end_month, $end_day, $end_hour, $end_minute) = explode('-', date('Y-m-d-h-i', strtotime($row['event_end'])));
         $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, intval(floor($recurrences)), 0, $row['event_title'], $row['event_note'], 3, $row['event_public'], $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, NULL, 1, $submitter, 0, strtotime($row['event_start']));
         import_id_remap_put('event', strval($row['event_id']), $id_new);
     }
 }
Ejemplo n.º 24
0
 /**
  * The actualiser to apply to join a usergroup.
  *
  * @return tempcode		The UI
  */
 function apply()
 {
     $id = post_param_integer('id', NULL);
     if (is_null($id)) {
         $_id = get_param('id');
         if (is_numeric($_id)) {
             $id = intval($_id);
         } else {
             $id = $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' => $_id));
             if (is_null($id)) {
                 warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
             }
         }
         if ($id == db_get_first_id()) {
             warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
         }
         $_leader = ocf_get_group_property($id, 'group_leader');
         $free_access = ocf_get_group_property($id, 'open_membership') == 1;
         $name = ocf_get_group_name($id);
         $title = get_page_title('_APPLY_TO_GROUP', true, array(escape_html($name)));
         $post_url = build_url(array('page' => '_SELF', 'type' => get_param('type')), '_SELF', NULL, true);
         $hidden = form_input_hidden('id', strval($id));
         if ($free_access) {
             $text = do_lang_tempcode('ABOUT_TO_APPLY_FREE_ACCESS', escape_html($name));
         } else {
             if (is_null($_leader) || is_null($GLOBALS['FORUM_DRIVER']->get_username($_leader))) {
                 $text = do_lang_tempcode('ABOUT_TO_APPLY_STAFF', escape_html($name), escape_html(get_site_name()));
             } else {
                 $leader_username = $GLOBALS['FORUM_DRIVER']->get_username($_leader);
                 if (is_null($leader_username)) {
                     $leader_username = do_lang('UNKNOWN');
                 }
                 $leader_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($_leader, false, true);
                 $text = do_lang_tempcode('ABOUT_TO_APPLY_LEADER', escape_html($name), escape_html($leader_username), escape_html($leader_url));
             }
         }
         return do_template('YESNO_SCREEN', array('_GUID' => 'ceafde00ade4492c65ed2e6e2309a0e7', 'TITLE' => $title, 'TEXT' => $text, 'URL' => $post_url, 'HIDDEN' => $hidden));
     }
     if ($id == db_get_first_id()) {
         warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
     }
     $_name = $GLOBALS['FORUM_DB']->query_value('f_groups', 'g_name', array('id' => $id));
     $name = get_translated_text($_name, $GLOBALS['FORUM_DB']);
     $title = get_page_title('_APPLY_TO_GROUP', true, array(escape_html($name)));
     $free_access = ocf_get_group_property($id, 'open_membership') == 1;
     if (is_guest()) {
         access_denied('I_ERROR');
     }
     require_code('ocf_groups');
     if (ocf_get_group_property($id, 'open_membership') == 1) {
         return $this->add_to(true, $GLOBALS['FORUM_DRIVER']->get_username(get_member()));
     }
     ocf_member_ask_join_group($id, get_member());
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('USERGROUPS')), array('_SELF:_SELF:view:id=' . strval($id), do_lang_tempcode('USERGROUP', escape_html($name)))));
     $url = build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $id), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('AWAITING_GROUP_LEADER'));
 }
Ejemplo n.º 25
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_calendar($db, $table_prefix, $file_base)
 {
     require_code('calendar2');
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'event');
     foreach ($rows as $row) {
         if (import_check_if_imported('event', strval($row['eventid']))) {
             continue;
         }
         $submitter = import_id_remap_get('member', strval($row['userid']), true);
         if (is_null($submitter)) {
             $submitter = $GLOBALS['OCF_DRIVER']->get_guest_id();
         }
         $recurrence = 'none';
         $recurrences = NULL;
         $bits = explode('|', $row['recuroption']);
         switch ($row['recurring']) {
             case 1:
                 $recurrence = 'daily ' . str_repeat('0', intval($bits[0]) - 1) . '1';
                 break;
             case 2:
                 $recurrence = 'daily 1111100';
                 break;
             case 3:
                 $recurrence = 'daily 0000000';
                 if (($bits[1] & 1) != 0) {
                     $recurrence[6] = '1';
                 }
                 if (($bits[1] & 2) != 0) {
                     $recurrence[7] = '1';
                 }
                 if (($bits[1] & 4) != 0) {
                     $recurrence[8] = '1';
                 }
                 if (($bits[1] & 8) != 0) {
                     $recurrence[9] = '1';
                 }
                 if (($bits[1] & 16) != 0) {
                     $recurrence[10] = '1';
                 }
                 if (($bits[1] & 32) != 0) {
                     $recurrence[11] = '1';
                 }
                 if (($bits[1] & 64) != 0) {
                     $recurrence[12] = '1';
                 }
                 $recurrences = $bits[0];
                 // Guess
                 break;
             case 4:
                 $recurrence = 'monthly ' . str_repeat('0', intval($bits[1]) - 1) . '1';
                 break;
             case 5:
                 $recurrence = 'monthly ' . str_repeat('0', intval($bits[0]) - 1) . '1';
                 break;
             case 6:
                 $recurrence = 'yearly ' . str_repeat('0', intval($bits[0]) - 1) . '1';
                 break;
             case 7:
                 $recurrence = 'yearly ' . str_repeat('0', intval($bits[0]) - 1) . '1';
                 break;
         }
         list($start_year, $start_month, $start_day, $start_hour, $start_minute) = explode('-', date('Y-m-d-h-i', strtotime($row['dateline'])));
         list($end_year, $end_month, $end_day, $end_hour, $end_minute) = array(NULL, NULL, NULL, NULL, NULL);
         ocf_over_msn();
         $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, $recurrences, 0, $row['title'], $row['event'], 3, $row['visible'], $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, NULL, 1, $submitter, 0, $row['dateline']);
         ocf_over_local();
         import_id_remap_put('event', strval($row['eventid']), $id_new);
     }
 }
 /**
  * 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);
 }
Ejemplo n.º 27
0
/**
 * Certain symbols need preprocessing, before the output stream is made.
 *
 * @param  array			Symbol details
 * @param  array			Where we store children stuff
 */
function handle_symbol_preprocessing($bit, &$children)
{
    switch ($bit[2]) {
        case 'PAGE_LINK':
            if (!array_key_exists(3, $bit) || is_null($bit[3])) {
                return;
            }
            $param = $bit[3];
            if (array_key_exists(0, $param)) {
                if (is_object($param[0])) {
                    $param[0] = $param[0]->evaluate();
                }
                list(, $url_parts, ) = page_link_decode(str_replace(chr(10), '', $param[0]));
                if (!array_key_exists('id', $url_parts)) {
                    return;
                }
                if (!array_key_exists('type', $url_parts)) {
                    $url_parts['type'] = 'misc';
                }
                if (is_null($url_parts['type'])) {
                    $url_parts['type'] = 'misc';
                }
                // NULL means "do not take from environment"; so we default it to 'misc' (even though it might actually be left out when SEO URLs are off, we know it cannot be for SEO URLs)
                if (!array_key_exists('page', $url_parts)) {
                    return;
                }
                if (!is_string($url_parts['id'])) {
                    if (is_null($url_parts['id'])) {
                        $url_parts['id'] = strval(db_get_first_id());
                    }
                }
                // Does this URL arrangement support monikers?
                global $CONTENT_OBS, $LOADED_MONIKERS;
                load_moniker_hooks();
                $found = false;
                $looking_for = '_SEARCH:' . $url_parts['page'] . ':' . $url_parts['type'] . ':_WILD';
                $ob_info = isset($CONTENT_OBS[$looking_for]) ? $CONTENT_OBS[$looking_for] : NULL;
                if (!is_null($ob_info)) {
                    if (!isset($LOADED_MONIKERS[$url_parts['page']][$url_parts['type']][$url_parts['id']])) {
                        $LOADED_MONIKERS[$url_parts['page']][$url_parts['type']][$url_parts['id']] = true;
                    }
                    // Indicator to preload this
                }
            }
            return;
        case 'SET':
            if (!array_key_exists(3, $bit) || is_null($bit[3])) {
                return;
            }
            $param = $bit[3];
            if (array_key_exists(1, $param)) {
                global $TEMPCODE_SETGET;
                $param_copy = array();
                foreach ($param as $i => $x) {
                    if ($i != 0) {
                        $param_copy[] = is_object($x) ? $x->evaluate() : $x;
                    }
                }
                $TEMPCODE_SETGET[is_object($param[0]) ? $param[0]->evaluate() : $param[0]] = implode(',', $param_copy);
            }
            return;
        case 'BLOCK':
            if (!array_key_exists(3, $bit) || is_null($bit[3])) {
                return;
            }
            $param = $bit[3];
            foreach ($param as $i => $p) {
                if (is_object($p)) {
                    $param[$i] = $p->evaluate();
                }
            }
            if (count($param) == 1 && strpos($param[0], ',') !== false) {
                $param = preg_split('#((?<![^\\\\])|(?<!\\\\\\\\)|(?<!^)),#', $param[0]);
            }
            //if (strpos(serialize($param),'side_stored_menu')!==false) { @debug_print_backtrace();exit(); } // Useful for debugging
            global $REQUEST_BLOCK_NEST_LEVEL;
            global $LOADED_BLOCKS;
            if (array_key_exists(serialize($param), $LOADED_BLOCKS)) {
                $REQUEST_BLOCK_NEST_LEVEL--;
                return;
            }
            $REQUEST_BLOCK_NEST_LEVEL++;
            if ($REQUEST_BLOCK_NEST_LEVEL > 20) {
                $REQUEST_BLOCK_NEST_LEVEL = 0;
                $LOADED_BLOCKS[serialize($param)] = do_lang_tempcode('INTERNAL_ERROR');
                attach_message(do_lang_tempcode('STOPPED_RECURSIVE_RESOURCE_INCLUDE', is_string($param[0]) ? $param[0] : 'block'), 'warn');
                return;
            }
            $block_parms = array();
            foreach ($param as $_param) {
                $block_parts = explode('=', $_param, 2);
                if (count($block_parts) != 2) {
                    $LOADED_BLOCKS[serialize($param)] = new ocp_tempcode();
                    continue 2;
                }
                list($key, $val) = $block_parts;
                $block_parms[$key] = $val;
            }
            $b_value = do_block($block_parms['block'], $block_parms);
            if ($GLOBALS['RECORD_TEMPLATES_TREE']) {
                $children[] = array(':block: ' . $block_parms['block'], array(array($b_value->codename, $b_value->children, $b_value->fresh)), true);
            }
            $b_value->handle_symbol_preprocessing();
            $LOADED_BLOCKS[serialize($param)] = $b_value;
            $REQUEST_BLOCK_NEST_LEVEL--;
            return;
        case 'JAVASCRIPT_INCLUDE':
            if (!array_key_exists(3, $bit) || is_null($bit[3])) {
                return;
            }
            $param = $bit[3];
            foreach ($param as $i => $p) {
                if (is_object($p)) {
                    $param[$i] = $p->evaluate();
                }
            }
            require_javascript($param[0]);
            return;
        case 'FACILITATE_AJAX_BLOCK_CALL':
            require_javascript('javascript_ajax');
            return;
        case 'CSS_INCLUDE':
            if (!array_key_exists(3, $bit) || is_null($bit[3])) {
                return;
            }
            $param = $bit[3];
            foreach ($param as $i => $p) {
                if (is_object($p)) {
                    $param[$i] = $p->evaluate();
                }
            }
            require_css($param[0]);
            return;
        case 'LOAD_PANEL':
            if (!array_key_exists(3, $bit) || is_null($bit[3])) {
                return;
            }
            $param = $bit[3];
            foreach ($param as $i => $p) {
                if (is_object($p)) {
                    $param[$i] = $p->evaluate();
                }
            }
            global $LOADED_PANELS;
            if (array_key_exists(serialize($param), $LOADED_PANELS)) {
                return;
            }
            if (array_key_exists(0, $param)) {
                if (substr(get_page_name(), 0, 6) != 'panel_') {
                    if (strpos($param[0], ':') !== false) {
                        $param = array_reverse(explode(':', $param[0], 2));
                    }
                    if (substr($param[0], 0, 6) == 'panel_') {
                        $param[0] = substr($param[0], 6);
                    }
                    global $ZONE;
                    $wide_high = is_wide_high();
                    $wide = is_wide();
                    if (($wide == 0 || $wide_high == 0 && ($param[0] == 'bottom' || $param[0] == 'top')) && (get_option('site_closed') == '0' || $GLOBALS['IS_ACTUALLY_ADMIN'] || has_specific_permission(get_member(), 'access_closed_site'))) {
                        $tp_value = request_page('panel_' . $param[0], false, array_key_exists(1, $param) ? $param[1] : NULL, NULL);
                        $sub_children = array();
                        $tp_value->handle_symbol_preprocessing();
                        if ($GLOBALS['RECORD_TEMPLATES_TREE']) {
                            $children[] = array(':panel: ' . $param[0], $sub_children, isset($tp_value->fresh) ? $tp_value->fresh : false);
                        }
                        $value = $tp_value->evaluate();
                    } else {
                        $value = '';
                    }
                } else {
                    $value = '';
                }
            } else {
                $value = '';
            }
            $LOADED_PANELS[serialize($param)] = $value;
            return;
        case 'JS_TEMPCODE':
            if ($GLOBALS['RECORD_TEMPLATES_TREE']) {
                if (!array_key_exists(3, $bit) || is_null($bit[3])) {
                    return;
                }
                $param = $bit[3];
                foreach ($param as $i => $p) {
                    if (is_object($p)) {
                        $param[$i] = $p->evaluate();
                    }
                }
                $temp = javascript_tempcode(array_key_exists(0, $param) ? $param[0] : NULL);
                $children[] = array(':container', $temp->children, $temp->fresh);
            }
            return;
        case 'CSS_TEMPCODE':
            if ($GLOBALS['RECORD_TEMPLATES_TREE']) {
                if (!array_key_exists(3, $bit) || is_null($bit[3])) {
                    return;
                }
                $temp = css_tempcode();
                $children[] = array(':container', $temp->children, $temp->fresh);
            }
            return;
        case 'LOAD_PAGE':
            if (!array_key_exists(3, $bit) || is_null($bit[3])) {
                return;
            }
            $param = $bit[3];
            foreach ($param as $i => $p) {
                if (is_object($p)) {
                    $param[$i] = $p->evaluate();
                }
            }
            global $LOADED_PAGES;
            if (array_key_exists(serialize($param), $LOADED_PAGES)) {
                return;
            }
            if (array_key_exists(0, $param)) {
                if (strpos($param[0], ':') !== false) {
                    $param = array_reverse(explode(':', $param[0], 2));
                }
                $being_included = !array_key_exists(2, $param) || $param[2] == '1';
                $tp_value = request_page($param[0], false, array_key_exists(1, $param) ? $param[1] : NULL, NULL, $being_included);
                if ($GLOBALS['RECORD_TEMPLATES_TREE']) {
                    $children[] = array(':page: ' . $param[0], $tp_value->children, $tp_value->fresh);
                }
            } else {
                $tp_value = new ocp_tempcode();
            }
            $LOADED_PAGES[serialize($param)] = $tp_value;
            return;
        case 'FRACTIONAL_EDITABLE':
            require_javascript('javascript_fractional_edit');
            return;
    }
}
Ejemplo n.º 28
0
 /**
  * Gets the default value for the config option.
  *
  * @return ?string		The default value (NULL: option is disabled)
  */
 function get_default()
 {
     return has_no_forum() ? NULL : strval(db_get_first_id());
 }
Ejemplo n.º 29
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)
 {
     $order = 0;
     // Actualiser
     if (post_param('submitting_settings_tab', NULL) !== NULL) {
         require_code('ocf_members_action2');
         $is_ldap = ocf_is_ldap_member($member_id_of);
         $is_httpauth = ocf_is_httpauth_member($member_id_of);
         $is_remote = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_password_compat_scheme') == 'remote';
         if ($is_ldap || $is_httpauth || $is_remote || $member_id_of != $member_id_viewing && !has_specific_permission($member_id_viewing, 'assume_any_member')) {
             $password = NULL;
         } else {
             $password = post_param('edit_password');
             if ($password == '') {
                 $password = NULL;
             } else {
                 $password_confirm = trim(post_param('password_confirm'));
                 if ($password != $password_confirm) {
                     warn_exit(make_string_tempcode(escape_html(do_lang('PASSWORD_MISMATCH'))));
                 }
             }
         }
         $custom_fields = ocf_get_all_custom_fields_match($GLOBALS['FORUM_DRIVER']->get_members_groups($member_id_of), $member_id_of != $member_id_viewing && !has_specific_permission($member_id_viewing, 'view_any_profile_field') ? 1 : NULL, $member_id_of != $member_id_viewing ? NULL : 1, $member_id_of != $member_id_viewing ? NULL : 1);
         $actual_custom_fields = ocf_read_in_custom_fields($custom_fields, $member_id_of);
         $pt_allow = array_key_exists('pt_allow', $_POST) ? implode(',', $_POST['pt_allow']) : '';
         $tmp_groups = $GLOBALS['OCF_DRIVER']->get_usergroup_list(true, true);
         $all_pt_allow = '';
         foreach (array_keys($tmp_groups) as $key) {
             if ($key != db_get_first_id()) {
                 if ($all_pt_allow != '') {
                     $all_pt_allow .= ',';
                 }
                 $all_pt_allow .= strval($key);
             }
         }
         if ($pt_allow == $all_pt_allow) {
             $pt_allow = '*';
         }
         $pt_rules_text = post_param('pt_rules_text', NULL);
         if (has_specific_permission($member_id_viewing, 'member_maintenance')) {
             $validated = post_param_integer('validated', 0);
             $primary_group = $is_ldap || !has_specific_permission($member_id_viewing, 'assume_any_member') ? NULL : post_param_integer('primary_group', NULL);
             $is_perm_banned = post_param_integer('is_perm_banned', 0);
             $old_is_perm_banned = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_is_perm_banned');
             if ($old_is_perm_banned != $is_perm_banned) {
                 if ($is_perm_banned == 1) {
                     ocf_ban_member($member_id_of);
                 } else {
                     ocf_unban_member($member_id_of);
                 }
             }
             $highlighted_name = post_param_integer('highlighted_name', 0);
             if (has_specific_permission($member_id_viewing, 'probate_members')) {
                 $on_probation_until = get_input_date('on_probation_until');
                 $current__on_probation_until = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_on_probation_until');
                 if ((is_null($on_probation_until) || $on_probation_until <= time()) && $current__on_probation_until > time()) {
                     log_it('STOP_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of));
                 } elseif (!is_null($on_probation_until) && $on_probation_until > time() && $current__on_probation_until <= time()) {
                     log_it('START_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of));
                 } elseif (!is_null($on_probation_until) && $current__on_probation_until > $on_probation_until && $on_probation_until > time() && $current__on_probation_until > time()) {
                     log_it('REDUCE_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of));
                 } elseif (!is_null($on_probation_until) && $current__on_probation_until < $on_probation_until && $on_probation_until > time() && $current__on_probation_until > time()) {
                     log_it('EXTEND_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of));
                 }
             } else {
                 $on_probation_until = NULL;
             }
         } else {
             $validated = NULL;
             $primary_group = NULL;
             $highlighted_name = NULL;
             $on_probation_until = NULL;
         }
         if (has_actual_page_access($member_id_viewing, 'admin_ocf_join') || has_specific_permission($member_id_of, 'rename_self')) {
             $username = $is_ldap || $is_remote ? NULL : post_param('edit_username', NULL);
         } else {
             $username = NULL;
         }
         $email = post_param('email_address', NULL);
         if (!is_null($email)) {
             $email = trim($email);
         }
         $theme = post_param('theme', NULL);
         if ($is_remote) {
             $preview_posts = NULL;
             $zone_wide = NULL;
             $auto_monitor_contrib_content = NULL;
             $views_signatures = NULL;
             $timezone = NULL;
         } else {
             $preview_posts = post_param_integer('preview_posts', 0);
             $zone_wide = post_param_integer('zone_wide', 0);
             $auto_monitor_contrib_content = NULL;
             //post_param_integer('auto_monitor_contrib_content',0);	Moved to notifications tab
             $views_signatures = post_param_integer('views_signatures', 0);
             $timezone = post_param('timezone', get_site_timezone());
         }
         ocf_edit_member($member_id_of, $email, $preview_posts, post_param_integer('dob_day', -1), post_param_integer('dob_month', -1), post_param_integer('dob_year', -1), $timezone, $primary_group, $actual_custom_fields, $theme, post_param_integer('reveal_age', 0), $views_signatures, $auto_monitor_contrib_content, post_param('language', NULL), post_param_integer('allow_emails', 0), post_param_integer('allow_emails_from_staff', 0), $validated, $username, $password, $zone_wide, $highlighted_name, $pt_allow, $pt_rules_text, $on_probation_until);
         if (!array_key_exists('secondary_groups', $_POST)) {
             $_POST['secondary_groups'] = array();
         }
         require_code('ocf_groups_action2');
         $members_groups = $GLOBALS['OCF_DRIVER']->get_members_groups($member_id_of);
         $group_count = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)');
         $groups = list_to_map('id', $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), $group_count > 200 ? array('g_is_private_club' => 0) : NULL));
         foreach ($_POST['secondary_groups'] as $group_id) {
             $group = $groups[intval($group_id)];
             if ($group['g_hidden'] == 1 && !in_array($group['id'], $members_groups) && !has_specific_permission($member_id_viewing, 'see_hidden_groups')) {
                 continue;
             }
             if (!in_array($group['id'], $members_groups) && (has_specific_permission($member_id_viewing, 'assume_any_member') || $group['g_open_membership'] == 1)) {
                 ocf_add_member_to_group($member_id_of, $group['id']);
             }
         }
         foreach ($members_groups as $group_id) {
             if (!in_array(strval($group_id), $_POST['secondary_groups'])) {
                 ocf_member_leave_group($group_id, $member_id_of);
             }
         }
         $GLOBALS['FORUM_DB']->query('DELETE FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_member_known_login_ips WHERE i_member_id=' . strval($member_id_of) . ' AND ' . db_string_not_equal_to('i_val_code', ''));
         // So any re-confirms can happen
         if (addon_installed('awards')) {
             require_code('awards');
             handle_award_setting('member', strval($member_id_of));
         }
         attach_message(do_lang_tempcode('SUCCESS_SAVE'), 'inform');
     }
     if ($leave_to_ajax_if_possible) {
         return NULL;
     }
     // UI
     $title = do_lang_tempcode('SETTINGS');
     $myrow = $GLOBALS['FORUM_DRIVER']->get_member_row($member_id_of);
     if (is_null($myrow)) {
         warn_exit(do_lang_tempcode('USER_NO_EXIST'));
     }
     require_code('ocf_members_action2');
     list($fields, $hidden) = ocf_get_member_fields_settings(false, $member_id_of, NULL, $myrow['m_email_address'], $myrow['m_preview_posts'], $myrow['m_dob_day'], $myrow['m_dob_month'], $myrow['m_dob_year'], get_users_timezone($member_id_of), $myrow['m_theme'], $myrow['m_reveal_age'], $myrow['m_views_signatures'], $myrow['m_auto_monitor_contrib_content'], $myrow['m_language'], $myrow['m_allow_emails'], $myrow['m_allow_emails_from_staff'], $myrow['m_validated'], $myrow['m_primary_group'], $myrow['m_username'], $myrow['m_is_perm_banned'], '', $myrow['m_zone_wide'], $myrow['m_highlighted_name'], $myrow['m_pt_allow'], get_translated_text($myrow['m_pt_rules_text'], $GLOBALS['FORUM_DB']), $myrow['m_on_probation_until']);
     // Awards?
     if (addon_installed('awards')) {
         require_code('awards');
         $fields->attach(get_award_fields('member', strval($member_id_of)));
     }
     $redirect = get_param('redirect', NULL);
     if (!is_null($redirect)) {
         $hidden->attach(form_input_hidden('redirect', $redirect));
     }
     $hidden->attach(form_input_hidden('submitting_settings_tab', '1'));
     $javascript = "\n\t\t\tvar form=document.getElementById('email_address').form;\n\t\t\tform.prior_profile_edit_submit=form.onsubmit;\n\t\t\tform.onsubmit=function()\n\t\t\t\t{\n\t\t\t\t\tif (typeof form.elements['edit_password']!='undefined')\n\t\t\t\t\t{\n\t\t\t\t\t\tif ((form.elements['password_confirm']) && (form.elements['password_confirm'].value!=form.elements['edit_password'].value))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('PASSWORD_MISMATCH')) . "');\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof form.prior_profile_edit_submit!='undefined' && form.prior_profile_edit_submit) return form.prior_profile_edit_submit();\n\t\t\t\t\treturn true;\n\t\t\t\t};\n\t\t";
     $text = '';
     return array($title, $fields, $text, $javascript, $order, $hidden);
 }
Ejemplo n.º 30
0
/**
 * Delete a forum.
 *
 * @param  AUTO_LINK		The ID of the forum we are deleting.
 * @param  AUTO_LINK		The ID of the forum that topics will be moved to.
 * @param  BINARY			Whether to delete topics instead of moving them to the target forum.
 */
function ocf_delete_forum($forum_id, $target_forum_id, $delete_topics = 0)
{
    if ($forum_id == db_get_first_id()) {
        warn_exit(do_lang_tempcode('CANNOT_DELETE_ROOT_FORUM'));
    }
    require_code('ocf_topics_action');
    require_code('ocf_topics_action2');
    if ($delete_topics == 0) {
        ocf_move_topics($forum_id, $target_forum_id);
    } else {
        $rows = $GLOBALS['FORUM_DB']->query_select('f_topics', array('id'), array('t_forum_id' => $forum_id));
        foreach ($rows as $row) {
            ocf_delete_topic($row['id'], '');
        }
    }
    $forum_info = $GLOBALS['FORUM_DB']->query_select('f_forums', array('*'), array('id' => $forum_id), '', 1);
    if (!array_key_exists(0, $forum_info)) {
        warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
    }
    delete_lang($forum_info[0]['f_description'], $GLOBALS['FORUM_DB']);
    delete_lang($forum_info[0]['f_intro_question'], $GLOBALS['FORUM_DB']);
    $name = $GLOBALS['FORUM_DB']->query_value('f_forums', 'f_name', array('id' => $forum_id));
    $GLOBALS['FORUM_DB']->query_update('f_multi_moderations', array('mm_move_to' => NULL), array('mm_move_to' => $forum_id));
    $GLOBALS['FORUM_DB']->query_update('f_forums', array('f_parent_forum' => db_get_first_id()), array('f_parent_forum' => $forum_id));
    $GLOBALS['FORUM_DB']->query_delete('f_forums', array('id' => $forum_id), '', 1);
    $GLOBALS['FORUM_DB']->query_delete('group_category_access', array('module_the_name' => 'forums', 'category_name' => strval($forum_id)));
    $GLOBALS['FORUM_DB']->query_delete('gsp', array('module_the_name' => 'forums', 'category_name' => strval($forum_id)));
    require_code('notifications');
    delete_all_notifications_on('ocf_topic', 'forum:' . strval($forum_id));
    $GLOBALS['FORUM_DB']->query_delete('f_forum_intro_member', array('i_forum_id' => $forum_id));
    $GLOBALS['FORUM_DB']->query_delete('f_forum_intro_ip', array('i_forum_id' => $forum_id));
    log_it('DELETE_FORUM', strval($forum_id), $name);
}