コード例 #1
0
 /**
  * Send an e-mail to the admin and another to the user if form passes
  * validation.
  */
 public function add_ics_feed_frontend()
 {
     global $wpdb;
     $table_name = $wpdb->prefix . 'ai1ec_event_feeds';
     $check = $this->validate_form();
     $check['nonce'] = wp_nonce_field('ai1ec_submit_ics_form', AI1EC_POST_TYPE, true, false);
     if (true === $check['success']) {
         $ai1ec_settings = Ai1ec_Settings::get_instance();
         // Strip slashes if ridiculous PHP setting magic_quotes_gpc is enabled.
         if (get_magic_quotes_gpc()) {
             foreach ($_POST as &$param) {
                 $param = stripslashes($param);
             }
         }
         $translations = $this->get_translations();
         $notification_for_admin = Ai1ec_Notification_Factory::create_notification_instance(array(get_option('admin_email')), $ai1ec_settings->admin_mail_body, Ai1ec_Notification_Factory::EMAIL_NOTIFICATION, $ai1ec_settings->admin_mail_subject);
         $notification_for_user = Ai1ec_Notification_Factory::create_notification_instance(array($_POST['ai1ec_submitter_email']), $ai1ec_settings->user_mail_body, Ai1ec_Notification_Factory::EMAIL_NOTIFICATION, $ai1ec_settings->user_mail_subject);
         $notification_for_admin->set_translations($translations);
         $notification_for_admin->send();
         $notification_for_user->set_translations($translations);
         $notification_for_user->send();
     }
     echo json_encode($check);
     exit;
 }
コード例 #2
0
 /**
  *  Check if a cookie is set for the current page
  * 
  * @return Ai1ec_Cookie_Present_Dto
  */
 public static function is_cookie_set_for_current_page()
 {
     $cookie_dto = Ai1ec_Dto_Factory::create_cookie_present_dto_instance();
     $ai1ec_settings = Ai1ec_Settings::get_instance();
     $calendar_url = get_page_link($ai1ec_settings->calendar_page_id);
     $requested_page_url = Ai1ec_Wp_Uri_Helper::get_current_url(true);
     $cookie_set = isset($_COOKIE['ai1ec_saved_filter']);
     if (false !== $cookie_set) {
         $cookie = json_decode(stripslashes($_COOKIE['ai1ec_saved_filter']), true);
         if ($calendar_url === $requested_page_url && isset($cookie['calendar_page']) && $cookie['calendar_page'] !== $calendar_url) {
             $cookie_dto->set_calendar_cookie($cookie['calendar_page']);
             $cookie_dto->set_is_cookie_set_for_calendar_page(true);
             $cookie_dto->set_is_a_cookie_set_for_this_page(true);
         } else {
             if (isset($cookie[$requested_page_url])) {
                 $cookie_dto->set_shortcode_cookie($cookie[$requested_page_url]);
                 $cookie_dto->set_is_cookie_set_for_shortcode(true);
                 $cookie_dto->set_is_a_cookie_set_for_this_page(true);
             } else {
                 if (strpos($requested_page_url, $calendar_url) === 0 && isset($cookie['calendar_page']) && is_page($ai1ec_settings->calendar_page_id)) {
                     // This is the case after a redirect from the calendar page
                     $cookie_dto->set_is_a_cookie_set_for_this_page(true);
                     $cookie_dto->set_calendar_cookie($cookie['calendar_page']);
                 }
             }
         }
     }
     return $cookie_dto;
 }
コード例 #3
0
 /**
  * Returns singletonian instance of this object
  *
  * @return Ai1ec_Oauth_Controller Singletonian instance of self
  */
 public static function get_instance()
 {
     if (!self::$_instance instanceof self) {
         global $wpdb;
         self::$_instance = new self($wpdb, Ai1ec_Settings::get_instance());
     }
     return self::$_instance;
 }
コード例 #4
0
 /**
  * Constructor
  *
  * Initiate local values - settings object and initialize
  * Twitter library.
  *
  * @return void Constructor does not return
  */
 public function __construct(Ai1ec_Settings $settings = NULL)
 {
     if (NULL === $settings) {
         $settings = Ai1ec_Settings::get_instance();
     }
     $this->_settings = $settings;
     if (NULL === $this->_reinit_connector()) {
         throw new Ai1ec_Oauth_Exception('Twitter provider not configured');
     }
     $this->_state = new Ai1ec_Session_Model();
 }
コード例 #5
0
 /**
  * Check if client accepts gzip and we should compress content
  *
  * Plugin settings, client preferences and server capabilities are
  * checked to make sure we should use gzip for output compression.
  *
  * @uses Ai1ec_Settings::get_instance To early instantiate object
  *
  * @return bool True when gzip should be used
  */
 public static function client_use_gzip()
 {
     if (Ai1ec_Settings::get_instance()->disable_gzip_compression || isset($_SERVER['HTTP_ACCEPT_ENCODING']) && 'identity' === $_SERVER['HTTP_ACCEPT_ENCODING'] || !extension_loaded('zlib')) {
         return false;
     }
     $zlib_output_handler = ini_get('zlib.output_handler');
     if (in_array('ob_gzhandler', ob_list_handlers()) || in_array(strtolower(ini_get('zlib.output_compression')), array('1', 'on')) || !empty($zlib_output_handler)) {
         return false;
     }
     return true;
 }
コード例 #6
0
 /**
  * Check if at least one filter is set in the request
  *
  * @param array $view_args
  * @return boolean
  */
 public static function is_at_least_one_filter_set_in_request(array $view_args)
 {
     if (null === self::$at_least_one_filter_set_in_request) {
         $filter_set = false;
         $ai1ec_settings = Ai1ec_Settings::get_instance();
         // check if something in the filters is set
         foreach (Ai1ec_Cookie_Utility::$types as $type) {
             if (!empty($view_args[$type])) {
                 $filter_set = true;
                 break;
             }
         }
         // check if the default view is set
         if ($ai1ec_settings->default_calendar_view !== $view_args['action']) {
             $filter_set = true;
         }
         self::$at_least_one_filter_set_in_request = $filter_set;
     }
     return self::$at_least_one_filter_set_in_request;
 }
コード例 #7
0
 /**
  * Allow the upgrade notice only on certain pages.
  *
  * @param string|bool $real_value Value from options table or false if none
  *
  * @return string|bool Given value {$real_value} or false
  */
 public function limit_update_notice($real_value)
 {
     // In CRON `get_current_screen()` is not present
     // and we wish to have notice on all "our" pages
     if (isset($_GET['page']) && 0 === strncasecmp($_GET['page'], AI1EC_PLUGIN_NAME, strlen(AI1EC_PLUGIN_NAME)) || !function_exists('get_current_screen')) {
         return $real_value;
     }
     $ai1ec_settings = Ai1ec_Settings::get_instance();
     $screen = get_current_screen();
     $allow_on = array('plugins', 'update-core', $ai1ec_settings->settings_page);
     if (is_object($screen) && isset($screen->id) && in_array($screen->id, $allow_on)) {
         return $real_value;
     }
     return false;
 }
コード例 #8
0
 /**
  * Handle AJAX request for submission of front-end create event form.
  *
  * @return null
  */
 public function submit_front_end_create_event_form()
 {
     global $ai1ec_view_helper, $ai1ec_calendar_helper, $ai1ec_events_helper;
     $ai1ec_settings = Ai1ec_Settings::get_instance();
     $error = false;
     $html = '';
     $default_error_msg = __('There was an error creating your event.', AI1EC_PLUGIN_NAME) . ' ' . __('Please try again or contact the site administrator for help.', AI1EC_PLUGIN_NAME);
     $valid = $this->validate_front_end_create_event_form($message);
     // If valid submission, proceed with event creation.
     if ($valid) {
         // Determine post publish status.
         if (current_user_can('publish_ai1ec_events')) {
             $post_status = 'publish';
         } else {
             if (current_user_can('edit_ai1ec_events')) {
                 $post_status = 'pending';
             } else {
                 if ($ai1ec_settings->allow_anonymous_submissions) {
                     $post_status = 'pending';
                 }
             }
         }
         // Strip slashes if ridiculous PHP setting magic_quotes_gpc is enabled.
         foreach ($_POST as $param_name => $param) {
             if ('ai1ec' === substr($param_name, 0, 5) && is_scalar($param)) {
                 $_POST[$param_name] = stripslashes($param);
             }
         }
         // Build post array from submitted data.
         $post = array('post_type' => AI1EC_POST_TYPE, 'post_author' => get_current_user_id(), 'post_title' => $_POST['post_title'], 'post_content' => $_POST['post_content'], 'post_status' => $post_status);
         // Copy posted event data to new empty event object.
         $event = new Ai1ec_Event();
         $event->post = $post;
         $event->categories = isset($_POST['ai1ec_categories']) ? implode(',', $_POST['ai1ec_categories']) : '';
         $event->tags = isset($_POST['ai1ec_tags']) ? $_POST['ai1ec_tags'] : '';
         $event->allday = isset($_POST['ai1ec_all_day_event']) ? (bool) $_POST['ai1ec_all_day_event'] : 0;
         $event->instant_event = isset($_POST['ai1ec_instant_event']) ? (bool) $_POST['ai1ec_instant_event'] : 0;
         $event->start = isset($_POST['ai1ec_start_time']) ? $_POST['ai1ec_start_time'] : '';
         if ($event->instant_event) {
             $event->end = $event->start + 1800;
         } else {
             $event->end = isset($_POST['ai1ec_end_time']) ? $_POST['ai1ec_end_time'] : '';
         }
         $event->address = isset($_POST['ai1ec_address']) ? $_POST['ai1ec_address'] : '';
         $event->show_map = isset($_POST['ai1ec_google_map']) ? (bool) $_POST['ai1ec_google_map'] : 0;
         $scalar_field_list = array('ai1ec_venue' => FILTER_SANITIZE_STRING, 'ai1ec_cost' => FILTER_SANITIZE_STRING, 'ai1ec_is_free' => FILTER_SANITIZE_NUMBER_INT, 'ai1ec_ticket_url' => FILTER_VALIDATE_URL, 'ai1ec_contact_name' => FILTER_SANITIZE_STRING, 'ai1ec_contact_phone' => FILTER_SANITIZE_STRING, 'ai1ec_contact_email' => FILTER_VALIDATE_EMAIL, 'ai1ec_contact_url' => FILTER_VALIDATE_URL);
         foreach ($scalar_field_list as $scalar_field => $field_filter) {
             $scalar_value = filter_input(INPUT_POST, $scalar_field, $field_filter);
             if (!empty($scalar_value)) {
                 $use_name = substr($scalar_field, 6);
                 $event->{$use_name} = $scalar_value;
             }
         }
         // Save the event to the database.
         try {
             $event->save();
             $ai1ec_events_helper->cache_event($event);
             // Check if uploads are enabled and there is an uploaded file.
             if ((is_user_logged_in() || $ai1ec_settings->allow_anonymous_submissions && $ai1ec_settings->allow_anonymous_uploads) && !empty($_FILES['ai1ec_image']['name'])) {
                 require_once ABSPATH . 'wp-admin/includes/image.php';
                 require_once ABSPATH . 'wp-admin/includes/file.php';
                 require_once ABSPATH . 'wp-admin/includes/media.php';
                 $attach_id = media_handle_upload('ai1ec_image', $event->post_id);
                 if (is_int($attach_id)) {
                     update_post_meta($event->post_id, '_thumbnail_id', $attach_id);
                 }
             }
             // Send the mail
             $admin_notification = Ai1ec_Notification_Factory::create_notification_instance(array(get_option('admin_email')), $ai1ec_settings->admin_add_new_event_mail_body, Ai1ec_Notification_Factory::EMAIL_NOTIFICATION, $ai1ec_settings->admin_add_new_event_mail_subject);
             $edit_url = 'post.php?post=' . $event->post_id . '&action=edit';
             $translations = array('[event_title]' => $_POST['post_title'], '[site_title]' => get_bloginfo('name'), '[site_url]' => site_url(), '[event_admin_url]' => admin_url($edit_url));
             $admin_notification->set_translations($translations);
             $sent = $admin_notification->send();
             if (current_user_can('publish_ai1ec_events')) {
                 $message = sprintf(__('Thank you for your submission. Your event <em>%s</em> was published successfully.', AI1EC_PLUGIN_NAME), $post['post_title']);
                 $link_text = __('View Your Event', AI1EC_PLUGIN_NAME);
                 $link_url = get_permalink($event->post_id);
             } else {
                 $message = sprintf(__('Thank you for your submission. Your event <em>%s</em> will be reviewed and published once approved.', AI1EC_PLUGIN_NAME), $post['post_title']);
                 $link_text = __('Back to Calendar', AI1EC_PLUGIN_NAME);
                 $link_url = $ai1ec_calendar_helper->get_calendar_url();
             }
         } catch (Exception $e) {
             trigger_error(sprintf(__('There was an error during event creation: %s', AI1EC_PLUGIN_NAME), $e->getMessage()), E_USER_WARNING);
             $error = true;
             $message = $default_error_msg;
         }
         $args = array('message_type' => $error ? 'error' : 'success', 'message' => $message, 'link_text' => $link_text, 'link_url' => $link_url);
         $html = $ai1ec_view_helper->get_theme_view('create-event-message.php', $args);
     } else {
         $error = true;
     }
     $response = array('error' => $error, 'message' => $message, 'html' => $html);
     $ai1ec_view_helper->xml_response($response);
 }
コード例 #9
0
    }
    // Not a plugin update request.
    $plugins = unserialize($r['body']['plugins']);
    unset($plugins->plugins[plugin_basename(__FILE__)]);
    unset($plugins->active[array_search(plugin_basename(__FILE__), $plugins->active)]);
    $r['body']['plugins'] = serialize($plugins);
    return $r;
}
add_filter('http_request_args', 'ai1ec_disable_updates', 5, 2);
// Instantiate scheduling utility early, to get all schedules set-up
Ai1ec_Scheduling_Utility::instance();
// ===============================
// = Initialize and setup MODELS =
// ===============================
global $ai1ec_settings;
$ai1ec_settings = Ai1ec_Settings::get_instance();
// If GZIP is causing JavaScript failure following query
// parameter disable compression, until reversing change
// is made. Causative issue: AIOEC-1192.
if (isset($_REQUEST['ai1ec_disable_gzip_compression'])) {
    $ai1ec_settings->disable_gzip_compression = true;
    $ai1ec_settings->save();
}
// This is a fix for AIOEC-73. I need to set those values as soon as possible so that
// the platofrom controller has the fresh data and can act accordingly
// I do not trigger the save action at this point because there are too many things going on
// there and i might break things
if (isset($_POST['ai1ec_save_settings'])) {
    $ai1ec_settings->event_platform = isset($_POST['event_platform']);
    $ai1ec_settings->event_platform_strict = isset($_POST['event_platform_strict']);
}