Exemple #1
0
    $copy = true;
}
if ($action == 'new') {
    if ($evt->eventid > 0) {
        $action = 'edit';
    } else {
        if (!$fsCalendar->userCanAddEvents()) {
            $fatal[] = __('No permission to create event', fsCalendar::$plugin_textdom);
        }
    }
}
if ($action == 'edit') {
    if (empty($evt->eventid)) {
        $fatal[] = __('Event does not exist');
    } else {
        if (!$evt->userCanEditEvent()) {
            if ($fsCalendar->userCanViewEvents()) {
                $action = 'view';
            } else {
                $fatal[] = __('No permission to edit event', fsCalendar::$plugin_textdom);
            }
        }
    }
}
if ($action == 'view') {
    if (empty($evt->eventid)) {
        $fatal[] = __('Event does not exist');
    } else {
        if (!$evt->userCanViewEvent()) {
            $fatal[] = __('No permission to view event', fsCalendar::$plugin_textdom);
        }
 function hookSaveEventFromPost($post_id)
 {
     global $fsCalendar;
     @session_start();
     // Check autosave
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     // Store the postdata in the session, because all data gets lost on the
     // frontend, when a error occurs!
     $_SESSION['fse_postdata'] = $_POST;
     // Check nonce
     if (isset($_POST['eventid']) && $action != 'view') {
         $nonce = $_POST['_fseevent'];
         if (!wp_verify_nonce($nonce, 'event')) {
             $_SESSION['fse_error'] = __('Security check failed', fsCalendar::$plugin_textdom);
             return;
         }
     }
     $active = isset($_POST['fseventactive']) && $_POST['fseventactive'] == true;
     $sync = isset($_POST['fseventsync']) && $_POST['fseventsync'] == true;
     $synconce = isset($_POST['fseventupdate']) && $_POST['fseventupdate'] == true;
     // WP Calender event active?
     if (!$active) {
         return;
     }
     // Only use the main post (nut the revisions)
     if (wp_is_post_revision($post_id) !== false) {
         return;
     }
     // Check if an event exists
     $evt = new fsEvent(0, '', true, $post_id);
     // Neuer Event
     if (empty($evt->eventid)) {
         if (!$fsCalendar->userCanAddEvents()) {
             $_SESSION['fse_error'] = __('You do not have the permission to create events', fsCalendar::$plugin_textdom);
             return;
         }
     } else {
         // Check if needs to be updated!
         //if (!$sync && !$synconce)
         //	return;
         // Check authority to edit
         if (!$evt->userCanEditEvent()) {
             $_SESSION['fse_error'] = __('No permission to edit event', fsCalendar::$plugin_textdom);
             return;
         }
     }
     // Now add all the data
     $evt->postid = $post_id;
     $evt->updatedbypost = $sync;
     // Some date are only updated when requestet
     if ($sync || $synconce) {
         $post = get_post($post_id);
         $cats = wp_get_post_categories($post_id);
         $evt->subject = $post->post_title;
         $evt->description = $post->post_content;
         $evt->categories = array();
         foreach ($cats as $c) {
             $evt->categories[] = $c;
         }
     }
     $evt->allday = isset($_POST['event_allday']) ? true : false;
     $evt->date_admin_from = $_POST['event_from'];
     $evt->date_admin_to = $_POST['event_to'];
     $evt->time_admin_from = $_POST['event_tfrom'];
     $evt->time_admin_to = $_POST['event_tto'];
     $evt->location = $_POST['event_location'];
     if (($ret = $evt->saveToDataBase()) === true) {
         $_SESSION['fse_success'] = 'Successfully saved';
     } else {
         $_SESSION['fse_error'] = $ret;
     }
     return $post_id;
 }
Exemple #3
0
                echo '<img src="' . fsCalendar::$plugin_img_url . 'synchronized.png" alt="" />';
            }
            ?>
						<a class="row-title" 
							title="<?php 
            _e('Edit', fsCalendar::$plugin_textdom);
            ?>
 <?php 
            echo esc_attr($e->subject);
            ?>
" 
							href="<?php 
            echo $bl;
            ?>
&amp;action=<?php 
            echo $e->userCanEditEvent() == true ? 'edit' : 'view';
            ?>
&amp;event=<?php 
            echo esc_attr($e->eventid);
            ?>
">
						<?php 
            echo esc_attr($e->subject);
            ?>
</a>
						<?php 
            switch ($e->state) {
                case 'draft':
                    echo ' - ' . __('Draft', fsCalendar::$plugin_textdom);
                    break;
            }