Beispiel #1
0
 /**
  * Standard modular run function.
  *
  * @return array		An array of tuples: The task row to show, the number of seconds until it is due (or NULL if not on a timer), the number of things to sort out (or NULL if not on a queue), The name of the config option that controls the schedule (or NULL if no option).
  */
 function run()
 {
     if (!addon_installed('backup')) {
         return array();
     }
     if (get_option('backup_time', true) == '') {
         return array();
     }
     $limit_hours = intval(get_option('backup_time', true));
     require_lang('backups');
     $date = intval(get_value('last_backup'));
     $seconds_ago = mixed();
     if ($date != 0) {
         $seconds_ago = time() - $date;
         $status = intval($seconds_ago) > $limit_hours * 60 * 60 ? 0 : 1;
     } else {
         $status = 0;
     }
     $_status = $status == 0 ? do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_0') : do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_1');
     $config_row = $GLOBALS['SITE_DB']->query_select('config', array('the_page', 'section'), array('the_name' => 'backup_time'), '', 1);
     if (array_key_exists(0, $config_row)) {
         $_config_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $config_row[0]['the_page']), get_module_zone('admin_config'));
         $config_url = $_config_url->evaluate();
         $config_url .= '#group_' . $config_row[0]['section'];
     } else {
         $config_url = NULL;
     }
     $url = build_url(array('page' => 'admin_backup', 'type' => 'misc'), 'adminzone');
     list($info, $seconds_due_in) = staff_checklist_time_ago_and_due($seconds_ago, $limit_hours);
     $tpl = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM', array('_GUID' => '432685ec6c9f7548ce8b488b6ce00030', 'CONFIG_URL' => $config_url, 'URL' => $url, 'STATUS' => $_status, 'TASK' => do_lang_tempcode('BACKUP'), 'INFO' => $info));
     return array(array($tpl, $seconds_due_in, NULL, 'backup_time'));
 }
Beispiel #2
0
 /**
  * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system.
  *
  * @return array			Array of links and where to show
  */
 function run()
 {
     if (!addon_installed('realtime_rain')) {
         return array();
     }
     return array(array('usage', 'realtime_rain', array('admin_realtime_rain', array('type' => 'misc'), get_module_zone('admin_realtime_rain')), do_lang_tempcode('_REALTIME_RAIN'), do_lang_tempcode('DOC_REALTIME_RAIN')));
 }
Beispiel #3
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);
 }
Beispiel #4
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     require_lang('leader_board');
     require_code('points');
     require_css('points');
     $title = get_page_title('POINT_LEADERBOARD');
     $start_date = intval(get_option('leaderboard_start_date'));
     $weeks = $GLOBALS['SITE_DB']->query('SELECT DISTINCT date_and_time FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'leader_board WHERE date_and_time>=' . strval($start_date) . ' ORDER BY date_and_time DESC');
     if (count($weeks) == 0) {
         warn_exit(do_lang_tempcode('NO_ENTRIES'));
     }
     $first_week = $weeks[count($weeks) - 1]['date_and_time'];
     $weeks = collapse_1d_complexity('date_and_time', $weeks);
     $out = new ocp_tempcode();
     foreach ($weeks as $week) {
         $rows = collapse_2d_complexity('lb_member', 'lb_points', $GLOBALS['SITE_DB']->query_select('leader_board', array('lb_member', 'lb_points'), array('date_and_time' => $week)));
         $week_tpl = new ocp_tempcode();
         foreach ($rows as $member => $points) {
             $points_url = build_url(array('page' => 'points', 'type' => 'member', 'id' => $member), get_module_zone('points'));
             $profile_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member, false, true);
             $name = $GLOBALS['FORUM_DRIVER']->get_username($member);
             if (is_null($name)) {
                 $name = do_lang('UNKNOWN');
             }
             $week_tpl->attach(do_template('POINTS_LEADERBOARD_ROW', array('_GUID' => '6d323b4b5abea0e82a14cb4745c4af4f', 'POINTS_URL' => $points_url, 'PROFILE_URL' => $profile_url, 'POINTS' => integer_format($points), 'NAME' => $name, 'ID' => strval($member))));
         }
         $nice_week = intval(($week - $first_week) / (7 * 24 * 60 * 60) + 1);
         $out->attach(do_template('POINTS_LEADERBOARD_WEEK', array('_GUID' => '3a0f71bf20f9098e5711e85cf25f6549', 'WEEK' => integer_format($nice_week), 'ROWS' => $week_tpl)));
     }
     return do_template('POINTS_LEADERBOARD_SCREEN', array('_GUID' => 'bab5f7b661435b83800532d3eebd0d54', 'TITLE' => $title, 'WEEKS' => $out));
 }
Beispiel #5
0
 /**
  * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system.
  *
  * @return array			Array of links and where to show
  */
 function run()
 {
     if (!addon_installed('bulkupload')) {
         return array();
     }
     return array(array('tools', 'bulkupload', array('admin_bulkupload', array(), get_module_zone('admin_bulkupload')), do_lang_tempcode('BULK_UPLOAD'), 'DOC_BULK_UPLOAD'));
 }
Beispiel #6
0
 /**
  * Standard modular run function for preview hooks.
  *
  * @return array			A pair: The preview, the updated post Comcode
  */
 function run()
 {
     require_code('uploads');
     $urls = get_url('', 'file', 'uploads/iotds', 0, OCP_UPLOAD_IMAGE, true, '', 'file2');
     if ($urls[0] == '') {
         if (!is_null(post_param_integer('id', NULL))) {
             $rows = $GLOBALS['SITE_DB']->query_select('iotds', array('url', 'thumb_url'), array('id' => post_param_integer('id')), '', 1);
             $urls = $rows[0];
             $url = $urls['url'];
             $thumb_url = $urls['thumb_url'];
         } else {
             warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD'));
         }
     } else {
         $url = $urls[0];
         $thumb_url = $urls[1];
     }
     $caption = comcode_to_tempcode(post_param('caption', ''));
     $title = comcode_to_tempcode(post_param('title', ''));
     require_code('images');
     $thumb = do_image_thumb(url_is_local($thumb_url) ? get_custom_base_url() . '/' . $thumb_url : $thumb_url, $caption, true);
     $url = url_is_local($url) ? get_custom_base_url() . '/' . $url : $url;
     $preview = do_template('IOTD', array('ID' => '', 'IMAGE_URL' => $url, 'SUBMITTER' => strval(get_member()), 'VIEW_URL' => $url, 'IMAGE' => $thumb, 'CAPTION' => $title));
     return array($preview, NULL);
 }
Beispiel #7
0
 /**
  * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system.
  *
  * @return array			Array of links and where to show
  */
 function run()
 {
     if (!addon_installed('backup')) {
         return array();
     }
     return array(array('tools', 'backups', array('admin_backup', array('type' => 'misc'), get_module_zone('admin_backup')), do_lang_tempcode('BACKUPS'), 'DOC_BACKUPS'));
 }
Beispiel #8
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (!addon_installed('calendar')) {
         return new ocp_tempcode();
     }
     require_lang('calendar');
     $bits = new ocp_tempcode();
     if (get_option('calendar_show_stats_count_events', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('EVENTS'), 'VALUE' => integer_format($GLOBALS['SITE_DB']->query_value('calendar_events', 'COUNT(*)')))));
     }
     if (get_option('calendar_show_stats_count_events_this_week', true) == '1') {
         require_code('calendar');
         $events = calendar_matches($GLOBALS['FORUM_DRIVER']->get_guest_id(), true, utctime_to_usertime(time()), utctime_to_usertime(time() + 60 * 60 * 24 * 7));
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('EVENTS_THIS_WEEK'), 'VALUE' => integer_format(count($events)))));
     }
     if (get_option('calendar_show_stats_count_events_this_month', true) == '1') {
         require_code('calendar');
         $events = calendar_matches($GLOBALS['FORUM_DRIVER']->get_guest_id(), true, utctime_to_usertime(time()), utctime_to_usertime(time() + 60 * 60 * 24 * 31));
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('EVENTS_THIS_MONTH'), 'VALUE' => integer_format(count($events)))));
     }
     if (get_option('calendar_show_stats_count_events_this_year', true) == '1') {
         require_code('calendar');
         $events = calendar_matches($GLOBALS['FORUM_DRIVER']->get_guest_id(), true, utctime_to_usertime(time()), utctime_to_usertime(time() + 60 * 60 * 24 * 365));
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('EVENTS_THIS_YEAR'), 'VALUE' => integer_format(count($events)))));
     }
     if ($bits->is_empty()) {
         return new ocp_tempcode();
     }
     $section = do_template('BLOCK_SIDE_STATS_SECTION', array('SECTION' => do_lang_tempcode('CALENDAR'), 'CONTENT' => $bits));
     return $section;
 }
Beispiel #9
0
 /**
  * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system.
  *
  * @return array			Array of links and where to show
  */
 function run()
 {
     if (!addon_installed('occle')) {
         return array();
     }
     return array(array('tools', 'occle', array('admin_occle', array('type' => 'misc'), get_module_zone('admin_occle')), do_lang_tempcode('OCCLE')));
 }
Beispiel #10
0
 /**
  * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system.
  *
  * @return array			Array of links and where to show
  */
 function run()
 {
     // TODO: Make workflows register itself in the addon registry
     //if (!addon_installed('workflows')) return array();
     require_lang('workflows');
     return array(array('cms', 'workflows', array('admin_workflow', array('type' => 'misc'), get_module_zone('admin_workflow')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('WORKFLOWS'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value('workflow_requirements', 'COUNT(DISTINCT workflow_name)'))))), 'DOC_WORKFLOWS'));
 }
Beispiel #11
0
 /**
  * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system.
  *
  * @return array			Array of links and where to show
  */
 function run()
 {
     if (!addon_installed('pointstore')) {
         return array();
     }
     return array(array('usage', 'pointstorelog', array('admin_pointstore', array('type' => 'misc'), get_module_zone('admin_pointstore')), do_lang_tempcode('POINTSTORE_MANAGE_SALES'), 'DOC_POINT_STORE'), array('setup', 'pointstore', array('admin_pointstore', array('type' => 'p'), get_module_zone('admin_pointstore')), do_lang_tempcode('POINTSTORE_MANAGE_INVENTORY'), 'DOC_POINT_STORE'));
 }
Beispiel #12
0
 /**
  * Standard modular info function for award hooks. Provides information to allow task reporting, randomisation, and add-screen linking, to function.
  *
  * @return ?array	Map of award content-type info (NULL: disabled).
  */
 function info()
 {
     $info = array();
     $info['connection'] = $GLOBALS['SITE_DB'];
     $info['table'] = 'videos';
     $info['date_field'] = 'add_date';
     $info['id_field'] = 'id';
     $info['add_url'] = has_submit_permission('mid', get_member(), get_ip_address(), 'cms_galleries') ? build_url(array('page' => 'cms_galleries', 'type' => 'av'), get_module_zone('cms_galleries')) : new ocp_tempcode();
     $info['category_field'] = 'cat';
     $info['category_type'] = 'galleries';
     $info['parent_spec__table_name'] = 'galleries';
     $info['parent_spec__parent_name'] = 'parent_id';
     $info['parent_spec__field_name'] = 'name';
     $info['parent_field_name'] = 'cat';
     $info['submitter_field'] = 'submitter';
     $info['id_is_string'] = false;
     require_lang('galleries');
     $info['title'] = do_lang_tempcode('VIDEOS');
     $info['validated_field'] = 'validated';
     $info['category_is_string'] = true;
     $info['archive_url'] = build_url(array('page' => 'galleries'), get_module_zone('galleries'));
     $info['cms_page'] = 'cms_galleries';
     $info['where'] = 'cat NOT LIKE \'' . db_encode_like('download\\_%') . '\'';
     $info['views_field'] = 'video_views';
     $info['supports_custom_fields'] = true;
     return $info;
 }
Beispiel #13
0
 /**
  * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system.
  *
  * @return array			Array of links and where to show
  */
 function run()
 {
     if (get_forum_type() != 'ocf') {
         return array();
     }
     return array(array('setup', 'notifications', array('admin_notifications', array('type' => 'misc'), get_module_zone('admin_notifications')), do_lang_tempcode('NOTIFICATIONS_LOCKDOWN'), 'DOC_NOTIFICATIONS'));
 }
Beispiel #14
0
 /**
  * Standard modular run function.
  *
  * @return array		An array of tuples: The task row to show, the number of seconds until it is due (or NULL if not on a timer), the number of things to sort out (or NULL if not on a queue), The name of the config option that controls the schedule (or NULL if no option).
  */
 function run()
 {
     if (!addon_installed('iotds')) {
         return array();
     }
     if (get_option('iotd_update_time') == '') {
         return array();
     }
     require_lang('iotds');
     $date = $GLOBALS['SITE_DB']->query_value_null_ok('iotd', 'date_and_time', array('is_current' => 1));
     $limit_hours = intval(get_option('iotd_update_time'));
     $seconds_ago = mixed();
     if (!is_null($date)) {
         $seconds_ago = time() - $date;
         $status = $seconds_ago > $limit_hours * 60 * 60 ? 0 : 1;
     } else {
         $status = 0;
     }
     $_status = $status == 0 ? do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_0') : do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_1');
     $config_row = $GLOBALS['SITE_DB']->query_select('config', array('the_page', 'section'), array('the_name' => 'iotd_update_time'), '', 1);
     if (array_key_exists(0, $config_row)) {
         $_config_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $config_row[0]['the_page']), get_module_zone('admin_config'));
         $config_url = $_config_url->evaluate();
         $config_url .= '#group_' . $config_row[0]['section'];
     } else {
         $config_url = NULL;
     }
     $url = build_url(array('page' => 'cms_iotds', 'type' => 'ed'), get_module_zone('cms_iotds'));
     $num_queue = $this->get_num_iotd_queue();
     list($info, $seconds_due_in) = staff_checklist_time_ago_and_due($seconds_ago, $limit_hours);
     $info->attach(do_lang_tempcode('NUM_QUEUE', integer_format($num_queue)));
     $tpl = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM', array('_GUID' => '5c55aed7bedca565c8aa553548b88e64', 'CONFIG_URL' => $config_url, 'URL' => $url, 'STATUS' => $_status, 'TASK' => do_lang_tempcode('PT_choose_iotd'), 'INFO' => $info));
     return array(array($tpl, $seconds_due_in, NULL, 'iotd_update_time'));
 }
 /**
  * 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)));
 }
Beispiel #16
0
 /**
  * Standard modular info function for award hooks. Provides information to allow task reporting, randomisation, and add-screen linking, to function.
  *
  * @return ?array	Map of award content-type info (NULL: disabled).
  */
 function info()
 {
     $info = array();
     $info['connection'] = $GLOBALS['SITE_DB'];
     $info['table'] = 'download_downloads';
     $info['date_field'] = 'add_date';
     $info['id_field'] = 'id';
     $info['add_url'] = has_submit_permission('mid', get_member(), get_ip_address(), 'cms_downloads') ? build_url(array('page' => 'cms_downloads', 'type' => 'ad'), get_module_zone('cms_downloads')) : new ocp_tempcode();
     $info['category_field'] = 'category_id';
     $info['category_type'] = 'downloads';
     $info['parent_spec__table_name'] = 'download_categories';
     $info['parent_spec__parent_name'] = 'parent_id';
     $info['parent_spec__field_name'] = 'id';
     $info['parent_field_name'] = 'id';
     $info['submitter_field'] = 'submitter';
     $info['id_is_string'] = false;
     require_lang('downloads');
     $info['title'] = do_lang_tempcode('SECTION_DOWNLOADS');
     $info['validated_field'] = 'validated';
     $info['category_is_string'] = false;
     $info['archive_url'] = build_url(array('page' => 'downloads'), get_module_zone('downloads'));
     $info['cms_page'] = 'cms_downloads';
     $info['views_field'] = 'download_views';
     $info['supports_custom_fields'] = true;
     return $info;
 }
Beispiel #17
0
 /**
  * Standard modular run function.
  *
  * @param  MEMBER		The ID of the member we are getting detail hooks for
  * @return ?tempcode	Results (NULL: no action)
  */
 function run($member_id)
 {
     global $OCWORLD_MEMBER_CACHE;
     if (!isset($OCWORLD_MEMBER_CACHE)) {
         $OCWORLD_MEMBER_CACHE = array();
     }
     if (array_key_exists($member_id, $OCWORLD_MEMBER_CACHE)) {
         return $OCWORLD_MEMBER_CACHE[$member_id];
     }
     $zone = get_page_zone('ocworld', false);
     if (is_null($zone)) {
         return NULL;
     }
     if (!has_zone_access(get_member(), $zone)) {
         return NULL;
     }
     $rows = $GLOBALS['SITE_DB']->query_select('w_members m LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'w_realms r ON m.location_realm=r.id', array('*'), array('m.id' => $member_id), '', 1, 0, true);
     if (!is_null($rows) && array_key_exists(0, $rows)) {
         $row = $rows[0];
         $room = $GLOBALS['SITE_DB']->query_value_null_ok('w_rooms', 'name', array('location_x' => $row['location_x'], 'location_y' => $row['location_y'], 'location_realm' => $row['location_realm']));
         if (is_null($room)) {
             return NULL;
         }
         require_lang('ocworld');
         $a = do_template('OCF_TOPIC_POST_CUSTOM_FIELD', array('_GUID' => '3d36d5ae8bcb66d59a0676200571fb1a', 'NAME' => do_lang_tempcode('_W_ROOM'), 'VALUE' => do_lang_tempcode('W_ROOM_COORD', escape_html($room), strval($row['location_realm']), array(strval($row['location_x']), strval($row['location_y'])))));
         $b = do_template('OCF_TOPIC_POST_CUSTOM_FIELD', array('_GUID' => '72c62771f7796d69d1f1a616c2591206', 'NAME' => do_lang_tempcode('_W_REALM'), 'VALUE' => $row['name']));
         $a->attach($b);
         $OCWORLD_MEMBER_CACHE[$member_id] = $a;
         return $a;
     }
     return NULL;
 }
Beispiel #18
0
 function auth_set($member_id, $oauth_url)
 {
     require_lang('twitter');
     require_code('twitter');
     $api_key = get_option('twitter_api_key', true);
     $api_secret = get_option('twitter_api_secret', true);
     $twitter = new Twitter($api_key, $api_secret);
     if (get_param_integer('oauth_in_progress', 0) == 0) {
         $response = $twitter->oAuthRequestToken($oauth_url->evaluate());
         $twitter->oAuthAuthorize($response['oauth_token']);
         exit;
     }
     $response = $twitter->oAuthAccessToken(get_param('oauth_token'), get_param('oauth_verifier'));
     if (!isset($response['oauth_token'])) {
         attach_message(do_lang_tempcode('TWITTER_OAUTH_FAIL', escape_html($response['message'])), 'warn');
         return false;
     }
     $save_to = 'twitter_oauth_token';
     if (!is_null($member_id)) {
         $save_to .= '__' . strval($member_id);
     }
     set_long_value($save_to, $response['oauth_token']);
     $save_to = 'twitter_oauth_token_secret';
     if (!is_null($member_id)) {
         $save_to .= '__' . strval($member_id);
     }
     set_long_value($save_to, $response['oauth_token_secret']);
     return true;
 }
Beispiel #19
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (!addon_installed('downloads')) {
         return new ocp_tempcode();
     }
     require_lang('downloads');
     require_code('downloads_stats');
     $bits = new ocp_tempcode();
     if (get_option('downloads_show_stats_count_total', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => 'ff2bd884d88ddc8c5a81cff897f99a5a', 'KEY' => do_lang_tempcode('COUNT_TOTAL'), 'VALUE' => integer_format(get_num_archive_downloads()))));
     }
     if (get_option('downloads_show_stats_count_archive', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => '3d221f2145581a3af51c8948f28b7ac7', 'KEY' => do_lang_tempcode('COUNT_ARCHIVE'), 'VALUE' => get_download_archive_size())));
     }
     if (get_option('downloads_show_stats_count_downloads', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => '47c544ef053f9be47e2c48c3a694da1c', 'KEY' => do_lang_tempcode('COUNT_DOWNLOADS'), 'VALUE' => integer_format(get_num_downloads_downloaded()))));
     }
     if (get_option('downloads_show_stats_count_bandwidth', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => 'b2589ae83652953ece220267043d75c9', 'KEY' => do_lang_tempcode('COUNT_BANDWIDTH'), 'VALUE' => clean_file_size(get_download_bandwidth()))));
     }
     if ($bits->is_empty()) {
         return new ocp_tempcode();
     }
     $files = do_template('BLOCK_SIDE_STATS_SECTION', array('_GUID' => '99ae3f35b3e5eda18901e97ac385d99c', 'SECTION' => do_lang_tempcode('SECTION_DOWNLOADS'), 'CONTENT' => $bits));
     return $files;
 }
Beispiel #20
0
 /**
  * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system.
  *
  * @return array			Array of links and where to show
  */
 function run()
 {
     if (!addon_installed('points')) {
         return array();
     }
     return array(array('usage', 'pointslog', array('admin_points', array('type' => 'misc'), get_module_zone('admin_points')), do_lang_tempcode('GIFT_TRANSACTIONS'), 'DOC_POINTS'));
 }
Beispiel #21
0
 /**
  * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system.
  *
  * @return array			Array of links and where to show
  */
 function run()
 {
     if (!addon_installed('newsletter')) {
         return array();
     }
     return array(array('tools', 'newsletters', array('admin_newsletter', array('type' => 'misc'), get_module_zone('admin_newsletter')), do_lang_tempcode('NEWSLETTER'), 'DOC_NEWSLETTER'));
 }
Beispiel #22
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);
}
 /**
  * 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');
     require_code('ocfiltering');
     $number = array_key_exists('param', $map) ? intval($map['param']) : 10;
     $filter = array_key_exists('filter', $map) ? $map['filter'] : '*';
     $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('downloads');
     $sql_filter = ocfilter_to_sqlfragment($filter, 'p.category_id', 'download_categories', 'parent_id', 'p.category_id', 'id');
     // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set)
     $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'download_downloads p WHERE validated=1 AND (' . $sql_filter . ') ORDER BY add_date DESC', $number);
     $title = do_lang_tempcode('RECENT', make_string_tempcode(integer_format($number)), do_lang_tempcode('SECTION_DOWNLOADS'));
     if (array_key_exists('title', $map) && $map['title'] != '') {
         $title = protect_from_escaping(escape_html($map['title']));
     }
     $out = new ocp_tempcode();
     foreach ($rows as $i => $row) {
         if ($i != 0) {
             $out->attach(do_template('BLOCK_SEPARATOR'));
         }
         $out->attach(get_download_html($row, true, true, $zone));
     }
     if ($out->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', 'redirect' => SELF_REDIRECT), get_module_zone('cms_downloads'));
         } else {
             $submit_url = new ocp_tempcode();
         }
         return do_template('BLOCK_NO_ENTRIES', array('_GUID' => '74399763a51102bdd6e6d92c2c11354f', 'HIGH' => false, 'TITLE' => $title, 'MESSAGE' => do_lang_tempcode('NO_DOWNLOADS_YET'), 'ADD_NAME' => do_lang_tempcode('ADD_DOWNLOAD'), 'SUBMIT_URL' => $submit_url));
     }
     return do_template('BLOCK_MAIN_RECENT_DOWNLOADS', array('_GUID' => '257fa1b83d1b6fe3acbceb2b618e6d7f', 'TITLE' => $title, 'CONTENT' => $out, 'NUMBER' => integer_format($number)));
 }
Beispiel #24
0
 /**
  * Standard modular run function.
  *
  * @return array		An array of tuples: The task row to show, the number of seconds until it is due (or NULL if not on a timer), the number of things to sort out (or NULL if not on a queue), The name of the config option that controls the schedule (or NULL if no option).
  */
 function run()
 {
     if (!addon_installed('tickets')) {
         return array();
     }
     require_lang('tickets');
     require_code('tickets');
     require_code('tickets2');
     $outstanding = 0;
     $tickets = get_tickets(get_member(), NULL, false, true);
     if (!is_null($tickets)) {
         foreach ($tickets as $topic) {
             if ($topic['closed'] == 0) {
                 $outstanding++;
             }
         }
     }
     if ($outstanding > 0) {
         $status = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_0', array('_GUID' => 'g578142633c6f3d37776e82a869deb91'));
     } else {
         $status = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_1', array('_GUID' => 'h578142633c6f3d37776e82a869deb91'));
     }
     $url = build_url(array('page' => 'tickets', 'type' => 'misc'), get_module_zone('tickets'));
     $tpl = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM', array('URL' => $url, 'STATUS' => $status, 'TASK' => do_lang_tempcode('SUPPORT_TICKETS'), 'INFO' => do_lang_tempcode('NUM_QUEUE', escape_html(integer_format($outstanding)))));
     return array(array($tpl, NULL, $outstanding, NULL));
 }
Beispiel #25
0
 /**
  * Standard modular run function.
  *
  * @return array		An array of tuples: The task row to show, the number of seconds until it is due (or NULL if not on a timer), the number of things to sort out (or NULL if not on a queue), The name of the config option that controls the schedule (or NULL if no option).
  */
 function run()
 {
     if (!addon_installed('flagrant')) {
         return array();
     }
     require_lang('flagrant');
     $rows = $GLOBALS['SITE_DB']->query_select('text', array('activation_time', 'days'), array('active_now' => 1), '', NULL, NULL, true);
     if (is_null($rows)) {
         return array();
     }
     $seconds_due_in = mixed();
     if (array_key_exists(0, $rows)) {
         $activation_time = $rows[0]['activation_time'];
         $days = $rows[0]['days'];
         $date = $activation_time + $days * 24 * 60 * 60;
         $seconds_due_in = $date - time();
         $status = $seconds_due_in <= 0 ? 0 : 1;
     } else {
         $status = 1;
     }
     $_status = $status == 0 ? do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_0') : do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_1');
     $url = build_url(array('page' => 'admin_flagrant', 'type' => 'misc'), 'adminzone');
     $num_queue = $this->get_num_flagrant_queue();
     list($info, $seconds_due_in) = staff_checklist_time_ago_and_due($seconds_due_in);
     $info->attach(do_lang_tempcode('NUM_QUEUE', escape_html(integer_format($num_queue))));
     $tpl = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM', array('_GUID' => '820e0e3cd80754dc7dfd9a0d05a43ec0', 'URL' => $url, 'STATUS' => $_status, 'TASK' => do_lang_tempcode('CHOOSE_FLAGRANT'), 'INFO' => $info));
     return array(array($tpl, $seconds_due_in, NULL, NULL));
 }
Beispiel #26
0
 /**
  * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system.
  *
  * @return array			Array of links and where to show
  */
 function run()
 {
     if (!addon_installed('ldap')) {
         return array();
     }
     return array(get_forum_type() != 'ocf' ? NULL : array('security', 'ldap', array('admin_ocf_ldap', array('type' => 'misc'), get_module_zone('admin_ocf_ldap')), do_lang_tempcode('LDAP'), 'DOC_LDAP'));
 }
Beispiel #27
0
 /**
  * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system.
  *
  * @return array			Array of links and where to show
  */
 function run()
 {
     if (!addon_installed('downloads')) {
         return array();
     }
     return array(array('cms', 'downloads', array('cms_downloads', array('type' => 'misc'), get_module_zone('cms_downloads')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('SECTION_DOWNLOADS'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('download_downloads', 'COUNT(*)', NULL, '', true))))), 'DOC_DOWNLOADS'));
 }
Beispiel #28
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;
 }
Beispiel #29
0
 /**
  * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX.
  *
  * @return tempcode  The snippet
  */
 function run()
 {
     if (get_option('is_on_rating') == '0') {
         return do_lang_tempcode('INTERNAL_ERROR');
     }
     // Has there actually been any rating?
     if (strtoupper(ocp_srv('REQUEST_METHOD')) == 'POST' || ocp_srv('HTTP_REFERER') == '') {
         $rating = either_param_integer('rating', NULL);
     } else {
         $rating = post_param_integer('rating');
         // Will fail
     }
     $content_type = get_param('content_type');
     $type = get_param('type', '');
     $content_id = get_param('id');
     $content_url = get_param('content_url', '', true);
     $content_title = get_param('content_title', '', true);
     require_code('feedback');
     actualise_specific_rating($rating, get_page_name(), get_member(), $content_type, $type, $content_id, $content_url, $content_title);
     actualise_give_rating_points();
     $template = get_param('template', NULL);
     if ($template !== '') {
         if (is_null($template)) {
             $template = 'RATING_BOX';
         }
         return display_rating($content_url, $content_title, $content_type, $content_id, $template);
     }
     return do_lang_tempcode('THANKYOU_FOR_RATING_SHORT');
 }
Beispiel #30
0
 /**
  * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system.
  *
  * @return array			Array of links and where to show
  */
 function run()
 {
     if (!addon_installed('galleries')) {
         return array();
     }
     return array(array('cms', 'galleries', array('cms_galleries', array('type' => 'misc'), get_module_zone('cms_galleries')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('GALLERIES'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('images', 'COUNT(*)', NULL, '', true) + $GLOBALS['SITE_DB']->query_value_null_ok('videos', 'COUNT(*)', NULL, '', true))))), 'DOC_GALLERIES'));
 }