Esempio n. 1
0
 /**
  * The actualiser to edit a poll.
  *
  * @return tempcode		The UI
  */
 function _edit_poll()
 {
     $poll_id = get_param_integer('id');
     $topic_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_topics', 'id', array('t_poll_id' => $poll_id));
     if (is_null($topic_id)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $question = post_param('question', STRING_MAGIC_NULL);
     $is_private = post_param_integer('is_private', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $is_open = post_param_integer('is_open', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $minimum_selections = post_param_integer('minimum_selections', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $maximum_selections = post_param_integer('maximum_selections', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $reason = post_param('reason', STRING_MAGIC_NULL);
     $requires_reply = post_param_integer('requires_reply', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     if (fractional_edit()) {
         $answers = collapse_1d_complexity('pa_answer', $GLOBALS['FORUM_DB']->query_select('f_poll_answers', array('pa_answer'), array('pa_poll_id' => $poll_id)));
         foreach ($answers as $i => $answer) {
             $answers[$i] = post_param('answer_' . strval($i), $answer);
         }
     } else {
         $answers = array();
         foreach ($_POST as $key => $val) {
             if (!is_string($val)) {
                 continue;
             }
             if (substr($key, 0, 7) == 'answer_') {
                 if (get_magic_quotes_gpc()) {
                     $val = stripslashes($val);
                 }
                 if ($val != '') {
                     $answers[] = $val;
                 }
             }
         }
     }
     require_code('ocf_polls_action');
     require_code('ocf_polls_action2');
     ocf_edit_poll($poll_id, $question, $is_private, $is_open, $minimum_selections, $maximum_selections, $requires_reply, $answers, $reason);
     return $this->redirect_to('EDIT_TOPIC_POLL', $topic_id);
 }
 /**
  * Standard aed_module edit actualiser.
  *
  * @param  ID_TEXT		The entry being edited
  */
 function edit_actualisation($id)
 {
     ocf_edit_category(intval($id), post_param('title'), post_param('description', STRING_MAGIC_NULL), post_param_integer('expanded_by_default', fractional_edit() ? INTEGER_MAGIC_NULL : 0));
     $this->extra_donext_whatever = array(array('add_one', array('admin_ocf_forums', array('type' => 'ad', 'category_id' => $id), get_module_zone('admin_ocf_forums'))), array('edit_one', array('admin_ocf_forums', array('type' => 'ed'), get_module_zone('admin_ocf_forums'))));
 }
Esempio n. 3
0
 /**
  * Find the posted value from the get_field_inputter field
  *
  * @param  boolean		Whether we were editing (because on edit, it could be a fractional edit)
  * @param  array			The field details
  * @param  string			Where the files will be uploaded to
  * @param  ?string		Former value of field (NULL: none)
  * @return string			The value
  */
 function inputted_to_field_value($editing, $field, $upload_dir = 'uploads/catalogues', $old_value = NULL)
 {
     $id = $field['id'];
     $tmp_name = 'field_' . strval($id);
     if (!fractional_edit()) {
         require_code('uploads');
         $temp = get_url('', $tmp_name, $upload_dir, 0, OCP_UPLOAD_VIDEO);
         $value = $temp[0];
         if ($editing && $value == '' && post_param_integer($tmp_name . '_unlink', 0) != 1) {
             return is_null($old_value) ? '' : $old_value;
         }
         if (!is_null($old_value) && $old_value != '' && ($value != '' || post_param_integer('custom_' . strval($field['id']) . '_value_unlink', 0) == 1)) {
             @unlink(get_custom_file_base() . '/' . rawurldecode($old_value));
             sync_file(rawurldecode($old_value));
         }
     } else {
         $value = STRING_MAGIC_NULL;
     }
     return $value;
 }
Esempio n. 4
0
 /**
  * Standard aed_module edit actualiser.
  *
  * @param  ID_TEXT		The entry being edited
  */
 function edit_actualisation($_id)
 {
     $id = intval($_id);
     $validated = post_param_integer('validated', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $news_article = post_param('post', STRING_MAGIC_NULL);
     if (post_param('main_news_category') != 'personal') {
         $main_news_category = post_param_integer('main_news_category', INTEGER_MAGIC_NULL);
     } else {
         warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
     }
     $news_category = array();
     if (array_key_exists('news_category', $_POST)) {
         foreach ($_POST['news_category'] as $val) {
             $news_category[] = intval($val);
         }
     }
     $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);
     $this->donext_type = $main_news_category;
     if (!fractional_edit()) {
         $urls = get_url('', 'file', 'uploads/grepimages', 0, OCP_UPLOAD_IMAGE);
         $url = $urls[0];
         if ($url != '' && function_exists('imagecreatefromstring')) {
             convert_image(get_base_url() . '/' . $url, get_file_base() . '/uploads/grepimages/' . basename(rawurldecode($url)), -1, -1, intval(get_option('thumb_width')), true, NULL, false, true);
         }
         if ($url == '' && post_param_integer('file_unlink', 0) != 1) {
             $url = NULL;
         }
     } else {
         $url = STRING_MAGIC_NULL;
     }
     $owner = $GLOBALS['SITE_DB']->query_value_null_ok('news_categories', 'nc_owner', array('id' => $main_news_category));
     // null_ok in case somehow category setting corrupted
     if (!is_null($owner) && $owner != get_member()) {
         check_specific_permission('can_submit_to_others_categories', array('news', $main_news_category), NULL, 'cms_news');
     }
     $schedule = get_input_date('schedule');
     $add_time = is_null($schedule) ? mixed() : $schedule;
     if (addon_installed('calendar') && has_specific_permission(get_member(), 'scheduled_publication_times')) {
         require_code('calendar2');
         $schedule_code = ':$GLOBALS[\'SITE_DB\']->query_update(\'news\',array(\'date_and_time\'=>$GLOBALS[\'event_timestamp\'],\'validated\'=>1),array(\'id\'=>' . strval($id) . '),\'\',1);';
         $past_event = $GLOBALS['SITE_DB']->query_value_null_ok('calendar_events e LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'translate t ON e.e_content=t.id', 'e.id', array('text_original' => $schedule_code));
         require_code('calendar');
         if (!is_null($past_event)) {
             delete_calendar_event($past_event);
         }
         if (!is_null($schedule) && $schedule > time()) {
             $validated = 0;
             $start_year = post_param_integer('schedule_year');
             $start_month = post_param_integer('schedule_month');
             $start_day = post_param_integer('schedule_day');
             $start_hour = post_param_integer('schedule_hour');
             $start_minute = post_param_integer('schedule_minute');
             $event_id = add_calendar_event(db_get_first_id(), 'none', NULL, 0, do_lang('PUBLISH_NEWS', 0, post_param('title')), $schedule_code, 3, 0, $start_year, $start_month, $start_day, $start_hour, $start_minute);
             regenerate_event_reminder_jobs($event_id, true);
         }
     }
     $title = post_param('title', STRING_MAGIC_NULL);
     if ($validated == 1 && $main_news_category != INTEGER_MAGIC_NULL && $GLOBALS['SITE_DB']->query_value('news', 'validated', array('id' => intval($id))) == 0) {
         $is_blog = true;
         $submitter = $GLOBALS['SITE_DB']->query_value('news', 'submitter', array('id' => $id));
         $activity_title = $is_blog ? 'news:ACTIVITY_ADD_NEWS_BLOG' : 'news:ACTIVITY_ADD_NEWS';
         $activity_title_validate = $is_blog ? 'news:ACTIVITY_VALIDATE_NEWS_BLOG' : 'news:ACTIVITY_VALIDATE_NEWS';
         if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'news')) {
             // NB: no category permission check, as syndication choice was explicit, and news categorisation is a bit more complex
             syndicate_described_activity($submitter != get_member() ? $activity_title_validate : $activity_title, $title, '', '', '_SEARCH:news:view:' . strval($id), '', '', 'news', 1, NULL, true);
         }
     }
     edit_news(intval($id), $title, post_param('news', STRING_MAGIC_NULL), post_param('author', STRING_MAGIC_NULL), $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes, $news_article, $main_news_category, $news_category, post_param('meta_keywords', STRING_MAGIC_NULL), post_param('meta_description', STRING_MAGIC_NULL), $url, $add_time);
 }
Esempio n. 5
0
 /**
  * Standard aed_module edit actualiser.
  *
  * @param  ID_TEXT		The entry being edited
  */
 function edit_actualisation($id)
 {
     $name = post_param('name', fractional_edit() ? $id : 'root');
     $parent_id = post_param('parent_id', STRING_MAGIC_NULL);
     $accept_images = post_param_integer('accept_images', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $accept_videos = post_param_integer('accept_videos', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $is_member_synched = post_param_integer('is_member_synched', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $flow_mode_interface = post_param_integer('flow_mode_interface', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     if (!fractional_edit()) {
         $urls = get_url('image_url', 'rep_image', 'uploads/grepimages', 0, OCP_UPLOAD_IMAGE);
         $url = $urls[0];
         if ($url == '' && post_param_integer('rep_image_unlink', 0) != 1) {
             $url = NULL;
         }
         $watermark_top_left = get_url('', 'watermark_top_left', 'uploads/watermarks', 0, OCP_UPLOAD_IMAGE);
         if ($watermark_top_left[0] == '' && post_param_integer('watermark_top_left_unlink', 0) != 1) {
             $watermark_top_left[0] = NULL;
         }
         $watermark_top_right = get_url('', 'watermark_top_right', 'uploads/watermarks', 0, OCP_UPLOAD_IMAGE);
         if ($watermark_top_right[0] == '' && post_param_integer('watermark_top_right_unlink', 0) != 1) {
             $watermark_top_right[0] = NULL;
         }
         $watermark_bottom_left = get_url('', 'watermark_bottom_left', 'uploads/watermarks', 0, OCP_UPLOAD_IMAGE);
         if ($watermark_bottom_left[0] == '' && post_param_integer('watermark_bottom_left_unlink', 0) != 1) {
             $watermark_bottom_left[0] = NULL;
         }
         $watermark_bottom_right = get_url('', 'watermark_bottom_right', 'uploads/watermarks', 0, OCP_UPLOAD_IMAGE);
         if ($watermark_bottom_right[0] == '' && post_param_integer('watermark_bottom_right_unlink', 0) != 1) {
             $watermark_bottom_right[0] = NULL;
         }
     } else {
         $url = STRING_MAGIC_NULL;
         $watermark_top_left = STRING_MAGIC_NULL;
         $watermark_top_right = STRING_MAGIC_NULL;
         $watermark_bottom_left = STRING_MAGIC_NULL;
         $watermark_bottom_right = 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);
     $g_owner_name = post_param('g_owner', NULL);
     if (is_null($g_owner_name)) {
         $g_owner = $GLOBALS['SITE_DB']->query_value('galleries', 'g_owner', array('name' => $name));
     } else {
         $g_owner = $GLOBALS['FORUM_DRIVER']->get_member_from_username($g_owner_name);
     }
     if (fractional_edit()) {
         $g_owner = INTEGER_MAGIC_NULL;
     }
     edit_gallery($id, $name, post_param('fullname'), post_param('description', STRING_MAGIC_NULL), post_param('teaser', STRING_MAGIC_NULL), post_param('notes', STRING_MAGIC_NULL), $parent_id, $accept_images, $accept_videos, $is_member_synched, $flow_mode_interface, $url, $watermark_top_left[0], $watermark_top_right[0], $watermark_bottom_left[0], $watermark_bottom_right[0], post_param('meta_keywords', STRING_MAGIC_NULL), post_param('meta_description', STRING_MAGIC_NULL), $allow_rating, $allow_comments, $g_owner);
     $this->new_id = $name;
     if (!fractional_edit()) {
         $this->set_permissions($name);
     }
 }
Esempio n. 6
0
 /**
  * Standard aed_module edit actualiser.
  *
  * @param  ID_TEXT		The entry being edited
  */
 function edit_actualisation($old_name)
 {
     require_code('catalogues2');
     $name = post_param('name', $old_name);
     $title = post_param('title', STRING_MAGIC_NULL);
     $description = post_param('description', STRING_MAGIC_NULL);
     $display_type = post_param_integer('display_type', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $notes = post_param('notes', STRING_MAGIC_NULL);
     $submit_points = post_param_integer('submit_points', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $ecommerce = post_param_integer('ecommerce', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $send_view_reports = post_param('send_view_reports', STRING_MAGIC_NULL);
     if (!fractional_edit()) {
         if (post_param_integer('reset_category_permissions', 0) == 1) {
             if (function_exists('set_time_limit')) {
                 @set_time_limit(0);
             }
             $start = 0;
             do {
                 $rows = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('id'), array('c_name' => $name), '', 300, $start);
                 foreach ($rows as $row) {
                     $this->set_permissions(strval($row['id']));
                 }
                 $start += 300;
             } while (array_key_exists(0, $rows));
         }
     }
     $was_tree = $GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_is_tree', array('c_name' => $old_name));
     if (is_null($was_tree)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $is_tree = post_param_integer('is_tree', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     if (!fractional_edit()) {
         // What fields do we have?
         $old = array();
         $new = array();
         foreach ($_POST as $key => $val) {
             if (!is_string($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;
             } elseif (preg_match('#existing\\_field\\_(\\d+)\\_(.*)#A', $key, $matches) != 0) {
                 $old[$matches[1]][$matches[2]] = $val;
             }
         }
         $num_fields = 0;
         foreach ($new as $field) {
             if ($field['name'] != '') {
                 $num_fields++;
             }
         }
         foreach ($old as $field) {
             if (!(array_key_exists('delete', $field) && $field['delete'] == '1')) {
                 $num_fields++;
             }
         }
         if ($num_fields == 0) {
             warn_exit(do_lang_tempcode('NO_FIELDS'));
         }
     }
     if ($is_tree == 1 && $was_tree == 0) {
         catalogue_to_tree($name);
     }
     if ($is_tree == 0 && $was_tree == 1) {
         catalogue_from_tree($name);
     }
     $this->is_tree_catalogue = $is_tree == 1;
     actual_edit_catalogue($old_name, $name, $title, $description, $display_type, $notes, $submit_points, $ecommerce, $send_view_reports);
     $this->new_id = $name;
     if (!fractional_edit()) {
         // Now onto the fields
         //  First we must rationalise the ordering
         $o = 0;
         $orderings = array();
         foreach ($new as $current) {
             if (!array_key_exists('default', $current)) {
                 warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
             }
             if (!array_key_exists('description', $current)) {
                 warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
             }
             if (!array_key_exists('name', $current)) {
                 warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
             }
             if (!array_key_exists('order', $current)) {
                 warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
             }
             if (!array_key_exists('type', $current) || $current['type'] == '') {
                 warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
             }
             if ($current['name'] != '') {
                 if (!array_key_exists('order', $current) || $current['order'] == '') {
                     $current['order'] = strval(count($new) + count($old));
                 }
                 $orderings['new_' . strval($o)] = $current['order'];
             }
             $o++;
         }
         $o = 0;
         foreach ($old as $current) {
             if (!(array_key_exists('delete', $current) && $current['delete'] == '1')) {
                 if (!array_key_exists('order', $current) || $current['order'] == '') {
                     $current['order'] = strval(count($new) + count($old));
                 }
                 $orderings['old_' . strval($o)] = $current['order'];
             }
             $o++;
         }
         asort($orderings);
         //  Now add/edit them
         $o = 0;
         foreach ($new as $field) {
             $p = 0;
             foreach (array_keys($orderings) as $key) {
                 if ($key == 'new_' . strval($o)) {
                     $order = $p;
                 }
                 $p++;
             }
             $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'], $order, $defines_order, $visible, $searchable, $field['default'], $required, $put_in_category, $put_in_search);
             }
             $o++;
         }
         $o = 0;
         foreach ($old as $id => $field) {
             if (array_key_exists('delete', $field) && $field['delete'] == '1') {
                 actual_delete_catalogue_field($id);
             } else {
                 $p = 0;
                 foreach (array_keys($orderings) as $key) {
                     if ($key == 'old_' . strval($o)) {
                         $order = $p;
                     }
                     $p++;
                 }
                 $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;
                 $field_type = array_key_exists('type', $field) ? $field['type'] : NULL;
                 actual_edit_catalogue_field($id, $name, $field['name'], $field['description'], $order, $defines_order, $visible, $searchable, $field['default'], $required, $put_in_category, $put_in_search, $field_type);
             }
             $o++;
         }
     }
     // Do this last as it causes a main_sitemap decache which can cause memory errors if we do a warn_exit (i.e. we want the warn_exit's before this)
     if (!fractional_edit()) {
         $this->set_permissions($name);
     }
 }
Esempio n. 7
0
 /**
  * Find the posted value from the get_field_inputter field
  *
  * @param  boolean		Whether we were editing (because on edit, it could be a fractional edit)
  * @param  array			The field details
  * @param  string			Where the files will be uploaded to
  * @param  ?string		Former value of field (NULL: none)
  * @return string			The value
  */
 function inputted_to_field_value($editing, $field, $upload_dir = 'uploads/catalogues', $old_value = NULL)
 {
     $default = $field['cf_default'];
     $list = explode('|', $default);
     if (fractional_edit()) {
         return $editing ? STRING_MAGIC_NULL : '';
     }
     $id = $field['id'];
     $value = '';
     foreach ($list as $i => $l) {
         $tmp_name = 'field_' . strval($id) . '_' . strval($i);
         if (post_param_integer($tmp_name, 0) == 1) {
             if ($value != '') {
                 $value .= chr(10);
             }
             $value .= $l;
         }
     }
     return $value;
 }
Esempio n. 8
0
 /**
  * Standard aed_module edit actualiser.
  *
  * @param  ID_TEXT		The entry being edited
  */
 function edit_actualisation($id)
 {
     require_code('themes2');
     $title = post_param('title');
     $img = get_theme_img_code('newscats', STRING_MAGIC_NULL);
     $notes = post_param('notes', STRING_MAGIC_NULL);
     $_owner = post_param('owner', fractional_edit() ? STRING_MAGIC_NULL : NULL);
     $owner = is_null($_owner) ? NULL : $GLOBALS['FORUM_DRIVER']->get_member_from_username($_owner);
     edit_news_category(intval($id), $title, $img, $notes, $owner);
     $this->set_permissions(intval($id));
 }
Esempio n. 9
0
 /**
  * Standard aed_module edit actualiser.
  *
  * @param  ID_TEXT		The entry being edited
  */
 function edit_actualisation($id)
 {
     require_code('themes2');
     edit_event_type(intval($id), post_param('title'), get_theme_img_code('calendar'), post_param('external_feed'));
     if (!fractional_edit()) {
         $this->set_permissions($id);
     }
 }
Esempio n. 10
0
 /**
  * Standard aed_module edit actualiser.
  *
  * @param  ID_TEXT		The entry being edited
  */
 function edit_actualisation($id)
 {
     ocf_edit_forum(intval($id), post_param('name'), post_param('description', STRING_MAGIC_NULL), post_param_integer('category_id', INTEGER_MAGIC_NULL), post_param_integer('parent_forum', INTEGER_MAGIC_NULL), post_param_integer('position', INTEGER_MAGIC_NULL), post_param_integer('post_count_increment', fractional_edit() ? INTEGER_MAGIC_NULL : 0), post_param_integer('order_sub_alpha', fractional_edit() ? INTEGER_MAGIC_NULL : 0), post_param('intro_question', STRING_MAGIC_NULL), post_param('intro_answer', STRING_MAGIC_NULL), post_param('redirection', STRING_MAGIC_NULL), post_param('order', STRING_MAGIC_NULL), post_param_integer('is_threaded', fractional_edit() ? INTEGER_MAGIC_NULL : 0), post_param_integer('reset_intro_acceptance', 0) == 1);
     if (!fractional_edit()) {
         require_code('ocf_groups2');
         $old_access_mapping = collapse_1d_complexity('group_id', $GLOBALS['FORUM_DB']->query_select('group_category_access', array('group_id'), array('module_the_name' => 'forums', 'category_name' => $id)));
         require_code('ocf_groups_action');
         require_code('ocf_groups_action2');
         $lost_groups = array();
         foreach ($old_access_mapping as $group_id) {
             if (post_param_integer('access_' . strval($group_id), 0) == 0) {
                 // Lost access
                 $lost_groups[] = $group_id;
             }
         }
         $this->set_permissions($id);
     }
 }
Esempio n. 11
0
/**
 * Situation: something that may have awards has just been added/edited. Action: add any specified awards.
 *
 * @param  ID_TEXT		The content type
 * @param  ID_TEXT		The content ID
 */
function handle_award_setting($content_type, $id)
{
    if (fractional_edit()) {
        return;
    }
    $rows = $GLOBALS['SITE_DB']->query_select('award_types', array('*'), array('a_content_type' => $content_type));
    foreach ($rows as $row) {
        if (has_category_access(get_member(), 'award', strval($row['id']))) {
            $test = $GLOBALS['SITE_DB']->query_value_null_ok('award_archive', 'content_id', array('a_type_id' => $row['id']), 'ORDER BY date_and_time DESC');
            $has_award = !is_null($test) && $test === $id;
            $will_have_award = post_param_integer('award_' . strval($row['id']), 0) == 1;
            if ($will_have_award && $has_award) {
                decache('main_awards');
            }
            if ($will_have_award && !$has_award) {
                give_award($row['id'], $id);
            } elseif (!$will_have_award && $has_award) {
                $GLOBALS['SITE_DB']->query_delete('award_archive', array('a_type_id' => $row['id'], 'content_id' => strval($id)), '', 1);
            }
            // Otherwise we're happy with the current situation (regardless of whether it is set or unset)
        }
    }
}
Esempio n. 12
0
/**
 * Save custom fields to a content item.
 *
 * @param  ID_TEXT		Award hook codename
 * @param  ID_TEXT		Content entry ID
 */
function save_form_custom_fields($content_type, $id)
{
    if (fractional_edit()) {
        return;
    }
    $existing = get_bound_content_entry($content_type, $id);
    require_code('catalogues');
    // Get field values
    $fields = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('*'), array('c_name' => '_' . $content_type), 'ORDER BY cf_order');
    $map = array();
    require_code('fields');
    foreach ($fields as $field) {
        $ob = get_fields_hook($field['cf_type']);
        list(, , $storage_type) = $ob->get_field_value_row_bits($field);
        $value = $ob->inputted_to_field_value(!is_null($existing), $field, 'uploads/catalogues', is_null($existing) ? NULL : _get_catalogue_entry_field($field['id'], $existing, $storage_type));
        $map[$field['id']] = $value;
    }
    $first_cat = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'MIN(id)', array('c_name' => '_' . $content_type));
    require_code('catalogues2');
    if (!is_null($existing)) {
        actual_edit_catalogue_entry($existing, $first_cat, 1, '', 0, 0, 0, $map);
    } else {
        $catalogue_entry_id = actual_add_catalogue_entry($first_cat, 1, '', 0, 0, 0, $map);
        $GLOBALS['SITE_DB']->query_insert('catalogue_entry_linkage', array('catalogue_entry_id' => $catalogue_entry_id, 'content_type' => $content_type, 'content_id' => $id));
    }
}
Esempio n. 13
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));
             }
         }
     }
 }