/** * Index page */ public function indexAction() { // get user info by api key if (null != ($apiKey = $this->getRequest()->getQuery()->api_key)) { if (null != ($userInfo = UserIdentityService::getUserInfo($apiKey, UserModelBase::USER_INFO_BY_API_KEY))) { // fill the user's info if ($userInfo['status'] == UserModelBase::STATUS_APPROVED) { $userIdentity = []; foreach ($userInfo as $fieldName => $value) { $userIdentity[$fieldName] = $value; } // init user identity UserIdentityService::setCurrentUserIdentity($userIdentity); } } } XmlRpcServerFault::attachFaultException('XmlRpc\\Exception\\XmlRpcActionDenied'); $server = new XmlRpcServer(); // get xmlrpc classes if (null != ($classes = $this->getModel()->getClasses())) { $server->sendArgumentsToAllMethods(false); foreach ($classes as $class) { $server->setClass($class['path'], $class['namespace'], $this->getServiceLocator()); } } $server->handle(); // disable layout and view script return $this->response; }
/** * Login user * * @param integer $userId * @param string $nickName * @param boolean $rememberMe * @return void */ public static function loginUser($userId, $nickName, $rememberMe) { $user = []; $user['user_id'] = $userId; // save user id UserIdentityService::getAuthService()->getStorage()->write($user); UserIdentityService::setCurrentUserIdentity(UserIdentityService::getUserInfo($userId)); AclService::clearCurrentAcl(); // fire the user login event UserEvent::fireLoginEvent($userId, $nickName); if ($rememberMe) { ServiceLocatorService::getServiceLocator()->get('Zend\\Session\\SessionManager')->rememberMe((int) SettingService::getSetting('user_session_time')); } }
/** * Get widget content * * @return string|boolean */ public function getContent() { if (AclService::checkPermission('comment_view', false)) { // get the current user's info if (null != ($userInfo = UserIdentityService::getUserInfo($this->getSlug(), BaseModel::USER_INFO_BY_SLUG))) { // get last comments $comments = $this->getModel()->getLastComments($this->getCurrentLanguage(), (int) $this->getWidgetSetting('comment_count'), $userInfo['user_id']); if (count($comments)) { // increase ACL track AclService::checkPermission('comment_view'); return $this->getView()->partial('comment/widget/user-last-comments-list', ['visible_chars' => $this->getWidgetSetting('comment_visible_chars'), 'comments' => $comments]); } } } return false; }
/** * Process action */ public function processAction() { // get the payment's type info if (null == ($payment = $this->getModel()->getPaymentTypeInfo($this->getSlug()))) { return $this->createHttpNotFoundModel($this->getResponse()); } // get the payment type instance $paymentInstance = $this->getServiceLocator()->get('Payment\\Type\\PaymentTypeManager')->getInstance($payment['handler']); // validate the payment if (false !== ($transactionInfo = $paymentInstance->validatePayment())) { if (true === ($result = $this->getModel()->activateTransaction($transactionInfo, $payment['id'], true, true))) { // send an email notification about the paid transaction if ((int) $this->applicationSetting('payment_transaction_paid_users')) { // get the user's info $userInfo = !empty($transactionInfo['user_id']) ? UserIdentityService::getUserInfo($transactionInfo['user_id']) : []; $notificationLanguage = !empty($userInfo['language']) ? $userInfo['language'] : LocalizationService::getDefaultLocalization()['language']; EmailNotificationUtility::sendNotification($transactionInfo['email'], $this->applicationSetting('payment_transaction_paid_users_title', $notificationLanguage), $this->applicationSetting('payment_transaction_paid_users_message', $notificationLanguage), ['find' => ['Id', 'PaymentType'], 'replace' => [$transactionInfo['slug'], $this->getTranslator()->translate($payment['description'], 'default', LocalizationService::getLocalizations()[$notificationLanguage]['locale'])]]); } } } else { return $this->createHttpNotFoundModel($this->getResponse()); } return $this->getResponse(); }
/** * Set the item as paid * * @param integer $id * @param array $transactionInfo * integer id * string slug * integer user_id * string first_name * string last_name * string phone * string address * string email * integer currency * integer payment_type * integer discount_cupon * string currency_code * string payment_name * @return void */ public function setPaid($id, array $transactionInfo) { // the default user cannot buy any membership levels, // he(she) must stays as a default user with the admin role if ($transactionInfo['user_id'] == UserBaseModel::DEFAULT_USER_ID || null == ($roleInfo = $this->getModel()->getRoleInfo($id, true))) { return; } // get a user's membership connections $result = $this->getModel()->getAllUserMembershipConnections($transactionInfo['user_id']); $activateConnection = count($result) ? false : true; // add a new membership connection $connectionId = $this->getModel()->addMembershipConnection($transactionInfo['user_id'], $roleInfo['id'], $roleInfo['lifetime'], $roleInfo['expiration_notification']); // activate the membership connection if (is_numeric($connectionId) && $activateConnection) { // change the user's role $userInfo = UserIdentityService::getUserInfo($transactionInfo['user_id']); if (true === ($result = $this->getUserModel()->editUserRole($transactionInfo['user_id'], $roleInfo['role_id'], $roleInfo['role_name'], (array) $userInfo, true))) { // activate the membership connection $this->getModel()->activateMembershipConnection($connectionId); } } }