diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index 2fdb0088afed9bd537b1305aea7ea2a7918a8cb3..e84b4b6a6d816bbe7d0683a92a4db449053ace36 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -668,6 +668,9 @@ class DynamicFormEntry extends VerySimpleModel { 'null' => true, 'constraint' => array('form_id' => 'DynamicForm.id'), ), + 'answers' => array( + 'reverse' => 'DynamicFormEntryAnswer.entry' + ), ), ); diff --git a/include/class.user.php b/include/class.user.php index 87edb06ddf76f30c2dc4e11492e133cf80318324..a6f996002c6b8f60c5126040a2488ee225e92eea 100644 --- a/include/class.user.php +++ b/include/class.user.php @@ -82,6 +82,13 @@ class UserModel extends VerySimpleModel { 'null' => true, 'constraint' => array('default_email_id' => 'UserEmailModel.id') ), + 'cdata_entry' => array( + 'constraint' => array( + 'id' => 'DynamicFormEntry.object_id', + "'U'" => 'DynamicFormEntry.object_type', + ), + null => true, + ), ) ); @@ -726,9 +733,9 @@ class PersonsName { $r = explode(' ', $name); $size = count($r); - + //check if name is bad format (ex: J.Everybody), and fix them - if($size==1 && mb_strpos($r[0], '.') !== false) + if($size==1 && mb_strpos($r[0], '.') !== false) { $r = explode('.', $name); $size = count($r); @@ -836,6 +843,11 @@ class UserAccountModel extends VerySimpleModel { $this->save(); } + function unlock() { + $this->clearStatus(UserAccountStatus::LOCKED); + $this->save(); + } + function isLocked() { return $this->_status->isLocked(); } diff --git a/include/staff/user-view.inc.php b/include/staff/user-view.inc.php index 7bb706c898b86fbde3c5310323ac72af82cd140b..1111cbf0e33fb7edfb8cce6a09583198b77145e8 100644 --- a/include/staff/user-view.inc.php +++ b/include/staff/user-view.inc.php @@ -28,7 +28,7 @@ $org = $user->getOrganization(); <?php } else { ?> <a id="user-register" class="action-button pull-right user-action" - href="#users/<?php echo $user->getId(); ?>/register"><i class="icon-edit"></i> + href="#users/<?php echo $user->getId(); ?>/register"><i class="icon-star"></i> <?php echo __('Register'); ?></a> <?php } ?> diff --git a/include/staff/users.inc.php b/include/staff/users.inc.php index deae27b5ea5ff1a10597ff78139d3b0490988de5..be1739ec929d0ed40bb967bf752a3f878603a72d 100644 --- a/include/staff/users.inc.php +++ b/include/staff/users.inc.php @@ -90,12 +90,44 @@ $_SESSION['users_qs_'.$qhash] = $query; </table> </form> </div> - <div class="pull-right flush-right" style="padding-right:5px;"> - <b><a href="#users/add" class="Icon newstaff popup-dialog"><?php echo __('Add User'); ?></a></b> - | - <b><a href="#users/import" class="popup-dialog"><i class="icon-cloud-upload icon-large"></i> - <?php echo __('Import'); ?></a></b> + +<div class="pull-right"> + <a class="action-button popup-dialog" + href="#users/add"> + <i class="icon-plus-sign"></i> + <?php echo __('Add User'); ?> + </a> + <a class="action-button popup-dialog" + href="#users/import"> + <i class="icon-upload"></i> + <?php echo __('Import'); ?> + </a> + <span class="action-button" data-dropdown="#action-dropdown-more" + style="/*DELME*/ vertical-align:top; margin-bottom:0"> + <i class="icon-caret-down pull-right"></i> + <span ><i class="icon-cog"></i> <?php echo __('More');?></span> + </span> + <div id="action-dropdown-more" class="action-dropdown anchor-right"> + <ul> + <li><a class="users-action" href="#delete"> + <i class="icon-trash icon-fixed-width"></i> + <?php echo __('Delete'); ?></a></li> + <li><a class="users-action" href="#reset"> + <i class="icon-envelope icon-fixed-width"></i> + <?php echo __('Send Password Reset Email'); ?></a></li> + <li><a class="users-action" href="#register"> + <i class="icon-star icon-fixed-width"></i> + <?php echo __('Register'); ?></a></li> + <li><a class="users-action" href="#lock"> + <i class="icon-lock icon-fixed-width"></i> + <?php echo __('Lock'); ?></a></li> + <li><a class="users-action" href="#unlock"> + <i class="icon-unlock icon-fixed-width"></i> + <?php echo __('Unlock'); ?></a></li> + </ul> + </div> </div> + <div class="clear"></div> <?php $showing = $search ? __('Search Results').': ' : ''; @@ -105,14 +137,16 @@ if($res && ($num=db_num_rows($res))) else $showing .= __('No users found!'); ?> -<form action="users.php" method="POST" name="staff" > +<form id="users-list" action="users.php" method="POST" name="staff" > <?php csrf_token(); ?> <input type="hidden" name="do" value="mass_process" > <input type="hidden" id="action" name="a" value="" > + <input type="hidden" id="selected-count" name="count" value="" > <table class="list" border="0" cellspacing="1" cellpadding="0" width="940"> <caption><?php echo $showing; ?></caption> <thead> <tr> + <th nowrap width="12"> </th> <th width="350"><a <?php echo $name_sort; ?> href="users.php?<?php echo $qstr; ?>&sort=name"><?php echo __('Name'); ?></a></th> <th width="250"><a <?php echo $status_sort; ?> href="users.php?<?php @@ -145,6 +179,9 @@ else $sel=true; ?> <tr id="<?php echo $row['id']; ?>"> + <td nowrap> + <input type="checkbox" value="<?php echo $row['id']; ?>" class="mass nowarn"/> + </td> <td> <a class="userPreview" href="users.php?id=<?php echo $row['id']; ?>"><?php echo Format::htmlchars($name); ?></a> @@ -202,7 +239,26 @@ $(function() { }); return false; - }); + }); + $(document).on('click', 'a.users-action', function(e) { + e.preventDefault(); + var ids = [], + $form = $('form#users-list'); + $(':checkbox.mass:checked', $form).each(function() { + ids.push($(this).val()); + }); + if (ids.length && confirm(__('You sure?'))) { + $form.find('#action').val($(this).attr('href').substr(1)); + $.each(ids, function() { $form.append($('<input type="hidden" name="ids[]">').val(this)); }); + $form.find('#selected-count').val(ids.length); + $form.submit(); + } + else if (!ids.length) { + $.sysAlert(__('Oops'), + __('You need to select at least one item')); + } + return false; + }); }); </script> diff --git a/scp/users.php b/scp/users.php index ade2474137ff87dd793e9ebc01d9aad9dcd2a98c..f9915606d30f9265cf2ce607b761ca27c70de8dd 100644 --- a/scp/users.php +++ b/scp/users.php @@ -70,7 +70,61 @@ if ($_POST) { $errors['err'] = sprintf(__('You must select at least %s.'), __('one end user')); } else { - $errors['err'] = "Coming soon!"; + $users = User::objects()->filter( + array('id__in' => $_POST['ids']) + ); + $count = 0; + switch (strtolower($_POST['a'])) { + case 'lock': + foreach ($users as $U) + if (($acct = $U->getAccount()) && $acct->lock()) + $count++; + break; + + case 'unlock': + foreach ($users as $U) + if (($acct = $U->getAccount()) && $acct->unlock()) + $count++; + break; + + case 'delete': + foreach ($users as $U) + if ($U->delete()) + $count++; + break; + + case 'reset': + foreach ($users as $U) + if (($acct = $U->getAccount()) && $acct->sendResetEmail()) + $count++; + break; + + case 'register': + foreach ($users as $U) { + if (($acct = $U->getAccount()) && $acct->setConfirmationEmail()) + $count++; + elseif ($acct = UserAccount::register($U, + array('sendemail' => true), $errors + )) { + $count++; + } + } + break; + + default: + $errors['err']=__('Unknown action - get technical help.'); + } + if (!$errors['err'] && !$count) { + $errors['err'] = __('Unable to manage any of the selected end users'); + } + elseif ($_POST['count'] && $count != $_POST['count']) { + $warn = __('Not all selected items were updated'); + } + elseif ($count) { + $msg = __('Successfully managed selected end users'); + } + + } break; case 'import-users':