Ejemplo n.º 1
0
 /**
  * getInstance
  *
  * @return	Instance
  */
 public static function &getInstance()
 {
     if (!self::$_instance) {
         self::$_instance = new SharingHelper();
     }
     return self::$_instance;
 }
 /**
  * postQueuedMessages
  *
  * @param   integer  $max  Param
  *
  * @return	boolean
  */
 public function postQueuedMessages($max)
 {
     $now = JFactory::getDate();
     $logger = AutotweetLogger::getInstance();
     if (AUTOTWEETNG_JOOCIAL && !VirtualManager::getInstance()->isWorking($now)) {
         $logger->log(JLog::INFO, 'AutotweetPostHelper - VM not working now ' . $now->toISO8601(true));
         return false;
     }
     // Get msgs from queue (sending is allowed only, when publish date is not in the future)
     // Sub 1 minute to avoid problems when automator plugin and extension plugin are executed at the same time...
     $check_date = $now->toUnix();
     // Sub 1 minute check
     $mincheck_time_intval = EParameter::getComponentParam(CAUTOTWEETNG, 'mincheck_time_intval', 60);
     $check_date = $check_date - $mincheck_time_intval;
     $check_date = JFactory::getDate($check_date);
     $requests = RequestHelp::getRequestList($check_date, $max);
     $sharingHelper = SharingHelper::getInstance();
     $logger->log(JLog::INFO, 'postQueuedMessages Requests: ' . count($requests));
     foreach ($requests as $request) {
         $result = false;
         $message = null;
         try {
             $result = $sharingHelper->publishRequest($request);
         } catch (Exception $e) {
             $message = $e->getMessage();
             $logger->log(JLog::ERROR, 'postQueuedMessages: Exception! ' . $message);
         }
         if ($result) {
             RequestHelp::processed($request->id);
         } else {
             RequestHelp::saveError($request->id, $message);
         }
     }
     if (AUTOTWEETNG_JOOCIAL && empty($requests)) {
         $logger->log(JLog::INFO, 'VirtualManager: anything else to publish?');
         VirtualManager::getInstance()->enqueueEvergreenMessage($check_date, $max);
     }
 }
Ejemplo n.º 3
0
 /**
  * publishRequests
  *
  * @param   array  &$requests  Param
  *
  * @return	boolean
  */
 public static function publishRequests(&$requests)
 {
     JLoader::register('SharingHelper', JPATH_AUTOTWEET_HELPERS . '/sharing.php');
     $sharinghelper = SharingHelper::getInstance();
     foreach ($requests as $request) {
         try {
             if ($sharinghelper->publishRequest($request)) {
                 // Remove only, when post is logged successfully
                 self::processed($request->id);
             } else {
                 self::saveError($request->id);
             }
         } catch (Exception $e) {
             $message = $e->getMessage();
             self::saveError($request->id, $message);
         }
     }
     return true;
 }
Ejemplo n.º 4
0
 /**
  * publishCronjobPosts
  *
  * @param   int  $limit  Param
  *
  * @return	boolean
  */
 public static function publishCronjobPosts($limit)
 {
     $postsModel = F0FModel::getTmpInstance('Posts', 'AutoTweetModel');
     $postsModel->set('pubstate', AutotweetPostHelper::POST_CRONJOB);
     $postsModel->set('filter_order', 'postdate');
     $postsModel->set('filter_order_Dir', 'ASC');
     $postsModel->set('limit', $limit);
     $posts = $postsModel->getItemList();
     $sharingHelper = SharingHelper::getInstance();
     $logger = AutotweetLogger::getInstance();
     $logger->log(JLog::INFO, 'publishCronjobPosts Posts: ' . count($posts));
     foreach ($posts as $post) {
         $logger->log(JLog::INFO, 'Sending Post ID: ' . $post->id . ' Channel: ' . $post->channel_id . ' Plugin: ' . $post->plugin);
         $post->xtform = EForm::paramsToRegistry($post);
         $sharingHelper->publishPost($post);
     }
 }