Skip to content

Commit

Permalink
move to gContent perm functions to fully support liberty content perm…
Browse files Browse the repository at this point in the history
…issions
  • Loading branch information
Max Kremmel committed Jul 6, 2007
1 parent 61d47f9 commit e89540d
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 39 deletions.
8 changes: 4 additions & 4 deletions BitArticle.php
@@ -1,6 +1,6 @@
<?php
/**
* @version $Header: /cvsroot/bitweaver/_bit_articles/BitArticle.php,v 1.123 2007/06/26 08:51:51 lsces Exp $
* @version $Header: /cvsroot/bitweaver/_bit_articles/BitArticle.php,v 1.124 2007/07/06 16:37:22 squareing Exp $
* @package article
*
* Copyright( c )2004 bitweaver.org
Expand All @@ -9,14 +9,14 @@
* All Rights Reserved. See copyright.txt for details and a complete list of authors.
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
*
* $Id: BitArticle.php,v 1.123 2007/06/26 08:51:51 lsces Exp $
* $Id: BitArticle.php,v 1.124 2007/07/06 16:37:22 squareing Exp $
*
* Article class is used when accessing BitArticles. It is based on TikiSample
* and builds on core bitweaver functionality, such as the Liberty CMS engine.
*
* created 2004/8/15
* @author wolffy <wolff_borg@yahoo.com.au>
* @version $Revision: 1.123 $ $Date: 2007/06/26 08:51:51 $ $Author: lsces $
* @version $Revision: 1.124 $ $Date: 2007/07/06 16:37:22 $ $Author: squareing $
*/

/**
Expand Down Expand Up @@ -274,7 +274,7 @@ function verify( &$pParamHash ) {

if( @$this->verifyId( $pParamHash['status_id'] ) ) {
if( $pParamHash['status_id'] > ARTICLE_STATUS_PENDING ) {
if( $gBitUser->hasPermission( 'p_articles_approve_submission' ) || $gTikiuser->hasPermission( 'p_articles_auto_approve' ) ) {
if( $gBitUser->hasPermission( 'p_articles_approve_submission' )) {
$pParamHash['article_store']['status_id'] =( int )( $pParamHash['status_id'] );
} else {
$pParamHash['article_store']['status_id'] = ARTICLE_STATUS_PENDING;
Expand Down
1 change: 1 addition & 0 deletions admin/schema_inc.php
Expand Up @@ -98,6 +98,7 @@
array('p_articles_edit', 'Can edit articles', 'editors', ARTICLES_PKG_NAME),
array('p_articles_remove', 'Can remove articles', 'editors', ARTICLES_PKG_NAME),
array('p_articles_read', 'Can read articles', 'basic', ARTICLES_PKG_NAME),
array('p_articles_read_history', 'Can read article history', 'registered', ARTICLES_PKG_NAME),
array('p_articles_submit', 'Can submit articles', 'basic', ARTICLES_PKG_NAME),
array('p_articles_edit_submission', 'Can edit submissions', 'editors', ARTICLES_PKG_NAME),
array('p_articles_remove_submission', 'Can remove submissions', 'editors', ARTICLES_PKG_NAME),
Expand Down
6 changes: 3 additions & 3 deletions article_history.php
Expand Up @@ -20,8 +20,8 @@
require_once( ARTICLES_PKG_PATH.'BitArticle.php' );

$gBitSystem->verifyPackage( 'articles' );
$gBitSystem->verifyPermission( 'p_articles_read', tra( "Permission denied you cannot browse this article history" ) );
$gBitSystem->verifyPermission( 'p_articles_read_history', tra( "Permission denied you cannot browse this article history" ) );
$gBitSystem->verifyPermission( 'p_articles_read' );
$gBitSystem->verifyPermission( 'p_articles_read_history' );

if( !isset( $_REQUEST["article_id"] ) ) {
$gBitSystem->fatalError( tra( "No article indicated" ));
Expand All @@ -35,7 +35,7 @@
}

// additionally we need to check if this article is a submission and see if user has perms to view it.
if( $gContent->getField( 'status_id' ) != ARTICLE_STATUS_APPROVED && !( $gBitUser->hasPermission( 'p_articles_edit_submission' ) || $gBitUser->hasPermission( 'p_articles_edit_submission' ) || $gBitUser->hasPermission( 'p_articles_edit_submission' ) || $gBitUser->isAdmin() ) ) {
if( $gContent->getField( 'status_id' ) != ARTICLE_STATUS_APPROVED && !( $gContent->hasUserPermission( 'p_articles_edit_submission' ) || $gContent->hasUserPermission( 'p_articles_edit_submission' ) || $gContent->hasUserPermission( 'p_articles_edit_submission' ) || $gBitUser->isAdmin() ) ) {
$gBitSmarty->assign( 'msg', tra( "Permission denied you cannot view this article" ) );
$gBitSystem->display( "error.tpl" );
die;
Expand Down
4 changes: 2 additions & 2 deletions articles_rss.php
@@ -1,6 +1,6 @@
<?php
/**
* @version $Header: /cvsroot/bitweaver/_bit_articles/articles_rss.php,v 1.19 2007/06/13 19:39:05 squareing Exp $
* @version $Header: /cvsroot/bitweaver/_bit_articles/articles_rss.php,v 1.20 2007/07/06 16:37:22 squareing Exp $
* @package article
* @subpackage functions
*/
Expand All @@ -21,7 +21,7 @@
$rss->description = $gBitSystem->getConfig( 'articles_rss_description', $gBitSystem->getConfig( 'site_title' ).' - '.tra( 'RSS Feed' ) );

// check permission to view articles
if( !$gBitUser->hasPermission( 'p_articles_read' ) ) {
if( !$gContent->hasUserPermission( 'p_articles_read' ) ) {
require_once( RSS_PKG_PATH."rss_error.php" );
} else {
// check if we want to use the cache file
Expand Down
16 changes: 7 additions & 9 deletions edit.php
@@ -1,6 +1,6 @@
<?php
/**
* @version $Header: /cvsroot/bitweaver/_bit_articles/edit.php,v 1.36 2007/06/20 21:16:21 lsces Exp $
* @version $Header: /cvsroot/bitweaver/_bit_articles/edit.php,v 1.37 2007/07/06 16:37:22 squareing Exp $
* @package article
* @subpackage functions
*/
Expand All @@ -24,20 +24,18 @@
include_once('lookup_article_inc.php');

$isOwner = FALSE;
if( $gBitUser->hasPermission('p_articles_admin' ) || $gBitUser->hasPermission( 'p_articles_edit' ) ) {
if( $gContent->hasAdminPermission() || $gContent->hasUserPermission( 'p_articles_edit' ) || $gContent->isOwner() ) {
$isOwner = TRUE;
} elseif( !empty($gContent->mInfo['user_id'] ) && $gContent->mInfo['user_id'] == $gBitUser->mUserId ) {
$isOwner = TRUE;
} elseif( !$gContent->mArticleId && $gBitUser->hasPermission( 'p_articles_submit' ) ) {
} elseif( !$gContent->mArticleId && $gContent->hasUserPermission( 'p_articles_submit' ) ) {
$isOwner = TRUE;
}

// Now check permissions to access this page
if( !$isOwner ) {
if ( empty( $gContent->mArticleId ) ) {
$gBitSystem->fatalPermission('p_articles_submit');
if ( empty( $gContent->mArticleId )) {
$gBitSystem->fatalPermission( 'p_articles_submit' );
} else {
$gBitSystem->fatalPermission('p_articles_edit');
$gBitSystem->fatalPermission( 'p_articles_edit' );
}
}

Expand All @@ -50,7 +48,7 @@
}

// random image code
if( !( $gBitUser->hasPermission( 'p_articles_approve_submission' ) || $gBitUser->hasPermission( 'p_articles_auto_approve' ) ) && !empty( $_REQUEST["save"] ) && $gBitSystem->isFeatureActive( 'articles_submissions_rnd_img' ) && ( !isset( $_SESSION['random_number'] ) || $_SESSION['random_number'] != $_REQUEST['rnd_img'] ) ) {
if( !( $gContent->hasUserPermission( 'p_articles_approve_submission' ) || $gContent->hasUserPermission( 'p_articles_auto_approve' ) ) && !empty( $_REQUEST["save"] ) && $gBitSystem->isFeatureActive( 'articles_submissions_rnd_img' ) && ( !isset( $_SESSION['random_number'] ) || $_SESSION['random_number'] != $_REQUEST['rnd_img'] ) ) {
$feedback['error'] = tra( "You need to supply the correct code to submit." );
$_REQUEST['preview'] = TRUE;
unset( $_REQUEST['save'] );
Expand Down
4 changes: 2 additions & 2 deletions list.php
@@ -1,6 +1,6 @@
<?php
/**
* @version $Header: /cvsroot/bitweaver/_bit_articles/list.php,v 1.18 2007/06/13 19:39:05 squareing Exp $
* @version $Header: /cvsroot/bitweaver/_bit_articles/list.php,v 1.19 2007/07/06 16:37:22 squareing Exp $
* @package article
* @subpackage functions
*/
Expand Down Expand Up @@ -88,7 +88,7 @@
}
}

if( empty( $_REQUEST['status_id'] ) || (!(($gBitSystem->isFeatureActive('articles_auto_approve') && $gBitUser->isRegistered())||$gBitUser->hasPermission( 'p_articles_edit_submission' ) || $gBitUser->hasPermission( 'p_articles_admin' ) ) ) ) {
if( empty( $_REQUEST['status_id'] ) || (!(($gBitSystem->isFeatureActive('articles_auto_approve') && $gBitUser->isRegistered()) || $gBitUser->hasPermission( 'p_articles_edit_submission' ) || $gBitUser->hasPermission( 'p_articles_admin' ) ) ) ) {
$_REQUEST['status_id'] = ARTICLE_STATUS_APPROVED;
}
$listArticles = $article->getList( $_REQUEST );
Expand Down
6 changes: 3 additions & 3 deletions read.php
@@ -1,6 +1,6 @@
<?php
/**
* @version $Header: /cvsroot/bitweaver/_bit_articles/read.php,v 1.20 2007/06/23 18:27:41 squareing Exp $
* @version $Header: /cvsroot/bitweaver/_bit_articles/read.php,v 1.21 2007/07/06 16:37:22 squareing Exp $
* @package article
* @subpackage functions
*/
Expand Down Expand Up @@ -28,14 +28,14 @@

// additionally we need to check if this article is a submission and see if user has perms to view it.
if( $gContent->getField( 'status_id' ) != ARTICLE_STATUS_APPROVED ) {
if( !( $gBitUser->hasPermission( 'p_articles_edit_submission' ) || $gBitUser->hasPermission( 'p_articles_approve_submission' ))) {
if( !( $gContent->hasUserPermission( 'p_articles_edit_submission' ) || $gContent->hasUserPermission( 'p_articles_approve_submission' ))) {
$gBitSystem->fatalError( tra( "Permission denied you cannot view this article" ));
}
}

// we also need to check and see if the article is future dated - we will display it if the user can edit it otherwise we pretend it does not exist.
$timestamp = $gBitSystem->getUTCTime();
if ( ($gContent->mInfo['publish_date'] > $timestamp) && !$gBitUser->hasPermission( 'p_articles_edit' ) ){
if ( ($gContent->mInfo['publish_date'] > $timestamp) && !$gContent->hasUserPermission( 'p_articles_edit' ) ){
$gBitSystem->fatalError( tra( 'Article cannot be found' ));
}

Expand Down
14 changes: 7 additions & 7 deletions templates/article_display.tpl
@@ -1,4 +1,4 @@
{* $Header: /cvsroot/bitweaver/_bit_articles/templates/article_display.tpl,v 1.43 2007/06/26 10:08:08 lsces Exp $ *}
{* $Header: /cvsroot/bitweaver/_bit_articles/templates/article_display.tpl,v 1.44 2007/07/06 16:37:22 squareing Exp $ *}
{strip}
{if !$showDescriptionsOnly}
{include file="bitpackage:liberty/services_inc.tpl" serviceLocation='nav' serviceHash=$article}
Expand All @@ -7,14 +7,14 @@
<div class="{$outer_div|default:"post"}">
<div class="floaticon">
{include file="bitpackage:liberty/services_inc.tpl" serviceLocation='icon' serviceHash=$article}
{if $gBitUser->hasPermission( 'p_articles_read_history' ) && !$version && $article.version>1}
{if $gContent->hasUserPermission( 'p_articles_read_history' ) && !$version && $article.version>1}
{smartlink ititle="View History" ipackage=articles ifile="article_history.php" ibiticon="icons/appointment-new" article_id=$article.article_id}
{/if}
{if $gBitUser->hasPermission('p_articles_admin') || $gBitUser->getField('user_id') == $article.user_id}
{if $gContent->hasUserPermission('p_articles_admin') || $gBitUser->getField('user_id') == $article.user_id}
<a href="{$smarty.const.ARTICLES_PKG_URL}edit.php?article_id={$article.article_id}">{biticon ipackage="icons" iname="accessories-text-editor" iexplain=edit}</a>
{/if}
{*<a style="display:none;" href="{$smarty.const.ARTICLES_PKG_URL}print.php?article_id={$article.article_id}">{biticon ipackage="icons" iname="document-print" iexplain=print}</a>*}
{if $gBitUser->hasPermission( 'p_articles_remove' )}
{if $gContent->hasUserPermission( 'p_articles_remove' )}
{smartlink ititle="Remove" ipackage=articles ifile="list.php" ibiticon="icons/edit-delete" action=remove remove_article_id=$article.article_id status_id=$smarty.request.status_id}
{/if}
</div><!-- end .footer -->
Expand All @@ -35,7 +35,7 @@
{/if}
</div>

<div class="body"{if $gBitUser->getPreference( 'users_double_click' ) and $gBitUser->hasPermission( 'p_articles_edit' )} ondblclick="location.href='{$smarty.const.ARTICLES_PKG_URL}edit.php?article_id={$article.article_id}';"{/if}>
<div class="body"{if $gBitUser->getPreference( 'users_double_click' ) and $gContent->hasUserPermission( 'p_articles_edit' )} ondblclick="location.href='{$smarty.const.ARTICLES_PKG_URL}edit.php?article_id={$article.article_id}';"{/if}>
<div class="content">
{include file="bitpackage:liberty/services_inc.tpl" serviceLocation='body' serviceHash=$article}
{* If there is a custom primary override *}
Expand Down Expand Up @@ -113,11 +113,11 @@
<div class="row">
{formlabel label="Approve or deny Submission"}
{forminput}
{if $gBitUser->hasPermission( 'p_articles_approve_submission' )}
{if $gContent->hasUserPermission( 'p_articles_approve_submission' )}
<a href="{$smarty.const.ARTICLES_PKG_URL}list.php?status_id={$article.status_id}&amp;article_id={$article.article_id}&amp;content_id={$article.content_id}&amp;set_status_id=300&amp;action=approve">{biticon ipackage=icons iname="large/dialog-ok" iexplain="Approve Article"}</a> &nbsp;
{/if}

{if $gBitUser->hasPermission( 'p_articles_remove' ) || $gBitUser->hasPermission( 'p_articles_remove_submission' )}
{if $gContent->hasUserPermission( 'p_articles_remove' ) || $gContent->hasUserPermission( 'p_articles_remove_submission' )}
<a href="{$smarty.const.ARTICLES_PKG_URL}list.php?status_id={$article.status_id}&amp;remove_article_id={$article.article_id}&amp;action=remove">{biticon ipackage=icons iname="large/dialog-cancel" iexplain="Remove Article"}</a>
{/if}
{/forminput}
Expand Down
6 changes: 3 additions & 3 deletions templates/article_history.tpl
Expand Up @@ -81,13 +81,13 @@
&nbsp;&bull;&nbsp;{smartlink ititle="Difference" article_id=`$gContent->mArticleId` diff2=`$item.version`}
&nbsp;&bull;&nbsp;{smartlink ititle="Source" article_id=`$gContent->mArticleId` source=`$item.version`}
{* Articles doesnt have rollback option yet
{if $gBitUser->hasPermission( 'p_articles_rollback' )}
{if $gContent->hasUserPermission( 'p_articles_rollback' )}
&nbsp;&bull;&nbsp;{smartlink iurl="rollback.php" ititle="Rollback" article_id=`$gContent->mArticleId` version=`$item.version`}
{/if}
*}
</td>
<td style="text-align:right;">
{if $gBitUser->hasPermission( 'p_articles_remove' )}
{if $gContent->hasUserPermission( 'p_articles_remove' )}
<input type="checkbox" name="hist[{$item.version}]" id="hist_{$item.version}" />
{/if}
</td>
Expand All @@ -101,7 +101,7 @@
{/foreach}
</table>

{if $gBitUser->hasPermission( 'p_articles_remove' )}
{if $gContent->hasUserPermission( 'p_articles_remove' )}
<div style="text-align:right;">
<input type="submit" name="delete" value="{tr}Delete selected versions{/tr}" />
</div>
Expand Down
6 changes: 3 additions & 3 deletions templates/edit_article.tpl
Expand Up @@ -9,7 +9,7 @@
<div class="header">
{if $gContent->mArticleId}
<h1>{tr}Edit Article{/tr}: {$article.title|escape}</h1>
{elseif $gBitUser->hasPermission('p_articles_approve_submission') || $gBitUser->hasPermission('p_articles_auto_approve')}
{elseif $gContent->hasUserPermission('p_articles_approve_submission') || $gContent->hasUserPermission('p_articles_auto_approve')}
<h1>{tr}Create Article{/tr}</h1>
{else}
<h1>{tr}Submit Article{/tr}</h1>
Expand Down Expand Up @@ -49,7 +49,7 @@
{/forminput}
</div>

{if $topics or $gBitUser->hasPermission( 'p_articles_admin' )}
{if $topics or $gContent->hasUserPermission( 'p_articles_admin' )}
<div class="row">
{formlabel label="Topic" for="topic_id"}
{forminput}
Expand Down Expand Up @@ -114,7 +114,7 @@

{include file="bitpackage:liberty/edit_services_inc.tpl serviceFile=content_edit_mini_tpl}
{if $gBitSystem->isFeatureActive( 'articles_submissions_rnd_img' ) && !( $gContent->mArticleId || ( $gBitUser->hasPermission('p_articles_approve_submission') || $gBitUser->hasPermission('p_articles_auto_approve') ) )}
{if $gBitSystem->isFeatureActive( 'articles_submissions_rnd_img' ) && !( $gContent->mArticleId || ( $gContent->hasUserPermission('p_articles_approve_submission') || $gContent->hasUserPermission('p_articles_auto_approve') ) )}
<div class="row">
{formlabel label="Submission Code"}
{forminput}
Expand Down
6 changes: 3 additions & 3 deletions templates/print_article.tpl
@@ -1,4 +1,4 @@
{* $Header: /cvsroot/bitweaver/_bit_articles/templates/print_article.tpl,v 1.4 2006/04/11 13:03:25 squareing Exp $ *}
{* $Header: /cvsroot/bitweaver/_bit_articles/templates/print_article.tpl,v 1.5 2007/07/06 16:37:22 squareing Exp $ *}
{* Index we display a wiki page here *}

{include file="bitpackage:kernel/header.tpl"}
Expand Down Expand Up @@ -28,10 +28,10 @@
</div> {* end articleheading *}
<div class="articletrailer">
({$size} bytes
{if $gBitUser->hasPermission( 'p_articles_edit' )}
{if $gContent->hasUserPermission( 'p_articles_edit' )}
[<a href="{$smarty.const.ARTICLES_PKG_URL}edit.php?article_id={$article_id}">{tr}Edit{/tr}</a>]
{/if}
{if $gBitUser->hasPermission( 'p_articles_remove' )}
{if $gContent->hasUserPermission( 'p_articles_remove' )}
[<a href="{$smarty.const.ARTICLES_PKG_URL}list.php?remove={$article_id}">{tr}Remove{/tr}</a>]
{/if}
)
Expand Down

0 comments on commit e89540d

Please sign in to comment.