Ejemplo n.º 1
0
 protected function onAdd($tpl = null)
 {
     /** @var AkeebaModelCpanels $model */
     $model = $this->getModel();
     $aeconfig = Factory::getConfiguration();
     // Load the helper classes
     $this->loadHelper('utils');
     $this->loadHelper('status');
     $statusHelper = AkeebaHelperStatus::getInstance();
     // Load the model
     if (!class_exists('AkeebaModelStatistics')) {
         JLoader::import('models.statistics', JPATH_COMPONENT_ADMINISTRATOR);
     }
     $statmodel = new AkeebaModelStatistics();
     $this->profileid = $model->getProfileID();
     // Active profile ID
     $this->profilelist = $model->getProfilesList();
     // List of available profiles
     $this->statuscell = $statusHelper->getStatusCell();
     // Backup status
     $this->detailscell = $statusHelper->getQuirksCell();
     // Details (warnings)
     $this->statscell = $statmodel->getLatestBackupDetails();
     $this->fixedpermissions = $model->fixMediaPermissions();
     // Fix media/com_akeeba permissions
     $this->needsdlid = $model->needsDownloadID();
     $this->needscoredlidwarning = $model->mustWarnAboutDownloadIDInCore();
     $this->extension_id = $model->getState('extension_id', 0, 'int');
     // Should I ask for permission to display desktop notifications?
     JLoader::import('joomla.application.component.helper');
     $this->desktop_notifications = \Akeeba\Engine\Util\Comconfig::getValue('desktop_notifications', '0') ? 1 : 0;
     $this->statsIframe = F0FModel::getTmpInstance('Stats', 'AkeebaModel')->collectStatistics(true);
     return $this->onDisplay($tpl);
 }
Ejemplo n.º 2
0
	function display()
	{
		$selfhealModel = JModel::getInstance('Selfheal','AkeebaModel');
		$schemaok = $selfhealModel->healSchema();
		$this->assign('schemaok', $schemaok);		
		
		$registry =& AEFactory::getConfiguration();
		// Set the toolbar title; add a help button
		JToolBarHelper::title(JText::_('AKEEBA').':: <small>'.JText::_('AKEEBA_CONTROLPANEL').'</small>','akeeba');
		//JToolBarHelper::preferences('com_akeeba', '500', '660');

		if($schemaok) {
			// Add submenus (those nifty text links below the toolbar!)
			// -- Configuration
			$link = JURI::base().'index.php?option='.JRequest::getCmd('option').'&view=config';
			JSubMenuHelper::addEntry(JText::_('CONFIGURATION'), $link);

			// -- Backup Now
			$link = JURI::base().'index.php?option='.JRequest::getCmd('option').'&view=backup';
			JSubMenuHelper::addEntry(JText::_('BACKUP'), $link);
			// -- Administer Backup Files
			$link = JURI::base().'index.php?option='.JRequest::getCmd('option').'&view=buadmin';
			JSubMenuHelper::addEntry(JText::_('BUADMIN'), $link);
			// -- View log
			$link = JURI::base().'index.php?option='.JRequest::getCmd('option').'&view=log';
			JSubMenuHelper::addEntry(JText::_('VIEWLOG'), $link);

			// Load the helper classes
			$this->loadHelper('utils');
			$this->loadHelper('status');
			$statusHelper = AkeebaHelperStatus::getInstance();

			// Load the model
			akimport('models.statistics', true);
			$model =& $this->getModel();
			$statmodel = new AkeebaModelStatistics();

			$this->assign('icondefs', $model->getIconDefinitions()); // Icon definitions
			$this->assign('profileid', $model->getProfileID()); // Active profile ID
			$this->assign('profilelist', $model->getProfilesList()); // List of available profiles
			$this->assign('statuscell', $statusHelper->getStatusCell() ); // Backup status
			$this->assign('newscell', $statusHelper->getNewsCell() ); // News
			$this->assign('detailscell', $statusHelper->getQuirksCell() ); // Details (warnings)
			$this->assign('statscell', $statmodel->getLatestBackupDetails() );

			$this->assign('fixedpermissions', $model->fixMediaPermissions() ); // Fix media/com_akeeba permissions
			
			// Add live help
			AkeebaHelperIncludes::addHelp();
		}
		
		// Add references to CSS and JS files
		AkeebaHelperIncludes::includeMedia(false);

		parent::display();
	}
Ejemplo n.º 3
0
 protected function onAdd($tpl = null)
 {
     /** @var AkeebaModelCpanels $model */
     $model = $this->getModel();
     /**
     		$selfhealModel = F0FModel::getTmpInstance('Selfheal','AkeebaModel');
     		$schemaok = $selfhealModel->healSchema();
     		/**/
     $schemaok = true;
     $this->schemaok = $schemaok;
     $aeconfig = AEFactory::getConfiguration();
     if ($schemaok) {
         // Load the helper classes
         $this->loadHelper('utils');
         $this->loadHelper('status');
         $statusHelper = AkeebaHelperStatus::getInstance();
         // Load the model
         if (!class_exists('AkeebaModelStatistics')) {
             JLoader::import('models.statistics', JPATH_COMPONENT_ADMINISTRATOR);
         }
         $statmodel = new AkeebaModelStatistics();
         $this->icondefs = $model->getIconDefinitions();
         // Icon definitions
         $this->profileid = $model->getProfileID();
         // Active profile ID
         $this->profilelist = $model->getProfilesList();
         // List of available profiles
         $this->statuscell = $statusHelper->getStatusCell();
         // Backup status
         $this->detailscell = $statusHelper->getQuirksCell();
         // Details (warnings)
         $this->statscell = $statmodel->getLatestBackupDetails();
         $this->fixedpermissions = $model->fixMediaPermissions();
         // Fix media/com_akeeba permissions
         $this->update_plugin = $model->isUpdatePluginEnabled();
         $this->needsdlid = $model->needsDownloadID();
         $this->needscoredlidwarning = $model->mustWarnAboutDownloadIDInCore();
         $this->hasPostInstallationMessages = $model->hasPostInstallMessages();
         $this->extension_id = $model->getState('extension_id', 0, 'int');
         // Add live help
         AkeebaHelperIncludes::addHelp('cpanel');
         $this->statsIframe = F0FModel::getTmpInstance('Stats', 'AkeebaModel')->collectStatistics(true);
     }
     return $this->onDisplay($tpl);
 }
 protected function onAdd($tpl = null)
 {
     // Used in FOF 1.x where the behaviour was kinda clunky
     $model = $this->getModel();
     /**
     		$selfhealModel = FOFModel::getTmpInstance('Selfheal','AkeebaModel');
     		$schemaok = $selfhealModel->healSchema();
     		**/
     $schemaok = true;
     $this->schemaok = $schemaok;
     $aeconfig = AEFactory::getConfiguration();
     if ($schemaok) {
         // Load the helper classes
         $this->loadHelper('utils');
         $this->loadHelper('status');
         $statusHelper = AkeebaHelperStatus::getInstance();
         // Load the model
         if (!class_exists('AkeebaModelStatistics')) {
             JLoader::import('models.statistics', JPATH_COMPONENT_ADMINISTRATOR);
         }
         $statmodel = new AkeebaModelStatistics();
         //$model->applyJoomlaExtensionUpdateChanges();
         $this->icondefs = $model->getIconDefinitions();
         // Icon definitions
         $this->profileid = $model->getProfileID();
         // Active profile ID
         $this->profilelist = $model->getProfilesList();
         // List of available profiles
         $this->statuscell = $statusHelper->getStatusCell();
         // Backup status
         $this->detailscell = $statusHelper->getQuirksCell();
         // Details (warnings)
         $this->statscell = $statmodel->getLatestBackupDetails();
         $this->fixedpermissions = $model->fixMediaPermissions();
         // Fix media/com_akeeba permissions
         $this->needsdlid = $model->needsDownloadID();
         $this->needscoredlidwarning = $model->mustWarnAboutDownloadIDInCore();
         // Add live help
         AkeebaHelperIncludes::addHelp('cpanel');
     }
     return $this->onDisplay($tpl);
 }
Ejemplo n.º 5
0
    public function onBrowse($tpl = null)
    {
        $session = JFactory::getSession();
        $task = $session->get('buadmin.task', 'default', 'akeeba');
        if ($task != 'restorepoint') {
            $task = 'default';
        }
        $aeconfig = AEFactory::getConfiguration();
        // Add custom submenus
        if (AKEEBA_PRO) {
            $toolbar = F0FToolbar::getAnInstance($this->input->get('option', 'com_foobar', 'cmd'), $this->config);
            $toolbar->appendLink(JText::_('BUADMIN_LABEL_BACKUPS'), JURI::base() . 'index.php?option=com_akeeba&view=buadmin&task=browse', $task == 'default');
            $toolbar->appendLink(JText::_('BUADMIN_LABEL_SRP'), JURI::base() . 'index.php?option=com_akeeba&view=buadmin&task=restorepoint', $task == 'restorepoint');
        }
        if (AKEEBA_PRO && $task == 'default') {
            $bar = JToolBar::getInstance('toolbar');
            $bar->appendButton('Link', 'restore', JText::_('DISCOVER'), 'index.php?option=com_akeeba&view=discover');
            JToolBarHelper::publish('restore', JText::_('STATS_LABEL_RESTORE'));
        }
        if ($task == 'default') {
            JToolBarHelper::editList('showcomment', JText::_('STATS_LOG_EDITCOMMENT'));
            $pModel = F0FModel::getTmpInstance('Profiles', 'AkeebaModel');
            $enginesPerPprofile = $pModel->getPostProcessingEnginePerProfile();
            $this->enginesPerProfile = $enginesPerPprofile;
        }
        JToolBarHelper::spacer();
        // "Show warning first" download button. Joomlantastic!
        $confirmationText = AkeebaHelperEscape::escapeJS(JText::_('STATS_LOG_DOWNLOAD_CONFIRM'), "'\n");
        $baseURI = JURI::base();
        $js = <<<JS

// This comment is intentionally put here to prevent badly written plugins from causing a Javascript error
// due to missing trailing semicolon and/or newline in their code.
function confirmDownloadButton()
{
\tvar answer = confirm('{$confirmationText}');
\tif(answer) submitbutton('download');
}

function confirmDownload(id, part)
{
\tvar answer = confirm('{$confirmationText}');
\tvar newURL = '{$baseURI}';
\tif(answer) {
\t\tnewURL += 'index.php?option=com_akeeba&view=buadmin&task=download&id='+id;
\t\tif( part != '' ) newURL += '&part=' + part
\t\twindow.location = newURL;
\t}
}

JS;
        $document = JFactory::getDocument();
        $document->addScriptDeclaration($js);
        $hash = 'akeebabuadmin';
        // ...ordering
        $app = JFactory::getApplication();
        $this->lists->set('order', $app->getUserStateFromRequest($hash . 'filter_order', 'filter_order', 'backupstart'));
        $this->lists->set('order_Dir', $app->getUserStateFromRequest($hash . 'filter_order_Dir', 'filter_order_Dir', 'DESC'));
        // ...filter state
        $this->lists->set('fltDescription', $app->getUserStateFromRequest($hash . 'filter_description', 'description', null));
        $this->lists->set('fltFrom', $app->getUserStateFromRequest($hash . 'filter_from', 'from', null));
        $this->lists->set('fltTo', $app->getUserStateFromRequest($hash . 'filter_to', 'to', null));
        $this->lists->set('fltOrigin', $app->getUserStateFromRequest($hash . 'filter_origin', 'origin', null));
        $this->lists->set('fltProfile', $app->getUserStateFromRequest($hash . 'filter_profile', 'profile', null));
        $filters = $this->_getFilters();
        $ordering = $this->_getOrdering();
        require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/statistics.php';
        $model = new AkeebaModelStatistics();
        $list = $model->getStatisticsListWithMeta(false, $filters, $ordering);
        // Assign data to the view
        $this->lists = $this->lists;
        // Filter lists
        $this->list = $list;
        // Data
        $this->pagination = $model->getPagination($filters);
        // Pagination object
        // Add live help
        if ($task == 'restorepoint') {
            $this->setLayout('restorepoint');
            AkeebaHelperIncludes::addHelp('restorepoint');
        } else {
            AkeebaHelperIncludes::addHelp('buadmin');
        }
        return true;
    }
Ejemplo n.º 6
0
	public function display()
	{
		$task = JRequest::getCmd('task','default');

		switch($task)
		{
			case 'showcomment':
				JToolBarHelper::title(JText::_('AKEEBA').': <small>'.JText::_('BUADMIN').'</small>','akeeba');
				JToolBarHelper::back('AKEEBA_CONTROLPANEL', 'index.php?option='.JRequest::getCmd('option'));
				JToolBarHelper::save();
				JToolBarHelper::cancel();
				$document =& JFactory::getDocument();
				$document->addStyleSheet(JURI::base().'../media/com_akeeba/theme/akeebaui.css?'.AKEEBAMEDIATAG);

				$id = JRequest::getInt('id',0);
				$record = AEPlatform::get_statistics($id);
				$this->assign('record', $record);
				$this->assign('record_id', $id);

				JRequest::setVar('tpl','comment');
				break;

			default:
				$registry =& AEFactory::getConfiguration();

				if($task == 'default') {
					JToolBarHelper::title(JText::_('AKEEBA').': <small>'.JText::_('BUADMIN').'</small>','akeeba');
				} else {
					JToolBarHelper::title(JText::_('AKEEBA').': <small>'.JText::_('BUADMINSRP').'</small>','akeeba');
				}

				JToolBarHelper::back('AKEEBA_CONTROLPANEL', 'index.php?option='.JRequest::getCmd('option'));
				JToolBarHelper::spacer();
				JToolBarHelper::deleteList();
				JToolBarHelper::custom( 'deletefiles', 'delete.png', 'delete_f2.png', JText::_('STATS_LABEL_DELETEFILES'), true );

				// Add custom submenus
				JSubMenuHelper::addEntry(
					JText::_('BUADMIN_LABEL_BACKUPS'),
					JURI::base().'index.php?option=com_akeeba&view='.JRequest::getCmd('view').'&task=default',
					($task == 'default')
				);
				JSubMenuHelper::addEntry(
					JText::_('BUADMIN_LABEL_SRP'),
					JURI::base().'index.php?option=com_akeeba&view='.JRequest::getCmd('view').'&task=restorepoint',
					($task == 'restorepoint')
				);
				
				if(AKEEBA_PRO && ($task == 'default'))
				{
					$bar = & JToolBar::getInstance('toolbar');
					$bar->appendButton( 'Link', 'restore', JText::_('DISCOVER'), 'index.php?option=com_akeeba&view=discover' );
					JToolBarHelper::publish('restore', JText::_('STATS_LABEL_RESTORE'));
				}

				if(($task == 'default')) {
					JToolBarHelper::editList('showcomment', JText::_('STATS_LOG_EDITCOMMENT'));
					
					$pModel = JModel::getInstance('Profiles','AkeebaModel');
					$enginesPerPprofile = $pModel->getPostProcessingEnginePerProfile();
					$this->assign('enginesPerProfile', $enginesPerPprofile);
				}
				JToolBarHelper::spacer();

				// "Show warning first" download button. Joomlantastic!
				$confirmationText = AkeebaHelperEscape::escapeJS( JText::_('STATS_LOG_DOWNLOAD_CONFIRM'), "'\n" );
				$baseURI = JURI::base();
				$js = <<<ENDSCRIPT
function confirmDownloadButton()
{
	var answer = confirm('$confirmationText');
	if(answer) submitbutton('download');
}

function confirmDownload(id, part)
{
	var answer = confirm('$confirmationText');
	var newURL = '$baseURI';
	if(answer) {
		newURL += 'index.php?option=com_akeeba&view=buadmin&task=download&id='+id;
		if( part != '' ) newURL += '&part=' + part
		window.location = newURL;
	}
}

ENDSCRIPT;

				$document =& JFactory::getDocument();
				$document->addScriptDeclaration($js);				
				$document->addStyleSheet(JURI::base().'../media/com_akeeba/theme/akeebaui.css?'.AKEEBAMEDIATAG);
				
				$hash = 'akeebabuadmin';
		
				// ...ordering
				$app = JFactory::getApplication();
				$this->lists->set('order',			$app->getUserStateFromRequest($hash.'filter_order',
					'filter_order', 'backupstart'));
				$this->lists->set('order_Dir',		$app->getUserStateFromRequest($hash.'filter_order_Dir',
					'filter_order_Dir', 'DESC'));
				
				// ...filter state
				$this->lists->set('fltDescription',	$app->getUserStateFromRequest($hash.'filter_description',
					'description', null));
				$this->lists->set('fltFrom',		$app->getUserStateFromRequest($hash.'filter_from',
					'from', null));
				$this->lists->set('fltTo',			$app->getUserStateFromRequest($hash.'filter_to',
					'to', null));
				$this->lists->set('fltOrigin',		$app->getUserStateFromRequest($hash.'filter_origin',
					'origin', null));
				$this->lists->set('fltProfile',		$app->getUserStateFromRequest($hash.'filter_profile',
					'profile', null));
				
				$filters = $this->_getFilters();
				$ordering = $this->_getOrdering();

				require_once JPATH_COMPONENT_ADMINISTRATOR.DS.'models'.DS.'statistics.php';
				$model = new AkeebaModelStatistics();
				$list =& $model->getStatisticsListWithMeta(false, $filters, $ordering);

				// Assign data to the view
				$this->assignRef( 'lists',		$this->lists); // Filter lists
				$this->assignRef( 'list',		$list); // Data
				$this->assignRef( 'pagination',	$model->getPagination($filters)); // Pagination object
				break;
		}

		// Add live help
		AkeebaHelperIncludes::addHelp();

		parent::display(JRequest::getVar('tpl'));
	}
Ejemplo n.º 7
0
    /**
     * This method is called when the Quick Icons module is constructing its set
     * of icons. You can return an array which defines a single icon and it will
     * be rendered right after the stock Quick Icons.
     *
     * @param  $context  The calling context
     *
     * @return array A list of icon definition associative arrays, consisting of the
     *                 keys link, image, text and access.
     *
     * @since       2.5
     */
    public function onGetIcons($context)
    {
        $user = JFactory::getUser();
        if (!$user->authorise('akeeba.backup', 'com_akeeba')) {
            return;
        }
        if ($context != $this->params->get('context', 'mod_quickicon') || !JFactory::getUser()->authorise('core.manage', 'com_installer')) {
            return;
        }
        Platform::addPlatform('joomla25', JPATH_ADMINISTRATOR . '/components/com_akeeba/platform/joomla25');
        $url = JUri::base();
        $url = rtrim($url, '/');
        $profileId = (int) $this->params->get('profileid', 1);
        $token = JFactory::getSession()->getToken();
        if ($profileId <= 0) {
            $profileId = 1;
        }
        $ret = array('link' => 'index.php?option=com_akeeba&view=backup&autostart=1&returnurl=' . urlencode($url) . '&profileid=' . $profileId . "&{$token}=1", 'image' => 'akeeba-black', 'text' => JText::_('PLG_QUICKICON_AKEEBABACKUP_OK'), 'id' => 'plg_quickicon_akeebabackup', 'group' => 'MOD_QUICKICON_MAINTENANCE');
        if (version_compare(JVERSION, '3.0', 'lt')) {
            $ret['image'] = $url . '/../media/com_akeeba/icons/akeeba-48.png';
        }
        if ($this->params->get('enablewarning', 0) == 0) {
            // Process warnings
            $warning = false;
            $aeconfig = Factory::getConfiguration();
            Platform::getInstance()->load_configuration();
            // Get latest non-SRP backup ID
            $filters = array(array('field' => 'tag', 'operand' => '<>', 'value' => 'restorepoint'));
            $ordering = array('by' => 'backupstart', 'order' => 'DESC');
            require_once JPATH_ADMINISTRATOR . '/components/com_akeeba/models/statistics.php';
            $model = new AkeebaModelStatistics();
            $list = $model->getStatisticsListWithMeta(false, $filters, $ordering);
            if (!empty($list)) {
                $record = (object) array_shift($list);
            } else {
                $record = null;
            }
            // Process "failed backup" warnings, if specified
            if ($this->params->get('warnfailed', 0) == 0) {
                if (!is_null($record)) {
                    $warning = $record->status == 'fail' || $record->status == 'run';
                }
            }
            // Process "stale backup" warnings, if specified
            if (is_null($record)) {
                $warning = true;
            } else {
                $maxperiod = $this->params->get('maxbackupperiod', 24);
                JLoader::import('joomla.utilities.date');
                $lastBackupRaw = $record->backupstart;
                $lastBackupObject = new JDate($lastBackupRaw);
                $lastBackup = $lastBackupObject->toUnix(false);
                $maxBackup = time() - $maxperiod * 3600;
                if (!$warning) {
                    $warning = $lastBackup < $maxBackup;
                }
            }
            if ($warning) {
                $ret['image'] = 'akeeba-red';
                $ret['text'] = JText::_('PLG_QUICKICON_AKEEBABACKUP_BACKUPREQUIRED');
                if (version_compare(JVERSION, '3.0', 'lt')) {
                    $ret['image'] = $url . '/../media/com_akeeba/icons/akeeba-warning-48.png';
                } else {
                    $ret['text'] = '<span class="badge badge-important">' . $ret['text'] . '</span>';
                }
            }
        }
        if (version_compare(JVERSION, '3.0', 'gt')) {
            $inlineCSS = <<<CSS
.icon-akeeba-black {
\tbackground-image: url("../media/com_akeeba/icons/akeebabackup-16-black.png");
\twidth: 16px;
\theight: 16px;
}

.icon-akeeba-red {
\tbackground-image: url("../media/com_akeeba/icons/akeebabackup-16-red.png");
\twidth: 16px;
\theight: 16px;
}

.quick-icons .nav-list [class^="icon-akeeba-"], .quick-icons .nav-list [class*=" icon-akeeba-"] {
\tmargin-right: 7px;
}

.quick-icons .nav-list [class^="icon-akeeba-red"], .quick-icons .nav-list [class*=" icon-akeeba-red"] {
\tmargin-bottom: -4px;
}
CSS;
            JFactory::getApplication()->getDocument()->addStyleDeclaration($inlineCSS);
        }
        // Re-enable self
        $db = JFactory::getDbo();
        $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where($db->qn('element') . ' = ' . $db->q('akeebabackup'))->where($db->qn('folder') . ' = ' . $db->q('quickicon'));
        $db->setQuery($query);
        $db->execute();
        F0FUtilsCacheCleaner::clearPluginsCache();
        return array($ret);
    }
Ejemplo n.º 8
0
 private function _apiDeleteFiles($config)
 {
     $defConfig = array('backup_id' => 0);
     $config = array_merge($defConfig, $config);
     $backup_id = $config['backup_id'];
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/statistics.php';
     $model = new AkeebaModelStatistics();
     $model->setState('id', (int) $backup_id);
     $result = $model->deleteFile();
     if (!$result) {
         $this->status = self::STATUS_ERROR;
         $this->encapsulation = self::ENCAPSULATION_RAW;
         return $model->getError();
     } else {
         return true;
     }
 }
$jlang->load('mod_akadmin', JPATH_ADMINISTRATOR, $jlang->getDefault(), true);
$jlang->load('mod_akadmin', JPATH_ADMINISTRATOR, null, true);
// Initialize defaults
$image = "akeeba-48.png";
$label = JText::_('LBL_AKEEBA');
if ($params->get('enablewarning', 0) == 0) {
    // Process warnings
    $warning = false;
    require_once JPATH_ADMINISTRATOR . '/components/com_akeeba/akeeba/factory.php';
    $aeconfig = AEFactory::getConfiguration();
    AEPlatform::getInstance()->load_configuration();
    // Get latest non-SRP backup ID
    $filters = array(array('field' => 'tag', 'operand' => '<>', 'value' => 'restorepoint'));
    $ordering = array('by' => 'backupstart', 'order' => 'DESC');
    require_once JPATH_ADMINISTRATOR . '/components/com_akeeba/models/statistics.php';
    $model = new AkeebaModelStatistics();
    $list = $model->getStatisticsListWithMeta(false, $filters, $ordering);
    if (!empty($list)) {
        $record = (object) array_shift($list);
    } else {
        $record = null;
    }
    // Process "failed backup" warnings, if specified
    if ($params->get('warnfailed', 0) == 0) {
        if (!is_null($record)) {
            $warning = $record->status == 'fail' || $record->status == 'run';
        }
    }
    // Process "stale backup" warnings, if specified
    if (is_null($record)) {
        $warning = true;
 /**
  * This method is called when the Quick Icons module is constructing its set
  * of icons. You can return an array which defines a single icon and it will
  * be rendered right after the stock Quick Icons.
  *
  * @param  $context  The calling context
  *
  * @return array A list of icon definition associative arrays, consisting of the
  *				 keys link, image, text and access.
  *
  * @since       2.5
  */
 public function onGetIcons($context)
 {
     if ($context != $this->params->get('context', 'mod_quickicon') || !JFactory::getUser()->authorise('core.manage', 'com_installer')) {
         return;
     }
     $url = JURI::base();
     $url = rtrim($url, '/');
     $ret = array('link' => 'index.php?option=com_akeeba&view=backup', 'image' => 'briefcase', 'text' => JText::_('PLG_QUICKICON_AKEEBABACKUP_OK'), 'id' => 'plg_quickicon_akeebabackup', 'group' => 'MOD_QUICKICON_MAINTENANCE');
     if (version_compare(JVERSION, '3.0', 'lt')) {
         $ret['image'] = $url . '/../media/com_akeeba/icons/akeeba-48.png';
     }
     if ($this->params->get('enablewarning', 0) == 0) {
         // Process warnings
         $warning = false;
         $aeconfig = AEFactory::getConfiguration();
         AEPlatform::getInstance()->load_configuration();
         // Get latest non-SRP backup ID
         $filters = array(array('field' => 'tag', 'operand' => '<>', 'value' => 'restorepoint'));
         $ordering = array('by' => 'backupstart', 'order' => 'DESC');
         require_once JPATH_ADMINISTRATOR . '/components/com_akeeba/models/statistics.php';
         $model = new AkeebaModelStatistics();
         $list = $model->getStatisticsListWithMeta(false, $filters, $ordering);
         if (!empty($list)) {
             $record = (object) array_shift($list);
         } else {
             $record = null;
         }
         // Process "failed backup" warnings, if specified
         if ($this->params->get('warnfailed', 0) == 0) {
             if (!is_null($record)) {
                 $warning = $record->status == 'fail' || $record->status == 'run';
             }
         }
         // Process "stale backup" warnings, if specified
         if (is_null($record)) {
             $warning = true;
         } else {
             $maxperiod = $this->params->get('maxbackupperiod', 24);
             JLoader::import('joomla.utilities.date');
             $lastBackupRaw = $record->backupstart;
             $lastBackupObject = new JDate($lastBackupRaw);
             $lastBackup = $lastBackupObject->toUnix(false);
             $maxBackup = time() - $maxperiod * 3600;
             if (!$warning) {
                 $warning = $lastBackup < $maxBackup;
             }
         }
         if ($warning) {
             $ret['image'] = 'health';
             $ret['text'] = JText::_('PLG_QUICKICON_AKEEBABACKUP_BACKUPREQUIRED');
             if (version_compare(JVERSION, '3.0', 'lt')) {
                 $ret['image'] = $url . '/../media/com_akeeba/icons/akeeba-warning-48.png';
             }
         }
     }
     // Re-enable self
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where($db->qn('element') . ' = ' . $db->q('akeebabackup'))->where($db->qn('folder') . ' = ' . $db->q('quickicon'));
     $db->setQuery($query);
     $db->execute();
     return array($ret);
 }
 function onMonitoringCall($oldValuesSerialized = null)
 {
     // Plugin setup
     $this->setName("AkeebaBackup");
     //on donne une nom (unique) au plugin
     $this->setDescription("Checks the status of your Akeeba Backup backups");
     //on donne une description au plugin
     // Load language strings
     $jlang = JFactory::getLanguage();
     $jlang->load('com_akeeba', JPATH_ADMINISTRATOR, 'en-GB', true);
     $jlang->load('com_akeeba' . '.override', JPATH_ADMINISTRATOR, 'en-GB', true);
     // Load Akeeba Backup's configuration
     require_once JPATH_ADMINISTRATOR . '/components/com_akeeba/akeeba/factory.php';
     $aeconfig = AEFactory::getConfiguration();
     AEPlatform::getInstance()->load_configuration();
     // Get latest non-SRP backup ID
     $filters = array(array('field' => 'tag', 'operand' => '<>', 'value' => 'restorepoint'));
     $ordering = array('by' => 'backupstart', 'order' => 'DESC');
     require_once JPATH_ADMINISTRATOR . '/components/com_akeeba/models/statistics.php';
     $model = new AkeebaModelStatistics();
     $list = $model->getStatisticsListWithMeta(false, $filters, $ordering);
     if (!empty($list)) {
         $record = (object) array_shift($list);
     } else {
         $record = null;
     }
     // Process "failed backup" warnings, if specified
     if (!is_null($record)) {
         jimport('joomla.utilities.date');
         $jOn = new JDate($record->backupstart);
         // Warn on failed backups
         if ($record->status == 'fail') {
             $this->createJMonitoringAlert(2, "The latest backup which started on " . $jOn->toSql(false) . " has failed");
         }
         // Warn on still running backups
         if ($record->status == 'run') {
             $this->createJMonitoringAlert(1, "The latest backup which started on " . $jOn->toSql(false) . " is still running");
         }
         // Warn on out of date backups
         if (version_compare(JVERSION, '3.0', 'ge')) {
             $maxperiod = $this->params->get('maxbackupperiod', 24);
         } else {
             $maxperiod = $this->params->getValue('maxbackupperiod', 24);
         }
         if ($maxperiod > 0) {
             $lastBackupRaw = $record->backupstart;
             $lastBackupObject = new JDate($lastBackupRaw);
             $lastBackup = $lastBackupObject->toUnix(false);
             $maxBackup = time() - $maxperiod * 3600;
             if ($lastBackup < $maxBackup) {
                 $this->createJMonitoringAlert(1, "The backup is out of date");
             }
         }
         // Set up some values
         switch ($record->status) {
             case 'run':
                 $status = JText::_('STATS_LABEL_STATUS_PENDING');
                 break;
             case 'fail':
                 $status = JText::_('STATS_LABEL_STATUS_FAIL');
                 break;
             case 'complete':
                 $status = JText::_('STATS_LABEL_STATUS_OK');
                 break;
         }
         switch ($record->origin) {
             case 'frontend':
                 $origin = JText::_('STATS_LABEL_ORIGIN_FRONTEND');
                 break;
             case 'backend':
                 $origin = JText::_('STATS_LABEL_ORIGIN_BACKEND');
                 break;
             case 'cli':
                 $origin = JText::_('STATS_LABEL_ORIGIN_CLI');
                 break;
             default:
                 $origin = '&ndash;';
                 break;
         }
         $backupStatus = $record->status;
         $this->createJMonitoringValue('Akeeba Backup – Status', $status);
         $this->createJMonitoringValue('Akeeba Backup – Origin', $origin);
         $this->createJMonitoringValue('Akeeba Backup – Start', $jOn->format(JText::_('DATE_FORMAT_LC2'), true));
     }
     return $this;
 }
Ejemplo n.º 12
0
    public function onBrowse($tpl = null)
    {
        $this->loadHelper('Utils');
        $task = 'default';
        if (AKEEBA_PRO && $task == 'default') {
            $bar = JToolBar::getInstance('toolbar');
            $bar->appendButton('Link', 'restore', JText::_('DISCOVER'), 'index.php?option=com_akeeba&view=discover');
            JToolBarHelper::publish('restore', JText::_('STATS_LABEL_RESTORE'));
        }
        if ($task == 'default') {
            JToolBarHelper::editList('showcomment', JText::_('STATS_LOG_EDITCOMMENT'));
            $pModel = F0FModel::getTmpInstance('Profiles', 'AkeebaModel');
            $enginesPerPprofile = $pModel->getPostProcessingEnginePerProfile();
            $this->enginesPerProfile = $enginesPerPprofile;
        }
        JToolBarHelper::spacer();
        // "Show warning first" download button. Joomlantastic!
        $confirmationText = AkeebaHelperEscape::escapeJS(JText::_('STATS_LOG_DOWNLOAD_CONFIRM'), "'\n");
        $baseURI = JUri::base();
        $js = <<<JS

;// This comment is intentionally put here to prevent badly written plugins from causing a Javascript error
// due to missing trailing semicolon and/or newline in their code.
function confirmDownloadButton()
{
\tvar answer = confirm('{$confirmationText}');
\tif(answer) submitbutton('download');
}

function confirmDownload(id, part)
{
\tvar answer = confirm('{$confirmationText}');
\tvar newURL = '{$baseURI}';
\tif(answer) {
\t\tnewURL += 'index.php?option=com_akeeba&view=buadmin&task=download&id='+id;
\t\tif( part != '' ) newURL += '&part=' + part
\t\twindow.location = newURL;
\t}
}

JS;
        $document = JFactory::getDocument();
        $document->addScriptDeclaration($js);
        $hash = 'akeebabuadmin';
        // ...ordering
        $app = JFactory::getApplication();
        $this->lists->set('order', $app->getUserStateFromRequest($hash . 'filter_order', 'filter_order', 'backupstart'));
        $this->lists->set('order_Dir', $app->getUserStateFromRequest($hash . 'filter_order_Dir', 'filter_order_Dir', 'DESC'));
        // ...filter state
        $this->lists->set('fltDescription', $app->getUserStateFromRequest($hash . 'filter_description', 'description', null));
        $this->lists->set('fltFrom', $app->getUserStateFromRequest($hash . 'filter_from', 'from', null));
        $this->lists->set('fltTo', $app->getUserStateFromRequest($hash . 'filter_to', 'to', null));
        $this->lists->set('fltOrigin', $app->getUserStateFromRequest($hash . 'filter_origin', 'origin', null));
        $this->lists->set('fltProfile', $app->getUserStateFromRequest($hash . 'filter_profile', 'profile', null));
        $filters = $this->_getFilters();
        $ordering = $this->_getOrdering();
        require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/statistics.php';
        $model = new AkeebaModelStatistics();
        $list = $model->getStatisticsListWithMeta(false, $filters, $ordering);
        $profilesModel = F0FModel::getTmpInstance('Profiles', 'AkeebaModel');
        $profilesModel->reset()->clearState()->clearInput();
        // Let's create an array indexed with the profile id for better handling
        $profiles = $profilesModel->getItemList(true, 'id');
        $profilesList = array(JHtml::_('select.option', '', '–' . JText::_('STATS_LABEL_PROFILEID') . '–'));
        if (!empty($profiles)) {
            foreach ($profiles as $profile) {
                $profilesList[] = JHtml::_('select.option', $profile->id, '#' . $profile->id . '. ' . $profile->description);
            }
        }
        // Assign data to the view
        $this->profiles = $profiles;
        // Profiles
        $this->profilesList = $profilesList;
        // Profiles list for select box
        $this->list = $list;
        // Data
        $this->pagination = $model->getPagination($filters);
        // Pagination object
        return true;
    }