mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
User/Misc
* floating changes * codify user checks into functions
This commit is contained in:
@@ -27,7 +27,7 @@ class AjaxAccount extends AjaxHandler
|
||||
{
|
||||
parent::__construct($params);
|
||||
|
||||
if (!$this->params || !User::$id)
|
||||
if (!$this->params || !User::isLoggedIn())
|
||||
return;
|
||||
|
||||
// select handler
|
||||
|
||||
@@ -172,7 +172,7 @@ class AjaxComment extends AjaxHandler
|
||||
|
||||
protected function handleCommentDelete() : void
|
||||
{
|
||||
if (!$this->_post['id'] || !User::$id)
|
||||
if (!$this->_post['id'] || !User::isLoggedIn())
|
||||
{
|
||||
trigger_error('AjaxComment::handleCommentDelete - commentId empty or user not logged in', E_USER_ERROR);
|
||||
return;
|
||||
@@ -204,7 +204,7 @@ class AjaxComment extends AjaxHandler
|
||||
|
||||
protected function handleCommentUndelete() : void
|
||||
{
|
||||
if (!$this->_post['id'] || !User::$id)
|
||||
if (!$this->_post['id'] || !User::isLoggedIn())
|
||||
{
|
||||
trigger_error('AjaxComment::handleCommentUndelete - commentId empty or user not logged in', E_USER_ERROR);
|
||||
return;
|
||||
@@ -242,7 +242,7 @@ class AjaxComment extends AjaxHandler
|
||||
|
||||
protected function handleCommentVote() : string
|
||||
{
|
||||
if (!User::$id || !$this->_get['id'] || !$this->_get['rating'])
|
||||
if (!User::isLoggedIn() || !$this->_get['id'] || !$this->_get['rating'])
|
||||
return Util::toJSON(['error' => 1, 'message' => Lang::main('genericError')]);
|
||||
|
||||
$target = DB::Aowow()->selectRow('SELECT c.`userId` AS owner, ur.`value` FROM ?_comments c LEFT JOIN ?_user_ratings ur ON ur.`type` = ?d AND ur.`entry` = c.id AND ur.`userId` = ?d WHERE c.id = ?d', RATING_COMMENT, User::$id, $this->_get['id']);
|
||||
@@ -393,7 +393,7 @@ class AjaxComment extends AjaxHandler
|
||||
|
||||
protected function handleReplyDelete() : void
|
||||
{
|
||||
if (!User::$id || !$this->_post['id'])
|
||||
if (!User::isLoggedIn() || !$this->_post['id'])
|
||||
{
|
||||
trigger_error('AjaxComment::handleReplyDelete - commentId empty or user not logged in', E_USER_ERROR);
|
||||
return;
|
||||
@@ -407,7 +407,7 @@ class AjaxComment extends AjaxHandler
|
||||
|
||||
protected function handleReplyFlag() : void
|
||||
{
|
||||
if (!User::$id || !$this->_post['id'])
|
||||
if (!User::isLoggedIn() || !$this->_post['id'])
|
||||
{
|
||||
trigger_error('AjaxComment::handleReplyFlag - commentId empty or user not logged in', E_USER_ERROR);
|
||||
return;
|
||||
|
||||
@@ -10,7 +10,7 @@ class AjaxCookie extends AjaxHandler
|
||||
public function __construct(array $params)
|
||||
{
|
||||
// note that parent::__construct has to come after this
|
||||
if (!$params || !User::$id)
|
||||
if (!$params || !User::isLoggedIn())
|
||||
return;
|
||||
|
||||
$this->_get = array(
|
||||
@@ -30,7 +30,7 @@ class AjaxCookie extends AjaxHandler
|
||||
*/
|
||||
protected function handleCookie() : string
|
||||
{
|
||||
if (User::$id && $this->params && $this->_get[$this->params[0]])
|
||||
if (User::isLoggedIn() && $this->params && $this->_get[$this->params[0]])
|
||||
{
|
||||
if (DB::Aowow()->query('REPLACE INTO ?_account_cookies VALUES (?d, ?, ?)', User::$id, $this->params[0], $this->_get[$this->params[0]]))
|
||||
return '0';
|
||||
|
||||
@@ -34,7 +34,7 @@ class AjaxEdit extends AjaxHandler
|
||||
*/
|
||||
protected function handleUpload() : string
|
||||
{
|
||||
if (!User::$id || $this->_get['guide'] != 1)
|
||||
if (!User::canWriteGuide() || $this->_get['guide'] != 1)
|
||||
return Util::toJSON(['success' => false, 'error' => '']);
|
||||
|
||||
require_once('includes/libs/qqFileUploader.class.php');
|
||||
|
||||
@@ -25,7 +25,7 @@ class AjaxGetdescription extends AjaxHandler
|
||||
{
|
||||
$this->contentType = MIME_TYPE_TEXT;
|
||||
|
||||
if (!User::$id)
|
||||
if (!User::canWriteGuide())
|
||||
return '';
|
||||
|
||||
$desc = (new Markup($this->_post['description']))->stripTags();
|
||||
|
||||
@@ -103,7 +103,7 @@ class AjaxProfile extends AjaxHandler
|
||||
*/
|
||||
protected function handleLink() : void // links char with account
|
||||
{
|
||||
if (!User::$id || empty($this->_get['id']))
|
||||
if (!User::isLoggedIn() || empty($this->_get['id']))
|
||||
{
|
||||
trigger_error('AjaxProfile::handleLink - profileId empty or user not logged in', E_USER_ERROR);
|
||||
return;
|
||||
@@ -143,7 +143,7 @@ class AjaxProfile extends AjaxHandler
|
||||
*/
|
||||
protected function handlePin() : void // (un)favorite
|
||||
{
|
||||
if (!User::$id || empty($this->_get['id'][0]))
|
||||
if (!User::isLoggedIn() || empty($this->_get['id'][0]))
|
||||
{
|
||||
trigger_error('AjaxProfile::handlePin - profileId empty or user not logged in', E_USER_ERROR);
|
||||
return;
|
||||
@@ -173,7 +173,7 @@ class AjaxProfile extends AjaxHandler
|
||||
*/
|
||||
protected function handlePrivacy() : void // public visibility
|
||||
{
|
||||
if (!User::$id || empty($this->_get['id'][0]))
|
||||
if (!User::isLoggedIn() || empty($this->_get['id'][0]))
|
||||
{
|
||||
trigger_error('AjaxProfile::handlePrivacy - profileId empty or user not logged in', E_USER_ERROR);
|
||||
return;
|
||||
@@ -451,7 +451,7 @@ class AjaxProfile extends AjaxHandler
|
||||
*/
|
||||
protected function handleDelete() : void // kill a profile
|
||||
{
|
||||
if (!User::$id || !$this->_get['id'])
|
||||
if (!User::isLoggedIn() || !$this->_get['id'])
|
||||
{
|
||||
trigger_error('AjaxProfile::handleDelete - profileId empty or user not logged in', E_USER_ERROR);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user