Skip to content

Commit

Permalink
[imp] Codestyle fixes for plugins. Fixes #3322. Fixes #3323. Fixes #3324
Browse files Browse the repository at this point in the history
. Fixes #3325. Fixes #3326. Fixes #3327. Fixes #3328. Fixes #3329

@Package     Joomla.Plugin
@subpackage  System.p3p

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  System.languagefilter

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  System.sef

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  System.cache

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  System.languagecode

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  System.logout

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  System.Highlight

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  System.Debug

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  System.redirect

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  System.log

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  System.remember

[CodeStyle] Add description for onUserLogout

[CodeStyle] add variable description

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Twofactorauth.totp

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Twofactorauth.yubikey

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Search.weblinks

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Search.categories

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Search.contacts

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Search.content

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Search.newsfeeds

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Finder.Categories

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Finder.Contacts

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Finder.Content

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Finder.Newsfeeds

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Finder.Tags

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Finder.Weblinks

Fix word spelling

[UNDO] Codestyle changes

Reason:
#3326 (comment)

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Extension.Joomla

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Content.Contact

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Content.emailcloak

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Content.loadmodule

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Content.vote

[CodeStyle] add variable description

[CodeStyle] change variable description

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Authentication.joomla

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Authentication.cookie

[CodeStyle] additional CodeStyle according https://github.com/shopfe/joomla-cms/commit/8da6fe6e361a5287902ae4a41d317478f15bd4d2#commitcomment-5721073

CodeStyle correction

@Package     Joomla.Plugin
@subpackage  Editors.none

[CodeStyle] Add description for onGetInsertMethod
  • Loading branch information
Sebastian Hopfe authored and phproberto committed Mar 20, 2014
1 parent 74a70d4 commit 54972ff
Show file tree
Hide file tree
Showing 32 changed files with 168 additions and 81 deletions.
42 changes: 19 additions & 23 deletions plugins/authentication/cookie/cookie.php
Expand Up @@ -59,8 +59,8 @@ public function onUserAuthenticate($credentials, $options, &$response)

// Get cookie
$cookieName = JUserHelper::getShortHashedUserAgent();

$cookieValue = $this->app->input->cookie->get($cookieName);

if (!$cookieValue)
{
return;
Expand Down Expand Up @@ -95,7 +95,6 @@ public function onUserAuthenticate($credentials, $options, &$response)
->where($this->db->quoteName('series') . ' = ' . $this->db->quote($series))
->where($this->db->quoteName('uastring') . ' = ' . $this->db->quote($cookieName))
->order($this->db->quoteName('time') . ' DESC');

$results = $this->db->setQuery($query)->loadObjectList();

if (count($results) !== 1)
Expand All @@ -111,6 +110,7 @@ public function onUserAuthenticate($credentials, $options, &$response)
else
{
$token = JUserHelper::hashPassword($cookieArray[0]);

if (!JUserHelper::verifyPassword($cookieArray[0], $results[0]->token))
{
// This is a real attack! Either the series was guessed correctly or a cookie was stolen and used twice (once by attacker and once by victim).
Expand All @@ -124,10 +124,8 @@ public function onUserAuthenticate($credentials, $options, &$response)
$this->app->input->cookie->set($cookieName, false, time() - 42000, $this->app->get('cookie_path', '/'), $this->app->get('cookie_domain'));

// Issue warning by email to user and/or admin?
JLog::add(JText::sprintf('PLG_AUTH_COOKIE_ERROR_LOG_LOGIN_FAILED', $results[0]->user_id), JLog::WARNING, 'security');

$response->status = JAuthentication::STATUS_FAILURE;
$response->status = JAuthentication::STATUS_FAILURE;

return false;
}
Expand All @@ -138,7 +136,6 @@ public function onUserAuthenticate($credentials, $options, &$response)
->select($this->db->quoteName(array('id', 'username', 'password')))
->from($this->db->quoteName('#__users'))
->where($this->db->quoteName('username') . ' = ' . $this->db->quote($results[0]->user_id));

$result = $this->db->setQuery($query)->loadObject();

if ($result)
Expand All @@ -147,11 +144,11 @@ public function onUserAuthenticate($credentials, $options, &$response)
$user = JUser::getInstance($result->id);

// Set response data.
$response->username = $result->username;
$response->email = $user->email;
$response->fullname = $user->name;
$response->password = $result->password;
$response->language = $user->getParam('language');
$response->username = $result->username;
$response->email = $user->email;
$response->fullname = $user->name;
$response->password = $result->password;
$response->language = $user->getParam('language');

// Set response status.
$response->status = JAuthentication::STATUS_SUCCESS;
Expand All @@ -169,7 +166,7 @@ public function onUserAuthenticate($credentials, $options, &$response)
* We set a new cookie either for a user with no cookies or one
* where the user used a cookie to authenticate.
*
* @param array options Array holding options
* @param array $options Array holding options
*
* @return boolean True on success
*
Expand All @@ -191,6 +188,7 @@ public function onUserAfterLogin($options)
// We need the old data to get the existing series
$cookieValue = $this->app->input->cookie->get($cookieName);
$cookieArray = explode('.', $cookieValue);

// Filter series since we're going to use it in the query
$filter = new JFilterInput;
$series = $filter->clean($cookieArray[1], 'ALNUM');
Expand All @@ -202,22 +200,22 @@ public function onUserAfterLogin($options)

// Create an unique series which will be used over the lifespan of the cookie
$unique = false;

do
{
$series = JUserHelper::genRandomPassword(20);

$query = $this->db->getQuery(true)
->select($this->db->quoteName('series'))
->from($this->db->quoteName('#__user_keys'))
->where($this->db->quoteName('series') . ' = ' . $this->db->quote($series));

$results = $this->db->setQuery($query)->loadResult();

if (is_null($results))
{
$unique = true;
}
}

while ($unique === false);
}
else
Expand All @@ -226,18 +224,17 @@ public function onUserAfterLogin($options)
}

// Get the parameter values
$lifetime = $this->params->get('cookie_lifetime', '60') * 24 * 60 * 60;
$length = $this->params->get('key_length', '16');
$lifetime = $this->params->get('cookie_lifetime', '60') * 24 * 60 * 60;
$length = $this->params->get('key_length', '16');

// Generate new cookie
$token = JUserHelper::genRandomPassword($length);
$cookieValue = $token . '.' . $series;
$token = JUserHelper::genRandomPassword($length);
$cookieValue = $token . '.' . $series;

// Overwrite existing cookie with new value
$this->app->input->cookie->set(
$cookieName, $cookieValue, time() + $lifetime, $this->app->get('cookie_path', '/'), $this->app->get('cookie_domain'), $this->app->isSSLConnection()
);

$query = $this->db->getQuery(true);

if (!empty($options['remember']))
Expand All @@ -263,7 +260,6 @@ public function onUserAfterLogin($options)
$hashed_token = JUserHelper::hashPassword($token);
$query
->set($this->db->quoteName('token') . ' = ' . $this->db->quote($hashed_token));

$this->db->setQuery($query)->execute();

return true;
Expand All @@ -288,6 +284,7 @@ public function onUserAfterLogout($options)

$cookieName = JUserHelper::getShortHashedUserAgent();
$cookieValue = $this->app->input->cookie->get($cookieName);

// There are no cookies to delete.
if (!$cookieValue)
{
Expand All @@ -297,15 +294,14 @@ public function onUserAfterLogout($options)
$cookieArray = explode('.', $cookieValue);

// Filter series since we're going to use it in the query
$filter = new JFilterInput;
$series = $filter->clean($cookieArray[1], 'ALNUM');
$filter = new JFilterInput;
$series = $filter->clean($cookieArray[1], 'ALNUM');

// Remove the record from the database
$query = $this->db->getQuery(true);
$query
->delete('#__user_keys')
->where($this->db->quoteName('series') . ' = ' . $this->db->quote($series));

$this->db->setQuery($query)->execute();

// Destroy the cookie
Expand Down
2 changes: 1 addition & 1 deletion plugins/authentication/joomla/joomla.php
Expand Up @@ -191,7 +191,7 @@ public function onUserAuthenticate($credentials, $options, &$response)
*/
return false;
}
}
}

// Clean up the OTEP (remove dashes, spaces and other funny stuff
// our beloved users may have unwittingly stuffed in it)
Expand Down
6 changes: 4 additions & 2 deletions plugins/content/contact/contact.php
Expand Up @@ -31,6 +31,7 @@ class PlgContentContact extends JPlugin
public function onContentPrepare($context, &$row, $params, $page = 0)
{
$allowed_contexts = array('com_content.category', 'com_content.article', 'com_content.featured');

if (!in_array($context, $allowed_contexts))
{
return true;
Expand Down Expand Up @@ -69,14 +70,15 @@ public function onContentPrepare($context, &$row, $params, $page = 0)
/**
* Retrieve Contact
*
* @param int $created_by
* @param int $created_by Id of the user who created the contact
*
* @return mixed|null|integer
*/
protected function getContactID($created_by)
{
static $contacts = array();
if(isset($contacts[$created_by]))

if (isset($contacts[$created_by]))
{
return $contacts[$created_by];
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/content/emailcloak/emailcloak.php
Expand Up @@ -116,10 +116,10 @@ protected function _cloak(&$text, &$params)

$mode = $this->params->def('mode', 1);

// any@email.address.com
// Example: any@email.address.com
$searchEmail = '([\w\.\-]+\@(?:[a-z0-9\.\-]+\.)+(?:[a-zA-Z0-9\-]{2,10}))';

// any@email.address.com?subject=anyText
// Example: any@email.address.com?subject=anyText
$searchEmailLink = $searchEmail . '([?&][\x20-\x7f][^"<>]+)';

// Any Text
Expand Down
2 changes: 1 addition & 1 deletion plugins/content/loadmodule/loadmodule.php
Expand Up @@ -173,7 +173,7 @@ protected function _loadmod($module, $title, $style = 'none')
// This allows people to enter it either way in the content
if (!isset($mod))
{
$name = 'mod_'.$module;
$name = 'mod_' . $module;
$mod = JModuleHelper::getModule($name, $title);
}

Expand Down
1 change: 1 addition & 0 deletions plugins/content/vote/vote.php
Expand Up @@ -41,6 +41,7 @@ class PlgContentVote extends JPlugin
public function onContentBeforeDisplay($context, &$row, &$params, $page=0)
{
$parts = explode(".", $context);

if ($parts[0] != 'com_content')
{
return false;
Expand Down
2 changes: 2 additions & 0 deletions plugins/editors/none/none.php
Expand Up @@ -92,6 +92,8 @@ public function onSetContent($id, $html)
}

/**
* Inserts html code into the editor
*
* @param string $id The id of the editor field
*
* @return boolean returns true when complete
Expand Down
7 changes: 4 additions & 3 deletions plugins/extension/joomla/joomla.php
Expand Up @@ -70,6 +70,7 @@ private function addUpdateSite($name, $type, $location, $enabled)
->columns(array($db->quoteName('name'), $db->quoteName('type'), $db->quoteName('location'), $db->quoteName('enabled')))
->values($db->quote($name) . ', ' . $db->quote($type) . ', ' . $db->quote($location) . ', ' . (int) $enabled);
$db->setQuery($query);

if ($db->execute())
{
// Link up this extension to the update site
Expand All @@ -88,6 +89,7 @@ private function addUpdateSite($name, $type, $location, $enabled)
->where('extension_id = ' . $this->eid);
$db->setQuery($query);
$tmpid = (int) $db->loadResult();

if (!$tmpid)
{
// Link this extension to the relevant update site
Expand Down Expand Up @@ -187,13 +189,12 @@ public function onExtensionAfterUninstall($installer, $eid, $result)
// Note: this might wipe out the entire table if there are no extensions linked
$db->setQuery($updatesite_delete);
$db->execute();

}

// Last but not least we wipe out any pending updates for the extension
$query->clear()
->delete('#__updates')
->where('extension_id = '. $eid);
->where('extension_id = ' . $eid);
$db->setQuery($query);
$db->execute();
}
Expand All @@ -216,7 +217,7 @@ public function onExtensionAfterUpdate($installer, $eid)
$this->installer = $installer;
$this->eid = $eid;

// handle any update sites
// Handle any update sites
$this->processUpdateSites();
}
}
Expand Down
10 changes: 7 additions & 3 deletions plugins/finder/categories/categories.php
Expand Up @@ -140,8 +140,8 @@ public function onFinderAfterSave($context, $row, $isNew)
{
$this->categoryAccessChange($row);
}

}

return true;
}

Expand Down Expand Up @@ -203,7 +203,6 @@ public function onFinderChangeState($context, $pks, $value)
$query = clone($this->getStateQuery());
$query->where('a.id = ' . (int) $pk);
// Get the published states.
$this->db->setQuery($query);
$item = $this->db->loadObject();
*/
Expand Down Expand Up @@ -256,6 +255,7 @@ protected function index(FinderIndexerResult $item, $format = 'html')

// Need to import component route helpers dynamically, hence the reason it's handled here.
$path = JPATH_SITE . '/components/' . $item->extension . '/helpers/route.php';

if (is_file($path))
{
include_once $path;
Expand Down Expand Up @@ -285,6 +285,8 @@ protected function index(FinderIndexerResult $item, $format = 'html')
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'author');

// Deactivated Methods
// $item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias');

// Trigger the onContentPrepare event.
Expand All @@ -294,6 +296,7 @@ protected function index(FinderIndexerResult $item, $format = 'html')
$item->url = $this->getURL($item->id, $item->extension, $this->layout);

$class = $extension . 'HelperRoute';

if (class_exists($class) && method_exists($class, 'getCategoryRoute'))
{
$item->route = $class::getCategoryRoute($item->id, $item->language);
Expand All @@ -302,6 +305,7 @@ protected function index(FinderIndexerResult $item, $format = 'html')
{
$item->route = ContentHelperRoute::getCategoryRoute($item->slug, $item->catid);
}

$item->path = FinderIndexerHelper::getContentPath($item->route);

// Get the menu title if it exists.
Expand Down Expand Up @@ -371,7 +375,7 @@ protected function getListQuery($query = null)
$a_id = $query->castAsChar('a.id');
$case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when_item_alias .= ' ELSE ';
$case_when_item_alias .= $a_id.' END as slug';
$case_when_item_alias .= $a_id . ' END as slug';
$query->select($case_when_item_alias)
->from('#__categories AS a')
->where($db->quoteName('a.id') . ' > 1');
Expand Down
5 changes: 3 additions & 2 deletions plugins/finder/contacts/contacts.php
Expand Up @@ -408,6 +408,7 @@ protected function setup()
protected function getListQuery($query = null)
{
$db = JFactory::getDbo();

// Check if we can use the supplied SQL query.
$query = $query instanceof JDatabaseQuery ? $query : $db->getQuery(true)
->select('a.id, a.name AS title, a.alias, a.con_position AS position, a.address, a.created AS start_date')
Expand All @@ -427,7 +428,7 @@ protected function getListQuery($query = null)
$a_id = $query->castAsChar('a.id');
$case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when_item_alias .= ' ELSE ';
$case_when_item_alias .= $a_id.' END as slug';
$case_when_item_alias .= $a_id . ' END as slug';
$query->select($case_when_item_alias);

$case_when_category_alias = ' CASE WHEN ';
Expand All @@ -436,7 +437,7 @@ protected function getListQuery($query = null)
$c_id = $query->castAsChar('c.id');
$case_when_category_alias .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when_category_alias .= ' ELSE ';
$case_when_category_alias .= $c_id.' END as catslug';
$case_when_category_alias .= $c_id . ' END as catslug';
$query->select($case_when_category_alias)

->select('u.name')
Expand Down
4 changes: 2 additions & 2 deletions plugins/finder/content/content.php
Expand Up @@ -358,7 +358,7 @@ protected function getListQuery($query = null)
$a_id = $query->castAsChar('a.id');
$case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when_item_alias .= ' ELSE ';
$case_when_item_alias .= $a_id.' END as slug';
$case_when_item_alias .= $a_id . ' END as slug';
$query->select($case_when_item_alias);

$case_when_category_alias = ' CASE WHEN ';
Expand All @@ -367,7 +367,7 @@ protected function getListQuery($query = null)
$c_id = $query->castAsChar('c.id');
$case_when_category_alias .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when_category_alias .= ' ELSE ';
$case_when_category_alias .= $c_id.' END as catslug';
$case_when_category_alias .= $c_id . ' END as catslug';
$query->select($case_when_category_alias)

->select('u.name AS author')
Expand Down
4 changes: 2 additions & 2 deletions plugins/finder/newsfeeds/newsfeeds.php
Expand Up @@ -349,7 +349,7 @@ protected function getListQuery($query = null)
$a_id = $query->castAsChar('a.id');
$case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when_item_alias .= ' ELSE ';
$case_when_item_alias .= $a_id.' END as slug';
$case_when_item_alias .= $a_id . ' END as slug';
$query->select($case_when_item_alias);

$case_when_category_alias = ' CASE WHEN ';
Expand All @@ -358,7 +358,7 @@ protected function getListQuery($query = null)
$c_id = $query->castAsChar('c.id');
$case_when_category_alias .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when_category_alias .= ' ELSE ';
$case_when_category_alias .= $c_id.' END as catslug';
$case_when_category_alias .= $c_id . ' END as catslug';
$query->select($case_when_category_alias)

->from('#__newsfeeds AS a')
Expand Down

0 comments on commit 54972ff

Please sign in to comment.