protected function create_post(array $record)
 {
     $organizer = $this->build_organizer_array($record);
     $id = TribeEventsAPI::createOrganizer($organizer);
     TribeEventsAPI::updateOrganizer($id, $organizer);
     return $id;
 }
 /**
  * Saves the event organizer information passed via an event
  */
 private static function saveEventOrganizer($data, $post = null, $post_status = 'publish')
 {
     if (isset($data['OrganizerID']) && $data['OrganizerID'] > 0) {
         if (count($data) == 1) {
             // Only an ID was passed and we should do nothing.
             return $data['OrganizerID'];
         } else {
             return TribeEventsAPI::updateOrganizer($data['OrganizerID'], $data);
         }
     } else {
         return TribeEventsAPI::createOrganizer($data, $post_status);
     }
 }
 public function save_organizer_data($postID = null, $post = null)
 {
     global $_POST;
     // don't do anything on autosave or auto-draft either or massupdates
     // Or inline saves, or data being posted without a organizer Or
     // finally, called from the save_post action, but on save_posts that
     // are not organizer posts
     if (!isset($_POST['organizer'])) {
         $_POST['organizer'] = null;
     }
     if (wp_is_post_autosave($postID) || $post->post_status == 'auto-draft' || isset($_GET['bulk_edit']) || isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save' || !$_POST['organizer'] || $post->post_type != self::ORGANIZER_POST_TYPE && $postID) {
         return;
     }
     if (!current_user_can('edit_tribe_organizers')) {
         return;
     }
     //There is a possibility to get stuck in an infinite loop.
     //That would be bad.
     remove_action('save_post', array($this, 'save_organizer_data'), 16, 2);
     $data = stripslashes_deep($_POST['organizer']);
     $organizer_id = TribeEventsAPI::updateOrganizer($postID, $data);
     /**
      * Put our hook back
      * @link http://codex.wordpress.org/Plugin_API/Action_Reference/save_post#Avoiding_infinite_loops
      */
     add_action('save_post', array($this, 'save_organizer_data'), 16, 2);
     return $organizer_id;
 }
 /**
  * Make sure the organizer meta gets saved
  *
  * @param int $postID The organizer id.
  * @param WP_Post $post The post object.
  * @return null|void
  */
 public function save_organizer_data($postID = null, $post = null)
 {
     global $current_screen;
     if (!empty($current_screen) && $current_screen->id == 'tribe_organizer') {
         // single organizer
         $_POST['Organizer'] = isset($_POST['organizer']) ? stripslashes_deep($_POST['organizer']) : null;
     }
     // Don't save the organizer meta if there wasn't one submitted
     if (empty($_POST['Organizer'])) {
         return;
     }
     // @TODO move this to the API function
     if (!current_user_can('edit_tribe_organizers')) {
         return;
     }
     $data = stripslashes_deep($_POST['Organizer']);
     TribeEventsAPI::updateOrganizer($postID, $data);
 }
示例#5
0
 /**
  * Update an Organizer
  *
  * @param int $postId ID of the Organizer to be modified.
  * @param array $args Args for updating the post. See {@link tribe_create_organizer()} for more info.
  * @return int ID of the Organizer that was created. False if update failed.
  * @link http://codex.wordpress.org/Function_Reference/wp_update_post
  * @see wp_update_post()
  * @see tribe_create_organizer()
  * @category Organizer Functions
  * @since 2.0.1
  */
 function tribe_update_organizer($postId, $args)
 {
     $postId = TribeEventsAPI::updateOrganizer($postId, $args);
     return $postId;
 }
 /**
  * Make sure the organizer meta gets saved
  *
  * @param int     $postID The organizer id.
  * @param WP_Post $post   The post object.
  *
  * @return null|void
  */
 public function save_organizer_data($postID = null, $post = null)
 {
     // was an organizer submitted from the single organizer post editor?
     if (empty($_POST['post_ID']) || $_POST['post_ID'] != $postID || empty($_POST['organizer'])) {
         return;
     }
     // is the current user allowed to edit this venue?
     if (!current_user_can('edit_tribe_organizer', $postID)) {
         return;
     }
     $data = stripslashes_deep($_POST['organizer']);
     TribeEventsAPI::updateOrganizer($postID, $data);
 }
 protected function update_post($post_id, array $record)
 {
     $organizer = $this->build_organizer_array($record);
     TribeEventsAPI::updateOrganizer($post_id, $organizer);
 }
 /**
  * Organizer form for events.
  *
  * @param int $tribe_organizer_id The organizer's ID.
  * @return string The form.
  * @author Nick Ciske
  * @since 1.0
  */
 public function doOrganizerForm($tribe_organizer_id)
 {
     add_filter('tribe-post-origin', array($this, 'filterPostOrigin'));
     $output = '';
     if (empty($tribe_organizer_id)) {
         return '<p>' . __('Organizer not found.', 'tribe-events-community') . '</p>';
     }
     if (!class_exists('TribeEventsPro')) {
         return __('This feature is not currently enabled.', 'tribe-events-community');
     }
     if (!is_user_logged_in()) {
         return $this->login_form(__('Please log in to edit this organizer', 'tribe-events-community'));
     }
     if (!current_user_can('edit_post', $tribe_organizer_id)) {
         $output .= '<p>' . __('You do not have permission to edit this organizer.', 'tribe-events-community') . '</p>';
         return $output;
     }
     $this->loadScripts = true;
     $output .= '<div id="tribe-community-events" class="form organizer">';
     if (isset($_POST['community-event']) && $_POST['community-event'] && check_admin_referer('ecp_organizer_submission')) {
         if (isset($_POST['post_title']) && $_POST['post_title']) {
             require_once 'tribe-community-events-submission-scrubber.php';
             require_once 'tribe-community-events-organizer-submission-scrubber.php';
             $_POST['ID'] = $tribe_organizer_id;
             $scrubber = new TribeCommunityEvents_OrganizerSubmissionScrubber($_POST);
             $_POST = $scrubber->scrub();
             remove_action('save_post_' . TribeEvents::ORGANIZER_POST_TYPE, array(TribeEvents::instance(), 'save_organizer_data'), 16, 2);
             wp_update_post(array('post_title' => $_POST['post_title'], 'ID' => $tribe_organizer_id, 'post_content' => $_POST['post_content']));
             TribeEventsAPI::updateOrganizer($tribe_organizer_id, $_POST['organizer']);
             $this->enqueueOutputMessage(__('Organizer updated.', 'tribe-events-community'));
             /*
             // how it should work, but updateOrganizer does not return a boolean
             if ( TribeEventsAPI::updateOrganizer($tribe_organizer_id, $_POST) ) {
             	$this->enqueueOutputMessage( __("Organizer updated.",'tribe-events-community') );
             }else{
             	$this->enqueueOutputMessage( __("There was a problem saving your organizer, please try again.",'tribe-events-community'), 'error' );
             }
             */
         } else {
             $this->enqueueOutputMessage(__('Organizer name cannot be blank.', 'tribe-events-community'), 'error');
         }
     } else {
         if (isset($_POST['community-event'])) {
             $this->enqueueOutputMessage(__('There was a problem updating this organizer, please try again.', 'tribe-events-community'), 'error');
         }
     }
     global $post;
     $post = get_post(intval($tribe_organizer_id));
     ob_start();
     include TribeEventsTemplates::getTemplateHierarchy('community/edit-organizer');
     $output .= ob_get_clean();
     $output .= '</div>';
     remove_filter('tribe-post-origin', array($this, 'filterPostOrigin'));
     return $output;
 }