function __construct()
 {
     global $user_ID, $rcl_options;
     $user_can = $rcl_options['user_public_access_recall'];
     if ($user_can && !$user_ID) {
         return false;
     }
     if (isset($_FILES)) {
         require_once ABSPATH . "wp-admin" . '/includes/image.php';
         require_once ABSPATH . "wp-admin" . '/includes/file.php';
         require_once ABSPATH . "wp-admin" . '/includes/media.php';
     }
     if ($_POST['post-rcl']) {
         $post_id = intval($_POST['post-rcl']);
         $this->post_id = $post_id;
         $pst = get_post($this->post_id);
         $this->post_type = $pst->post_type;
         if ($this->post_type == 'post-group') {
             if (!rcl_can_user_edit_post_group($post_id)) {
                 return false;
             }
         } else {
             if (!current_user_can('edit_post', $post_id)) {
                 return false;
             }
             $user_info = get_userdata($user_ID);
             if ($pst->post_author != $user_ID) {
                 $author_info = get_userdata($pst->post_author);
                 if ($user_info->user_level < $author_info->user_level) {
                     return false;
                 }
             }
             if ($user_info->user_level < 10 && rcl_is_limit_editing($post->post_date)) {
                 return false;
             }
         }
         $this->update = true;
     } else {
         if (!session_id()) {
             session_start();
         }
         unset($_SESSION['new-' . $this->post_type]);
         //session_destroy();
     }
     if ($_POST['posttype']) {
         $post_type = sanitize_text_field(base64_decode($_POST['posttype']));
         if (!get_post_types(array('name' => $post_type))) {
             wp_die(__('Error publishing!', 'wp-recall'));
         }
         $this->post_type = $post_type;
         $this->update = false;
     }
     do_action('init_update_post_rcl', $this);
     add_filter('pre_update_postdata_rcl', array(&$this, 'add_data_post'), 10, 2);
     $this->update_post();
 }
Example #2
0
function rcl_get_edit_post_button($content)
{
    global $post, $user_ID, $current_user, $rcl_options;
    if (is_tax('groups') || $post->post_type == 'page') {
        return $content;
    }
    if (!current_user_can('edit_post', $post->ID)) {
        return $content;
    }
    get_currentuserinfo();
    $user_info = get_userdata($current_user->ID);
    if ($post->post_author != $user_ID) {
        $author_info = get_userdata($post->post_author);
        if ($user_info->user_level < $author_info->user_level) {
            return $content;
        }
    }
    if (!isset($rcl_options['front_editing'])) {
        $rcl_options['front_editing'] = array(0);
    }
    $access = isset($rcl_options['consol_access_rcl']) && $rcl_options['consol_access_rcl'] ? $rcl_options['consol_access_rcl'] : 7;
    if (false !== array_search($user_info->user_level, $rcl_options['front_editing']) || $user_info->user_level >= $access) {
        if ($post->post_type == 'task') {
            if (get_post_meta($post->ID, 'step_order', 1) != 1) {
                return $content;
            }
        }
        if ($user_info->user_level < 10 && rcl_is_limit_editing($post->post_date)) {
            return $content;
        }
        $content = rcl_edit_post_button_html($post->ID) . $content;
    }
    return $content;
}