From 52a7d47a4936af9c8e6931dd6b00ceee18bc94bc Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 20 Jun 2023 00:50:36 +0900 Subject: [PATCH] Also force communication and ncenterlite views to share member mid --- .../communication/communication.mobile.php | 8 +++ modules/communication/communication.view.php | 64 ++++++++++++++++--- modules/member/member.view.php | 11 ++-- modules/ncenterlite/ncenterlite.view.php | 43 +++++++++++-- 4 files changed, 106 insertions(+), 20 deletions(-) diff --git a/modules/communication/communication.mobile.php b/modules/communication/communication.mobile.php index dc6470fb7..288031dc0 100644 --- a/modules/communication/communication.mobile.php +++ b/modules/communication/communication.mobile.php @@ -51,6 +51,14 @@ class communicationMobile extends communicationView */ function dispCommunicationMessageBoxList() { + // Check member mid + $oMemberView = MemberView::getInstance(); + if (!$oMemberView->checkMidAndRedirect()) + { + $this->setRedirectUrl($oMemberView->getRedirectUrl()); + return; + } + $this->setTemplateFile('message_box'); } } diff --git a/modules/communication/communication.view.php b/modules/communication/communication.view.php index b207812da..ec238552c 100644 --- a/modules/communication/communication.view.php +++ b/modules/communication/communication.view.php @@ -61,6 +61,14 @@ class communicationView extends communication throw new Rhymix\Framework\Exceptions\MustLogin; } + // Check member mid + $oMemberView = MemberView::getInstance(); + if (!$oMemberView->checkMidAndRedirect()) + { + $this->setRedirectUrl($oMemberView->getRedirectUrl()); + return; + } + $logged_info = Context::get('logged_info'); // Set the variables @@ -177,11 +185,17 @@ class communicationView extends communication throw new Rhymix\Framework\Exceptions\MustLogin; } - $oCommunicationModel = getModel('communication'); + // Check member mid + $oMemberView = MemberView::getInstance(); + if (!$oMemberView->checkMidAndRedirect()) + { + $this->setRedirectUrl($oMemberView->getRedirectUrl()); + return; + } // get a new message $columnList = array('message_srl', 'member_srl', 'nick_name', 'title', 'content', 'sender_srl'); - $message = $oCommunicationModel->getNewMessage($columnList); + $message = CommunicationModel::getInstance()->getNewMessage($columnList); if($message) { stripEmbedTagForAdmin($message->content, $message->sender_srl); @@ -207,23 +221,33 @@ class communicationView extends communication { throw new Rhymix\Framework\Exceptions\InvalidRequest; } + + // Error appears if not logged-in + if(!Context::get('is_logged')) + { + throw new Rhymix\Framework\Exceptions\MustLogin; + } + + // Check permission if(!getModel('communication')->checkGrant($this->config->grant_send)) { throw new Rhymix\Framework\Exceptions\NotPermitted; } + // Check member mid + $oMemberView = MemberView::getInstance(); + if (!$oMemberView->checkMidAndRedirect()) + { + $this->setRedirectUrl($oMemberView->getRedirectUrl()); + return; + } + // Fix missing mid (it causes errors when uploading) if(!Context::get('mid')) { Context::set('mid', Context::get('site_module_info')->mid); } - // Error appears if not logged-in - if(!Context::get('is_logged')) - { - throw new Rhymix\Framework\Exceptions\MustLogin; - } - $logged_info = Context::get('logged_info'); // get receipient's information @@ -310,6 +334,14 @@ class communicationView extends communication throw new Rhymix\Framework\Exceptions\MustLogin; } + // Check member mid + $oMemberView = MemberView::getInstance(); + if (!$oMemberView->checkMidAndRedirect()) + { + $this->setRedirectUrl($oMemberView->getRedirectUrl()); + return; + } + $oCommunicationModel = getModel('communication'); // get a group list @@ -369,6 +401,14 @@ class communicationView extends communication throw new Rhymix\Framework\Exceptions\MustLogin; } + // Check member mid + $oMemberView = MemberView::getInstance(); + if (!$oMemberView->checkMidAndRedirect()) + { + $this->setRedirectUrl($oMemberView->getRedirectUrl()); + return; + } + $logged_info = Context::get('logged_info'); $target_srl = Context::get('target_srl'); @@ -419,7 +459,13 @@ class communicationView extends communication throw new Rhymix\Framework\Exceptions\MustLogin; } - $logged_info = Context::get('logged_info'); + // Check member mid + $oMemberView = MemberView::getInstance(); + if (!$oMemberView->checkMidAndRedirect()) + { + $this->setRedirectUrl($oMemberView->getRedirectUrl()); + return; + } // change to edit mode when getting the group_srl $friend_group_srl = Context::get('friend_group_srl'); diff --git a/modules/member/member.view.php b/modules/member/member.view.php index f7f0465a5..0de830c6b 100644 --- a/modules/member/member.view.php +++ b/modules/member/member.view.php @@ -7,9 +7,8 @@ */ class MemberView extends Member { - var $group_list = NULL; // /< Group list information - var $member_info = NULL; // /< Member information of the user - var $skin = 'default'; + public $member_config; + public $member_info; /** * @brief Initialization @@ -48,6 +47,10 @@ class MemberView extends Member */ public function checkMidAndRedirect() { + if (!$this->member_config) + { + $this->member_config = MemberModel::getMemberConfig(); + } if (!$this->member_config->mid) { return true; @@ -56,7 +59,7 @@ class MemberView extends Member { return true; } - if (isset($this->mid) && $this->mid === $this->member_config->mid) + if (Context::get('mid') === $this->member_config->mid) { return true; } diff --git a/modules/ncenterlite/ncenterlite.view.php b/modules/ncenterlite/ncenterlite.view.php index 14d126533..43ac8eff2 100644 --- a/modules/ncenterlite/ncenterlite.view.php +++ b/modules/ncenterlite/ncenterlite.view.php @@ -4,7 +4,7 @@ class ncenterliteView extends ncenterlite { function init() { - $oNcenterliteModel = getModel('ncenterlite'); + $oNcenterliteModel = ncenterliteModel::getInstance(); $config = $oNcenterliteModel->getConfig(); $template_path = sprintf("%sskins/%s/",$this->module_path, $config->skin); if(!is_dir($template_path)||!$config->skin) @@ -28,8 +28,15 @@ class ncenterliteView extends ncenterlite function dispNcenterliteNotifyList() { - $oNcenterliteModel = getModel('ncenterlite'); + // Check member mid + $oMemberView = MemberView::getInstance(); + if (!$oMemberView->checkMidAndRedirect()) + { + $this->setRedirectUrl($oMemberView->getRedirectUrl()); + return; + } + $oNcenterliteModel = ncenterliteModel::getInstance(); $output = $oNcenterliteModel->getMyNotifyList($this->user->member_srl, 1, null, true); Context::set('total_count', $output->page_navigation->total_count); @@ -43,7 +50,15 @@ class ncenterliteView extends ncenterlite function dispNcenterliteUserConfig() { - $oNcenterliteModel = getModel('ncenterlite'); + // Check member mid + $oMemberView = MemberView::getInstance(); + if (!$oMemberView->checkMidAndRedirect()) + { + $this->setRedirectUrl($oMemberView->getRedirectUrl()); + return; + } + + $oNcenterliteModel = ncenterliteModel::getInstance(); $config = $oNcenterliteModel->getConfig(); if($config->user_notify_setting != 'Y') { @@ -102,8 +117,15 @@ class ncenterliteView extends ncenterlite */ function dispNcenterliteUnsubscribeList() { - /** @var ncenterliteModel $oNcenterliteModel */ - $oNcenterliteModel = getModel('ncenterlite'); + // Check member mid + $oMemberView = MemberView::getInstance(); + if (!$oMemberView->checkMidAndRedirect()) + { + $this->setRedirectUrl($oMemberView->getRedirectUrl()); + return; + } + + $oNcenterliteModel = ncenterliteModel::getInstance(); $config = $oNcenterliteModel->getConfig(); if($config->unsubscribe !== 'Y') @@ -147,8 +169,15 @@ class ncenterliteView extends ncenterlite $this->setLayoutPath('./common/tpl'); $this->setLayoutFile('popup_layout'); - /** @var ncenterliteModel $oNcenterliteModel */ - $oNcenterliteModel = getModel('ncenterlite'); + // Check member mid + $oMemberView = MemberView::getInstance(); + if (!$oMemberView->checkMidAndRedirect()) + { + $this->setRedirectUrl($oMemberView->getRedirectUrl()); + return; + } + + $oNcenterliteModel = ncenterliteModel::getInstance(); $target_srl = Context::get('target_srl'); $unsubscribe_srl = Context::get('unsubscribe_srl'); $unsubscribe_type = Context::get('unsubscribe_type');