- md5
- d524d857ffae17b8ac3b9565d03ab854
- sha1
- 26be291e2810132e1d5c8cdcf36629127727d1f4
- sha256
- c2400b6d68df85c860db0c88a3cf5d7d3e64a1dd9b7fd6f5d38281534e80db4d
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
<?php
/**
* @package Joomla.Administrator
* @subpackage com_postinstall
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Model class to manage postinstall messages
*
* @package Joomla.Administrator
* @subpackage com_postinstall
* @since 3.2
*/
class PostinstallModelMessages extends FOFModel
{
/**
* Builds the SELECT query
*
* @param boolean $overrideLimits Are we requested to override the set limits?
*
* @return JDatabaseQuery
*
* @since 3.2
*/
public function buildQuery($overrideLimits = false)
{
$query = parent::buildQuery($overrideLimits);
$db = $this->getDbo();
// Add a forced extension filtering to the list
$eid = $this->input->getInt('eid', 700);
$query->where($db->qn('extension_id') . ' = ' . $db->q($eid));
// Force filter only enabled messages
$published = $this->input->getInt('published', 1);
$query->where($db->qn('enabled') . ' = ' . $db->q($published));
return $query;
}
/**
* Returns the name of an extension, as registered in the #__extensions table
*
* @param integer $eid The extension ID
*
* @return string The extension name
*
* @since 3.2
*/
public function getExtensionName($eid)
{
// Load the extension's information from the database
$db = $this->getDbo();
$query = $db->getQuery(true)
->select(array('name', 'element', 'client_id'))
->from($db->qn('#__extensions'))
->where($db->qn('extension_id') . ' = ' . $db->q((int) $eid));
$db->setQuery($query, 0, 1);
$extension = $db->loadObject();
if (!is_object($extension))
{
return '';
}
// Load language files
$basePath = JPATH_ADMINISTRATOR;
if ($extension->client_id == 0)
{
$basePath = JPATH_SITE;
}
$lang = JFactory::getLanguage();
$lang->load($extension->element, $basePath);
// Return the localised name
return JText::_($extension->name);
}
/**
* Resets all messages for an extension
*
* @param integer $eid The extension ID whose messages we'll reset
*
* @return mixed False if we fail, a db cursor otherwise
*
* @since 3.2
*/
public function resetMessages($eid)
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->update($db->qn('#__postinstall_messages'))
->set($db->qn('enabled') . ' = ' . $db->q(1))
->where($db->qn('extension_id') . ' = ' . $db->q($eid));
$db->setQuery($query);
return $db->execute();
}
/**
* List post-processing. This is used to run the programmatic display
* conditions against each list item and decide if we have to show it or
* not.
*
* Do note that this a core method of the RAD Layer which operates directly
* on the list it's being fed. A little touch of modern magic.
*
* @param array $resultArray A list of items to process
*
* @return void
*
* @since 3.2
*/
protected function onProcessList(&$resultArray)
{
$unset_keys = array();
$language_extensions = array();
foreach ($resultArray as $key => $item)
{
// Filter out messages based on dynamically loaded programmatic conditions
if (!empty($item->condition_file) && !empty($item->condition_method))
{
jimport('joomla.filesystem.file');
$file = FOFTemplateUtils::parsePath($item->condition_file, true);
if (JFile::exists($file))
{
require_once $file;
$result = call_user_func($item->condition_method);
if ($result === false)
{
$unset_keys[] = $key;
}
}
}
// Load the necessary language files
if (!empty($item->language_extension))
{
$hash = $item->language_client_id . '-' . $item->language_extension;
if (!in_array($hash, $language_extensions))
{
$language_extensions[] = $hash;
JFactory::getLanguage()->load($item->language_extension, $item->language_client_id == 0 ? JPATH_SITE : JPATH_ADMINISTRATOR);
}
}
}
if (!empty($unset_keys))
{
foreach ($unset_keys as $key)
{
unset($resultArray[$key]);
}
}
}
}
The same content is in 2 releases, Joomla 3.2.0 to 3.2.1. See them all, or every version of this file.