function rcl_can_user_edit_post_group($post_id) { global $user_ID; $group_id = rcl_get_group_id_by_post($post_id); if (!$group_id) { return false; } if (current_user_can('edit_post', $post_id)) { return true; } $rcl_group = rcl_get_group($group_id); if ($rcl_group->admin_id == $user_ID) { return true; } if (rcl_get_group_user_status($user_ID, $group_id) == 'moderator') { return true; } return false; }
function __construct($atts) { global $editpost, $group_id, $rcl_options, $user_ID, $formData; $editpost = false; $this->can_edit = true; extract(shortcode_atts(array('cats' => false, 'id' => 1, 'id_upload' => 'upload-public-form', 'accept' => 'image/*', 'post_type' => 'post', 'type_editor' => null, 'wp_editor' => null, 'group_id' => $group_id), $atts)); $this->post_type = $post_type; $this->id_upload = $id_upload; $this->terms = $cats; $this->form_id = $id; $this->accept = $accept; if (!isset($wp_editor)) { if (isset($rcl_options['wp_editor'])) { $cnt = count($rcl_options['wp_editor']); if ($cnt == 1) { $type = $rcl_options['wp_editor'][0]; } else { $type = 3; } } $this->wp_editor = isset($type) ? $type : 0; } else { $this->wp_editor = $wp_editor; } $this->type_editor = $type_editor; if (!isset($this->type_editor)) { $this->type_editor = isset($rcl_options['type_editor-' . $this->post_type]) ? $rcl_options['type_editor-' . $this->post_type] : $rcl_options['type_text_editor']; } if (isset($_GET['rcl-post-edit'])) { $this->post_id = $_GET['rcl-post-edit']; $editpost = get_post($this->post_id); $this->post_type = $editpost->post_type; if ($this->post_type == 'post-group') { if (!rcl_can_user_edit_post_group($this->post_id) && !current_user_can('edit_post', $this->post_id)) { $this->can_edit = false; } $group_id = rcl_get_group_id_by_post($this->post_id); $widget_options = rcl_get_group_option($group_id, 'widgets_options'); if (isset($widget_options['group-public-form-widget'])) { $this->type_editor = $widget_options['group-public-form-widget']['type_form']; } } else { if (!current_user_can('edit_post', $this->post_id)) { $this->can_edit = false; } } $form_id = get_post_meta($this->post_id, 'publicform-id', 1); if ($form_id) { $this->form_id = $form_id; } } $taxs = array(); $taxs = apply_filters('taxonomy_public_form_rcl', $taxs); if (isset($rcl_options['accept-' . $this->post_type])) { $this->accept = $rcl_options['accept-' . $this->post_type]; } $formData = (object) array('form_id' => $this->form_id, 'post_id' => $this->post_id, 'post_type' => $this->post_type, 'id_upload' => $this->id_upload, 'terms' => $this->terms, 'accept' => $this->accept, 'type_editor' => $this->type_editor, 'wp_editor' => $this->wp_editor, 'taxonomy' => $taxs); if ($this->user_can()) { rcl_fileapi_scripts(); rcl_fileupload_scripts(); } if ($this->post_id) { add_filter('after_public_form_rcl', array(&$this, 'delete_button'), 10, 2); } }