/** * Fire onContentPrepare for content that isn't part of an article. * * @param string $text The content to be transformed. * @param array $params The content params. * @param string $context The context of the content to be transformed. * * @return string The content after transformation. * * @since 11.1 */ public static function prepare($text, $params = null, $context = 'text') { if ($params === null) { $params = new Object(); } $article = new stdClass(); $article->text = $text; Helper::importPlugin('content'); $dispatcher = Dispatcher::getInstance(); $dispatcher->trigger('onContentPrepare', array($context, &$article, &$params, 0)); return $article->text; }
/** * Allows the application to load a custom or default dispatcher. * * The logic and options for creating this object are adequately generic for default cases * but for many applications it will make sense to override this method and create event * dispatchers, if required, based on more specific needs. * * @param JEventDispatcher $dispatcher An optional dispatcher object. If omitted, the factory dispatcher is created. * * @return JApplicationBase This method is chainable. * * @since 12.1 */ public function loadDispatcher(Dispatcher $dispatcher = null) { $this->dispatcher = $dispatcher === null ? Dispatcher::getInstance() : $dispatcher; return $this; }
/** * Authorises that a particular user should be able to login * * @param AuthenticationResponse $response response including username of the user to authorise * @param array $options list of options * * @return array[AuthenticationResponse] results of authorisation * * @since 11.2 */ public static function authorise($response, $options = array()) { // Get plugins in case they haven't been imported already Helper::importPlugin('user'); Helper::importPlugin('authentication'); $dispatcher = Dispatcher::getInstance(); $results = $dispatcher->trigger('onUserAuthorisation', array($response, $options)); return $results; }
/** * Method to delete the JUser object from the database * * @return boolean True on success * * @since 11.1 */ public function delete() { PluginHelper::importPlugin('user'); // Trigger the onUserBeforeDelete event $dispatcher = Dispatcher::getInstance(); $dispatcher->trigger('onUserBeforeDelete', array($this->getProperties())); // Create the user table object $table = $this->getTable(); $result = false; if (!($result = $table->delete($this->id))) { $this->setError($table->getError()); } // Trigger the onUserAfterDelete event $dispatcher->trigger('onUserAfterDelete', array($this->getProperties(), $result, $this->getError())); return $result; }
/** * Gets the user profile information * * @param integer $userId The id of the user. * * @return object * * @since 11.1 */ public static function getProfile($userId = 0) { if ($userId == 0) { $user = Factory::getUser(); $userId = $user->id; } // Get the dispatcher and load the user's plugins. $dispatcher = Dispatcher::getInstance(); Helper::importPlugin('user'); $data = new Object(); $data->id = $userId; // Trigger the data preparation event. $dispatcher->trigger('onContentPrepareData', array('com_users.profile', &$data)); return $data; }
/** * Loads the plugin file. * * @param object $plugin The plugin. * @param boolean $autocreate True to autocreate. * @param Dispatcher $dispatcher Optionally allows the plugin to use a different dispatcher. * * @return void * * @since 11.1 */ protected static function _import($plugin, $autocreate = true, Dispatcher $dispatcher = null) { static $paths = array(); $plugin->type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $plugin->type); $plugin->name = preg_replace('/[^A-Z0-9_\\.-]/i', '', $plugin->name); $path = JPATH_PLUGINS . '/' . $plugin->type . '/' . $plugin->name . '/' . $plugin->name . '.php'; if (!isset($paths[$path])) { if (file_exists($path)) { if (!isset($paths[$path])) { require_once $path; } $paths[$path] = true; if ($autocreate) { // Makes sure we have an event dispatcher if (!is_object($dispatcher)) { $dispatcher = Dispatcher::getInstance(); } $className = 'plg' . $plugin->type . $plugin->name; if (class_exists($className)) { // Load the plugin from the database. if (!isset($plugin->params)) { // Seems like this could just go bye bye completely $plugin = self::getPlugin($plugin->type, $plugin->name); } // Instantiate and register the plugin. new $className($dispatcher, (array) $plugin); } } } else { $paths[$path] = false; } } }