[pLog-svn] r5915 - in plugins/branches/lifetype-1.2: . abtrash abtrash/class abtrash/class/action abtrash/class/view abtrash/locale abtrash/templates
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Fri Sep 7 05:30:56 EDT 2007
Author: jondaley
Date: 2007-09-07 05:30:56 -0400 (Fri, 07 Sep 2007)
New Revision: 5915
Added:
plugins/branches/lifetype-1.2/abtrash/
plugins/branches/lifetype-1.2/abtrash/class/
plugins/branches/lifetype-1.2/abtrash/class/action/
plugins/branches/lifetype-1.2/abtrash/class/action/adminemptytrashaction.class.php
plugins/branches/lifetype-1.2/abtrash/class/action/adminviewtrashaction.class.php
plugins/branches/lifetype-1.2/abtrash/class/view/
plugins/branches/lifetype-1.2/abtrash/class/view/adminviewtrashview.class.php
plugins/branches/lifetype-1.2/abtrash/locale/
plugins/branches/lifetype-1.2/abtrash/locale/locale_en_UK.php
plugins/branches/lifetype-1.2/abtrash/pluginabtrash.class.php
plugins/branches/lifetype-1.2/abtrash/readme.txt
plugins/branches/lifetype-1.2/abtrash/templates/
plugins/branches/lifetype-1.2/abtrash/templates/viewtrash.template
Log:
Ahmad's trash plugin. changes coming shortly
Added: plugins/branches/lifetype-1.2/abtrash/class/action/adminemptytrashaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/abtrash/class/action/adminemptytrashaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/abtrash/class/action/adminemptytrashaction.class.php 2007-09-07 09:30:56 UTC (rev 5915)
@@ -0,0 +1,91 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/abtrash/class/view/adminviewtrashview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+
+ /**
+ * empty trash
+ */
+ class AdminEmptyTrashAction extends AdminAction
+ {
+
+ var $_postIds;
+
+
+ function AdminEmptyTrashAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+
+ // data validation stuff...
+ if( $request['postId'] ) {
+ $this->registerFieldValidator( "postId", new IntegerValidator());
+ $this->_postIds[] = $this->_request->getValue( "postId" );
+ } else {
+ $this->registerFieldValidator( "postIds", new ArrayValidator());
+ $this->_postIds = $this->_request->getValue( "postIds" );
+ }
+
+ $view = new AdminViewTrashView ( $this->_blogInfo );
+ $view->setErrorMessage( $this->_locale->tr("error_incorrect_article_id"));
+ $this->setValidationErrorView( $view );
+ $this->requirePermission( "update_post" );
+
+ }
+
+
+
+ function perform()
+ {
+ $articles = new Articles();
+ $errorMessage = "";
+ $successMessage = "";
+ $totalOk = 0;
+
+ foreach( $this->_postIds as $postId ) {
+
+ $this->_view = new AdminViewTrashView( $this->_blogInfo );
+
+ // get the post
+ $post = $articles->getBlogArticle( $postId, $this->_blogInfo->getId());
+
+ if( $post ) {
+
+ // we won't permanently delete undeleted posts
+ if( POST_STATUS_DELETED != $post->getStatus() ) {
+ $this->setCommonData();
+ return true;
+ }
+
+ if( $post->getUserId() == $this->_userInfo->getId() ) {
+ $result = $articles->deleteArticle( $postId, $post->getUser(), $this->_blogInfo->getId(), true);
+ } else {
+ $errorMessage .= $this->_locale->tr("error_can_only_update_own_articles")." ";
+ $result = false;
+ }
+
+ if( !$result ) {
+ $errorMessage .= $this->_locale->pr("error_deleting_article", $post->getTopic())."<br/>";
+ } else {
+ $totalOk++;
+ if( $totalOk < 2 )
+ $successMessage .= $this->_locale->pr("article_deleted_ok", $post->getTopic())."<br/>";
+ else
+ $successMessage = $this->_locale->pr("articles_deleted_ok", $totalOk );
+ }
+ }
+ }
+
+ if( $errorMessage != "" )
+ $this->_view->setErrorMessage( $errorMessage );
+
+ if( $successMessage != "" )
+ $this->_view->setSuccessMessage( $successMessage );
+
+ $this->setCommonData();
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/abtrash/class/action/adminviewtrashaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/abtrash/class/action/adminviewtrashaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/abtrash/class/action/adminviewtrashaction.class.php 2007-09-07 09:30:56 UTC (rev 5915)
@@ -0,0 +1,27 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/abtrash/class/view/adminviewtrashview.class.php" );
+
+ /**
+ * view trash
+ */
+ class AdminViewTrashAction extends AdminAction
+ {
+
+ function AdminViewTrashAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ // Check permissions
+ $this->requirePermission( 'manage_admin_plugins' );
+ }
+
+ function perform()
+ {
+ $this->_view = new AdminViewTrashView( $this->_blogInfo );
+
+ $this->setCommonData();
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/abtrash/class/view/adminviewtrashview.class.php
===================================================================
--- plugins/branches/lifetype-1.2/abtrash/class/view/adminviewtrashview.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/abtrash/class/view/adminviewtrashview.class.php 2007-09-07 09:30:56 UTC (rev 5915)
@@ -0,0 +1,49 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/config/siteconfig.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );
+
+ class AdminViewTrashView extends AdminPluginTemplatedView
+ {
+
+ var $_page;
+
+ function AdminViewTrashView( $blogInfo )
+ {
+ $this->AdminPluginTemplatedView( $blogInfo, "abtrash", "viewtrash" );
+ $this->_page = $this->getCurrentPageFromRequest();
+
+ $blogSettings = $blogInfo->getSettings();
+
+ $this->_itemsPerPage = $blogSettings->getValue( "show_posts_max" );
+ if( $this->_itemsPerPage > SiteConfig::getHardShowPostsMax())
+ $this->_itemsPerPage = SiteConfig::getHardShowPostsMax();
+ }
+
+ function render()
+ {
+ $articles = new Articles();
+ $blogId = $this->_blogInfo->getId();
+ $userId = $this->_userInfo->getId();
+
+ $posts = $articles->getBlogArticles( $blogId, -1, $this->_itemsPerPage, 0, POST_STATUS_DELETED, $userId, 0, '', $this->_page);
+
+ // get the total number of posts
+ $numPosts = $articles->getNumBlogArticles( $blogId, -1, 0, POST_STATUS_DELETED, $userId, 0, '');
+
+
+ $pager = new Pager( "?op=viewTrash&page=", $this->_page, $numPosts, $this->_itemsPerPage );
+
+ $this->setValue( "posts", $posts );
+
+ // throw the even in case somebody is listening to it
+ $this->notifyEvent( EVENT_POSTS_LOADED, Array( "posts" => &$posts ));
+
+ $this->setValue( "pager", $pager );
+
+ parent::render();
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/abtrash/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.2/abtrash/locale/locale_en_UK.php (rev 0)
+++ plugins/branches/lifetype-1.2/abtrash/locale/locale_en_UK.php 2007-09-07 09:30:56 UTC (rev 5915)
@@ -0,0 +1,6 @@
+<?php
+$messages['trash'] = 'Trash';
+$messages['emptyTrash'] = 'Empty Trash';
+$messages['comments'] = 'Comments';
+
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/abtrash/pluginabtrash.class.php
===================================================================
--- plugins/branches/lifetype-1.2/abtrash/pluginabtrash.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/abtrash/pluginabtrash.class.php 2007-09-07 09:30:56 UTC (rev 5915)
@@ -0,0 +1,39 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/template/menu/menu.class.php" );
+
+ /**
+ * CrystalPoll class
+ */
+ class PluginABTrash extends PluginBase
+ {
+ function PluginABTrash( $source = "" )
+ {
+ $this->PluginBase();
+ $this->id = "abTrash";
+ $this->desc = "This plugin make you able to delete deleted posts permanently";
+ $this->author = "Ahmad Fathi Saleh (Al Bawaba Team)";
+ $this->locale = "locale_en_UK";
+ $this->version = "20070906";
+ if( "admin" == $source ) {
+ $this->adminInit();
+ }
+ }
+
+ /**
+ * init admin actions
+ */
+ function adminInit()
+ {
+
+ $this->registerAdminAction( "viewTrash", "AdminViewTrashAction" );
+ $this->registerAdminAction( "emptyTrash", "AdminEmptyTrashAction" );
+
+ $menu =& Menu::getMenu();
+ if( $menu->entryExists( "/menu/Manage/managePosts" ) ) {
+ $this->addMenuEntry( "/menu/Manage/managePosts", "trash", "admin.php?op=viewTrash", null, true, false );
+ }
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/abtrash/readme.txt
===================================================================
--- plugins/branches/lifetype-1.2/abtrash/readme.txt (rev 0)
+++ plugins/branches/lifetype-1.2/abtrash/readme.txt 2007-09-07 09:30:56 UTC (rev 5915)
@@ -0,0 +1,8 @@
+Plugin: abTrash
+Author: Ahmad Fathi Saleh
+Release Date: 2007/09/06
+Version: 20070906
+
+This plugin make you able to delete deleted posts permanently.
+
+
Added: plugins/branches/lifetype-1.2/abtrash/templates/viewtrash.template
===================================================================
--- plugins/branches/lifetype-1.2/abtrash/templates/viewtrash.template (rev 0)
+++ plugins/branches/lifetype-1.2/abtrash/templates/viewtrash.template 2007-09-07 09:30:56 UTC (rev 5915)
@@ -0,0 +1,103 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=trash title=$locale->tr("trash")}
+ <script type="text/javascript" src="js/ui/plogui.js"></script>
+ <script type="text/javascript">
+ {literal}
+ YAHOO.util.Event.addListener( window, "load", function() {
+ var t = new Lifetype.UI.TableEffects( "list" );
+ t.stripe();
+ t.highlightRows();
+ });
+ {/literal}
+ </script>
+
+ <form id="trashList" action="admin.php" method="post">
+ <div id="list">
+ {include file="$admintemplatepath/successmessage.template"}
+ {include file="$admintemplatepath/errormessage.template"}
+ <!--
+ <div id="list_action_bar">
+ {check_perms perm=update_post}
+ <input type="button" name="delete1" value="{$locale->tr("delete")}" class="submit" onClick="javascript:if(confirmation('{$locale->tr("items_delete_confirmation")}')) submitPostsList('deletePosts');else return false;" />
+ {/check_perms}
+ </div>
+
+ <script type="text/javascript">
+ var checks=new Array("all"{foreach from=$posts item=post},"checks_{$post->getId()}"{/foreach});
+ </script>
+ -->
+ <table id="list" class="info" summary="{$locale->tr("trash")}">
+ <thead>
+ <tr>
+ <th><input class="checkbox" type="checkbox" name="all" id="all" value="1" onclick="toggleAllChecks('trashList');" /></th>
+ <th style="width:50%;">{$locale->tr("topic")}</th>
+ <th style="width:10%;">{$locale->tr("date")}</th>
+ <th style="width:15%;">{$locale->tr("author")}</th>
+ <th style="width:10%;text-align:center;">{$locale->tr("comments")}</th>
+ <th style="width:10%;">{$locale->tr("actions")}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {foreach from=$posts item=post}
+ <tr>
+ <td>
+ <input class="checkbox" type="checkbox" name="postIds[{$post->getId()}]" id="checks_{$post->getId()}" value="{$post->getId()}"/><!-- onclick="toggleChecks('checks_{$post->getId()}',checks);"/>-->
+ </td>
+ <td class="col_highlighted">
+ {check_perms perm=update_post}<a href="?op=editPost&postId={$post->getId()}">{/check_perms}
+ {$post->getTopic()|strip_tags}
+ {check_perms perm=update_post}</a>{/check_perms}<br />
+ »
+ <span style="font-weight: normal;">
+ {foreach name=postCategories from=$post->getCategories() item=postCategory}
+ <a href="?op=editPosts&showCategory={$postCategory->getId()}&showStatus=0">{$postCategory->getName()}</a>{if !$smarty.foreach.postCategories.last}, {/if}
+ {/foreach}
+ </span>
+ </td>
+ <td>
+ {assign var=date value=$post->getDateObject()}
+ {$locale->formatDate($date)}
+ </td>
+ <td>
+ {assign var=owner value=$post->getUserInfo()}
+ {$owner->getUsername()}
+ </td>
+
+ <td style="text-align: center;">
+ {if $post->getTotalComments(false) > 0}
+ <a href="?op=editComments&articleId={$post->getId()}">({$post->getTotalComments(false)})</a>
+ {else}
+ 0
+ {/if}
+ </td>
+
+ <td>
+ {check_perms perm=update_post}
+ <div class="list_action_button">
+ <a href="?op=editPost&postId={$post->getId()}" title="{$locale->tr("edit")}">
+ <img src="imgs/admin/icon_edit-16.png" alt="{$locale->tr("edit")}" />
+ </a>
+ <a href="?op=emptyTrash&postId={$post->getId()}" title="{$locale->tr("delete")}"/> <!-- onclick="javascript:return confirmation('{$locale->tr("items_delete_confirmation")}');">-->
+ <img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("delete")}" />
+ </a>
+ {/check_perms}
+ </div>
+ </td>
+ </tr>
+ {/foreach}
+ </tbody>
+ </table>
+ </div>
+
+
+ <div id="list_action_bar">
+ {adminpager style="list"}
+ {check_perms perm=update_post}
+ <input type="submit" name="emptyTrash" value="{$locale->tr("emptyTrash")}" class="submit" /> <!-- onClick="javascript:return (confirmation('{$locale->tr("items_delete_confirmation")}')) submitPostsList('deletePosts');else return false;" />-->
+ <input type="hidden" name="op" value="emptyTrash" />
+ {/check_perms}
+ </div>
+
+ </form>
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
More information about the pLog-svn
mailing list