Added group to user overview manager. fixes #897
Showing
3 changed files
with
82 additions
and
30 deletions
| ... | @@ -149,7 +149,6 @@ function create_user() { | ... | @@ -149,7 +149,6 @@ function create_user() { |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | class ProfileValidation extends Common\Validation { | 151 | class ProfileValidation extends Common\Validation { |
| 152 | |||
| 153 | public function prefix($val) { | 152 | public function prefix($val) { |
| 154 | update_user_meta($_POST['uid'], __FUNCTION__, $val); | 153 | update_user_meta($_POST['uid'], __FUNCTION__, $val); |
| 155 | } | 154 | } |
| ... | @@ -336,8 +335,39 @@ class ProfileValidation extends Common\Validation { | ... | @@ -336,8 +335,39 @@ class ProfileValidation extends Common\Validation { |
| 336 | } | 335 | } |
| 337 | 336 | ||
| 338 | class AccountValidation extends Common\Validation { | 337 | class AccountValidation extends Common\Validation { |
| 338 | protected $on_groups = false; | ||
| 339 | protected $all_groups = false; | ||
| 340 | |||
| 341 | protected function setGroups() { | ||
| 342 | if (false === $this->on_groups || false === $this->all_groups) { | ||
| 343 | return false; | ||
| 344 | } | ||
| 345 | |||
| 346 | foreach ($this->all_groups as $id => $one) { | ||
| 347 | if (isset($this->on_groups[$id])) { | ||
| 348 | UAM\getGroupByID($id)->addUser($_POST['uid']); | ||
| 349 | } else { | ||
| 350 | UAM\getGroupByID($id)->removeUser($_POST['uid']); | ||
| 351 | } | ||
| 352 | } | ||
| 353 | } | ||
| 354 | |||
| 355 | public function group($val) { | ||
| 356 | $this->on_groups = $val; | ||
| 357 | $this->setGroups(); | ||
| 358 | } | ||
| 359 | |||
| 360 | public function grpanch($val) { | ||
| 361 | $this->all_groups = $val; | ||
| 362 | $this->setGroups(); | ||
| 363 | } | ||
| 339 | 364 | ||
| 340 | public function status($val) { | 365 | public function status($val) { |
| 366 | /* | ||
| 367 | $account = new User\Account($_POST['uid']); | ||
| 368 | $account->setStatus($val); | ||
| 369 | */ | ||
| 370 | |||
| 341 | update_user_meta($_POST['uid'], 'status',$val); | 371 | update_user_meta($_POST['uid'], 'status',$val); |
| 342 | } | 372 | } |
| 343 | 373 | ... | ... |
| ... | @@ -5,6 +5,7 @@ use Tz, Tz\Common; | ... | @@ -5,6 +5,7 @@ use Tz, Tz\Common; |
| 5 | use Tz\WordPress\CBV; | 5 | use Tz\WordPress\CBV; |
| 6 | use Tz\WordPress\CBV\CEHours; | 6 | use Tz\WordPress\CBV\CEHours; |
| 7 | use Tz\WordPress\CBV\Events; | 7 | use Tz\WordPress\CBV\Events; |
| 8 | use Tz\WordPress\CBV\User; | ||
| 8 | use Tz\WordPress\UAM; | 9 | use Tz\WordPress\UAM; |
| 9 | 10 | ||
| 10 | use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD; | 11 | use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD; |
| ... | @@ -12,9 +13,18 @@ use Tz\WordPress\Tools\Notifications; | ... | @@ -12,9 +13,18 @@ use Tz\WordPress\Tools\Notifications; |
| 12 | 13 | ||
| 13 | use Exception, StdClass; | 14 | use Exception, StdClass; |
| 14 | use WP_User; | 15 | use WP_User; |
| 16 | |||
| 17 | CBV\load('Courses'); | ||
| 18 | $user = new User\Account($_GET['uid']); | ||
| 15 | ?> | 19 | ?> |
| 16 | <div style="padding:10px 10px 0px 10px; min-width:760px;"> | 20 | <div style="padding:10px 10px 0px 10px; min-width:760px;"> |
| 21 | <h2>Security Question Status</h2> | ||
| 22 | <p> | ||
| 23 | |||
| 24 | </p> | ||
| 25 | |||
| 17 | <h2 style="margin-bottom:10px;padding-bottom:0px;">Registered for Courses...</h2> | 26 | <h2 style="margin-bottom:10px;padding-bottom:0px;">Registered for Courses...</h2> |
| 18 | <em>Will be implemented when Courses is complete.</em> | 27 | <pre><?php print_r(get_user_meta($_GET['uid'], 'courses_registered', true)); ?></pre> |
| 28 | <pre><?php print_r(get_user_meta($_GET['uid'], 'course_4q_approvals', true)); ?></pre> | ||
| 19 | </div> | 29 | </div> |
| 20 | <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script> | 30 | <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script> |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -5,6 +5,7 @@ use Tz, Tz\Common; | ... | @@ -5,6 +5,7 @@ use Tz, Tz\Common; |
| 5 | use Tz\WordPress\CBV; | 5 | use Tz\WordPress\CBV; |
| 6 | use Tz\WordPress\CBV\CEHours; | 6 | use Tz\WordPress\CBV\CEHours; |
| 7 | use Tz\WordPress\CBV\Events; | 7 | use Tz\WordPress\CBV\Events; |
| 8 | use Tz\WordPress\CBV\User; | ||
| 8 | use Tz\WordPress\UAM; | 9 | use Tz\WordPress\UAM; |
| 9 | 10 | ||
| 10 | use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD; | 11 | use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD; |
| ... | @@ -13,42 +14,34 @@ use Tz\WordPress\Tools\Notifications; | ... | @@ -13,42 +14,34 @@ use Tz\WordPress\Tools\Notifications; |
| 13 | use Exception, StdClass; | 14 | use Exception, StdClass; |
| 14 | use WP_User, WP_Roles; | 15 | use WP_User, WP_Roles; |
| 15 | 16 | ||
| 16 | $uid = $user->ID; | 17 | $uid = $user->ID; |
| 18 | $account = new User\Account($uid); | ||
| 17 | 19 | ||
| 18 | $first_name = get_user_meta($uid, 'first_name', true); | 20 | $first_name = get_user_meta($uid, 'first_name', true); |
| 19 | $last_name = get_user_meta($uid, 'last_name', true); | 21 | $last_name = get_user_meta($uid, 'last_name', true); |
| 20 | $description = get_user_meta($uid, 'description', true); | ||
| 21 | 22 | ||
| 22 | // contact info. | 23 | // contact info. |
| 23 | $address = get_user_meta($uid, 'address', true); | 24 | $country = get_user_meta($uid, 'country', true); |
| 24 | $address2 = get_user_meta($uid, 'address2', true); | 25 | $mobile = get_user_meta($uid, 'mobile', true); |
| 25 | $city = get_user_meta($uid, 'city', true); | 26 | $email = $user->user_email;//get_user_meta($uid, 'email', true); |
| 26 | $province = get_user_meta($uid, 'province', true); | ||
| 27 | $postal = get_user_meta($uid, 'postal', true); | ||
| 28 | $country = get_user_meta($uid, 'country', true); | ||
| 29 | $phone = get_user_meta($uid, 'phone', true); | ||
| 30 | $fax = get_user_meta($uid, 'fax', true); | ||
| 31 | $mobile = get_user_meta($uid, 'mobile', true); | ||
| 32 | $email = $user->user_email;//get_user_meta($uid, 'email', true); | ||
| 33 | 27 | ||
| 34 | // professional stuff | 28 | // professional stuff |
| 35 | $title = get_user_meta($uid, 'title', true); | 29 | $title = get_user_meta($uid, 'title', true); |
| 36 | $company = get_user_meta($uid, 'company', true); | 30 | $company = get_user_meta($uid, 'company', true); |
| 37 | $website = get_user_meta($uid, 'website', true); | ||
| 38 | 31 | ||
| 39 | // status | 32 | // status |
| 40 | $status = get_user_meta($uid, 'status', true); | 33 | $status = get_user_meta($uid, 'status', true); |
| 41 | 34 | ||
| 42 | // membership | 35 | // membership |
| 43 | $member_id = get_user_meta($uid, 'member_id', true); | 36 | $member_id = get_user_meta($uid, 'member_id', true); |
| 44 | 37 | ||
| 45 | $notify_me = get_user_meta($uid, 'notify_me', true); | 38 | $notify_me = get_user_meta($uid, 'notify_me', true); |
| 46 | 39 | ||
| 47 | 40 | ||
| 48 | $rc = new WP_Roles(); | 41 | $rc = new WP_Roles(); |
| 49 | $roles = $rc->role_names; | 42 | $roles = $rc->role_names; |
| 50 | ksort($roles); | 43 | ksort($roles); |
| 51 | unset($rc, $roles['administrator']); | 44 | unset($rc, $roles['administrator']); |
| 52 | 45 | ||
| 53 | 46 | ||
| 54 | ?> | 47 | ?> |
| ... | @@ -229,9 +222,28 @@ unset($rc, $roles['administrator']); | ... | @@ -229,9 +222,28 @@ unset($rc, $roles['administrator']); |
| 229 | </tr> | 222 | </tr> |
| 230 | </tbody> | 223 | </tbody> |
| 231 | </table> | 224 | </table> |
| 225 | |||
| 232 | <div style="clear:both;"></div> | 226 | <div style="clear:both;"></div> |
| 233 | </div> | 227 | </div> |
| 234 | 228 | ||
| 229 | <div> | ||
| 230 | <h3>Groups:</h3> | ||
| 231 | <ul> | ||
| 232 | <?php | ||
| 233 | $groups = UAM\getGroups(); | ||
| 234 | foreach ($groups as $group): | ||
| 235 | $dom = "group[{$group->getID()}]"; | ||
| 236 | $checked = ($account->isMemberOf($group->getName()) ? ' checked="checked"' : ''); | ||
| 237 | $disabled = ($group->isRoleAffiliated($account->getRole()) ? ' disabled="disabled"' : ''); | ||
| 238 | ?> | ||
| 239 | <li> | ||
| 240 | <input type="hidden" name="grpanch[<?php echo $group->getID(); ?>]" value="1" /> | ||
| 241 | <input type="checkbox" name="<?php echo $dom; ?>" id="<?php echo $dom; ?>" value="1" <?php echo $checked . $disabled; ?> /> | ||
| 242 | <label for="<?php echo $dom; ?>"><?php echo $group->getName(); ?></label> | ||
| 243 | </li> | ||
| 244 | <?php endforeach; ?> | ||
| 245 | </ul> | ||
| 246 | </div> | ||
| 235 | 247 | ||
| 236 | 248 | ||
| 237 | <div class="validation-errors" style="display:none;"><div class="error-wrap"><h6>OOPS...</h6><ul></ul></div></div> | 249 | <div class="validation-errors" style="display:none;"><div class="error-wrap"><h6>OOPS...</h6><ul></ul></div></div> | ... | ... |
-
Please register or sign in to post a comment