// Paste PHP Code
Index: core/objects/deki_role.php
===================================================================
--- core/objects/deki_role.php (revision 24819)
+++ core/objects/deki_role.php (working copy)
@@ -115,17 +115,15 @@
if (!isset(self::$cache[$id]) || $fromName)
{
$Plug = DekiPlug::getInstance()->At('site', 'roles')->At(($fromName ? '=' : '') . $id);
-
$Result = $Plug->Get();
if (!$Result->isSuccess())
{
return null;
}
-
$result = $Result->getVal('body/permissions');
-
$Role = self::newFromArray($result);
- self::$cache[$Role->getId()] = $Role;
+ $id = $Role->getId();
+ self::$cache[$id] = $Role;
}
return self::$cache[$id];
Index: cp/configuration.php
===================================================================
--- cp/configuration.php (revision 24819)
+++ cp/configuration.php (working copy)
@@ -29,8 +29,6 @@
class SiteConfig extends DekiControlPanel
{
- const CLOUD_CONFIG_KEY = 'site/limited-admin-permissions';
-
// needed to determine the template folder
protected $name = 'configuration';
@@ -73,7 +71,7 @@
$this->View->set('form.input.atdspellchecker', DekiForm::singleInput('checkbox', 'atdspellchecker', '1', array('checked' => wfGetConfig('ui/editor/atd-enabled', ATD_DEFAULT_STATUS) === true), $this->View->msg('Settings.basic.form.atdspellchecker')));
// hide options for cloud
- $this->View->set('form.hideOptions', wfGetConfig(self::CLOUD_CONFIG_KEY, false));
+ $this->View->set('form.hideOptions', $this->isRunningCloud);
$this->View->output();
}
Index: cp/includes/deki_control_panel.php
===================================================================
--- cp/includes/deki_control_panel.php (revision 24819)
+++ cp/includes/deki_control_panel.php (working copy)
@@ -25,6 +25,7 @@
class DekiControlPanel extends DekiController
{
+ const CLOUD_CONFIG_KEY = 'site/limited-admin-permissions';
const HOOK_INITIALIZE_ACTION = 'ControlPanel:InitializeAction';
/**
@@ -32,6 +33,12 @@
* @var bool
*/
protected $canManageSeats = false;
+
+ /**
+ * True if instance is running in the cloud. Convenience.
+ * @var bool
+ */
+ protected $isRunningCloud = false;
protected function initializeObjects()
{
@@ -44,6 +51,7 @@
$License = DekiLicense::getCurrent();
$this->canManageSeats = $License->hasCapabilitySeats();
+ $this->isRunningCloud = wfGetConfig(self::CLOUD_CONFIG_KEY, false);
}
protected function initialize()
Index: cp/templates/user_management/add.php
===================================================================
--- cp/templates/user_management/add.php (revision 24819)
+++ cp/templates/user_management/add.php (working copy)
@@ -26,10 +26,7 @@
<div class="password-instructions"><?php echo $this->msg('Users.form.password.instructions'); ?></div>
</div>
- <div class="field">
- <?php echo $this->msg('Users.form.role'); ?><br/>
- <?php $this->html('form.role-select'); ?>
- </div>
+ <?php $this->html('form.role-select-section'); ?>
<?php $this->html('form.auth-section'); ?>
Index: cp/templates/user_management/add_multiple.php
===================================================================
--- cp/templates/user_management/add_multiple.php (revision 24819)
+++ cp/templates/user_management/add_multiple.php (working copy)
@@ -8,10 +8,8 @@
<div class="field">
<?php echo DekiForm::singleInput('textarea', 'user_csv', $this->get('add-form.user_csv'), array('class' => 'resizable')); ?>
</div>
- <div class="field">
- <?php echo $this->msg('Users.form.role'); ?><br/>
- <?php $this->html('form.role-select'); ?>
- </div>
+
+ <?php $this->html('form.role-select-section'); ?>
<?php $this->html('form.auth-section'); ?>
Index: cp/templates/user_management/edit.php
===================================================================
--- cp/templates/user_management/edit.php (revision 24819)
+++ cp/templates/user_management/edit.php (working copy)
@@ -1,4 +1,5 @@
<?php
+/* @var $this DekiView */
$this->includeCss('users.css');
$this->includeJavaScript('externalauth.js');
$this->set('template.subtitle', $this->msg('Users.edit.title'));
@@ -35,48 +36,8 @@
<div class="password-instructions"><?php echo $this->msg('Users.form.password.instructions'); ?></div>
</div>
- <div class="field status">
- <?php if ($this->has('form.options.seat-status')) : ?>
+ <?php $this->html('form.role-select-section'); ?>
- <span class="select">
- <?php echo $this->msg('Users.form.seat-status'); ?>
- <?php if ($this->get('user.isOwner')) : ?>
- <?php echo $this->msg('Users.form.seat-status.owner'); ?>
- <?php endif; ?>
- </span><br/>
- <?php
- echo DekiForm::multipleInput(
- 'radio',
- 'seat_status',
- $this->get('form.options.seat-status'),
- $this->get('user.isSeated'),
- array('disabled' => $this->get('user.isOwner'))
- );
- ?>
- <?php $this->html('form.role-select'); ?>
- <script type="text/javascript">
- $(function() {
- var $roles = $('#select-role_id');
- var $seated = $('#radio-seat_status-seated');
- if (!$seated.is(':checked')) {
- $roles.attr('disabled', 'disabled');
- }
- $seated.click(function() {
- // enable roles
- $roles.removeAttr('disabled');
- });
- Deki.$('#radio-seat_status-unseated').click(function() {
- // disable roles
- $roles.attr('disabled', 'disabled');
- });
- });
- </script>
- <?php else : ?>
- <?php echo $this->msg('Users.form.role'); ?><br/>
- <?php $this->html('form.role-select'); ?>
- <?php endif; ?>
- </div>
-
<div class="field">
<?php echo $this->msg('Users.form.status'); ?><br/>
<?php
@@ -104,5 +65,5 @@
<div class="submit">
<?php echo DekiForm::singleInput('button', 'submit', 'submit', array(), $this->msg('Users.edit.button')); ?>
<span class="or"><?php echo $this->msgRaw('Users.form.cancel', $this->get('edit-form.back'));?></span>
- </div>
-</form>
\ No newline at end of file
+ </div>
+</form>
Index: cp/user_management.php
===================================================================
--- cp/user_management.php (revision 24819)
+++ cp/user_management.php (working copy)
@@ -482,115 +482,11 @@
public function add()
{
- if ($this->Request->isPost())
+ if ($this->Request->isPost() && $this->POST_add())
{
- do
- {
- // attempt to create a new user with the specified information
- $username = $this->Request->getVal('username');
- $fullname = $this->Request->getVal('fullname');
- $email = $this->Request->getVal('email');
- // TODO: consolidate the field validation for edit, add, add_multiple
- $password = $this->Request->getVal('password');
- $passwordVerify = $this->Request->getVal('password_verify');
- if (!empty($password) && ($password != $passwordVerify))
- {
- DekiMessage::error($this->View->msg('Users.error.passwords'));
- break;
- }
- if (!empty($password) && strlen($password) < 4)
- {
- DekiMessage::error($this->View->msg('Users.error.passwords-length'));
- break;
- }
-
- // create the user object
- $User = new DekiUser(null, $username, $fullname);
-
- $authType = $this->Request->getVal('auth_type', 'local');
- $authUsername = $this->Request->getVal('external_auth_username');
- $authPassword = $this->Request->getVal('external_auth_password');
-
- // set the authentication
- if ($authType == 'external')
- {
- // external authentication
- $authId = $this->Request->getVal('external_auth_id');
- $User->setAuthService($authId);
- }
- else
- {
- // local authentication
- $User->setAuthService(DekiAuthService::INTERNAL_AUTH_ID);
- }
-
- // validate the email after setting the auth service
- if (!$User->setEmail($email))
- {
- DekiMessage::error($this->View->msg('Users.error.email', $email));
- break;
- }
-
- // set the role
- $roleId = $this->Request->getInt('role_id', $User->getRole()->getId());
- $Role = DekiRole::newFromId($roleId);
- if ($Role == null)
- {
- // something went wrong while retrieving the role
- DekiMessage::error($this->View->msg('Users.error.role'));
- break;
- }
- else
- {
- $User->setRole($Role);
- }
-
- // check for an empty password
- if (empty($password))
- {
- $password = wfRandomStr();
- }
- else
- {
- // validate passwords for internal users
- if ($User->isInternal())
- {
-
- }
- }
-
- // create the new user
- $Result = $User->create($authUsername, $authPassword, $password);
- if ($Result->getStatus() == 409)
- {
- DekiMessage::error($this->View->msg('Users.error.exists', $username));
- break;
- }
- elseif (!$Result->handleResponse())
- {
- DekiMessage::error($this->View->msg('Users.error.nouser', $Result->getError()));
- break;
- }
-
- // notify the user of their new account
- $this->sendUserWelcomeEmail($User, $password);
- DekiMessage::success($this->View->msg('Users.success.user', $User->getName()));
-
- // add the user to the selected groups
- $groups = $this->Request->getVal('group_id', array());
- if (!empty($groups))
- {
- $User->updateGroups($groups);
- DekiMessage::success($this->View->msg('Users.success.usergroup', $User->getName()));
- }
-
- // everything checks out, redirect
- $this->Request->redirect($this->getUrl('add'));
- return;
- } while (false);
+ return;
}
-
// init autocomplete & template search fields
$this->setupTemplateSearch();
// user add form
@@ -599,7 +495,7 @@
$this->View->set('add-form.back', $this->getUrl('listing', array('page'), true));
// setup the role selection
- $this->View->set('form.role-select', $this->getRoleSelect());
+ $this->View->set('form.role-select-section', $this->renderAction('role_select_section'));
// setup external auth selections
$this->View->set('form.auth-section', $this->renderAction('auth_form_section'));
@@ -608,155 +504,134 @@
$this->View->set('form.group-boxes', $this->getGroupBoxes());
$this->View->set('form.group-boxes.count', DekiGroup::getSiteCount());
-
$this->View->output();
}
-
- public function add_multiple()
+
+ /**
+ * Add user post helper
+ * @return bool
+ */
+ protected function POST_add()
{
- if ($this->Request->isPost())
+ // attempt to create a new user with the specified information
+ $username = $this->Request->getVal('username');
+ $fullname = $this->Request->getVal('fullname');
+ $email = $this->Request->getVal('email');
+ // TODO: consolidate the field validation for edit, add, add_multiple
+ $password = $this->Request->getVal('password');
+ $passwordVerify = $this->Request->getVal('password_verify');
+ if (!empty($password) && ($password != $passwordVerify))
{
- do
- {
- $authType = $this->Request->getVal('auth_type', 'local');
- $authId = $this->Request->getVal('external_auth_id');
- $authUsername = $this->Request->getVal('external_auth_username');
- $authPassword = $this->Request->getVal('external_auth_password');
- $groups = $this->Request->getArray('group_id');
+ DekiMessage::error($this->View->msg('Users.error.passwords'));
+ return false;
+ }
+ if (!empty($password) && strlen($password) < 4)
+ {
+ DekiMessage::error($this->View->msg('Users.error.passwords-length'));
+ return false;
+ }
+
+ // create the user object
+ $User = new DekiUser(null, $username, $fullname);
- // set the authentication
- if ($authType == 'local')
- {
- // local authentication
- $authId = DekiAuthService::INTERNAL_AUTH_ID;
- }
+ $authType = $this->Request->getVal('auth_type', 'local');
+ $authUsername = $this->Request->getVal('external_auth_username');
+ $authPassword = $this->Request->getVal('external_auth_password');
- // set the role
- $roleId = $this->Request->getInt('role_id', 0);
- $Role = DekiRole::newFromId($roleId);
- if ($Role == null)
- {
- // something went wrong while retrieving the role
- DekiMessage::error($this->View->msg('Users.error.role'));
- break;
- }
-
- // attempt to create the users
- $userErrors = array();
- $userSuccesses = array();
+ // set the authentication
+ if ($authType == 'external')
+ {
+ // external authentication
+ $authId = $this->Request->getVal('external_auth_id');
+ $User->setAuthService($authId);
+ }
+ else
+ {
+ // local authentication
+ $User->setAuthService(DekiAuthService::INTERNAL_AUTH_ID);
+ }
- $userList = $this->Request->getVal('user_csv');
- $lines = explode("\n", $userList);
- foreach ($lines as $line)
- {
- @list($username, $email) = explode(',', $line, 2);
- $username = trim($username);
- $email = trim($email);
+ // validate the email after setting the auth service
+ if (!$User->setEmail($email))
+ {
+ DekiMessage::error($this->View->msg('Users.error.email', $email));
+ return false;
+ }
- // create the user object
- $User = new DekiUser(null, $username, $username);
+ // set the role
+ $roleId = $this->Request->getInt('role_id', $User->getRole()->getId());
+ $Role = DekiRole::newFromId($roleId);
+ if ($Role == null)
+ {
+ // something went wrong while retrieving the role
+ DekiMessage::error($this->View->msg('Users.error.role'));
+ return false;
+ }
+ else
+ {
+ $User->setRole($Role);
+ }
- // validate the email
- if (!$User->setEmail($email))
- {
- // could not create this user
- $userErrors[] = array(
- 'name' => $username,
- 'email' => $email,
- 'error' => $this->View->msg('Users.error.email', $email)
- );
- continue;
- }
+ // check for an empty password
+ if (empty($password))
+ {
+ $password = wfRandomStr();
+ }
+ else
+ {
+ if ($User->isInternal())
+ {
+ // TODO: validate passwords for internal users?
+ }
+ }
+
+ // create the new user
+ $Result = $User->create($authUsername, $authPassword, $password);
+ if ($Result->getStatus() == 409)
+ {
+ DekiMessage::error($this->View->msg('Users.error.exists', $username));
+ return false;
+ }
+ elseif (!$Result->handleResponse())
+ {
+ DekiMessage::error($this->View->msg('Users.error.nouser', $Result->getError()));
+ return false;
+ }
- $User->setRole($Role);
- $User->setAuthService($authId);
-
- // create the new user
- $Result = $User->create($authUsername, $authPassword);
- if (!$Result->isSuccess())
- {
- // could not create this user
- $userErrors[] = array(
- 'name' => $username,
- 'email' => $email,
- 'error' => htmlspecialchars($Result->getError())
- );
- }
- else
- {
- $userSuccesses[] = array(
- 'name' => $username,
- 'email' => $email,
- 'id' => $User->getId()
- );
-
- // user was created successfully
- if ($User->isInternal())
- {
- // set the user's temporary password
- $newPassword = wfRandomStr();
- $Result = $User->changePassword($newPassword, null, true);
-
- if ($Result->isSuccess())
- {
- $this->sendUserWelcomeEmail($User, $newPassword);
- }
- }
- else
- {
- // external users cannot have their passwords reset
- $this->sendUserWelcomeEmail($User);
- }
- }
- }
-
- $successes = count($userSuccesses);
- if ($successes > 0)
- {
- $userIds = array();
- foreach ($userSuccesses as $user)
- {
- $userIds[] = $user['id'];
- }
+ // notify the user of their new account
+ $this->sendUserWelcomeEmail($User, $password);
+ DekiMessage::success($this->View->msg('Users.success.user', $User->getName()));
- foreach ($groups as $groupId)
- {
- $Group = DekiGroup::newFromId($groupId);
- if (!$Group->addUsers($userIds))
- {
- DekiMessage::error($this->View->msg('Users.error.group', $Group->getName()));
- }
- }
- DekiMessage::success($this->View->msg('Users.success.multiple', $successes));
- }
+ // add the user to the selected groups
+ $groups = $this->Request->getVal('group_id', array());
+ if (!empty($groups))
+ {
+ $User->updateGroups($groups);
+ DekiMessage::success($this->View->msg('Users.success.usergroup', $User->getName()));
+ }
+
+ // update seat status
+ if (!$this->updateUserSeatStatus($User))
+ {
+ // redirect to the edit user page
+ $this->Request->redirect($this->getUrl('edit/'.$User->getId()));
+ }
+ else
+ {
+ // everything checks out, redirect
+ $this->Request->redirect($this->getUrl('add'));
+ }
+
+ return true;
+ }
- $errors = count($userErrors);
- if ($errors > 0)
- {
- DekiMessage::error($this->View->msg('Users.error.multiple', $errors));
-
- // update the post field for the form, only show users with errors
- foreach ($userErrors as $user)
- {
- // report an error message for each user
- DekiMessage::error(
- $this->View->msgRaw('Users.error.multiple.user', htmlspecialchars($user['name']), $user['error'])
- );
- $userList = $user['name'] . ',' . $user['email'] . "\n";
- }
- $_POST['user_csv'] = $userList;
-
- DekiMessage::error($this->View->msg('Users.error.multiple.end'));
- break;
- }
-
- // everything checks out, redirect
- $this->Request->redirect($this->getUrl('add_multiple'));
- return;
- } while (false);
+ public function add_multiple()
+ {
+ if ($this->Request->isPost() && $this->POST_add_multiple())
+ {
+ return;
}
-
// init autocomplete & template search fields
$this->setupTemplateSearch();
// user add form
@@ -767,8 +642,11 @@
$this->View->set('add-form.user_csv', $this->Request->getVal('user_csv'));
// setup the role selection
- $this->View->set('form.role-select', $this->getRoleSelect($this->Request->getVal('role_id', null)));
-
+ if (!$this->canManageSeats)
+ {
+ $this->View->set('form.role-select-section', $this->renderAction('role_select_section'));
+ }
+
// setup external auth selections
$this->View->set('form.auth-section', $this->renderAction('auth_form_section'));
@@ -776,9 +654,160 @@
$this->View->set('form.group-boxes', $this->getGroupBoxes());
$this->View->set('form.group-boxes.count', DekiGroup::getSiteCount());
- $this->View->output();
+ $this->View->output();
}
+
+ /**
+ * Post helper for adding multiple users
+ * @return bool
+ */
+ protected function POST_add_multiple()
+ {
+ global $wgNewAccountRole;
+
+ // grab values from request
+ $authType = $this->Request->getVal('auth_type', 'local');
+ $authId = $this->Request->getVal('external_auth_id');
+ $authUsername = $this->Request->getVal('external_auth_username');
+ $authPassword = $this->Request->getVal('external_auth_password');
+ $groups = $this->Request->getArray('group_id');
+ // set the authentication
+ if ($authType == 'local')
+ {
+ // local authentication
+ $authId = DekiAuthService::INTERNAL_AUTH_ID;
+ }
+
+ // set the role
+ $Role = DekiRole::newFromText($wgNewAccountRole);
+ fb($Role);
+ if (!$this->canManageSeats)
+ {
+ $roleId = $this->Request->getInt('role_id', 0);
+ $Role = DekiRole::newFromId($roleId);
+ }
+ if ($Role == null)
+ {
+ // something went wrong while retrieving the role
+ DekiMessage::error($this->View->msg('Users.error.role'));
+ return false;
+ }
+
+ // attempt to create the users
+ $userErrors = array();
+ $userSuccesses = array();
+
+ $userList = $this->Request->getVal('user_csv');
+ $lines = explode("\n", $userList);
+ foreach ($lines as $line)
+ {
+ @list($username, $email) = explode(',', $line, 2);
+ $username = trim($username);
+ $email = trim($email);
+
+ // create the user object
+ $User = new DekiUser(null, $username, $username);
+
+ // validate the email
+ if (!$User->setEmail($email))
+ {
+ // could not create this user
+ $userErrors[] = array(
+ 'name' => $username,
+ 'email' => $email,
+ 'error' => $this->View->msg('Users.error.email', $email)
+ );
+ continue;
+ }
+
+ $User->setRole($Role);
+ $User->setAuthService($authId);
+
+ // create the new user
+ $Result = $User->create($authUsername, $authPassword);
+ if (!$Result->isSuccess())
+ {
+ // could not create this user
+ $userErrors[] = array(
+ 'name' => $username,
+ 'email' => $email,
+ 'error' => htmlspecialchars($Result->getError())
+ );
+ }
+ else
+ {
+ $userSuccesses[] = array(
+ 'name' => $username,
+ 'email' => $email,
+ 'id' => $User->getId()
+ );
+
+ // user was created successfully
+ if ($User->isInternal())
+ {
+ // set the user's temporary password
+ $newPassword = wfRandomStr();
+ $Result = $User->changePassword($newPassword, null, true);
+
+ if ($Result->isSuccess())
+ {
+ $this->sendUserWelcomeEmail($User, $newPassword);
+ }
+ }
+ else
+ {
+ // external users cannot have their passwords reset
+ $this->sendUserWelcomeEmail($User);
+ }
+ }
+ }
+
+ $successes = count($userSuccesses);
+ if ($successes > 0)
+ {
+ $userIds = array();
+ foreach ($userSuccesses as $user)
+ {
+ $userIds[] = $user['id'];
+ }
+
+ foreach ($groups as $groupId)
+ {
+ $Group = DekiGroup::newFromId($groupId);
+ if (!$Group->addUsers($userIds))
+ {
+ DekiMessage::error($this->View->msg('Users.error.group', $Group->getName()));
+ }
+ }
+ DekiMessage::success($this->View->msg('Users.success.multiple', $successes));
+ }
+
+ $errors = count($userErrors);
+ if ($errors > 0)
+ {
+ DekiMessage::error($this->View->msg('Users.error.multiple', $errors));
+
+ // update the post field for the form, only show users with errors
+ foreach ($userErrors as $user)
+ {
+ // report an error message for each user
+ DekiMessage::error(
+ $this->View->msgRaw('Users.error.multiple.user', htmlspecialchars($user['name']), $user['error'])
+ );
+ $userList = $user['name'] . ',' . $user['email'] . "\n";
+ }
+ $_POST['user_csv'] = $userList;
+
+ DekiMessage::error($this->View->msg('Users.error.multiple.end'));
+ return false;
+ }
+
+ // everything checks out, redirect
+ $this->Request->redirect($this->getUrl('add_multiple'));
+ return true;
+ }
+
public function edit($id = null)
{
// need to find the user
@@ -809,18 +838,12 @@
$this->View->set('user.isInternal', $User->isInternal());
$this->View->set('user.isAnonymous', $User->isAnonymous());
$this->View->set('user.isDisabled', $User->isDisabled());
-
+
// setup the role selection
- $this->View->set('form.role-select', $this->getRoleSelect($this->Request->getVal('role_id', $User->getRole()->getId())));
- if ($this->canManageSeats)
- {
- $this->View->set('form.options.seat-status', array(
- DekiUser::SEAT_STATUS_UNSEATED => $this->View->msg('Users.form.seat-status.unseated'),
- DekiUser::SEAT_STATUS_SEATED => $this->View->msg('Users.form.seat-status.seated')
- ));
- $this->View->set('user.isSeated', $User->isSeated() ? DekiUser::SEAT_STATUS_SEATED : DekiUser::SEAT_STATUS_UNSEATED);
- $this->View->set('user.isOwner', $User->isSiteOwner());
- }
+ $params = array(
+ $User
+ );
+ $this->View->set('form.role-select-section', $this->renderAction('role_select_section', $params));
// setup external auth selections
$auth = array(
@@ -921,29 +944,8 @@
$User->setRole($Role);
}
- // update seat status if enabled and not site owner
- if ($this->canManageSeats && !$User->isSiteOwner())
- {
- $seatStatus = $this->Request->getVal('seat_status');
- $Result = DekiUser::updateSeatStatus($User, $seatStatus);
- if ($Result->is(409) && !$User->isSeated() && !$User->isAnonymous())
- {
- // check if the seat limit has been hit
- $limit = DekiLicense::getCurrent()->getSeatCount();
- $current = DekiLicense::getCurrent()->getSeatCount(true);
- if ($current+1 > $limit)
- {
- DekiMessage::error($this->View->msg('Users.error.seat.limit', $limit, $limit+1));
- return false;
- }
- }
-
- // general error bubbling
- if (!$Result->handleResponse())
- {
- return false;
- }
- }
+ // update seat status
+ $this->updateUserSeatStatus($User);
$activeUser = $this->Request->getBool('status', true);
if ($activeUser)
@@ -986,6 +988,40 @@
}
/**
+ * Helper for setting a user's seat status. Reused by add, add_multiple, & edit
+ *
+ * @param DekiUser $User - user to update seat status for
+ * @return bool - false if the seat could not be updated
+ */
+ private function updateUserSeatStatus($User)
+ {
+ if ($this->canManageSeats && !$User->isSiteOwner())
+ {
+ $seatStatus = $this->Request->getVal('seat_status');
+ $Result = DekiUser::updateSeatStatus($User, $seatStatus);
+ if ($Result->is(409) && !$User->isSeated() && !$User->isAnonymous())
+ {
+ // check if the seat limit has been hit
+ $limit = DekiLicense::getCurrent()->getSeatCount();
+ $current = DekiLicense::getCurrent()->getSeatCount(true);
+ if ($current+1 > $limit)
+ {
+ DekiMessage::error($this->View->msg('Users.error.seat.limit', $limit, $limit+1));
+ return false;
+ }
+ }
+
+ // general error bubbling
+ if (!$Result->handleResponse())
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
* Sends the welcome email to a user with a password they can login with
* @param DekiUser $User - Welcome email recipient
* @param $newPassword - new password to be emailed. Ignored if user is external.
@@ -1065,6 +1101,32 @@
$this->View->output();
}
+
+ /**
+ * Call using renderAction() to render the role select for add & edit users
+ */
+ protected function role_select_section($User = null)
+ {
+ $roleId = !is_null($User) ? $User->getRole()->getId() : null;
+ $this->View->set('form.role-select', $this->getRoleSelect($this->Request->getVal('role_id', $roleId)));
+ if ($this->canManageSeats)
+ {
+ $this->View->set('form.options.seat-status', array(
+ DekiUser::SEAT_STATUS_UNSEATED => $this->View->msg('Users.form.seat-status.unseated'),
+ DekiUser::SEAT_STATUS_SEATED => $this->View->msg('Users.form.seat-status.seated')
+ ));
+
+ $this->View->set('form.seatStatus', DekiUser::SEAT_STATUS_UNSEATED);
+ if ($User)
+ {
+ $this->View->set('form.seatStatus', $User->isSeated() ? DekiUser::SEAT_STATUS_SEATED : DekiUser::SEAT_STATUS_UNSEATED);
+ $this->View->set('user.isOwner', $User->isSiteOwner());
+ }
+ }
+
+ // add stuffs
+ $this->View->output();
+ }
private function getGroupBoxes($User = null)
{
/* @var $this DekiView */
?>
<div class="field status">
<?php if (!$this->has('form.options.seat-status')) : ?>
<?php echo $this->msg('Users.form.role'); ?><br/>
<?php $this->html('form.role-select'); ?>
<?php else : ?>
<span class="select">
<?php echo $this->msg('Users.form.seat-status'); ?>
</span><br/>
<?php
echo DekiForm::multipleInput(
'radio',
'seat_status',
$this->get('form.options.seat-status'),
$this->get('form.seatStatus'),
array('disabled' => $this->get('user.isOwner'))
);
?>
<?php if ($this->get('user.isOwner')) : ?>
<?php echo $this->msg('Users.form.seat-status.owner'); ?>
<?php else : ?>
<?php $this->html('form.role-select'); ?>
<?php endif; ?>
<script type="text/javascript">
$(function() {
var $roles = $('#select-role_id');
var $seated = $('#radio-seat_status-seated');
if (!$seated.is(':checked')) {
$roles.attr('disabled', 'disabled');
}
$seated.click(function() {
// enable roles
$roles.removeAttr('disabled');
});
Deki.$('#radio-seat_status-unseated').click(function() {
// disable roles
$roles.attr('disabled', 'disabled');
});
});
</script>
<?php endif; ?>
</div>
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by