Skip to content

Commit 1fc3885

Browse files
committed
More User::isAdmin()
1 parent 07fd659 commit 1fc3885

File tree

10 files changed

+18
-18
lines changed

10 files changed

+18
-18
lines changed

featherbb/Controller/Admin/Users.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ public function display($req, $res, $args)
9292
$paging_links = '<span class="pages-label">' . __('Pages') . ' </span>' . Url::paginate_old($num_pages, $p, '?find_user=&amp;'.implode('&amp;', $search['query_str']));
9393

9494
// Some helper variables for permissions
95-
$can_delete = $can_move = User::get()->g_id == ForumEnv::get('FEATHER_ADMIN');
96-
$can_ban = User::get()->g_id == ForumEnv::get('FEATHER_ADMIN') || (User::can('mod.is_mod') && User::can('mod.ban_users'));
95+
$can_delete = $can_move = User::isAdmin();
96+
$can_ban = User::isAdmin() || (User::can('mod.is_mod') && User::can('mod.ban_users'));
9797
$can_action = ($can_delete || $can_ban || $can_move) && $num_users > 0;
9898
View::addAsset('js', 'style/imports/common.js', array('type' => 'text/javascript'));
9999

featherbb/Controller/Forum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function display($req, $res, $args)
3636

3737
// Sort out who the moderators are and if we are currently a moderator (or an admin)
3838
$mods_array = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array();
39-
$is_admmod = (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN') || (User::can('mod.is_mod') && array_key_exists(User::get()->username, $mods_array))) ? true : false;
39+
$is_admmod = (User::isAdmin() || (User::can('mod.is_mod') && array_key_exists(User::get()->username, $mods_array))) ? true : false;
4040

4141
$sort_by = $this->model->sort_forum_by($cur_forum['sort_by']);
4242

featherbb/Controller/Post.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function newpost($req, $res, $args)
7171

7272
// Sort out who the moderators are and if we are currently a moderator (or an admin)
7373
$mods_array = ($cur_posting['moderators'] != '') ? unserialize($cur_posting['moderators']) : array();
74-
$is_admmod = (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN') || (User::can('mod.is_mod') && array_key_exists(User::get()->username, $mods_array))) ? true : false;
74+
$is_admmod = (User::isAdmin() || (User::can('mod.is_mod') && array_key_exists(User::get()->username, $mods_array))) ? true : false;
7575

7676
// Do we have permission to post?
7777
if ((($args['tid'] && (($cur_posting['post_replies'] == '' && !User::can('topic.reply')) || $cur_posting['post_replies'] == '0')) ||
@@ -208,7 +208,7 @@ public function delete($req, $res, $args)
208208

209209
// Sort out who the moderators are and if we are currently a moderator (or an admin)
210210
$mods_array = ($cur_post['moderators'] != '') ? unserialize($cur_post['moderators']) : array();
211-
$is_admmod = (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN') || (User::can('mod.is_mod') && array_key_exists(User::get()->username, $mods_array))) ? true : false;
211+
$is_admmod = (User::isAdmin() || (User::can('mod.is_mod') && array_key_exists(User::get()->username, $mods_array))) ? true : false;
212212

213213
$is_topic_post = ($args['id'] == $cur_post['first_post_id']) ? true : false;
214214

@@ -249,7 +249,7 @@ public function editpost($req, $res, $args)
249249

250250
// Sort out who the moderators are and if we are currently a moderator (or an admin)
251251
$mods_array = ($cur_post['moderators'] != '') ? unserialize($cur_post['moderators']) : array();
252-
$is_admmod = (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN') || (User::can('mod.is_mod') && array_key_exists(User::get()->username, $mods_array))) ? true : false;
252+
$is_admmod = (User::isAdmin() || (User::can('mod.is_mod') && array_key_exists(User::get()->username, $mods_array))) ? true : false;
253253

254254
$can_edit_subject = $args['id'] == $cur_post['first_post_id'];
255255

featherbb/Controller/Topic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function display($req, $res, $args)
4949

5050
// Sort out who the moderators are and if we are currently a moderator (or an admin)
5151
$mods_array = ($cur_topic['moderators'] != '') ? unserialize($cur_topic['moderators']) : array();
52-
$is_admmod = (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN') || (User::can('mod.is_mod') && array_key_exists(User::get()->username, $mods_array))) ? true : false;
52+
$is_admmod = (User::isAdmin() || (User::can('mod.is_mod') && array_key_exists(User::get()->username, $mods_array))) ? true : false;
5353

5454
// Can we or can we not post replies?
5555
$post_link = $this->model->get_post_link($args['id'], $cur_topic['closed'], $cur_topic['post_replies'], $is_admmod);

featherbb/Model/Profile.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ public function update_profile($id, $info, $section)
713713
$form['admin_note'] = Utils::trim(Input::post('admin_note'));
714714

715715
// Are we allowed to change usernames?
716-
if (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN') || (User::can('mod.is_mod') && User::can('mod.rename_users'))) {
716+
if (User::isAdmin() || (User::can('mod.is_mod') && User::can('mod.rename_users'))) {
717717
$form['username'] = Utils::trim(Input::post('req_username'));
718718

719719
if ($form['username'] != $info['old_username']) {
@@ -728,7 +728,7 @@ public function update_profile($id, $info, $section)
728728
}
729729

730730
// We only allow administrators to update the post count
731-
if (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN')) {
731+
if (User::isAdmin()) {
732732
$form['num_posts'] = intval(Input::post('num_posts'));
733733
}
734734
}
@@ -771,7 +771,7 @@ public function update_profile($id, $info, $section)
771771
$form['url'] = '';
772772
}
773773

774-
if (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN')) {
774+
if (User::isAdmin()) {
775775
$form['title'] = Utils::trim(Input::post('title'));
776776
} elseif (User::can('user.set_title')) {
777777
$form['title'] = Utils::trim(Input::post('title'));
@@ -1114,7 +1114,7 @@ public function edit_essentials($id, $user)
11141114
$user_disp = Container::get('hooks')->fire('model.profile.edit_essentials_start', $user_disp, $id, $user);
11151115

11161116
if (User::isAdminMod()) {
1117-
if (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN') || User::can('mod.rename_users')) {
1117+
if (User::isAdmin() || User::can('mod.rename_users')) {
11181118
$user_disp['username_field'] = '<label class="required"><strong>'.__('Username').' <span>'.__('Required').'</span></strong><br /><input type="text" name="req_username" value="'.Utils::escape($user['username']).'" size="25" maxlength="25" required /><br /></label>'."\n";
11191119
} else {
11201120
$user_disp['username_field'] = '<p>'.sprintf(__('Username info'), Utils::escape($user['username'])).'</p>'."\n";
@@ -1134,13 +1134,13 @@ public function edit_essentials($id, $user)
11341134
$user_disp['posts_field'] = '';
11351135
$posts_actions = array();
11361136

1137-
if (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN')) {
1137+
if (User::isAdmin()) {
11381138
$user_disp['posts_field'] .= '<label>'.__('Posts').'<br /><input type="text" name="num_posts" value="'.$user['num_posts'].'" size="8" maxlength="8" /><br /></label>';
11391139
} elseif (ForumSettings::get('o_show_post_count') == '1' || User::isAdminMod()) {
11401140
$posts_actions[] = sprintf(__('Posts info'), Utils::forum_number_format($user['num_posts']));
11411141
}
11421142

1143-
if (User::can('search.topics') || User::get()->g_id == ForumEnv::get('FEATHER_ADMIN')) {
1143+
if (User::can('search.topics') || User::isAdmin()) {
11441144
$posts_actions[] = '<a href="'.Router::pathFor('search').'?action=show_user_topics&amp;user_id='.$id.'">'.__('Show topics').'</a>';
11451145
$posts_actions[] = '<a href="'.Router::pathFor('search').'?action=show_user_posts&amp;user_id='.$id.'">'.__('Show posts').'</a>';
11461146

featherbb/Model/Topic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ public function print_posts($topic_id, $start_from, $cur_topic, $is_admmod)
968968
}
969969
} else {
970970
$cur_post['post_actions'][] = '<li class="postreport"><span><a href="'.Router::pathFor('report', ['id' => $cur_post['id']]).'">'.__('Report').'</a></span></li>';
971-
if (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN') || !in_array($cur_post['poster_id'], $admin_ids)) {
971+
if (User::isAdmin() || !in_array($cur_post['poster_id'], $admin_ids)) {
972972
$cur_post['post_actions'][] = '<li class="postdelete"><span><a href="'.Router::pathFor('deletePost', ['id' => $cur_post['id']]).'">'.__('Delete').'</a></span></li>';
973973
$cur_post['post_actions'][] = '<li class="postedit"><span><a href="'.Router::pathFor('editPost', ['id' => $cur_post['id']]).'">'.__('Edit').'</a></span></li>';
974974
}

featherbb/View/admin/menu.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</div>
3333
</div>
3434
<?php
35-
if (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN')):
35+
if (User::isAdmin()):
3636
?>
3737
<h2 class="block2"><span><?php _e('Admin menu') ?></span></h2>
3838
<div class="box">

featherbb/View/admin/statistics.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<dd>
2727
<?php printf(__('Server load data')."\n", $server_load, $num_online) ?>
2828
</dd>
29-
<?php if (User::get()->g_id == ForumEnv::get('FEATHER_ADMIN')): ?> <dt><?php _e('Environment label') ?></dt>
29+
<?php if (User::isAdmin()): ?> <dt><?php _e('Environment label') ?></dt>
3030
<dd>
3131
<?php printf(__('Environment data OS'), PHP_OS) ?><br />
3232
<?php printf(__('Environment data version'), phpversion(), '<a href="'.Router::pathFor('phpInfo').'">'.__('Show info').'</a>') ?><br />

featherbb/View/profile/section_essentials.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<div class="infldset">
2828
<input type="hidden" name="form_sent" value="1" />
2929
<?= $user_disp['username_field'] ?>
30-
<?php if (User::get()->id == $id || User::get()->g_id == ForumEnv::get('FEATHER_ADMIN') || (User::can('mod.is_mod') && User::can('mod.change_passwords'))): ?>
30+
<?php if (User::get()->id == $id || User::isAdmin() || (User::can('mod.is_mod') && User::can('mod.change_passwords'))): ?>
3131
<p class="actions"><span><a href="<?= Router::pathFor('profileAction', ['id' => $id, 'action' => 'change_pass']) ?>"><?php _e('Change pass') ?></a></span></p>
3232
<?php endif; ?>
3333
</div>

featherbb/View/profile/section_personal.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<label><?php _e('Realname') ?><br /><input type="text" name="form_realname" value="<?= Utils::escape($user['realname']) ?>" size="40" maxlength="40" /><br /></label>
3232
<?php if (isset($title_field)): ?> <?= $title_field ?>
3333
<?php endif; ?> <label><?php _e('Location') ?><br /><input type="text" name="form_location" value="<?= Utils::escape($user['location']) ?>" size="30" maxlength="30" /><br /></label>
34-
<?php if (User::can('post.links') || User::get()->g_id == ForumEnv::get('FEATHER_ADMIN')) : ?> <label><?php _e('Website') ?><br /><input type="text" name="form_url" value="<?= Utils::escape($user['url']) ?>" size="50" maxlength="80" /><br /></label>
34+
<?php if (User::can('post.links') || User::isAdmin()) : ?> <label><?php _e('Website') ?><br /><input type="text" name="form_url" value="<?= Utils::escape($user['url']) ?>" size="50" maxlength="80" /><br /></label>
3535
<?php endif; ?>
3636
<label><?php _e('API token') ?><br /><input type="text" name="api" readonly="readonly" value="<?= Api::getToken(User::get()) ?>" size="60" maxlength="60" /><br /></label>
3737
</div>

0 commit comments

Comments
 (0)