CommunityID/modules/users/controllers/UserslistController.php

70 lines
2.4 KiB
PHP
Raw Normal View History

2019-07-17 20:08:50 +00:00
<?
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
2019-07-17 20:16:19 +00:00
class Users_UserslistController extends CommunityID_Controller_Action
2019-07-17 20:08:50 +00:00
{
public function indexAction()
{
$this->_helper->viewRenderer->setNeverRender(true);
2019-07-17 20:16:19 +00:00
$users = new Users_Model_Users();
2019-07-17 20:08:50 +00:00
switch($this->_getParam('filter')) {
case 'confirmed':
2019-07-17 20:16:19 +00:00
$where = "accepted_eula=1 AND role != '".Users_Model_User::ROLE_ADMIN."'";
2019-07-17 20:08:50 +00:00
break;
case 'unconfirmed':
2019-07-17 20:16:19 +00:00
$where = "accepted_eula=0 AND role != '".Users_Model_User::ROLE_ADMIN."'";
2019-07-17 20:08:50 +00:00
break;
default:
$where = false;
break;
}
$usersRows = $users->getUsers(
$this->_getParam('startIndex'),
$this->_getParam('results'),
$this->_getParam('sort', 'registration'),
2019-07-17 20:16:19 +00:00
$this->_getParam('dir', Users_Model_Users::DIR_DESC),
$where,
trim($this->_getParam('search')));
2019-07-17 20:08:50 +00:00
$jsonObj = new StdClass();
$jsonObj->recordsReturned = count($usersRows);
2019-07-17 20:16:19 +00:00
$jsonObj->totalRecords = $users->getNumUsers($where, trim($this->_getParam('search')));
$jsonObj->totalUsers = $users->getNumUsers();
2019-07-17 20:08:50 +00:00
$jsonObj->totalUnconfirmedUsers = $users->getNumUnconfirmedUsers();
2019-07-17 20:16:19 +00:00
$jsonObj->startIndex = $this->_getParam('startIndex');
2019-07-17 20:08:50 +00:00
$jsonObj->sort = $this->_getParam('sort');
$jsonObj->dir = $this->_getParam('dir');
$jsonObj->records = array();
foreach ($usersRows as $user) {
2019-07-17 20:16:19 +00:00
if ($user->role == Users_Model_User::ROLE_ADMIN) {
2019-07-17 20:08:50 +00:00
$status = $this->view->translate('admin');
} else if ($user->accepted_eula) {
$status = $this->view->translate('confirmed');
} else {
$status = $this->view->translate('unconfirmed');
}
$jsonObjUser = new StdClass();
$jsonObjUser->id = $user->id;
$jsonObjUser->name = $user->getFullName();
$jsonObjUser->registration = $user->registration_date;
$jsonObjUser->role = $user->role;
$jsonObjUser->status = $status;
$jsonObj->records[] = $jsonObjUser;
}
echo Zend_Json::encode($jsonObj);
}
}