/** * @param integer $iProfileId * @param \PH7\UserCoreModel $oUserModel * @return void */ public function __construct($iProfileId, UserCoreModel $oUserModel) { parent::__construct(); $oGetPrivacy = $oUserModel->getPrivacySetting($iProfileId); if (!$this->str->equals($this->httpRequest->post('privacy_profile'), $oGetPrivacy->privacyProfile)) { $oUserModel->updatePrivacySetting('privacyProfile', $this->httpRequest->post('privacy_profile'), $iProfileId); } if (!$this->str->equals($this->httpRequest->post('search_profile'), $oGetPrivacy->searchProfile)) { $oUserModel->updatePrivacySetting('searchProfile', $this->httpRequest->post('search_profile'), $iProfileId); } if (!$this->str->equals($this->httpRequest->post('user_save_views'), $oGetPrivacy->userSaveViews)) { $oUserModel->updatePrivacySetting('userSaveViews', $this->httpRequest->post('user_save_views'), $iProfileId); } if (!$this->str->equals($this->httpRequest->post('user_status'), $oUserModel->getUserStatus($iProfileId))) { $oUserModel->setUserStatus($iProfileId, $this->httpRequest->post('user_status')); } /* Clean UserCoreModel Cache */ (new Framework\Cache\Cache())->start(UserCoreModel::CACHE_GROUP, 'privacySetting' . $iProfileId, null)->clear()->start(UserCoreModel::CACHE_GROUP, 'userStatus' . $iProfileId, null)->clear(); \PFBC\Form::setSuccess('form_privacy_account', t('Your privacy settings have been saved successfully!')); }
/** * @param integer $iProfileId * @param \PH7\UserCoreModel $oUserModel * @return void */ public function __construct($iProfileId, UserCoreModel $oUserModel) { parent::__construct(); $oGetNotofication = $oUserModel->getNotification($iProfileId); if (!$this->str->equals($this->httpRequest->post('enable_newsletters'), $oGetNotofication->enableNewsletters)) { $oUserModel->setNotification('enableNewsletters', $this->httpRequest->post('enable_newsletters'), $iProfileId); } if (!$this->str->equals($this->httpRequest->post('new_msg'), $oGetNotofication->newMsg)) { $oUserModel->setNotification('newMsg', $this->httpRequest->post('new_msg'), $iProfileId); } if (!$this->str->equals($this->httpRequest->post('friend_request'), $oGetNotofication->friendRequest)) { $oUserModel->setNotification('friendRequest', $this->httpRequest->post('friend_request'), $iProfileId); } unset($oUserModel); /* Clean UserCoreModel Cache */ (new Framework\Cache\Cache())->start(UserCoreModel::CACHE_GROUP, 'notification' . $iProfileId, null)->clear()->start(UserCoreModel::CACHE_GROUP, 'isNotification' . $iProfileId, null)->clear(); \PFBC\Form::setSuccess('form_notification', t('Your notifications settings have been saved successfully!')); }
/** * Send an email to warn the friend request. * * @param int $iId friend ID * @param object \PH7\UserCoreModel $oUserModel * @return void */ protected function sendMail($iId, UserCoreModel $oUserModel) { $sFriendEmail = $oUserModel->getEmail($iId); $sFriendUsername = $oUserModel->getUsername($iId); /** * Note: The predefined variables as %site_name% does not work here, * because we are in an ajax script that is called before the definition of these variables. */ /** * Get the site name, because we do not have access to predefined variables. */ $sSiteName = Framework\Mvc\Model\DbConfig::getSetting('siteName'); $this->view->content = t('Hello %0%!<br /><strong>%1%</strong> sent you a friendship request on %2%.<br /> <a href="%3%">Click here</a> to see your friend request.', $sFriendUsername, $this->session->get('member_username'), $sSiteName, Framework\Mvc\Router\Uri::get('user', 'friend', 'index')); /* Because we work in Ajax, the constant "PH7_TPL_NAME" is not yet defined. * So we use the constant "PH7_DEFAULT_THEME" is already defined. */ $sMessageHtml = $this->view->parseMail(PH7_PATH_SYS . 'global/' . PH7_VIEWS . PH7_DEFAULT_THEME . '/mail/sys/mod/user/friend_request.tpl', $sFriendEmail); $aInfo = ['to' => $sFriendEmail, 'subject' => t('%0% wants to be friends with you on %1%', $this->session->get('member_first_name'), $sSiteName)]; (new Framework\Mail\Mail())->send($aInfo, $sMessageHtml); }
<?php /** * @author Pierre-Henry Soria <*****@*****.**> * @copyright (c) 2012-2016, Pierre-Henry Soria. All Rights Reserved. * @license GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory. * @package PH7 / App / System / Module / User */ namespace PH7; defined('PH7') or die('Restricted access'); // Automatic connection if (!UserCore::auth() && Framework\Registry\Registry::getInstance()->action != 'soon') { $oCookie = new Framework\Cookie\Cookie(); if ($oCookie->exists(array('member_remember', 'member_id'))) { if ((new ExistsCoreModel())->id($oCookie->get('member_id'))) { $oUserModel = new UserCoreModel(); $oUser = $oUserModel->readProfile($oCookie->get('member_id')); if ($oCookie->get('member_remember') === Framework\Security\Security::hashCookie($oUser->password)) { (new UserCore())->setAuth($oUser, $oUserModel, new Framework\Session\Session()); } } } unset($oCookie); }