[pLog-svn] r2975 - in plog/trunk: class/action/admin
class/controller class/template/menu styles templates/admin
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Wed Feb 22 06:01:35 GMT 2006
Author: oscar
Date: 2006-02-22 06:01:35 +0000 (Wed, 22 Feb 2006)
New Revision: 2975
Added:
plog/trunk/class/action/admin/adminadminblogselectaction.class.php
Modified:
plog/trunk/class/action/admin/blogowneradminaction.class.php
plog/trunk/class/controller/admincontrollermap.properties.php
plog/trunk/class/template/menu/menurenderer.class.php
plog/trunk/styles/admin.css
plog/trunk/templates/admin/navigation.template
plog/trunk/templates/admin/siteblogs.template
Log:
implemented a new feature that allows site administrators to administrate any blog in the site. All that an admin needs to do is go to the "site blogs" page, find the blog that we'd like to administrate, and click the open lock icon on the right side (below the 'actions' column) The new action AdminAdminBlogSelectAction will take care of setting everything up so that the blog is loaded and we, as admins, are given full access to it. Everything looks the same in the
administrated blog, except that the title of the page we're browsing ("Control Centre", "New Post", etc, which appears on the top left corner right below the navigation tabs) now appears in bold red colours and the text "[Admin Mode]" is appended to it to remind administrators that this is not their own blog but one that they're administrating.
Everything seems to work fine, articles can be posted, deleted, blog settings can be changed, etc. The new blog appears correctly in the "bread and crumbs" navigation thingie too, but it does not appear in the drop-down list on the top right corner. This of course needs to be fixed because it's a bit confusing, but I don't think it's going to be complicated.
This should make some people happy, specially those that were demanding more access to everybody's blogs as administrators...
Added: plog/trunk/class/action/admin/adminadminblogselectaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminadminblogselectaction.class.php 2006-02-22 05:49:17 UTC (rev 2974)
+++ plog/trunk/class/action/admin/adminadminblogselectaction.class.php 2006-02-22 06:01:35 UTC (rev 2975)
@@ -0,0 +1,76 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/action/admin/siteadminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminsiteblogslistview.class.php" );
+
+ /**
+ * \ingroup Action
+ * @private
+ *
+ * Sets everything so that admins are allowed to log in into anybody's blog
+ */
+ class AdminAdminBlogSelectAction extends SiteAdminAction
+ {
+
+ var $_blogId;
+
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ function AdminAdminBlogSelectAction( $actionInfo, $request )
+ {
+ $this->SiteAdminAction( $actionInfo, $request );
+
+ // validate the only field we're expecting, the blog id
+ $this->registerFieldValidator( "blogId", new IntegerValidator());
+ $view = new AdminSiteBlogsListView( $this->_blogInfo );
+ $view->setErrorMessage( $this->_locale->tr( "error_incorrect_blog_id" ));
+ $this->setValidationErrorView( $view );
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function perform()
+ {
+ $this->_blogId = $this->_request->getValue( "blogId" );
+
+ // load the blog
+ require_once( PLOG_CLASS_PATH . "class/dao/blogs.class.php" );
+ $blogs = new Blogs();
+ $blogInfo = $blogs->getBlogInfo( $this->_blogId );
+
+ // check if the blog really exists
+ if( !$blogInfo ) {
+ $this->_view = new AdminSiteBlogsListView( $this->_blogInfo );
+ $this->_view->setValue( "message", $this->_locale->tr("error_incorrect_blog_id" ));
+ $this->setCommonData();
+ return false;
+ }
+
+ // if all correct, we can now set the blogInfo object in the session for later use
+ $this->_session->setValue( "blogInfo", $blogInfo );
+ $session = HttpVars::getSession();
+ $session["SessionInfo"] = $this->_session;
+ $session["SessionInfo"]->setValue( "blogId", $blogInfo->getId() );
+ HttpVars::setSession( $session );
+
+ /*print_r($session);
+ die();*/
+
+ // check if there was any redirection
+ $this->_nextAction = $this->_request->getValue( "action" );
+
+ if ( $this->_nextAction ) {
+ AdminController::setForwardAction( $this->_nextAction );
+ } else {
+ AdminController::setForwardAction( "newPost" );
+ }
+
+ // better to return true if everything fine
+ return true;
+ }
+ }
+?>
Modified: plog/trunk/class/action/admin/blogowneradminaction.class.php
===================================================================
--- plog/trunk/class/action/admin/blogowneradminaction.class.php 2006-02-22 05:49:17 UTC (rev 2974)
+++ plog/trunk/class/action/admin/blogowneradminaction.class.php 2006-02-22 06:01:35 UTC (rev 2975)
@@ -27,8 +27,9 @@
$this->AdminAction( $actionInfo, $request );
// we should check if the user has permissions to be here...
- if( $this->_blogInfo->getOwner() != $this->_userInfo->getId()) {
- print("Sorry, only the owner of the blog can access this area." );
+ if( ($this->_blogInfo->getOwner() != $this->_userInfo->getId()) &&
+ ($this->_userInfo->isSiteAdmin() == false )) {
+ print("Sorry, only the owner of the blog or site administrators can access this area." );
die();
}
}
Modified: plog/trunk/class/controller/admincontrollermap.properties.php
===================================================================
--- plog/trunk/class/controller/admincontrollermap.properties.php 2006-02-22 05:49:17 UTC (rev 2974)
+++ plog/trunk/class/controller/admincontrollermap.properties.php 2006-02-22 06:01:35 UTC (rev 2975)
@@ -285,4 +285,6 @@
$actions["updateGlobalArticleCategory"] = "AdminUpdateGlobalArticleCategoryAction";
// resend the confirmation email
$actions["resendConfirmation"] = "AdminResendConfirmationAction";
+ // allow admins to control any blog
+ $actions["adminBlogSelect"] = "AdminAdminBlogSelectAction";
?>
Modified: plog/trunk/class/template/menu/menurenderer.class.php
===================================================================
--- plog/trunk/class/template/menu/menurenderer.class.php 2006-02-22 05:49:17 UTC (rev 2974)
+++ plog/trunk/class/template/menu/menurenderer.class.php 2006-02-22 06:01:35 UTC (rev 2975)
@@ -131,9 +131,10 @@
if( $nodeIsAdminOnly && !$userInfo->isSiteAdmin())
return false;
- // check if the node is only for blog owners and if the user is a blog owner
+ // check if the node is only for blog owners or site admins and if the user is a blog owner
$nodeIsBlogOwnerOnly = $node->getAttribute( "blogOwner" );
- if( $nodeIsBlogOwnerOnly && ( $this->_blogInfo->getOwner() != $userInfo->getId()))
+ if( $nodeIsBlogOwnerOnly && (( $this->_blogInfo->getOwner() != $userInfo->getId()) &&
+ $userInfo->isSiteAdmin() == false ))
return false;
// if none of the above is true, then the user does not have enough permissions!
Modified: plog/trunk/styles/admin.css
===================================================================
--- plog/trunk/styles/admin.css 2006-02-22 05:49:17 UTC (rev 2974)
+++ plog/trunk/styles/admin.css 2006-02-22 06:01:35 UTC (rev 2975)
@@ -224,6 +224,17 @@
padding-left : 4px;
}
+#section_title_admin_mode h2
+{
+ color : red;
+ font-weight : bold;
+ font-family : trebuchet ms, tahoma, sans-serif;
+ font-size : 1.5em;
+ letter-spacing : 0.08em;
+ margin : 0;
+ padding-left : 4px;
+}
+
#navigation
{
float : right;
Modified: plog/trunk/templates/admin/navigation.template
===================================================================
--- plog/trunk/templates/admin/navigation.template 2006-02-22 05:49:17 UTC (rev 2974)
+++ plog/trunk/templates/admin/navigation.template 2006-02-22 06:01:35 UTC (rev 2975)
@@ -2,9 +2,15 @@
<div id="navigation">
{$menu->breadCrumbs($showOpt)}
</div>
+ {if $user->isSiteAdmin() && ($blog->getOwnerId() != $user->getId())}
+ <div id="section_title_admin_mode">
+ <h2>{$title} [{$locale->tr("admin_mode")}]</h2>
+ </div>
+ {else}
<div id="section_title">
<h2>{$title}</h2>
- </div>
+ </div>
+ {/if}
<br style="clear:both;" />
</div>
{if $templatename != "main" && $templatename != "controlcenter" && $templatename != "adminsettings" && $templatename != "resourcesgroup" && $templatename != "error" && $templatename != "message" }
Modified: plog/trunk/templates/admin/siteblogs.template
===================================================================
--- plog/trunk/templates/admin/siteblogs.template 2006-02-22 05:49:17 UTC (rev 2974)
+++ plog/trunk/templates/admin/siteblogs.template 2006-02-22 06:01:35 UTC (rev 2975)
@@ -77,6 +77,9 @@
{if $siteblog->getStatus() == 3}
<a href="?op=resendConfirmation&blogId={$siteblog->getId()}"><img src="imgs/admin/icon_mail-16.png" alt="{$locale->tr("resend_confirmation_blog")}" /></a>
{/if}
+ <a href="?op=adminBlogSelect&blogId={$siteblog->getId()}&action=controlCenter">
+ <img src="imgs/admin/icon_lock_open-16.png" alt="{$locale->tr("administrate_user_blog")}" />
+ </a>
</div>
</tr>
{/foreach}
More information about the pLog-svn
mailing list