Exemple #1
0
 /**
  * delete Token
  *
  * @param YNSOCIALBRIDGE_BOL_Token
  * @return void
  */
 public function delete(YNSOCIALBRIDGE_BOL_Token $tokenDto)
 {
     //get all Queues with this token
     YNSOCIALBRIDGE_BOL_QueueService::getInstance()->deleteQueuesByTokenId($tokenDto->id);
     $tokenDao = $this->tokenDao;
     return $tokenDao->delete($tokenDto);
 }
Exemple #2
0
 /**
  * Returns class instance
  *
  * @return YNSOCIALBRIDGE_BOL_QueueService
  */
 public static function getInstance()
 {
     if (!isset(self::$classInstance)) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Exemple #3
0
 /**
  * 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);
 }
Exemple #4
0
 public function queueProcess()
 {
     $queues = YNSOCIALBRIDGE_BOL_QueueService::getInstance()->getAllQueues();
     $core = new YNSOCIALBRIDGE_CLASS_Core();
     foreach ($queues as $queue) {
         switch ($queue->type) {
             case 'sendInvite':
                 $extra_params = unserialize($queue->extraParams);
                 $token = YNSOCIALBRIDGE_BOL_TokenService::getInstance()->findById($queue->tokenId);
                 $obj = $core->getInstance($queue->service);
                 $params['list'] = $extra_params['list'];
                 $params['link'] = $extra_params['link'];
                 $params['message'] = $extra_params['message'];
                 $params['uid'] = $token->uid;
                 $params['user_id'] = $queue->userId;
                 $params['access_token'] = $token->accessToken;
                 $params['secret_token'] = $token->secretToken;
                 echo ucfirst($queue->service) . ": " . $token->uid . ": Send invite successfully! ";
                 if ($obj->sendInvites($params)) {
                     echo " <br/>  ";
                     YNSOCIALBRIDGE_BOL_QueueService::getInstance()->delete($queue);
                 }
                 break;
             case 'getFeed':
                 $configs = OW::getConfig()->getValues('ynsocialstream');
                 if (isset($configs['get_feed_cron']) && $configs['get_feed_cron']) {
                     $service = $queue->service;
                     $token = YNSOCIALBRIDGE_BOL_TokenService::getInstance()->findById($queue->tokenId);
                     //get user & check authorized get feed
                     OW_User::getInstance()->login($token->userId);
                     if (!OW::getUser()->isAuthorized('ynsocialstream', 'get_feed')) {
                         break;
                     }
                     //check preferences
                     if (!$configs['enable_' . $service . '_' . $token->userId]) {
                         break;
                     }
                     if ($token && isset($configs['cron_job_user_' . $token->userId]) && $configs['cron_job_user_' . $token->userId]) {
                         $uid = $token->uid;
                         //get Feeds
                         $obj = $core->getInstance($service);
                         $feedService = YNSOCIALSTREAM_BOL_SocialstreamFeedService::getInstance();
                         $feedLast = $feedService->getFeedLast($service, $uid);
                         $arr_token = array('access_token' => $token->accessToken, 'secret_token' => $token->secretToken);
                         $arr_token['lastFeedTimestamp'] = 0;
                         if ($feedLast) {
                             $arr_token['lastFeedTimestamp'] = $feedLast['timestamp'];
                         }
                         $arr_token['limit'] = $configs['max_' . $service . '_get_feed'];
                         $arr_token['uid'] = $uid;
                         $arr_token['type'] = 'user';
                         $activities = $obj->getActivity($arr_token);
                         if ($activities != null) {
                             $obj->insertFeeds(array('activities' => $activities, 'user_id' => $token->userId, 'timestamp' => $arr_token['lastFeedTimestamp'], 'access_token' => $token->accessToken, 'secret_token' => $token->secretToken, 'uid' => $uid));
                         }
                         $queue->lastRun = date('Y-m-d H:i:s');
                         YNSOCIALBRIDGE_BOL_QueueService::getInstance()->save($queue);
                         echo ucfirst($service) . ": " . $token->uid . ": Get feed successfully!";
                         echo " <br/>  ";
                     }
                     OW_User::getInstance()->logout();
                 }
                 break;
             default:
                 break;
         }
     }
 }
Exemple #5
0
 public function getQueue($params)
 {
     return YNSOCIALBRIDGE_BOL_QueueService::getInstance()->getQueue($params);
 }
Exemple #6
0
 /**
  * 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);
 }
Exemple #7
0
 public function socialQueue()
 {
     $importUrl = OW::getRouter()->urlForRoute('yncontactimporter-import');
     if (!OW::getPluginManager()->isPluginActive('ynsocialbridge')) {
         $this->redirect($importUrl);
     }
     $this->menu->getElement('3')->setActive(true);
     OW::getDocument()->setTitle(OW::getLanguage()->text('yncontactimporter', 'meta_title_invite_queue_message'));
     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) {
                     YNSOCIALBRIDGE_BOL_QueueService::getInstance()->deleteContactById($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, 'type' => 'sendInvite', 'first' => $first, 'count' => $count, 'search' => $search);
     $list = YNSOCIALBRIDGE_BOL_QueueService::getInstance()->getQueuesByUserId($params);
     $itemsCount = YNSOCIALBRIDGE_BOL_QueueService::getInstance()->countQueuesByUserId($params);
     $tmp_list = array();
     foreach ($list as $value) {
         $arr_id = $arr = explode('/', $value['id']);
         $value['newId'] = $arr_id[0];
         $tmp_list[] = $value;
     }
     $this->assign('contacts', $tmp_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'));
 }