Example #1
0
 /**
  * Standard modular UI/actualiser to edit an entry.
  *
  * @return tempcode	The UI
  */
 function __ed()
 {
     $id = mixed();
     // Define type as mixed
     $id = $this->non_integer_id ? get_param('id', false, true) : strval(get_param_integer('id'));
     $doing = 'EDIT_' . $this->lang_type;
     if ($this->catalogue && get_param('catalogue_name', '') != '') {
         $catalogue_title = get_translated_text($GLOBALS['SITE_DB']->query_value('catalogues', 'c_title', array('c_name' => get_param('catalogue_name'))));
         if ($this->type_code == 'd') {
             $doing = do_lang('CATALOGUE_GENERIC_EDIT', escape_html($catalogue_title));
         } elseif ($this->type_code == 'c') {
             $doing = do_lang('CATALOGUE_GENERIC_EDIT_CATEGORY', escape_html($catalogue_title));
         }
     }
     $title = get_page_title($doing);
     if ($this->second_stage_preview && get_param_integer('preview', 0) == 1) {
         return $this->preview_intercept($title);
     }
     if (method_exists($this, 'get_submitter')) {
         list($submitter, $date_and_time) = $this->get_submitter($id);
         if (!is_null($date_and_time) && addon_installed('points')) {
             $reverse = post_param_integer('reverse_point_transaction', 0);
             if ($reverse == 1) {
                 $points_test = $GLOBALS['SITE_DB']->query_select('gifts', array('*'), array('date_and_time' => $date_and_time, 'gift_to' => $submitter, 'gift_from' => $GLOBALS['FORUM_DRIVER']->get_guest_id()));
                 if (array_key_exists(0, $points_test)) {
                     $amount = $points_test[0]['amount'];
                     $sender_id = $points_test[0]['gift_from'];
                     $recipient_id = $points_test[0]['gift_to'];
                     $GLOBALS['SITE_DB']->query_delete('gifts', array('id' => $points_test[0]['id']), '', 1);
                     if (!is_guest($sender_id)) {
                         $_sender_gift_points_used = point_info($sender_id);
                         $sender_gift_points_used = array_key_exists('gift_points_used', $_sender_gift_points_used) ? $_sender_gift_points_used['gift_points_used'] : 0;
                         $GLOBALS['FORUM_DRIVER']->set_custom_field($sender_id, 'gift_points_used', strval($sender_gift_points_used - $amount));
                     }
                     require_code('points');
                     $temp_points = point_info($recipient_id);
                     $GLOBALS['FORUM_DRIVER']->set_custom_field($recipient_id, 'points_gained_given', strval((array_key_exists('points_gained_given', $temp_points) ? $temp_points['points_gained_given'] : 0) - $amount));
                 }
             }
         }
     } else {
         $submitter = NULL;
     }
     breadcrumb_set_parents(array_merge($GLOBALS['BREADCRUMB_SET_PARENTS'], array(array('_SELF:_SELF:_e' . $this->type_code . ':' . $id, strpos($doing, ' ') !== false ? protect_from_escaping($doing) : do_lang_tempcode($doing)))));
     $delete = post_param_integer('delete', 0);
     if ($delete == 1 || $delete == 2) {
         if (!is_null($this->permissions_require)) {
             check_delete_permission($this->permissions_require, $submitter, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? NULL : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? NULL : $this->get_cat_b($id)), $this->permission_page_name);
         }
         $doing = 'DELETE_' . $this->lang_type;
         if ($this->catalogue && get_param('catalogue_name', '') != '') {
             $catalogue_title = get_translated_text($GLOBALS['SITE_DB']->query_value('catalogues', 'c_title', array('c_name' => get_param('catalogue_name'))));
             if ($this->type_code == 'd') {
                 $doing = do_lang('CATALOGUE_GENERIC_DELETE', escape_html($catalogue_title));
             } elseif ($this->type_code == 'c') {
                 $doing = do_lang('CATALOGUE_GENERIC_DELETE_CATEGORY', escape_html($catalogue_title));
             }
         }
         $title = get_page_title($doing);
         $test = $this->handle_confirmations($title);
         if (!is_null($test)) {
             return $test;
         }
         $this->delete_actualisation($id);
         // Delete custom fields
         if ($this->has_tied_catalogue()) {
             require_code('fields');
             delete_form_custom_fields($this->award_type, $id);
         }
         /*if ((!is_null($this->redirect_type)) || ((!is_null(get_param('redirect',NULL)))))		No - resource is gone now, and redirect would almost certainly try to take us back there
         		{
         			$url=(($this->redirect_type=='!') || (is_null($this->redirect_type)))?get_param('redirect'):build_url(array('page'=>'_SELF','type'=>$this->redirect_type),'_SELF');
         			return redirect_screen($title,$url,do_lang_tempcode('SUCCESS'));
         		}*/
         clear_ocp_autosave();
         $description = is_null($this->do_next_description) ? do_lang_tempcode('SUCCESS') : $this->do_next_description;
         return $this->do_next_manager($title, $description, NULL);
     } else {
         if (!is_null($this->permissions_require)) {
             check_edit_permission($this->permissions_require, $submitter, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? NULL : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? NULL : $this->get_cat_b($id)), $this->permission_page_name);
         }
         $test = $this->handle_confirmations($title);
         if (!is_null($test)) {
             return $test;
         }
         if ($this->user_facing && !is_null($this->permissions_require) && array_key_exists('validated', $_POST)) {
             if (!has_specific_permission(get_member(), 'bypass_validation_' . $this->permissions_require . 'range_content', $this->permission_page_name, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? '' : post_param($this->permissions_cat_name), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? '' : post_param($this->permissions_cat_name_b)))) {
                 $_POST['validated'] = '0';
             }
         }
         if (!is_null($this->upload)) {
             require_code('uploads');
         }
         $description = $this->edit_actualisation($id);
         if (!is_null($this->new_id)) {
             $id = $this->new_id;
         }
         // Save custom fields
         if ($this->has_tied_catalogue()) {
             require_code('fields');
             save_form_custom_fields($this->award_type, $id);
         }
         if ($this->output_of_action_is_confirmation && !is_null($description)) {
             return $description;
         }
         if (is_null($description)) {
             $description = do_lang_tempcode('SUCCESS');
         }
         if (addon_installed('awards')) {
             if (!is_null($this->award_type)) {
                 require_code('awards');
                 handle_award_setting($this->award_type, $id);
             }
         }
         if ($this->user_facing) {
             if ($this->check_validation && post_param_integer('validated', 0) == 0) {
                 require_code('submit');
                 if ($this->send_validation_request) {
                     $edit_url = build_url(array('page' => '_SELF', 'type' => '_e' . $this->type_code, 'id' => $id, 'validated' => 1), '_SELF', NULL, false, false, true);
                     if (addon_installed('unvalidated')) {
                         send_validation_request($doing, $this->table, $this->non_integer_id, $id, $edit_url);
                     }
                 }
                 $description->attach(paragraph(do_lang_tempcode('SUBMIT_UNVALIDATED')));
             }
         }
     }
     if (!is_null($this->redirect_type) || !is_null(get_param('redirect', NULL))) {
         $url = $this->redirect_type == '!' || is_null($this->redirect_type) ? make_string_tempcode(get_param('redirect')) : build_url(array('page' => '_SELF', 'type' => $this->redirect_type), '_SELF');
         return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
     }
     clear_ocp_autosave();
     decache('main_awards');
     return $this->do_next_manager($title, $description, $id);
 }
Example #2
0
 /**
  * Standard aed_module edit actualiser.
  *
  * @param  ID_TEXT		The entry being edited
  */
 function edit_actualisation($_id)
 {
     $id = intval($_id);
     $rows = $GLOBALS['SITE_DB']->query_select('iotd', array('is_current', 'submitter'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $is_current = $rows[0]['is_current'];
     $submitter = $rows[0]['submitter'];
     require_code('uploads');
     check_edit_permission($is_current == 1 ? 'high' : 'mid', $submitter);
     $urls = get_url('url', 'file', 'uploads/iotds', 0, OCP_UPLOAD_IMAGE, true, 'thumb_url', 'file2');
     if ($urls[0] == '' || $urls[1] == '') {
         warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD'));
     }
     $url = $urls[0];
     $thumb_url = $urls[1];
     if (substr($urls[0], 0, 8) != 'uploads/' && $urls[0] != '' && is_null(http_download_file($urls[0], 0, false)) && !is_null($GLOBALS['HTTP_MESSAGE_B'])) {
         attach_message($GLOBALS['HTTP_MESSAGE_B'], 'warn');
     }
     $allow_rating = post_param_integer('allow_rating', 0);
     $allow_comments = post_param_integer('allow_comments', 0);
     $notes = post_param('notes', '');
     $allow_trackbacks = post_param_integer('allow_trackbacks', 0);
     $current = post_param_integer('validated', 0);
     $title = post_param('title');
     if ($current == 1 && $GLOBALS['SITE_DB']->query_value('iotd', 'is_current', array('id' => $id)) == 0) {
         $submitter = $GLOBALS['SITE_DB']->query_value('iotd', 'submitter', array('id' => $id));
         if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'iotds')) {
             syndicate_described_activity('iotds:ACTIVITY_ADD_IOTD', $title, '', '', '_SEARCH:iotds:view:' . strval($id), '', '', 'iotds', 1, NULL);
         }
     }
     edit_iotd($id, $title, post_param('caption'), $thumb_url, $url, $allow_rating, $allow_comments, $allow_trackbacks, $notes);
     if ($current == 1) {
         if ($is_current == 0) {
             if (!has_specific_permission(get_member(), 'choose_iotd')) {
                 log_hack_attack_and_exit('BYPASS_VALIDATION_HACK');
             }
             set_iotd($id);
         }
     }
 }
Example #3
0
 /**
  * The actualiser to edit a comcode page.
  *
  * @return tempcode		The UI
  */
 function __ed()
 {
     $simple_add = get_param_integer('simple_add', 0) == 1;
     $title = get_page_title($simple_add ? 'COMCODE_PAGE_ADD' : 'COMCODE_PAGE_EDIT');
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/comcode_page_edit';
     $file = filter_naughty(post_param('file'));
     $lang = filter_naughty(post_param('lang'));
     $zone = filter_naughty(post_param('zone'));
     if (addon_installed('page_management')) {
         $new_file = filter_naughty(has_actual_page_access(get_member(), 'admin_sitetree') ? post_param('title', $file) : $file);
     } else {
         $new_file = filter_naughty($file);
     }
     if ($file == '') {
         $file = $new_file;
     }
     require_code('type_validation');
     if (!is_alphanumeric($file, true)) {
         warn_exit(do_lang_tempcode('BAD_CODENAME'));
     }
     $fullpath = zone_black_magic_filterer(get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . $lang . '/' . $file . '.txt');
     $renaming_page = $new_file != $file;
     if ($renaming_page) {
         if (!is_alphanumeric($new_file, true)) {
             warn_exit(do_lang_tempcode('BAD_CODENAME'));
         }
         $langs = find_all_langs(true);
         $rename_map = array();
         $afm_needed = false;
         // Actually will stay false as we don't allow renaming original-pages at the moment
         foreach (array_keys($langs) as $lang) {
             $path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/comcode_custom/' . $lang . '/' . $file . '.txt', true);
             if (is_file(get_file_base() . '/' . $path)) {
                 $new_path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/comcode_custom/' . $lang . '/' . $new_file . '.txt', true);
                 if (is_file($new_path)) {
                     warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($zone . ':' . $new_file)));
                 }
                 $rename_map[$path] = $new_path;
             }
             if (is_file(get_file_base() . '/' . str_replace('/comcode_custom/', '/comcode/', $path))) {
                 $completion_text = do_lang_tempcode('ORIGINAL_PAGE_NO_RENAME');
             }
         }
         if ($afm_needed) {
             require_code('abstract_file_manager');
             force_have_afm_details();
         }
     }
     $validated = post_param_integer('validated', 0);
     if (!has_specific_permission(get_member(), 'bypass_validation_highrange_content')) {
         $validated = 0;
     }
     $parent_page = post_param('parent_page', '');
     $show_as_edit = post_param_integer('show_as_edit', 0);
     $resource_owner = $GLOBALS['SITE_DB']->query_value_null_ok('comcode_pages', 'p_submitter', array('the_zone' => $zone, 'the_page' => $file));
     check_edit_permission('high', $resource_owner);
     if ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) {
         $_owner = post_param('owner', $GLOBALS['FORUM_DRIVER']->get_username(get_member()));
         $owner = $GLOBALS['FORUM_DRIVER']->get_member_from_username($_owner);
         if (is_null($owner)) {
             $owner = get_member();
         }
     } else {
         $owner = get_member();
     }
     if (is_null($resource_owner)) {
         check_submit_permission('high');
         require_code('submit');
         give_submit_points('COMCODE_PAGE_ADD');
         if (!addon_installed('unvalidated')) {
             $validated = 1;
         }
         $GLOBALS['SITE_DB']->query_insert('comcode_pages', array('the_zone' => $zone, 'the_page' => $file, 'p_parent_page' => $parent_page, 'p_validated' => $validated, 'p_edit_date' => NULL, 'p_add_date' => time(), 'p_submitter' => $owner, 'p_show_as_edit' => 0));
     } else {
         if (!has_actual_page_access(get_member(), $file, $zone)) {
             access_denied('PAGE_ACCESS');
         }
         require_code('submit');
         $just_validated = !content_validated('comcode_page', $zone . ':' . $file) && $validated == 1;
         if ($just_validated) {
             send_content_validated_notification('comcode_page', $zone . ':' . $file);
         }
         if (!addon_installed('unvalidated')) {
             $validated = 1;
         }
         $GLOBALS['SITE_DB']->query_update('comcode_pages', array('p_parent_page' => $parent_page, 'p_validated' => $validated, 'p_edit_date' => time(), 'p_submitter' => $owner, 'p_show_as_edit' => $show_as_edit), array('the_zone' => $zone, 'the_page' => $file), '', 1);
     }
     if ($validated == 0) {
         require_code('submit');
         $edit_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $zone . ':' . $new_file), '_SELF', NULL, false, false, true);
         if (addon_installed('unvalidated')) {
             send_validation_request('COMCODE_PAGE_EDIT', 'comcode_pages', true, $zone . ':' . $new_file, $edit_url);
         }
     }
     $new = post_param('post');
     require_code('attachments2');
     $_new = do_comcode_attachments($new, 'comcode_page', $zone . ':' . $file);
     $new = $_new['comcode'];
     if (!file_exists($fullpath) || $new != file_get_contents($fullpath, FILE_TEXT)) {
         $myfile = @fopen($fullpath, 'wt');
         if ($myfile === false) {
             intelligent_write_error($fullpath);
         }
         final_attachments_from_preview($zone . ':' . $file);
         if (fwrite($myfile, $new) < strlen($new)) {
             warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
         }
         fclose($myfile);
         sync_file($fullpath);
         $file_changed = true;
     } else {
         $file_changed = false;
     }
     require_code('seo2');
     $new_keywords = post_param('meta_keywords', '');
     $new_description = post_param('meta_description', '');
     if ($new_keywords == '' && $new_description == '') {
         seo_meta_set_for_implicit('comcode_page', $zone . ':' . $file, array($new), $new);
     } else {
         seo_meta_set_for_explicit('comcode_page', $zone . ':' . $file, $new_keywords, $new_description);
     }
     $completion_text = $validated == 0 ? do_lang_tempcode('SUBMIT_UNVALIDATED') : do_lang_tempcode('SUCCESS');
     // Update cache  NO WE CAN'T - THEY'RE MULTI-THEME NOW
     /*	$string_index=$GLOBALS['SITE_DB']->query_value_null_ok('cached_comcode_pages','string_index',array('the_zone'=>$zone,'the_page'=>$file));
     		if (!is_null($string_index))
     		{
     			lang_remap_comcode($string_index,$new);
     		} else
     		{
     			$string_index=insert_lang_comcode($new,1,NULL,false,NULL,NULL,false,NULL,NULL,60,true,true);
     			$GLOBALS['SITE_DB']->query_insert('cached_comcode_pages',array('the_zone'=>$zone,'the_page'=>$file,'string_index'=>$string_index));
     		}*/
     require_code('permissions2');
     set_page_permissions_from_environment($zone, $file);
     $caches = $GLOBALS['SITE_DB']->query_select('cached_comcode_pages', array('string_index'), array('the_zone' => $zone, 'the_page' => $file));
     $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_zone' => $zone, 'the_page' => $file));
     foreach ($caches as $cache) {
         delete_lang($cache['string_index']);
     }
     persistant_cache_empty();
     persistant_cache_delete(array('PAGE_INFO'));
     decache('main_comcode_page_children');
     fix_permissions($fullpath);
     if (is_file($fullpath) && get_option('store_revisions') == '1' && $file_changed) {
         $time = time();
         @copy($fullpath, $fullpath . '.' . strval($time)) or intelligent_write_error($fullpath . '.' . strval($time));
         fix_permissions($fullpath . '.' . strval($time));
         sync_file($fullpath . '.' . strval($time));
     }
     log_it('COMCODE_PAGE_EDIT', $file, $zone);
     require_code('autosave');
     clear_ocp_autosave();
     if ($renaming_page) {
         $GLOBALS['SITE_DB']->query_delete('comcode_pages', array('the_zone' => $zone, 'the_page' => $new_file), '', 1);
         $GLOBALS['SITE_DB']->query_update('comcode_pages', array('the_page' => $new_file), array('the_zone' => $zone, 'the_page' => $file), '', 1);
         $GLOBALS['SITE_DB']->query_update('comcode_pages', array('p_parent_page' => $new_file), array('the_zone' => $zone, 'p_parent_page' => $file));
         foreach ($rename_map as $path => $new_path) {
             if ($afm_needed) {
                 afm_move($path, $new_path);
             } else {
                 rename(get_custom_file_base() . '/' . $path, get_custom_file_base() . '/' . $new_path);
             }
         }
         if (addon_installed('awards')) {
             $types = $GLOBALS['SITE_DB']->query_select('award_types', array('id'), array('a_content_type' => 'comcode_page'));
             foreach ($types as $type) {
                 $GLOBALS['SITE_DB']->query_update('award_archive', array('content_id' => $new_file), array('content_id' => $file, 'a_type_id' => $type['id']));
             }
         }
         $file = $new_file;
     }
     if (post_param_integer('delete', 0) == 1) {
         unlink(get_custom_file_base() . '/' . $path);
     }
     if (addon_installed('awards')) {
         require_code('awards');
         handle_award_setting('comcode_page', $zone . ':' . $file);
     }
     decache('main_sitemap');
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     // Look for bad title semantics
     $_new['html'] = $_new['tempcode']->evaluate();
     if (substr($file, 0, 1) != '_' && substr($file, 0, 6) != 'panel_' && trim($_new['html']) != '') {
         if (strpos($_new['html'], '<h1') === false && strpos($_new['comcode'], '[title]') === false && strpos($_new['comcode'], '[title="1"]') === false) {
             attach_message(do_lang_tempcode('NO_LEVEL_1_HEADERS'), 'notice');
         }
         $matches = array();
         if (strpos($_new['html'], '<h2') === false && preg_match_all('#\\n\\[(b|font|size)\\][^\\.]+\\[/(b|font|size)\\]\\n#', $_new['comcode'], $matches) >= 2) {
             attach_message(do_lang_tempcode('NO_LEVEL_2_HEADERS'), 'inform');
         }
     }
     // Show it worked / Refresh
     $url = post_param('redirect', '');
     if ($url != '') {
         return redirect_screen($title, $url, $completion_text);
     }
     return $this->do_next_manager($title, $file, $zone, $completion_text);
 }
Example #4
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'));
 }
Example #5
0
 /**
  * Standard aed_module edit actualiser.
  *
  * @param  ID_TEXT		The entry being edited
  * @return tempcode		Description shown after editing
  */
 function edit_actualisation($_id)
 {
     $id = intval($_id);
     $rows = $GLOBALS['SITE_DB']->query_select('calendar_events', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $event = $rows[0];
     check_edit_permission($event['e_is_public'] == 1 ? 'mid' : 'low', $event['e_submitter']);
     $delete_status = post_param('delete', '0');
     list($type, $recurrence, $_recurrences, $title, $content, $priority, $is_public, $_start_year, $_start_month, $_start_day, $_start_hour, $_start_minute, $_end_year, $_end_month, $_end_day, $_end_hour, $_end_minute, $timezone, $do_timezone_conv) = $this->get_event_parameters();
     $allow_trackbacks = post_param_integer('allow_trackbacks', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $allow_rating = post_param_integer('allow_rating', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $allow_comments = post_param_integer('allow_comments', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $notes = post_param('notes', STRING_MAGIC_NULL);
     $validated = post_param_integer('validated', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $seg_recurrences = post_param_integer('seg_recurrences', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $fixed_past = false;
     if ($delete_status == '3' && !fractional_edit()) {
         // Fix past occurences
         $past_times = find_periods_recurrence($event['e_timezone'], 1, $event['e_start_year'], $event['e_start_month'], $event['e_start_day'], $event['e_start_hour'], $event['e_start_minute'], $event['e_end_year'], $event['e_end_month'], $event['e_end_day'], $event['e_end_hour'], $event['e_end_minute'], $event['e_recurrence'], $event['e_recurrences'], utctime_to_usertime(mktime($event['e_start_hour'], $event['e_start_minute'], 0, $event['e_start_month'], $event['e_start_day'], $event['e_start_year'])), utctime_to_usertime(time()));
         if (count($past_times) > 0) {
             foreach ($past_times as $past_time) {
                 list($start_year, $start_month, $start_day, $start_hour, $start_minute) = explode('-', date('Y-m-d-h-i', usertime_to_utctime($past_time[0])));
                 if (is_null($past_time[1])) {
                     list($end_year, $end_month, $end_day, $end_hour, $end_minute) = array(NULL, NULL, NULL, NULL, NULL);
                 } else {
                     $explode = explode('-', date('Y-m-d-h-i', usertime_to_utctime($past_time[1])));
                     $end_year = intval($explode[0]);
                     $end_month = intval($explode[1]);
                     $end_day = intval($explode[2]);
                     $end_hour = intval($explode[3]);
                     $end_minute = intval($explode[4]);
                 }
                 add_calendar_event($event['e_type'], 'none', NULL, 0, get_translated_text($event['e_title']), get_translated_text($event['e_content']), $event['e_priority'], $event['e_is_public'], intval($start_year), intval($start_month), intval($start_day), intval($start_hour), intval($start_minute), $end_year, $end_month, $end_day, $end_hour, $end_minute, $timezone, $do_timezone_conv, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes);
             }
             if (is_null($_recurrences)) {
                 $recurrences = NULL;
             } else {
                 $recurrences = max(0, $_recurrences - count($past_times));
             }
             // Find next occurence in future
             if (count($past_times) == 0) {
                 $start_year = $_start_year;
                 $start_month = $_start_month;
                 $start_day = $_start_day;
                 $start_hour = $_start_hour;
                 $start_minute = $_start_minute;
                 $end_year = $_end_year;
                 $end_month = $_end_month;
                 $end_day = $_end_day;
                 $end_hour = $_end_hour;
                 $end_minute = $_end_minute;
             }
             $past_times = find_periods_recurrence($event['e_timezone'], 1, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, $event['e_recurrence'], 1, time());
             if (array_key_exists(0, $past_times)) {
                 $past_time = $past_times[0];
                 $explode = explode('-', date('Y-m-d-h-i', $past_time[0]));
                 $start_year = intval($explode[0]);
                 $start_month = intval($explode[1]);
                 $start_day = intval($explode[2]);
                 $start_hour = intval($explode[3]);
                 $start_minute = intval($explode[4]);
                 if (is_null($past_time[1])) {
                     list($end_year, $end_month, $end_day, $end_hour, $end_minute) = array(NULL, NULL, NULL, NULL, NULL);
                 } else {
                     $explode = explode('-', date('Y-m-d-h-i', $past_time[1]));
                     $end_year = intval($explode[0]);
                     $end_month = intval($explode[1]);
                     $end_day = intval($explode[2]);
                     $end_hour = intval($explode[3]);
                     $end_minute = intval($explode[4]);
                 }
             } else {
                 $recurrences = 0;
             }
             $fixed_past = true;
         }
     }
     if (!$fixed_past) {
         $start_year = $_start_year;
         $start_month = $_start_month;
         $start_day = $_start_day;
         $start_hour = $_start_hour;
         $start_minute = $_start_minute;
         $end_year = $_end_year;
         $end_month = $_end_month;
         $end_day = $_end_day;
         $end_hour = $_end_hour;
         $end_minute = $_end_minute;
         $recurrences = $_recurrences;
     }
     if ($validated == 1 && $GLOBALS['SITE_DB']->query_value('calendar_events', 'validated', array('id' => $id)) == 0) {
         if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'calendar') && has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'calendar', strval($type))) {
             $_from = cal_get_start_utctime_for_event($timezone, $start_year, $start_month, $start_day, $start_hour, $start_minute, true);
             $from = cal_utctime_to_usertime($_from, $timezone, false);
             $to = mixed();
             if (!is_null($end_year) && !is_null($end_month) && !is_null($end_day)) {
                 $_to = cal_get_end_utctime_for_event($timezone, $end_year, $end_month, $end_day, $end_hour, $end_minute, true);
                 $to = cal_utctime_to_usertime($_to, $timezone, false);
             }
             $submitter = $GLOBALS['SITE_DB']->query_value('calendar_events', 'e_submitter', array('id' => $id));
             syndicate_described_activity($submitter != get_member() ? 'calendar:ACTIVITY_VALIDATE_CALENDAR_EVENT' : 'calendar:ACTIVITY_CALENDAR_EVENT', $title, date_range($from, $to, !is_null($start_hour)), '', '_SEARCH:calendar:view:' . strval($id), '', '', 'calendar', 1, NULL, true);
         }
     }
     edit_calendar_event($id, $type, $recurrence, $recurrences, $seg_recurrences, $title, $content, $priority, $is_public, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, $timezone, $do_timezone_conv, post_param('meta_keywords', STRING_MAGIC_NULL), post_param('meta_description', STRING_MAGIC_NULL), $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes);
     if (!fractional_edit()) {
         $conflicts = detect_conflicts(get_member(), $id, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, $recurrence, $recurrences);
         $_description = is_null($conflicts) ? paragraph(do_lang_tempcode('SUCCESS')) : $conflicts;
         regenerate_event_reminder_jobs($id);
     } else {
         $_description = do_lang_tempcode('SUCCESS');
     }
     $this->donext_type = $type;
     $this->donext_date = strval($start_year) . '-' . strval($start_month) . '-' . strval($start_day);
     return $_description;
 }
Example #6
0
 /**
  * Standard aed_module edit actualiser.
  *
  * @param  ID_TEXT		The entry being edited
  */
 function edit_actualisation($id)
 {
     $rows = $GLOBALS['SITE_DB']->query_select('poll', array('is_current', 'submitter', 'num_options'), array('id' => intval($id)), '', 1);
     if (!array_key_exists(0, $rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $is_current = $rows[0]['is_current'];
     $submitter = $rows[0]['submitter'];
     check_edit_permission($is_current == 1 ? 'high' : 'mid', $submitter);
     $question = post_param('question', STRING_MAGIC_NULL);
     $option1 = post_param('option1', STRING_MAGIC_NULL);
     $option2 = post_param('option2', STRING_MAGIC_NULL);
     $option3 = post_param('option3', STRING_MAGIC_NULL);
     $option4 = post_param('option4', STRING_MAGIC_NULL);
     $option5 = post_param('option5', STRING_MAGIC_NULL);
     $option6 = post_param('option6', STRING_MAGIC_NULL);
     $option7 = post_param('option7', STRING_MAGIC_NULL);
     $option8 = post_param('option8', STRING_MAGIC_NULL);
     $option9 = post_param('option9', STRING_MAGIC_NULL);
     $option10 = post_param('option10', STRING_MAGIC_NULL);
     $allow_rating = post_param_integer('allow_rating', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $allow_comments = post_param_integer('allow_comments', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $allow_trackbacks = post_param_integer('allow_trackbacks', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $notes = post_param('notes', STRING_MAGIC_NULL);
     if (fractional_edit()) {
         $num_options = $rows[0]['num_options'];
     } else {
         $num_options = 10;
         if ($option10 == '') {
             $num_options = 9;
         }
         if ($option9 == '') {
             $num_options = 8;
         }
         if ($option8 == '') {
             $num_options = 7;
         }
         if ($option7 == '') {
             $num_options = 6;
         }
         if ($option6 == '') {
             $num_options = 5;
         }
         if ($option5 == '') {
             $num_options = 4;
         }
         if ($option4 == '') {
             $num_options = 3;
         }
         if ($option3 == '') {
             $num_options = 2;
         }
         if ($option2 == '') {
             $num_options = 1;
         }
     }
     $current = post_param_integer('validated', 0);
     if ($current == 1 && $GLOBALS['SITE_DB']->query_value('poll', 'is_current', array('id' => $id)) == 0) {
         $submitter = $GLOBALS['SITE_DB']->query_value('poll', 'submitter', array('id' => $id));
         if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'polls')) {
             syndicate_described_activity('polls:ACTIVITY_ADD_POLL', $question, '', '', '_SEARCH:polls:view:' . strval($id), '', '', 'polls', 1, NULL);
         }
     }
     edit_poll(intval($id), $question, $option1, $option2, $option3, $option4, $option5, $option6, $option7, $option8, $option9, $option10, $num_options, $allow_rating, $allow_comments, $allow_trackbacks, $notes);
     if (!fractional_edit()) {
         if ($current == 1) {
             if ($is_current == 0) {
                 if (!has_specific_permission(get_member(), 'choose_poll')) {
                     log_hack_attack_and_exit('BYPASS_VALIDATION_HACK');
                 }
                 set_poll(intval($id));
             }
         }
     }
 }