[opw-web] Allow resigned students to reapply as student or mentor
- From: Owen Taylor <otaylor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [opw-web] Allow resigned students to reapply as student or mentor
- Date: Mon, 10 Mar 2014 20:44:39 +0000 (UTC)
commit b06dac75059ef980a1ffe18a4fbcf4f33f72009e
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Mon Mar 10 16:42:14 2014 -0400
Allow resigned students to reapply as student or mentor
Once someone resigned as student, allow them to reapply as a
student or a mentor (in case they just accidentally applied as
a student.)
modules/mod_program_home.php | 4 ++--
modules/mod_view_projects.php | 22 +++++++++++++---------
2 files changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/modules/mod_program_home.php b/modules/mod_program_home.php
index fc146e1..8af0c4f 100644
--- a/modules/mod_program_home.php
+++ b/modules/mod_program_home.php
@@ -47,8 +47,8 @@ if ($program_data != null)
'student_deadlines' => $lang->get('student_dl_info'),
'mentor_deadlines' => $lang->get('mentor_dl_info'),
'return_url' => urlencode($core->request_uri()),
- 'prg_guest_visibility' => $skin->visibility($role == 'g'),
- 'prg_resign_visibility' => $skin->visibility($role == 'r'),
+ 'prg_guest_visibility' => $skin->visibility($role == 'g' || $role == 'r'),
+ 'prg_resign_visibility' => $skin->visibility(false),
'prg_rejected_visibility' => $skin->visibility($role == 'x'),
'prg_student_visibility' => $skin->visibility($role == 's'),
'prg_interm_visibility' => $skin->visibility($role == 'i'),
diff --git a/modules/mod_view_projects.php b/modules/mod_view_projects.php
index ba2a828..a7775b6 100644
--- a/modules/mod_view_projects.php
+++ b/modules/mod_view_projects.php
@@ -826,8 +826,8 @@ else if ($action == 'approve' || $action == 'reject')
}
else if ($action == 'apply')
{
- // Only guests can apply
- $user->restrict($role == 'g');
+ // Only guests and resigned participants can apply
+ $user->restrict($role == 'g' || $role == 'r');
// We need program ID for this action
$user->restrict($program_id > 0);
@@ -838,8 +838,11 @@ else if ($action == 'apply')
// When applying as a mentor, an organization must be selected - otherwise
// we can continue
if ($category == 'student' || ($organization_id > 0 || $organization_id == -1)) {
+ if ($category == 'student')
+ $organization_id = 0;
+
$params = array('program_id' => $program_id,
- 'organization_id' => $organization_id,
+ 'organization_id' => $organization_id > 0 ? $organization_id : null,
'username' => $user->username);
// Get the program data
@@ -855,18 +858,19 @@ else if ($action == 'apply')
$params['role'] = $new_role;
// Insert the new role
- if ($organization_id > 0) {
+ if ($role == 'g') {
$sql = "INSERT INTO {$db->prefix}roles " .
"(username, program_id, organization_id, role) " .
"VALUES (:username, :program_id, :organization_id, :role)";
- $db->query($sql, $params);
} else {
- $sql = "INSERT INTO {$db->prefix}roles " .
- "(username, program_id, role) " .
- "VALUES (:username, :program_id, :role)";
- $db->query($sql, $params);
+ $sql = "UPDATE {$db->prefix}roles " .
+ "SET organization_id = :organization_id, " .
+ "role = :role " .
+ "WHERE username = :username AND program_id = :program_id";
}
+ $db->query($sql, $params);
+
// Notify admin with email for new mentor requests
if ($new_role == 'i')
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]