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) { ...@@ -38,6 +38,52 @@ function select_opts_securities($selected = null, $echo = true) {
38 return select_opts(Vars::$securities, $selected, $echo); 38 return select_opts(Vars::$securities, $selected, $echo);
39 } 39 }
40 40
41 function validateDate( $date, $format='YYYY-MM-DD')
42 {
43 switch( $format )
44 {
45 case 'YYYY/MM/DD':
46 case 'YYYY-MM-DD':
47 list( $y, $m, $d ) = preg_split( '/[-\.\/ ]/', $date );
48 break;
49
50 case 'YYYY/DD/MM':
51 case 'YYYY-DD-MM':
52 list( $y, $d, $m ) = preg_split( '/[-\.\/ ]/', $date );
53 break;
54
55 case 'DD-MM-YYYY':
56 case 'DD/MM/YYYY':
57 list( $d, $m, $y ) = preg_split( '/[-\.\/ ]/', $date );
58 break;
59
60 case 'MM-DD-YYYY':
61 case 'MM/DD/YYYY':
62 list( $m, $d, $y ) = preg_split( '/[-\.\/ ]/', $date );
63 break;
64
65 case 'YYYYMMDD':
66 $y = substr( $date, 0, 4 );
67 $m = substr( $date, 4, 2 );
68 $d = substr( $date, 6, 2 );
69 break;
70
71 case 'YYYYDDMM':
72 $y = substr( $date, 0, 4 );
73 $d = substr( $date, 4, 2 );
74 $m = substr( $date, 6, 2 );
75 break;
76
77 default:
78 throw new Exception( "Invalid Date Format" );
79 }
80
81 return checkdate( $m, $d, $y );
82
83
84
85 }
86
41 class Vars { 87 class Vars {
42 88
43 public static $prefixes = Array( 89 public static $prefixes = Array(
......
...@@ -36,7 +36,7 @@ function get_user_notices($uid) { ...@@ -36,7 +36,7 @@ function get_user_notices($uid) {
36 $notices = get_user_meta($uid,'notices',true); 36 $notices = get_user_meta($uid,'notices',true);
37 if(!empty($notices)) { 37 if(!empty($notices)) {
38 38
39 $notices = subval_sort($notices,'sent_date',arsort); 39 $notices = subval_sort($notices,'sent_date','arsort');
40 40
41 Vars::$notices = $notices; 41 Vars::$notices = $notices;
42 } 42 }
...@@ -83,7 +83,7 @@ function print_user_notices($show_more = true) { ...@@ -83,7 +83,7 @@ function print_user_notices($show_more = true) {
83 } 83 }
84 endif; 84 endif;
85 85
86 $rows .= '<tr>'; 86 $rows .= '<tr class="notice-row">';
87 if ($notices[$i]['status']=="unread") { 87 if ($notices[$i]['status']=="unread") {
88 $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>'; 88 $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>';
89 } else { 89 } else {
......
...@@ -62,8 +62,8 @@ jQuery(function() { ...@@ -62,8 +62,8 @@ jQuery(function() {
62 } 62 }
63 , error: function(XMLHttpRequest, textStatus, errorThrown) { 63 , error: function(XMLHttpRequest, textStatus, errorThrown) {
64 var $error_container = jQuery('.validation-errors'); 64 var $error_container = jQuery('.validation-errors');
65 jQuery('h6',$error_container).html("A server error has occurred."); 65 jQuery('h6',$error_container).html("OOPS...");
66 jQuery('ul',$error_container).html("<li>"+errorThrown+"</li>"); 66 jQuery('ul',$error_container).html("<li>Please check all required fields and be sure they are the right format.</li>");
67 $error_container.show(); 67 $error_container.show();
68 } 68 }
69 }); 69 });
......
...@@ -12,6 +12,7 @@ use Tz\Common; ...@@ -12,6 +12,7 @@ use Tz\Common;
12 use Tz\WordPress\Tools; 12 use Tz\WordPress\Tools;
13 use Tz\WordPress\Tools\Auth; 13 use Tz\WordPress\Tools\Auth;
14 use Tz\WordPress\UAM; 14 use Tz\WordPress\UAM;
15 use Tz\WordPress\Tools\HTML;
15 use Tz\WordPress\CBV; 16 use Tz\WordPress\CBV;
16 use Tz\WordPress\CBV\User; 17 use Tz\WordPress\CBV\User;
17 use Tz\WordPress\CBV\Events; 18 use Tz\WordPress\CBV\Events;
...@@ -23,6 +24,7 @@ const OPTION_NAME = "user_options"; ...@@ -23,6 +24,7 @@ const OPTION_NAME = "user_options";
23 const CAPABILITY = "manage_cbv_users"; 24 const CAPABILITY = "manage_cbv_users";
24 25
25 CBV\load('User'); 26 CBV\load('User');
27 Tools\import('HTML');
26 28
27 29
28 call_user_func(function() { 30 call_user_func(function() {
...@@ -184,6 +186,11 @@ class ProfileValidation extends Common\Validation { ...@@ -184,6 +186,11 @@ class ProfileValidation extends Common\Validation {
184 } 186 }
185 187
186 public function date_of_birth($val) { 188 public function date_of_birth($val) {
189 if (!empty($val)) {
190 if (!HTML\validateDate($val)) {
191 throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' must be in YYYY-MM-DD format.');
192 }
193 }
187 update_user_meta($_POST['uid'], __FUNCTION__, $val); 194 update_user_meta($_POST['uid'], __FUNCTION__, $val);
188 } 195 }
189 196
...@@ -740,7 +747,7 @@ class Actions { ...@@ -740,7 +747,7 @@ class Actions {
740 } 747 }
741 748
742 public static function admin_menu() { 749 public static function admin_menu() {
743 add_menu_page('CBV Users','CBV Users',CAPABILITY,'cbv_users',__NAMESPACE__ . '\display_users' ); 750 add_menu_page('CBV Users','CBV Users',CAPABILITY,'cbv_users',__NAMESPACE__ . '\display_users',null,3 );
744 add_submenu_page('cbv_users','New User', 'New User',CAPABILITY,'cbv_users_create',__NAMESPACE__ . '\create_user'); 751 add_submenu_page('cbv_users','New User', 'New User',CAPABILITY,'cbv_users_create',__NAMESPACE__ . '\create_user');
745 } 752 }
746 753
......
...@@ -64,7 +64,7 @@ $preference = get_user_meta($user->ID, 'email_address_preference', true); ...@@ -64,7 +64,7 @@ $preference = get_user_meta($user->ID, 'email_address_preference', true);
64 <td><textarea name="description"><?php echo get_user_meta($_GET['uid'], 'description', true);?></textarea></td> 64 <td><textarea name="description"><?php echo get_user_meta($_GET['uid'], 'description', true);?></textarea></td>
65 </tr> 65 </tr>
66 <tr> 66 <tr>
67 <th>Date of Birth:</th> 67 <th>Date of Birth:<br /><span style="font-size:10px;color:#999;font-weight:normal;">(Ex. YYYY-MM-DD)</span></th>
68 <td><input type="text" name="date_of_birth" class="datepicker" value="<?php echo get_user_meta($_GET['uid'], 'date_of_birth', true);?>" /></td> 68 <td><input type="text" name="date_of_birth" class="datepicker" value="<?php echo get_user_meta($_GET['uid'], 'date_of_birth', true);?>" /></td>
69 </tr> 69 </tr>
70 </tbody> 70 </tbody>
......