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

Source for file edit.php

Documentation is available at edit.php

  1. <?php
  2. /**
  3.  * @version $Header$
  4.  * @package articles
  5.  * @subpackage functions
  6.  */
  7.  
  8. // Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
  9. // All Rights Reserved. See below for details and a complete list of authors.
  10. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
  11.  
  12. /**
  13.  * Initialization
  14.  */
  15. require_once '../kernel/setup_inc.php';
  16. require_once( ARTICLES_PKG_PATH . 'BitArticle.php' );
  17.  
  18. // Is package installed and enabled
  19. $gBitSystem->verifyPackage( 'articles' );
  20.  
  21. include_once 'lookup_article_inc.php';
  22.  
  23. if ( $gContent->isValid() ) {
  24.     $gContent->verifyUpdatePermission();
  25. } else {
  26.     $gContent->verifyCreatePermission();
  27. }
  28.  
  29. // if we want to remove a custom image, just nuke all custom image settings at once
  30. if( !empty( $_REQUEST['remove_image'] ) ) {
  31.     $_REQUEST['image_attachment_id'] = NULL;
  32.     $gContent->expungeImage( $gContent->mArticleId, !empty( $_REQUEST['preview_image_path'] ) ? $_REQUEST['preview_image_path'] : NULL );
  33.     // set the preview mode to maintain all settings
  34.     $_REQUEST['preview'] = 1;
  35. }
  36.  
  37. if( isset( $_REQUEST["save"] ) ) {
  38.     // random image code
  39.     if( !( $gContent->hasUserPermission( 'p_articles_approve_submission' ) || $gContent->hasUserPermission( 'p_articles_auto_approve' ) ) && $gBitSystem->isFeatureActive( 'articles_submissions_rnd_img' ) && !$gBitUser->verifyCaptcha( $_REQUEST['captcha'] ) ) {
  40.         $feedback['error'] = tra( "You need to supply the correct code to submit." );
  41.         $_REQUEST['preview'] = TRUE;
  42.         unset( $_REQUEST['save'] );
  43.     }
  44. }
  45. // If we are in preview mode then preview it!
  46. if( !empty( $_REQUEST['preview'] ) ) {
  47.     $article = $gContent->preparePreview( $_REQUEST );
  48.     $gBitSmarty->assign( 'preview', TRUE );
  49.     $gContent->invokeServices( 'content_preview_function', $_REQUEST );
  50.     $gBitSmarty->assign_by_ref( 'article', $article );
  51. } else {
  52.     $gContent->invokeServices( 'content_edit_function' );
  53.     if( empty( $gContent->mInfo['author_name'] ) ) {
  54.         $gContent->mInfo['author_name'] = $gBitUser->getDisplayName();
  55.     }
  56.     $gBitSmarty->assign_by_ref('article', $gContent->mInfo);
  57. }
  58.  
  59. // If the article was saved, show feedback or show result
  60. if( !empty( $_REQUEST['save'] ) ) {
  61.     if( empty( $_REQUEST['rating'] ) ) $_REQUEST['rating'] = 0;
  62.     if( empty( $_REQUEST['topic_id'] ) ) $_REQUEST['topic_id'] = 0;
  63.     if( $gContent->store( $_REQUEST ) ) {
  64.         if( isset ($gContent->mInfo['status_id']) and $gContent->mInfo['status_id'] == ARTICLE_STATUS_PENDING ) {
  65.             bit_redirect( ARTICLES_PKG_URL. "index.php?feedback=".urlencode( tra( 'Your article has been submitted and is awaiting approval.' ) ) );
  66.         } else {
  67.             bit_redirect( ARTICLES_PKG_URL . ( ($gBitSystem->isFeatureActive('pretty_urls_extended') || $gBitSystem->isFeatureActive('pretty_urls')) ? $gContent->mArticleId : "read.php?article_id=" . $gContent->mArticleId ) );
  68.         }
  69.     }
  70. }
  71.  
  72. // Get a topic list
  73. $topics = BitArticleTopic::getTopicList( array( 'active_topic' => TRUE ) );
  74. $gBitSmarty->assign_by_ref( 'topics', $topics );
  75. if ( !empty( $_REQUEST['topic'] ) ) {
  76.     $gBitSmarty->assign( 'topic', $_REQUEST['topic'] );
  77. }
  78. // get list of valid types
  79. $gBitSmarty->assign_by_ref( 'types', $types );
  80.  
  81. if ( !empty( $gContent->mErrors ) || !empty( $feedback ) ) {
  82.     $article = $gContent->preparePreview( $_REQUEST );
  83.     $gBitSmarty->assign_by_ref( 'article', $article );
  84. }
  85.  
  86. $gBitSmarty->assign_by_ref( 'errors', $gContent->mErrors );
  87. $gBitSmarty->assign( 'feedback', ( !empty( $feedback ) ? $feedback : NULL ) );
  88.  
  89. // Display the Index Template
  90. $gBitSmarty->assign( 'show_page_bar', 'n' );
  91. $gBitSystem->display( 'bitpackage:articles/edit_article.tpl', tra( "Articles" ) , array( 'display_mode' => 'edit' ));

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