6d755f9b by Chris Boden

Merged Branding/UM-Course changes into cicbv live, r199

1 parent 6ba11066
......@@ -102,7 +102,7 @@ function swap_admin_menu_sections($from_section,$to_section) {
$from_section = get_admin_menu_section($from_section);
if ($from_section)
$from_section->swap_with($to_section);
return $section;
return $from_section;
}
function get_admin_menu_section($section) {
if (!is_a($section,'WP_AdminMenuSection'))
......
function submitMark(e) {
if (e.keyCode == 27) {
document.getElementById(e.target.getAttribute('data-ref')).style.display = 'inline';
e.target.parentNode.removeChild(e.target);
return;
}
if (e.keyCode == 13) {
jQuery.ajax({
url: '/wp-admin/admin-ajax.php'
, data: {ajax: 'yes', action: 'update_mark', uid: user_id, course_id: e.target.getAttribute('data-course-id'), value: e.target.value}
, type: 'POST'
, dataType: 'json'
, success: function() {
var oLink = document.getElementById(e.target.getAttribute('data-ref'));
oLink.setAttribute('data-mark-value', e.target.value);
oLink.firstChild.nodeValue = e.target.value;
oLink.style.display = 'inline';
e.target.parentNode.removeChild(e.target);
}
});
}
}
function update_listing_preference() {
var pref = jQuery('#profile_preference').val();
if (pref == "Work") {
......@@ -366,6 +392,34 @@ jQuery(function($) {
return false;
});
jQuery('#TzFQActions input').click(function(e) {
jQuery.ajax({
url: '/wp-admin/admin-ajax.php'
, data: {ajax: 'yes', action: 'update_fq_status', uid: user_id, status: e.target.value}
, type: 'POST'
, dataType: 'json'
, success: function() {
jQuery("#Tz4QContainer").remove();
}
});
});
jQuery('#mark_history a[data-mark="editable"]').click(function(e) {
var oEdit = document.createElement('input');
oEdit.type = 'text';
oEdit.size = 3;
oEdit.value = e.target.getAttribute('data-mark-value');
e.target.parentNode.appendChild(oEdit);
oEdit.setAttribute('data-ref', e.target.id);
oEdit.setAttribute('data-course-id', e.target.getAttribute('data-course-id'));
oEdit.focus();
jQuery(oEdit).keydown(submitMark);
e.target.style.display = 'none';
}).each(function(i, o) {
o.onclick = function() { return false; };
});
});
\ No newline at end of file
......
......@@ -389,6 +389,7 @@ class AccountValidation extends Common\Validation {
return false;
}
// here
foreach ($this->all_groups as $id => $one) {
if (isset($this->on_groups[$id])) {
UAM\getGroupByID($id)->addUser($_POST['uid']);
......@@ -527,6 +528,30 @@ function run_validation() {
}
class Actions {
public static function wp_ajax_update_mark() {
$account = new User\Account($_POST['uid']);
$marks = $account->marks;
$marks['history'][$_POST['course_id']]['mark'] = $_POST['value'];
update_user_meta($account->ID, 'marks', $marks);
}
public static function wp_ajax_update_fq_status() {
$return = Array('success' => 'false');
$status = trim(strtolower($_POST['status']));
$lookup = Array(
'approve' => 'A'
, 'decline' => 'D'
);
if (isset($lookup[$status])) {
update_user_meta($_POST['uid'], 'course_4q_approvals', $lookup[$status]);
$return['success'] = 'true';
}
die(json_encode($return));
}
public static function wp_ajax_update_edit_notes() {
global $wpdb;
......
......@@ -3,7 +3,7 @@ namespace Tz\WordPress\Tools\UserManager;
use Tz, Tz\Common;
use Tz\WordPress\Tools;
use Tz\WordPress\CBV;
use Tz\WordPress\CBV\Courses;
use Tz\WordPress\CBV\Courses, Tz\WordPress\CBV\Courses\Registration;
use Tz\WordPress\CBV\User;
use Tz\WordPress\UAM;
use WP_Query;
......@@ -27,20 +27,37 @@ use WP_Query;
};
?>
<div style="padding:10px 10px 0px 10px; min-width:760px;">
<!--
<div id="Tz4QContainer">
<?php if ($user->course_4q_approvals == 'P'): ?>
<h2>Security Question Status</h2>
<p>
<ul>
<?php
CBV\load('Courses\Registration');
$four_questions = Registration\get_four_questions();
foreach ($user->four_security_questions as $key => $yesno) {
if ($yesno == 1) {
echo "<li>Q: {$four_questions[$key]} (yes)</li>";
}
}
?>
</ul>
<p style="padding: 0 1em;"><em>&quot;<?php echo nl2br(htmlspecialchars($user->four_security_explanation)); ?>&quot;</em></p>
<p id="TzFQActions">
<input type="button" value=" Approve " />
<input type="button" value=" Decline " />
</p>
-->
<?php endif; ?>
</div>
<h2 style="margin-bottom:10px;padding-bottom:0px;">Courses</h2>
<h2 style="margin-bottom:10px;padding-bottom:0px;">Current Courses</h2>
<table class="clean-lines widefat post fixed">
<thead><tr>
<th>Course</th>
<th>Type</th>
<th>Mark & Pass/Fail</th>
<th width="85">Type</th>
<th width="100">Latest Mark</th>
<th>Registration Deadline</th>
<th>Semester Runs</th>
<th>Register</th>
......@@ -59,7 +76,7 @@ use WP_Query;
<td><?php echo get_post_meta(get_the_ID(), 'course_type', true); ?></td>
<td><?php echo $user->getMark(get_the_ID()); ?></td>
<td><?php echo $fn_cd(get_the_ID(), 'course_regi_close'); ?>
<td><?php echo $fn_cd(get_the_ID(), 'course_start') . ' - ' . $fn_cd(get_the_ID(), 'course_end'); ?></td>
<td><?php echo $fn_cd(get_the_ID(), 'course_start') . '&nbsp;-&nbsp;' . $fn_cd(get_the_ID(), 'course_end'); ?></td>
<td>
<?php if (isset($lookup[get_the_ID()]) && $lookup[get_the_ID()]->registrationOpen()): ?>
<?php if ($user->courseApprovalStatus($lookup[get_the_ID()]->getID()) == $user::CAS_APPROVED): ?>
......@@ -77,10 +94,31 @@ use WP_Query;
</tbody>
</table>
<?php /*
<pre><?php print_r(get_user_meta($_GET['uid'], 'courses_registered', true)); ?></pre>
<pre><?php print_r(get_user_meta($_GET['uid'], 'marks', true)); ?></pre>
<pre><?php print_r(get_user_meta($_GET['uid'], 'course_4q_approvals', true)); ?></pre>
*/ ?>
<h2>Course History</h2>
<table class="clean-lines widefat post fixed" id="mark_history">
<thead><tr>
<th>Course</th>
<th>Type</th>
<th>Mark</th>
<th>Semester</th>
<th>Date Achieved</th>
</tr></thead>
<tbody>
<?php
foreach ($user->marks['history'] as $data):
$course = new Courses\Course($data['course_id']);
?>
<tr>
<td><?php echo $course->post_title; ?></td>
<td><?php echo $course->course_type; ?></td>
<td><a href="#" id="edit_mark_<?php echo $course->ID; ?>" data-mark="editable" data-course-id="<?php echo $course->ID; ?>" data-mark-value="<?php echo $data['mark']; ?>"><?php echo $data['mark']; ?></a></td>
<td><?php echo $course->semester_id; ?></td>
<td><?php echo date('Y-m-d', $data['added']); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
\ No newline at end of file
......