*/
public function isSiteAdmin(): bool;
+ /**
+ * Check if current user is a moderator.
+ *
+ * @return bool true if user is a moderator
+ */
+ public function isModerator(): bool;
+
/**
* Returns User ID of the managed user in case it's a different identity
*
return User::isSiteAdmin($this->getLocalUserId());
}
+ /** {@inheritDoc} */
+ public function isModerator(): bool
+ {
+ return User::isModerator($this->getLocalUserId());
+ }
+
/** {@inheritDoc} */
public function setVisitorsContacts(string $my_url)
{
]);
}
+ /**
+ * Returns if the given uid is valid and a moderator
+ *
+ * @param int $uid
+ *
+ * @return bool
+ * @throws Exception
+ */
+ public static function isModerator(int $uid): bool
+ {
+ // @todo Replace with a moderator check in the future
+ return self::isSiteAdmin($uid);
+ }
+
/**
* Checks if a nickname is in the list of the forbidden nicknames
*
}
}
- if (!$this->app->isSiteAdmin()) {
- throw new HTTPException\ForbiddenException($this->t('You don\'t have access to administration pages.'));
+ if (!$this->session->isModerator()) {
+ throw new HTTPException\ForbiddenException($this->t('You don\'t have access to moderation pages.'));
}
if ($this->session->getSubManagedUserId()) {
- throw new HTTPException\ForbiddenException($this->t('Submanaged account can\'t access the administration pages. Please log back in as the main account.'));
+ throw new HTTPException\ForbiddenException($this->t('Submanaged account can\'t access the moderation pages. Please log back in as the main account.'));
}
}
$myurl = $this->session->getMyUrl();
$mail_count = $this->database->count('mail', ["`uid` = ? AND NOT `seen` AND `from-url` != ?", $this->session->getLocalUserId(), $myurl]);
- if (intval($this->config->get('config', 'register_policy')) === Register::APPROVE && $this->app->isSiteAdmin()) {
+ if (intval($this->config->get('config', 'register_policy')) === Register::APPROVE && $this->session->isSiteAdmin()) {
$registrations = \Friendica\Model\Register::getPending();
$register_count = count($registrations);
}