Beispiel #1
0
 function testEditCediPage()
 {
     require_code('permissions2');
     set_category_permissions_from_environment('seedy_page', strval($this->id), 'cms_cedi');
     cedi_edit_page($this->id, 'title-edited', 'test description', 'notes_edited', 0, '', '');
     //Check the page was edited
     $this->assertTrue('notes_edited' == $GLOBALS['FORUM_DB']->query_value('seedy_pages', 'notes', array('id' => $this->id)));
 }
Beispiel #2
0
 /**
  * Set permissions of the news category from POST parameters.
  *
  * @param  ID_TEXT		The category to set permissions for
  */
 function set_permissions($id)
 {
     set_category_permissions_from_environment($this->permission_module, $id, $this->permission_page);
 }
Beispiel #3
0
 /**
  * The actualiser to edit/delete a ticket type.
  *
  * @return tempcode		The UI
  */
 function _edit_ticket_type()
 {
     $title = get_page_title('EDIT_TICKET_TYPE');
     $type = get_param_integer('ticket_type');
     if (post_param_integer('delete', 0) == 1) {
         $title = get_page_title('DELETE_TICKET_TYPE');
         delete_ticket_type($type);
     } else {
         $trans_old_ticket_type = get_translated_text($type);
         edit_ticket_type($type, post_param('new_type'), post_param_integer('guest_emails_mandatory', 0), post_param_integer('search_faq', 0));
         $GLOBALS['SITE_DB']->query_delete('group_category_access', array('module_the_name' => 'tickets', 'category_name' => $trans_old_ticket_type), '', 1);
         require_code('permissions2');
         set_category_permissions_from_environment('tickets', post_param('new_type'));
     }
     // Show it worked / Refresh
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
Beispiel #4
0
 /**
  * Common theme change saving for adding and editing themes.
  *
  * @param  ID_TEXT			The name of the theme
  */
 function save_theme_changes($theme)
 {
     if (!file_exists(($theme == 'default' ? get_file_base() : get_custom_file_base()) . '/themes/' . filter_naughty($theme) . '/theme.ini')) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     if (post_param_integer('use_on_all', 0) == 1) {
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'zones SET zone_theme=\'' . db_escape_string($theme) . '\' WHERE ' . db_string_not_equal_to('zone_name', 'cms') . ' AND ' . db_string_not_equal_to('zone_name', 'adminzone'));
     }
     persistant_cache_empty();
     $before = better_parse_ini_file(($theme == 'default' ? get_file_base() : get_custom_file_base()) . '/themes/' . filter_naughty($theme) . '/theme.ini');
     $myfile = @fopen(($theme == 'default' ? get_file_base() : get_custom_file_base()) . '/themes/' . filter_naughty($theme) . '/theme.ini', 'wt') or intelligent_write_error(get_custom_file_base() . '/themes/' . filter_naughty($theme) . '/theme.ini');
     if (fwrite($myfile, 'title=' . post_param('title') . chr(10)) == 0) {
         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
     }
     if (fwrite($myfile, 'description=' . post_param('description') . chr(10)) == 0) {
         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
     }
     foreach ($before as $key => $val) {
         if ($key != 'title' && $key != 'description' && $key != 'author' && $key != 'mobile_pages' && $key != 'supports_wide') {
             fwrite($myfile, $key . '=' . $val . chr(10));
         }
     }
     if (fwrite($myfile, 'author=' . post_param('author') . chr(10)) == 0) {
         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
     }
     if (fwrite($myfile, 'mobile_pages=' . post_param('mobile_pages') . chr(10)) == 0) {
         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
     }
     if (fwrite($myfile, 'supports_wide=' . strval(post_param_integer('supports_wide', 0)) . chr(10)) == 0) {
         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
     }
     fclose($myfile);
     sync_file(($theme == 'default' ? get_file_base() : get_custom_file_base()) . '/themes/' . filter_naughty($theme) . '/theme.ini');
     require_code('permissions2');
     set_category_permissions_from_environment('theme', $theme);
     $map = file_exists(get_file_base() . '/themes/map.ini') ? better_parse_ini_file(get_file_base() . '/themes/map.ini') : array();
     $new_map = array();
     foreach ($map as $key => $val) {
         if ($val != $theme) {
             $new_map[$key] = $val;
         }
     }
     if (array_key_exists('mapping', $_POST)) {
         foreach ($_POST['mapping'] as $val) {
             if (get_magic_quotes_gpc()) {
                 $val = stripslashes($val);
             }
             $new_map[$val] = $theme;
         }
     }
     $myfile = @fopen(get_file_base() . '/themes/map.ini', 'wt') or intelligent_write_error(get_file_base() . '/themes/map.ini');
     foreach ($new_map as $key => $val) {
         if (fwrite($myfile, $key . '=' . $val . chr(10)) == 0) {
             warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
         }
     }
     fclose($myfile);
     sync_file('themes/map.ini');
 }
Beispiel #5
0
 /**
  * Standard aed_module add actualiser.
  *
  * @return ID_TEXT		The entry added
  */
 function add_actualisation()
 {
     require_code('catalogues2');
     $name = post_param('name');
     $title = post_param('title');
     $description = post_param('description');
     $display_type = post_param_integer('display_type');
     $is_tree = post_param_integer('is_tree', 0);
     $this->is_tree_catalogue = $is_tree == 1;
     $notes = post_param('notes', '');
     $submit_points = post_param_integer('submit_points', 0);
     $cat_tab = post_param_integer('cat_tab', 0);
     $ecommerce = post_param_integer('ecommerce', 0);
     $send_view_reports = post_param('send_view_reports');
     // What fields do we have?
     $new = array();
     foreach ($_POST as $key => $val) {
         if (!is_string($val) && !is_integer($val)) {
             continue;
         }
         if (get_magic_quotes_gpc()) {
             $val = stripslashes($val);
         }
         $matches = array();
         if (preg_match('#new_field_(\\d*)_(.*)#A', $key, $matches) != 0) {
             $new[$matches[1]][$matches[2]] = $val;
         }
     }
     $num_fields = 0;
     foreach ($new as $field) {
         if ($field['name'] != '') {
             $num_fields++;
         }
     }
     if ($num_fields == 0) {
         warn_exit(do_lang_tempcode('NO_FIELDS'));
     }
     $category_id = actual_add_catalogue($name, $title, $description, $display_type, $is_tree, $notes, $submit_points, $ecommerce, $send_view_reports);
     $this->set_permissions($name);
     if (!is_null($category_id)) {
         $GLOBALS['MODULE_CMS_CATALOGUES']->cat_aed_module->set_permissions(strval($category_id));
     }
     // Now onto the fields
     foreach ($new as $field) {
         if (!array_key_exists('default', $field)) {
             warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
         }
         if (!array_key_exists('description', $field)) {
             warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
         }
         if (!array_key_exists('name', $field)) {
             warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
         }
         if (!array_key_exists('order', $field)) {
             warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
         }
         if (!array_key_exists('type', $field) || $field['type'] == '') {
             warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
         }
         if ($field['order'] == '') {
             $field['order'] = 0;
         } else {
             $field['order'] = intval($field['order']);
         }
         $defines_order = array_key_exists('defines_order', $field) ? intval($field['defines_order']) : 0;
         $visible = array_key_exists('visible', $field) ? intval($field['visible']) : 0;
         $searchable = array_key_exists('searchable', $field) ? intval($field['searchable']) : 0;
         $required = array_key_exists('required', $field) ? intval($field['required']) : 0;
         $put_in_category = array_key_exists('put_in_category', $field) ? intval($field['put_in_category']) : 0;
         $put_in_search = array_key_exists('put_in_search', $field) ? intval($field['put_in_search']) : 0;
         if ($field['name'] != '') {
             actual_add_catalogue_field($name, $field['name'], $field['description'], $field['type'], $field['order'], $defines_order, $visible, $searchable, $field['default'], $required, $put_in_category, $put_in_search);
         }
     }
     $add_to_menu = post_param_integer('add_to_menu', 0);
     if ($add_to_menu == 1) {
         require_code('menus2');
         if ($is_tree == 1) {
             add_menu_item_simple('main_content', NULL, $title, '_SEARCH:catalogues:type=category:catalogue_name=' . $name);
         } else {
             add_menu_item_simple('main_content', NULL, $title, '_SEARCH:catalogues:type=index:' . $name);
         }
     }
     // Auto-fill feature
     $auto_fill = post_param('auto_fill');
     if ($auto_fill != '') {
         $categories = array();
         if (strpos($auto_fill, '|') === false) {
             $to_do = explode(',', $auto_fill);
         } else {
             $to_do = explode('|', $auto_fill);
         }
         foreach ($to_do as $doing) {
             if (trim($doing) == '') {
                 continue;
             }
             $bits = explode('\\', $doing);
             $parent_id = $category_id;
             foreach ($bits as $bit) {
                 $bit = trim($bit);
                 if (array_key_exists($bit, $categories)) {
                     if (!is_null($parent_id)) {
                         $parent_id = $categories[$bit];
                     }
                 } else {
                     $_parent_id = actual_add_catalogue_category($name, $bit, '', '', $parent_id, '');
                     if (!is_null($parent_id)) {
                         $parent_id = $_parent_id;
                     }
                     require_code('permissions2');
                     if (get_value('disable_cat_cat_perms') !== '1') {
                         set_category_permissions_from_environment('catalogues_category', strval($parent_id), $this->permission_page);
                     }
                     $categories[$bit] = $parent_id;
                 }
             }
         }
     }
     if ($is_tree == 0 && substr($name, 0, 1) != '_') {
         $this->do_next_description = paragraph(do_lang_tempcode('SUGGEST_ADD_CATEGORY_NEXT'));
     }
     return $name;
 }
Beispiel #6
0
 /**
  * The actualiser for editing a CEDI page.
  *
  * @return tempcode	The UI.
  */
 function _edit_page()
 {
     $_id = get_param_cedi_chain('id');
     $id = intval($_id[0]);
     if (!has_category_access(get_member(), 'seedy_page', strval($id))) {
         access_denied('CATEGORY_ACCESS');
     }
     if (post_param_integer('delete', 0) == 1) {
         $title = get_page_title('CEDI_DELETE_PAGE');
         check_delete_permission('cat_low', NULL, array('seedy_page', $id));
         cedi_delete_page($id);
         require_code('fields');
         if (has_tied_catalogue('seedy_page')) {
             delete_form_custom_fields('seedy_page', strval($id));
         }
         require_code('autosave');
         clear_ocp_autosave();
         $_url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
         $url = $_url->evaluate();
     } else {
         $title = get_page_title('CEDI_EDIT_PAGE');
         check_edit_permission('cat_low', NULL, array('seedy_page', $id));
         require_code('permissions2');
         set_category_permissions_from_environment('seedy_page', strval($id), 'cms_cedi');
         cedi_edit_page($id, post_param('title'), post_param('post'), post_param('notes', ''), post_param_integer('hide_posts', 0), post_param('meta_keywords', ''), post_param('meta_description', ''));
         require_code('fields');
         if (has_tied_catalogue('seedy_page')) {
             save_form_custom_fields('seedy_page', strval($id));
         }
         require_code('autosave');
         clear_ocp_autosave();
         if (addon_installed('awards')) {
             require_code('awards');
             handle_award_setting('seedy_page', strval($id));
         }
         $url = get_param('redirect');
     }
     // Show it worked / Refresh
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }