b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (0.9.x) [ class tree: admin ] [ index: admin ] [ all elements ]

Source for file b2edit.php

Documentation is available at b2edit.php

  1. <?php
  2. /**
  3.  * Editing posts
  4.  *
  5.  * b2evolution - {@link http://b2evolution.net/}
  6.  * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
  7.  * @copyright (c)2003-2005 by Francois PLANQUE - {@link http://fplanque.net/}
  8.  *
  9.  * @package admin
  10.  */
  11.  
  12. /**
  13.  * Includes:
  14.  */
  15. require_once (dirname(__FILE__)'/_header.php');
  16. $admin_tab 'new';
  17. param'action''string' );
  18.  
  19. // All statuses are allowed for display/acting on (including drafts and deprecated posts):
  20. $show_statuses array'published''protected''private''draft''deprecated' );
  21.  
  22. switch($action)
  23. {
  24.     case 'edit':
  25.         /*
  26.          * --------------------------------------------------------------------
  27.          * Display post editing form
  28.          */
  29.         param'post''integer'true );
  30.         $postdata get_postdata$post or dieT_('Oops, no post with this ID.') );
  31.         $edited_Item Item_get_by_ID$post );
  32.         $post_locale $edited_Item->get'locale' );
  33.         $cat $edited_Item->get'main_cat_ID' );
  34.         $blog get_catblog($cat);
  35.         $Blog Blog_get_by_ID$blog );
  36.  
  37.         $admin_pagetitle T_('Editing post');
  38.         require (dirname(__FILE__)'/_menutop.php');
  39.  
  40.         printfT_('#%d in blog: %s')$edited_Item->IDget_bloginfo'name' ) );
  41.  
  42.         require (dirname(__FILE__)'/_menutop_end.php');
  43.  
  44.         $post_status $edited_Item->get'status' );
  45.         // Check permission:
  46.         $current_User->check_perm'blog_post_statuses'$post_statustrue$blog );
  47.  
  48.         $post_title $edited_Item->get'title' );
  49.         $post_urltitle $edited_Item->get'urltitle' );
  50.         $post_url $edited_Item->get'url' );
  51.         $content format_to_edit$edited_Item->get'content' )$edited_Item->get'autobr' ) );
  52.         $post_autobr $edited_Item->get'autobr' );
  53.         $post_pingback 0;
  54.         $post_trackbacks '';
  55.         $post_comments $edited_Item->get'comments' );
  56.         $post_extracats postcats_get_byID$post );
  57.         $edit_date 0;
  58.         $post_issue_date $edited_Item->get'issue_date' );
  59.         $renderers $edited_Item->get'renderers' );
  60.         $aa mysql2date('Y'$post_issue_date  );
  61.         $mm mysql2date('m'$post_issue_date  );
  62.         $jj mysql2date('d'$post_issue_date  );
  63.         $hh mysql2date('H'$post_issue_date  );
  64.         $mn mysql2date('i'$post_issue_date  );
  65.         $ss mysql2date('s'$post_issue_date  );
  66.  
  67.         $form_action 'editpost';
  68.         require(dirname(__FILE__).'/_edit_form.php');
  69.  
  70.         break;
  71.  
  72.  
  73.     case 'editcomment':
  74.         /*
  75.          * --------------------------------------------------------------------
  76.          * Display comment in edit form
  77.          */
  78.         param'comment''integer'true );
  79.         $commentdata get_commentdata($comment,1or dieT_('Oops, no comment with this ID!') );
  80.         $edited_Comment Comment_get_by_ID$comment );
  81.  
  82.         $admin_pagetitle T_('Editing comment');
  83.         require (dirname(__FILE__).'/_menutop.php');
  84.         echo "#".$commentdata['comment_ID'];
  85.         require (dirname(__FILE__).'/_menutop_end.php');
  86.  
  87.         $comment_post_ID $commentdata['comment_post_ID'];
  88.         $comment_postdata get_postdata$comment_post_ID );
  89.         $blog get_catblog$comment_postdata['Category');
  90.         $Blog Blog_get_by_ID$blog );
  91.  
  92.         // Check permission:
  93.         $current_User->check_perm'blog_comments''any'true$blog );
  94.  
  95.         $content $commentdata['comment_content'];
  96.         $content format_to_edit($content($comments_use_autobr == 'always' || $comments_use_autobr == 'opt-out') );
  97.         $post_autobr ($comments_use_autobr == 'always' || $comments_use_autobr == 'opt-out');
  98.         $edit_date 0;
  99.         $aa mysql2date('Y'$commentdata['comment_date']);
  100.         $mm mysql2date('m'$commentdata['comment_date']);
  101.         $jj mysql2date('d'$commentdata['comment_date']);
  102.         $hh mysql2date('H'$commentdata['comment_date']);
  103.         $mn mysql2date('i'$commentdata['comment_date']);
  104.         $ss mysql2date('s'$commentdata['comment_date']);
  105.  
  106.         $form_action 'editedcomment';
  107.         require(dirname(__FILE__).'/_edit_form.php');
  108.  
  109.         break;
  110.  
  111.  
  112.     default:
  113.         /*
  114.          * --------------------------------------------------------------------
  115.          * New post form  (can be a bookmarklet form if mode == bookmarklet )
  116.          */
  117.         $admin_pagetitle T_('New post in blog:');
  118.         require (dirname(__FILE__).'/_menutop.php');
  119.  
  120.         if( ($blog == 0&& $current_User->check_perm'blog_post_statuses''any'false$default_to_blog ) )
  121.         {    // Default blog is a valid choice
  122.             $blog $default_to_blog;
  123.         }
  124.  
  125.         // ---------------------------------- START OF BLOG LIST ----------------------------------
  126.         for$curr_blog_ID blog_list_start();
  127.                     $curr_blog_ID != false;
  128.                     $curr_blog_ID blog_list_next() )
  129.         {
  130.             if$current_User->check_perm'blog_post_statuses''any'false$curr_blog_ID ) )
  131.             {    // Current user is not a member of this blog...
  132.                 continue;
  133.             }
  134.             if$blog == )
  135.             {    // If no selected blog yet, select this one:
  136.                 $blog $curr_blog_ID;
  137.             }
  138.             // This is for when Javascript is not available:
  139.             echo '<a href="b2edit.php?blog='$curr_blog_ID;
  140.             if!empty$mode ) ) echo '&amp;mode='$mode;
  141.             echo '" ';
  142.             ifblog_has_cats$curr_blog_ID ) )
  143.             {    // loop blog has no categories, you cannot post to it.
  144.                 echo 'onclick="alert(\''str_replace"'""\'"T_('Since this blog has no categories, you cannot post to it. You must create categories first.') )'\'); return false;" title="'T_('Since this blog has no categories, you cannot post to it. You must create categories first.')'"';
  145.             }
  146.             elseifblog_has_cats$blog ) )
  147.             {    // loop blog AND current blog both have catageories, normal situation:
  148.                 echo 'onclick="return edit_reload(this.ownerDocument.forms.namedItem(\'post\'), '$curr_blog_ID,' )" title="'T_('Switch to this blog (keeping your input if Javascript is active)')'"';
  149.             }
  150.  
  151.             if$curr_blog_ID == $blog 
  152.                 echo ' class="CurrentBlog"';
  153.             else
  154.                 echo ' class="OtherBlog"';
  155.             echo '>';
  156.             blog_list_iteminfo('shortname');
  157.             echo '</a> ';
  158.         // --------------------------------- END OF BLOG LIST ---------------------------------
  159.  
  160.         require (dirname(__FILE__).'/_menutop_end.php');
  161.  
  162.         if$blog == )
  163.         {
  164.             ?>
  165.             <div class="panelblock">
  166.             <?php printfT_('Since you\'re a newcomer, you\'ll have to wait for an admin to authorize you to post. You can also <a %s>e-mail the admin</a> to ask for a promotion. When you\'re promoted, just reload this page and you\'ll be able to blog. :)')'href="mailto:'.$admin_email.'?subject=b2-promotion"' )?>
  167.             </div>
  168.             <?php
  169.             break;
  170.         }
  171.  
  172.         $Blog Blog_get_by_ID$blog )/* TMP: */ $blogparams get_blogparams_by_ID$blog );
  173.  
  174.         ifblog_has_cats$blog ) )
  175.         {
  176.             ?>
  177.             <div class="panelinfo"><p>
  178.             <?php echo T_('Since this blog has no categories, you cannot post to it. You must create categories first.'?>
  179.             </p></div>
  180.             <?php
  181.             break;
  182.         }
  183.  
  184.         // Check permission:
  185.         $current_User->check_perm'blog_post_statuses''any'true$blog );
  186.  
  187.         // Okay now we know we can use at least one status,
  188.         // but we need to make sure the requested/default one is ok...
  189.         param'post_status''string',  $default_post_status );        // 'published' or 'draft' or ...
  190.         if$current_User->check_perm'blog_post_statuses'$post_statusfalse$blog ) )
  191.         {    // We need to find another one:
  192.             if$current_User->check_perm'blog_post_statuses''published'false$blog ) )
  193.                 $post_status 'published';
  194.             elseif$current_User->check_perm'blog_post_statuses''protected'false$blog ) )
  195.                 $post_status 'protected';
  196.             elseif$current_User->check_perm'blog_post_statuses''private'false$blog ) )
  197.                 $post_status 'private';
  198.             elseif$current_User->check_perm'blog_post_statuses''draft'false$blog ) )
  199.                 $post_status 'draft';
  200.             else
  201.                 $post_status 'deprecated';
  202.         }
  203.  
  204.         $action 'post';
  205.  
  206.         // These are bookmarklet params:
  207.         param'popuptitle''string''' );
  208.         param'popupurl''string''' );
  209.         param'text''html''' );
  210.  
  211.         param'post_autobr''integer'$Settings->get('AutoBR') );  // Use default if nothing provided
  212.         param'post_pingback''integer');
  213.         param'trackback_url''string' );
  214.         $post_trackbacks $trackback_url;
  215.         param'content''html'$text );
  216.         $content format_to_edit$contentfalse );
  217.         param'post_title''html'$popuptitle );
  218.         param'post_urltitle''string''' );
  219.         param'post_url''string'$popupurl );
  220.         $post_url format_to_edit$post_urlfalse );
  221.         param'post_comments''string''open' );        // 'open' or 'closed' or ...
  222.         param'post_extracats''array'array() );
  223.         param'post_locale''string'$default_locale );
  224.         param'renderers''array'array'default' ) );
  225.  
  226.         param'edit_date''integer');
  227.         param'aa''string'date'Y'$localtimenow) );
  228.         param'mm''string'date'm'$localtimenow) );
  229.         param'jj''string'date'd'$localtimenow) );
  230.         param'hh''string'date'H'$localtimenow) );
  231.         param'mn''string'date'i'$localtimenow) );
  232.         param'ss''string'date's'$localtimenow) );
  233.  
  234.         $form_action 'post';
  235.         require(dirname(__FILE__).'/_edit_form.php');
  236. }
  237.  
  238. requiredirname(__FILE__).'/_footer.php' );
  239.  
  240. ?>

Documentation generated on Tue, 20 May 2008 01:51:21 +0200 by phpDocumentor 1.4.2