|
From: <al...@us...> - 2007-08-16 00:20:47
|
Revision: 485
http://sciret.svn.sourceforge.net/sciret/?rev=485&view=rev
Author: alpeb
Date: 2007-08-15 17:20:45 -0700 (Wed, 15 Aug 2007)
Log Message:
-----------
allow users to hide categories in the main screen
Modified Paths:
--------------
branches/release-candidates/sciret-1.2/flowMap.php
branches/release-candidates/sciret-1.2/models/User.php
branches/release-candidates/sciret-1.2/templates/EditCategories.tpl
branches/release-candidates/sciret-1.2/templates/header.tpl
branches/release-candidates/sciret-1.2/views/EditCategories.php
branches/release-candidates/sciret-1.2/views/View.php
Modified: branches/release-candidates/sciret-1.2/flowMap.php
===================================================================
--- branches/release-candidates/sciret-1.2/flowMap.php 2007-08-15 19:31:40 UTC (rev 484)
+++ branches/release-candidates/sciret-1.2/flowMap.php 2007-08-16 00:20:45 UTC (rev 485)
@@ -26,7 +26,7 @@
'ManageUsers' => array(ROLE_ADMIN, true, true),
'EditUser' => array(ROLE_REGISTERED, true, true),
'AddQuestion' => array(ROLE_ANONYMOUS, true, true, true),
- 'EditCategories' => array(ROLE_ADMIN, true, true),
+ 'EditCategories' => array(ROLE_ANONYMOUS, true, true, true),
'EditCategory' => array(ROLE_ADMIN, true, true),
'EditPreferences' => array(ROLE_ANONYMOUS, true, true, true),
'ManageArticles' => array(ROLE_REGISTERED, true, false),
@@ -81,6 +81,8 @@
'DeleteTodo' => array(ROLE_REGISTERED, true),
'MarkArticleFinal' => array(ROLE_REGISTERED, true),
'Upgrade' => array(ROLE_ANONYMOUS, true, false),
+ 'HideCategory' => array(ROLE_ANONYMOUS, true, true),
+ 'ShowCategory' => array(ROLE_ANONYMOUS, true, true),
);
?>
Modified: branches/release-candidates/sciret-1.2/models/User.php
===================================================================
--- branches/release-candidates/sciret-1.2/models/User.php 2007-08-15 19:31:40 UTC (rev 484)
+++ branches/release-candidates/sciret-1.2/models/User.php 2007-08-16 00:20:45 UTC (rev 485)
@@ -33,6 +33,7 @@
'dateFormat' => 'Month Day, Year',
'language' => LANGUAGE_DEFAULT,
'navigationType' => 'catAndSubCats',
+ 'hiddenCategories' => '',
);
var $rtlLanguages = array('Hebrew');
Modified: branches/release-candidates/sciret-1.2/templates/EditCategories.tpl
===================================================================
--- branches/release-candidates/sciret-1.2/templates/EditCategories.tpl 2007-08-15 19:31:40 UTC (rev 484)
+++ branches/release-candidates/sciret-1.2/templates/EditCategories.tpl 2007-08-16 00:20:45 UTC (rev 485)
@@ -37,11 +37,19 @@
<td>{catDescription}</td>
<td>{catIcon}</td>
<td>
- <a href="{addSubCatLink}">[l]Add subcategory[/l]</a>
- <a href="{editCatLink}">[l]Edit[/l]</a>
- <!-- BEGIN deleteCategory_block -->
- <a href="#" onclick="deleteCategory({catId}, '{catLabel}')">[l]Delete[/l]</a>
- <!-- END deleteCategory_block -->
+ <!-- BEGIN hideCategory_block -->
+ <a href="{hideCatLink}">[l]Hide[/l]</a>
+ <!-- END hideCategory_block -->
+ <!-- BEGIN showCategory_block -->
+ <a href="{showCatLink}">[l]Show[/l]</a>
+ <!-- END showCategory_block -->
+ <!-- BEGIN categoryAdminOps_block -->
+ <a href="{addSubCatLink}">[l]Add subcategory[/l]</a>
+ <a href="{editCatLink}">[l]Edit[/l]</a>
+ <!-- BEGIN deleteCategory_block -->
+ <a href="#" onclick="deleteCategory({catId}, '{catLabel}')">[l]Delete[/l]</a>
+ <!-- END deleteCategory_block -->
+ <!-- END categoryAdminOps_block -->
</td>
</tr>
<!-- END categories_block -->
Modified: branches/release-candidates/sciret-1.2/templates/header.tpl
===================================================================
--- branches/release-candidates/sciret-1.2/templates/header.tpl 2007-08-15 19:31:40 UTC (rev 484)
+++ branches/release-candidates/sciret-1.2/templates/header.tpl 2007-08-16 00:20:45 UTC (rev 485)
@@ -88,7 +88,7 @@
<a href="{addBookmarkHref}">[l]Add Bookmark[/l]</a> |
<!-- END addBookmarkLink_block -->
<!-- BEGIN editCategoriesLink_block -->
- <a href="{editCategoriesHref}">[l]Edit Categories[/l]</a> |
+ <a href="{editCategoriesHref}">[l]Manage Categories[/l]</a> |
<!-- END editCategoriesLink_block -->
<!-- BEGIN manageArticlesLink_block -->
<a href="{manageArticlesHref}">[l]Manage Items[/l]</a> |
Modified: branches/release-candidates/sciret-1.2/views/EditCategories.php
===================================================================
--- branches/release-candidates/sciret-1.2/views/EditCategories.php 2007-08-15 19:31:40 UTC (rev 484)
+++ branches/release-candidates/sciret-1.2/views/EditCategories.php 2007-08-16 00:20:45 UTC (rev 485)
@@ -14,12 +14,17 @@
class EditCategories extends View {
+ var $hiddenCategories;
+
function dispatch() {
$this->tpl->set_file('edit_categories', 'EditCategories.tpl');
$this->tpl->set_block('edit_categories', 'categories_block', 'categories');
$this->tpl->set_block('categories_block', 'boldCategory_block', 'boldCategory');
$this->tpl->set_block('categories_block', 'nonBoldCategory_block', 'nonBoldCategory');
- $this->tpl->set_block('categories_block', 'deleteCategory_block', 'deleteCategory');
+ $this->tpl->set_block('categories_block', 'categoryAdminOps_block', 'categoryAdminOps');
+ $this->tpl->set_block('categoryAdminOps_block', 'deleteCategory_block', 'deleteCategory');
+ $this->tpl->set_block('categories_block', 'hideCategory_block', 'hideCategory');
+ $this->tpl->set_block('categories_block', 'showCategory_block', 'showCategory');
$this->tpl->set_var(array(
'deleteCatRedirect' => Library::getLink(array('action' => 'DeleteCategory')),
'addCatRedirect' => Library::getLink(array('view' => 'EditCategory', 'subAction' => 'add')),
@@ -27,6 +32,11 @@
$categoryGateway = new CategoryGateway;
$categories = $categoryGateway->getCategories();
+ if (!$this->user->getPreference('hiddenCategories')) {
+ $this->hiddenCategories = array();
+ } else {
+ $this->hiddenCategories = explode(',', $this->user->getPreference('hiddenCategories'));
+ }
foreach ($categories[0]->getChildren() as $category) {
$this->_showCategories($category);
}
@@ -44,6 +54,8 @@
$indent = str_repeat(' ', $depth);
$this->tpl->set_var(array(
+ 'hideCatLink' => Library::getLink(array('action' => 'HideCategory', 'catId' => $category->getId())),
+ 'showCatLink' => Library::getLink(array('action' => 'ShowCategory', 'catId' => $category->getId())),
'addSubCatLink' => Library::getLink(array('view' => 'EditCategory', 'subAction' => 'addSubCategory', 'catId' => $category->getId())),
'editCatLink' => Library::getLink(array('view' => 'EditCategory', 'catId' => $category->getId())),
'rowClass' => $rowClass,
@@ -54,6 +66,17 @@
'catIcon' => ($category->getIconFileName() != '')? '<img src="uploads/icons/'.$category->getIconFileName().'" />' : '',
));
+ if (in_array($category->getParentId(), $this->hiddenCategories)) {
+ $this->tpl->set_var('hideCategory', '');
+ $this->tpl->set_var('showCategory', '');
+ } elseif (in_array($category->getId(), $this->hiddenCategories)) {
+ $this->tpl->parse('showCategory', 'showCategory_block');
+ $this->tpl->set_var('hideCategory', '');
+ } else {
+ $this->tpl->parse('hideCategory', 'hideCategory_block');
+ $this->tpl->set_var('showCategory', '');
+ }
+
if ($depth == 0) {
$this->tpl->parse('boldCategory', 'boldCategory_block');
$this->tpl->set_var('nonBoldCategory', '');
@@ -68,6 +91,12 @@
$this->tpl->parse('deleteCategory', 'deleteCategory_block');
}
+ if ($this->user->isAdmin()) {
+ $this->tpl->parse('categoryAdminOps', 'categoryAdminOps_block');
+ } else {
+ $this->tpl->set_var('categoryAdminOps', '');
+ }
+
$this->tpl->parse('categories', 'categories_block', !$firstIteration);
$firstIteration = false;
$rowClass = $rowClass == 'row_off'? 'row_on' : 'row_off';
Modified: branches/release-candidates/sciret-1.2/views/View.php
===================================================================
--- branches/release-candidates/sciret-1.2/views/View.php 2007-08-15 19:31:40 UTC (rev 484)
+++ branches/release-candidates/sciret-1.2/views/View.php 2007-08-16 00:20:45 UTC (rev 485)
@@ -98,12 +98,8 @@
}
$this->tpl->set_block('header', 'editCategoriesLink_block', 'editCategoriesLink');
- if ($this->user->isAdmin()) {
- $this->tpl->set_var('editCategoriesHref', Library::getLink(array('view' => 'EditCategories')));
- $this->tpl->parse('editCategoriesLink', 'editCategoriesLink_block');
- } else {
- $this->tpl->set_var('editCategoriesLink', '');
- }
+ $this->tpl->set_var('editCategoriesHref', Library::getLink(array('view' => 'EditCategories')));
+ $this->tpl->parse('editCategoriesLink', 'editCategoriesLink_block');
$this->tpl->set_block('header', 'manageArticlesLink_block', 'manageArticlesLink');
if (!$this->user->isAnonymous()) {
@@ -154,8 +150,17 @@
function _getCategoriesHTML($categories, $view) {
$categories_str = '';
$num_main_cat = 0;
+ if (!$this->user->getPreference('hiddenCategories')) {
+ $hiddenCategories = array();
+ } else {
+ $hiddenCategories = explode(',', $this->user->getPreference('hiddenCategories'));
+ }
foreach ($categories as $cat) {
+ if (in_array($cat->getId(), $hiddenCategories)) {
+ continue;
+ }
+
$num_main_cat ++;
$categories_str .= "<tr><td valign=top>";
if ($icon = $cat->getIconFileName()) {
@@ -163,6 +168,9 @@
}
$categories_str .= "</td><td><a href='".Library::getLink(array('view' => $view, 'catId' => $cat->getId()))."'><b>".$cat->getLabel()."</b></a><br><div style='padding-left:10px'>";
foreach ($cat->getChildren() as $subcat) {
+ if (in_array($subcat->getId(), $hiddenCategories)) {
+ continue;
+ }
$categories_str .= "<a href='".Library::getLink(array('view' => $view, 'catId' => $subcat->getId()))."'>".$subcat->getLabel()."</a>, ";
}
if ($cat->hasChildren()) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|