public function __construct() { $isLoaded = MPluginHelper::importPlugin('authentication'); if (!$isLoaded) { MError::raiseWarning('SOME_ERROR_CODE', MText::_('MLIB_USER_ERROR_AUTHENTICATION_LIBRARIES')); } }
public static function prepare($text, $params = null, $context = 'text') { if ($params === null) { $params = new MObject(); } $article = new stdClass(); $article->text = $text; MPluginHelper::importPlugin('content'); $dispatcher = MDispatcher::getInstance(); $dispatcher->trigger('onContentPrepare', array($context, &$article, &$params, 0)); return $article->text; }
public function search($posts, $wp_query) { if (!is_search() or !isset($wp_query->query) or !isset($wp_query->query['s'])) { return $posts; } $this->wp_query = $wp_query; $text = get_search_query(); mimport('framework.plugin.helper'); mimport('framework.application.component.helper'); MPluginHelper::importPlugin('search'); $dispatcher = MDispatcher::getInstance(); $plg_result = $dispatcher->trigger('onContentSearch', array($text, 'all', 'newest', null, $this->context)); $miwo_result = array(); foreach ($plg_result as $rows) { $miwo_result = array_merge($miwo_result, $rows); } $posts = array_merge($miwo_result, $posts); usort($posts, array('MWordpress', '_sortResult')); return $posts; }
public function logout($userid = null, $options = array()) { // Get a user object from the MApplication. $user = MFactory::getUser($userid); // Build the credentials array. $parameters['username'] = $user->get('username'); $parameters['id'] = $user->get('id'); // Set clientid in the options array if it hasn't been set already. if (!isset($options['clientid'])) { $options['clientid'] = $this->getClientId(); } // Import the user plugin group. MPluginHelper::importPlugin('user'); // OK, the credentials are built. Lets fire the onLogout event. $results = $this->triggerEvent('onUserLogout', array($parameters, $options)); // Check if any of the plugins failed. If none did, success. if (!in_array(false, $results, true)) { // Use domain and path set in config for cookie if it exists. $cookie_domain = $this->getCfg('cookie_domain', ''); $cookie_path = $this->getCfg('cookie_path', '/'); setcookie(self::getHash('MLOGIN_REMEMBER'), false, time() - 86400, $cookie_path, $cookie_domain); return true; } // Trigger onUserLoginFailure Event. $this->triggerEvent('onUserLogoutFailure', array($parameters)); return false; }
public function delete() { MPluginHelper::importPlugin('user'); // Trigger the onUserBeforeDelete event $dispatcher = MDispatcher::getInstance(); $dispatcher->trigger('onUserBeforeDelete', array($this->getProperties())); $result = false; if (!($result = wp_delete_user($this->id))) { $this->setError('Not deleted'); } // Trigger the onUserAfterDelete event $dispatcher->trigger('onUserAfterDelete', array($this->getProperties(), $result, $this->getError())); return $result; }
protected function preprocessForm(MForm $form, $data, $group = 'content') { // Import the appropriate plugin group. MPluginHelper::importPlugin($group); // Get the dispatcher. $dispatcher = MDispatcher::getInstance(); // Trigger the form preparation event. $results = $dispatcher->trigger('onContentPrepareForm', array($form, $data)); // Check for errors encountered while preparing the form. if (count($results) && in_array(false, $results, true)) { // Get the last error. $error = $dispatcher->getError(); if (!$error instanceof Exception) { throw new Exception($error); } } }
public function save($data) { $dispatcher = MEventDispatcher::getInstance(); $table = $this->getTable(); $key = $table->getKeyName(); $pk = !empty($data[$key]) ? $data[$key] : (int) $this->getState($this->getName() . '.id'); $isNew = true; // Include the content plugins for the on save events. MPluginHelper::importPlugin('content'); // Allow an exception to be thrown. try { // Load the row if saving an existing record. if ($pk > 0) { $table->load($pk); $isNew = false; } // Bind the data. if (!$table->bind($data)) { $this->setError($table->getError()); return false; } // Prepare the row for saving $this->prepareTable($table); // Check the data. if (!$table->check()) { $this->setError($table->getError()); return false; } // Trigger the onContentBeforeSave event. $result = $dispatcher->trigger($this->event_before_save, array($this->option . '.' . $this->name, $table, $isNew)); if (in_array(false, $result, true)) { $this->setError($table->getError()); return false; } // Store the data. if (!$table->store()) { $this->setError($table->getError()); return false; } // Clean the cache. $this->cleanCache(); // Trigger the onContentAfterSave event. $dispatcher->trigger($this->event_after_save, array($this->option . '.' . $this->name, $table, $isNew)); } catch (Exception $e) { $this->setError($e->getMessage()); return false; } $pkName = $table->getKeyName(); if (isset($table->{$pkName})) { $this->setState($this->getName() . '.id', $table->{$pkName}); } $this->setState($this->getName() . '.new', $isNew); return true; }