コード例 #1
0
 /**
  * Redirects the hook call to plugin path
  *
  * @return void
  */
 function redirectToPlugin()
 {
     $c = new RequestHelp($this);
     $um = UserManager::instance();
     $user = $um->getCurrentUser();
     $ignoreLabs = $this->getProperty('ignore_labs');
     if ($user->isLoggedIn() && ($ignoreLabs || $user->useLabFeatures())) {
         $c->redirect($this->getPluginPath() . '/');
         exit;
     }
 }
コード例 #2
0
 /**
  * insertRequest
  *
  * @param   int     $ref_id            Param
  * @param   string  $plugin            Param
  * @param   date    $publish_up        Param
  * @param   string  $description       Param
  * @param   int     $typeinfo          Param
  * @param   string  $url               Param
  * @param   string  $image_url         Param
  * @param   json    &$native_object    Param
  * @param   object  &$advanced_attrs   Param
  * @param   object  &$params           Param
  * @param   string  $content_language  Param
  *
  * @return	mixed (bool or request Id)
  */
 public static function insertRequest($ref_id, $plugin, $publish_up, $description, $typeinfo = 0, $url = '', $image_url = '', &$native_object = null, &$advanced_attrs = null, &$params = null, $content_language = null)
 {
     if ($publish_up == 0) {
         $publish_up = JFactory::getDate()->toSql();
     }
     if ($advanced_attrs) {
         if (!empty($advanced_attrs->description)) {
             $description = $advanced_attrs->description;
         }
         if (!empty($advanced_attrs->hashtags)) {
             $description .= ' ' . $advanced_attrs->hashtags;
         }
         if ($advanced_attrs->postthis == PlgAutotweetBase::POSTTHIS_NO) {
             // Post this or not
             return null;
         }
         if (($image = $advanced_attrs->image) && !empty($image)) {
             // This image
             if ($image == 'none') {
                 $image_url = null;
             } else {
                 $image_url = $image;
             }
         }
         if (isset($advanced_attrs->image_url) && ($image = $advanced_attrs->image_url) && !empty($image)) {
             $image_url = $image;
         }
         if (($agenda = $advanced_attrs->agenda) && count($agenda) > 0) {
             // The first date, it's the next date
             $publish_up = AdvancedattrsHelper::getNextAgendaDate($agenda);
             if (empty($publish_up)) {
                 $logger = AutotweetLogger::getInstance();
                 $logger->log(JLog::INFO, 'insertRequest: ref_id=' . $ref_id . ' - No Next Agenda Date.');
                 return false;
             }
         }
     }
     $result = RequestHelp::insertRequest($ref_id, $plugin, $publish_up, $description, $typeinfo, $url, $image_url, $native_object, $advanced_attrs, $params, $content_language);
     return $result;
 }
コード例 #3
0
ファイル: sharing.php プロジェクト: johngrange/wookeyholeweb
 /**
  * _getContentData
  *
  * @param   array  &$request  Param
  *
  * @return	data
  */
 public function _getContentData(&$request)
 {
     $this->logger->log(JLog::INFO, '_getContentData', $request);
     // Get source plugin for message
     // Gets the plugin that has triggered the message
     $pluginsModel = F0FModel::getTmpInstance('Plugins', 'AutoTweetModel');
     $plugin = $pluginsModel->createPlugin($request->plugin);
     if (empty($plugin)) {
         $this->logger->log(JLog::WARNING, 'publishRequest: unknown plugin. Source: ' . $request->plugin);
         $post = $request;
     } else {
         $plugin->setMessage($request->description);
         $request->xtform = EForm::paramsToRegistry($request);
         $plugin->setHashtags($request->xtform->get('hashtags', ''));
         // Get data from plugin
         if (method_exists($plugin, 'getExtendedData')) {
             if (!isset($request->native_object) && isset($request->params)) {
                 $request->native_object = $request->params;
             }
             $data = $plugin->getExtendedData($request->ref_id, $request->typeinfo, $request->native_object);
         } else {
             $data = $plugin->getData($request->ref_id, $request->typeinfo);
         }
     }
     // Check if post is valid to avoid spam; if not remove post from queue
     if (empty($data) || !array_key_exists('is_valid', $data) || !$data['is_valid']) {
         $this->logger->log(JLog::ERROR, 'publishRequest: message not valid (spam or technical problem - old plugin?), queue id = ' . $request->id);
         RequestHelp::saveError($request->id, 'COM_AUTOTWEET_ERROR_PUBLISHREQUEST');
         return null;
     }
     $data['autopublish'] = $plugin->isAutopublish();
     $data['show_url'] = $plugin->getShowUrlMode();
     return $data;
 }
コード例 #4
0
ファイル: requests.php プロジェクト: johngrange/wookeyholeweb
 /**
  * moveToState
  *
  * @param   int  $published  Param
  *
  * @return	string
  */
 public function moveToState($published)
 {
     JLoader::register('RequestHelp', JPATH_AUTOTWEET_HELPERS . '/request.php');
     if (is_array($this->id_list) && !empty($this->id_list)) {
         if (empty($user)) {
             $oUser = JFactory::getUser();
             $userid = $oUser->id;
         }
         if (!RequestHelp::moveToState($this->id_list, $userid, $published)) {
             $this->setError('Requests::moveToState failed');
             return false;
         }
     }
     return true;
 }
コード例 #5
0
 /**
  * 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);
     }
 }