From 38c128710020b89212ad73142815205791e543e8 Mon Sep 17 00:00:00 2001 From: aB0t Date: Mon, 7 Aug 2023 10:33:21 +0200 Subject: [PATCH] Stable release of v2.0.15 Fixed JavaScript Database Manager. Adds new session option. Adds make public switches to back-end. --- CHANGELOG.md | 8 +- README.md | 18 +-- admin/README.txt | 18 +-- admin/access.xml | 4 + admin/language/en-GB/en-GB.com_getbible.ini | 16 ++ .../language/en-GB/en-GB.com_getbible.sys.ini | 4 + admin/layouts/linker/details_above.php | 50 +++++++ admin/layouts/linker/details_left.php | 2 +- admin/layouts/linker/details_right.php | 48 ++++++ .../fields/linkersfilterpublicnotes.php | 77 ++++++++++ .../linkersfilterpublictaggedverses.php | 77 ++++++++++ admin/models/forms/filter_linkers.xml | 18 +++ admin/models/forms/linker.xml | 28 ++++ admin/models/linker.php | 46 ++++++ admin/models/linkers.php | 103 ++++++++++++- admin/sql/install.mysql.utf8.sql | 4 + admin/sql/updates/mysql/2.0.14.sql | 3 + admin/views/linker/tmpl/edit.php | 6 +- admin/views/linkers/tmpl/default_body.php | 6 + admin/views/linkers/tmpl/default_foot.php | 2 +- admin/views/linkers/tmpl/default_head.php | 6 + admin/views/linkers/view.html.php | 42 ++++++ getbible.xml | 6 +- .../VDM.Joomla.GetBible/src/Linker.php | 11 ++ .../VDM.Joomla.GetBible/src/Table.php | 18 +++ script.php | 4 +- site/assets/js/app.js | 43 +++++- site/language/en-GB/en-GB.com_getbible.ini | 3 + site/layouts/getbiblefavouriteverse.php | 87 +++++++++++ site/views/app/tmpl/default_getbibleapp.php | 6 +- ...default_getbiblefavouriteverseselector.php | 140 ++++++++++++------ site/views/app/view.html.php | 12 ++ update_server.xml | 18 +++ 33 files changed, 846 insertions(+), 88 deletions(-) create mode 100644 admin/layouts/linker/details_above.php create mode 100644 admin/layouts/linker/details_right.php create mode 100644 admin/models/fields/linkersfilterpublicnotes.php create mode 100644 admin/models/fields/linkersfilterpublictaggedverses.php create mode 100644 admin/sql/updates/mysql/2.0.14.sql create mode 100644 site/layouts/getbiblefavouriteverse.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 4782d97..f2b84c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,4 +74,10 @@ - Adds install mysql commands for faster queries on large systems. - Fixes mobile layout on settings active session tab. -- Making correction to tag descriptions. \ No newline at end of file +- Making correction to tag descriptions. + +# v2.0.15 + +- Fixed JavaScript Database Manager +- Adds new session option +- Adds make public switches to back-end \ No newline at end of file diff --git a/README.md b/README.md index 150ca50..feba0c4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Get Bible (2.0.14) +# Get Bible (2.0.15) ![Get Bible image](https://git.vdm.dev/getBible/joomla-component/raw/branch/master/admin/assets/images/vdm-component.jpg "GetBible") @@ -18,32 +18,32 @@ In essence, The Bible for Joomla is designed to transform how the Word of God is + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Get Bible](https://getbible.net) + *First Build*: 3rd December, 2015 -+ *Last Build*: 5th August, 2023 -+ *Version*: 2.0.14 ++ *Last Build*: 7th August, 2023 ++ *Version*: 2.0.15 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html ## Build Time -**547 Hours** or **68 Eight Hour Days** (actual time the author saved - +**549 Hours** or **69 Eight Hour Days** (actual time the author saved - due to [Automated Component Builder](https://www.joomlacomponentbuilder.com)) > (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**, > never making one mistake or taking any coffee break.) -+ *Line count*: **196060** -+ *File count*: **1704** ++ *Line count*: **196866** ++ *File count*: **1710** + *Folder count*: **163** -**361 Hours** or **46 Eight Hour Days** (the actual time the author spent) +**363 Hours** or **45 Eight Hour Days** (the actual time the author spent) > (with the following break down: > **debugging @137hours** = codingtime / 4; > **planning @78hours** = codingtime / 7; > **mapping @55hours** = codingtime / 10; -> **office @91hours** = codingtime / 6;) +> **office @92hours** = codingtime / 6;) -**908 Hours** or **114 Eight Hour Days** +**912 Hours** or **114 Eight Hour Days** (a total of the realistic time frame for this project) > (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**, diff --git a/admin/README.txt b/admin/README.txt index 150ca50..feba0c4 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -1,4 +1,4 @@ -# Get Bible (2.0.14) +# Get Bible (2.0.15) ![Get Bible image](https://git.vdm.dev/getBible/joomla-component/raw/branch/master/admin/assets/images/vdm-component.jpg "GetBible") @@ -18,32 +18,32 @@ In essence, The Bible for Joomla is designed to transform how the Word of God is + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Get Bible](https://getbible.net) + *First Build*: 3rd December, 2015 -+ *Last Build*: 5th August, 2023 -+ *Version*: 2.0.14 ++ *Last Build*: 7th August, 2023 ++ *Version*: 2.0.15 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html ## Build Time -**547 Hours** or **68 Eight Hour Days** (actual time the author saved - +**549 Hours** or **69 Eight Hour Days** (actual time the author saved - due to [Automated Component Builder](https://www.joomlacomponentbuilder.com)) > (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**, > never making one mistake or taking any coffee break.) -+ *Line count*: **196060** -+ *File count*: **1704** ++ *Line count*: **196866** ++ *File count*: **1710** + *Folder count*: **163** -**361 Hours** or **46 Eight Hour Days** (the actual time the author spent) +**363 Hours** or **45 Eight Hour Days** (the actual time the author spent) > (with the following break down: > **debugging @137hours** = codingtime / 4; > **planning @78hours** = codingtime / 7; > **mapping @55hours** = codingtime / 10; -> **office @91hours** = codingtime / 6;) +> **office @92hours** = codingtime / 6;) -**908 Hours** or **114 Eight Hour Days** +**912 Hours** or **114 Eight Hour Days** (a total of the realistic time frame for this project) > (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**, diff --git a/admin/access.xml b/admin/access.xml index e1c2533..6837e1f 100644 --- a/admin/access.xml +++ b/admin/access.xml @@ -56,6 +56,8 @@ + + @@ -276,6 +278,8 @@ + +
diff --git a/admin/language/en-GB/en-GB.com_getbible.ini b/admin/language/en-GB/en-GB.com_getbible.ini index 635fdbb..d546279 100644 --- a/admin/language/en-GB/en-GB.com_getbible.ini +++ b/admin/language/en-GB/en-GB.com_getbible.ini @@ -509,6 +509,10 @@ COM_GETBIBLE_FILTER_PROMPT_ASCENDING="Prompt ascending" COM_GETBIBLE_FILTER_PROMPT_DESCENDING="Prompt descending" COM_GETBIBLE_FILTER_PROMPT_INTEGRATION_SCOPE_ASCENDING="Prompt Integration Scope ascending" COM_GETBIBLE_FILTER_PROMPT_INTEGRATION_SCOPE_DESCENDING="Prompt Integration Scope descending" +COM_GETBIBLE_FILTER_PUBLIC_NOTES_ASCENDING="Public Notes ascending" +COM_GETBIBLE_FILTER_PUBLIC_NOTES_DESCENDING="Public Notes descending" +COM_GETBIBLE_FILTER_PUBLIC_TAGGED_VERSES_ASCENDING="Public Tagged Verses ascending" +COM_GETBIBLE_FILTER_PUBLIC_TAGGED_VERSES_DESCENDING="Public Tagged Verses descending" COM_GETBIBLE_FILTER_PUBLISHED="Status" COM_GETBIBLE_FILTER_PUBLISHED_BOOKS="Status options for books" COM_GETBIBLE_FILTER_PUBLISHED_CHAPTERS="Status options for chapters" @@ -554,6 +558,8 @@ COM_GETBIBLE_FILTER_SELECT_NAME="Select Name" COM_GETBIBLE_FILTER_SELECT_NUMBER="Select Number" COM_GETBIBLE_FILTER_SELECT_OPEN_AI_RESPONSE="Select Open AI Response" COM_GETBIBLE_FILTER_SELECT_PROMPT="Select Prompt" +COM_GETBIBLE_FILTER_SELECT_PUBLIC_NOTES="Select Public Notes" +COM_GETBIBLE_FILTER_SELECT_PUBLIC_TAGGED_VERSES="Select Public Tagged Verses" COM_GETBIBLE_FILTER_SELECT_RESPONSE_ID="Select Response ID" COM_GETBIBLE_FILTER_SELECT_RESPONSE_MODEL="Select Response model" COM_GETBIBLE_FILTER_SELECT_ROLE="Select Role" @@ -609,6 +615,10 @@ COM_GETBIBLE_LINKERS_EDIT_NAME="Linkers Edit Name" COM_GETBIBLE_LINKERS_EDIT_NAME_DESC="Allows the users in this group to edit name of linker" COM_GETBIBLE_LINKERS_EDIT_OWN="Linkers Edit Own" COM_GETBIBLE_LINKERS_EDIT_OWN_DESC="Allows the users in this group to edit edit own linkers created by them" +COM_GETBIBLE_LINKERS_EDIT_PUBLIC_NOTES="Linkers Edit Public Notes" +COM_GETBIBLE_LINKERS_EDIT_PUBLIC_NOTES_DESC="Allows the users in this group to edit public notes of linker" +COM_GETBIBLE_LINKERS_EDIT_PUBLIC_TAGGED_VERSES="Linkers Edit Public Tagged Verses" +COM_GETBIBLE_LINKERS_EDIT_PUBLIC_TAGGED_VERSES_DESC="Allows the users in this group to edit public tagged verses of linker" COM_GETBIBLE_LINKERS_EDIT_STATE="Linkers Edit State" COM_GETBIBLE_LINKERS_EDIT_STATE_DESC="Allows the users in this group to update the state of the linker" COM_GETBIBLE_LINKERS_N_ITEMS_ARCHIVED="%s Linkers archived." @@ -651,16 +661,22 @@ COM_GETBIBLE_LINKER_NAME_HINT="Name Here" COM_GETBIBLE_LINKER_NAME_LABEL="Name" COM_GETBIBLE_LINKER_NAME_MESSAGE="Error! Please add name here." COM_GETBIBLE_LINKER_NEW="A New Linker" +COM_GETBIBLE_LINKER_NO="No" COM_GETBIBLE_LINKER_NOTES="Notes" COM_GETBIBLE_LINKER_ORDERING_LABEL="Ordering" COM_GETBIBLE_LINKER_PASSWORDS="Passwords" COM_GETBIBLE_LINKER_PERMISSION="Permissions" +COM_GETBIBLE_LINKER_PUBLIC_NOTES_DESCRIPTION="Linker can make their notes public." +COM_GETBIBLE_LINKER_PUBLIC_NOTES_LABEL="Public Notes" +COM_GETBIBLE_LINKER_PUBLIC_TAGGED_VERSES_DESCRIPTION="Linker can make their tagged verses public." +COM_GETBIBLE_LINKER_PUBLIC_TAGGED_VERSES_LABEL="Public Tagged Verses" COM_GETBIBLE_LINKER_PUBLISHING="Publishing" COM_GETBIBLE_LINKER_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Linker to customise the alias." COM_GETBIBLE_LINKER_STATUS="Status" COM_GETBIBLE_LINKER_TAGS="Tags" COM_GETBIBLE_LINKER_VERSION_DESC="A count of the number of times this Linker has been revised." COM_GETBIBLE_LINKER_VERSION_LABEL="Version" +COM_GETBIBLE_LINKER_YES="Yes" COM_GETBIBLE_NEW="New" COM_GETBIBLE_NOTE="Note" COM_GETBIBLE_NOTES="Notes" diff --git a/admin/language/en-GB/en-GB.com_getbible.sys.ini b/admin/language/en-GB/en-GB.com_getbible.sys.ini index 4b4efe8..54c29f0 100644 --- a/admin/language/en-GB/en-GB.com_getbible.sys.ini +++ b/admin/language/en-GB/en-GB.com_getbible.sys.ini @@ -92,6 +92,10 @@ COM_GETBIBLE_LINKERS_EDIT_NAME="Linkers Edit Name" COM_GETBIBLE_LINKERS_EDIT_NAME_DESC="Allows the users in this group to edit name of linker" COM_GETBIBLE_LINKERS_EDIT_OWN="Linkers Edit Own" COM_GETBIBLE_LINKERS_EDIT_OWN_DESC="Allows the users in this group to edit edit own linkers created by them" +COM_GETBIBLE_LINKERS_EDIT_PUBLIC_NOTES="Linkers Edit Public Notes" +COM_GETBIBLE_LINKERS_EDIT_PUBLIC_NOTES_DESC="Allows the users in this group to edit public notes of linker" +COM_GETBIBLE_LINKERS_EDIT_PUBLIC_TAGGED_VERSES="Linkers Edit Public Tagged Verses" +COM_GETBIBLE_LINKERS_EDIT_PUBLIC_TAGGED_VERSES_DESC="Allows the users in this group to edit public tagged verses of linker" COM_GETBIBLE_LINKERS_EDIT_STATE="Linkers Edit State" COM_GETBIBLE_LINKERS_EDIT_STATE_DESC="Allows the users in this group to update the state of the linker" COM_GETBIBLE_LINKERS_SUBMENU="Linkers Submenu" diff --git a/admin/layouts/linker/details_above.php b/admin/layouts/linker/details_above.php new file mode 100644 index 0000000..709476d --- /dev/null +++ b/admin/layouts/linker/details_above.php @@ -0,0 +1,50 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'name' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/linker/details_left.php b/admin/layouts/linker/details_left.php index e867d90..b83f222 100644 --- a/admin/layouts/linker/details_left.php +++ b/admin/layouts/linker/details_left.php @@ -32,7 +32,7 @@ $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields $fields = $displayData->get($fields_tab_layout) ?: array( - 'name' + 'public_tagged_verses' ); $hiddenFields = $displayData->get('hidden_fields') ?: array(); diff --git a/admin/layouts/linker/details_right.php b/admin/layouts/linker/details_right.php new file mode 100644 index 0000000..f17d385 --- /dev/null +++ b/admin/layouts/linker/details_right.php @@ -0,0 +1,48 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'public_notes' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/models/fields/linkersfilterpublicnotes.php b/admin/models/fields/linkersfilterpublicnotes.php new file mode 100644 index 0000000..46a0573 --- /dev/null +++ b/admin/models/fields/linkersfilterpublicnotes.php @@ -0,0 +1,77 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Linkersfilterpublicnotes Form Field class for the Getbible component + */ +class JFormFieldLinkersfilterpublicnotes extends JFormFieldList +{ + /** + * The linkersfilterpublicnotes field type. + * + * @var string + */ + public $type = 'linkersfilterpublicnotes'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('public_notes')); + $query->from($db->quoteName('#__getbible_linker')); + $query->order($db->quoteName('public_notes') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_PUBLIC_NOTES') . ' -'); + + if ($_results) + { + // get linkersmodel + $_model = GetbibleHelper::getModel('linkers'); + $_results = array_unique($_results); + foreach ($_results as $public_notes) + { + // Translate the public_notes selection + $_text = $_model->selectionTranslation($public_notes,'public_notes'); + // Now add the public_notes and its text to the options array + $_filter[] = JHtml::_('select.option', $public_notes, JText::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/linkersfilterpublictaggedverses.php b/admin/models/fields/linkersfilterpublictaggedverses.php new file mode 100644 index 0000000..c6ae335 --- /dev/null +++ b/admin/models/fields/linkersfilterpublictaggedverses.php @@ -0,0 +1,77 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Linkersfilterpublictaggedverses Form Field class for the Getbible component + */ +class JFormFieldLinkersfilterpublictaggedverses extends JFormFieldList +{ + /** + * The linkersfilterpublictaggedverses field type. + * + * @var string + */ + public $type = 'linkersfilterpublictaggedverses'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('public_tagged_verses')); + $query->from($db->quoteName('#__getbible_linker')); + $query->order($db->quoteName('public_tagged_verses') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_PUBLIC_TAGGED_VERSES') . ' -'); + + if ($_results) + { + // get linkersmodel + $_model = GetbibleHelper::getModel('linkers'); + $_results = array_unique($_results); + foreach ($_results as $public_tagged_verses) + { + // Translate the public_tagged_verses selection + $_text = $_model->selectionTranslation($public_tagged_verses,'public_tagged_verses'); + // Now add the public_tagged_verses and its text to the options array + $_filter[] = JHtml::_('select.option', $public_tagged_verses, JText::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/models/forms/filter_linkers.xml b/admin/models/forms/filter_linkers.xml index a0dcc2b..43e72be 100644 --- a/admin/models/forms/filter_linkers.xml +++ b/admin/models/forms/filter_linkers.xml @@ -37,6 +37,20 @@ multiple="false" onchange="this.form.submit();" /> + + @@ -57,6 +71,10 @@ + + + + diff --git a/admin/models/forms/linker.xml b/admin/models/forms/linker.xml index 6996ada..6a555d1 100644 --- a/admin/models/forms/linker.xml +++ b/admin/models/forms/linker.xml @@ -122,6 +122,34 @@ validate="guid" hint="COM_GETBIBLE_LINKER_GUID_HINT" /> + + + + + + + + + + + + diff --git a/admin/models/linker.php b/admin/models/linker.php index 7c018aa..b427b38 100644 --- a/admin/models/linker.php +++ b/admin/models/linker.php @@ -38,6 +38,12 @@ class GetbibleModelLinker extends AdminModel protected $tabLayoutFields = array( 'details' => array( 'left' => array( + 'public_tagged_verses' + ), + 'right' => array( + 'public_notes' + ), + 'above' => array( 'name' ) ) @@ -580,6 +586,46 @@ class GetbibleModelLinker extends AdminModel $form->setFieldAttribute('guid', 'required', 'false'); } } + // Modify the form based on Edit Public Tagged Verses access controls. + if ($id != 0 && (!$user->authorise('linker.edit.public_tagged_verses', 'com_getbible.linker.' . (int) $id)) + || ($id == 0 && !$user->authorise('linker.edit.public_tagged_verses', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('public_tagged_verses', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('public_tagged_verses', 'readonly', 'true'); + // Disable radio button for display. + $class = $form->getFieldAttribute('public_tagged_verses', 'class', ''); + $form->setFieldAttribute('public_tagged_verses', 'class', $class.' disabled no-click'); + // If there is no value continue. + if (!$form->getValue('public_tagged_verses')) + { + // Disable fields while saving. + $form->setFieldAttribute('public_tagged_verses', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('public_tagged_verses', 'required', 'false'); + } + } + // Modify the form based on Edit Public Notes access controls. + if ($id != 0 && (!$user->authorise('linker.edit.public_notes', 'com_getbible.linker.' . (int) $id)) + || ($id == 0 && !$user->authorise('linker.edit.public_notes', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('public_notes', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('public_notes', 'readonly', 'true'); + // Disable radio button for display. + $class = $form->getFieldAttribute('public_notes', 'class', ''); + $form->setFieldAttribute('public_notes', 'class', $class.' disabled no-click'); + // If there is no value continue. + if (!$form->getValue('public_notes')) + { + // Disable fields while saving. + $form->setFieldAttribute('public_notes', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('public_notes', 'required', 'false'); + } + } // Only load these values if no id is found if (0 == $id) { diff --git a/admin/models/linkers.php b/admin/models/linkers.php index 55fa01b..2d607a2 100644 --- a/admin/models/linkers.php +++ b/admin/models/linkers.php @@ -37,7 +37,9 @@ class GetbibleModelLinkers extends ListModel 'a.ordering','ordering', 'a.created_by','created_by', 'a.modified_by','modified_by', - 'a.name','name' + 'a.name','name', + 'a.public_tagged_verses','public_tagged_verses', + 'a.public_notes','public_notes' ); } @@ -97,6 +99,20 @@ class GetbibleModelLinkers extends ListModel $this->setState('filter.name', $name); } + $public_tagged_verses = $this->getUserStateFromRequest($this->context . '.filter.public_tagged_verses', 'filter_public_tagged_verses'); + if ($formSubmited) + { + $public_tagged_verses = $app->input->post->get('public_tagged_verses'); + $this->setState('filter.public_tagged_verses', $public_tagged_verses); + } + + $public_notes = $this->getUserStateFromRequest($this->context . '.filter.public_notes', 'filter_public_notes'); + if ($formSubmited) + { + $public_notes = $app->input->post->get('public_notes'); + $this->setState('filter.public_notes', $public_notes); + } + // List state information. parent::populateState($ordering, $direction); } @@ -134,10 +150,59 @@ class GetbibleModelLinkers extends ListModel } } + + // set selection value to a translatable value + if (GetbibleHelper::checkArray($items)) + { + foreach ($items as $nr => &$item) + { + // convert public_tagged_verses + $item->public_tagged_verses = $this->selectionTranslation($item->public_tagged_verses, 'public_tagged_verses'); + // convert public_notes + $item->public_notes = $this->selectionTranslation($item->public_notes, 'public_notes'); + } + } + // return items return $items; } + + /** + * Method to convert selection values to translatable string. + * + * @return translatable string + */ + public function selectionTranslation($value,$name) + { + // Array of public_tagged_verses language strings + if ($name === 'public_tagged_verses') + { + $public_tagged_versesArray = array( + 1 => 'COM_GETBIBLE_LINKER_YES', + 0 => 'COM_GETBIBLE_LINKER_NO' + ); + // Now check if value is found in this array + if (isset($public_tagged_versesArray[$value]) && GetbibleHelper::checkString($public_tagged_versesArray[$value])) + { + return $public_tagged_versesArray[$value]; + } + } + // Array of public_notes language strings + if ($name === 'public_notes') + { + $public_notesArray = array( + 1 => 'COM_GETBIBLE_LINKER_YES', + 0 => 'COM_GETBIBLE_LINKER_NO' + ); + // Now check if value is found in this array + if (isset($public_notesArray[$value]) && GetbibleHelper::checkString($public_notesArray[$value])) + { + return $public_notesArray[$value]; + } + } + return $value; + } /** * Method to build an SQL query to load the list data. @@ -223,6 +288,40 @@ class GetbibleModelLinkers extends ListModel { $query->where('a.name = ' . $db->quote($db->escape($_name))); } + // Filter by Public_tagged_verses. + $_public_tagged_verses = $this->getState('filter.public_tagged_verses'); + if (is_numeric($_public_tagged_verses)) + { + if (is_float($_public_tagged_verses)) + { + $query->where('a.public_tagged_verses = ' . (float) $_public_tagged_verses); + } + else + { + $query->where('a.public_tagged_verses = ' . (int) $_public_tagged_verses); + } + } + elseif (GetbibleHelper::checkString($_public_tagged_verses)) + { + $query->where('a.public_tagged_verses = ' . $db->quote($db->escape($_public_tagged_verses))); + } + // Filter by Public_notes. + $_public_notes = $this->getState('filter.public_notes'); + if (is_numeric($_public_notes)) + { + if (is_float($_public_notes)) + { + $query->where('a.public_notes = ' . (float) $_public_notes); + } + else + { + $query->where('a.public_notes = ' . (int) $_public_notes); + } + } + elseif (GetbibleHelper::checkString($_public_notes)) + { + $query->where('a.public_notes = ' . $db->quote($db->escape($_public_notes))); + } // Add the list ordering clause. $orderCol = $this->state->get('list.ordering', 'a.id'); @@ -263,6 +362,8 @@ class GetbibleModelLinkers extends ListModel $id .= ':' . $this->getState('filter.created_by'); $id .= ':' . $this->getState('filter.modified_by'); $id .= ':' . $this->getState('filter.name'); + $id .= ':' . $this->getState('filter.public_tagged_verses'); + $id .= ':' . $this->getState('filter.public_notes'); return parent::getStoreId($id); } diff --git a/admin/sql/install.mysql.utf8.sql b/admin/sql/install.mysql.utf8.sql index 0a3b5b4..bcbc777 100644 --- a/admin/sql/install.mysql.utf8.sql +++ b/admin/sql/install.mysql.utf8.sql @@ -3,6 +3,8 @@ CREATE TABLE IF NOT EXISTS `#__getbible_linker` ( `asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.', `guid` VARCHAR(36) NOT NULL DEFAULT '', `name` VARCHAR(255) NOT NULL DEFAULT '', + `public_notes` TINYINT(1) NOT NULL DEFAULT 0, + `public_tagged_verses` TINYINT(1) NOT NULL DEFAULT 0, `params` text NULL, `published` TINYINT(3) NOT NULL DEFAULT 1, `created_by` INT(10) unsigned NOT NULL DEFAULT 0, @@ -18,6 +20,8 @@ CREATE TABLE IF NOT EXISTS `#__getbible_linker` ( PRIMARY KEY (`id`), KEY `idx_name` (`name`), KEY `idx_guid` (`guid`), + KEY `idx_public_tagged_verses` (`public_tagged_verses`), + KEY `idx_public_notes` (`public_notes`), KEY `idx_access` (`access`), KEY `idx_checkout` (`checked_out`), KEY `idx_createdby` (`created_by`), diff --git a/admin/sql/updates/mysql/2.0.14.sql b/admin/sql/updates/mysql/2.0.14.sql new file mode 100644 index 0000000..f5792ef --- /dev/null +++ b/admin/sql/updates/mysql/2.0.14.sql @@ -0,0 +1,3 @@ +ALTER TABLE `#__getbible_linker` ADD `public_notes` TINYINT(1) NOT NULL DEFAULT 0 AFTER `name`; + +ALTER TABLE `#__getbible_linker` ADD `public_tagged_verses` TINYINT(1) NOT NULL DEFAULT 0 AFTER `public_notes`; diff --git a/admin/views/linker/tmpl/edit.php b/admin/views/linker/tmpl/edit.php index 793cf77..4cb9e8d 100644 --- a/admin/views/linker/tmpl/edit.php +++ b/admin/views/linker/tmpl/edit.php @@ -49,15 +49,19 @@ $componentParams = $this->params; // will be removed just use $this->params inst