[opw-web] Finish the admin approve/reject interface on the application ranking screen



commit a4343688c1b8410faa929b9f41c85bad4c3bae01
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Wed Mar 19 09:13:48 2014 -0400

    Finish the admin approve/reject interface on the application ranking screen
    
    * Show badges indicating approved/rejected projects
    * Add a pending icon to allow clearing approved/rejected status

 lang/en-gb.php                                     |    4 ++++
 modules/mod_manage_projects.php                    |    6 ++++--
 modules/mod_view_projects.php                      |   11 ++++++++---
 skins/easterngreen/html/tpl_manage_projects.html   |    2 +-
 .../html/tpl_manage_projects_item.html             |    6 +++++-
 utils.php                                          |   20 ++++++++++++++++++++
 6 files changed, 42 insertions(+), 7 deletions(-)
---
diff --git a/lang/en-gb.php b/lang/en-gb.php
index 50674a5..01caabb 100644
--- a/lang/en-gb.php
+++ b/lang/en-gb.php
@@ -72,6 +72,9 @@ $lang_data = array(
     'debug_email'           => 'Mail service is %s',
     'approve'               => 'Approve',
     'reject'                => 'Reject',
+    'accepted'              => 'Accepted',
+    'rejected'              => 'Rejected',
+    'withdrawn'             => 'Withdrawn',
 
     /* Homepage */
     'welcome_homepage'      => 'Welcome to [[site_name]]',
@@ -151,6 +154,7 @@ $lang_data = array(
     'applicant'             => 'Applicant',
     'manage'                => 'Rank',
     'status'                => 'Status',
+    'pending'               => 'Pending',
     'opinion_n'             => 'No contribution',
     'opinion_y'             => 'No contribution, will not accept',
     'opinion_c'             => 'Contribution, under review',
diff --git a/modules/mod_manage_projects.php b/modules/mod_manage_projects.php
index 4463024..05f9317 100644
--- a/modules/mod_manage_projects.php
+++ b/modules/mod_manage_projects.php
@@ -141,7 +141,6 @@ $a = 1;
 foreach ($list_data as &$row)
 {
     $project_title = htmlspecialchars($row['title']);
-    $is_withdrawn = $row['is_withdrawn'] == 1;
     $username = $row['username'];
     $profile = $user->profile($username);
 
@@ -164,12 +163,14 @@ foreach ($list_data as &$row)
         'project_applicant'     => $profile,
         'ranking'               => $ranking,
         'ranking_name'          => 'ranking' . $project_id,
-        'withdrawn_visibility'  => $skin->visibility($is_withdrawn),
+        'badges'                => build_project_badges($role, $row),
         'disabled'              => $can_edit ? '' : ' disabled',
         'opinion_select'        => build_opinion_select($row['org_opinion'], 'opinion' . $project_id, 
!$can_edit),
         'project_url'           => "?q=view_projects&amp;prg={$program_id}&amp;p={$project_id}",
         'approve_url'           => "?q=view_projects&amp;a=approve&amp;prg={$program_id}" .
                                    "&amp;p={$project_id}&amp;r={$return_url}",
+        'pending_url'           => "?q=view_projects&amp;a=pending&amp;prg={$program_id}" .
+                                   "&amp;p={$project_id}&amp;r={$return_url}",
         'reject_url'            => "?q=view_projects&amp;a=reject&amp;prg={$program_id}" .
                                    "&amp;p={$project_id}&amp;r={$return_url}",
     ));
@@ -186,6 +187,7 @@ $skin->assign(array(
     'organization_select'   => $organization_select,
     'projects_list'         => $projects_list,
     'disabled'              => $can_edit ? '' : ' disabled',
+    'admin_visibility'      => $skin->visibility($user->is_admin),
     'notice_visibility'     => $skin->visibility($organization_id > 0 && count($list_data) == 0),
     'list_visibility'       => $skin->visibility(count($list_data) > 0)
 ));
diff --git a/modules/mod_view_projects.php b/modules/mod_view_projects.php
index facad03..ca1a224 100644
--- a/modules/mod_view_projects.php
+++ b/modules/mod_view_projects.php
@@ -815,7 +815,7 @@ else if ($action == 'user' || $action == 'proposed' || $action == 'accepted' ||
     $module_title = $title;
     $module_data = $skin->output('tpl_view_projects');
 }
-else if ($action == 'approve' || $action == 'reject')
+else if ($action == 'approve' || $action == 'reject' || $action == 'pending')
 {
     $user->check_csrf();
 
@@ -825,8 +825,13 @@ else if ($action == 'approve' || $action == 'reject')
     // Program ID, Project ID and return URL are mandatory
     $user->restrict($program_id > 0 && $project_id > 0 && !empty($return_url));
 
-    // Set the accepted flag when approving
-    $flag = $action == 'approve' ? 1 : 0;
+    // Set the appropriate value of the accepted flag
+    if ($action == 'approve')
+        $flag = 1;
+    else if ($action == 'reject')
+        $flag = 0;
+    else
+        $flag = -1;
 
     // Set the project as approved
     $sql = "UPDATE {$db->prefix}projects " .
diff --git a/skins/easterngreen/html/tpl_manage_projects.html 
b/skins/easterngreen/html/tpl_manage_projects.html
index c3040f2..7d9f3a9 100644
--- a/skins/easterngreen/html/tpl_manage_projects.html
+++ b/skins/easterngreen/html/tpl_manage_projects.html
@@ -47,7 +47,7 @@
                     {{rank}}
                 </th>
 
-                <th style="width:50px;"></th>
+                <th style="width:75px" class="[[admin_visibility]]"></th>
             </tr>
         </thead>
 
diff --git a/skins/easterngreen/html/tpl_manage_projects_item.html 
b/skins/easterngreen/html/tpl_manage_projects_item.html
index abb76ba..b3932f7 100644
--- a/skins/easterngreen/html/tpl_manage_projects_item.html
+++ b/skins/easterngreen/html/tpl_manage_projects_item.html
@@ -2,7 +2,7 @@
     <td>
         <a href="[[project_url]]">
             [[project_title]]
-        </a><span class="[[withdrawn_visibility]]">&nbsp;<span class="badge">Withdrawn</span></span>
+        </a>[[badges]]
     </td>
 
     <td>
@@ -23,6 +23,10 @@
                 <i class="icon-ok"></i>
             </a>
             &nbsp;
+            <a href="#" onclick="submitForm(event, '[[pending_url]]')" title="{{pending}}">
+                <i class="icon-adjust"></i>
+            </a>
+            &nbsp;
             <a href="#" onclick="submitForm(event, '[[reject_url]]')" title="{{reject}}">
                 <i class="icon-remove"></i>
             </a>
diff --git a/utils.php b/utils.php
index 8dd24a5..860dd0a 100644
--- a/utils.php
+++ b/utils.php
@@ -65,6 +65,26 @@ function opinion_is_valid($value) {
   return in_array($value, $VALID_OPINIONS);
 }
 
+function build_project_badges($role, $project_data) {
+    global $lang, $user;
+
+    $result = '';
+    if ($project_data['is_withdrawn'] == 1) {
+        $result .= '&nbsp;<span class="badge">' . $lang->get('withdrawn') . '</span>';
+    }
+
+    if ($role == 'm' || $user->is_admin) {
+        if ($project_data['is_accepted'] == 1) {
+            $result .= '&nbsp;<span class="badge badge-success">' . $lang->get('accepted') . '</span>';
+        }
+        if ($project_data['is_accepted'] == 0) {
+            $result .= '&nbsp;<span class="badge badge-warning">' . $lang->get('rejected') . '</span>';
+        }
+    }
+
+    return $result;
+}
+
 class ProjectPermissions {
 
     public $can_submit;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]