Exemplo n.º 1
0
 private function initialise()
 {
     static $loaded = false;
     if (!$loaded || true) {
         defined('DS') || define('DS', DIRECTORY_SEPARATOR);
         require_once JPATH_SITE . '/components/com_sobipro/lib/sobi.php';
         Sobi::Initialise();
         if (SOBI_CMS == 'joomla3') {
             SPFactory::header()->initBase(true)->addJsFile(array('sobipro', 'jqnc', 'adm.sobipro', 'adm.jnmenu', 'jquery-base64'));
         } else {
             SPFactory::header()->initBase(true)->addJsFile(array('sobipro', 'jquery', 'adm.sobipro', 'adm.jnmenu', 'jquery-migrate', 'jquery-base64'))->addCSSCode('#toolbar-box { display: block }');
         }
         $loaded = true;
         SPLoader::loadClass('mlo.input');
         SPLoader::loadClass('models.datamodel');
         SPLoader::loadClass('models.dbobject');
         SPLoader::loadModel('section');
         $model = JModelLegacy::getInstance('MenusModelItem')->getItem();
         self::$mid = $model->id;
         if (isset($model->params['SobiProSettings']) && strlen($model->params['SobiProSettings'])) {
             $this->params = json_decode(base64_decode($model->params['SobiProSettings']));
         }
         $jsString = json_encode(array('component' => Sobi::Txt('SOBI_NATIVE_TASKS'), 'buttonLabel' => Sobi::Txt('SOBI_SELECT_FUNCTIONALITY')));
         SPFactory::header()->addJsCode("SpStrings = {$jsString}; ");
     }
 }
Exemplo n.º 2
0
 public function execute($argv)
 {
     Sobi::Initialise();
     $continue = $this->parseParameters($argv);
     if ($continue) {
         if (!$this->section) {
             $this->sections = SPFactory::db()->select('id', 'spdb_object', array('oType' => 'section', 'state' => '1', '@VALID' => SPFactory::db()->valid('validUntil', 'validSince')))->loadResultArray();
         } else {
             $this->sections = SPFactory::db()->select('id', 'spdb_object', array('id' => $this->section, 'oType' => 'section', 'state' => '1', '@VALID' => SPFactory::db()->valid('validUntil', 'validSince')))->loadResultArray();
         }
         if (!$this->liveURL || !preg_match('/http[s]?:\\/\\/.*/i', $this->liveURL)) {
             $this->out('[ERROR] A valid live URL address is required');
         }
         if (count($this->sections)) {
             $this->start = time();
             foreach ($this->sections as $sid) {
                 $this->crawlSobiSection($sid);
             }
         } else {
             $this->out('[ERROR] No valid sections found');
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Called whenever the administrator asks to refresh integration status.
  *
  * @param $user_id int The Joomla! user ID to refresh information for.
  */
 public function onAKUserRefresh($user_id)
 {
     static $hasZoo = null;
     static $hasK2 = null;
     static $hasSobipro = null;
     if (is_null($hasZoo) || is_null($hasK2) || is_null($hasSobipro)) {
         JLoader::import('joomla.filesystem.folder');
         $hasZoo = JFolder::exists(JPATH_ADMINISTRATOR . '/components/com_zoo');
         $hasK2 = JFolder::exists(JPATH_ADMINISTRATOR . '/components/com_k2');
         $hasSobipro = JFolder::exists(JPATH_ADMINISTRATOR . '/components/com_sobipro');
         if (@(include_once JPATH_ROOT . '/components/com_sobipro/lib/sobi.php')) {
             if (!method_exists('Sobi', 'Initialise')) {
                 // We require SOBIPro 1.1 or later
                 $hasSobipro = false;
             }
         } else {
             $hasSobipro = false;
         }
     }
     // Get all of the user's subscriptions
     $subscriptions = F0FModel::getTmpInstance('Subscriptions', 'AkeebasubsModel')->user_id($user_id)->getList();
     // Make sure there are subscriptions set for the user
     if (!count($subscriptions)) {
         return;
     }
     // Get active/inactive subscription level IDs
     $active = array();
     foreach ($subscriptions as $subscription) {
         if (!$subscription->enabled) {
             continue;
         }
         if (!in_array($subscription->akeebasubs_level_id, $active)) {
             $active[] = $subscription->akeebasubs_level_id;
         }
     }
     $inactive = array();
     foreach ($subscriptions as $subscription) {
         if ($subscription->enabled) {
             continue;
         }
         if (!in_array($subscription->akeebasubs_level_id, $active)) {
             $inactive[] = $subscription->akeebasubs_level_id;
         }
     }
     $db = JFactory::getDbo();
     // Unpublish articles for inactive subscriptions
     if (!empty($inactive)) {
         foreach ($inactive as $level_id) {
             if (array_key_exists($level_id, $this->unpublishCore)) {
                 if ($this->unpublishCore[$level_id]) {
                     // Unpublish core articles
                     $query = $db->getQuery(true)->update($db->qn('#__content'))->set($db->qn('state') . ' = ' . $db->q('0'))->where($db->qn('created_by') . ' = ' . $db->q($user_id))->where($db->qn('state') . ' <= ' . $db->q('1'));
                     $db->setQuery($query);
                     $db->execute();
                 }
             }
             if (array_key_exists($level_id, $this->unpublishK2) && $hasK2) {
                 if ($this->unpublishK2[$level_id]) {
                     // Unpublish K2 items
                     $query = $db->getQuery(true)->update($db->qn('#__k2_items'))->set($db->qn('published') . ' = ' . $db->q('0'))->where($db->qn('created_by') . ' = ' . $db->q($user_id));
                     $db->setQuery($query);
                     $db->execute();
                 }
             }
             if (array_key_exists($level_id, $this->unpublishSobipro) && $hasSobipro) {
                 if ($this->unpublishSobipro[$level_id]) {
                     if (!class_exists('Sobi')) {
                         @(include_once JPATH_ROOT . '/components/com_sobipro/lib/sobi.php');
                     }
                     if (class_exists('Sobi')) {
                         Sobi::Initialise();
                         // Unpublish SOBI Pro items
                         $query = $db->getQuery(true)->select($db->qn('id'))->from($db->qn('#__sobipro_object'))->where($db->qn('oType') . ' = ' . $db->q('entry'))->where($db->qn('owner') . ' = ' . $db->q($user_id))->where($db->qn('state') . ' = ' . $db->q(1));
                         $db->setQuery($query);
                         $ids = $db->loadColumn();
                         if (count($ids)) {
                             foreach ($ids as $id) {
                                 SPFactory::Entry($id)->unpublish();
                             }
                         }
                     }
                 }
             }
             if (array_key_exists($level_id, $this->unpublishZOO) && array_key_exists($level_id, $this->removeGroups) && $hasZoo) {
                 if ($this->unpublishZOO[$level_id]) {
                     $apps = $this->removeGroups[$level_id];
                     if (!empty($apps)) {
                         $temp = array();
                         foreach ($apps as $app) {
                             $temp[] = $db->q($app);
                         }
                         // Unpublish ZOO items
                         $query = $db->getQuery(true)->update($db->qn('#__zoo_item'))->set($db->qn('state') . ' = ' . $db->q('0'))->where($db->qn('created_by') . ' = ' . $db->q($user_id))->where($db->qn('state') . ' <= ' . $db->q('1'))->where($db->qn('application_id') . ' IN (' . implode(',', $temp) . ')');
                         $db->setQuery($query);
                         $db->execute();
                     }
                 }
             }
         }
     }
     // Publish articles for active subscriptions
     if (!empty($active)) {
         foreach ($active as $level_id) {
             if (array_key_exists($level_id, $this->publishCore)) {
                 if ($this->publishCore[$level_id]) {
                     // Publish core Joomla! articles
                     $query = $db->getQuery(true)->update($db->qn('#__content'))->set($db->qn('state') . ' = ' . $db->q('1'))->where($db->qn('created_by') . ' = ' . $db->q($user_id))->where($db->qn('state') . ' = ' . $db->q('0'));
                     $db->setQuery($query);
                     $db->execute();
                 }
             }
             if (array_key_exists($level_id, $this->publishK2) && $hasK2) {
                 if ($this->publishK2[$level_id]) {
                     // Publish K2 content
                     $query = $db->getQuery(true)->update($db->qn('#__k2_items'))->set($db->qn('published') . ' = ' . $db->q('1'))->where($db->qn('created_by') . ' = ' . $db->q($user_id))->where($db->qn('published') . ' = ' . $db->q('0'));
                     $db->setQuery($query);
                     $db->execute();
                 }
             }
             if (array_key_exists($level_id, $this->publishSobipro) && $hasSobipro) {
                 if ($this->publishSobipro[$level_id]) {
                     if (!class_exists('Sobi')) {
                         @(include_once JPATH_ROOT . '/components/com_sobipro/lib/sobi.php');
                     }
                     if (class_exists('Sobi')) {
                         Sobi::Initialise();
                         // Publish SOBI Pro items
                         $query = $db->getQuery(true)->select($db->qn('id'))->from($db->qn('#__sobipro_object'))->where($db->qn('oType') . ' = ' . $db->q('entry'))->where($db->qn('owner') . ' = ' . $db->q($user_id))->where($db->qn('state') . ' = ' . $db->q(0));
                         $db->setQuery($query);
                         $ids = $db->loadColumn();
                         if (count($ids)) {
                             foreach ($ids as $id) {
                                 SPFactory::Entry($id)->publish();
                             }
                         }
                     }
                 }
             }
             if (array_key_exists($level_id, $this->publishZOO) && array_key_exists($level_id, $this->addGroups) && $hasZoo) {
                 if ($this->publishZOO[$level_id]) {
                     $apps = $this->addGroups[$level_id];
                     if (!empty($apps)) {
                         $temp = array();
                         foreach ($apps as $app) {
                             $temp[] = $db->q($app);
                         }
                         // Publish ZOO items
                         $query = $db->getQuery(true)->update($db->qn('#__zoo_item'))->set($db->qn('state') . ' = ' . $db->q('1'))->where($db->qn('created_by') . ' = ' . $db->q($user_id))->where($db->qn('state') . ' = ' . $db->q('0'))->where($db->qn('application_id') . ' IN (' . implode(',', $temp) . ')');
                         $db->setQuery($query);
                         $db->execute();
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Plugin that returns the object list for DJ-Mediatools album
  * 
  * Each object must contain following properties (mandatory): title, description, image
  * Optional properties: link, target (_blank or _self), alt (alt attribute for image)
  * 
  * @param	object	The album params
  */
 public function onAlbumPrepare(&$source, &$params)
 {
     // Lets check the requirements
     $check = $this->onCheckRequirements($source);
     if (is_null($check) || is_string($check)) {
         return null;
     }
     $app = JFactory::getApplication();
     require_once JPATH_ROOT . '/components/com_sobipro/lib/sobi.php';
     Sobi::Initialise($params->get('section'));
     require_once dirname(__FILE__) . '/lib/emod.php';
     $emod = new SPEntriesDJMTCtrl();
     $default_image = $params->get('plg_sobipro_image');
     // create parameters for K2 content module helper
     $mparams = new JRegistry();
     $mparams->def('entriesLimit', $params->get('max_images'));
     $mparams->def('section', $params->get('section'));
     $mparams->def('cid', $params->get('cid'));
     $mparams->def('sid', $params->get('sid'));
     $mparams->def('autoListing', $params->get('plg_sobipro_autoListing'));
     $mparams->def('spOrder', $params->get('spOrder'));
     $mparams->def('spOrderDir', $params->get('spOrderDir'));
     $mparams->def('spLimit', $params->get('spLimit'));
     $mparams->def('engine', 'static');
     $items = $emod->getSourceEntries($mparams);
     $slides = array();
     //$this->debug($items);
     foreach ($items as $item) {
         $slide = (object) array();
         $slide->title = $item['name']['_data'];
         $slide->description = $item['fields']['field_short_description']['_data']['data']['_data'];
         $slide->image = $item['fields']['field_company_logo']['_data']['data']['_attributes']['image'];
         if (!$slide->image) {
             $slide->image = DJMediatoolsLayoutHelper::getImageFromText($slide->description);
         }
         if (!$slide->image) {
             $slide->image = $default_image;
         }
         // if no default image set then don't display this entry
         if (!$slide->image) {
             continue;
         }
         $slide->id = $item->id;
         $slide->canonical = $slide->link = $item['url'];
         if ($comments = $params->get('commnets', 0)) {
             $host = str_replace(JURI::root(true), '', JURI::root());
             $host = preg_replace('/\\/$/', '', $host);
             switch ($comments) {
                 case 1:
                     // jcomments
                     $slide->comments = array('id' => $item->id, 'group' => 'com_sobipro');
                     break;
                 case 2:
                     // disqus
                     $disqus_shortname = $params->get('disqus_shortname', '');
                     if (!empty($disqus_shortname)) {
                         $slide->comments = array();
                         $slide->comments['url'] = $host . $slide->link;
                         $slide->comments['identifier'] = substr(md5($disqus_shortname), 0, 10) . "_id" . $item->id;
                     }
                     break;
                 case 3:
                     // facebook
                     $slide->comments = $host . $slide->link;
                     break;
                 case 4:
                     //komento
                     // not implemented
                     break;
             }
         }
         $slides[] = $slide;
     }
     return $slides;
 }