Source for file joomla.php
Documentation is available at joomla.php
* @subpackage Content.joomla
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @subpackage Content.joomla
* Example after save content method
* Article is passed by reference, but after the save, so no changes will be saved.
* Method is called right after the content is saved
* @param string $context The context of the content passed to the plugin (added in 1.6)
* @param object $article A JTableContent object
* @param boolean $isNew If the content is just about to be created
* @return boolean true if function not enabled, is in front-end or is new. Else true or
* false depending on success of save function.
// Check we are handling the frontend edit form.
if ($context !=
'com_content.form')
// Check if this function is enabled.
if (!$this->params->def('email_new_fe', 1))
// Check this is a new article.
// Messaging for new items
$query =
$db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__users'))
->where($db->quoteName('sendEmail') .
' = 1');
$users = (array)
$db->loadColumn();
$default_language =
JComponentHelper::getParams('com_languages')->get('administrator');
foreach ($users as $user_id)
if ($user_id !=
$user->id)
// Load language for messaging
$lang->load('com_content');
'user_id_to' =>
$user_id,
'subject' =>
$lang->_('COM_CONTENT_NEW_ARTICLE'),
'message' =>
sprintf($lang->_('COM_CONTENT_ON_NEW_CONTENT'), $user->get('name'), $article->title)
$result =
$model_message->save($message);
* Don't allow categories to be deleted if they contain items or subcategories with items
* @param string $context The context for the content passed to the plugin.
* @param object $data The data relating to the content that was deleted.
// Skip plugin if we are deleting something other than categories
if ($context !=
'com_categories.category')
// Check if this function is enabled.
if (!$this->params->def('check_categories', 1))
// Default to true if not a core extension
'com_banners' =>
array('table_name' =>
'#__banners'),
'com_contact' =>
array('table_name' =>
'#__contact_details'),
'com_content' =>
array('table_name' =>
'#__content'),
'com_newsfeeds' =>
array('table_name' =>
'#__newsfeeds'),
'com_weblinks' =>
array('table_name' =>
'#__weblinks')
// Now check to see if this is a known core extension
if (isset
($tableInfo[$extension]))
// Get table name for known core extensions
$table =
$tableInfo[$extension]['table_name'];
// See if this category has any content items
$count =
$this->_countItemsInCategory($table, $data->get('id'));
// Return false if db error
// Show error if items are found in the category
$msg =
JText::sprintf('COM_CATEGORIES_DELETE_NOT_ALLOWED', $data->get('title')) .
JText::plural('COM_CATEGORIES_N_ITEMS_ASSIGNED', $count);
// Check for items in any child categories (if it is a leaf, there are no child categories)
$count =
$this->_countItemsInChildren($table, $data->get('id'), $data);
$msg =
JText::sprintf('COM_CATEGORIES_DELETE_NOT_ALLOWED', $data->get('title')) .
JText::plural('COM_CATEGORIES_HAS_SUBCATEGORY_ITEMS', $count);
* Get count of items in a category
* @param string $table table name of component table (column is catid)
* @param integer $catid id of the category to check
* @return mixed count of items found or false if db error
private function _countItemsInCategory($table, $catid)
$query =
$db->getQuery(true);
// Count the items in this category
$query->select('COUNT(id)')
->where('catid = ' .
$catid);
$count =
$db->loadResult();
catch
(RuntimeException $e)
* Get count of items in a category's child categories
* @param string $table table name of component table (column is catid)
* @param integer $catid id of the category to check
* @param object $data The data relating to the content that was deleted.
* @return mixed count of items found or false if db error
private function _countItemsInChildren($table, $catid, $data)
// Create subquery for list of child categories
$childCategoryTree =
$data->getTree();
// First element in tree is the current category, so we can skip that one
unset
($childCategoryTree[0]);
$childCategoryIds =
array();
foreach ($childCategoryTree as $node)
$childCategoryIds[] =
$node->id;
// Make sure we only do the query if we have some categories to look in
if (count($childCategoryIds))
// Count the items in this category
$query =
$db->getQuery(true)
->where('catid IN (' .
implode(',', $childCategoryIds) .
')');
$count =
$db->loadResult();
catch
(RuntimeException $e)
// If we didn't have any categories to check, return 0
* Change the state in core_content if the state in a table is changed
* @param string $context The context for the content passed to the plugin.
* @param array $pks A list of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
$query =
$db->getQuery(true)
->select($db->quoteName('core_content_id'))
->from($db->quoteName('#__ucm_content'))
->where($db->quoteName('core_type_alias') .
' = ' .
$db->quote($context))
->where($db->quoteName('core_content_item_id') .
' IN (' .
$pksImploded =
implode(',', $pks) .
')');
$ccIds =
$db->loadColumn();
$cctable->publish($ccIds, $value);
Documentation generated on Tue, 19 Nov 2013 15:06:07 +0100 by phpDocumentor 1.4.3