mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 11:44:10 +09:00
Add MustLogin exception and apply to communication module
This commit is contained in:
parent
fe4e336f2b
commit
c1cbc5dbdb
3 changed files with 79 additions and 61 deletions
18
common/framework/exceptions/mustlogin.php
Normal file
18
common/framework/exceptions/mustlogin.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Rhymix\Framework\Exceptions;
|
||||
|
||||
/**
|
||||
* The "must login" exception class.
|
||||
*/
|
||||
class MustLogin extends \Rhymix\Framework\Exception
|
||||
{
|
||||
public function __construct($message = '', $code = 0, $previous = null)
|
||||
{
|
||||
if ($message === '')
|
||||
{
|
||||
$message = lang('msg_not_logged');
|
||||
}
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ class communicationController extends communication
|
|||
{
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->setError('msg_not_logged');
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
|
||||
$args = new stdClass();
|
||||
|
|
@ -54,7 +54,7 @@ class communicationController extends communication
|
|||
// Check login information
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->setError('msg_not_logged');
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
|
@ -63,19 +63,19 @@ class communicationController extends communication
|
|||
$receiver_srl = Context::get('receiver_srl');
|
||||
if(!$receiver_srl)
|
||||
{
|
||||
return $this->setError('msg_not_exists_member');
|
||||
throw new Rhymix\Framework\Exception('msg_not_exists_member');
|
||||
}
|
||||
|
||||
$title = trim(Context::get('title'));
|
||||
if(!$title)
|
||||
{
|
||||
return $this->setError('msg_title_is_null');
|
||||
throw new Rhymix\Framework\Exception('msg_title_is_null');
|
||||
}
|
||||
|
||||
$content = trim(Context::get('content'));
|
||||
if(!$content)
|
||||
{
|
||||
return $this->setError('msg_content_is_null');
|
||||
throw new Rhymix\Framework\Exception('msg_content_is_null');
|
||||
}
|
||||
|
||||
$send_mail = Context::get('send_mail');
|
||||
|
|
@ -91,13 +91,13 @@ class communicationController extends communication
|
|||
|
||||
if(!$oCommunicationModel->checkGrant($config->grant_send))
|
||||
{
|
||||
return $this->setError('msg_not_permitted');
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
|
||||
$receiver_member_info = $oMemberModel->getMemberInfoByMemberSrl($receiver_srl);
|
||||
if($receiver_member_info->member_srl != $receiver_srl)
|
||||
{
|
||||
return $this->setError('msg_not_exists_member');
|
||||
throw new Rhymix\Framework\Exception('msg_not_exists_member');
|
||||
}
|
||||
|
||||
// check whether to allow to receive the message(pass if a top-administrator)
|
||||
|
|
@ -107,12 +107,12 @@ class communicationController extends communication
|
|||
{
|
||||
if(!$oCommunicationModel->isFriend($receiver_member_info->member_srl))
|
||||
{
|
||||
return $this->setError('msg_allow_message_to_friend');
|
||||
throw new Rhymix\Framework\Exception('msg_allow_message_to_friend');
|
||||
}
|
||||
}
|
||||
else if($receiver_member_info->allow_message == 'N')
|
||||
{
|
||||
return $this->setError('msg_disallow_message');
|
||||
throw new Rhymix\Framework\Exception('msg_disallow_message');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -269,7 +269,7 @@ class communicationController extends communication
|
|||
// Check login information
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->setError('msg_not_logged');
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
||||
|
|
@ -277,7 +277,7 @@ class communicationController extends communication
|
|||
$message_srl = Context::get('message_srl');
|
||||
if(!$message_srl)
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
// get the message
|
||||
|
|
@ -285,7 +285,7 @@ class communicationController extends communication
|
|||
$message = $oCommunicationModel->getSelectedMessage($message_srl);
|
||||
if(!$message || $message->message_type != 'R')
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
$args = new stdClass();
|
||||
|
|
@ -309,7 +309,7 @@ class communicationController extends communication
|
|||
// Check login information
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->setError('msg_not_logged');
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
|
@ -319,7 +319,7 @@ class communicationController extends communication
|
|||
$message_srl = Context::get('message_srl');
|
||||
if(!$message_srl)
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
// Get the message
|
||||
|
|
@ -327,7 +327,7 @@ class communicationController extends communication
|
|||
$message = $oCommunicationModel->getSelectedMessage($message_srl);
|
||||
if(!$message)
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
// Check the grant
|
||||
|
|
@ -336,14 +336,14 @@ class communicationController extends communication
|
|||
case 'S':
|
||||
if($message->sender_srl != $member_srl)
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
if($message->receiver_srl != $member_srl)
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -369,7 +369,7 @@ class communicationController extends communication
|
|||
// Check login information
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->setError('msg_not_logged');
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
|
@ -378,7 +378,7 @@ class communicationController extends communication
|
|||
// check variables
|
||||
if(!Context::get('message_srl_list'))
|
||||
{
|
||||
return $this->setError('msg_cart_is_null');
|
||||
throw new Rhymix\Framework\Exception('msg_cart_is_null');
|
||||
}
|
||||
|
||||
$message_srl_list = Context::get('message_srl_list');
|
||||
|
|
@ -389,13 +389,13 @@ class communicationController extends communication
|
|||
|
||||
if(!count($message_srl_list))
|
||||
{
|
||||
return $this->setError('msg_cart_is_null');
|
||||
throw new Rhymix\Framework\Exception('msg_cart_is_null');
|
||||
}
|
||||
|
||||
$message_type = Context::get('message_type');
|
||||
if(!$message_type || !in_array($message_type, array('R', 'S', 'T', 'N')))
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
$message_count = count($message_srl_list);
|
||||
|
|
@ -412,7 +412,7 @@ class communicationController extends communication
|
|||
}
|
||||
if(!count($target))
|
||||
{
|
||||
return $this->setError('msg_cart_is_null');
|
||||
throw new Rhymix\Framework\Exception('msg_cart_is_null');
|
||||
}
|
||||
|
||||
// Delete
|
||||
|
|
@ -458,7 +458,7 @@ class communicationController extends communication
|
|||
// Check login information
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->setError('msg_not_logged');
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
|
@ -466,11 +466,11 @@ class communicationController extends communication
|
|||
$target_srl = (int) trim(Context::get('target_srl'));
|
||||
if(!$target_srl)
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
if($target_srl == $logged_info->member_srl)
|
||||
{
|
||||
return $this->setError('msg_no_self_friend');
|
||||
throw new Rhymix\Framework\Exception('msg_no_self_friend');
|
||||
}
|
||||
|
||||
// Check duplicate friend
|
||||
|
|
@ -480,7 +480,7 @@ class communicationController extends communication
|
|||
$output = executeQuery('communication.isAddedFriend', $args);
|
||||
if($output->data->count)
|
||||
{
|
||||
return $this->setError('msg_already_friend');
|
||||
throw new Rhymix\Framework\Exception('msg_already_friend');
|
||||
}
|
||||
|
||||
// Variable
|
||||
|
|
@ -520,7 +520,7 @@ class communicationController extends communication
|
|||
// Check login information
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->setError('msg_not_logged');
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
|
@ -529,7 +529,7 @@ class communicationController extends communication
|
|||
$friend_srl_list = Context::get('friend_srl_list');
|
||||
if(!$friend_srl_list)
|
||||
{
|
||||
return $this->setError('msg_cart_is_null');
|
||||
throw new Rhymix\Framework\Exception('msg_cart_is_null');
|
||||
}
|
||||
|
||||
if(!is_array($friend_srl_list))
|
||||
|
|
@ -539,7 +539,7 @@ class communicationController extends communication
|
|||
|
||||
if(!count($friend_srl_list))
|
||||
{
|
||||
return $this->setError('msg_cart_is_null');
|
||||
throw new Rhymix\Framework\Exception('msg_cart_is_null');
|
||||
}
|
||||
|
||||
$friend_count = count($friend_srl_list);
|
||||
|
|
@ -557,7 +557,7 @@ class communicationController extends communication
|
|||
|
||||
if(!count($target))
|
||||
{
|
||||
return $this->setError('msg_cart_is_null');
|
||||
throw new Rhymix\Framework\Exception('msg_cart_is_null');
|
||||
}
|
||||
|
||||
// Variables
|
||||
|
|
@ -587,7 +587,7 @@ class communicationController extends communication
|
|||
// Check login information
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->setError('msg_not_logged');
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
|
@ -603,7 +603,7 @@ class communicationController extends communication
|
|||
|
||||
if(!count($friend_srl_list))
|
||||
{
|
||||
return $this->setError('msg_cart_is_null');
|
||||
throw new Rhymix\Framework\Exception('msg_cart_is_null');
|
||||
}
|
||||
|
||||
$friend_count = count($friend_srl_list);
|
||||
|
|
@ -622,7 +622,7 @@ class communicationController extends communication
|
|||
|
||||
if(!count($target))
|
||||
{
|
||||
return $this->setError('msg_cart_is_null');
|
||||
throw new Rhymix\Framework\Exception('msg_cart_is_null');
|
||||
}
|
||||
|
||||
// Delete
|
||||
|
|
@ -650,7 +650,7 @@ class communicationController extends communication
|
|||
// Check login information
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->setError('msg_not_logged');
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
|
@ -664,7 +664,7 @@ class communicationController extends communication
|
|||
|
||||
if(!$args->title)
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
// modify if friend_group_srl exists.
|
||||
|
|
@ -726,7 +726,7 @@ class communicationController extends communication
|
|||
// Check login information
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->setError('msg_not_logged');
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
|
@ -740,7 +740,7 @@ class communicationController extends communication
|
|||
|
||||
if(!$args->title)
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
$output = executeQuery('communication.renameFriendGroup', $args);
|
||||
|
|
@ -761,7 +761,7 @@ class communicationController extends communication
|
|||
// Check login information
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->setError('msg_not_logged');
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
|
|
|||
|
|
@ -52,13 +52,13 @@ class communicationView extends communication
|
|||
{
|
||||
if($this->config->enable_message == 'N')
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
// Error appears if not logged-in
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->setError('msg_not_logged');
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
|
@ -86,28 +86,28 @@ class communicationView extends communication
|
|||
case 'R':
|
||||
if($message->receiver_srl != $logged_info->member_srl)
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
if($message->sender_srl != $logged_info->member_srl)
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
if($message->receiver_srl != $logged_info->member_srl && $message->sender_srl != $logged_info->member_srl)
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'N':
|
||||
if($message->receiver_srl != $logged_info->member_srl)
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -151,13 +151,13 @@ class communicationView extends communication
|
|||
|
||||
if($this->config->enable_message == 'N')
|
||||
{
|
||||
return $this->stop('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
// Error appears if not logged-in
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->stop('msg_not_logged');
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
|
@ -190,17 +190,17 @@ class communicationView extends communication
|
|||
|
||||
if($this->config->enable_message == 'N')
|
||||
{
|
||||
return $this->stop('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
if(!getModel('communication')->checkGrant($this->config->grant_send))
|
||||
{
|
||||
return $this->stop('msg_not_permitted');
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
|
||||
// Error appears if not logged-in
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->stop('msg_not_logged');
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
|
@ -210,13 +210,13 @@ class communicationView extends communication
|
|||
$receiver_srl = Context::get('receiver_srl');
|
||||
if(!$receiver_srl)
|
||||
{
|
||||
return $this->stop('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
// check receiver and sender are same
|
||||
if($logged_info->member_srl == $receiver_srl)
|
||||
{
|
||||
return $this->stop('msg_cannot_send_to_yourself');
|
||||
throw new Rhymix\Framework\Exception('msg_cannot_send_to_yourself');
|
||||
}
|
||||
|
||||
$oCommunicationModel = getModel('communication');
|
||||
|
|
@ -241,7 +241,7 @@ class communicationView extends communication
|
|||
$receiver_info = $oMemberModel->getMemberInfoByMemberSrl($receiver_srl);
|
||||
if(!$receiver_info)
|
||||
{
|
||||
return $this->stop('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
Context::set('receiver_info', $receiver_info);
|
||||
|
|
@ -275,13 +275,13 @@ class communicationView extends communication
|
|||
{
|
||||
if($this->config->enable_friend == 'N')
|
||||
{
|
||||
return $this->stop('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
// Error appears if not logged-in
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->stop('msg_not_logged');
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
|
||||
$oCommunicationModel = getModel('communication');
|
||||
|
|
@ -339,13 +339,13 @@ class communicationView extends communication
|
|||
|
||||
if($this->config->enable_friend == 'N')
|
||||
{
|
||||
return $this->stop('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
// error appears if not logged-in
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->stop('msg_not_logged');
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
|
@ -353,11 +353,11 @@ class communicationView extends communication
|
|||
|
||||
if(!$target_srl)
|
||||
{
|
||||
return $this->stop('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
if($target_srl == $logged_info->member_srl)
|
||||
{
|
||||
return $this->stop('msg_no_self_friend');
|
||||
throw new Rhymix\Framework\Exception('msg_no_self_friend');
|
||||
}
|
||||
|
||||
// get information of the member
|
||||
|
|
@ -367,7 +367,7 @@ class communicationView extends communication
|
|||
|
||||
if($communication_info->member_srl != $target_srl)
|
||||
{
|
||||
return $this->stop('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
Context::set('target_info', $communication_info);
|
||||
|
|
@ -390,13 +390,13 @@ class communicationView extends communication
|
|||
|
||||
if($this->config->enable_friend == 'N')
|
||||
{
|
||||
return $this->stop('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
// error apprears if not logged-in
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->stop('msg_not_logged');
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue