Source for file update.php

Documentation is available at update.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_installer
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * Installer Update Controller
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_installer
  17.  * @since       1.6
  18.  */
  19. {
  20.     /**
  21.      * Update a set of extensions.
  22.      *
  23.      * @return  void 
  24.      *
  25.      * @since   1.6
  26.      */
  27.     public function update()
  28.     {
  29.         // Check for request forgeries
  30.         JSession::checkToken(or jexit(JText::_('JINVALID_TOKEN'));
  31.  
  32.         $model $this->getModel('update');
  33.         $uid   $this->input->get('cid'array()'array');
  34.  
  35.         JArrayHelper::toInteger($uidarray());
  36.         if ($model->update($uid))
  37.         {
  38.             $cache JFactory::getCache('mod_menu');
  39.             $cache->clean();
  40.         }
  41.  
  42.         $app JFactory::getApplication();
  43.         $redirect_url $app->getUserState('com_installer.redirect_url');
  44.         if (empty($redirect_url))
  45.         {
  46.             $redirect_url JRoute::_('index.php?option=com_installer&view=update'false);
  47.         }
  48.         else
  49.         {
  50.             // Wipe out the user state when we're going to redirect
  51.             $app->setUserState('com_installer.redirect_url''');
  52.             $app->setUserState('com_installer.message''');
  53.             $app->setUserState('com_installer.extension_message''');
  54.         }
  55.         $this->setRedirect($redirect_url);
  56.     }
  57.  
  58.     /**
  59.      * Find new updates.
  60.      *
  61.      * @return  void 
  62.      *
  63.      * @since   1.6
  64.      */
  65.     public function find()
  66.     {
  67.         // Check for request forgeries
  68.         JSession::checkToken(or jexit(JText::_('JINVALID_TOKEN'));
  69.  
  70.         // Get the caching duration
  71.         $component JComponentHelper::getComponent('com_installer');
  72.         $params $component->params;
  73.         $cache_timeout $params->get('cachetimeout'6'int');
  74.         $cache_timeout 3600 $cache_timeout;
  75.  
  76.         // Find updates
  77.         $model    $this->getModel('update');
  78.         $model->findUpdates(0$cache_timeout);
  79.         $this->setRedirect(JRoute::_('index.php?option=com_installer&view=update'false));
  80.     }
  81.  
  82.     /**
  83.      * Purges updates.
  84.      *
  85.      * @return  void 
  86.      *
  87.      * @since   1.6
  88.      */
  89.     public function purge()
  90.     {
  91.         // Purge updates
  92.         // Check for request forgeries
  93.         JSession::checkToken(or jexit(JText::_('JINVALID_TOKEN'));
  94.         $model $this->getModel('update');
  95.         $model->purge();
  96.         $model->enableSites();
  97.         $this->setRedirect(JRoute::_('index.php?option=com_installer&view=update'false)$model->_message);
  98.     }
  99.  
  100.     /**
  101.      * Fetch and report updates in JSON format, for AJAX requests
  102.      *
  103.      * @return void 
  104.      *
  105.      * @since 2.5
  106.      */
  107.     public function ajax()
  108.     {
  109.         /*
  110.          * Note: we don't do a token check as we're fetching information
  111.          * asynchronously. This means that between requests the token might
  112.          * change, making it impossible for AJAX to work.
  113.          */
  114.  
  115.         $eid  $this->input->getInt('eid'0);
  116.         $skip $this->input->get('skip'array()'array');
  117.  
  118.         $cache_timeout $this->input->getInt('cache_timeout'0);
  119.         if ($cache_timeout == 0)
  120.         {
  121.             $component JComponentHelper::getComponent('com_installer');
  122.             $params $component->params;
  123.             $cache_timeout $params->get('cachetimeout'6'int');
  124.             $cache_timeout 3600 $cache_timeout;
  125.         }
  126.  
  127.         $model $this->getModel('update');
  128.         $model->findUpdates($eid$cache_timeout);
  129.  
  130.         $model->setState('list.start'0);
  131.         $model->setState('list.limit'0);
  132.         if ($eid != 0)
  133.         {
  134.             $model->setState('filter.extension_id'$eid);
  135.         }
  136.         $updates $model->getItems();
  137.  
  138.         if (!empty($skip))
  139.         {
  140.             $unfiltered_updates $updates;
  141.             $updates array();
  142.             foreach ($unfiltered_updates as $update)
  143.             {
  144.                 if (!in_array($update->extension_id$skip))
  145.                 {
  146.                     $updates[$update;
  147.                 }
  148.             }
  149.         }
  150.         echo json_encode($updates);
  151.  
  152.         JFactory::getApplication()->close();
  153.     }
  154. }

Documentation generated on Tue, 19 Nov 2013 15:16:11 +0100 by phpDocumentor 1.4.3