示例#1
0
 protected function _actionLogout(KCommandContext $context)
 {
     $result = JFactory::getApplication()->logout();
     if (!JError::isError($result)) {
         $this->_redirect = 'index.php?Itemid=' . JSite::getMenu()->getDefault()->id;
     } else {
         $this->setRedirect(KRequest::referrer(), $result->getError(), 'error');
     }
 }
示例#2
0
 protected function _actionDelete(KCommandContext $context)
 {
     $data = parent::_actionDelete($context);
     // TODO: Remove this temporary when upgrading Nooku Framework.
     if ($context->status == KHttpResponse::NO_CONTENT) {
         $context->status = KHttpResponse::OK;
     }
     $this->setRedirect(KRequest::referrer(), JText::_('Comment has been deleted.'), 'message');
     return $data;
 }
示例#3
0
 public function _actionCheckin(KCommandContext $context)
 {
     JFactory::getLanguage()->load('com_checkin', JPATH_ADMINISTRATOR);
     $table = $this->getModel()->getTable();
     $database = $table->getDatabase();
     $query = 'UPDATE #__' . $table->getName() . ' SET `locked_on` = \'0000-00-00 00:00:00\', `locked_by` = 0 WHERE locked_by > 0;';
     $database->execute($query);
     $rows = $database->getConnection()->affected_rows;
     $this->setRedirect(KRequest::referrer(), JText::plural('COM_CHECKIN_N_ITEMS_CHECKED_IN', $rows));
 }
示例#4
0
 /**
  * Constructor
  *
  * @param 	object 	An optional KConfig object with configuration options.
  */
 public function __construct(KConfig $config)
 {
     //To prevent these states to be set while browsing after a delete/unwatch
     $config->append(array('request' => array('sort' => 'created_on', 'direction' => 'desc')));
     $config->persistent = false;
     parent::__construct($config);
     $this->registerCallback('before.add', array($this, 'setUser'));
     $this->registerCallback('before.edit', array($this, 'setUser'));
     $this->registerCallback('before.delete', array($this, 'beforeDelete'));
     //Set default redirect
     $this->_redirect = KRequest::referrer();
 }
 protected function _afterDelete(KCommandContext $context)
 {
     if ($context->status == KHttpResponse::NO_CONTENT) {
         $extension = $context->result instanceof KDatabaseRowsetInterface ? $context->result->top() : $context->result;
         $url = KRequest::referrer();
         $query = $url->getQuery(true);
         $query['event'] = 'uninstall';
         $query['name'] = $extension->name;
         $query['version'] = $extension->version;
         $url->setQuery($query);
         $this->setRedirect($url);
     }
 }
示例#6
0
 /**
  * Store the referrer in the session
  *
  * @param 	KCommandContext		The active command context
  * @return void
  */
 public function saveReferrer(KCommandContext $context)
 {
     $referrer = KRequest::referrer();
     if (isset($referrer) && KRequest::type() == 'HTTP') {
         $request = KRequest::url();
         $request->get(KHttpUri::PART_PATH | KHttpUri::PART_QUERY);
         $referrer->get(KHttpUri::PART_PATH | KHttpUri::PART_QUERY);
         //Compare request url and referrer
         if ($request != $referrer) {
             KRequest::set('session.com.controller.referrer', (string) $referrer);
         }
     }
 }
示例#7
0
 public function _actionIndex(KCommandContext $context)
 {
     // We will get all the items of the database and resave them to index everything.
     set_time_limit(1440);
     $modelIdentifier = clone $context->caller->getIdentifier();
     $modelIdentifier->path = array('model');
     $modelIdentifier->name = KInflector::pluralize($modelIdentifier->name);
     $model = $this->getService($modelIdentifier);
     $items = $model->limit(0)->getList();
     foreach ($items as $item) {
         $item->save();
     }
     JFactory::getApplication()->redirect(KRequest::referrer(), JText::_(ucfirst($modelIdentifier->name) . ' reindexed'));
 }
示例#8
0
 protected function _actionLogout(KCommandContext $context)
 {
     $users = $this->getModel()->getList();
     if (count($users)) {
         foreach ($users as $user) {
             $clients = array(0, 1);
             //Force logout from site and administrator
             $result = JFactory::getApplication()->logout($user->id, array('clientid' => $clients));
             if (JError::isError($result)) {
                 $this->_redirect_type = 'error';
                 $this->_redirect_message = $result->getError();
             }
         }
     }
     $this->_redirect = KRequest::referrer();
 }
示例#9
0
 protected function _actionLogout(KCommandContext $context)
 {
     $user = JFactory::getUser();
     if ($user->id) {
         $app = JFactory::getApplication();
         $error = $app->logout();
         if (!$error instanceof Exception) {
         } else {
             $context->status = KHttpResponse::OK;
         }
     }
     if (KRequest::type() != 'AJAX') {
         $this->_redirect = KRequest::referrer();
         //			return $rowset;
     }
 }
示例#10
0
 /**
  * Set the referrer
  *
  * @return void
  */
 public function setReferrer()
 {
     $identifier = $this->getMixer()->getIdentifier();
     if (!KRequest::has('cookie.referrer_locked')) {
         $request = KRequest::url();
         $referrer = KRequest::referrer();
         //Compare request url and referrer
         if (!isset($referrer) || (string) $referrer == (string) $request) {
             $option = 'com_' . $identifier->package;
             $view = KInflector::pluralize($identifier->name);
             $url = 'index.php?option=' . $option . '&view=' . $view;
             $referrer = $this->getService('koowa:http.url', array('url' => $url));
         }
         KRequest::set('cookie.referrer', (string) $referrer);
     }
 }
示例#11
0
 protected function _actionRemind(KCommandContext $context)
 {
     $email = KRequest::get('post.email', 'email');
     if (!$this->getService('koowa:filter.email')->validate($email)) {
         $this->setRedirect(KRequest::referrer(), JText::_('INVALID_EMAIL_ADDRESS'), 'error');
         return false;
     }
     $user = $this->getService('com://site/users.model.users')->set('email', $email)->getItem();
     if (!$user->id) {
         $this->setRedirect(KRequest::referrer(), JText::_('COULD_NOT_FIND_EMAIL'), 'error');
         return false;
     }
     $config = JFactory::getConfig();
     $site_url = KRequest::url()->get(KHttpUrl::SCHEME | KHttpUrl::HOST | KHttpUrl::PORT);
     $url = $site_url . JRoute::_('index.php?option=com_users&view=login');
     $details = array('from_email' => $config->getValue('mailfrom'), 'from_name' => $config->getValue('fromname'), 'subject' => JText::sprintf('USERNAME_REMINDER_EMAIL_TITLE', $config->getValue('sitename')), 'body' => JText::sprintf('USERNAME_REMINDER_EMAIL_TEXT', $config->getValue('sitename'), $user->username, $url));
     if (!JUtility::sendMail($details['from_email'], $details['from_name'], $email, $details['subject'], $details['body'])) {
         $this->setRedirect(KRequest::referrer(), JText::_('ERROR_SENDING_REMINDER_EMAIL'), 'error');
         return false;
     }
 }
示例#12
0
 public function __construct(KConfig $config)
 {
     parent::__construct($config);
     $lang =& JFactory::getLanguage();
     $orphans = $lang->getOrphans();
     if ($orphans) {
         ksort($orphans, SORT_STRING);
         $guesses = array();
         foreach ($orphans as $key => $occurance) {
             if (is_array($occurance) and isset($occurance[0])) {
                 $info =& $occurance[0];
                 $file = @$info['step']['file'];
                 $guess = str_replace('_', ' ', $info['string']);
                 // Integers isn't translatable
                 if (is_numeric($key) || strpos($key, '??') === 0 || strpos($guess, '•') === 0) {
                     continue;
                 }
                 $guesses[] = array('file' => $file, 'keys' => strtoupper($key) . '=' . $guess);
             }
         }
         $append = false;
         foreach ($guesses as $guess) {
             if (!$guess['file'] || strpos($guess['file'], '/components/' . $config->option . '/') === false && strpos($guess['file'], '/components/com_ninja/') === false) {
                 continue;
             }
             $append .= "\n" . $guess['keys'];
         }
         if (!$append) {
             return;
         }
         $langfile = key($lang->getPaths($config->option));
         $readfile = JFile::read($langfile);
         $text = $readfile . "\n\n# " . KInflector::humanize(KRequest::get('get.view', 'cmd')) . "\n# @file     " . $guess['file'] . "\n# @url      " . KRequest::url() . "\n# @referrer " . KRequest::referrer() . "\n" . $append;
         JFile::write($langfile, $text);
         //echo $readfile;
         //die('<pre>'.var_export($langfile, true).'</pre>');
     }
     //die('<script type="text/javascript">console.log('.json_encode($orphans).')</script>');
 }
示例#13
0
 /**
  * Saves the row to the database. And saves a Joomla User.
  *
  * This performs an intelligent insert/update and reloads the properties
  * with fresh data from the table on success.
  *
  * @return boolean	If successfull return TRUE, otherwise FALSE
  */
 public function save()
 {
     $user = JUser::getInstance();
     if (isset($this->_modified['password'])) {
         $data = array('id' => $this->id, 'name' => $this->name, 'username' => $this->username, 'email' => $this->email, 'groups' => $this->groups);
         if ($this->password !== '' && $this->password_verify !== '') {
             $data['password'] = $this->password;
             $data['password2'] = $this->password_verify;
         }
         $user->id = $this->id;
         $user->bind($data);
         if ($this->isNew() && empty($this->password)) {
             JFactory::getApplication()->redirect(KRequest::referrer(), 'No password.', 'error');
         }
         if (!$user->save()) {
             JFactory::getApplication()->redirect(KRequest::referrer(), 'Error while saving Joomla user.', 'error');
         }
     }
     if ($this->isNew()) {
         $this->setData(array('id' => $user->id, 'profile_user_id' => $user->id));
     }
     parent::save();
 }
示例#14
0
 /**
  * Filter that creates a redirect message based on the action
  * 
  * This function takes the row(set) status into account. If the status is STATUS_FAILED the status message information 
  * us used to generate an appropriate redirect message and set the redirect to the referrer. Otherwise, we generate the 
  * message based on the action and identifier name.
  *
  * @param KCommandContext   The active command context
  * @return void
  */
 public function setMessage(KCommandContext $context)
 {
     if ($context->result instanceof KDatabaseRowsetInterface) {
         $row = $context->result->top();
     } else {
         $row = $context->result;
     }
     $action = KRequest::get('post.action', 'cmd');
     $name = $this->_identifier->name;
     $status = $row->getStatus();
     if ($status == KDatabase::STATUS_FAILED) {
         $this->_redirect = KRequest::referrer();
         $this->_redirect_type = 'error';
         if ($row->getStatusMessage()) {
             $this->_redirect_message = $row->getStatusMessage();
         } else {
             $this->_redirect_message = JText::_(ucfirst(KInflector::singularize($name)) . ' ' . $action . ' failed');
         }
     }
     if (!is_null($status) && $status != KDatabase::STATUS_LOADED) {
         $suffix = $action == 'add' || $action == 'edit' ? 'ed' : 'd';
         $this->_redirect_message = JText::_(ucfirst(KInflector::singularize($name)) . ' ' . $action . $suffix);
     }
 }
示例#15
0
 /**
  * Unset the referrer
  *
  * @return void
  */
 public function unsetReferrer()
 {
     $identifier = $this->getMixer()->getIdentifier();
     KRequest::set('cookie.referrer_' . md5(KRequest::referrer()), null);
 }
示例#16
0
 public function redirect(KCommandContext $context)
 {
     $item = $context->caller->getModel()->getItem();
     if ($item->getStatus() != 'failed') {
         if (!($url = KRequest::get('post.return', 'url'))) {
             $url = 'index.php?Itemid=' . JSite::getMenu()->getDefault()->id;
         }
         $this->setRedirect($url, JText::_('Modifications have been saved.'), 'message');
     } else {
         $this->setRedirect(KRequest::referrer(), $item->getStatusMessage(), 'error');
     }
 }
示例#17
0
    protected function _actionComplete(KCommandContext $context)
    {
        $password        = KRequest::get('post.password', 'raw');
        $password_verify = KRequest::get('post.password_verify', 'raw');

        if(!$password)
        {
            $this->setRedirect(KRequest::referrer(), JText::_('MUST_SUPPLY_PASSWORD'), 'error');
            return false;
        }

        if($password != $password_verify)
        {
            $this->setRedirect(KRequest::referrer(), JText::_('PASSWORDS_DO_NOT_MATCH_LOW'), 'error');
            return false;
        }

        $user     = KFactory::get('joomla:user', array(KRequest::get('session.com.users.id', 'int')));

        JPluginHelper::importPlugin('user');
        $dispatcher = JDispatcher::getInstance();
        $dispatcher->trigger('onBeforeStoreUser', array($user->getProperties(), false));

        KFactory::get('com://site/users.model.users')
            ->set('id', $user->id)
            ->getItem()
            ->set('password', $password)
           	->set('password_verify', $password_verify)
            ->set('activation', '')
            ->save();

        $user->password         = $password;
        $user->activation       = '';
        $user->password_clear   = $password_verify;

        $dispatcher->trigger('onAfterStoreUser', array($user->getProperties(), false, $result));

        KRequest::set('session.com.users.id', null);
        KRequest::set('session.com.users.token', null);

        $this->setRedirect('index.php?option=com_users&view=login', JText::_('PASSWORD_RESET_SUCCESS'));
    }
示例#18
0
 public function afterSave(KCommandContext $context)
 {
     $url = ($referrer = KRequest::get('post.referrer', 'base64')) ? base64_decode($referrer) : KRequest::referrer();
     $this->setRedirect($url);
 }
示例#19
0
            _token: '<?php 
echo JUtility::getToken();
?>
'
        }
    });

    <? if($agent): ?>
    new News.Delete({
        holder: 'article-toolbar',
        url: '<?php 
echo html_entity_decode(@route('view=article'));
?>
',
        forward: '<?php 
echo html_entity_decode(KRequest::referrer());
?>
',
        data: {
			id: '<?php 
echo $article->id;
?>
',
			_token: '<?php 
echo JUtility::getToken();
?>
',
			action: 'delete'			
        }
    });
    <? endif; ?>
示例#20
0
 /**
  * Returns the HTTP referrer.
  *
  * 'referer' a commonly used misspelling word for 'referrer'
  *
  * @see     http://en.wikipedia.org/wiki/HTTP_referrer
  *
  * @param   bool     Only allow internal url's
  *
  * @return  KHttpUrl    A KHttpUrl object
  */
 public function getReferrer($isInternal = true)
 {
     return KRequest::referrer($isInternal);
 }
示例#21
0
    /**
     * Set status messages after save and delete actions
     *
     * @param KCommandContext $context
     */
    public function setStatusMessage(KCommandContext $context)
    {
        $translator = $this->getService('translator')->getTranslator($this->getIdentifier());
        $action = strtolower($translator->translate($context->action));
        $name   = $this->getIdentifier()->name;
        $item_type = ucfirst($translator->translate(KInflector::singularize($name)));
        $rowset = ($context->result instanceof KDatabaseRowAbstract) ? array($context->result) : $context->result;
        $failed = false;

        foreach ($rowset as $row) {
            if ($row->getStatus() == KDatabase::STATUS_FAILED) {
                $this->_redirect        = KRequest::referrer();
                $this->_redirect_type   = 'error';

                if ($row->getStatusMessage()) {
                    $this->_redirect_message = $row->getStatusMessage();
                } else {
                    $this->_redirect_message = ucfirst($translator->translate('%item_type% %action% failed', array(
                        '%item_type%' => $item_type,
                        '%action%'    => $action
                    )));
                }

                $failed = true;
                break;
            }
        }

        if (!$failed && count($rowset) === 1) {
            $this->_redirect_message = ucfirst($translator->translate('%item_type% %action% successful', array(
                '%item_type%' => $item_type,
                '%action%'    => $action
            )));
        }
    }
示例#22
0
 public function redirect(KCommandContext $context)
 {
     $item = $context->caller->getModel()->getItem();
     if ($item->getStatus() != KDatabase::STATUS_FAILED) {
         $this->setRedirect(KRequest::referrer(), JText::_('Modifications have been saved.'), 'message');
     } else {
         $this->setRedirect(KRequest::referrer(), $item->getStatusMessage(), 'error');
     }
 }