Example #1
0
 /**
  * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system.
  *
  * @param  boolean		Whether to look deep into the database (or whatever else might be time-intensive) for links
  * @return array			Array of links and where to show
  */
 function run($exhaustive = false)
 {
     if (!addon_installed('catalogues')) {
         return array();
     }
     $ret = array();
     if (has_specific_permission(get_member(), 'submit_cat_highrange_content', 'cms_catalogues')) {
         $ret[] = array('cms', 'catalogues', array('cms_catalogues', array('type' => 'misc'), get_module_zone('cms_catalogues')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('CATALOGUES'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'COUNT(*)', NULL, '', true))))), 'DOC_CATALOGUES');
     }
     if ($exhaustive) {
         $catalogues = $GLOBALS['SITE_DB']->query_select('catalogues', array('c_name', 'c_title', 'c_description', 'c_ecommerce'), NULL, '', 10, NULL, true);
         if (!is_null($catalogues)) {
             $ret2 = array();
             foreach ($catalogues as $row) {
                 if (substr($row['c_name'], 0, 1) == '_') {
                     continue;
                 }
                 if ($row['c_ecommerce'] == 0 || addon_installed('shopping')) {
                     if (has_submit_permission('mid', get_member(), get_ip_address(), 'cms_catalogues', array('catalogues_catalogue', $row['c_name']))) {
                         $ret2[] = array('cms', 'of_catalogues', array('cms_catalogues', array('type' => 'misc', 'catalogue_name' => $row['c_name']), get_module_zone('cms_catalogues')), do_lang_tempcode('ITEMS_HERE', escape_html(get_translated_text($row['c_title'])), escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('catalogue_entries', 'COUNT(*)', array('c_name' => $row['c_name']), '', true)))), get_translated_text($row['c_description']));
                     }
                 }
             }
             if (count($ret2) < 10) {
                 $ret = array_merge($ret, $ret2);
             }
         }
     }
     return $ret;
 }
Example #2
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);
     require_code('ocf_groups');
     $url = build_url(array('page' => 'groups', 'type' => 'view', 'id' => $row['id']), get_module_zone('groups'));
     return put_in_standard_box(do_template('SIMPLE_PREVIEW_BOX', array('SUMMARY' => get_translated_text($row['g_name'], $GLOBALS['FORUM_DB']), 'URL' => $url)), ocf_get_group_name($row['id']));
 }
Example #3
0
 function testEditNewsletter()
 {
     // Test the forum edits
     edit_newsletter($this->news_id, 'Thanks', 'Thank you');
     // Test the forum was actually created
     $this->assertTrue('Thanks' == get_translated_text($GLOBALS['SITE_DB']->query_value('newsletters', 'title', array('id' => $this->news_id))));
 }
Example #4
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)
 {
     $url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $row['id']), $zone);
     $title = get_translated_tempcode($row['title']);
     $title_plain = get_translated_text($row['title']);
     $news_cat_rows = $GLOBALS['SITE_DB']->query_select('news_categories', array('nc_title', 'nc_img'), array('id' => $row['news_category']), '', 1);
     if (!array_key_exists(0, $news_cat_rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $news_cat_row = $news_cat_rows[0];
     $category = get_translated_text($news_cat_row['nc_title']);
     $img = find_theme_image($news_cat_row['nc_img']);
     if ($row['news_image'] != '') {
         $img = $row['news_image'];
         if (url_is_local($img)) {
             $img = get_base_url() . '/' . $img;
         }
     }
     $news = get_translated_tempcode($row['news']);
     if ($news->is_empty()) {
         $news = get_translated_tempcode($row['news_article']);
         $truncate = true;
     } else {
         $truncate = false;
     }
     $author_url = addon_installed('authors') ? build_url(array('page' => 'authors', 'type' => 'misc', 'id' => $row['author']), get_module_zone('authors')) : new ocp_tempcode();
     $author = $row['author'];
     require_css('news');
     $seo_bits = seo_meta_get_for('news', strval($row['id']));
     $map = array('_GUID' => 'jd89f893jlkj9832gr3uyg2u', 'TAGS' => get_loaded_tags('news', explode(',', $seo_bits[0])), 'TRUNCATE' => $truncate, 'AUTHOR' => $author, 'BLOG' => false, 'AUTHOR_URL' => $author_url, 'CATEGORY' => $category, 'IMG' => $img, 'NEWS' => $news, 'ID' => strval($row['id']), 'SUBMITTER' => strval($row['submitter']), 'DATE' => get_timezoned_date($row['date_and_time']), 'DATE_RAW' => strval($row['date_and_time']), 'FULL_URL' => $url, 'NEWS_TITLE' => $title, 'NEWS_TITLE_PLAIN' => $title_plain);
     if (get_option('is_on_comments') == '1' && !has_no_forum() && $row['allow_comments'] >= 1) {
         $map['COMMENT_COUNT'] = '1';
     }
     return put_in_standard_box(do_template('NEWS_PIECE_SUMMARY', $map));
 }
Example #5
0
 function testEditNews()
 {
     // Test the forum edits
     edit_news($id = $this->news_id, $title = "Politics", $news = "teheyehehj ", $author = "rolly", $validated = 1, $allow_rating = 1, $allow_comments = 1, $allow_trackbacks = 1, $notes = "yedd", $news_article = "test article 22222222", $main_news_category = 5, $news_category = NULL, $meta_keywords = "", $meta_description = "", $image = "");
     // Test the forum was actually created
     $this->assertTrue('Politics' == get_translated_text($GLOBALS['SITE_DB']->query_value('news', 'title ', array('id' => $this->news_id))));
 }
Example #6
0
 function testEditComment()
 {
     // Test the forum edits
     edit_calendar_event($this->event_id, 8, '', NULL, 0, 'test_event1', '', 3, 1, 2010, 1, 10, 10, 15, 2010, 1, 19, 0, 0, get_users_timezone(), 1, '', '', 1, 1, 1, 1, '');
     // Test the forum was actually created
     $this->assertTrue('test_event1' == get_translated_text($GLOBALS['FORUM_DB']->query_value('calendar_events', 'e_title ', array('id' => $this->event_id)), $GLOBALS['FORUM_DB']));
 }
Example #7
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('galleries')) {
         return NULL;
     }
     if (!has_actual_page_access(get_member(), 'galleries')) {
         return NULL;
     }
     $filters_1 = ocfilter_to_sqlfragment($_filters, 'name', 'galleries', 'parent_id', 'name', 'name', false, false);
     // 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)
     $filters = ocfilter_to_sqlfragment($_filters, 'cat', 'galleries', 'parent_id', 'cat', 'name', false, false);
     // 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)
     require_lang('galleries');
     $content = new ocp_tempcode();
     $_galleries = array();
     if ($GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'galleries WHERE ' . $filters_1) < 3000) {
         $_galleries = $GLOBALS['SITE_DB']->query('SELECT fullname,name FROM ' . get_table_prefix() . 'galleries WHERE ' . $filters_1);
         foreach ($_galleries as $i => $_gallery) {
             $_galleries[$i]['text_original'] = get_translated_text($_gallery['fullname']);
         }
     }
     $galleries = collapse_2d_complexity('name', 'text_original', $_galleries);
     $rows1 = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'videos WHERE add_date>' . strval((int) $cutoff) . ' AND ' . $filters . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND validated=1 ' : '') . ' ORDER BY add_date DESC', $max);
     $rows2 = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'images WHERE add_date>' . strval((int) $cutoff) . ' AND ' . $filters . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND validated=1 ' : '') . ' ORDER BY add_date DESC', $max);
     $rows = array_merge($rows1, $rows2);
     foreach ($rows as $row) {
         $id = strval($row['id']);
         $author = $GLOBALS['FORUM_DRIVER']->get_username($row['submitter']);
         if (is_null($author)) {
             $author = '';
         }
         $news_date = date($date_string, $row['add_date']);
         $edit_date = is_null($row['edit_date']) ? '' : date($date_string, $row['edit_date']);
         $news_title = xmlentities(do_lang('THIS_WITH_SIMPLE', array_key_exists('video_views', $row) ? do_lang('VIDEO') : do_lang('IMAGE'), strval($row['id'])));
         $_summary = get_translated_tempcode($row['comments']);
         $summary = xmlentities($_summary->evaluate());
         $news = '';
         if (!array_key_exists($row['cat'], $galleries)) {
             $_fullname = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'fullname', array('name' => $row['cat']));
             if (is_null($_fullname)) {
                 continue;
             }
             $galleries[$row['cat']] = get_translated_text($_fullname);
         }
         $category = $galleries[$row['cat']];
         $category_raw = $row['cat'];
         $view_url = build_url(array('page' => 'galleries', 'type' => array_key_exists('video_views', $row) ? 'video' : 'image', 'id' => $row['id']), get_module_zone('galleries'), NULL, false, false, true);
         if ($prefix == 'RSS_' && get_option('is_on_comments') == '1' && $row['allow_comments'] >= '1') {
             $if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => '65dc0cec8c75f565c58c95fa1667aa1e', 'COMMENT_URL' => $view_url, 'ID' => strval($row['id'])));
         } else {
             $if_comments = new ocp_tempcode();
         }
         require_code('images');
         $enclosure_url = ensure_thumbnail($row['url'], $row['thumb_url'], 'galleries', array_key_exists('video_views', $row) ? 'videos' : 'images', $row['id']);
         list($enclosure_length, $enclosure_type) = get_enclosure_details($row['url'], $enclosure_url);
         $content->attach(do_template($prefix . 'ENTRY', array('ENCLOSURE_URL' => $enclosure_url, 'ENCLOSURE_LENGTH' => $enclosure_length, 'ENCLOSURE_TYPE' => $enclosure_type, '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('galleries');
     return array($content, do_lang('GALLERIES'));
 }
Example #8
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('news')) {
         return NULL;
     }
     if (!has_actual_page_access(get_member(), 'news')) {
         return NULL;
     }
     $filters_1 = ocfilter_to_sqlfragment($_filters, 'p.news_category', 'news_categories', NULL, 'p.news_category', '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)
     $filters_2 = ocfilter_to_sqlfragment($_filters, 'd.news_entry_category', 'news_categories', NULL, 'd.news_category', '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)
     $filters = '(' . $filters_1 . ' OR ' . $filters_2 . ')';
     $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news p LEFT JOIN ' . get_table_prefix() . 'news_category_entries d ON d.news_entry=p.id WHERE date_and_time>' . strval($cutoff) . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND validated=1 ' : '') . ' AND ' . $filters . (can_arbitrary_groupby() ? ' GROUP BY p.id' : '') . ' ORDER BY date_and_time DESC', $max);
     $rows = remove_duplicate_rows($rows, 'id');
     $_categories = $GLOBALS['SITE_DB']->query_select('news_categories', array('id', 'nc_title'), array('nc_owner' => NULL));
     foreach ($_categories as $i => $_category) {
         $_categories[$i]['text_original'] = get_translated_text($_category['nc_title']);
     }
     $categories = collapse_2d_complexity('id', 'text_original', $_categories);
     $content = new ocp_tempcode();
     foreach ($rows as $row) {
         if (has_category_access(get_member(), 'news', strval($row['news_category']))) {
             $id = strval($row['id']);
             $author = $row['author'];
             $news_date = date($date_string, $row['date_and_time']);
             $edit_date = is_null($row['edit_date']) ? '' : date($date_string, $row['edit_date']);
             $_title = get_translated_tempcode($row['title']);
             $news_title = xmlentities($_title->evaluate());
             $_summary = get_translated_tempcode($row['news']);
             if ($_summary->is_empty()) {
                 $_summary = get_translated_tempcode($row['news_article']);
             }
             $summary = xmlentities($_summary->evaluate());
             if (!is_null($row['news_article'])) {
                 $_news = get_translated_tempcode($row['news_article']);
                 if ($_news->is_empty()) {
                     $news = '';
                 } else {
                     $news = xmlentities($_news->evaluate());
                 }
             } else {
                 $news = '';
             }
             if (!array_key_exists($row['news_category'], $categories)) {
                 $categories[$row['news_category']] = get_translated_text($GLOBALS['SITE_DB']->query_value('news_categories', 'nc_title', array('id' => $row['news_category'])));
             }
             $category = $categories[$row['news_category']];
             $category_raw = strval($row['news_category']);
             $view_url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $row['id']), get_module_zone('news'), NULL, false, false, true);
             if ($prefix == 'RSS_' && get_option('is_on_comments') == '1' && $row['allow_comments'] >= 1) {
                 $if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => 'b4f25f5cf68304f8d402bb06851489d6', 'COMMENT_URL' => $view_url, 'ID' => strval($row['id'])));
             } else {
                 $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)));
         }
     }
     return array($content, do_lang('NEWS'));
 }
Example #9
0
 /**
  * Standard modular run function for realtime-rain hooks.
  *
  * @param  TIME			Start of time range.
  * @param  TIME			End of time range.
  * @return array			A list of template parameter sets for rendering a 'drop'.
  */
 function run($from, $to)
 {
     $drops = array();
     if (has_actual_page_access(get_member(), 'chat')) {
         require_code('chat');
         $rows = $GLOBALS['SITE_DB']->query('SELECT ip_address,the_message,user_id AS member_id,date_and_time AS timestamp,room_id FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'chat_messages WHERE system_message=0 AND date_and_time BETWEEN ' . strval($from) . ' AND ' . strval($to));
         foreach ($rows as $row) {
             if (!check_chatroom_access($row['room_id'], true)) {
                 continue;
             }
             $timestamp = $row['timestamp'];
             $member_id = $row['member_id'];
             $message = get_translated_text($row['the_message']);
             if (strpos($message, '[private') !== false) {
                 continue;
             }
             $message = strip_comcode($message);
             if ($message == '') {
                 continue;
             }
             $drops[] = rain_get_special_icons($row['ip_address'], $timestamp, NULL, $message) + array('TYPE' => 'chat', 'FROM_MEMBER_ID' => strval($member_id), 'TO_MEMBER_ID' => NULL, 'TITLE' => rain_truncate_for_title($message), 'IMAGE' => is_guest($member_id) ? rain_get_country_image($row['ip_address']) : $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id), 'TIMESTAMP' => strval($timestamp), 'RELATIVE_TIMESTAMP' => strval($timestamp - $from), 'TICKER_TEXT' => $message, 'URL' => build_url(array('page' => 'points', 'type' => 'member', 'id' => $member_id), '_SEARCH'), 'IS_POSITIVE' => false, 'IS_NEGATIVE' => false, 'FROM_ID' => 'member_' . strval($member_id), 'TO_ID' => NULL, 'GROUP_ID' => 'room_' . strval($row['room_id']));
         }
     }
     return $drops;
 }
Example #10
0
 function testEditModeration()
 {
     // Test the forum edits
     ocf_edit_multi_moderation($this->mod_id, 'Tested', 'Something', NULL, 0, 0, 0, '*', 'Hello');
     // Test the forum was actually created
     $this->assertTrue('Tested' == get_translated_text($GLOBALS['FORUM_DB']->query_value('f_multi_moderations', 'mm_name ', array('id' => $this->mod_id)), $GLOBALS['FORUM_DB']));
 }
Example #11
0
 /**
  * Standard modular run function for newsletter hooks.
  *
  * @param  TIME				The time that the entries found must be newer than
  * @param  LANGUAGE_NAME	The language the entries found must be in
  * @param  string				Category filter to apply
  * @param  BINARY				Whether to use full article instead of summary
  * @return array				Tuple of result details
  */
 function run($cutoff_time, $lang, $filter, $in_full = 1)
 {
     if (!addon_installed('news')) {
         return array();
     }
     require_lang('news');
     $new = new ocp_tempcode();
     require_code('ocfiltering');
     $or_list = ocfilter_to_sqlfragment($filter, 'news_category');
     $or_list_2 = ocfilter_to_sqlfragment($filter, 'news_entry_category');
     $rows = $GLOBALS['SITE_DB']->query('SELECT title,news,news_article,id,date_and_time,submitter FROM ' . get_table_prefix() . 'news LEFT JOIN ' . get_table_prefix() . 'news_category_entries ON news_entry=id WHERE validated=1 AND date_and_time>' . strval((int) $cutoff_time) . ' AND ((' . $or_list . ') OR (' . $or_list_2 . ')) ORDER BY date_and_time DESC', 300);
     if (count($rows) == 300) {
         return array();
     }
     $rows = remove_duplicate_rows($rows, 'id');
     foreach ($rows as $row) {
         $_url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $row['id']), get_module_zone('news'), NULL, false, false, true);
         $url = $_url->evaluate();
         $name = get_translated_text($row['title'], NULL, $lang);
         $description = get_translated_text($row[$in_full == 1 ? 'news_article' : 'news'], NULL, $lang);
         if ($description == '') {
             $description = get_translated_text($row[$in_full == 1 ? 'news' : 'news_article'], NULL, $lang);
         }
         $member_id = is_guest($row['submitter']) ? NULL : strval($row['submitter']);
         $new->attach(do_template('NEWSLETTER_NEW_RESOURCE_FCOMCODE', array('_GUID' => '4eaf5ec00db1f0b89cef5120c2486521', 'MEMBER_ID' => $member_id, 'URL' => $url, 'NAME' => $name, 'DESCRIPTION' => $description)));
     }
     return array($new, do_lang('NEWS', '', '', '', $lang));
 }
Example #12
0
 function testEditQuiz()
 {
     // Test the forum edits
     edit_quiz($this->quiz_id, 'Quiz2', 10, 'Go', 'Stop', '', 'Nothing', 50, time(), NULL, 3, 0, 'TEST', 1, 'Questions', 'Nothing', '', 0, NULL);
     // Test the forum was actually created
     $this->assertTrue('Quiz2' == get_translated_text($GLOBALS['FORUM_DB']->query_value('quizzes', 'q_name', array('id' => $this->quiz_id))));
 }
Example #13
0
 /**
  * Standard modular run function for realtime-rain hooks.
  *
  * @param  TIME			Start of time range.
  * @param  TIME			End of time range.
  * @return array			A list of template parameter sets for rendering a 'drop'.
  */
 function run($from, $to)
 {
     $drops = array();
     if (has_actual_page_access(get_member(), 'polls')) {
         $rows = $GLOBALS['SITE_DB']->query('SELECT b.option1,b.option2,b.option3,b.option4,b.option5,b.option6,b.option7,b.option8,b.option9,b.option10,b.votes1,b.votes2,b.votes3,b.votes4,b.votes5,b.votes6,b.votes7,b.votes8,b.votes9,b.votes10,b.question,b.id,b.submitter AS member_id,a.date_and_time AS timestamp FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'poll a LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'poll b ON a.date_and_time>b.date_and_time WHERE NOT EXISTS(SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'poll x WHERE x.id<>a.id AND x.id<>b.id AND x.date_and_time BETWEEN b.date_and_time AND a.date_and_time) AND b.date_and_time IS NOT NULL AND b.date_and_time BETWEEN ' . strval($from) . ' AND ' . strval($to));
         foreach ($rows as $row) {
             require_lang('polls');
             $timestamp = $row['timestamp'];
             $member_id = $row['member_id'];
             $best = NULL;
             $best_num = -1;
             for ($i = 1; $i <= 10; $i++) {
                 if ($row['votes' . strval($i)] > $best_num) {
                     $best = $row['option' . strval($i)];
                     $best_num = $row['votes' . strval($i)];
                 }
             }
             if ($best_num == -1) {
                 continue;
             }
             $ticker_text = do_lang('VOTES_ARE_IN', strip_comcode(get_translated_text($row['question'])), strip_comcode(get_translated_text($best)));
             $drops[] = rain_get_special_icons(NULL, $timestamp, NULL, $ticker_text) + array('TYPE' => 'polls', 'FROM_MEMBER_ID' => strval($member_id), 'TO_MEMBER_ID' => NULL, 'TITLE' => rain_truncate_for_title(get_translated_text($row['question'])), 'IMAGE' => find_theme_image('bigicons/polls'), 'TIMESTAMP' => strval($timestamp), 'RELATIVE_TIMESTAMP' => strval($timestamp - $from), 'TICKER_TEXT' => $ticker_text, 'URL' => build_url(array('page' => 'polls', 'type' => 'view', 'id' => $row[1]['id']), '_SEARCH'), 'IS_POSITIVE' => false, 'IS_NEGATIVE' => false, 'FROM_ID' => 'member_' . strval($member_id), 'TO_ID' => NULL, 'GROUP_ID' => 'poll_' . strval($row['id']));
         }
     }
     return $drops;
 }
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     unset($map);
     require_lang('custom_comcode');
     $tags = array();
     $wmap = array('tag_enabled' => 1);
     if (!has_specific_permission(get_member(), 'comcode_dangerous')) {
         $wmap['tag_dangerous_tag'] = 0;
     }
     $tags = array_merge($tags, $GLOBALS['SITE_DB']->query_select('custom_comcode', array('tag_title', 'tag_description', 'tag_example', 'tag_parameters', 'tag_replace', 'tag_tag', 'tag_dangerous_tag', 'tag_block_tag', 'tag_textual_tag'), $wmap));
     if (isset($GLOBALS['FORUM_DB']) && $GLOBALS['FORUM_DB']->connection_write != $GLOBALS['SITE_DB']->connection_write && get_forum_type() == 'ocf') {
         $tags = array_merge($tags, $GLOBALS['FORUM_DB']->query_select('custom_comcode', array('tag_title', 'tag_description', 'tag_example', 'tag_parameters', 'tag_replace', 'tag_tag', 'tag_dangerous_tag', 'tag_block_tag', 'tag_textual_tag'), $wmap));
     }
     // From Comcode hooks
     $hooks = find_all_hooks('systems', 'comcode');
     foreach (array_keys($hooks) as $hook) {
         require_code('hooks/systems/comcode/' . filter_naughty_harsh($hook));
         $object = object_factory('Hook_comcode_' . filter_naughty_harsh($hook), true);
         $tags[] = $object->get_tag();
     }
     if (!array_key_exists(0, $tags)) {
         return paragraph(do_lang_tempcode('NONE_EM'), '', 'nothing_here');
     }
     $content = new ocp_tempcode();
     foreach ($tags as $tag) {
         $content->attach(do_template('CUSTOM_COMCODE_TAG_ROW', array('_GUID' => '28c257f5d0c596aa828fd9556b0df4a9', 'TITLE' => is_string($tag['tag_title']) ? $tag['tag_title'] : get_translated_text($tag['tag_title']), 'DESCRIPTION' => is_string($tag['tag_description']) ? $tag['tag_description'] : get_translated_text($tag['tag_description']), 'EXAMPLE' => $tag['tag_example'])));
     }
     return do_template('BLOCK_MAIN_CUSTOM_COMCODE_TAGS', array('_GUID' => 'b8d3436e6e5fe679ae9b0a368e607610', 'TAGS' => $content));
 }
Example #15
0
 function testEditCalendarEventType()
 {
     // Test the forum edits
     edit_event_type($this->eventtype_id, "test_event_type1", 'calendar/testtype1', '');
     // Test the forum was actually created
     $this->assertTrue('test_event_type1' == get_translated_text($GLOBALS['SITE_DB']->query_value('calendar_types', 't_title ', array('id' => $this->eventtype_id))));
 }
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_lang('news');
     $categories = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL));
     $content = new ocp_tempcode();
     $categories2 = array();
     foreach ($categories as $category) {
         if (has_category_access(get_member(), 'news', strval($category['id']))) {
             $join = ' LEFT JOIN ' . get_table_prefix() . 'news_category_entries d ON d.news_entry=p.id';
             $count = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'news p' . $join . ' WHERE validated=1 AND (news_entry_category=' . strval($category['id']) . ' OR news_category=' . strval($category['id']) . ') ORDER BY date_and_time DESC');
             if ($count > 0) {
                 $category['_nc_title'] = get_translated_text($category['nc_title']);
                 $categories2[] = $category;
             }
         }
     }
     if (count($categories2) == 0) {
         global $M_SORT_KEY;
         $M_SORT_KEY = '_nc_title';
         usort($categories2, 'multi_sort');
         foreach ($categories as $category) {
             if (has_category_access(get_member(), 'news', strval($category['id']))) {
                 $categories2[] = $category;
             }
         }
     }
     foreach ($categories2 as $category) {
         $url = build_url(array('page' => 'news', 'type' => 'misc', 'id' => $category['id']), get_module_zone('news'));
         $name = $category['_nc_title'];
         $content->attach(do_template('BLOCK_SIDE_NEWS_CATEGORIES_CATEGORY', array('_GUID' => 'fee49cac370ec00fc59d2e9c66b6255a', 'URL' => $url, 'NAME' => $name, 'COUNT' => integer_format($count))));
     }
     return do_template('BLOCK_SIDE_NEWS_CATEGORIES', array('_GUID' => 'b47a0047247096373e5aa626348c4ebb', 'CONTENT' => $content, 'PRE' => '', 'POST' => ''));
 }
Example #17
0
 function testEditNewscategory()
 {
     // Test the forum edits
     edit_news_category($this->news_id, 'Politics', 'world.jpg', 'Around the world', NULL);
     // Test the forum was actually created
     $this->assertTrue('Politics' == get_translated_text($GLOBALS['SITE_DB']->query_value('news_categories', 'nc_title ', array('id' => $this->news_id))));
 }
Example #18
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'));
 }
 /**
  * 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)));
 }
Example #20
0
 function testEditTicketType()
 {
     // Test the forum edits
     $this->tickettype_id = $GLOBALS['SITE_DB']->query_value_null_ok('translate', 'id', array('text_original' => "platinum"));
     edit_ticket_type($this->tickettype_id, "gold", 0, 0);
     // Test the forum was actually created
     $this->assertTrue('gold' == get_translated_text($this->tickettype_id));
 }
/**
 * Delete a multi moderation.
 *
 * @param  AUTO_LINK  The ID of the multi moderation we are deleting.
 */
function ocf_delete_multi_moderation($id)
{
    $_name = $GLOBALS['FORUM_DB']->query_value('f_multi_moderations', 'mm_name', array('id' => $id));
    $name = get_translated_text($_name, $GLOBALS['FORUM_DB']);
    $GLOBALS['FORUM_DB']->query_delete('f_multi_moderations', array('id' => $id), '', 1);
    delete_lang($_name, $GLOBALS['FORUM_DB']);
    log_it('DELETE_MULTI_MODERATION', strval($id), $name);
}
Example #22
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('tickets')) {
         return NULL;
     }
     if (!has_actual_page_access(get_member(), 'tickets')) {
         return NULL;
     }
     if (is_guest()) {
         return NULL;
     }
     require_code('tickets');
     require_code('tickets2');
     $ticket_types = ocfilter_to_idlist_using_callback($_filters, '', NULL, NULL, NULL, NULL, false);
     if (count($ticket_types) != 0) {
         $rows = array();
         foreach ($ticket_types as $ticket_type) {
             if (!has_category_access(get_member(), 'tickets', get_translated_text($ticket_type))) {
                 continue;
             }
             $rows = array_merge($rows, get_tickets(get_member(), $ticket_type, false, false, true));
         }
     } else {
         $rows = get_tickets(get_member(), NULL, false, false, true);
     }
     require_code('feedback');
     $content = new ocp_tempcode();
     foreach ($rows as $i => $row) {
         if ($i == $max) {
             break;
         }
         if ($row['lasttime'] < $cutoff) {
             continue;
         }
         $ticket_id = extract_topic_identifier($row['description']);
         $ticket_type = $GLOBALS['SITE_DB']->query_value_null_ok('tickets', 'ticket_type', array('ticket_id' => $ticket_id));
         $author = $row['firstusername'];
         $date = date($date_string, $row['firsttime']);
         $edit_date = date($date_string, $row['lasttime']);
         $title = xmlentities($row['firsttitle']);
         $summary = xmlentities($row['firstpost']->evaluate());
         $category = '';
         $category_raw = '';
         if (!is_null($ticket_type)) {
             $category = get_translated_text($ticket_type);
             $category_raw = strval($ticket_type);
         }
         $view_url = build_url(array('page' => 'tickets', 'type' => 'ticket', 'id' => $ticket_id), get_module_zone('tickets'), NULL, false, false, true);
         if ($prefix == 'RSS_' && get_option('is_on_comments') == '1') {
             $if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => 'b4f25f5cf68304f8d402bb06851489d6', 'COMMENT_URL' => $view_url, 'ID' => strval($ticket_id)));
         } else {
             $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' => $title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $ticket_id, 'NEWS' => '', 'DATE' => $date)));
     }
     require_lang('tickets');
     return array($content, do_lang('SUPPORT_TICKETS'));
 }
Example #23
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;
 }
 /**
  * Get a list of all the notification codes this hook can handle.
  * (Addons can define hooks that handle whole sets of codes, so hooks are written so they can take wide authority)
  *
  * @return array			List of codes (mapping between code names, and a pair: section and labelling for those codes)
  */
 function list_handled_codes()
 {
     $list = array();
     $catalogues = $GLOBALS['SITE_DB']->query('SELECT c_name,c_title FROM ' . get_table_prefix() . 'catalogues WHERE ' . db_string_not_equal_to('c_send_view_reports', 'never'));
     foreach ($catalogues as $catalogue) {
         $list['catalogue_view_reports__' . $catalogue['c_name']] = array(do_lang('GENERAL'), do_lang('NOTIFICATION_TYPE_catalogue_view_reports', get_translated_text($catalogue['c_title'])));
     }
     return $list;
 }
Example #25
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)
 {
     if ($row['c_is_tree']) {
         $url = build_url(array('page' => 'catalogues', 'type' => 'category', 'catalogue_name' => $row['c_name']), $zone);
     } else {
         $url = build_url(array('page' => 'catalogues', 'type' => 'index', 'id' => $row['c_name']), $zone);
     }
     return put_in_standard_box(do_template('SIMPLE_PREVIEW_BOX', array('SUMMARY' => get_translated_text($row['c_description']), 'URL' => $url)), get_translated_text($row['c_title']));
 }
 /**
  * Standard modular run function for ajax-tree hooks. Generates XML for a tree list, which is interpreted by Javascript and expanded on-demand (via new calls).
  *
  * @param  ?ID_TEXT		The ID to do under (NULL: root)
  * @param  array			Options being passed through
  * @param  ?ID_TEXT		The ID to select by default (NULL: none)
  * @return string			XML in the special category,entry format
  */
 function run($id, $options, $default = NULL)
 {
     if ($id === NULL) {
         $id = '';
     }
     require_code('files2');
     require_code('images');
     $fullpath = get_custom_file_base() . '/uploads/filedump';
     if ($id != '') {
         $fullpath .= '/' . $id;
     }
     $folder = isset($options['folder']) && $options['folder'];
     // We want to select folders, not files
     $out = '';
     if (has_actual_page_access(NULL, 'filedump') && file_exists($fullpath)) {
         $files = get_directory_contents($fullpath, '', false, false);
         foreach ($files as $f) {
             $description = $GLOBALS['SITE_DB']->query_value_null_ok('filedump', 'description', array('name' => basename($f), 'path' => $id . '/'));
             if (isset($options['attachment_ready']) && $options['attachment_ready']) {
                 $entry_id = 'url_' . 'uploads/filedump/' . ($id == '' ? '' : rawurlencode($id) . '/') . rawurlencode($f);
             } else {
                 $entry_id = 'uploads/filedump/' . ($id == '' ? '' : rawurlencode($id) . '/') . rawurlencode($f);
             }
             if (is_dir($fullpath . '/' . $f)) {
                 $has_children = count(get_directory_contents($fullpath . '/' . $f, '', false, false)) > 0;
                 $out .= '<category id="' . xmlentities(($id == '' ? '' : $id . '/') . $f) . '" title="' . xmlentities($f) . '" has_children="' . ($has_children ? 'true' : 'false') . '" selectable="' . ($folder ? 'true' : 'false') . '"></category>';
             } elseif (!$folder) {
                 if (!isset($options['only_images']) || !$options['only_images'] || is_image($f)) {
                     if (is_null($description) || get_translated_text($description) == '') {
                         $_description = '';
                         if (is_image($f)) {
                             $url = get_custom_base_url() . '/uploads/filedump/' . ($id == '' ? '' : $id . '/') . $f;
                             $_description = static_evaluate_tempcode(do_image_thumb($url, '', true, true));
                         }
                     } else {
                         $_description = escape_html(get_translated_text($description));
                     }
                     $out .= '<entry id="' . xmlentities($entry_id) . '" title="' . xmlentities($f) . '" description_html="' . xmlentities($_description) . '" selectable="true"></entry>';
                 }
             }
         }
         // Mark parent cats for pre-expansion
         if (!is_null($default) && $default != '') {
             $cat = '';
             foreach (explode('/', $default) as $_cat) {
                 if ($_cat != '') {
                     $cat .= '/';
                     $cat .= $_cat;
                 }
                 $out .= '<expand>' . $cat . '</expand>';
             }
         }
     }
     return '<result>' . $out . '</result>';
 }
Example #27
0
 /**
  * Get the products handled by this eCommerce hook.
  *
  * @return array		A map of product name to list of product details.
  */
 function get_products()
 {
     require_lang('classifieds');
     $prices = $GLOBALS['SITE_DB']->query_select('classifieds_prices', array('id', 'c_label', 'c_price'), NULL, 'ORDER BY c_price');
     $products = array();
     foreach ($prices as $price) {
         if ($price['c_price'] != 0.0) {
             $products['CLASSIFIEDS_ADVERT_' . strval($price['id'])] = array(PRODUCT_PURCHASE_WIZARD, float_to_raw_string($price['c_price']), 'handle_classifieds_advert', array(), do_lang('CLASSIFIED_ADVERT_BUY', get_translated_text($price['c_label'])));
         }
     }
     return $products;
 }
Example #28
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('ticket_types', array('ticket_type'));
     foreach ($types as $type) {
         $pagelinks[] = array('id' => $type['ticket_type'], 'title' => get_translated_text($type['ticket_type']));
     }
     global $M_SORT_KEY;
     $M_SORT_KEY = 'title';
     usort($pagelinks, 'multi_sort');
     return $pagelinks;
 }
Example #29
0
 /**
  * Get special Tempcode for inputting this field.
  *
  * @param  array			The row for the field to input
  * @return ?array			List of specially encoded input detail rows (NULL: nothing special)
  */
 function get_search_inputter($row)
 {
     $fields = array();
     $type = '_LIST';
     $special = new ocp_tempcode();
     $special->attach(form_input_list_entry('', get_param('option_' . strval($row['id']), '') == '', do_lang_tempcode('NA_EM')));
     $special->attach(form_input_list_entry('0', get_param('option_' . strval($row['id']), '') == '0', do_lang_tempcode('NO')));
     $special->attach(form_input_list_entry('1', get_param('option_' . strval($row['id']), '') == '1', do_lang_tempcode('YES')));
     $display = array_key_exists('trans_name', $row) ? $row['trans_name'] : get_translated_text($row['cf_name']);
     // 'trans_name' may have been set in CPF retrieval API, might not correspond to DB lookup if is an internal field
     $fields[] = array('NAME' => strval($row['id']), 'DISPLAY' => $display, 'TYPE' => $type, 'SPECIAL' => $special);
     return $fields;
 }
Example #30
0
 /**
  * Find what field types this hook can serve. This method only needs to be defined if it is not serving a single field type with a name corresponding to the hook itself.
  *
  * @return array			Map of field type to field type title
  */
 function get_field_types()
 {
     if (!addon_installed('catalogues')) {
         return array();
     }
     require_lang('fields');
     $cats = $GLOBALS['SITE_DB']->query_select('catalogues', array('c_name', 'c_title'));
     $ret = array();
     foreach ($cats as $cat) {
         $ret['ck_' . $cat['c_name']] = do_lang_tempcode('FIELD_TYPE_reference_x', escape_html(get_translated_text($cat['c_title'])));
     }
     return $ret;
 }