012719e3 by Kevin Burton

HTML library update and user manager update

1 parent 51385ba3
......@@ -38,6 +38,52 @@ function select_opts_securities($selected = null, $echo = true) {
return select_opts(Vars::$securities, $selected, $echo);
}
function validateDate( $date, $format='YYYY-MM-DD')
{
switch( $format )
{
case 'YYYY/MM/DD':
case 'YYYY-MM-DD':
list( $y, $m, $d ) = preg_split( '/[-\.\/ ]/', $date );
break;
case 'YYYY/DD/MM':
case 'YYYY-DD-MM':
list( $y, $d, $m ) = preg_split( '/[-\.\/ ]/', $date );
break;
case 'DD-MM-YYYY':
case 'DD/MM/YYYY':
list( $d, $m, $y ) = preg_split( '/[-\.\/ ]/', $date );
break;
case 'MM-DD-YYYY':
case 'MM/DD/YYYY':
list( $m, $d, $y ) = preg_split( '/[-\.\/ ]/', $date );
break;
case 'YYYYMMDD':
$y = substr( $date, 0, 4 );
$m = substr( $date, 4, 2 );
$d = substr( $date, 6, 2 );
break;
case 'YYYYDDMM':
$y = substr( $date, 0, 4 );
$d = substr( $date, 4, 2 );
$m = substr( $date, 6, 2 );
break;
default:
throw new Exception( "Invalid Date Format" );
}
return checkdate( $m, $d, $y );
}
class Vars {
public static $prefixes = Array(
......
......@@ -36,7 +36,7 @@ function get_user_notices($uid) {
$notices = get_user_meta($uid,'notices',true);
if(!empty($notices)) {
$notices = subval_sort($notices,'sent_date',arsort);
$notices = subval_sort($notices,'sent_date','arsort');
Vars::$notices = $notices;
}
......@@ -83,7 +83,7 @@ function print_user_notices($show_more = true) {
}
endif;
$rows .= '<tr>';
$rows .= '<tr class="notice-row">';
if ($notices[$i]['status']=="unread") {
$rows .= '<td width="12" style="padding:0;padding-left:10px;vertical-align:middle;"><a id="'.$i.'" href="#" class="notice '.(($notices[$i]['status']=="read") ? 'read' : 'unread').'"><img src="assets/images/blank.gif" width="12" height="12" /></a></td>';
} else {
......
......@@ -62,8 +62,8 @@ jQuery(function() {
}
, error: function(XMLHttpRequest, textStatus, errorThrown) {
var $error_container = jQuery('.validation-errors');
jQuery('h6',$error_container).html("A server error has occurred.");
jQuery('ul',$error_container).html("<li>"+errorThrown+"</li>");
jQuery('h6',$error_container).html("OOPS...");
jQuery('ul',$error_container).html("<li>Please check all required fields and be sure they are the right format.</li>");
$error_container.show();
}
});
......
......@@ -12,6 +12,7 @@ use Tz\Common;
use Tz\WordPress\Tools;
use Tz\WordPress\Tools\Auth;
use Tz\WordPress\UAM;
use Tz\WordPress\Tools\HTML;
use Tz\WordPress\CBV;
use Tz\WordPress\CBV\User;
use Tz\WordPress\CBV\Events;
......@@ -23,6 +24,7 @@ const OPTION_NAME = "user_options";
const CAPABILITY = "manage_cbv_users";
CBV\load('User');
Tools\import('HTML');
call_user_func(function() {
......@@ -184,6 +186,11 @@ class ProfileValidation extends Common\Validation {
}
public function date_of_birth($val) {
if (!empty($val)) {
if (!HTML\validateDate($val)) {
throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' must be in YYYY-MM-DD format.');
}
}
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
......@@ -740,7 +747,7 @@ class Actions {
}
public static function admin_menu() {
add_menu_page('CBV Users','CBV Users',CAPABILITY,'cbv_users',__NAMESPACE__ . '\display_users' );
add_menu_page('CBV Users','CBV Users',CAPABILITY,'cbv_users',__NAMESPACE__ . '\display_users',null,3 );
add_submenu_page('cbv_users','New User', 'New User',CAPABILITY,'cbv_users_create',__NAMESPACE__ . '\create_user');
}
......
......@@ -64,7 +64,7 @@ $preference = get_user_meta($user->ID, 'email_address_preference', true);
<td><textarea name="description"><?php echo get_user_meta($_GET['uid'], 'description', true);?></textarea></td>
</tr>
<tr>
<th>Date of Birth:</th>
<th>Date of Birth:<br /><span style="font-size:10px;color:#999;font-weight:normal;">(Ex. YYYY-MM-DD)</span></th>
<td><input type="text" name="date_of_birth" class="datepicker" value="<?php echo get_user_meta($_GET['uid'], 'date_of_birth', true);?>" /></td>
</tr>
</tbody>
......