id; if (!$user_id) { $dummy=oqp_get_dummy_user(); if (($guest_posting) && ($dummy)) { $user_id=$dummy->ID; $messages['logged']=__("As you are not logged; you have to give us your name and email.",'oqp'); }else { $errors['logged']=__("You must be logged to send this form.",'oqp'); } } if ($_REQUEST['oqp_blog_id']) $blog_id=$_REQUEST['oqp_blog_id']; if ($_POST['oqp-form-id']==$form_id) { //be sure we handle the good form (if there are several OQP forms on the page) if ($_POST['oqp-action']=='oqp-post') { $sent_title = trim($_POST['oqp_title']); $sent_desc = trim($_POST['oqp_desc']); if (!$sent_title) $errors[]=__('Please enter a title','oqp'); if (($sent_title) && (!$sent_desc)) $errors[]=__('Empty post, uh ?','oqp'); //format taxonomies before saving foreach ($taxonomies as $tax_slug=>$tax_settings) { unset($value); $value = $_POST['oqp_'.$tax_slug]; //check if the taxonomy value can be empty if (!$value) { if ($tax_settings['required']) { $tax_obj=get_taxonomy($tax_slug); $errors[]=sprintf(__('You have to choose a value for the %s','oqp'),''.$tax_obj->label.''); } } $taxonomies[$tax_slug]['selected']=$value; } if ($dummy) { $sent_dummy_name = trim($_POST['oqp_dummy_name']); $sent_dummy_email = trim($_POST['oqp_dummy_email']); if (!$sent_dummy_name) $errors[]=__('Please enter your name','oqp'); if (!is_email($sent_dummy_email)) $errors[]=__('Please enter a valid email address.'); } if (!$errors) { $edit_post_id = $_POST['oqp-post-id']; $sent_blog_id = $_POST['oqp-blog-id']; $post_type = $post_type; $cats_tax = $cats; $tags_tax = $tags; $author_id = $user_id; oqp_save_post($author_id,$sent_title,$sent_desc,$post_type,$taxonomies,$sent_dummy_name,$sent_dummy_email,$edit_post_id,$sent_blog_id); } } } if ($_REQUEST['oqp-action']) { $post_id = $_REQUEST['oqp-post-id']; $blog_id = $_REQUEST['oqp-blog-id']; $oqp_post=oqp_get_the_post($post_id,$blog_id); if ($oqp_post) { if ($_REQUEST['oqp-action']=='edit') { }else { unset($messages['logged']); //do not show it when it is posted if ($_REQUEST['oqp-action']=='saved') { if ($oqp_post->post_status=='publish') $messages[]=sprintf(__('Your post %s has been published.','oqp'),''.$oqp_post->post_title.''); elseif ($oqp_post->post_status=='pending') $messages[]=sprintf(__('Your post %s is now awaiting moderation.','oqp'),''.$oqp_post->post_title.''); }elseif ($_REQUEST['oqp-action']=='updated') { $messages[]=sprintf(__('Post %s updated.','oqp'),''.$oqp_post->post_title.''); } } $can_edit_post=oqp_user_can_edit_the_post($post_id,$current_user->id,$_REQUEST['oqp-key'],$blog_id); //check the user can edit a published post if (!$can_edit_post) { $errors[]=__('You are not allowed to edit this post.','oqp'); }else { if ($oqp_post->post_status=='publish') { if (!oqp_user_can_for_blog('edit_published_posts',$user_id,$blog_id)) { //user_id is the guest user ID or the current user id $can_edit_post=false; $errors[]=__('You are not allowed to edit a published post.','oqp'); } } } //get form datas for the post if ($can_edit_post) { foreach($taxonomies as $tax_slug=>$tax_settings) { $taxonomies[$tax_slug]['selected']=''; $tax_list = oqp_get_the_terms_list($tax_slug,$post_id,$blog_id); //$cats = the taxonomy, see oqp_block args. if (!is_array($tax_list)) { //no taxonomy error $taxonomies[$tax_slug]['selected']=strip_tags($tax_list); } } $post_title=$oqp_post->post_title; $post_desc=$oqp_post->post_content; if (!$current_user->id) { //user is a guest //TO FIX TO CHECK SWITCH BLOG ? $dummy_name=get_post_meta($post_id,'oqp_guest_name', true); $dummy_email=get_post_meta($post_id,'oqp_guest_email', true); } } }else { if ($_REQUEST['oqp-action']=='edit') { $errors[]=__('This post do not exists.','oqp'); }else { $errors[]=__('Error while trying to save the post.','oqp'); } } } ?>

"; } ?>

"; } ?>

$taxonomy) { unset($tax_obj); unset($tax_html); $tax_obj = get_taxonomy( $tax_slug ); //is it hierarchical ? if (!isset($taxonomy['hierarchical'])) { $taxonomy['hierarchical']=$tax_obj->hierarchical; } $html='

'."\n"; $html.="\t".''."\n"; if (!$taxonomy['hierarchical']) { $tax_html.=oqp_js_autocomplete($blog_id,"oqp_form_".$form_id,"oqp_".$tax_obj->name,$tax_obj->name); $tax_html.="\t".''."\n"; }else { $tax_hierarchical_defaults=array( 'type'=>'checkbox', 'style'=>false, 'taxonomy'=>$tax_obj->name, 'echo'=>false, 'hide_empty'=>false ); $taxonomy = wp_parse_args($taxonomy,$tax_hierarchical_defaults); $tax_html.="\t".'

\n"; } $html.=apply_filters('oqp_form_render_taxonomy_'.$tax_obj->name,$tax_html,$tax_obj->name,$taxonomy['selected']); $html.='

'."\n"; echo $html; } } do_action('oqp_form'); ?>