customize custom field Access level

  • Posts: 120
  • Thank you received: 2
10 years 4 months ago #200247

Hi Dear
I need customize custom field Access level. when created a custom field we can set Access level and it's this is:



but I want customize it and use configuration mode for each custom field created. configuration Access level mode this is:



how can do it? thank you for your best support

Attachments:
Last edit: 10 years 4 months ago by kaya.

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
10 years 4 months ago #200262

Hello,

but I want customize it and use configuration mode for each custom field created. configuration Access level mode this is:

I didn't totally understood what you wanted to do so can you give me more information about your issue ?
Note that you'll just have to go through each custom field configuration page and use the "Access level" option.

Please Log in or Create an account to join the conversation.

  • Posts: 120
  • Thank you received: 2
10 years 4 months ago #200349

I want each custom field configuration page change the "Access level" options to this mode:


I want select who user can view or manage or delete a custom field in backe-end

Last edit: 10 years 4 months ago by kaya.

Please Log in or Create an account to join the conversation.

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 4 months ago #200372

Hi,

There is no way to restrict the managing of each field based on user groups in HikaShop with the options available.
It would require custom code development.

Please Log in or Create an account to join the conversation.

  • Posts: 120
  • Thank you received: 2
10 years 4 months ago #200394

Hi Dear Nicolas
If you help me I can code development. Which files edit for this program?

Last edit: 10 years 4 months ago by kaya.

Please Log in or Create an account to join the conversation.

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 4 months ago #200411

Hi,

You'll want to edit the file "form" of the view "field" via the menu Display>Views in order to add the selection of the ACL for each custom field. You'll want to add a new column in the hikashop_field table in order to store that new data for each field.
Then, you'll want to modify the file administrator/components/com_hikashop/controllers/field.php in order to add a check on the store and the remove processes so that the system doesn't allow for it based on the data from the new setting that you added in the form view file.

The following user(s) said Thank You: kaya

Please Log in or Create an account to join the conversation.

  • Posts: 120
  • Thank you received: 2
10 years 4 months ago #201770

Hi dear Nicolas
This method for config access options in config view

$acltable = hikashop_get('type.acltable');

now I want know which table in database this method save data?

Please Log in or Create an account to join the conversation.

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 3 months ago #201869

Hi,

This method loads an instance of the class of the file administrator/components/com_hikashop/types/acltable.php
Then, this class has a method to display the ACL selector.
It doesn't save anything. The save is usually handled by the saveForm/save functions of the class file of the element you're editing.
So if you're saving a custom field, it's the file administrator/components/com_hikashop/classes/field.php where the saveForm function stores the ACLs displayed by the type.acltable

The following user(s) said Thank You: kaya

Please Log in or Create an account to join the conversation.

  • Posts: 120
  • Thank you received: 2
10 years 3 months ago #201984

Hi dear Nicolas
I can display the ACL selector with this method in custom field view.
are you have sample code for function stores the ACLs displayed by the type.acltable ?
thank you

Last edit: 10 years 3 months ago by kaya.

Please Log in or Create an account to join the conversation.

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 3 months ago #201987

Hi,

You can look at the store function of the file administrator/components/com_hikashop/controllers/config.php
That's where the configuration page is saved and thus, where the ACL settings are saved from the type.acltable used on the configuration page.
Here is more specifically the code used:

$formData = JRequest::getVar( 'config', array(), $source, 'array' );
		$aclcats = JRequest::getVar( 'aclcat', array(), '', 'array' );
		if(!empty($aclcats)){
			if(JRequest::getString('acl_config','all') != 'all' && !hikashop_isAllowed($formData['acl_config_manage'])){
				$app->enqueueMessage(JText::_( 'ACL_WRONG_CONFIG' ), 'notice');
				unset($formData['acl_config_manage']);
			}
			$deleteAclCats = array();
			$unsetVars = array('manage','delete','view');
			foreach($aclcats as $oneCat){
				if(JRequest::getString('acl_'.$oneCat) == 'all'){
					foreach($unsetVars as $oneVar){
						unset($formData['acl_'.$oneCat.'_'.$oneVar]);
					}
					$deleteAclCats[] = $oneCat;
				}
			}
		}

The following user(s) said Thank You: kaya

Please Log in or Create an account to join the conversation.

  • Posts: 120
  • Thank you received: 2
10 years 3 months ago #202399

Hi Dear Nicolas
thank you.
I'm display ACL in custom field in administrator/components/com_hikashop/views/field/tmpl/form.php by this code:

$acltable = hikashop_get('type.acltable');
           $actions = array('view','manage','delete');
           echo $acltable->display('customfield',$actions);

and try save in store method in this file administrator/components/com_hikashop/controllers/field.php
and my store method this is:
function store($new=false){
        JRequest::checkToken() || die( 'Invalid Token' );
        $source = is_array($_POST['field'])?'POST':'REQUEST'; 
        $formData = JRequest::getVar( 'field', array(), $source, 'array' ); 
      //  echo var_dump($formData);
        $aclcats = JRequest::getVar( 'aclcat', array(), '', 'array' );
        $deleteAclCats = array();
        $unsetVars = array('manage','delete','view');
            foreach($aclcats as $oneCat){
                if(JRequest::getString('acl_'.$oneCat) == 'all'){
                    foreach($unsetVars as $oneVar){
                        unset($formData['acl_'.$oneCat.'_'.$oneVar]);
                    }
                    $deleteAclCats[] = $oneCat;
                }
            }
        $app = JFactory::getApplication();

        $class = hikashop_get('class.field');
        $status = $class->saveForm();
        if($status){
            if(!HIKASHOP_J30)
                $app->enqueueMessage(JText::_( 'HIKASHOP_SUCC_SAVED' ), 'success');
            else
                $app->enqueueMessage(JText::_( 'HIKASHOP_SUCC_SAVED' ));
        }else{
            $app->enqueueMessage(JText::_( 'ERROR_SAVING' ), 'error');
            if(!empty($class->errors)){
                foreach($class->errors as $oneError){
                    $app->enqueueMessage($oneError, 'error');
                }
            }
        }
    }
but can't save ACL when use echo var_dump($formData); in field controller it's null.
Please check my code how can save it? what is my problem?

thank you so much.

Please Log in or Create an account to join the conversation.

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 3 months ago #202439

Hi,

To get the field data, you should do like that:
$formData = JRequest::getVar( 'data', array(), '', 'array' );

The following user(s) said Thank You: kaya

Please Log in or Create an account to join the conversation.

  • Posts: 120
  • Thank you received: 2
10 years 3 months ago #202552

Thank you dear Nicolas
I'm use this code:

$formData = JRequest::getVar( 'data', array(), '', 'array' );
but don't save custom ACL yet and when select custom ACL only save all and not save custom.
what is my problem in my codes?

Please Log in or Create an account to join the conversation.

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 3 months ago #202559

Hi,

You need to do the saving of your new option yourself in the database where you want to store it. So you could add a MySQL query.
I don't see any in your code.

Please Log in or Create an account to join the conversation.

  • Posts: 120
  • Thank you received: 2
10 years 3 months ago #203061

Hi dear Nicolas
in the custom filed view when echo var_dump $formData no display custom ACL data value which user group selected view manage or delete
but in config view when echo var_dump $formData I see in output selected ACL data.
in config view when save ACL and echo var_dump($formData) see output this:

string '7,2,3,4,5,8,' (length=12)

string '7,2,3,4,5,8,' (length=12)

string '6,7,2,3,4,5,8,' (length=14)

and
('acl_affiliates_view','7,2,3,4,5,8,'),
('acl_affiliates_manage','7,2,3,4,5,8,'),
('acl_affiliates_delete','6,7,2,3,4,5,8,'),
and database config_namekey and config_value this is:
acl_affiliates_view 	7,2,3,4,5,8, 	 
acl_affiliates_manage 	7,2,3,4,5,8, 	 
acl_affiliates_delete 	6,7,2,3,4,5,8,

how can get custom ACL data in custom field view?
thank you so much

Last edit: 10 years 3 months ago by kaya.

Please Log in or Create an account to join the conversation.

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 3 months ago #203085

Hi,

It's up to you to get data of your HTML checkboxes in $_POST, and it's up to do to store that data in new columns of the hikashop_field table, and it's up to you to then use this data in the controllers/field.php file (and other files) to allow/block the edition of the custom fields based on that data.

We're talking about custom coding here. So you're supposed to do that on your end. I can't provide you all the changes to do where. First it depends on how you want to do it, and second custom coding is not part of the support we offer. I'm happy to give hints on how it should be done (like I already did) and answer questions, but in the end it's up to you.

Please Log in or Create an account to join the conversation.

  • Posts: 120
  • Thank you received: 2
10 years 3 months ago #204138

Hi Dear Nicolas

thank you for your supporting. If I was asked because Hikashop classes is regular and I wanted use this classes first and not use other php class. But now I can programing it and it is work very good. I created a new method type in types folder and rename it type.aclfield and use it because type.acltable work with hikashop config. My program now work very good and store my data in custom field table and not have problem.

thank you.

The following user(s) said Thank You: Jerome

Please Log in or Create an account to join the conversation.

Time to create page: 0.106 seconds
Powered by Kunena Forum