[opw-web] Add 'all' option to view programs, link to from header
- From: Owen Taylor <otaylor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [opw-web] Add 'all' option to view programs, link to from header
- Date: Mon, 22 Sep 2014 03:43:52 +0000 (UTC)
commit 58d3cde40210fdb73e361cc6e18641df5a64f4ac
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Sun Sep 21 23:37:19 2014 -0400
Add 'all' option to view programs, link to from header
The new 'all' option shows all programs; change 'all' and 'inactive'
to be visible to mentors for any program. Link to the all version
from "View all programs" in the header.
lang/en-gb.php | 1 +
modules/mod_view_programs.php | 12 +++++++++---
skins/easterngreen/html/tpl_header.html | 6 ++++++
3 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/lang/en-gb.php b/lang/en-gb.php
index 7121e2a..1ff912b 100644
--- a/lang/en-gb.php
+++ b/lang/en-gb.php
@@ -32,6 +32,7 @@ $lang_data = array(
'manage_organizations' => 'Manage organizations',
'manage_bans' => 'Manage user bans',
'navigation' => 'Navigation',
+ 'view_all_programs' => 'View all programs',
'view_active_progms' => 'View active programs',
'view_archives' => 'View archived projects',
'view_rejected' => 'View rejected projects',
diff --git a/modules/mod_view_programs.php b/modules/mod_view_programs.php
index 975567d..3e04d27 100644
--- a/modules/mod_view_programs.php
+++ b/modules/mod_view_programs.php
@@ -17,7 +17,9 @@ $limit_start = ($page - 1) * $config->per_page;
$user->restrict(in_array($return_url, array('', 'accepted', 'proposed', 'rejected')));
// Inactive programs can be viewed only by admins
-$user->restrict($action == 'active' || ($action == 'inactive' && $user->is_admin));
+$user->restrict($action == 'active' ||
+ (($action == 'all' || $action == 'inactive') &&
+ ($user->is_admin || $user->isMentorAnyProgram())));
// Rejected return URL allowed only for admins
$user->restrict($return_url != 'rejected' || ($return_url == 'rejected' && $user->is_admin));
@@ -25,7 +27,11 @@ $user->restrict($return_url != 'rejected' || ($return_url == 'rejected' && $user
// Get a list of active programs
$data_sql = "SELECT * FROM {$db->prefix}programs ";
$count_sql = "SELECT COUNT(*) AS count FROM {$db->prefix}programs ";
-$filter = "WHERE is_active = " . ($action == 'active' ? '1 ' : '0 ');
+if ($action == 'all')
+ $filter = '';
+else
+ $filter = "WHERE is_active = " . ($action == 'active' ? '1 ' : '0 ');
+
$limit = "LIMIT {$limit_start}, {$config->per_page}";
// Apply filters
@@ -55,7 +61,7 @@ if (!$program_count)
// If only one program is active, directly take the user to the destination
// Don't do this when we are viewing archived projects
-if ($program_count['count'] == 1 && count($program_data) == 1 && $action != 'inactive')
+if ($program_count['count'] == 1 && count($program_data) == 1 && $action == 'active')
{
$row = $program_data[0];
diff --git a/skins/easterngreen/html/tpl_header.html b/skins/easterngreen/html/tpl_header.html
index 78df523..791a34e 100644
--- a/skins/easterngreen/html/tpl_header.html
+++ b/skins/easterngreen/html/tpl_header.html
@@ -105,6 +105,12 @@ ocalization variable
</a>
</li>
+ <li class="[[mentor_visibility]]">
+ <a href="?q=view_programs&a=all">
+ {{view_all_programs}}
+ </a>
+ </li>
+
<li class="divider [[admin_visibility]]"></li>
<li class="[[admin_visibility]]">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]