/** * Returns class instance * * @return YNCONTACTIMPORTER_BOL_PendingService */ public static function getInstance() { if (!isset(self::$classInstance)) { self::$classInstance = new self(); } return self::$classInstance; }
/** * get All invitations with userId * * @param OW_Example * * @return array YNCONTACTIMPORTER_BOL_Invitation */ public function getInvitationByUserId($params = array()) { $example = new OW_Example(); if (isset($params['count']) && $params['count']) { $example->setLimitClause($params['first'], $params['count']); } if (isset($params['userId'])) { $example->andFieldEqual('userId', $params['userId']); } if (isset($params['provider'])) { $example->andFieldEqual('provider', $params['provider']); } else { $example->andFieldEqual('isUsed', 0); } if (isset($params['userId']) && empty($params['provider'])) { // check queues $emails = YNCONTACTIMPORTER_BOL_PendingService::getInstance()->getAllPendingEmailsByUserId(array('userId' => $params['userId'])); $socials = YNSOCIALBRIDGE_BOL_QueueService::getInstance()->getQueuesByUserId(array('userId' => $params['userId'], 'type' => 'sendInvite')); $friendIds = array(); foreach ($emails as $email) { $friendIds[] = $email['recipientEmail']; } foreach ($socials as $social) { $arr_id = $arr = explode('/', $social['id']); $friendIds[] = $arr_id[0]; } if ($friendIds) { $example->andFieldNotInArray('friendId', $friendIds); } } if (isset($params['search']) && $params['search']) { $example->andFieldLike('friendId', "%" . $params['search'] . "%"); } $example->setOrder("`sentTime` DESC"); return $this->findListByExample($example); }
/** * get statistics * @param array $params * @return array YNCONTACTIMPORTER_BOL_Statistic */ public function getStatistics($params = array()) { $userId = OW::getUser()->getId(); $total_queue_mail = YNCONTACTIMPORTER_BOL_PendingService::getInstance()->countPendingEmailsByUserId(array('userId' => $userId)); $total_queue_message = YNSOCIALBRIDGE_BOL_QueueService::getInstance()->countQueuesByUserId(array('userId' => $userId, 'type' => 'sendInvite')); $total_remain = $total_queue_mail + $total_queue_message; $total_sent = 0; $statistic = $this->statisticDao->findByUserId($userId); if ($statistic) { $total_sent = $statistic->totalSent - $total_remain; } $total_joined = $this->joinedDao->getTotalJoined($userId); return array('sent' => $total_sent, 'remain' => $total_remain, 'joined' => $total_joined); }
public function emailQueue() { $this->menu->getElement('2')->setActive(true); OW::getDocument()->setTitle(OW::getLanguage()->text('yncontactimporter', 'meta_title_invite_queue_email')); 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; } if (OW::getRequest()->isPost()) { try { foreach ($_POST as $key => $val) { if (strpos($key, 'check_') !== false) { YNCONTACTIMPORTER_BOL_PendingService::getInstance()->deleteEmailById($val); } } } catch (Exception $e) { } } $userId = OW::getUser()->getId(); $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_PendingService::getInstance()->getAllPendingEmailsByUserId($params); $itemsCount = YNCONTACTIMPORTER_BOL_PendingService::getInstance()->countPendingEmailsByUserId($params); $this->assign('emails', $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')); }