Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] uncouple guest_usergroup from com_users #84

Open
wants to merge 13 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function update($installer)

// This needs to stay for 2.5 update compatibility
$this->deleteUnexistingFiles();
$this->updateGlobalConfig();
$this->updateManifestCaches();
$this->updateDatabase();
$this->clearRadCache();
Expand All @@ -46,6 +47,27 @@ public function update($installer)
$this->flushSessions();
}

/**
* Method to add new values to Global Config.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
protected function updateGlobalConfig()
{
// Since __DEPLOY_VERSION__. Moves guest_usergroup option from com_users component to global config.
if (!JFactory::getApplication()->get('guest_usergroup', ''))
{
// Load the global config model.
JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_config/model', 'ConfigModel');

// Add the new option to config.
$modelConfig = JModelLegacy::getInstance('Application', 'ConfigModel');
$modelConfig->save(array('guest_usergroup' => JComponentHelper::getParams('com_users')->get('guest_usergroup', 1)));
}
}

/**
* Method to clear our stats plugin cache to ensure we get fresh data on Joomla Update
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,15 @@
description="COM_CONFIG_FIELD_DEFAULT_ACCESS_LEVEL_DESC"
filter="integer" />

<field
name="guest_usergroup"
type="usergrouplist"
label="COM_CONFIG_FIELD_DEFAULT_GUEST_USER_GROUP_LABEL"
description="COM_CONFIG_FIELD_DEFAULT_GUEST_USER_GROUP_DESC"
default="1"
filter="integer"
/>

<field
name="list_limit"
type="list"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function render()
"sitename" => null,
"offline" => null,
"access" => null,
"guest_usergroup" => null,
"list_limit" => null,
"MetaDesc" => null,
"MetaKeys" => null,
Expand Down
8 changes: 0 additions & 8 deletions administrator/components/com_users/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@
showon="allowUserRegistration:1">
</field>

<field
name="guest_usergroup"
type="usergrouplist"
default="1"
label="COM_USERS_CONFIG_FIELD_GUEST_USER_GROUP_LABEL"
description="COM_USERS_CONFIG_FIELD_GUEST_USER_GROUP_DESC">
</field>

<field
name="sendpassword"
type="radio"
Expand Down
2 changes: 2 additions & 0 deletions administrator/language/en-GB/en-GB.com_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ COM_CONFIG_FIELD_DEFAULT_CAPTCHA_DESC="Select the default captcha for your site.
COM_CONFIG_FIELD_DEFAULT_CAPTCHA_LABEL="Default Captcha"
COM_CONFIG_FIELD_DEFAULT_FEED_LIMIT_DESC="Select the number of content items to show in the feed(s)."
COM_CONFIG_FIELD_DEFAULT_FEED_LIMIT_LABEL="Default Feed Limit"
COM_CONFIG_FIELD_DEFAULT_GUEST_USER_GROUP_DESC="The default Group that will be applied to Guest (not logged-in) Users."
COM_CONFIG_FIELD_DEFAULT_GUEST_USER_GROUP_LABEL="Default Guest User Group"
COM_CONFIG_FIELD_DEFAULT_LIST_LIMIT_DESC="Sets the default length of lists in the Control Panel for all users."
COM_CONFIG_FIELD_DEFAULT_LIST_LIMIT_LABEL="Default List Limit"
COM_CONFIG_FIELD_ERROR_REPORTING_DESC="Select the level of reporting. See the Help Screen for full details."
Expand Down
1 change: 1 addition & 0 deletions installation/configuration.php-dist
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class JConfig
public $captcha = '0';
public $list_limit = '20';
public $access = '1';
public $guest_usergroup = '1';

/* Database Settings */
public $dbtype = 'mysqli'; // Normally mysqli
Expand Down
55 changes: 55 additions & 0 deletions installation/model/configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public function setup($options)
// Get the options as an object for easier handling.
$options = ArrayHelper::toObject($options);

// Update the guest user group id.
$options->guest_usergroup = $this->getGuestUserGroup($options, 1);

// Attempt to create the configuration.
if (!$this->createConfiguration($options))
{
Expand All @@ -48,6 +51,57 @@ public function setup($options)
return true;
}

/**
* Method to get the guest user group based on the usergroups table.
*
* @param array $options The session options.
* @param integer $default The default guest user group.
*
* @return integer The guest user group id.
*
* @since __DEPLOY_VERSION__
*/
private function getGuestUserGroup($options, $default = 1)
{
// Get a database object.
try
{
$db = InstallationHelperDatabase::getDbo(
$options->db_type,
$options->db_host,
$options->db_user,
$options->db_pass,
$options->db_name,
$options->db_prefix
);
}
catch (RuntimeException $e)
{
JFactory::getApplication()->enqueueMessage(JText::sprintf('INSTL_ERROR_CONNECT_DB', $e->getMessage()), 'error');

return false;
}

// Quey to get the guest user group.
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__usergroups'))
->where($db->quoteName('title') . ' = ' . $db->quote('Guest'));

$db->setQuery($query);

try
{
return (int) $db->loadResult();
}
catch (RuntimeException $e)
{
return $default;
}

return $default;
}

/**
* Method to create the configuration file
*
Expand All @@ -72,6 +126,7 @@ public function createConfiguration($options)
$registry->set('captcha', '0');
$registry->set('list_limit', 20);
$registry->set('access', 1);
$registry->set('guest_usergroup', $options->guest_usergroup);

// Debug settings.
$registry->set('debug', 0);
Expand Down
2 changes: 1 addition & 1 deletion installation/sql/mysql/joomla.sql
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder`
(22, 'com_content', 'component', 'com_content', '', 1, 1, 0, 1, '', '{"article_layout":"_:default","show_title":"1","link_titles":"1","show_intro":"1","show_category":"1","link_category":"1","show_parent_category":"0","link_parent_category":"0","show_author":"1","link_author":"0","show_create_date":"0","show_modify_date":"0","show_publish_date":"1","show_item_navigation":"1","show_vote":"0","show_readmore":"1","show_readmore_title":"1","readmore_limit":"100","show_icons":"1","show_print_icon":"1","show_email_icon":"1","show_hits":"1","show_noauth":"0","show_publishing_options":"1","show_article_options":"1","save_history":"1","history_limit":10,"show_urls_images_frontend":"0","show_urls_images_backend":"1","targeta":0,"targetb":0,"targetc":0,"float_intro":"left","float_fulltext":"left","category_layout":"_:blog","show_category_title":"0","show_description":"0","show_description_image":"0","maxLevel":"1","show_empty_categories":"0","show_no_articles":"1","show_subcat_desc":"1","show_cat_num_articles":"0","show_base_description":"1","maxLevelcat":"-1","show_empty_categories_cat":"0","show_subcat_desc_cat":"1","show_cat_num_articles_cat":"1","num_leading_articles":"1","num_intro_articles":"4","num_columns":"2","num_links":"4","multi_column_order":"0","show_subcategory_content":"0","show_pagination_limit":"1","filter_field":"hide","show_headings":"1","list_show_date":"0","date_format":"","list_show_hits":"1","list_show_author":"1","orderby_pri":"order","orderby_sec":"rdate","order_date":"published","show_pagination":"2","show_pagination_results":"1","show_feed_link":"1","feed_summary":"0"}', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(23, 'com_config', 'component', 'com_config', '', 1, 1, 0, 1, '', '{"filters":{"1":{"filter_type":"NH","filter_tags":"","filter_attributes":""},"6":{"filter_type":"BL","filter_tags":"","filter_attributes":""},"7":{"filter_type":"NONE","filter_tags":"","filter_attributes":""},"2":{"filter_type":"NH","filter_tags":"","filter_attributes":""},"3":{"filter_type":"BL","filter_tags":"","filter_attributes":""},"4":{"filter_type":"BL","filter_tags":"","filter_attributes":""},"5":{"filter_type":"BL","filter_tags":"","filter_attributes":""},"10":{"filter_type":"BL","filter_tags":"","filter_attributes":""},"12":{"filter_type":"BL","filter_tags":"","filter_attributes":""},"8":{"filter_type":"NONE","filter_tags":"","filter_attributes":""}}}', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(24, 'com_redirect', 'component', 'com_redirect', '', 1, 1, 0, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(25, 'com_users', 'component', 'com_users', '', 1, 1, 0, 1, '', '{"allowUserRegistration":"0","new_usertype":"2","guest_usergroup":"9","sendpassword":"1","useractivation":"1","mail_to_admin":"0","captcha":"","frontend_userparams":"1","site_language":"0","change_login_name":"0","reset_count":"10","reset_time":"1","minimum_length":"4","minimum_integers":"0","minimum_symbols":"0","minimum_uppercase":"0","save_history":"1","history_limit":5,"mailSubjectPrefix":"","mailBodySuffix":""}', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(25, 'com_users', 'component', 'com_users', '', 1, 1, 0, 1, '', '{"allowUserRegistration":"0","new_usertype":"2","sendpassword":"1","useractivation":"1","mail_to_admin":"0","captcha":"","frontend_userparams":"1","site_language":"0","change_login_name":"0","reset_count":"10","reset_time":"1","minimum_length":"4","minimum_integers":"0","minimum_symbols":"0","minimum_uppercase":"0","save_history":"1","history_limit":5,"mailSubjectPrefix":"","mailBodySuffix":""}', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(27, 'com_finder', 'component', 'com_finder', '', 1, 1, 0, 0, '', '{"show_description":"1","description_length":255,"allow_empty_query":"0","show_url":"1","show_advanced":"1","expand_advanced":"0","show_date_filters":"0","highlight_terms":"1","opensearch_name":"","opensearch_description":"","batch_size":"50","memory_table_limit":30000,"title_multiplier":"1.7","text_multiplier":"0.7","meta_multiplier":"1.2","path_multiplier":"2.0","misc_multiplier":"0.3","stemmer":"snowball"}', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(28, 'com_joomlaupdate', 'component', 'com_joomlaupdate', '', 1, 1, 0, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(29, 'com_tags', 'component', 'com_tags', '', 1, 1, 1, 1, '', '{"tag_layout":"_:default","save_history":"1","history_limit":5,"show_tag_title":"0","tag_list_show_tag_image":"0","tag_list_show_tag_description":"0","tag_list_image":"","show_tag_num_items":"0","tag_list_orderby":"title","tag_list_orderby_direction":"ASC","show_headings":"0","tag_list_show_date":"0","tag_list_show_item_image":"0","tag_list_show_item_description":"0","tag_list_item_maximum_characters":0,"return_any_or_all":"1","include_children":"0","maximum":200,"tag_list_language_filter":"all","tags_layout":"_:default","all_tags_orderby":"title","all_tags_orderby_direction":"ASC","all_tags_show_tag_image":"0","all_tags_show_tag_descripion":"0","all_tags_tag_maximum_characters":20,"all_tags_show_tag_hits":"0","filter_field":"1","show_pagination_limit":"1","show_pagination":"2","show_pagination_results":"1","tag_field_ajax_mode":"1","show_feed_link":"1"}', '', '', 0, '0000-00-00 00:00:00', 0, 0),
Expand Down
2 changes: 0 additions & 2 deletions installation/sql/mysql/sample_learn.sql
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,4 @@ INSERT IGNORE INTO `#__viewlevels` (`id`, `title`, `ordering`, `rules`) VALUES
(5, 'Guest', 1, '[13]'),
(6, 'Super Users', 5, '[8]');

UPDATE `#__extensions` SET `params`='{"allowUserRegistration":"0","new_usertype":"2","guest_usergroup":"13","sendpassword":"1","useractivation":"1","mail_to_admin":"0","captcha":"","frontend_userparams":"1","site_language":"0","change_login_name":"0","reset_count":"10","reset_time":"1","mailSubjectPrefix":"","mailBodySuffix":"","save_history":"1","history_limit":5}' WHERE extension_id=25;

SET FOREIGN_KEY_CHECKS=1;
2 changes: 0 additions & 2 deletions installation/sql/mysql/sample_testing.sql
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,4 @@ INSERT INTO `#__ucm_content` (`core_content_id`, `core_type_alias`, `core_title`
(1, 'com_content.article', 'Joomla! Testing', 'joomla', '<p>Thanks for helping us to test Joomla!</p><p>We''re getting ready for the release of Joomla and we appreciate you helping us find and fix problems as we work.</p><p>If you haven''t done testing before here are some tips.</p><ul><li>Don''t delete the installation folder when you finish installing! While we''re working we turn that security feature off to make it easier to test.</li><li>Go to global configuration and set Error Reporting to Development (that''s on the server tab) and enable both debugging and language debugging (those are on the system tab). Don''t worry when you see ** around words --that means Joomla translation is doing its job.</li></ul><p>How to test</p><ul><li>First, do the things you normally do and see if you spot any problems.</li><li>Look at all of the front end views and record any problems</li><li>Look at all the back end views and report any problems</li><li>See more ideas below</li></ul><p>What to look for</p><ul><li>Any error messages that say things like Fatal Error or Strict or similar things that indicate that something is not working correctly.</li><li>Untranslated strings. You will know these because they look like this: ?STRING_HERE?</li><li>Problems of rendering--items not aligned correctly, missing or wrong images, pages that just don''t look right.</li><li>Unexpected behavior--anything that is working differently than it did in 2.5.</li></ul><p>Report problems</p><p>If you find a problem please report it to the <a href="https://issues.joomla.org" target="_blank">CMS Issue Tracker</a>. You will need to register for a github.com account if you don''t have one.</p><p>More Testing Ideas</p><ul><li>Pick one module or view and test all of the parameters.</li><li>Install an extension and see if anything breaks (report to the developer unless you are positive it is a core bug).</li><li>Turn on caching with different options</li><li>Try different session options</li><li>Install a language and test all the layouts.</li><li>Try different environments (like different servers which may have different version of PHP) or try you have IIS with MySQLi or SqlSrv. With millions of users Joomla needs to be ready for unusual environments.</li><li>Try with SEF URLS on or off and also with Apache rewrite on or off (if you are on Apache).</li><li>Try different combinations of browsers (Chrome, IE, FireFox, Opera to start) and operating systems (Mac, Windows, Linux).</li><li>Yes grammar and spelling errors are bugs too -- just keep in mind that we use British spelling.</li><li>Visit the <a href="https://issues.joomla.org" target="_blank">Feature Tracker</a> and test a new feature.</li></ul><p>Testing changes</p><p>You can also help Joomla by testing bug fixes and new features. A useful tool is the <a href="https://github.com/joomla-extensions/patchtester/releases" target="_blank">patchtester component</a> which helps to simplify and automate the process. Report your feedback on the <span style="line-height: 1.3em;"> </span><a style="line-height: 1.3em;" href="https://issues.joomla.org" target="_blank">CMS Issue Tracker</a>. If you enjoy helping Joomla this way, you may want to join the <a href="https://docs.joomla.org/Bug_Squad" target="_blank">Joomla Bug Squad</a>.</p><p></p>', 1, '', 0, 1, '{"show_title":"","link_titles":"","show_tags":"","show_intro":"","info_block_position":"","show_category":"","link_category":"","show_parent_category":"","link_parent_category":"","show_author":"","link_author":"","show_create_date":"","show_modify_date":"","show_publish_date":"","show_item_navigation":"","show_icons":"","show_print_icon":"","show_email_icon":"","show_vote":"","show_hits":"","show_noauth":"","urls_position":"","alternative_readmore":"","article_layout":""}', 1, '{"robots":"","author":"","rights":"","xreference":""}', 716, '', '2011-01-01 00:00:01', 0, '2013-10-15 14:57:20', '*', '2011-01-01 00:00:01', '0000-00-00 00:00:00', 24, 180, '{"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}', '{"urla":false,"urlatext":"","targeta":"","urlb":false,"urlbtext":"","targetb":"","urlc":false,"urlctext":"","targetc":""}', 59, 3, 2, '', '', 19, '', 1),
(3, 'com_content.article', 'Similar Tags', 'similar-tags', '<p>The similar tags modules shows a list of items which have the same or a similar set of tags.</p><p>{loadmodule tags_similar,Similar Tags}</p>', 1, '', 0, 1, '{"show_title":"","link_titles":"","show_tags":"","show_intro":"","info_block_position":"","show_category":"","link_category":"","show_parent_category":"","link_parent_category":"","show_author":"","link_author":"","show_create_date":"","show_modify_date":"","show_publish_date":"","show_item_navigation":"","show_icons":"","show_print_icon":"","show_email_icon":"","show_vote":"","show_hits":"","show_noauth":"","urls_position":"","alternative_readmore":"","article_layout":"","show_publishing_options":"","show_article_options":"","show_urls_images_backend":"","show_urls_images_frontend":""}', 0, '{"robots":"","author":"","rights":"","xreference":""}', 371, '', '2013-10-31 00:14:17', 371, '2013-10-31 00:39:09', '*', '2013-10-31 00:14:17', '0000-00-00 00:00:00', 71, 179, '{"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}', '{"urla":false,"urlatext":"","targeta":"","urlb":false,"urlbtext":"","targetb":"","urlc":false,"urlctext":"","targetc":""}', 3, 4, 0, '', '', 64, '', 1);

UPDATE `#__extensions` SET `params`='{"allowUserRegistration":"0","new_usertype":"2","guest_usergroup":"13","sendpassword":"1","useractivation":"1","mail_to_admin":"0","captcha":"","frontend_userparams":"1","site_language":"0","change_login_name":"0","reset_count":"10","reset_time":"1","mailSubjectPrefix":"","mailBodySuffix":"","save_history":"1","history_limit":5}' WHERE extension_id=25;

SET FOREIGN_KEY_CHECKS=1;
Loading