[pLog-svn] r4163 - in plog/trunk: class/action/admin templates/admin

oscar at devel.lifetype.net oscar at devel.lifetype.net
Sun Oct 22 20:27:50 GMT 2006


Author: oscar
Date: 2006-10-22 20:27:49 +0000 (Sun, 22 Oct 2006)
New Revision: 4163

Modified:
   plog/trunk/class/action/admin/adminaddpostaction.class.php
   plog/trunk/class/action/admin/admindeletepostaction.class.php
   plog/trunk/class/action/admin/admineditpostsaction.class.php
   plog/trunk/class/action/admin/adminsendtrackbacksaction.class.php
   plog/trunk/templates/admin/editposts.template
Log:
added permissions for managing posts


Modified: plog/trunk/class/action/admin/adminaddpostaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminaddpostaction.class.php	2006-10-22 20:10:15 UTC (rev 4162)
+++ plog/trunk/class/action/admin/adminaddpostaction.class.php	2006-10-22 20:27:49 UTC (rev 4163)
@@ -137,12 +137,18 @@
 			// save the article to the db
 			$artId = $this->_savePostData( $article );
 			
+			// depending on the permission that the user has, we'll show one view or another
+			if( $this->userHasPermission( "view_posts" ))
+				$view = "AdminNewPostView";
+			else
+				$view = "AdminPostsListView";			
+			
         	// once we have built the object, we can add it to the database
         	if( $artId ) {
 	            // clear autosave cookie
 	            $this->clearAutoSaveCookie();
 
-                $this->_view = new AdminPostsListView( $this->_blogInfo );
+                $this->_view = new $view( $this->_blogInfo );
             	//$article->setId( $artId );
                 $message = $this->_locale->tr("post_added_ok");
                 
@@ -191,7 +197,7 @@
 
         				// if no links, there is nothing to do
         				if( count($postLinks) == 0 && count($trackbackLinks) == 0 ) {
-        					$this->_view = new AdminPostsListView( $this->_blogInfo );
+        					$this->_view = new $view( $this->_blogInfo );
 			                $this->_view->setErrorMessage( $this->_locale->tr("error_no_trackback_links_sent"));
         				}
         				else {
@@ -211,14 +217,14 @@
 					CacheControl::resetBlogCache( $this->_blogInfo->getId());						
                 }
                 else {
-                	$this->_view = new AdminPostsListView( $this->_blogInfo );
+                	$this->_view = new $view( $this->_blogInfo );
                     $this->_view->setSuccessMessage( $this->_locale->tr("post_added_not_published") );
 					
 					$this->notifyEvent( EVENT_POST_POST_ADD, Array( "article" => &$article ));
                 }
         	}
         	else {
-        		$this->_view = new AdminPostsListView( $this->_blogInfo );
+        		$this->_view = new $view( $this->_blogInfo );
             	$this->_view->setErrorMessage( $this->_locale->tr("error_adding_post") );
         	}
 

Modified: plog/trunk/class/action/admin/admindeletepostaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admindeletepostaction.class.php	2006-10-22 20:10:15 UTC (rev 4162)
+++ plog/trunk/class/action/admin/admindeletepostaction.class.php	2006-10-22 20:27:49 UTC (rev 4163)
@@ -36,7 +36,9 @@
 
 			$view = new AdminPostsListView( $this->_blogInfo );
 			$view->setErrorMessage( $this->_locale->tr("error_incorrect_article_id"));
-			$this->setValidationErrorView( $view );		
+			$this->setValidationErrorView( $view );	
+			
+			$this->requirePermission( "update_post" );	
         }
 
         /**

Modified: plog/trunk/class/action/admin/admineditpostsaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admineditpostsaction.class.php	2006-10-22 20:10:15 UTC (rev 4162)
+++ plog/trunk/class/action/admin/admineditpostsaction.class.php	2006-10-22 20:27:49 UTC (rev 4163)
@@ -18,6 +18,8 @@
         function AdminEditPostsAction( $actionInfo, $request )
         {
         	$this->AdminAction( $actionInfo, $request );
+
+			$this->requirePermission( "view_posts" );
         }
 
         /**

Modified: plog/trunk/class/action/admin/adminsendtrackbacksaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminsendtrackbacksaction.class.php	2006-10-22 20:10:15 UTC (rev 4162)
+++ plog/trunk/class/action/admin/adminsendtrackbacksaction.class.php	2006-10-22 20:27:49 UTC (rev 4163)
@@ -2,6 +2,7 @@
 
 	lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
     lt_include( PLOG_CLASS_PATH."class/view/admin/adminpostslistview.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/view/admin/adminnewpostview.class.php" );
     lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
     lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
     lt_include( PLOG_CLASS_PATH."class/dao/trackbackclient.class.php" );
@@ -28,6 +29,8 @@
         function AdminSendTrackbacksAction( $actionInfo, $request )
         {
         	$this->AdminAction( $actionInfo, $request );
+
+			$this->requirePermission( "add_post" );
         }
 
 		function validate()
@@ -125,7 +128,11 @@
                 $this->setCommonData();
             }
             else {
-                $this->_view = new AdminPostsListView( $this->_blogInfo );
+				if( $this->userHasPermission( "view_posts" )) 
+                	$this->_view = new AdminPostsListView( $this->_blogInfo );
+				else
+					$this->_view = new AdminNewPostView( $this->_blogInfo );
+					
                 $this->_view->setSuccessMessage( $message );
                 $this->setCommonData();
             }

Modified: plog/trunk/templates/admin/editposts.template
===================================================================
--- plog/trunk/templates/admin/editposts.template	2006-10-22 20:10:15 UTC (rev 4162)
+++ plog/trunk/templates/admin/editposts.template	2006-10-22 20:27:49 UTC (rev 4163)
@@ -74,16 +74,17 @@
         </div>
 
         <form id="postsList" action="admin.php" method="post">
+	    {check_perms perm=update_post}
         <div class="optionIcon">
 			<a id="optionIconLink" href="#bulkEdit" title="{$locale->tr("show_massive_change_option")}" onclick="switchMassiveOption()">{$locale->tr("show_massive_change_option")}</a>
 		</div>
+		{/check_perms}
         <div id="list">
   {include file="$admintemplatepath/successmessage.template"}
   {include file="$admintemplatepath/errormessage.template"}
             <table class="info">
                 <thead>
                     <tr>
-                        <!-- 775 -->
                         <th style="width:10px;"><input class="checkbox" type="checkbox" name="all" id="all" value="1" onclick="toggleAllChecks('postsList');" /></th>
                         <th style="width:345px;">{$locale->tr("topic")}</th>
                         <th style="width:115px;">{$locale->tr("date")}</th>
@@ -101,9 +102,9 @@
                             <input class="checkbox" type="checkbox" name="postIds[{$post->getId()}]" id="checks_{$post->getId()}" value="{$post->getId()}" />
                         </td>
                         <td class="col_highlighted">
-                            <a href="?op=editPost&amp;postId={$post->getId()}">
+                            {check_perms perm=update_post}<a href="?op=editPost&amp;postId={$post->getId()}">{/check_perms}
                             {$post->getTopic()|strip_tags}
-                            </a><br />
+                            {check_perms perm=update_post}</a>{/check_perms}<br />
                             &nbsp;&raquo;
                             <span style="font-weight: normal;">
                             {foreach name=postCategories from=$post->getCategories() item=postCategory}
@@ -144,6 +145,7 @@
 							{/if}
                         </td>						
                         <td>
+							{check_perms perm=update_post}
                             <div class="list_action_button">
                             <a href="?op=editPost&amp;postId={$post->getId()}" title="{$locale->tr("edit")}">
                             	<img src="imgs/admin/icon_edit-16.png" alt="{$locale->tr("edit")}" />
@@ -151,12 +153,15 @@
                             <a href="?op=deletePost&amp;postId={$post->getId()}" title="{$locale->tr("delete")}">
                             	<img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("delete")}" />
                             </a>
+							{/check_perms}
                             <a href="{$url->postPermalink($post)}" title="{$locale->tr("permalink")}">
                             	<img src="imgs/admin/icon_url-16.png" alt="{$locale->tr("permalink")}" />
                             </a>
+							{check_perms perm=view_blog_stats}
                             <a href="?op=postStats&amp;postId={$post->getId()}" title="{$locale->tr("statistics")}">
                             	<img src="imgs/admin/icon_stats-16.png" alt="{$locale->tr("statistics")}" />
                             </a>
+							{/check_perms}
                             </div>
                         </td>
                     </tr>
@@ -167,8 +172,11 @@
         <a name="bulkEdit"></a>
         <div id="list_action_bar">
 			{adminpager style="list"}
+			{check_perms perm=update_post}
             <input type="button" name="delete" value="{$locale->tr("delete")}" class="submit" onClick="javascript:submitPostsList('deletePosts');" />
             <input type="hidden" name="op" value="" />
+			{/check_perms}
+			{check_perms perm=update_post}
             <div id="massiveChangeOption" style="display: none">
                 <fieldset>
                 <legend>{$locale->tr("massive_change_option")}</legend>            
@@ -189,6 +197,7 @@
 		            <input type="button" name="changePostsCategory" value="{$locale->tr("change_category")}" class="submit" onClick="javascript:submitPostsList('changePostsCategory');" />
 		        </fieldset>
 			</div>
+			{/check_perms}
         </div>
 
         </form>



More information about the pLog-svn mailing list