Esempio n. 1
0
 function setUp()
 {
     parent::setUp();
     require_code('calendar2');
     $this->event_id = add_calendar_event(8, '1', NULL, 0, 'test_event', '', 3, 1, 2010, 1, 10, 10, 15, 2010, NULL, 1, 1, 19, NULL, 1, 1, 1, 1, 1, '', NULL, 0, NULL, NULL, NULL);
     // Test the forum was actually created
     $this->assertTrue('test_event' == get_translated_text($GLOBALS['SITE_DB']->query_value('calendar_events', 'e_title ', array('id' => $this->event_id))));
 }
Esempio n. 2
0
 function setUp()
 {
     parent::setUp();
     require_code('calendar2');
     require_code('feedback');
     $this->event_id = add_calendar_event(8, '1', NULL, 0, 'test_event', '', 3, 1, 2010, 1, 10, 10, 15, 2010, NULL, 1, 1, 19, NULL, 1, 1, 1, 1, 1, '', NULL, 0, NULL, NULL, NULL);
     if ('test_event' == get_translated_text($GLOBALS['SITE_DB']->query_value('calendar_events', 'e_title ', array('id' => $this->event_id)))) {
         $GLOBALS['SITE_DB']->query_insert('rating', array('rating_for_type' => 'events', 'rating_for_id' => $this->event_id, 'rating_member' => get_member(), 'rating_ip' => get_ip_address(), 'rating_time' => time(), 'rating' => 4));
     }
     $data = $GLOBALS['SITE_DB']->query_select('rating', array('rating '), array('rating_for_id' => $this->event_id, 'rating_member' => get_member()));
     $rating = $data[0]['rating'];
     // Test the forum was actually created
     $this->assertTrue(4 == $rating);
 }
Esempio n. 3
0
 function setUp()
 {
     parent::setUp();
     require_code('calendar2');
     require_code('feedback');
     require_code('ocf_posts_action');
     require_code('ocf_forum_driver_helper');
     require_lang('lang');
     $this->event_id = add_calendar_event(8, '1', NULL, 0, 'test_event', '', 3, 1, 2010, 1, 10, 10, 15, 2010, NULL, 1, 1, 19, NULL, 1, 1, 1, 1, 1, '', NULL, 0, NULL, NULL, NULL);
     if ('test_event' == get_translated_text($GLOBALS['SITE_DB']->query_value('calendar_events', 'e_title ', array('id' => $this->event_id)))) {
         $lang_id = insert_lang_comcode('test_comment_desc_1', 4, $GLOBALS['FORUM_DB']);
         $map = array('p_title' => 'test_comment1', 'p_post' => $lang_id, 'p_ip_address' => '127.0.0.1', 'p_time' => time(), 'p_poster' => 0, 'p_poster_name_if_guest' => '', 'p_validated' => 1, 'p_topic_id' => 4, 'p_is_emphasised' => 0, 'p_cache_forum_id' => 4, 'p_last_edit_time' => NULL, 'p_last_edit_by' => NULL, 'p_intended_solely_for' => NULL, 'p_skip_sig' => 0, 'p_parent_id' => NULL);
         $this->post_id = $GLOBALS['FORUM_DB']->query_insert('f_posts', $map, true);
     }
     $rows = $GLOBALS['FORUM_DB']->query('SELECT p_title FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'f_posts p LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'translate t ON t.id=p.p_post WHERE t.text_original NOT LIKE \'%' . db_encode_like(do_lang('SPACER_POST_MATCHER', '', '', '', get_site_default_lang()) . '%') . '\' AND ( p.id = ' . strval($this->post_id) . ') ORDER BY p.id');
     $title = $rows[0]['p_title'];
     // Test the forum was actually created
     $this->assertTrue('test_comment1' == $title);
 }
Esempio n. 4
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_calendar($db, $table_prefix, $file_base)
 {
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'calendar');
     foreach ($rows as $row) {
         if (import_check_if_imported('event', strval($row['event_id']))) {
             continue;
         }
         $submitter = import_id_remap_get('member', strval($row['user_id']), true);
         if (is_null($submitter)) {
             $submitter = $GLOBALS['OCF_DRIVER']->get_guest_id();
         }
         $recurrence = 'none';
         $recurrences = NULL;
         if ($row['event_recurrence'] == 1) {
             $bits = explode('|', $row['event_recurrence_settings']);
             // $num_units, $every, $days_of_week (e.g. 1,2,5 (sunday is 0)), $which_week, $recurrence_ends
             if ($bits[3] == 'd' || $bits[3] == 'l') {
                 $bits[3] = '1';
             }
             $recurrence_part = str_repeat('0', intval($bits[3]) - 1) . '1';
             switch ($bits[1]) {
                 case 'd':
                     $recurrence = 'daily';
                     if ($bits[4] != '') {
                         $recurrences = (strtotime($bits[4]) - strtotime($row['event_start'])) / (60 * 60 * 24 * $bits[0] * (is_numeric($bits[3]) ? intval($bits[3]) : 1));
                     }
                     break;
                 case 'w':
                     if ($bits[2] == '') {
                         $recurrence = 'weekly';
                     } else {
                         $days = explode(',', $bits[2]);
                         $string = '0000000';
                         foreach ($days as $day) {
                             $string[$day] = '1';
                         }
                         $recurrence = 'weekly';
                         $recurrence_part = str_repeat('0000000', intval($bits[3]) - 1) . $string;
                     }
                     if ($bits[4] != '') {
                         $recurrences = (strtotime($bits[4]) - strtotime($row['event_start'])) / (60 * 60 * 24 * 7 * $bits[0] * (is_numeric($bits[3]) ? intval($bits[3]) : 1));
                     }
                     break;
                 case 'm':
                     $recurrence = 'monthly';
                     if ($bits[4] != '') {
                         $recurrences = (strtotime($bits[4]) - strtotime($row['event_start'])) / (60 * 60 * 24 * 32 * $bits[0] * (is_numeric($bits[3]) ? intval($bits[3]) : 1));
                     }
                     break;
                 case 'y':
                     $recurrence = 'yearly';
                     if ($bits[4] != '') {
                         $recurrences = (strtotime($bits[4]) - strtotime($row['event_start'])) / (60 * 60 * 24 * 365 * $bits[0] * (is_numeric($bits[3]) ? intval($bits[3]) : 1));
                     }
                     break;
             }
             $string = str_pad('', strlen($recurrence_part) * intval($bits[0]));
             for ($i = 0; $i < strlen($string); $i++) {
                 $string[$i] = $recurrence_part[$i / intval($bits[0])];
             }
             $recurrence .= ' ' . $string;
         }
         list($start_year, $start_month, $start_day, $start_hour, $start_minute) = explode('-', date('Y-m-d-h-i', strtotime($row['event_start'])));
         list($end_year, $end_month, $end_day, $end_hour, $end_minute) = explode('-', date('Y-m-d-h-i', strtotime($row['event_end'])));
         $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, intval(floor($recurrences)), 0, $row['event_title'], $row['event_note'], 3, $row['event_public'], $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, NULL, 1, $submitter, 0, strtotime($row['event_start']));
         import_id_remap_put('event', strval($row['event_id']), $id_new);
     }
 }
Esempio n. 5
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_calendar($db, $table_prefix, $file_base)
 {
     require_code('calendar2');
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'event');
     foreach ($rows as $row) {
         if (import_check_if_imported('event', strval($row['eventid']))) {
             continue;
         }
         $submitter = import_id_remap_get('member', strval($row['userid']), true);
         if (is_null($submitter)) {
             $submitter = $GLOBALS['OCF_DRIVER']->get_guest_id();
         }
         $recurrence = 'none';
         $recurrences = NULL;
         $bits = explode('|', $row['recuroption']);
         switch ($row['recurring']) {
             case 1:
                 $recurrence = 'daily ' . str_repeat('0', intval($bits[0]) - 1) . '1';
                 break;
             case 2:
                 $recurrence = 'daily 1111100';
                 break;
             case 3:
                 $recurrence = 'daily 0000000';
                 if (($bits[1] & 1) != 0) {
                     $recurrence[6] = '1';
                 }
                 if (($bits[1] & 2) != 0) {
                     $recurrence[7] = '1';
                 }
                 if (($bits[1] & 4) != 0) {
                     $recurrence[8] = '1';
                 }
                 if (($bits[1] & 8) != 0) {
                     $recurrence[9] = '1';
                 }
                 if (($bits[1] & 16) != 0) {
                     $recurrence[10] = '1';
                 }
                 if (($bits[1] & 32) != 0) {
                     $recurrence[11] = '1';
                 }
                 if (($bits[1] & 64) != 0) {
                     $recurrence[12] = '1';
                 }
                 $recurrences = $bits[0];
                 // Guess
                 break;
             case 4:
                 $recurrence = 'monthly ' . str_repeat('0', intval($bits[1]) - 1) . '1';
                 break;
             case 5:
                 $recurrence = 'monthly ' . str_repeat('0', intval($bits[0]) - 1) . '1';
                 break;
             case 6:
                 $recurrence = 'yearly ' . str_repeat('0', intval($bits[0]) - 1) . '1';
                 break;
             case 7:
                 $recurrence = 'yearly ' . str_repeat('0', intval($bits[0]) - 1) . '1';
                 break;
         }
         list($start_year, $start_month, $start_day, $start_hour, $start_minute) = explode('-', date('Y-m-d-h-i', strtotime($row['dateline'])));
         list($end_year, $end_month, $end_day, $end_hour, $end_minute) = array(NULL, NULL, NULL, NULL, NULL);
         ocf_over_msn();
         $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, $recurrences, 0, $row['title'], $row['event'], 3, $row['visible'], $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, NULL, 1, $submitter, 0, $row['dateline']);
         ocf_over_local();
         import_id_remap_put('event', strval($row['eventid']), $id_new);
     }
 }
Esempio n. 6
0
 /**
  * The actualiser to send a newsletter.
  *
  * @return tempcode		The UI
  */
 function send_message()
 {
     $title = get_page_title('NEWSLETTER_SEND');
     $lang = choose_language($title);
     if (is_object($lang)) {
         return $lang;
     }
     if (get_param('old_type', '') == 'whatsnew') {
         set_value('newsletter_whatsnew', strval(time()));
     }
     $message = post_param('message');
     $subject = post_param('subject');
     $csv_data = post_param('csv_data', '');
     // serialized PHP array
     $template = post_param('template', 'MAIL');
     $in_full = post_param_integer('in_full', 0);
     $html_only = post_param_integer('html_only', 0);
     $from_email = post_param('from_email', '');
     $from_name = post_param('from_name', '');
     $priority = post_param_integer('priority', 3);
     $newsletters = $GLOBALS['SITE_DB']->query_select('newsletters', array('id'));
     $send_details = array();
     foreach ($newsletters as $newsletter) {
         $send_details[strval($newsletter['id'])] = post_param_integer(strval($newsletter['id']), 0);
     }
     if (get_forum_type() == 'ocf') {
         $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list();
         foreach (array_keys($groups) as $id) {
             $send_details['g' . strval($id)] = post_param_integer('g' . strval($id), 0);
         }
         $send_details['-1'] = post_param_integer('-1', 0);
     }
     if (post_param_integer('make_periodic', 0) == 1) {
         // We're a periodic newsletter, so we don't actually want to be sent
         // out now. Rather, we store the newsletter settings so that it can be
         // regenerated as needed.
         // Next we store all of our settings in the newsletter_periodic table
         $when = post_param('periodic_when');
         $day = 1;
         if ($when == 'monthly') {
             $day = post_param_integer('periodic_monthly') % 29;
         } elseif ($when == 'biweekly') {
             $day = post_param_integer('periodic_weekday_biweekly', 5);
         } elseif ($when == 'weekly') {
             $day = post_param_integer('periodic_weekday_weekly', 5);
         }
         $map = array('np_message' => post_param('chosen_categories', ''), 'np_subject' => $subject, 'np_lang' => $lang, 'np_send_details' => serialize($send_details), 'np_html_only' => $html_only, 'np_from_email' => $from_email, 'np_from_name' => $from_name, 'np_priority' => $priority, 'np_csv_data' => $csv_data, 'np_frequency' => $when, 'np_day' => $day, 'np_in_full' => $in_full, 'np_template' => $template);
         require_lang('dates');
         $week_days = array(1 => do_lang('MONDAY'), 2 => do_lang('TUESDAY'), 3 => do_lang('WEDNESDAY'), 4 => do_lang('THURSDAY'), 5 => do_lang('FRIDAY'), 6 => do_lang('SATURDAY'), 7 => do_lang('SUNDAY'));
         if ($when == 'weekly') {
             $each = $week_days[$day];
         } elseif ($when == 'biweekly') {
             $each = $week_days[$day];
         } else {
             $suffix = gmdate('S', gmmktime(0, 0, 0, 1, $day, 1990));
             $each = strval($day) . $suffix;
         }
         $matches = array();
         if (preg_match('#^replace_existing\\_(\\d+)$#', post_param('periodic_choice', ''), $matches) != 0) {
             if (post_param('periodic_for') != 'future') {
                 $map['np_last_sent'] = 0;
             }
             $GLOBALS['SITE_DB']->query_update('newsletter_periodic', $map, array('id' => intval($matches[1])), '', 1);
             $message = do_lang('PERIODIC_SUCCESS_MESSAGE_EDIT', $when, $each);
         } else {
             $last_sent = post_param('periodic_for') == 'future' ? time() : 0;
             $map['np_last_sent'] = $last_sent;
             $GLOBALS['SITE_DB']->query_insert('newsletter_periodic', $map, true);
             $message = do_lang('PERIODIC_SUCCESS_MESSAGE_ADD', $when, $each);
         }
         $url = build_url(array('page' => 'admin_newsletter', 'type' => 'misc', 'redirected' => '1'), get_module_zone('admin_newsletter'));
         return redirect_screen(do_lang('SUCCESS'), $url, $message, false, 'inform');
     }
     if (addon_installed('calendar')) {
         $schedule = get_input_date('schedule');
         if (!is_null($schedule)) {
             require_code('calendar');
             require_code('calendar2');
             $send_details_string_exp = '';
             foreach ($send_details as $key => $val) {
                 $send_details_string_exp .= '"' . str_replace(chr(10), '\\n', addslashes($key)) . '"=>"' . str_replace(chr(10), '\\n', addslashes($val)) . '",';
             }
             $schedule_code = ':require_code(\'newsletter\'); actual_send_newsletter("' . php_addslashes($message) . '","' . php_addslashes($subject) . '","' . php_addslashes($lang) . '",array(' . $send_details_string_exp . '),' . strval($html_only) . ',"' . php_addslashes($from_email) . '","' . php_addslashes($from_name) . '",' . strval($priority) . ',"' . php_addslashes($template) . '");';
             $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(), '', NULL, 0, do_lang('NEWSLETTER_SEND', $subject), $schedule_code, 3, 0, $start_year, $start_month, $start_day, $start_hour, $start_minute);
             regenerate_event_reminder_jobs($event_id);
             return inform_screen($title, do_lang_tempcode('NEWSLETTER_DEFERRED', get_timezoned_date($schedule)));
         }
     }
     actual_send_newsletter($message, $subject, $lang, $send_details, $html_only, $from_email, $from_name, $priority, $csv_data, $template);
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_NEWSLETTER')), array('_SELF:_SELF:new', do_lang_tempcode('NEWSLETTER_SEND'))));
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     return inform_screen($title, do_lang_tempcode('SENDING_NEWSLETTER'));
 }
Esempio n. 7
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_calendar($db, $table_prefix, $file_base)
 {
     require_code('calendar2');
     $rows = $db->query_select('calendar');
     foreach ($rows as $row) {
         if (import_check_if_imported('event', strval($row['id_event']))) {
             continue;
         }
         $submitter = import_id_remap_get('member', strval($row['id_member']), true);
         if (is_null($submitter)) {
             $submitter = $GLOBALS['OCF_DRIVER']->get_guest_id();
         }
         $recurrence = 'none';
         $recurrences = NULL;
         $days = intval(floor((strtotime($row['end_date']) - strtotime($row['start_date'])) / (60 * 60 * 24)));
         //Max 7 days in SMF
         if ($days == 0) {
             $recurrence = 'none';
         } else {
             $recurrence = 'daily ';
             for ($i = 1; $i <= $days; $i++) {
                 $recurrence .= '1';
             }
         }
         list($start_year, $start_month, $start_day, $start_hour, $start_minute) = array_map('intval', explode('-', date('Y-m-d-h-i', strtotime($row['start_date']))));
         list($end_year, $end_month, $end_day, $end_hour, $end_minute) = array_map('intval', explode('-', date('Y-m-d-h-i', strtotime($row['end_date']))));
         $description = '';
         if ($row['id_topic'] != 0) {
             $atts = $db->query('SELECT * FROM ' . $table_prefix . 'attachments WHERE id_msg=' . strval($row['id_topic']) . ' ORDER BY id_msg ASC');
             $attid = isset($atts[0]['id_attach']) ? $atts[0]['id_attach'] : 0;
             $att_imported = $attid > 0 && import_check_if_imported('post_files', strval($attid)) ? true : false;
             $messages = $db->query('SELECT * FROM ' . $table_prefix . 'messages WHERE id_topic=' . strval($row['id_topic']) . ' ORDER BY id_topic ASC');
             $description = isset($messages[0]['body']) && $messages[0]['body'] != '' ? str_replace(array('[html]', '[/html]'), array('', ''), html_to_comcode($messages[0]['body'])) : '';
         }
         if ($att_imported) {
             $attid_new = import_id_remap_get('post_files', strval($attid), true);
             $description .= "\n\n" . '[attachment]' . strval($attid_new) . '[/attachment]';
         }
         $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, $recurrences, 0, $row['title'], $description, 3, 1, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, NULL, 1, 1, 1, 1, 1, '', $submitter);
         if ($att_imported) {
             $GLOBALS['SITE_DB']->query_insert('attachment_refs', array('r_referer_type' => 'calendar', 'r_referer_id' => strval($id_new), 'a_id' => $attid_new));
         }
         import_id_remap_put('event', strval($row['id_event']), $id_new);
     }
     $rows = array();
     $rows = $db->query_select('calendar_holidays');
     foreach ($rows as $row) {
         if (import_check_if_imported('event_holiday', strval($row['id_holiday']))) {
             continue;
         }
         $submitter = $GLOBALS['OCF_DRIVER']->get_guest_id();
         $recurrence = 'none';
         $recurrences = NULL;
         list($start_year, $start_month, $start_day, $start_hour, $start_minute) = array_map('intval', explode('-', date('Y-m-d-h-i', strtotime($row['event_date']))));
         list($end_year, $end_month, $end_day, $end_hour, $end_minute) = array_map('intval', explode('-', date('Y-m-d-h-i', strtotime($row['event_date']))));
         $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, $recurrences, 0, $row['title'], $row['title'], 3, 1, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, NULL, 1, 1, 1, 1, 1, '', $submitter);
         import_id_remap_put('event_holiday', strval($row['id_holiday']), $id_new);
     }
 }
Esempio n. 8
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_calendar($db, $table_prefix, $file_base)
 {
     require_code('calendar2');
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'calendar_types', NULL, NULL, true);
     if (is_null($rows)) {
         return;
     }
     foreach ($rows as $row) {
         if ($row['id'] == db_get_first_id()) {
             import_id_remap_put('event_type', strval($row['id']), db_get_first_id());
             continue;
         }
         if (import_check_if_imported('event_type', strval($row['id']))) {
             continue;
         }
         $id_new = add_event_type($this->get_lang_string($db, $row['t_title']), $row['t_logo'], array_key_exists('t_external_feed', $row) ? $row['t_external_feed'] : '');
         import_id_remap_put('event_type', strval($row['id']), $id_new);
     }
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'calendar_interests', NULL, NULL, true);
     if (is_null($rows)) {
         $rows = $db->query('SELECT * FROM ' . $table_prefix . 'calendar_declarations_of_interest');
     }
     $on_same_msn = $this->on_same_msn($file_base);
     foreach ($rows as $row) {
         $member = $on_same_msn ? $row['i_member_id'] : import_id_remap_get('member', $row['i_member_id'], true);
         if (is_null($member)) {
             continue;
         }
         $type = import_id_remap_get('event_type', strval($row['t_type']), true);
         if (is_null($type)) {
             continue;
         }
         $GLOBALS['SITE_DB']->query_delete('calendar_interests', array('i_member_id' => $member, 't_type' => $type), '', 1);
         $GLOBALS['SITE_DB']->query_insert('calendar_interests', array('i_member_id' => $member, 't_type' => $type));
     }
     $event_rows = $db->query('SELECT * FROM ' . $table_prefix . 'calendar_events ORDER BY id');
     foreach ($event_rows as $row) {
         if (import_check_if_imported('event', strval($row['id']))) {
             continue;
         }
         $submitter = $on_same_msn ? $row['e_submitter'] : import_id_remap_get('member', strval($row['e_submitter']), true);
         if (is_null($submitter)) {
             $submitter = $GLOBALS['FORUM_DRIVER']->get_guest_id();
         }
         $type = import_id_remap_get('event_type', strval($row['e_type']), true);
         if (is_null($type)) {
             continue;
         }
         if (!array_key_exists('validated', $row)) {
             $row['validated'] = 1;
         }
         if (!array_key_exists('notes', $row)) {
             $row['notes'] = '';
         }
         if (!array_key_exists('allow_rating', $row)) {
             $row['allow_rating'] = 1;
         }
         if (!array_key_exists('allow_comments', $row)) {
             $row['allow_comments'] = 1;
         }
         if (!array_key_exists('allow_trackbacks', $row)) {
             $row['allow_trackbacks'] = 1;
         }
         $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $row['id'];
         $id_new = add_calendar_event($type, $row['e_recurrence'], $row['e_recurrences'], array_key_exists('e_seg_recurrences', $row) ? $row['e_seg_recurrences'] : 0, $this->get_lang_string($db, $row['e_title']), $this->get_lang_string($db, $row['e_content']), $row['e_priority'], $row['e_is_public'], $row['e_start_year'], $row['e_start_month'], $row['e_start_day'], $row['e_start_hour'], $row['e_start_minute'], $row['e_end_year'], $row['e_end_month'], $row['e_end_day'], $row['e_end_hour'], $row['e_end_minute'], array_key_exists('e_timezone', $row) ? $row['e_timezone'] : NULL, array_key_exists('e_do_timezone_conv', $row) ? $row['e_do_timezone_conv'] : 1, $row['validated'], $row['allow_rating'], $row['allow_comments'], $row['allow_trackbacks'], $row['notes'], $submitter, $row['e_views'], $row['e_add_date'], $row['e_edit_date'], $id);
         import_id_remap_put('event', strval($row['id']), $id_new);
     }
     $this->_import_review_supplement($db, $table_prefix, 'events', 'event');
     $this->_import_catalogue_entry_linkage($db, $table_prefix, 'event', 'event');
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'calendar_reminders');
     foreach ($rows as $row) {
         $event = import_id_remap_get('event', strval($row['e_id']), true);
         if (is_null($event)) {
             continue;
         }
         $member = $on_same_msn ? $row['n_member_id'] : import_id_remap_get('member', strval($row['n_member_id']), true);
         if (is_null($member)) {
             continue;
         }
         $GLOBALS['SITE_DB']->query_insert('calendar_reminders', array('e_id' => $event, 'n_member_id' => $member, 'n_seconds_before' => $row['n_seconds_before']));
     }
     require_code('calendar');
     foreach ($event_rows as $row) {
         regenerate_event_reminder_jobs(import_id_remap_get('event', strval($row['id'])));
     }
 }
Esempio n. 9
0
    /**
     * The actualiser to add a reply.
     *
     * @return tempcode		The UI
     */
    function _add_reply()
    {
        if (addon_installed('captcha')) {
            require_code('captcha');
            enforce_captcha();
        }
        require_code('attachments2');
        require_code('ocf_posts_action');
        require_code('ocf_posts_action2');
        $invited_members = array();
        $topic_id = either_param_integer('topic_id', -1);
        // Posting into an existing topic?
        $forum_id = post_param_integer('forum_id', -1);
        // New topic in existing forum? (NB: -2 represents reported posts forum)
        $member_id = post_param_integer('member_id', -1);
        // Send TOPIC to specific member? Could be Private Topic (topic_id==-1, forum_id==-1), or personal post (topic_id!=-1, forum_id==-1)
        $parent_id = either_param_integer('parent_id', NULL);
        if ($member_id == -1) {
            $member_username = post_param('to_member_id_0', '');
            if ($member_username != '') {
                $member_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($member_username);
                if (is_null($member_id)) {
                    warn_exit(do_lang_tempcode('_USER_NO_EXIST', $member_username));
                }
            }
            foreach ($_POST as $key => $_invited_member) {
                if (substr($key, 0, 13) != 'to_member_id_') {
                    continue;
                }
                if ($key == 'to_member_id_0') {
                    continue;
                }
                if ($_invited_member == '') {
                    continue;
                }
                if (get_magic_quotes_gpc()) {
                    $_invited_member = stripslashes($_invited_member);
                }
                $invited_member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($_invited_member);
                if (is_null($invited_member)) {
                    attach_message(do_lang_tempcode('_USER_NO_EXIST', $_invited_member), 'warn');
                } else {
                    $invited_members[] = intval($invited_member);
                }
            }
        }
        $validated = post_param_integer('validated', post_param_integer('_validated', 0));
        $is_emphasised = post_param_integer('is_emphasised', 0);
        $skip_sig = post_param_integer('skip_sig', 0);
        $post = post_param('post');
        $title = post_param('title', NULL);
        if (is_null($title)) {
            $title = '';
        }
        $check_permissions = true;
        $add_poll = post_param_integer('add_poll', 0);
        $topic_validated = $validated;
        if ($validated == 1) {
            $topic_validated = 1 - $add_poll;
        }
        // If a topic is gonna have a poll added, it starts unvalidated. Adding the poll will validate it.
        $anonymous = post_param_integer('anonymous', 0);
        $poster_name_if_guest = post_param('poster_name_if_guest', NULL);
        if ($poster_name_if_guest == '') {
            $poster_name_if_guest = NULL;
        }
        if (!is_null($poster_name_if_guest)) {
            $poster_name_if_guest = trim($poster_name_if_guest);
            $restricted_usernames = explode(',', get_option('restricted_usernames'));
            $restricted_usernames[] = do_lang('UNKNOWN');
            $restricted_usernames[] = do_lang('SYSTEM');
            if (!is_null($GLOBALS['FORUM_DRIVER']->get_member_from_username($poster_name_if_guest))) {
                $restricted_usernames[] = $poster_name_if_guest;
            }
            foreach ($restricted_usernames as $_restricted_username) {
                $restricted_username = trim($_restricted_username);
                if ($restricted_username == '') {
                    continue;
                }
                if ($poster_name_if_guest == $restricted_username) {
                    $poster_name_if_guest = $poster_name_if_guest . ' (' . do_lang('GUEST') . ')';
                    break;
                }
            }
        }
        $new_topic = $topic_id == -1;
        if (!$new_topic) {
            $_intended_solely_for = post_param('intended_solely_for', '');
            if ($_intended_solely_for == '') {
                $intended_solely_for = NULL;
            } else {
                $intended_solely_for = $GLOBALS['FORUM_DRIVER']->get_member_from_username($_intended_solely_for);
                if (is_null($intended_solely_for)) {
                    warn_exit(do_lang_tempcode('_USER_NO_EXIST', $_intended_solely_for));
                }
            }
        } else {
            $intended_solely_for = NULL;
        }
        require_code('ocf_topics_action');
        require_code('ocf_topics_action2');
        if ($new_topic) {
            ocf_check_post($post);
            if ($title == '') {
                warn_exit(do_lang_tempcode('NO_PARAMETER_SENT', 'title'));
            }
            $sunk = post_param_integer('sunk', 0);
            $topic_title = $title;
            if ($forum_id == -1) {
                require_code('ocf_members2');
                if (!ocf_may_whisper($member_id)) {
                    warn_exit(do_lang_tempcode('NO_PT_FROM_ALLOW'));
                }
                check_specific_permission('use_pt');
                $topic_id = ocf_make_topic(NULL, post_param('description', ''), post_param('emoticon', ''), $topic_validated, post_param_integer('open', 0), post_param_integer('pinned', 0), $sunk, post_param_integer('cascading', 0), get_member(), $member_id);
                $_title = get_page_title('ADD_PERSONAL_TOPIC');
            } elseif ($forum_id == -2) {
                $forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name(get_option('reported_posts_forum'));
                if (is_null($forum_id)) {
                    warn_exit(do_lang_tempcode('NO_REPORTED_POST_FORUM'));
                }
                // See if post already reported...
                $topic_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_topics t LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts p ON p.id=t.t_cache_first_post_id', 't.id', array('p.p_title' => $title, 't.t_forum_id' => $forum_id));
                if (!is_null($topic_id)) {
                    // Already a topic
                } else {
                    $topic_id = ocf_make_topic($forum_id, '', '', 1, 1, 0, 0, 0, NULL, NULL, false);
                }
                $_title = get_page_title('REPORT_POST');
                $check_permissions = false;
                decache('main_staff_checklist');
            } else {
                $topic_id = ocf_make_topic($forum_id, post_param('description', ''), post_param('emoticon', ''), $topic_validated, post_param_integer('open', 0), post_param_integer('pinned', 0), $sunk, post_param_integer('cascading', 0));
                $_title = get_page_title('ADD_TOPIC');
                if (addon_installed('awards')) {
                    require_code('awards');
                    handle_award_setting('topic', strval($topic_id));
                }
            }
            $first_post = true;
            require_code('fields');
            if (has_tied_catalogue('topic')) {
                save_form_custom_fields('topic', strval($topic_id));
            }
        } else {
            $_title = get_page_title('ADD_POST');
            $first_post = false;
            $topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_cache_first_title', 't_sunk', 't_forum_id', 't_is_open', 't_description'), array('id' => $topic_id), '', 1);
            if (!array_key_exists(0, $topic_info)) {
                warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
            }
            $forum_id = $topic_info[0]['t_forum_id'];
            $topic_title = $topic_info[0]['t_cache_first_title'];
            $sunk = $topic_info[0]['t_sunk'];
            if ($topic_info[0]['t_is_open'] == 0) {
                $may_moderate_forum = ocf_may_moderate_forum($forum_id);
                if (!$may_moderate_forum) {
                    warn_exit(do_lang_tempcode('TOPIC_IS_CLOSED'));
                }
            }
            // Moderator reply
            $new_title = post_param('new_title', NULL);
            if (!is_null($new_title) && !is_null($forum_id) && ocf_may_moderate_forum($forum_id, get_member())) {
                $cascading = post_param_integer('cascading', 0);
                $pinned = post_param_integer('pinned', 0);
                $sunk = post_param_integer('sunk', 0);
                $open = post_param_integer('open', 0);
                $topic_validated = post_param_integer('topic_validated', 0);
                $to = post_param_integer('to', NULL);
                $schedule = get_input_date('schedule');
                if (!is_null($schedule) && addon_installed('calendar')) {
                    $_intended_solely_for = is_null($intended_solely_for) ? 'NULL' : strval($intended_solely_for);
                    $_postdetailser_name_if_guest = is_null($poster_name_if_guest) ? 'NULL' : '\'' . addslashes($poster_name_if_guest) . '\'';
                    $_first_post = $first_post ? 'true' : 'false';
                    $__title = is_null($title) ? 'NULL' : '\'' . str_replace(chr(10), '\'.chr(10).\'', addslashes($title)) . '\'';
                    $_postdetails = is_null($post) ? 'NULL' : '\'' . str_replace(chr(10), '\'.chr(10).\'', addslashes($post)) . '\'';
                    $_new_title = is_null($new_title) ? 'NULL' : '\'' . str_replace(chr(10), '\'.chr(10).\'', addslashes($new_title)) . '\'';
                    $schedule_code = <<<END
:require_code('ocf_topics_action2'); require_code('ocf_topics_action'); ocf_edit_topic({$topic_id},NULL,NULL,{$validated},{$open},{$pinned},{$sunk},{$cascading},'',{$_new_title}); if (({$to}!={$forum_id}) && (!is_null({$to}))) ocf_move_topics({$forum_id},{$to},array({$topic_id})); \$post_id=ocf_make_post({$topic_id},{$__title},{$_postdetails},{$skip_sig},{$_first_post},{$validated},{$is_emphasised},{$_postdetailser_name_if_guest},NULL,NULL,NULL,{$_intended_solely_for},NULL,NULL,false,true,NULL,true,{$topic_title},{$sunk},NULL,{$anonymous}==1); if (addon_installed('awards')) { require_code('awards'); handle_award_setting('post',strval(\$post_id)); }
END;
                    require_code('calendar');
                    $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');
                    require_code('calendar2');
                    $event_id = add_calendar_event(db_get_first_id(), '', NULL, 0, do_lang('ADD_POST'), $schedule_code, 3, 0, $start_year, $start_month, $start_day, $start_hour, $start_minute);
                    regenerate_event_reminder_jobs($event_id);
                    $text = do_lang_tempcode('SUCCESS');
                    $map = array('page' => 'topicview', 'id' => $topic_id, 'type' => 'first_unread');
                    $test = get_param_integer('kfs' . (is_null($forum_id) ? '' : strval($forum_id)), -1);
                    if ($test != -1 && $test != 0) {
                        $map['kfs' . (is_null($forum_id) ? '' : strval($forum_id))] = $test;
                    }
                    $test = get_param_integer('threaded', -1);
                    if ($test != -1) {
                        $map['threaded'] = $test;
                    }
                    $_url = build_url($map, get_module_zone('topicview'));
                    $url = $_url->evaluate();
                    $url .= '#first_unread';
                    $url = get_param('redirect', $url);
                    return redirect_screen($_title, $url, $text);
                }
                ocf_edit_topic($topic_id, NULL, NULL, $topic_validated, $open, $pinned, $sunk, $cascading, '', $new_title == '' ? NULL : $new_title);
                if ($to != $forum_id && !is_null($to)) {
                    ocf_move_topics($forum_id, $to, array($topic_id));
                }
            }
        }
        $post_id = ocf_make_post($topic_id, $title, $post, $skip_sig, $first_post, $validated, $is_emphasised, $poster_name_if_guest, NULL, NULL, NULL, $intended_solely_for, NULL, NULL, $check_permissions, true, NULL, true, $topic_title, $sunk, NULL, $anonymous == 1, $forum_id == -1 || is_null($forum_id), $forum_id == -1 || is_null($forum_id), false, $parent_id);
        if (addon_installed('awards')) {
            require_code('awards');
            handle_award_setting('post', strval($post_id));
        }
        if (!is_null($forum_id) && $anonymous == 0 && $intended_solely_for === NULL) {
            if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'forumview') && has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'forums', strval($forum_id))) {
                syndicate_described_activity($first_post ? 'ocf:ACTIVITY_ADD_TOPIC' : 'ocf:ACTIVITY_ADD_POST_IN', $first_post ? $title : $topic_title, '', '', '_SEARCH:topicview:misc:' . strval($topic_id) . '#post_' . strval($post_id), '', '', 'ocf_forum');
            }
        }
        require_code('fields');
        if (has_tied_catalogue('post')) {
            save_form_custom_fields('post', strval($post_id));
        }
        $validated = $GLOBALS['FORUM_DB']->query_value('f_posts', 'p_validated', array('id' => $post_id));
        $rep_post_id = post_param_integer('o_post_id', -1);
        if ($rep_post_id != -1) {
            $map = array('page' => 'topicview', 'id' => $rep_post_id, 'type' => 'findpost');
            $_url = build_url($map, get_module_zone('topicview'));
            $url = $_url->evaluate();
            $url .= '#post_' . strval($rep_post_id);
        } else {
            $map = array('page' => 'topicview', 'id' => $post_id, 'type' => 'findpost');
            $test = get_param_integer('kfs' . (is_null($forum_id) ? '' : strval($forum_id)), -1);
            if ($test != -1 && $test != 0) {
                $map['kfs' . (is_null($forum_id) ? '' : strval($forum_id))] = $test;
            }
            $test = get_param_integer('threaded', -1);
            if ($test != -1) {
                $map['threaded'] = $test;
            }
            $_url = build_url($map, get_module_zone('topicview'));
            $url = $_url->evaluate();
            if ($validated != 0) {
                $url .= '#post_' . strval($post_id);
            }
        }
        if ($forum_id >= 0) {
            $topic_validated = $GLOBALS['FORUM_DB']->query_value('f_topics', 't_validated', array('id' => $topic_id));
            if ($topic_validated == 0 && !has_specific_permission(get_member(), 'jump_to_unvalidated')) {
                $map = array('page' => 'forumview', 'id' => $forum_id);
                $test = get_param_integer('kfs' . (is_null($forum_id) ? '' : strval($forum_id)), -1);
                if ($test != -1 && $test != 0) {
                    $map['kfs' . (is_null($forum_id) ? '' : strval($forum_id))] = $test;
                }
                $test = get_param_integer('threaded', -1);
                if ($test != -1) {
                    $map['threaded'] = $test;
                }
                $_url = build_url($map, get_module_zone('forumview'));
                $url = $_url->evaluate();
            }
        }
        if ($new_topic && $forum_id == -1) {
            require_code('notifications');
            enable_notifications('ocf_topic', strval($topic_id), get_member());
            // from
            enable_notifications('ocf_topic', strval($topic_id), $member_id);
            // to
            foreach ($invited_members as $invited_member) {
                enable_notifications('ocf_topic', strval($topic_id), $invited_member);
                ocf_invite_to_pt($invited_member, $topic_id);
            }
        }
        if ($anonymous == 1) {
            log_it('MAKE_ANONYMOUS_POST', strval($post_id), $title);
        }
        if (addon_installed('awards')) {
            require_code('awards');
            handle_award_setting('post', strval($post_id));
        }
        if ($forum_id == -1 && $member_id != -1) {
            send_pt_notification($post_id, $title, $topic_id, $member_id, NULL, $post);
        }
        if ($add_poll == 1) {
            if (post_param_integer('add_poll', 0) == 1) {
                // Show it worked / Refresh
                $_url = build_url(array('page' => '_SELF', 'type' => 'add_poll', 'id' => $topic_id, 'try_validate' => 1), '_SELF');
                return redirect_screen($_title, $_url, do_lang_tempcode('SUCCESS'));
            }
        }
        if (!$new_topic && $forum_id != -1 && $member_id == -1) {
            handle_topic_ticket_reply($forum_id, $topic_id, $topic_title, $post);
        }
        $text = $validated == 1 ? do_lang_tempcode('SUCCESS') : do_lang_tempcode('SUBMIT_UNVALIDATED');
        require_code('autosave');
        clear_ocp_autosave();
        // Show it worked / Refresh
        $url = get_param('redirect', $url);
        return redirect_screen($_title, $url, $text);
    }
Esempio n. 10
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. 11
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_calendar($db, $table_prefix, $file_base)
 {
     require_code('calendar2');
     if (either_param('importer') == 'ipb1') {
         $rows = $db->query('SELECT * FROM ' . $table_prefix . 'calendar_events');
     } else {
         $rows = $db->query('SELECT ce.event_id AS eventid, ce.event_member_id AS userid, ce.event_tz AS event_repeat, ce.event_recurring AS repeat_unit,ce.* FROM ' . $table_prefix . 'cal_events as ce');
     }
     foreach ($rows as $row) {
         if (import_check_if_imported('event', strval($row['eventid']))) {
             continue;
         }
         $submitter = import_id_remap_get('member', strval($row['userid']), true);
         if (is_null($submitter)) {
             $submitter = $GLOBALS['FORUM_DRIVER']->get_guest_id();
         }
         $recurrence = 'none';
         $recurrences = NULL;
         if (either_param('importer') == 'ipb1') {
             if ($row['event_repeat'] != 0) {
                 switch ($row['repeat_unit']) {
                     case 'w':
                         $recurrence = 'weekly';
                         break;
                     case 'm':
                         $recurrence = 'monthly';
                         break;
                     case 'y':
                         $recurrence = 'yearly';
                         break;
                 }
             }
             $event_title = $row['title'];
             $event_text = $row['event_text'];
             $private_event = $row['priv_event'];
             $start_year = $row['year'];
             $start_month = $row['month'];
             $start_day = $row['mday'];
             $end_year = $row['end_year'];
             $end_month = $row['end_month'];
             $end_day = $row['end_day'];
         } else {
             if ($row['event_repeat'] != 0) {
                 switch ($row['repeat_unit']) {
                     case '1':
                         $recurrence = 'weekly';
                         break;
                     case '2':
                         $recurrence = 'monthly';
                         break;
                     case '3':
                         $recurrence = 'yearly';
                         break;
                 }
             }
             $event_title = $row['event_title'];
             $event_text = $row['event_content'];
             $private_event = $row['event_private'];
             $start_year = date('Y', $row['event_unix_from']);
             $start_month = date('n', $row['event_unix_from']);
             $start_day = date('j', $row['event_unix_from']);
             $end_year = date('Y', $row['event_unix_to']);
             $end_month = date('n', $row['event_unix_to']);
             $end_day = date('j', $row['event_unix_to']);
         }
         ocf_over_msn();
         //$id_new=add_calendar_event(db_get_first_id()+1,$recurrence,$recurrences,0,$event_title,$event_text,3,1-$private_event,$start_year,$start_month,$start_day,0,0,$end_year,$end_month,$end_day,NULL,1,0,0,$submitter); //old code
         $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, $recurrences, 0, $event_title, $event_text, 3, 1 - $private_event, $start_year, $start_month, $start_day, 0, 0, $end_year, $end_month, $end_day, NULL, NULL, NULL, 1, 1, 1, 1, 1, '', $submitter);
         ocf_over_local();
         import_id_remap_put('event', strval($row['eventid']), $id_new);
     }
 }
Esempio n. 12
0
function do_work()
{
    $num_wanted = 100000;
    require_code('config2');
    set_option('post_history_days', '0');
    // Needed for a little sanity in recent post retrieval
    set_value('disable_sunk', '1');
    // members (remember to test the username autocompleter, and birthdays)
    // authors (remember to check author autocompleter and popup author list)
    // lots of people getting notifications on a forum
    // lots of people getting notifications on a topic
    require_code('authors');
    require_code('ocf_members_action');
    require_code('notifications');
    for ($i = $GLOBALS['FORUM_DB']->query_value('f_members', 'COUNT(*)'); $i < $num_wanted; $i++) {
        $member_id = ocf_make_member(uniqid('', true), uniqid('', true), uniqid('', true) . '@example.com', array(), intval(date('d')), intval(date('m')), intval(date('Y')), array(), NULL, NULL, 1, NULL, NULL, '', NULL, '', 0, 0, 1, '', '', '', 1, 1, NULL, 1, 1, '', NULL, '', false);
        add_author(random_line(), '', $member_id, random_text(), random_text());
        enable_notifications('ocf_topic', 'forum:' . strval(db_get_first_id()), $member_id);
        enable_notifications('ocf_topic', strval(db_get_first_id()), $member_id);
        // number of friends to a single member
        $GLOBALS['SITE_DB']->query_insert('chat_buddies', array('member_likes' => $member_id, 'member_liked' => db_get_first_id() + 1, 'date_and_time' => time()), false, true);
    }
    $member_id = db_get_first_id() + 2;
    // point earn list / gift points to a single member
    require_code('points2');
    for ($j = $GLOBALS['SITE_DB']->query_value('gifts', 'COUNT(*)'); $j < $num_wanted; $j++) {
        give_points(10, $member_id, mt_rand(db_get_first_id(), min(100, $num_wanted - 1)), random_line(), false, false);
    }
    // number of friends of a single member
    for ($j = intval(floatval($GLOBALS['SITE_DB']->query_value('chat_buddies', 'COUNT(*)')) / 2.0); $j < $num_wanted; $j++) {
        $GLOBALS['SITE_DB']->query_insert('chat_buddies', array('member_likes' => $member_id, 'member_liked' => $j + db_get_first_id(), 'date_and_time' => time()), false, true);
    }
    echo 'done member/authors/points/notifications/friends stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // banners
    require_code('banners2');
    for ($i = $GLOBALS['SITE_DB']->query_value('banners', 'COUNT(*)'); $i < $num_wanted; $i++) {
        add_banner(uniqid('', true), get_logo_url(), random_line(), random_text(), 100, get_base_url(), 3, '', db_get_first_id(), NULL, db_get_first_id() + 1, 1);
    }
    echo 'done banner stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // comcode pages
    require_code('files');
    require_code('files2');
    for ($i = $GLOBALS['SITE_DB']->query_value('comcode_pages', 'COUNT(*)'); $i < $num_wanted; $i++) {
        $file = uniqid('', true);
        /*$path=get_custom_file_base().'/site/pages/comcode_custom/'.fallback_lang().'/'.$file.'.txt';
        		$myfile=fopen($path,'wt');
        		fwrite($myfile,random_text());
        		fclose($myfile);
        		sync_file($path);
        		fix_permissions($path);*/
        $GLOBALS['SITE_DB']->query_insert('comcode_pages', array('the_zone' => 'site', 'the_page' => $file, 'p_parent_page' => '', 'p_validated' => 1, 'p_edit_date' => NULL, 'p_add_date' => time(), 'p_submitter' => db_get_first_id(), 'p_show_as_edit' => 0));
    }
    echo 'done comcode stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // zones
    require_code('zones2');
    require_code('abstract_file_manager');
    for ($i = $GLOBALS['SITE_DB']->query_value('zones', 'COUNT(*)'); $i < min($num_wanted, 1000); $i++) {
        actual_add_zone(uniqid('', true), random_line(), 'start', random_line(), 'default', 0, 0, 0);
    }
    echo 'done zone stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // calendar events
    require_code('calendar2');
    for ($i = $GLOBALS['SITE_DB']->query_value('calendar_events', 'COUNT(*)'); $i < $num_wanted; $i++) {
        add_calendar_event(db_get_first_id(), '', NULL, 0, random_line(), random_text(), 1, 1, intval(date('Y')), intval(date('m')), intval(date('d')), 0, 0);
    }
    echo 'done event stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // chat rooms
    require_code('chat2');
    require_code('chat');
    for ($i = $GLOBALS['SITE_DB']->query_value('chat_rooms', 'COUNT(*)'); $i < $num_wanted; $i++) {
        $room_id = add_chatroom(random_text(), random_line(), mt_rand(db_get_first_id() + 1, $num_wanted - 1), strval(db_get_first_id() + 1), '', '', '', fallback_lang());
    }
    $room_id = db_get_first_id() + 1;
    // messages in chat room
    for ($j = $GLOBALS['SITE_DB']->query_value('chat_messages', 'COUNT(*)'); $j < $num_wanted; $j++) {
        $_message_parsed = insert_lang_comcode(random_text(), 4);
        $GLOBALS['SITE_DB']->query_insert('chat_messages', array('system_message' => 0, 'ip_address' => '', 'room_id' => $room_id, 'user_id' => db_get_first_id(), 'date_and_time' => time(), 'the_message' => $_message_parsed, 'text_colour' => get_option('chat_default_post_colour'), 'font_name' => get_option('chat_default_post_font')));
    }
    echo 'done chat stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // download categories under a subcategory
    require_code('downloads2');
    $subcat_id = add_download_category(random_line(), db_get_first_id(), random_text(), '');
    for ($i = $GLOBALS['SITE_DB']->query_value('download_categories', 'COUNT(*)'); $i < $num_wanted; $i++) {
        add_download_category(random_line(), $subcat_id, random_text(), '');
    }
    // downloads (remember to test content by the single author)
    require_code('downloads2');
    require_code('awards');
    $time = time();
    for ($i = $GLOBALS['SITE_DB']->query_value('download_downloads', 'COUNT(*)'); $i < $num_wanted; $i++) {
        $content_id = add_download(db_get_first_id(), random_line(), get_logo_url(), random_text(), 'admin', random_text(), NULL, 1, 1, 1, 1, '', uniqid('', true) . '.jpg', 100, 110, 1);
        give_award(db_get_first_id(), strval($content_id), $time - $i);
    }
    $content_id = db_get_first_id();
    $content_url = build_url(array('page' => 'downloads', 'type' => 'entry', 'id' => $content_id), 'site');
    for ($j = $GLOBALS['SITE_DB']->query_value('trackbacks', 'COUNT(*)'); $j < $num_wanted; $j++) {
        // trackbacks
        $GLOBALS['SITE_DB']->query_insert('trackbacks', array('trackback_for_type' => 'downloads', 'trackback_for_id' => $content_id, 'trackback_ip' => '', 'trackback_time' => time(), 'trackback_url' => '', 'trackback_title' => random_line(), 'trackback_excerpt' => random_text(), 'trackback_name' => random_line()));
        // ratings
        $GLOBALS['SITE_DB']->query_insert('rating', array('rating_for_type' => 'downloads', 'rating_for_id' => $content_id, 'rating_member' => $j + 1, 'rating_ip' => '', 'rating_time' => time(), 'rating' => 3));
        // posts in a comment topic
        $GLOBALS['FORUM_DRIVER']->make_post_forum_topic(get_option('comments_forum_name'), 'downloads_' . strval($content_id), get_member(), random_text(), random_line(), '', do_lang('COMMENT'), $content_url->evaluate(), NULL, NULL, 1, 1);
    }
    echo 'done download stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // forums under a forum (don't test it can display, just make sure the main index still works)
    require_code('ocf_forums_action');
    for ($i = $GLOBALS['FORUM_DB']->query_value('f_forums', 'COUNT(*)'); $i < $num_wanted; $i++) {
        ocf_make_forum(random_line(), random_text(), db_get_first_id(), array(), db_get_first_id() + 3);
    }
    // forum topics
    require_code('ocf_topics_action');
    require_code('ocf_posts_action');
    require_code('ocf_forums');
    require_code('ocf_topics');
    for ($i = intval(floatval($GLOBALS['FORUM_DB']->query_value('f_topics', 'COUNT(*)')) / 2.0); $i < $num_wanted; $i++) {
        $topic_id = ocf_make_topic(db_get_first_id(), '', '', NULL, 1, 0, 0, 0, NULL, NULL, false);
        ocf_make_post($topic_id, random_line(), random_text(), 0, true, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, false);
    }
    // forum posts in a topic
    require_code('ocf_topics_action');
    require_code('ocf_posts_action');
    $topic_id = ocf_make_topic(db_get_first_id() + 1, '', '', NULL, 1, 0, 0, 0, NULL, NULL, false);
    for ($i = intval(floatval($GLOBALS['FORUM_DB']->query_value('f_posts', 'COUNT(*)')) / 3.0); $i < $num_wanted; $i++) {
        ocf_make_post($topic_id, random_line(), random_text(), 0, true, 0, 0, NULL, NULL, NULL, mt_rand(db_get_first_id(), $num_wanted - 1), NULL, NULL, NULL, false, false);
    }
    echo 'done forum stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // clubs
    require_code('ocf_groups_action');
    require_code('ocf_groups');
    for ($i = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)'); $i < $num_wanted; $i++) {
        ocf_make_group(random_line(), 0, 0, 0, random_line(), '', NULL, NULL, NULL, 5, 0, 70, 50, 100, 100, 30000, 700, 25, 1, 0, 0, 0, $i, 1, 0, 1);
    }
    echo 'done club stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // galleries under a subcategory
    require_code('galleries2');
    $xsubcat_id = uniqid('', true);
    add_gallery($xsubcat_id, random_line(), random_text(), '', '', 'root');
    for ($i = $GLOBALS['SITE_DB']->query_value('galleries', 'COUNT(*)'); $i < $num_wanted; $i++) {
        add_gallery(uniqid('', true), random_line(), random_text(), '', '', $xsubcat_id);
    }
    // images
    require_code('galleries2');
    for ($i = $GLOBALS['SITE_DB']->query_value('images', 'COUNT(*)'); $i < $num_wanted; $i++) {
        add_image('', 'root', random_text(), get_logo_url(), get_logo_url(), 1, 1, 1, 1, '');
    }
    // videos / validation queue
    require_code('galleries2');
    for ($i = $GLOBALS['SITE_DB']->query_value('videos', 'COUNT(*)'); $i < $num_wanted; $i++) {
        add_video('', 'root', random_text(), get_logo_url(), get_logo_url(), 0, 1, 1, 1, '', 0, 0, 0);
    }
    echo 'done galleries stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // newsletter subscribers
    require_code('newsletter');
    for ($i = $GLOBALS['SITE_DB']->query_value('newsletter', 'COUNT(*)'); $i < $num_wanted; $i++) {
        basic_newsletter_join(uniqid('', true) . '@example.com');
    }
    echo 'done newsletter stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // polls (remember to test poll archive)
    require_code('polls');
    for ($i = $GLOBALS['SITE_DB']->query_value('poll', 'COUNT(*)'); $i < $num_wanted; $i++) {
        $poll_id = add_poll(random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), 10, 0, 0, 0, 0, '');
    }
    // votes on a poll
    $poll_id = db_get_first_id();
    for ($j = $GLOBALS['SITE_DB']->query_value('poll_votes', 'COUNT(*)'); $j < $num_wanted; $j++) {
        $cast = mt_rand(1, 6);
        $ip = uniqid('', true);
        $GLOBALS['SITE_DB']->query_insert('poll_votes', array('v_poll_id' => $poll_id, 'v_voter_id' => 2, 'v_voter_ip' => $ip, 'v_vote_for' => $cast));
    }
    echo 'done polls stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // quizzes
    require_code('quiz');
    for ($i = $GLOBALS['SITE_DB']->query_value('quizzes', 'COUNT(*)'); $i < $num_wanted; $i++) {
        add_quiz(random_line(), 0, random_text(), random_text(), random_text(), '', 0, time(), NULL, 3, 300, 'SURVEY', 1, '1) Some question');
    }
    echo 'done quizzes stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // successful searches (to test the search recommender)
    // ACTUALLY: I have manually verified the code, it is an isolated portion
    // cedi pages (do a long descendant tree for some, and orphans for others)
    // cedi posts (remember to test cedi changes screen)
    require_code('cedi');
    for ($i = $GLOBALS['SITE_DB']->query_value('seedy_pages', 'COUNT(*)'); $i < $num_wanted; $i++) {
        $page_id = cedi_add_page(random_line(), random_text(), '', 1);
        cedi_add_post($page_id, random_text(), 1, NULL, false);
    }
    echo 'done cedi stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // iotds
    require_code('iotds');
    for ($i = $GLOBALS['SITE_DB']->query_value('iotd', 'COUNT(*)'); $i < $num_wanted; $i++) {
        add_iotd(get_logo_url(), random_line(), random_text(), get_logo_url(), 1, 0, 0, 0, '');
    }
    echo 'done iotd stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // logged hack attempts
    for ($i = $GLOBALS['SITE_DB']->query_value('hackattack', 'COUNT(*)'); $i < $num_wanted; $i++) {
        $GLOBALS['SITE_DB']->query_insert('hackattack', array('url' => get_base_url(), 'data_post' => '', 'user_agent' => '', 'referer' => '', 'user_os' => '', 'the_user' => db_get_first_id(), 'date_and_time' => time(), 'ip' => uniqid('', true), 'reason' => 'ASCII_ENTITY_URL_HACK', 'reason_param_a' => '', 'reason_param_b' => ''));
    }
    // logged hits in one day
    require_code('site');
    for ($i = $GLOBALS['SITE_DB']->query_value('stats', 'COUNT(*)'); $i < $num_wanted; $i++) {
        log_stats('/testing' . uniqid('', true), mt_rand(100, 2000));
    }
    echo 'done logs stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // blogs and news entries (remember to test both blogs [categories] list, and a list of all news entries)
    require_code('news');
    for ($i = $GLOBALS['SITE_DB']->query_value('news', 'COUNT(*)'); $i < $num_wanted; $i++) {
        add_news(random_line(), random_text(), 'admin', 1, 1, 1, 1, '', random_text(), NULL, NULL, NULL, db_get_first_id() + $i);
    }
    echo 'done news stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // support tickets
    require_code('tickets');
    require_code('tickets2');
    for ($i = intval(floatval($GLOBALS['FORUM_DB']->query_value('f_topics', 'COUNT(*)')) / 2.0); $i < $num_wanted; $i++) {
        ticket_add_post(mt_rand(db_get_first_id(), $num_wanted - 1), uniqid('', true), db_get_first_id(), random_line(), random_text(), '', '');
    }
    echo 'done tickets stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // catalogues
    require_code('catalogues2');
    $root_id = db_get_first_id();
    for ($i = $GLOBALS['SITE_DB']->query_value('catalogues', 'COUNT(*)'); $i < $num_wanted; $i++) {
        $catalogue_name = uniqid('', true);
        $root_id = actual_add_catalogue($catalogue_name, random_line(), random_text(), mt_rand(0, 3), 1, '', 30);
    }
    // catalogue categories under a subcategory (remember to test all catalogue views: atoz, index, and root cat)
    $catalogue_name = 'products';
    $subcat_id = actual_add_catalogue_category($catalogue_name, random_line(), random_text(), '', $root_id);
    for ($j = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'COUNT(*)'); $j < $num_wanted; $j++) {
        actual_add_catalogue_category($catalogue_name, random_line(), random_text(), '', $subcat_id);
    }
    echo 'done catalogue stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // items in ecommerce store
    require_code('catalogues2');
    $cat_id = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'MIN(id)', array('c_name' => 'products'));
    $fields = collapse_1d_complexity('id', $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('id'), array('c_name' => 'products')));
    for ($i = $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'COUNT(*)'); $i < $num_wanted; $i++) {
        $map = array($fields[0] => random_line(), $fields[1] => uniqid('', true), $fields[2] => '1.0', $fields[3] => '1', $fields[4] => '0', $fields[5] => '1', $fields[6] => '0%', $fields[7] => get_logo_url(), $fields[8] => '2.0', $fields[9] => random_text());
        $pid = actual_add_catalogue_entry($cat_id, 1, '', 1, 1, 1, $map);
        unset($map);
    }
    // outstanding ecommerce orders
    $pid = $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'MIN(id)', array('c_name' => 'products'));
    require_code('shopping');
    for ($j = $GLOBALS['SITE_DB']->query_value('shopping_cart', 'COUNT(*)'); $j < $num_wanted; $j++) {
        $product_det = array('product_id' => $pid, 'product_name' => $fields[0], 'product_code' => $fields[1], 'price' => $fields[2], 'tax' => preg_replace('#[^\\d\\.]#', '', $fields[6]), 'description' => $fields[9], 'quantity' => mt_rand(1, 20), 'product_type' => 'catalogue_items', 'product_weight' => $fields[8]);
        $GLOBALS['SITE_DB']->query_insert('shopping_cart', array('session_id' => mt_rand(0, 1000000), 'ordered_by' => mt_rand(db_get_first_id() + 1, $num_wanted - 1), 'product_id' => $product_det['product_id'], 'product_name' => $product_det['product_name'], 'product_code' => $product_det['product_code'], 'quantity' => $product_det['quantity'], 'price' => round(floatval($product_det['price']), 2), 'price_pre_tax' => $product_det['tax'], 'product_description' => $product_det['description'], 'product_type' => $product_det['product_type'], 'product_weight' => $product_det['product_weight'], 'is_deleted' => 0));
    }
    for ($j = $GLOBALS['SITE_DB']->query_value('shopping_order', 'COUNT(*)'); $j < $num_wanted; $j++) {
        $order_id = $GLOBALS['SITE_DB']->query_insert('shopping_order', array('c_member' => mt_rand(db_get_first_id() + 1, $num_wanted - 1), 'session_id' => mt_rand(0, 1000000), 'add_date' => time(), 'tot_price' => '123.00', 'order_status' => 'ORDER_STATUS_awaiting_payment', 'notes' => '', 'purchase_through' => 'purchase_module', 'transaction_id' => '', 'tax_opted_out' => 0), true);
        $GLOBALS['SITE_DB']->query_insert('shopping_order_details', array('p_id' => 123, 'p_name' => random_line(), 'p_code' => 123, 'p_type' => 'catalogue_items', 'p_quantity' => 1, 'p_price' => '12.00', 'order_id' => $order_id, 'dispatch_status' => '', 'included_tax' => '1.00'));
    }
    echo 'done store stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    echo '{{DONE}}' . chr(10);
}
Esempio n. 13
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_calendar($db, $table_prefix, $file_base)
 {
     require_code('calendar2');
     $rows = $db->query_select('calendar');
     foreach ($rows as $row) {
         if (import_check_if_imported('event', strval($row['ID_EVENT']))) {
             continue;
         }
         $submitter = import_id_remap_get('member', strval($row['ID_MEMBER']), true);
         if (is_null($submitter)) {
             $submitter = $GLOBALS['OCF_DRIVER']->get_guest_id();
         }
         $recurrence = 'none';
         $recurrences = NULL;
         $days = intval(floor((strtotime($row['endDate']) - strtotime($row['startDate'])) / (60 * 60 * 24)));
         //Max 7 days in SMF
         if ($days == 0) {
             $recurrence = 'daily 1';
         } else {
             $recurrence = 'daily ';
             for ($i = 1; $i <= $days; $i++) {
                 $recurrence .= '1';
             }
         }
         $start_hour = 0;
         $start_minute = 0;
         list($start_year, $start_month, $start_day) = array_map('intval', explode('-', $row['eventDate']));
         list($end_year, $end_month, $end_day, $end_hour, $end_minute) = array($start_year, $start_month, $start_day, $start_hour, $start_minute);
         $description = '';
         if ($row['ID_TOPIC'] != 0) {
             $messages = $db->query('SELECT * FROM ' . $table_prefix . 'messages WHERE ID_TOPIC=' . strval($row['ID_TOPIC']) . ' ORDER BY ID_TOPIC ASC');
             ocf_over_msn();
             $description = isset($messages[0]['body']) && $messages[0]['body'] != '' ? html_to_comcode($messages[0]['body']) : '';
             ocf_over_local();
         }
         ocf_over_msn();
         $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, $recurrences, 0, $row['title'], $description, 3, 1, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, NULL, 1, 1, 1, 1, 1, '', $submitter);
         ocf_over_local();
         import_id_remap_put('event', strval($row['ID_EVENT']), $id_new);
     }
     $rows = array();
     $rows = $db->query_select('calendar_holidays');
     foreach ($rows as $row) {
         if (import_check_if_imported('event', strval($row['ID_HOLIDAY']))) {
             continue;
         }
         $submitter = $GLOBALS['OCF_DRIVER']->get_guest_id();
         $recurrence = 'none';
         $recurrences = NULL;
         list($start_year, $start_month, $start_day, $start_hour, $start_minute) = array_map('intval', explode('-', date('Y-m-d-h-i', strtotime($row['eventDate']))));
         list($end_year, $end_month, $end_day, $end_hour, $end_minute) = array_map('intval', explode('-', date('Y-m-d-h-i', strtotime($row['eventDate']))));
         ocf_over_msn();
         $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, $recurrences, 0, $row['title'], $row['title'], 3, 1, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, NULL, 1, 1, 1, 1, 1, '', $submitter);
         ocf_over_local();
         import_id_remap_put('event', strval($row['ID_HOLIDAY']), $id_new);
     }
 }
Esempio n. 14
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;
 }
Esempio n. 15
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_calendar($db, $table_prefix, $file_base)
 {
     require_code('calendar2');
     $rows = $db->query_select('events');
     foreach ($rows as $row) {
         if (import_check_if_imported('event', strval($row['eid']))) {
             continue;
         }
         $submitter = import_id_remap_get('member', strval($row['uid']), true);
         if (is_null($submitter)) {
             $submitter = $GLOBALS['OCF_DRIVER']->get_guest_id();
         }
         $recurrence = 'none';
         $recurrences = NULL;
         $event_repeat_data = unserialize($row['repeats']);
         $event_repeats = isset($event_repeat_data['repeats']) && $event_repeat_data['repeats'] != 0 ? $event_repeat_data['repeats'] : 0;
         switch ($event_repeats) {
             case 1:
                 $week_array = array(0, 0, 0, 0, 0, 0, 0);
                 $start_day_num = intval(date('w', $row['starttime']));
                 $every_days = $event_repeat_data['days'];
                 $week_array[$start_day_num] = 1;
                 $next_day = $start_day_num;
                 for ($i = 1; $i < 7; $i++) {
                     $next_day += $every_days;
                     if ($next_day > 6) {
                         $next_day -= 6;
                     }
                     $week_array[$next_day] = 1;
                 }
                 $recurrence = 'daily ' . implode('', $week_array);
                 break;
             case 2:
                 $recurrence = 'daily 1111100';
                 break;
             case 3:
                 $week_array = array(0, 0, 0, 0, 0, 0, 0);
                 $week_array[0] = isset($event_repeat_data['days'][0]) && $event_repeat_data['days'][0] != '' ? 1 : 0;
                 $week_array[1] = isset($event_repeat_data['days'][1]) && $event_repeat_data['days'][1] != '' ? 1 : 0;
                 $week_array[2] = isset($event_repeat_data['days'][2]) && $event_repeat_data['days'][2] != '' ? 1 : 0;
                 $week_array[3] = isset($event_repeat_data['days'][3]) && $event_repeat_data['days'][3] != '' ? 1 : 0;
                 $week_array[4] = isset($event_repeat_data['days'][4]) && $event_repeat_data['days'][4] != '' ? 1 : 0;
                 $week_array[5] = isset($event_repeat_data['days'][5]) && $event_repeat_data['days'][5] != '' ? 1 : 0;
                 $week_array[6] = isset($event_repeat_data['days'][6]) && $event_repeat_data['days'][6] != '' ? 1 : 0;
                 $recurrence = 'daily ' . implode('', $week_array);
                 break;
             case 4:
                 $pattern = '1';
                 $repeat_every_n_years = $event_repeat_data['months'];
                 for ($i = 1; $i < $repeat_every_n_years; $i++) {
                     $pattern .= '0';
                 }
                 $recurrence = 'monthly ' . $pattern;
                 break;
             case 5:
                 $pattern = '1';
                 $repeat_every_n_years = $event_repeat_data['years'];
                 for ($i = 1; $i < $repeat_every_n_years; $i++) {
                     $pattern .= '0';
                 }
                 $recurrence = 'yearly ' . $pattern;
                 break;
         }
         list($start_year, $start_month, $start_day, $start_hour, $start_minute) = explode('-', date('Y-m-d-h-i', strtotime($row['starttime'])));
         list($end_year, $end_month, $end_day, $end_hour, $end_minute) = explode('-', date('Y-m-d-h-i', strtotime($row['endtime'])));
         ocf_over_msn();
         $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, $recurrences, 0, $row['name'], $row['description'], 3, $row['visible'], $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, NULL, 1, $submitter, 0, $row['dateline']);
         ocf_over_local();
         import_id_remap_put('event', strval($row['eid']), $id_new);
     }
 }
Esempio n. 16
0
/**
 * Import ical events to members's event calendar.
 *
 * @param  PATH		File path
*/
function ical_import($file_name)
{
    $data = unixify_line_format(file_get_contents($file_name));
    $whole = end(explode('BEGIN:VCALENDAR', $data));
    $events = explode('BEGIN:VEVENT', $whole);
    $calendar_nodes = array();
    foreach ($events as $key => $items) {
        $items = preg_replace('#(.+)\\n +(.*)\\n#', '${1}${2}' . "\n", $items);
        // Merge split lines
        $nodes = explode("\n", $items);
        foreach ($nodes as $_child) {
            if (strpos($_child, ':') === false) {
                continue;
            }
            $child = array('', '');
            $in_quotes = false;
            $j = 0;
            for ($i = 0; $i < strlen($_child); $i++) {
                $char = $_child[$i];
                if ($char == '"') {
                    $in_quotes = !$in_quotes;
                }
                if ($j != 1 && !$in_quotes && $char == ':') {
                    $j++;
                } else {
                    $child[$j] .= $char;
                }
            }
            $matches = array();
            if (preg_match('#;TZID=(.*)#', $child[0], $matches)) {
                $calendar_nodes[$key]['TZID'] = $matches[1];
            }
            $child[0] = preg_replace('#;.*#', '', $child[0]);
            if (array_key_exists(1, $child) && $child[0] !== 'PRODID' && $child[0] !== 'VERSION' && $child[0] !== 'END') {
                $calendar_nodes[$key][$child[0]] = trim($child[1]);
            }
        }
        if ($key != 0) {
            list(, $type_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, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes) = get_event_data_ical($calendar_nodes[$key]);
            if (is_null($type_id)) {
                require_code('calendar2');
                $type_id = add_event_type(ucfirst($type), 'calendar/general');
            }
            $id = add_calendar_event($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, 1, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes);
        }
    }
}