本文整理汇总了PHP中UserService::count_admin_members方法的典型用法代码示例。如果您正苦于以下问题:PHP UserService::count_admin_members方法的具体用法?PHP UserService::count_admin_members怎么用?PHP UserService::count_admin_members使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserService
的用法示例。
在下文中一共展示了UserService::count_admin_members方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(HTTPRequestCustom $request)
{
$lang = LangLoader::get('common');
$is_admin = AppContext::get_current_user()->check_level(User::ADMIN_LEVEL);
$number_admins = UserService::count_admin_members();
$suggestions = array();
try {
$result = PersistenceContext::get_querier()->select("SELECT user_id, display_name, level, groups FROM " . DB_TABLE_MEMBER . " WHERE display_name LIKE '" . str_replace('*', '%', $request->get_value('value', '')) . "%'");
while ($row = $result->fetch()) {
$user_group_color = User::get_group_color($row['groups'], $row['level']);
$suggestion = '';
if ($is_admin) {
$edit_link = new LinkHTMLElement(UserUrlBuilder::edit_profile($row['user_id']), '', array('title' => $lang['edit']), 'fa fa-edit');
if ($row['level'] != User::ADMIN_LEVEL || $row['level'] == User::ADMIN_LEVEL && $number_admins > 1) {
$delete_link = new LinkHTMLElement(AdminMembersUrlBuilder::delete($row['user_id']), '', array('title' => $lang['delete'], 'data-confirmation' => 'delete-element'), 'fa fa-delete');
} else {
$delete_link = new LinkHTMLElement('', '', array('title' => $lang['delete'], 'onclick' => 'return false;'), 'fa fa-delete icon-disabled');
}
$suggestion .= $edit_link->display() . ' ' . $delete_link->display() . ' ';
}
$profile_link = new LinkHTMLElement(UserUrlBuilder::profile($row['user_id'])->rel(), $row['display_name'], array('style' => !empty($user_group_color) ? 'color:' . $user_group_color : ''), UserService::get_level_class($row['level']));
$suggestion .= $profile_link->display();
$suggestions[] = $suggestion;
}
$result->dispose();
} catch (Exception $e) {
}
return new JSONResponse(array('suggestions' => $suggestions));
}
示例2: execute
public function execute(HTTPRequestCustom $request)
{
$user_id = $request->get_int('id', null);
$user = UserService::get_user($user_id);
if (!$user->is_admin() || $user->is_admin() && UserService::count_admin_members() > 1) {
try {
UserService::delete_by_id($user_id);
} catch (RowNotFoundException $ex) {
$error_controller = PHPBoostErrors::unexisting_element();
DispatchManager::redirect($error_controller);
}
AppContext::get_response()->redirect($request->get_url_referrer() ? $request->get_url_referrer() : AdminMembersUrlBuilder::management(), StringVars::replace_vars(LangLoader::get_message('user.message.success.delete', 'user-common'), array('name' => $user->get_display_name())));
} else {
$error_controller = PHPBoostErrors::unauthorized_action();
DispatchManager::redirect($error_controller);
}
}
示例3: build_table
private function build_table()
{
$number_admins = UserService::count_admin_members();
$table_model = new SQLHTMLTableModel(DB_TABLE_MEMBER, 'table', array(new HTMLTableColumn($this->lang['display_name'], 'display_name'), new HTMLTableColumn($this->lang['level'], 'level'), new HTMLTableColumn($this->lang['email']), new HTMLTableColumn($this->lang['registration_date'], 'registration_date'), new HTMLTableColumn($this->lang['last_connection'], 'last_connection_date'), new HTMLTableColumn($this->lang['approbation'], 'approved'), new HTMLTableColumn('')), new HTMLTableSortingRule('display_name', HTMLTableSortingRule::ASC));
$table = new HTMLTable($table_model);
$table_model->set_caption(LangLoader::get_message('members.members-management', 'admin-user-common'));
$results = array();
$result = $table_model->get_sql_results('m LEFT JOIN ' . DB_TABLE_INTERNAL_AUTHENTICATION . ' ia ON ia.user_id = m.user_id');
foreach ($result as $row) {
$user = new User();
$user->set_properties($row);
$edit_link = new LinkHTMLElement(UserUrlBuilder::edit_profile($user->get_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit');
if ($user->get_level() != User::ADMIN_LEVEL || $user->get_level() == User::ADMIN_LEVEL && $number_admins > 1) {
$delete_link = new LinkHTMLElement(AdminMembersUrlBuilder::delete($user->get_id()), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => 'delete-element'), 'fa fa-delete');
} else {
$delete_link = new LinkHTMLElement('', '', array('title' => LangLoader::get_message('delete', 'common'), 'onclick' => 'return false;'), 'fa fa-delete icon-disabled');
}
$user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
$results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement(UserUrlBuilder::profile($user->get_id()), $user->get_display_name(), !empty($user_group_color) ? array('style' => 'color: ' . $user_group_color) : array(), UserService::get_level_class($user->get_level()))), new HTMLTableRowCell(UserService::get_level_lang($user->get_level())), new HTMLTableRowCell(new LinkHTMLElement('mailto:' . $user->get_email(), $this->lang['email'], array(), 'basic-button smaller')), new HTMLTableRowCell(Date::to_format($row['registration_date'], Date::FORMAT_DAY_MONTH_YEAR)), new HTMLTableRowCell(!empty($row['last_connection_date']) ? Date::to_format($row['last_connection_date'], Date::FORMAT_DAY_MONTH_YEAR) : LangLoader::get_message('never', 'main')), new HTMLTableRowCell($row['approved'] ? LangLoader::get_message('yes', 'common') : LangLoader::get_message('no', 'common')), new HTMLTableRowCell($edit_link->display() . $delete_link->display())));
}
$table->set_rows($table_model->get_number_of_matching_rows(), $results);
$this->view->put_all(array('FORM' => $this->build_form()->display(), 'table' => $table->display()));
}