0byt3m1n1-V2
Path:
/
home
/
a
/
c
/
a
/
academiac
/
www
/
[
Home
]
File: joomla.php.tar
home/academiac/www/plugins/content/joomla/joomla.php 0000644 00000014631 15137311126 0016622 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Example Content Plugin * * @package Joomla.Plugin * @subpackage Content.joomla * @since 1.6 */ class plgContentJoomla extends JPlugin { /** * 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 The context of the content passed to the plugin (added in 1.6) * @param object A JTableContent object * @param bool If the content is just about to be created * @since 1.6 */ public function onContentAfterSave($context, &$article, $isNew) { // Check we are handling the frontend edit form. if ($context != 'com_content.form') { return true; } // Check if this function is enabled. if (!$this->params->def('email_new_fe', 1)) { return true; } // Check this is a new article. if (!$isNew) { return true; } $user = JFactory::getUser(); // Messaging for new items JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR.'/components/com_messages/models', 'MessagesModel'); JTable::addIncludePath(JPATH_ADMINISTRATOR.'/components/com_messages/tables'); $db = JFactory::getDbo(); $db->setQuery('SELECT id FROM #__users WHERE sendEmail = 1'); $users = (array) $db->loadColumn(); $default_language = JComponentHelper::getParams('com_languages')->get('administrator'); $debug = JFactory::getConfig()->get('debug_lang'); foreach ($users as $user_id) { if ($user_id != $user->id) { // Load language for messaging $receiver = JUser::getInstance($user_id); $lang = JLanguage::getInstance($receiver->getParam('admin_language', $default_language), $debug); $lang->load('com_content'); $message = array( 'user_id_to' => $user_id, 'subject' => $lang->_('COM_CONTENT_NEW_ARTICLE'), 'message' => sprintf($lang->_('COM_CONTENT_ON_NEW_CONTENT'), $user->get('name'), $article->title) ); $model_message = JModelLegacy::getInstance('Message', 'MessagesModel'); $model_message->save($message); } } return true; } /** * Don't allow categories to be deleted if they contain items or subcategories with items * * @param string The context for the content passed to the plugin. * @param object The data relating to the content that was deleted. * @return boolean * @since 1.6 */ public function onContentBeforeDelete($context, $data) { // Skip plugin if we are deleting something other than categories if ($context != 'com_categories.category') { return true; } // Check if this function is enabled. if (!$this->params->def('check_categories', 1)) { return true; } $extension = JRequest::getString('extension'); // Default to true if not a core extension $result = true; $tableInfo = array ( '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 if ($count === false) { $result = false; } else { // Show error if items are found in the category if ($count > 0 ) { $msg = JText::sprintf('COM_CATEGORIES_DELETE_NOT_ALLOWED', $data->get('title')) . JText::plural('COM_CATEGORIES_N_ITEMS_ASSIGNED', $count); JError::raiseWarning(403, $msg); $result = false; } // Check for items in any child categories (if it is a leaf, there are no child categories) if (!$data->isLeaf()) { $count = $this->_countItemsInChildren($table, $data->get('id'), $data); if ($count === false) { $result = false; } elseif ($count > 0) { $msg = JText::sprintf('COM_CATEGORIES_DELETE_NOT_ALLOWED', $data->get('title')) . JText::plural('COM_CATEGORIES_HAS_SUBCATEGORY_ITEMS', $count); JError::raiseWarning(403, $msg); $result = false; } } } return $result; } } /** * Get count of items in a category * * @param string table name of component table (column is catid) * @param int id of the category to check * @return mixed count of items found or false if db error * @since 1.6 */ private function _countItemsInCategory($table, $catid) { $db = JFactory::getDbo(); $query = $db->getQuery(true); // Count the items in this category $query->select('COUNT(id)'); $query->from($table); $query->where('catid = ' . $catid); $db->setQuery($query); $count = $db->loadResult(); // Check for DB error. if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return false; } else { return $count; } } /** * Get count of items in a category's child categories * * @param string table name of component table (column is catid) * @param int id of the category to check * @return mixed count of items found or false if db error * @since 1.6 */ private function _countItemsInChildren($table, $catid, $data) { $db = JFactory::getDbo(); // 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); $query->select('COUNT(id)'); $query->from($table); $query->where('catid IN (' . implode(',', $childCategoryIds) . ')'); $db->setQuery($query); $count = $db->loadResult(); // Check for DB error. if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return false; } else { return $count; } } else // If we didn't have any categories to check, return 0 { return 0; } } } home/academiac/www/plugins/authentication/joomla/joomla.php 0000644 00000004315 15137313442 0020170 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined('_JEXEC') or die; /** * Joomla Authentication plugin * * @package Joomla.Plugin * @subpackage Authentication.joomla * @since 1.5 */ class plgAuthenticationJoomla extends JPlugin { /** * This method should handle any authentication and report back to the subject * * @access public * @param array Array holding the user credentials * @param array Array of extra options * @param object Authentication response object * @return boolean * @since 1.5 */ function onUserAuthenticate($credentials, $options, &$response) { $response->type = 'Joomla'; // Joomla does not like blank passwords if (empty($credentials['password'])) { $response->status = JAuthentication::STATUS_FAILURE; $response->error_message = JText::_('JGLOBAL_AUTH_EMPTY_PASS_NOT_ALLOWED'); return false; } // Initialise variables. $conditions = ''; // Get a database object $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('id, password'); $query->from('#__users'); $query->where('username=' . $db->quote($credentials['username'])); $db->setQuery($query); $result = $db->loadObject(); if ($result) { $match = JUserHelper::verifyPassword($credentials['password'], $result->password, $result->id); if ($match === true) { $user = JUser::getInstance($result->id); // Bring this in line with the rest of the system $response->email = $user->email; $response->fullname = $user->name; if (JFactory::getApplication()->isAdmin()) { $response->language = $user->getParam('admin_language'); } else { $response->language = $user->getParam('language'); } $response->status = JAuthentication::STATUS_SUCCESS; $response->error_message = ''; } else { $response->status = JAuthentication::STATUS_FAILURE; $response->error_message = JText::_('JGLOBAL_AUTH_INVALID_PASS'); } } else { $response->status = JAuthentication::STATUS_FAILURE; $response->error_message = JText::_('JGLOBAL_AUTH_NO_USER'); } } } home/academiac/www/plugins/extension/joomla/joomla.php 0000644 00000015140 15137426646 0017176 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access. defined('_JEXEC') or die; /** * Joomla! master extension plugin. * * @package Joomla.Plugin * @subpackage Extension.Joomla * @since 1.6 */ class plgExtensionJoomla extends JPlugin { /** * @var integer Extension Identifier * @since 1.6 */ private $eid = 0; /** * @var JInstaller Installer object * @since 1.6 */ private $installer = null; /** * Constructor * * @access protected * @param object $subject The object to observe * @param array $config An array that holds the plugin configuration * @since 1.5 */ public function __construct(& $subject, $config) { parent::__construct($subject, $config); $this->loadLanguage(); } /** * Adds an update site to the table if it doesn't exist. * * @param string The friendly name of the site * @param string The type of site (e.g. collection or extension) * @param string The URI for the site * @param boolean If this site is enabled * @since 1.6 */ private function addUpdateSite($name, $type, $location, $enabled) { $dbo = JFactory::getDBO(); // look if the location is used already; doesn't matter what type // you can't have two types at the same address, doesn't make sense $query = $dbo->getQuery(true); $query->select('update_site_id')->from('#__update_sites')->where('location = '. $dbo->Quote($location)); $dbo->setQuery($query); $update_site_id = (int)$dbo->loadResult(); // if it doesn't exist, add it! if (!$update_site_id) { $query->clear(); $query->insert('#__update_sites'); $query->columns(array($dbo->quoteName('name'), $dbo->quoteName('type'), $dbo->quoteName('location'), $dbo->quoteName('enabled'))); $query->values($dbo->quote($name) . ', ' . $dbo->quote($type) . ', ' . $dbo->quote($location) . ', ' . (int) $enabled); $dbo->setQuery($query); if ($dbo->query()) { // link up this extension to the update site $update_site_id = $dbo->insertid(); } } // check if it has an update site id (creation might have faileD) if ($update_site_id) { $query->clear(); // look for an update site entry that exists $query->select('update_site_id')->from('#__update_sites_extensions'); $query->where('update_site_id = '. $update_site_id)->where('extension_id = '. $this->eid); $dbo->setQuery($query); $tmpid = (int)$dbo->loadResult(); if(!$tmpid) { // link this extension to the relevant update site $query->clear(); $query->insert('#__update_sites_extensions'); $query->columns(array($dbo->quoteName('update_site_id'), $dbo->quoteName('extension_id'))); $query->values($update_site_id . ', ' . $this->eid); $dbo->setQuery($query); $dbo->query(); } } } /** * Handle post extension install update sites * * @param JInstaller Installer object * @param int Extension Identifier * @since 1.6 */ public function onExtensionAfterInstall($installer, $eid) { if ($eid) { $this->installer = $installer; $this->eid = $eid; // After an install we only need to do update sites $this->processUpdateSites(); } } /** * Handle extension uninstall * * @param JInstaller Installer instance * @param int extension id * @param int installation result * @since 1.6 */ public function onExtensionAfterUninstall($installer, $eid, $result) { if ($eid) { // wipe out any update_sites_extensions links $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->delete()->from('#__update_sites_extensions')->where('extension_id = '. $eid); $db->setQuery($query); $db->Query(); // delete any unused update sites $query->clear(); $query->select('update_site_id')->from('#__update_sites_extensions'); $db->setQuery($query); $results = $db->loadColumn(); if(is_array($results)) { // so we need to delete the update sites and their associated updates $updatesite_delete = $db->getQuery(true); $updatesite_delete->delete()->from('#__update_sites'); $updatesite_query = $db->getQuery(true); $updatesite_query->select('update_site_id')->from('#__update_sites'); // if we get results back then we can exclude them if(count($results)) { $updatesite_query->where('update_site_id NOT IN ('. implode(',', $results) .')'); $updatesite_delete->where('update_site_id NOT IN ('. implode(',', $results) .')'); } // so lets find what update sites we're about to nuke and remove their associated extensions $db->setQuery($updatesite_query); $update_sites_pending_delete = $db->loadColumn(); if(is_array($update_sites_pending_delete) && count($update_sites_pending_delete)) { // nuke any pending updates with this site before we delete it // TODO: investigate alternative of using a query after the delete below with a query and not in like above $query->clear(); $query->delete()->from('#__updates')->where('update_site_id IN ('. implode(',', $update_sites_pending_delete) .')'); $db->setQuery($query); $db->query(); } // note: this might wipe out the entire table if there are no extensions linked $db->setQuery($updatesite_delete); $db->query(); } // last but not least we wipe out any pending updates for the extension $query->clear(); $query->delete()->from('#__updates')->where('extension_id = '. $eid); $db->setQuery($query); $db->query(); } } /** * After update of an extension * * @param JInstaller Installer object * @param int Extension identifier * @since 1.6 */ public function onExtensionAfterUpdate($installer, $eid) { if ($eid) { $this->installer = $installer; $this->eid = $eid; // handle any update sites $this->processUpdateSites(); } } /** * Processes the list of update sites for an extension. * * @since 1.6 */ private function processUpdateSites() { $manifest = $this->installer->getManifest(); $updateservers = $manifest->updateservers; if($updateservers) { $children = $updateservers->children(); } else { $children = array(); } if (count($children)) { foreach ($children as $child) { $attrs = $child->attributes(); $this->addUpdateSite($attrs['name'], $attrs['type'], $child, true); } } else { $data = (string)$updateservers; if (strlen($data)) { // we have a single entry in the update server line, let us presume this is an extension line $this->addUpdateSite(JText::_('PLG_EXTENSION_JOOMLA_UNKNOWN_SITE'), 'extension', $data, true); } } } } home/academiac/www/plugins/user/joomla/joomla.php 0000644 00000017624 15137760540 0016143 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2009 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined('_JEXEC') or die; /** * Joomla User plugin * * @package Joomla.Plugin * @subpackage User.joomla * @since 1.5 */ class plgUserJoomla extends JPlugin { /** * Remove all sessions for the user name * * Method is called after user data is deleted from the database * * @param array $user Holds the user data * @param boolean $succes True if user was succesfully stored in the database * @param string $msg Message * * @return boolean * @since 1.6 */ public function onUserAfterDelete($user, $succes, $msg) { if (!$succes) { return false; } $db = JFactory::getDbo(); $db->setQuery( 'DELETE FROM '.$db->quoteName('#__session') . ' WHERE '.$db->quoteName('userid').' = '.(int) $user['id'] ); $db->Query(); return true; } /** * Utility method to act on a user after it has been saved. * * This method sends a registration email to new users created in the backend. * * @param array $user Holds the new user data. * @param boolean $isnew True if a new user is stored. * @param boolean $success True if user was succesfully stored in the database. * @param string $msg Message. * * @return void * @since 1.6 */ public function onUserAfterSave($user, $isnew, $success, $msg) { // Initialise variables. $app = JFactory::getApplication(); $config = JFactory::getConfig(); $mail_to_user = $this->params->get('mail_to_user', 1); if ($isnew) { // TODO: Suck in the frontend registration emails here as well. Job for a rainy day. if ($app->isAdmin()) { if ($mail_to_user) { $lang = JFactory::getLanguage(); $defaultLocale = $lang->getTag(); /** * Look for user language. Priority: * 1. User frontend language * 2. User backend language */ $userParams = new JRegistry($user['params']); $userLocale = $userParams->get('language', $userParams->get('admin_language', $defaultLocale)); if ($userLocale != $defaultLocale) { $lang->setLanguage($userLocale); } $lang->load('plg_user_joomla', JPATH_ADMINISTRATOR); // Compute the mail subject. $emailSubject = JText::sprintf( 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', $user['name'], $config->get('sitename') ); // Compute the mail body. $emailBody = JText::sprintf( 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', $user['name'], $config->get('sitename'), JUri::root(), $user['username'], $user['password_clear'] ); // Assemble the email data...the sexy way! $mail = JFactory::getMailer() ->setSender( array( $config->get('mailfrom'), $config->get('fromname') ) ) ->addRecipient($user['email']) ->setSubject($emailSubject) ->setBody($emailBody); // Set application language back to default if we changed it if ($userLocale != $defaultLocale) { $lang->setLanguage($defaultLocale); } if (!$mail->Send()) { // TODO: Probably should raise a plugin error but this event is not error checked. JError::raiseWarning(500, JText::_('ERROR_SENDING_EMAIL')); } } } } else { // Existing user - nothing to do...yet. } } /** * This method should handle any login logic and report back to the subject * * @param array $user Holds the user data * @param array $options Array holding options (remember, autoregister, group) * * @return boolean True on success * @since 1.5 */ public function onUserLogin($user, $options = array()) { $instance = $this->_getUser($user, $options); // If _getUser returned an error, then pass it back. if ($instance instanceof Exception) { return false; } // If the user is blocked, redirect with an error if ($instance->get('block') == 1) { JError::raiseWarning('SOME_ERROR_CODE', JText::_('JERROR_NOLOGIN_BLOCKED')); return false; } // Authorise the user based on the group information if (!isset($options['group'])) { $options['group'] = 'USERS'; } // Chek the user can login. $result = $instance->authorise($options['action']); if (!$result) { JError::raiseWarning(401, JText::_('JERROR_LOGIN_DENIED')); return false; } // Mark the user as logged in $instance->set('guest', 0); // Register the needed session variables $session = JFactory::getSession(); $session->set('user', $instance); $db = JFactory::getDBO(); // Check to see the the session already exists. $app = JFactory::getApplication(); $app->checkSession(); // Update the user related fields for the Joomla sessions table. $db->setQuery( 'UPDATE '.$db->quoteName('#__session') . ' SET '.$db->quoteName('guest').' = '.$db->quote($instance->get('guest')).',' . ' '.$db->quoteName('username').' = '.$db->quote($instance->get('username')).',' . ' '.$db->quoteName('userid').' = '.(int) $instance->get('id') . ' WHERE '.$db->quoteName('session_id').' = '.$db->quote($session->getId()) ); $db->query(); // Hit the user last visit field $instance->setLastVisit(); return true; } /** * This method should handle any logout logic and report back to the subject * * @param array $user Holds the user data. * @param array $options Array holding options (client, ...). * * @return object True on success * @since 1.5 */ public function onUserLogout($user, $options = array()) { $my = JFactory::getUser(); $session = JFactory::getSession(); $app = JFactory::getApplication(); // Make sure we're a valid user first if ($user['id'] == 0 && !$my->get('tmp_user')) { return true; } // Check to see if we're deleting the current session if ($my->get('id') == $user['id'] && $options['clientid'] == $app->getClientId()) { // Hit the user last visit field $my->setLastVisit(); // Destroy the php session for this user $session->destroy(); } // Force logout all users with that userid $db = JFactory::getDBO(); $db->setQuery( 'DELETE FROM '.$db->quoteName('#__session') . ' WHERE '.$db->quoteName('userid').' = '.(int) $user['id'] . ' AND '.$db->quoteName('client_id').' = '.(int) $options['clientid'] ); $db->query(); return true; } /** * This method will return a user object * * If options['autoregister'] is true, if the user doesn't exist yet he will be created * * @param array $user Holds the user data. * @param array $options Array holding options (remember, autoregister, group). * * @return object A JUser object * @since 1.5 */ protected function _getUser($user, $options = array()) { $instance = JUser::getInstance(); if ($id = intval(JUserHelper::getUserId($user['username']))) { $instance->load($id); return $instance; } //TODO : move this out of the plugin jimport('joomla.application.component.helper'); $config = JComponentHelper::getParams('com_users'); // Default to Registered. $defaultUserGroup = $config->get('new_usertype', 2); $acl = JFactory::getACL(); $instance->set('id' , 0); $instance->set('name' , $user['fullname']); $instance->set('username' , $user['username']); $instance->set('password_clear' , $user['password_clear']); $instance->set('email' , $user['email']); // Result should contain an email (check) $instance->set('usertype' , 'deprecated'); $instance->set('groups' , array($defaultUserGroup)); //If autoregister is set let's register the user $autoregister = isset($options['autoregister']) ? $options['autoregister'] : $this->params->get('autoregister', 1); if ($autoregister) { if (!$instance->save()) { return JError::raiseWarning('SOME_ERROR_CODE', $instance->getError()); } } else { // No existing user and autoregister off, this is a temporary user. $instance->set('tmp_user', true); } return $instance; } }
©
2018.