function onAfterInitialise() { $mainframe = JFactory::getApplication(); if ($mainframe->isAdmin()) { return; } $cron = JRequest::getInt('jasocial_feed_cron', 0); $next_run = $this->getNextRun(); $jatoken = JRequest::getInt('jatoken', 0); $last_run = isset($this->aInfo['last_run']) ? $this->aInfo['last_run'] : 0; $cron_interval = $this->plgParams->get('cache_time', 3600); $diff = $last_run - $jatoken; $isRunbyadmin = $diff >= 0 && $diff <= $cron_interval ? 1 : 0; if ($next_run > time() && !$isRunbyadmin) { return; } if (!$cron) { $document = JFactory::getDocument(); $script = "\r\n\t\t\tfunction jaGetSocialFeed() {\r\n\t\t\t\tvar jaSocialFeedReq = new Request({method: 'get', url: '" . JURI::root() . "/?jasocial_feed_cron=1'}).send();\r\n\t\t\t}\r\n\t\t\twindow.addEvent('load', function() {\r\n\t\t\t\tsetTimeout('jaGetSocialFeed()', 1000);\r\n\t\t\t});\r\n\t\t\t"; $document->addScriptDeclaration($script); } else { ignore_user_abort(true); require_once dirname(__FILE__) . '/helpers.php'; //update last run info to limit other people call request to get feed $this->updateCacheInfo(1); //order descreasing by processing speed $sources = array('vimeo', 'youtube', 'flickr', 'instagram', 'facebook', 'twitter'); foreach ($sources as $source) { $method = 'fetch' . ucfirst($source) . 'Post'; $profiles = jaSocialFeedGetProfiles($source); if (count($profiles)) { foreach ($profiles as $profile => $pName) { $data = jaSocialFeedGetProfile($source, $profile); if (is_object($data)) { $status = $this->getProperty($data, $source . '_status', 1); if ($status) { call_user_func_array(array($this, $method), array($data)); } } } } } jexit('done'); } return; }
<?php /** * ------------------------------------------------------------------------ * JA System Social Feed Plugin for J25 & J3.2 * ------------------------------------------------------------------------ * Copyright (C) 2004-2011 J.O.O.M Solutions Co., Ltd. All Rights Reserved. * @license - GNU/GPL, http://www.gnu.org/licenses/gpl.html * Author: J.O.O.M Solutions Co., Ltd * Websites: http://www.joomlart.com - http://www.joomlancers.com * ------------------------------------------------------------------------ */ // no direct access defined('_JEXEC') or die('Restricted access'); $profiles = jaSocialFeedGetProfiles($source); ?> <script type="text/javascript"> /*<![CDATA[*/ window.addEvent('load', function (e){ initProfiles('<?php echo $source; ?> '); }); /*]]>*/ </script> <ul id="list-profiles-<?php echo $source; ?> " class="ja-profile-titles"> <?php
function delete_profile() { $source = JRequest::getVar('profile_source'); $profile = JRequest::getString('profile'); $this->check_profile($source, $profile); if ($profile == 'default') { $this->doResponse(null, 0, JText::_('You can not delete Default profile!')); } $listProfiles = jaSocialFeedGetProfiles($source); $numProfiles = count($listProfiles); if (isset($listProfiles['default'])) { $numProfiles = $numProfiles - 1; } if ($numProfiles <= 1) { $this->doResponse(null, 0, JText::_('Failed Deleted! You must have at least one profile!')); } $path = PLG_JASOCIALFEED_PATH . 'profiles/' . $source . '/' . $profile . '.json'; if (!JFile::exists($path)) { $this->doResponse(null, 0, JText::_('Profile is not exists!')); } $result = JFile::delete($path); if ($result) { $result = new stdClass(); $result->source = $source; $result->profile = $profile; $this->doResponse($result, 1, JText::sprintf('Successfully deleted profile: %s!', $profile)); } else { $this->doResponse(null, 0, JText::sprintf('Failed deleted profile: %s!', $profile)); } }