From dac176fa2b3b0a367b91e861fffd086f9ba6ef4d Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Thu, 3 Dec 2015 04:39:36 +0200 Subject: [PATCH] Added image to readme, added access control to look view and its fields , other changes are only random variable name and date changes (due to automation sorry) --- README.md | 8 +- admin/access.xml | 22 ++++ admin/controllers/look.php | 26 +++- admin/helpers/demo.php | 5 +- admin/language/en-GB/en-GB.com_demo.ini | 22 ++++ admin/models/demo.php | 3 + admin/models/forms/help_document.js | 154 ++++++++++++------------ admin/models/forms/look.js | 30 ++--- admin/models/look.php | 82 ++++++++++--- admin/models/looks.php | 28 ++++- admin/views/help_document/tmpl/edit.php | 60 ++++----- admin/views/look/tmpl/edit.php | 20 +-- admin/views/look/view.html.php | 14 +-- admin/views/looks/tmpl/default_body.php | 8 +- admin/views/looks/view.html.php | 8 +- 15 files changed, 318 insertions(+), 172 deletions(-) diff --git a/README.md b/README.md index 15e4a1f..5cf72f7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Demo (1.0.4) +![Demo image] (https://raw.githubusercontent.com/namibia/demo-joomla-3-component/master/admin/assets/images/component-300.jpg "The Demo") + Just a basic demo of the most basic implementations of the [Joomla] (http://www.joomla.org) Component Builder's ability. # Build Details @@ -15,13 +17,13 @@ Just a basic demo of the most basic implementations of the [Joomla] (http://www. ## Build Time -**42 Hours** or **5 Eight Hour Days** (actual time the author saved - +**43 Hours** or **5 Eight Hour Days** (actual time the author saved - due to [Automated Component Builder] (https://www.vdm.io/joomla-component-builder)) > (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*: **15117** ++ *Line count*: **15263** + *File count*: **147** + *Folder count*: **50** @@ -33,7 +35,7 @@ due to [Automated Component Builder] (https://www.vdm.io/joomla-component-builde > **mapping @4hours** = codingtime / 10; > **office @7hours** = codingtime / 6;) -**70 Hours** or **9 Eight Hour Days** +**71 Hours** or **9 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 8f1a385..1128eec 100644 --- a/admin/access.xml +++ b/admin/access.xml @@ -27,15 +27,37 @@ + + + + + + + + + + +
+ + + + + + + + + + +
diff --git a/admin/controllers/look.php b/admin/controllers/look.php index 9254302..20094f9 100644 --- a/admin/controllers/look.php +++ b/admin/controllers/look.php @@ -54,8 +54,15 @@ class DemoControllerLook extends JControllerForm * @since 1.6 */ protected function allowAdd($data = array()) - { // In the absense of better information, revert to the component permissions. - return parent::allowAdd($data); + { + // Access check. + $access = JFactory::getUser()->authorise('look.access', 'com_demo'); + if (!$access) + { + return false; + } + // In the absense of better information, revert to the component permissions. + return JFactory::getUser()->authorise('look.create', $this->option); } /** @@ -76,13 +83,20 @@ class DemoControllerLook extends JControllerForm $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + // Access check. + $access = ($user->authorise('look.access', 'com_demo.look.' . (int) $recordId) && $user->authorise('look.access', 'com_demo')); + if (!$access) + { + return false; + } + if ($recordId) { // The record has been set. Check the record permissions. - $permission = $user->authorise('core.edit', 'com_demo.look.' . (int) $recordId); + $permission = $user->authorise('look.edit', 'com_demo.look.' . (int) $recordId); if (!$permission && !is_null($permission)) { - if ($user->authorise('core.edit.own', 'com_demo.look.' . $recordId)) + if ($user->authorise('look.edit.own', 'com_demo.look.' . $recordId)) { // Now test the owner is the user. $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; @@ -101,7 +115,7 @@ class DemoControllerLook extends JControllerForm // If the owner matches 'me' then allow. if ($ownerId == $user->id) { - if ($user->authorise('core.edit.own', 'com_demo')) + if ($user->authorise('look.edit.own', 'com_demo')) { return true; } @@ -111,7 +125,7 @@ class DemoControllerLook extends JControllerForm } } // Since there is no permission, revert to the component permissions. - return parent::allowEdit($data, $key); + return $user->authorise('look.edit', $this->option); } /** diff --git a/admin/helpers/demo.php b/admin/helpers/demo.php index c2c6ce2..e5dde36 100644 --- a/admin/helpers/demo.php +++ b/admin/helpers/demo.php @@ -154,7 +154,10 @@ abstract class DemoHelper $user = JFactory::getUser(); // load the submenus to sidebar JHtmlSidebar::addEntry(JText::_('COM_DEMO_SUBMENU_DASHBOARD'), 'index.php?option=com_demo&view=demo', $submenu == 'demo'); - JHtmlSidebar::addEntry(JText::_('COM_DEMO_SUBMENU_LOOKS'), 'index.php?option=com_demo&view=looks', $submenu == 'looks'); + if ($user->authorise('look.access', 'com_demo') && $user->authorise('look.submenu', 'com_demo')) + { + JHtmlSidebar::addEntry(JText::_('COM_DEMO_SUBMENU_LOOKS'), 'index.php?option=com_demo&view=looks', $submenu == 'looks'); + } if ($user->authorise('help_document.access', 'com_demo') && $user->authorise('help_document.submenu', 'com_demo')) { JHtmlSidebar::addEntry(JText::_('COM_DEMO_SUBMENU_HELP_DOCUMENTS'), 'index.php?option=com_demo&view=help_documents', $submenu == 'help_documents'); diff --git a/admin/language/en-GB/en-GB.com_demo.ini b/admin/language/en-GB/en-GB.com_demo.ini index 39d2150..9976528 100644 --- a/admin/language/en-GB/en-GB.com_demo.ini +++ b/admin/language/en-GB/en-GB.com_demo.ini @@ -178,14 +178,36 @@ COM_DEMO_KEEP_ORIGINAL_STATE="- Keep Original State -" COM_DEMO_LICENSE="License" COM_DEMO_LOOK="Look" COM_DEMO_LOOKS="Looks" +COM_DEMO_LOOKS_ACCESS="Looks Access" +COM_DEMO_LOOKS_ACCESS_DESC="Allows the users in this group to access access looks" COM_DEMO_LOOKS_BATCH_OPTIONS="Batch process the selected Looks" COM_DEMO_LOOKS_BATCH_TIP="All changes will be applied to all selected Looks" COM_DEMO_LOOKS_BATCH_USE="Looks Batch Use" COM_DEMO_LOOKS_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch looks" +COM_DEMO_LOOKS_CREATE="Looks Create" +COM_DEMO_LOOKS_CREATE_DESC="Allows the users in this group to create create looks" COM_DEMO_LOOKS_DASHBOARD_ADD="Looks Dashboard Add" COM_DEMO_LOOKS_DASHBOARD_ADD_DESC="Allows the users in this group to update the dashboard add of the look" COM_DEMO_LOOKS_DASHBOARD_LIST="Looks Dashboard List" COM_DEMO_LOOKS_DASHBOARD_LIST_DESC="Allows the users in this group to update the dashboard list of the look" +COM_DEMO_LOOKS_DELETE="Looks Delete" +COM_DEMO_LOOKS_DELETE_DESC="Allows the users in this group to delete delete looks" +COM_DEMO_LOOKS_EDIT="Looks Edit" +COM_DEMO_LOOKS_EDIT_ACRONYM="Looks Edit Acronym" +COM_DEMO_LOOKS_EDIT_ACRONYM_DESC="Allows the users in this group to update the edit acronym of the look" +COM_DEMO_LOOKS_EDIT_CREATED_BY="Looks Edit Created By" +COM_DEMO_LOOKS_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by looks" +COM_DEMO_LOOKS_EDIT_CREATED_DATE="Looks Edit Created Date" +COM_DEMO_LOOKS_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created looks" +COM_DEMO_LOOKS_EDIT_DESC="Allows the users in this group to edit the look" +COM_DEMO_LOOKS_EDIT_DESCRIPTION="Looks Edit Description" +COM_DEMO_LOOKS_EDIT_DESCRIPTION_DESC="Allows the users in this group to update the edit description of the look" +COM_DEMO_LOOKS_EDIT_MALE="Looks Edit Male" +COM_DEMO_LOOKS_EDIT_MALE_DESC="Allows the users in this group to update the edit male of the look" +COM_DEMO_LOOKS_EDIT_OWN="Looks Edit Own" +COM_DEMO_LOOKS_EDIT_OWN_DESC="Allows the users in this group to edit edit own looks created by them" +COM_DEMO_LOOKS_EDIT_STATE="Looks Edit State" +COM_DEMO_LOOKS_EDIT_STATE_DESC="Allows the users in this group to update the state of the look" COM_DEMO_LOOKS_EDIT_VERSION="Looks Edit Version" COM_DEMO_LOOKS_EDIT_VERSION_DESC="Allows users in this group to edit versions of version looks" COM_DEMO_LOOKS_EXPORT="Looks Export" diff --git a/admin/models/demo.php b/admin/models/demo.php index d9322c1..3cda95c 100644 --- a/admin/models/demo.php +++ b/admin/models/demo.php @@ -42,6 +42,9 @@ class DemoModelDemo extends JModelList ); // view access array $viewAccess = array( + 'look.create' => 'look.create', + 'looks.access' => 'look.access', + 'look.access' => 'look.access', 'looks.submenu' => 'look.submenu', 'looks.dashboard_list' => 'look.dashboard_list', 'look.dashboard_add' => 'look.dashboard_add', diff --git a/admin/models/forms/help_document.js b/admin/models/forms/help_document.js index 9894e53..16fe320 100644 --- a/admin/models/forms/help_document.js +++ b/admin/models/forms/help_document.js @@ -18,38 +18,38 @@ /------------------------------------------------------------------------------------------------------*/ // Some Global Values -jform_XvephxzImu_required = false; -jform_yFWFBjoUSy_required = false; -jform_revjpJkdku_required = false; -jform_MhQPsZtPMB_required = false; +jform_CLxRiyFDWv_required = false; +jform_zgwHidMmGR_required = false; +jform_dapwGJswww_required = false; +jform_KfchXiEDHv_required = false; // Initial Script jQuery(document).ready(function() { - var location_sLnxlWV = jQuery("#jform_location input[type='radio']:checked").val(); - sLnxlWV(location_sLnxlWV); + var location_gvgNtFm = jQuery("#jform_location input[type='radio']:checked").val(); + gvgNtFm(location_gvgNtFm); - var location_fqbSveC = jQuery("#jform_location input[type='radio']:checked").val(); - fqbSveC(location_fqbSveC); + var location_GxWLKer = jQuery("#jform_location input[type='radio']:checked").val(); + GxWLKer(location_GxWLKer); - var type_Xvephxz = jQuery("#jform_type").val(); - Xvephxz(type_Xvephxz); + var type_CLxRiyF = jQuery("#jform_type").val(); + CLxRiyF(type_CLxRiyF); - var type_yFWFBjo = jQuery("#jform_type").val(); - yFWFBjo(type_yFWFBjo); + var type_zgwHidM = jQuery("#jform_type").val(); + zgwHidM(type_zgwHidM); - var type_revjpJk = jQuery("#jform_type").val(); - revjpJk(type_revjpJk); + var type_dapwGJs = jQuery("#jform_type").val(); + dapwGJs(type_dapwGJs); - var target_MhQPsZt = jQuery("#jform_target input[type='radio']:checked").val(); - MhQPsZt(target_MhQPsZt); + var target_KfchXiE = jQuery("#jform_target input[type='radio']:checked").val(); + KfchXiE(target_KfchXiE); }); -// the sLnxlWV function -function sLnxlWV(location_sLnxlWV) +// the gvgNtFm function +function gvgNtFm(location_gvgNtFm) { // set the function logic - if (location_sLnxlWV == 1) + if (location_gvgNtFm == 1) { jQuery('#jform_admin_view').closest('.control-group').show(); } @@ -59,11 +59,11 @@ function sLnxlWV(location_sLnxlWV) } } -// the fqbSveC function -function fqbSveC(location_fqbSveC) +// the GxWLKer function +function GxWLKer(location_GxWLKer) { // set the function logic - if (location_fqbSveC == 2) + if (location_GxWLKer == 2) { jQuery('#jform_site_view').closest('.control-group').show(); } @@ -73,198 +73,198 @@ function fqbSveC(location_fqbSveC) } } -// the Xvephxz function -function Xvephxz(type_Xvephxz) +// the CLxRiyF function +function CLxRiyF(type_CLxRiyF) { - if (isSet(type_Xvephxz) && type_Xvephxz.constructor !== Array) + if (isSet(type_CLxRiyF) && type_CLxRiyF.constructor !== Array) { - var temp_Xvephxz = type_Xvephxz; - var type_Xvephxz = []; - type_Xvephxz.push(temp_Xvephxz); + var temp_CLxRiyF = type_CLxRiyF; + var type_CLxRiyF = []; + type_CLxRiyF.push(temp_CLxRiyF); } - else if (!isSet(type_Xvephxz)) + else if (!isSet(type_CLxRiyF)) { - var type_Xvephxz = []; + var type_CLxRiyF = []; } - var type = type_Xvephxz.some(type_Xvephxz_SomeFunc); + var type = type_CLxRiyF.some(type_CLxRiyF_SomeFunc); // set this function logic if (type) { jQuery('#jform_url').closest('.control-group').show(); - if (jform_XvephxzImu_required) + if (jform_CLxRiyFDWv_required) { updateFieldRequired('url',0); jQuery('#jform_url').prop('required','required'); jQuery('#jform_url').attr('aria-required',true); jQuery('#jform_url').addClass('required'); - jform_XvephxzImu_required = false; + jform_CLxRiyFDWv_required = false; } } else { jQuery('#jform_url').closest('.control-group').hide(); - if (!jform_XvephxzImu_required) + if (!jform_CLxRiyFDWv_required) { updateFieldRequired('url',1); jQuery('#jform_url').removeAttr('required'); jQuery('#jform_url').removeAttr('aria-required'); jQuery('#jform_url').removeClass('required'); - jform_XvephxzImu_required = true; + jform_CLxRiyFDWv_required = true; } } } -// the Xvephxz Some function -function type_Xvephxz_SomeFunc(type_Xvephxz) +// the CLxRiyF Some function +function type_CLxRiyF_SomeFunc(type_CLxRiyF) { // set the function logic - if (type_Xvephxz == 3) + if (type_CLxRiyF == 3) { return true; } return false; } -// the yFWFBjo function -function yFWFBjo(type_yFWFBjo) +// the zgwHidM function +function zgwHidM(type_zgwHidM) { - if (isSet(type_yFWFBjo) && type_yFWFBjo.constructor !== Array) + if (isSet(type_zgwHidM) && type_zgwHidM.constructor !== Array) { - var temp_yFWFBjo = type_yFWFBjo; - var type_yFWFBjo = []; - type_yFWFBjo.push(temp_yFWFBjo); + var temp_zgwHidM = type_zgwHidM; + var type_zgwHidM = []; + type_zgwHidM.push(temp_zgwHidM); } - else if (!isSet(type_yFWFBjo)) + else if (!isSet(type_zgwHidM)) { - var type_yFWFBjo = []; + var type_zgwHidM = []; } - var type = type_yFWFBjo.some(type_yFWFBjo_SomeFunc); + var type = type_zgwHidM.some(type_zgwHidM_SomeFunc); // set this function logic if (type) { jQuery('#jform_article').closest('.control-group').show(); - if (jform_yFWFBjoUSy_required) + if (jform_zgwHidMmGR_required) { updateFieldRequired('article',0); jQuery('#jform_article').prop('required','required'); jQuery('#jform_article').attr('aria-required',true); jQuery('#jform_article').addClass('required'); - jform_yFWFBjoUSy_required = false; + jform_zgwHidMmGR_required = false; } } else { jQuery('#jform_article').closest('.control-group').hide(); - if (!jform_yFWFBjoUSy_required) + if (!jform_zgwHidMmGR_required) { updateFieldRequired('article',1); jQuery('#jform_article').removeAttr('required'); jQuery('#jform_article').removeAttr('aria-required'); jQuery('#jform_article').removeClass('required'); - jform_yFWFBjoUSy_required = true; + jform_zgwHidMmGR_required = true; } } } -// the yFWFBjo Some function -function type_yFWFBjo_SomeFunc(type_yFWFBjo) +// the zgwHidM Some function +function type_zgwHidM_SomeFunc(type_zgwHidM) { // set the function logic - if (type_yFWFBjo == 1) + if (type_zgwHidM == 1) { return true; } return false; } -// the revjpJk function -function revjpJk(type_revjpJk) +// the dapwGJs function +function dapwGJs(type_dapwGJs) { - if (isSet(type_revjpJk) && type_revjpJk.constructor !== Array) + if (isSet(type_dapwGJs) && type_dapwGJs.constructor !== Array) { - var temp_revjpJk = type_revjpJk; - var type_revjpJk = []; - type_revjpJk.push(temp_revjpJk); + var temp_dapwGJs = type_dapwGJs; + var type_dapwGJs = []; + type_dapwGJs.push(temp_dapwGJs); } - else if (!isSet(type_revjpJk)) + else if (!isSet(type_dapwGJs)) { - var type_revjpJk = []; + var type_dapwGJs = []; } - var type = type_revjpJk.some(type_revjpJk_SomeFunc); + var type = type_dapwGJs.some(type_dapwGJs_SomeFunc); // set this function logic if (type) { jQuery('#jform_content-lbl').closest('.control-group').show(); - if (jform_revjpJkdku_required) + if (jform_dapwGJswww_required) { updateFieldRequired('content',0); jQuery('#jform_content').prop('required','required'); jQuery('#jform_content').attr('aria-required',true); jQuery('#jform_content').addClass('required'); - jform_revjpJkdku_required = false; + jform_dapwGJswww_required = false; } } else { jQuery('#jform_content-lbl').closest('.control-group').hide(); - if (!jform_revjpJkdku_required) + if (!jform_dapwGJswww_required) { updateFieldRequired('content',1); jQuery('#jform_content').removeAttr('required'); jQuery('#jform_content').removeAttr('aria-required'); jQuery('#jform_content').removeClass('required'); - jform_revjpJkdku_required = true; + jform_dapwGJswww_required = true; } } } -// the revjpJk Some function -function type_revjpJk_SomeFunc(type_revjpJk) +// the dapwGJs Some function +function type_dapwGJs_SomeFunc(type_dapwGJs) { // set the function logic - if (type_revjpJk == 2) + if (type_dapwGJs == 2) { return true; } return false; } -// the MhQPsZt function -function MhQPsZt(target_MhQPsZt) +// the KfchXiE function +function KfchXiE(target_KfchXiE) { // set the function logic - if (target_MhQPsZt == 1) + if (target_KfchXiE == 1) { jQuery('#jform_groups').closest('.control-group').show(); - if (jform_MhQPsZtPMB_required) + if (jform_KfchXiEDHv_required) { updateFieldRequired('groups',0); jQuery('#jform_groups').prop('required','required'); jQuery('#jform_groups').attr('aria-required',true); jQuery('#jform_groups').addClass('required'); - jform_MhQPsZtPMB_required = false; + jform_KfchXiEDHv_required = false; } } else { jQuery('#jform_groups').closest('.control-group').hide(); - if (!jform_MhQPsZtPMB_required) + if (!jform_KfchXiEDHv_required) { updateFieldRequired('groups',1); jQuery('#jform_groups').removeAttr('required'); jQuery('#jform_groups').removeAttr('aria-required'); jQuery('#jform_groups').removeClass('required'); - jform_MhQPsZtPMB_required = true; + jform_KfchXiEDHv_required = true; } } } diff --git a/admin/models/forms/look.js b/admin/models/forms/look.js index 53a8b11..aa54c72 100644 --- a/admin/models/forms/look.js +++ b/admin/models/forms/look.js @@ -18,23 +18,23 @@ /------------------------------------------------------------------------------------------------------*/ // Some Global Values -jform_FKWPxIhXqG_required = false; +jform_xEVTobmbza_required = false; // Initial Script jQuery(document).ready(function() { - var name_CxBsGuj = jQuery("#jform_name").val(); - CxBsGuj(name_CxBsGuj); + var name_RJYiubJ = jQuery("#jform_name").val(); + RJYiubJ(name_RJYiubJ); - var add_FKWPxIh = jQuery("#jform_add input[type='radio']:checked").val(); - FKWPxIh(add_FKWPxIh); + var add_xEVTobm = jQuery("#jform_add input[type='radio']:checked").val(); + xEVTobm(add_xEVTobm); }); -// the CxBsGuj function -function CxBsGuj(name_CxBsGuj) +// the RJYiubJ function +function RJYiubJ(name_RJYiubJ) { // set the function logic - if (isSet(name_CxBsGuj)) + if (isSet(name_RJYiubJ)) { jQuery('#jform_alias').closest('.control-group').show(); jQuery('#jform_description').closest('.control-group').show(); @@ -46,20 +46,20 @@ function CxBsGuj(name_CxBsGuj) } } -// the FKWPxIh function -function FKWPxIh(add_FKWPxIh) +// the xEVTobm function +function xEVTobm(add_xEVTobm) { // set the function logic - if (add_FKWPxIh == 1) + if (add_xEVTobm == 1) { jQuery('#jform_acronym').closest('.control-group').show(); - if (jform_FKWPxIhXqG_required) + if (jform_xEVTobmbza_required) { updateFieldRequired('acronym',0); jQuery('#jform_acronym').prop('required','required'); jQuery('#jform_acronym').attr('aria-required',true); jQuery('#jform_acronym').addClass('required'); - jform_FKWPxIhXqG_required = false; + jform_xEVTobmbza_required = false; } jQuery('#jform_website').closest('.control-group').show(); @@ -67,13 +67,13 @@ function FKWPxIh(add_FKWPxIh) else { jQuery('#jform_acronym').closest('.control-group').hide(); - if (!jform_FKWPxIhXqG_required) + if (!jform_xEVTobmbza_required) { updateFieldRequired('acronym',1); jQuery('#jform_acronym').removeAttr('required'); jQuery('#jform_acronym').removeAttr('aria-required'); jQuery('#jform_acronym').removeClass('required'); - jform_FKWPxIhXqG_required = true; + jform_xEVTobmbza_required = true; } jQuery('#jform_website').closest('.control-group').hide(); } diff --git a/admin/models/look.php b/admin/models/look.php index 811e3ba..c683a33 100644 --- a/admin/models/look.php +++ b/admin/models/look.php @@ -136,8 +136,8 @@ class DemoModelLook extends JModelAdmin // Check for existing item. // Modify the form based on Edit State access controls. - if ($id != 0 && (!$user->authorise('core.edit.state', 'com_demo.look.' . (int) $id)) - || ($id == 0 && !$user->authorise('core.edit.state', 'com_demo'))) + if ($id != 0 && (!$user->authorise('look.edit.state', 'com_demo.look.' . (int) $id)) + || ($id == 0 && !$user->authorise('look.edit.state', 'com_demo'))) { // Disable fields for display. $form->setFieldAttribute('ordering', 'disabled', 'true'); @@ -147,7 +147,8 @@ class DemoModelLook extends JModelAdmin $form->setFieldAttribute('published', 'filter', 'unset'); } // Modify the form based on Edit Creaded By access controls. - if (!$user->authorise('core.edit.created_by', 'com_demo')) + if ($id != 0 && (!$user->authorise('look.edit.created_by', 'com_demo.look.' . (int) $id)) + || ($id == 0 && !$user->authorise('look.edit.created_by', 'com_demo'))) { // Disable fields for display. $form->setFieldAttribute('created_by', 'disabled', 'true'); @@ -157,13 +158,65 @@ class DemoModelLook extends JModelAdmin $form->setFieldAttribute('created_by', 'filter', 'unset'); } // Modify the form based on Edit Creaded Date access controls. - if (!$user->authorise('core.edit.created', 'com_demo')) + if ($id != 0 && (!$user->authorise('look.edit.created', 'com_demo.look.' . (int) $id)) + || ($id == 0 && !$user->authorise('look.edit.created', 'com_demo'))) { // Disable fields for display. $form->setFieldAttribute('created', 'disabled', 'true'); // Disable fields while saving. $form->setFieldAttribute('created', 'filter', 'unset'); } + // Modify the form based on Edit Description access controls. + if ($id != 0 && (!$user->authorise('look.edit.description', 'com_demo.look.' . (int) $id)) + || ($id == 0 && !$user->authorise('look.edit.description', 'com_demo'))) + { + // Disable fields for display. + $form->setFieldAttribute('description', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('description', 'readonly', 'true'); + if (!$form->getValue('description')) + { + // Disable fields while saving. + $form->setFieldAttribute('description', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('description', 'required', 'false'); + } + } + // Modify the form based on Edit Acronym access controls. + if ($id != 0 && (!$user->authorise('look.edit.acronym', 'com_demo.look.' . (int) $id)) + || ($id == 0 && !$user->authorise('look.edit.acronym', 'com_demo'))) + { + // Disable fields for display. + $form->setFieldAttribute('acronym', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('acronym', 'readonly', 'true'); + if (!$form->getValue('acronym')) + { + // Disable fields while saving. + $form->setFieldAttribute('acronym', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('acronym', 'required', 'false'); + } + } + // Modify the form based on Edit Male access controls. + if ($id != 0 && (!$user->authorise('look.edit.male', 'com_demo.look.' . (int) $id)) + || ($id == 0 && !$user->authorise('look.edit.male', 'com_demo'))) + { + // Disable fields for display. + $form->setFieldAttribute('male', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('male', 'readonly', 'true'); + // Disable radio button for display. + $class = $form->getFieldAttribute('male', 'class', ''); + $form->setFieldAttribute('male', 'class', $class.' disabled no-click'); + if (!$form->getValue('male')) + { + // Disable fields while saving. + $form->setFieldAttribute('male', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('male', 'required', 'false'); + } + } return $form; } @@ -198,7 +251,7 @@ class DemoModelLook extends JModelAdmin $user = JFactory::getUser(); // The record has been set. Check the record permissions. - return $user->authorise('core.delete', 'com_demo.look.' . (int) $record->id); + return $user->authorise('look.delete', 'com_demo.look.' . (int) $record->id); } return false; } @@ -220,14 +273,14 @@ class DemoModelLook extends JModelAdmin if ($recordId) { // The record has been set. Check the record permissions. - $permission = $user->authorise('core.edit.state', 'com_demo.look.' . (int) $recordId); + $permission = $user->authorise('look.edit.state', 'com_demo.look.' . (int) $recordId); if (!$permission && !is_null($permission)) { return false; } } // In the absense of better information, revert to the component permissions. - return parent::canEditState($record); + return $user->authorise('look.edit.state', 'com_demo'); } /** @@ -242,8 +295,9 @@ class DemoModelLook extends JModelAdmin protected function allowEdit($data = array(), $key = 'id') { // Check specific edit permission then general edit permission. + $user = JFactory::getUser(); - return JFactory::getUser()->authorise('core.edit', 'com_demo.look.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or parent::allowEdit($data, $key); + return $user->authorise('look.edit', 'com_demo.look.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('look.edit', 'com_demo'); } /** @@ -492,7 +546,7 @@ class DemoModelLook extends JModelAdmin $this->canDo = DemoHelper::getActions('look'); } - if (!$this->canDo->get('core.create') || !$this->canDo->get('core.batch')) + if (!$this->canDo->get('look.create') && !$this->canDo->get('look.batch')) { return false; } @@ -507,7 +561,7 @@ class DemoModelLook extends JModelAdmin { $values['published'] = 0; } - elseif (isset($values['published']) && !$this->canDo->get('core.edit.state')) + elseif (isset($values['published']) && !$this->canDo->get('look.edit.state')) { $values['published'] = 0; } @@ -524,7 +578,7 @@ class DemoModelLook extends JModelAdmin // only allow copy if user may edit this item. - if (!$this->user->authorise('core.edit', $contexts[$pk])) + if (!$this->user->authorise('look.edit', $contexts[$pk])) { @@ -641,14 +695,14 @@ class DemoModelLook extends JModelAdmin $this->canDo = DemoHelper::getActions('look'); } - if (!$this->canDo->get('core.edit') && !$this->canDo->get('core.batch')) + if (!$this->canDo->get('look.edit') && !$this->canDo->get('look.batch')) { $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); return false; } // make sure published only updates if user has the permission. - if (isset($values['published']) && !$this->canDo->get('core.edit.state')) + if (isset($values['published']) && !$this->canDo->get('look.edit.state')) { unset($values['published']); } @@ -658,7 +712,7 @@ class DemoModelLook extends JModelAdmin // Parent exists so we proceed foreach ($pks as $pk) { - if (!$this->user->authorise('core.edit', $contexts[$pk])) + if (!$this->user->authorise('look.edit', $contexts[$pk])) { $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); diff --git a/admin/models/looks.php b/admin/models/looks.php index db5417a..f75ceca 100644 --- a/admin/models/looks.php +++ b/admin/models/looks.php @@ -112,7 +112,24 @@ class DemoModelLooks extends JModelList $this->checkInNow(); // load parent items - $items = parent::getItems(); + $items = parent::getItems(); + + // set values to display correctly. + if (DemoHelper::checkArray($items)) + { + // get user object. + $user = JFactory::getUser(); + foreach ($items as $nr => &$item) + { + $access = ($user->authorise('look.access', 'com_demo.look.' . (int) $item->id) && $user->authorise('look.access', 'com_demo')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } // set selection value to a translatable value if (DemoHelper::checkArray($items)) @@ -275,8 +292,17 @@ class DemoModelLooks extends JModelList // set values to display correctly. if (DemoHelper::checkArray($items)) { + // get user object. + $user = JFactory::getUser(); foreach ($items as $nr => &$item) { + $access = ($user->authorise('look.access', 'com_demo.look.' . (int) $item->id) && $user->authorise('look.access', 'com_demo')); + if (!$access) + { + unset($items[$nr]); + continue; + } + // unset the values we don't want exported. unset($item->asset_id); unset($item->checked_out); diff --git a/admin/views/help_document/tmpl/edit.php b/admin/views/help_document/tmpl/edit.php index df859b2..921f9f6 100644 --- a/admin/views/help_document/tmpl/edit.php +++ b/admin/views/help_document/tmpl/edit.php @@ -95,93 +95,93 @@ $componentParams = JComponentHelper::getParams('com_demo');