/** * find provider by id * * @param $userId * @return */ public function onUserRegister($userId = 0) { if (!$userId) { return null; } if (isset($_COOKIE['yncontactimporter_userId'])) { $refId = $_COOKIE['yncontactimporter_userId']; unset($_COOKIE['yncontactimporter_userId']); // check email and update isued $user = BOL_UserService::getInstance()->findUserById($userId); $email = $user->getEmail(); if ($invitation = YNCONTACTIMPORTER_BOL_InvitationService::getInstance()->checkInvitedUser($email)) { $invitation->isUsed = 1; YNCONTACTIMPORTER_BOL_InvitationService::getInstance()->save($invitation); } // save joined $joined = new YNCONTACTIMPORTER_BOL_Joined(); $joined->userId = $userId; $joined->inviterId = $refId; $this->joinedDao->save($joined); //invite friend $event = new OW_Event('friends.add_friend', array('requesterId' => $refId, 'userId' => $userId)); OW::getEventManager()->trigger($event); } }
public function pending() { $this->menu->getElement('4')->setActive(true); OW::getDocument()->setTitle(OW::getLanguage()->text('yncontactimporter', 'meta_title_invite_pending_invitation')); OW::getDocument()->setDescription(OW::getLanguage()->text('yncontactimporter', 'meta_description_invite_import')); if (!OW::getUser()->isAuthenticated()) { throw new AuthenticateException(); } if (!OW::getUser()->isAuthorized('yncontactimporter', 'invite')) { $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html'); return; } $userId = OW::getUser()->getId(); if (OW::getRequest()->isPost()) { if (isset($_POST['resend']) || isset($_POST['delete'])) { try { foreach ($_POST as $key => $val) { if (strpos($key, 'check_') !== false) { if (isset($_POST['delete']) && $_POST['delete']) { YNCONTACTIMPORTER_BOL_InvitationService::getInstance()->deleteInvitationById($val); } else { $invitation = YNCONTACTIMPORTER_BOL_InvitationService::getInstance()->findInvitationById($val); if ($invitation && $invitation->type == 'email') { $displayName = BOL_UserService::getInstance()->getDisplayName($userId); $vars = array('inviter' => $displayName, 'siteName' => OW::getConfig()->getValue('base', 'site_name'), 'customMessage' => $invitation->message); $link = OW::getRequest()->buildUrlQueryString(OW::getRouter()->urlForRoute('yncontactimporter-user-join'), array('refId' => $userId)); $vars['siteInviteURL'] = $link; $mail = OW::getMailer()->createMail(); $mail->setSubject(OW::getLanguage()->text('yncontactimporter', 'mail_email_invite_subject', $vars)); $mail->setHtmlContent(OW::getLanguage()->text('yncontactimporter', 'mail_email_invite_msg_html', $vars)); $mail->setTextContent(OW::getLanguage()->text('yncontactimporter', 'mail_email_invite_msg_txt', $vars)); $mail->addRecipientEmail($invitation->friendId); YNCONTACTIMPORTER_BOL_PendingService::getInstance()->savePending($mail); } } } } if (isset($_POST['delete']) && $_POST['delete']) { OW::getFeedback()->info(OW::getLanguage()->text('yncontactimporter', 'message_delete_completed')); } else { OW::getFeedback()->info(OW::getLanguage()->text('yncontactimporter', 'message_resend_completed')); } } catch (Exception $e) { } } } $rpp = (int) OW::getConfig()->getValue('yncontactimporter', 'contact_per_page'); $page = !empty($_GET['page']) && intval($_GET['page']) > 0 ? $_GET['page'] : 1; $first = ($page - 1) * $rpp; $count = $rpp; $search = ''; if (isset($_REQUEST['search'])) { $search = $_REQUEST['search']; } $params = array('userId' => $userId, 'first' => $first, 'count' => $count, 'search' => $search); $list = YNCONTACTIMPORTER_BOL_InvitationService::getInstance()->getInvitationsByUserId($params); $itemsCount = YNCONTACTIMPORTER_BOL_InvitationService::getInstance()->countInvitationsByUserId($params); $this->assign('invitations', $list); $paging = new BASE_CMP_Paging($page, ceil($itemsCount / $rpp), 5); $this->addComponent('paging', $paging); $this->assign('currentSearch', !empty($_REQUEST['search']) ? htmlspecialchars($_REQUEST['search']) : ''); $this->assign('totalSearch', $itemsCount); $this->assign('warningNoContactSelected', OW::getLanguage()->text('yncontactimporter', 'no_contacts_selected')); $this->assign('confirmDeleteSelected', OW::getLanguage()->text('yncontactimporter', 'confirm_delete_selected')); $this->assign('confirmDeleteContact', OW::getLanguage()->text('yncontactimporter', 'confirm_delete_contact')); $this->assign('messageResendCompleted', OW::getLanguage()->text('yncontactimporter', 'message_resend_completed')); $this->assign('deleteURL', OW::getRouter()->urlForRoute('yncontactimporter-ajax-delete')); $this->assign('resendURL', OW::getRouter()->urlForRoute('yncontactimporter-ajax-resend')); }
/** * delete Pending by id * * @param * @return void */ public function deleteEmailById($id) { $pendingDao = $this->pendingDao; $pending = $pendingDao->findById($id); if ($pending) { $email = BOL_MailDao::getInstance()->findById($pending->emailId)->recipientEmail; BOL_MailDao::getInstance()->deleteById($pending->emailId); $pendingDao->delete($pending); // delete invatation $invitation = YNCONTACTIMPORTER_BOL_InvitationService::getInstance()->checkInvitedUser($email); if ($invitation) { YNCONTACTIMPORTER_BOL_InvitationService::getInstance()->delete($invitation); } } }