Exemple #1
0
 public function buildUser()
 {
     $options = [];
     $options['clearSelect'] = true;
     $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'username']);
     $models = \Rebond\Core\User\Data::loadAll($options);
     return Util\Form::buildDropdownList('userId' . $this->unique, $models, 'id', 'username', $this->getModel()->getUserId(), true);
 }
Exemple #2
0
 public function buildId()
 {
     $options = [];
     $options['clearSelect'] = true;
     $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'username']);
     $options['where'][] = 'status = 1';
     $models = \Rebond\Core\User\Data::loadAll($options);
     return Util\Form::buildDropdownList('id' . $this->unique, $models, 'id', 'username', $this->getModel()->getId(), $this->idValidator['primaryKey']);
 }
Exemple #3
0
 public function buildPublisher()
 {
     $options = [];
     $options['clearSelect'] = true;
     $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'title']);
     $models = \Rebond\Core\User\Data::loadAll($options);
     return Util\Form::buildDropdownList('publisherId' . $this->unique, $models, 'id', 'title', $this->getModel()->getPublisherId(), $this->publisherValidator['foreignKey']);
 }
Exemple #4
0
 public function listUser()
 {
     if (!$this->hasPrivilege('admin.user')) {
         return $this->noPrivilege('admin.user');
     }
     $json = [];
     $json['result'] = ResultType::ERROR;
     // check
     $hashParam = Converter::string('hash', 'post');
     $hash = explode('/', $hashParam);
     $status = isset($hash[0]) && $hash[0] != '' ? $hash[0] : 'active';
     $page = isset($hash[1]) && $hash[1] != '' ? (int) $hash[1] : 1;
     $options = [];
     if ($status == 'active') {
         $options['where'][] = 'user.status IN (0,1)';
     } else {
         $options['where'][] = 'user.status = 2';
     }
     $userCount = \Rebond\Core\User\Data::count($options);
     // get user settings
     $userSettings = \Rebond\Cms\UserSettings\Data::loadByUserId($this->signedUser->getId());
     $listCount = 10;
     if (isset($userSettings)) {
         $listCount = (int) $userSettings->getPagingValue();
     }
     if ($page < 1) {
         $page = 1;
     }
     if ($page > ceil($userCount / $listCount) && $userCount > 0) {
         $page = ceil($userCount / $listCount);
     }
     // add paging and order
     $options['limit'][] = ($page - 1) * $listCount . ', ' . $listCount;
     $options['order'][] = 'user.modified_date DESC';
     $users = \Rebond\Core\User\Data::loadAll($options);
     $tpl = new Template(Template::MODULE, ['core', 'user']);
     $tpl->set('items', $users);
     $tplFilter = new Template(Template::MODULE, ['core', 'user']);
     $tplFilter->set('current', $page);
     $tplFilter->set('maxByPage', $listCount);
     $tplFilter->set('count', $userCount);
     $tplFilter->set('status', $status);
     $tplFilter->set('url', '#!/' . $status . '/');
     $tplLayout = new Template(Template::SITE, ['admin']);
     $tplLayout->set('column1', $tplFilter->render('filter-full'));
     $tplLayout->set('column2', $tpl->render('listing'));
     $json['result'] = ResultType::SUCCESS;
     $json['message'] = Lang::lang('listUpdated') . ' (' . count($users) . ')';
     $json['html'] = $tplLayout->render('layout-2-row');
     return json_encode($json);
 }