blogs
[ class tree: blogs ] [ index: blogs ] [ all elements ]

Source for file post.php

Documentation is available at post.php

  1. <?php
  2. /**
  3.  * @version $Header$
  4.  *
  5.  * @package blogs
  6.  * @subpackage functions
  7.  */
  8.  
  9. // Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
  10. // All Rights Reserved. See below for details and a complete list of authors.
  11. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
  12.  
  13. /**
  14.  * required setup
  15.  */
  16. require_once'../kernel/setup_inc.php' );
  17.  
  18. $gBitSystem->verifyPackage'blogs' );
  19.  
  20.  
  21. require_onceBLOGS_PKG_PATH.'lookup_post_inc.php' );
  22. require_onceBLOGS_PKG_PATH.'BitBlog.php');
  23.  
  24. if isset$_REQUEST["blog_id") ) {
  25.     #setup so we know what the default target blog is in the template
  26.     $gBlog new BitBlog($_REQUEST["blog_id"]);
  27.     $gBlog->load();
  28.     $gBitSmarty->assign('default_target_blog_content_id',$gBlog->mContentId );
  29. }else {
  30.     $gBlog new BitBlog();
  31. }     
  32.  
  33. //must be owner or admin to edit an existing post
  34. if$gContent->isValid() ) {
  35.     $gContent->verifyUpdatePermission();
  36. else {
  37.     $gContent->verifyCreatePermission();
  38. }
  39.  
  40.  
  41. // nuke post if requested
  42. if!empty$_REQUEST['action') ) {
  43.     if$_REQUEST['action'== 'remove' && $gContent->isValid() ) {
  44.         ifisset$_REQUEST["confirm") ) {
  45.             $gBitUser->verifyTicket();
  46.             $redirect !empty$gContent->mInfo['blogs'BLOGS_PKG_URL.'view.php?content_id='.key$gContent->mInfo['blogs'BLOGS_PKG_URL;
  47.             if$gContent->expunge() ) {
  48.                 bit_redirect$redirect );
  49.             else {
  50.                 $feedback['error'$gContent->mErrors;
  51.             }
  52.         }
  53.         $gBitSystem->setBrowserTitle'Confirm removal of '.$gContent->getTitle() );        
  54.         $formHash['remove'TRUE;
  55.         $formHash['action''remove';
  56.         $formHash['post_id'$_REQUEST['post_id'];
  57.         $msgHash array(
  58.             'label' => tra('Remove Blog Post'),
  59.             'confirm_item' => $gContent->getTitle(),
  60.             'warning' => tra'This will remove the above blog post.' ),
  61.             'error' => tra'This cannot be undone!' ),
  62.         );
  63.         $gBitSystem->confirmDialog$formHash$msgHash );
  64.     }
  65. }
  66.  
  67. if (isset($_REQUEST['remove_image'])) {
  68.     $gContent->expungeAttachment$_REQUEST['remove_image');
  69. }
  70.  
  71. ifisset$_REQUEST['format_guid'&& !isset$gContent->mInfo['format_guid') ) {
  72.     $formInfo['format_guid'$gContent->mInfo['format_guid'$_REQUEST['format_guid']
  73. }
  74.  
  75. if (isset($_REQUEST["preview"])) {
  76.     $post $gContent->preparePreview$_REQUEST );
  77.     $gBitSmarty->assign'preview'TRUE );
  78.     $gContent->invokeServices'content_preview_function' );
  79.     $gBitSmarty->assign_by_ref'post_info'$post );
  80.     /* minor hack to accomodate the view_blog_post.tpl
  81.      * this can eventually be removed with a change to the tpl to use post_info['parsed_data'] 
  82.      * but requires clean up in a few places.
  83.      */
  84.     $gBitSmarty->assign('parsed_data'$post['parsed_data']);    
  85. elseif (isset($_REQUEST['save_post']|| isset($_REQUEST['save_post_exit'])) {
  86.     // Editing page needs general ticket verification
  87.     $gBitUser->verifyTicket();
  88.  
  89.     // preserve a copy of the request data because if store fails we need to reprocess 
  90.     $requestCopy $_REQUEST;
  91.  
  92.     if$gContent->store$_REQUEST ) ) {
  93.         $postid $gContent->mPostId;
  94.         $gBitSmarty->assign('post_id'$gContent->mPostId);
  95.  
  96.         if (isset($_REQUEST['save_post_exit'])) {
  97.             header ("location: ".BLOGS_PKG_URL."view_post.php?post_id=$postid");
  98.             die;
  99.         }
  100.         
  101.         $parsed_data $gContent->parseData$gContent->getField('data')($gContent->getField('format_guid'$gContent->getField('format_guid''tikiwiki') );
  102.  
  103.         $gBitSmarty->assign'title'$gContent->getTitle('title') );
  104.         $gBitSmarty->assign'trackbacks_to'explode(','$gContent->getField('trackbacks_to')) );
  105.         $gBitSmarty->assign'parsed_data'$parsed_data );
  106.     else {
  107.         $post $gContent->preparePreview$requestCopy );
  108.         $gContent->invokeServices'content_preview_function' );
  109.         $gBitSmarty->assign_by_ref'post_info'$post );
  110.         $gBitSmarty->assign('parsed_data'$post['parsed_data']);    
  111.     }
  112. elseif!empty$_REQUEST['edit') ) {
  113. else {
  114.     $gContent->invokeServices'content_edit_function' );
  115.     if$gContent->isValid(&& $gContent->getContentStatus(== -&& $gContent->getField('publish_date'$gBitSystem->getUTCTime() ){
  116.         /* if we are working with a draft and a future publish date is not set 
  117.          * then we automatically move the publish date up to NOW to help users from publishing in the past.
  118.          * if they set it backward and preview or save the back date will be preserved.
  119.          */
  120.         $gContent->mInfo['publish_date'$gBitSystem->getUTCTime()
  121.     }
  122.     $gBitSmarty->assign_by_ref('post_info'$gContent->mInfo);
  123. }
  124.  
  125. // Get List of available blogs
  126. $listHash array();
  127. $listHash['sort_mode''title_asc';
  128. $listHash['max_records'BIT_MAX_RECORDS;
  129. if!$gBitUser->hasPermission'p_blogs_admin' )) {
  130.     $listHash['user_id'$gBitUser->mUserId;
  131.     $listHash['content_perm_name''p_blogs_post';
  132. }
  133. $blogs $gBlog->getList$listHash );
  134. $availableBlogs array();
  135. foreacharray_keys$blogs as $blogContentId {
  136.     $availableBlogs[$blogContentId$blogs[$blogContentId]['title'];
  137. }
  138. $gBitSmarty->assign'availableBlogs'$availableBlogs );
  139.  
  140. $gBitSmarty->assign_by_ref('blogs'$blogs['data']);
  141. if (isset($_REQUEST['blog_content_id'])) {
  142.     $gBitSmarty->assign('blog_content_id'$_REQUEST['blog_content_id');
  143. }
  144.  
  145. $gBitSmarty->assign_by_ref'errors'$gContent->mErrors );
  146.  
  147. $gBitSmarty->assign'textarea_label'tra('Post Content') );
  148.  
  149. // tweak title displayed for better usuability in browser history
  150. $gBitSystem->display'bitpackage:blogs/blog_post.tpl'$gContent->isValid(tra"Edit Blog Post" ).": ".$gContent->getTitle(tra"Create Blog Post" array'display_mode' => 'edit' ));
  151. ?>

Documentation generated on Wed, 29 Jul 2015 13:57:15 +0000 by phpDocumentor 1.5.0-lsces