Ejemplo n.º 1
0
 /**
  * @param $modelname
  *
  * @internal param string $encoding
  *
  * @return string
  */
 public function run($modelname)
 {
     // Set up an independent AJAX error handler
     set_error_handler(array($this, 'error_handler'));
     set_exception_handler(array($this, 'exception_handler'));
     while (@ob_end_clean()) {
     }
     // clean any pending output buffers
     ob_start();
     // start a fresh one
     try {
         $container = RokUpdater_ServiceProvider::getInstance();
         $model_container_name = self::DEFAULT_MODEL_CONTEXT_PREFIX . strtolower($modelname);
         /** @var RokUpdater_Ajax_IModel $model */
         $model = $container->{$model_container_name};
         // set the result to the run
         $result = $model->run();
     } catch (Exception $ae) {
         $result = new stdClass();
         $result->status = "error";
         $result->message = $ae->getMessage();
         $result = json_encode($result);
     }
     // restore normal error handling;
     restore_error_handler();
     restore_exception_handler();
     return $result;
 }
Ejemplo n.º 2
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new RokUpdater_ServiceProvider();
     }
     return self::$instance;
 }
Ejemplo n.º 3
0
 public function __construct($form = null)
 {
     if (!defined('ROKUPDATER_ROOT_PATH')) {
         define('ROKUPDATER_ROOT_PATH', JPATH_PLUGINS . '/system/rokupdater/');
     }
     require_once ROKUPDATER_ROOT_PATH . '/lib/include.php';
     $this->container = RokUpdater_ServiceProvider::getInstance();
     parent::__construct($form);
 }
Ejemplo n.º 4
0
 public function __construct(&$subject, $config = array())
 {
     parent::__construct($subject, $config);
     if (!defined('ROKUPDATER_ROOT_PATH')) {
         define('ROKUPDATER_ROOT_PATH', JPATH_PLUGINS . '/system/rokupdater/');
     }
     require_once dirname(__FILE__) . '/lib/include.php';
     JLog::addLogger(array('text_file' => 'rokupdater.php'), $this->params->get('debugloglevel', 63), array('rokupdater'));
     $this->container = RokUpdater_ServiceProvider::getInstance();
     $lang = JFactory::getLanguage();
     $lang->load('plg_system_rokupdater', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false);
     $lang->load('plg_system_rokupdater', JPATH_ADMINISTRATOR, null, false, false);
     $lang->load('plg_system_rokupdater', dirname(__FILE__), $lang->getDefault(), false, false);
     $lang->load('plg_system_rokupdater', dirname(__FILE__), null, false, false);
 }
Ejemplo n.º 5
0
 /**
  *
  */
 public function run()
 {
     $container = RokUpdater_ServiceProvider::getInstance();
     $user = JFactory::getUser();
     $result = new stdClass();
     $result->status = "error";
     $result->message = "";
     $lang = JFactory::getLanguage();
     $lang->load('plg_system_rokupdater', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false);
     $lang->load('plg_system_rokupdater', JPATH_ADMINISTRATOR, null, false, false);
     $lang->load('plg_system_rokupdater', JPATH_PLUGINS . '/system/rokupdater', $lang->getDefault(), false, false);
     $lang->load('plg_system_rokupdater', JPATH_PLUGINS . '/system/rokupdater', null, false, false);
     try {
         // Check for
         if ($user->id == 0 || !$user->authorise('core.manage', 'com_installer')) {
             throw new RokUpdater_Exception('ROKUPDATER_INVALID_ACCESS');
         }
         $input = JFactory::getApplication()->input;
         $username = $input->post->get('userid', null, 'STRING');
         $password = $input->post->get('pswrd', null, 'STRING');
         if (empty($username) || empty($password)) {
             throw new RokUpdater_Exception('ROKUPDATER_ERROR_NEED_USERNAME_AND_PASSSWORD');
         }
         $result = $container->messageservice->requestAccessToken($username, $password, $container->site_id);
         if ($result->getStatus() !== RokUpdater_Message_RequestStatus::SUCCESS) {
             throw new RokUpdater_Exception($result->getMessage());
         }
         // store the access token info to the extension data
         $container->storageservice->storeSubscriberInfo(RokUpdater_Subscriber_Factory::createFromOAuthAccessTokenResponse($result));
         // update the update_site urls with the current access token
         $container->storageservice->updateAccessToken($container->site_id, $result->getOauthInfo()->getAccessToken());
         // refresh the updates
         $container->storageservice->forceUpdatesRefresh();
         $result->status = 'success';
         $result->message = JText::_('ROKUPDATER_SUCCESS_LOGIN_MESSAGE');
     } catch (RokUpdater_Exception $roe) {
         $result->status = 'error';
         $result->message = JText::_($roe->getMessage());
     }
     return json_encode($result);
 }
Ejemplo n.º 6
0
 public function run()
 {
     $container = RokUpdater_ServiceProvider::getInstance();
     $user = JFactory::getUser();
     $conf = JFactory::getConfig();
     $result = new stdClass();
     $result->status = "error";
     $result->message = "";
     $lang = JFactory::getLanguage();
     $lang->load('plg_system_rokupdater', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false);
     $lang->load('plg_system_rokupdater', JPATH_ADMINISTRATOR, null, false, false);
     $lang->load('plg_system_rokupdater', dirname(__FILE__) . '/../', $lang->getDefault(), false, false);
     $lang->load('plg_system_rokupdater', dirname(__FILE__) . '/../', null, false, false);
     try {
         // Check for
         if ($user->id == 0 || !$user->authorise('core.manage', 'com_installer')) {
             throw new RokUpdater_Exception('ROKUPDATER_INVALID_ACCESS');
         }
         // store the access token info to the extension data
         $subscriber_info = $container->storageservice->getSubscriberInfo();
         if (null != $subscriber_info) {
             try {
                 $container->messageservice->requestLogout($subscriber_info->getUsername(), $subscriber_info->getAccessToken(), $subscriber_info->getRefreshToken(), $container->site_id);
             } catch (Exception $e) {
             }
         }
         $container->storageservice->updateAccessToken($container->site_id);
         $container->storageservice->removeSubscriberInfo();
         $container->storageservice->forceUpdatesRefresh();
         $result->status = 'success';
     } catch (RokUpdater_Exception $roe) {
         $result->status = 'error';
         $result->message = JText::_($roe->getMessage());
     }
     echo json_encode($result);
 }
 public function __construct($reader = null)
 {
     $this->container = RokUpdater_ServiceProvider::getInstance();
     parent::__construct($reader);
     // TODO: Change the autogenerated stub
 }
Ejemplo n.º 8
0
ob_end_clean();
// Now that you have it, use jimport to get the specific packages your application needs.
jimport('joomla.environment.uri');
jimport('joomla.utilities.date');
jimport('joomla.utilities.utility');
jimport('joomla.event.dispatcher');
jimport('joomla.utilities.arrayhelper');
jimport('joomla.user.user');
//It's an application, so let's get the application helper.
jimport('joomla.application.helper');
$app = JFactory::getApplication('administrator');
$app->initialise();
// no direct access
defined('_JEXEC') or die('Restricted access');
require_once dirname(__FILE__) . '/lib/include.php';
$container = RokUpdater_ServiceProvider::getInstance();
/** @var RokUpdater_Ajax $ajax_handler */
$ajax_handler = $container->ajax_handler;
$input = $app->input;
try {
    $model = $input->get('ajax_model', null, 'word');
    if (null == $model) {
        throw new RokUpdater_Exception('No Ajax Model passed.');
    }
    $results = $ajax_handler->run($model);
    if ($results !== false) {
        echo $results;
    }
} catch (Exception $e) {
    $result = new RokCommon_Ajax_Result();
    $result->setAsError();