7 Posts
Chris@FM
7 years ago
Topic

Hello Seblod users and members, 

I try to get bool/false answer for the logged in user for right to edit special item(s) from CCK / article.

Could someone lean me a hand how to get it worked? I do not understand, how the CCKAccess()->check() function can be used used (from /libraries/cck/joomla/access/access.php)

/** * Method to check if a user is authorised to perform an action, optionally on an asset.

* * @param integer $userId Id of the user for which to check authorisation. 

* @param string $action The name of the action to authorise. 

* @param mixed $asset Integer asset id or the name of the asset as a string. Defaults to the global asset node.

* * @return boolean True if authorised. 

* * @since 11.1 

*/ 

public static function check($userId, $action, $asset = null)

//end from lib

//my last try for today :-)

$userId = JFactory::getUser()->id; 

$test2 = new CCKAccess(); 

$test3 = $test2->check($userId, 'core.edit','83'); 

var_dump($test3);

//output is always NULL

I tried some stuff without success. How could I retrieve the assetid and should action be 'edit', 'core.edit' or sth else? Or do I maybe chose the totally wrong function to get the edit state for a particular article he is watching?

Or could anyone provide an example based on one article?

Thank you,

Pierre.

Get a Book for SEBLOD
4229 Posts
Kadministrator
7 years ago
0
Level 1

As you can see in method signature it is a static function yo you need to use it like this CCKAccess::check(...)

No sure why this exists although, it is the same as joomla access check method, probably for compatibility with older joomla releases.

7 Posts
Chris@FM
7 years ago
0
Level 1

Thank you, Klas.

Oh my, such a noob one^^

For the others who also need a php solution, easiest way is the Joomla! core solution:

[code php]

$art_id = $cck->getValue('art_id');

$user = JFactory::getUser();

$userId = $user->id;

$canChange = $user->authorise('core.edit','com_content.article.'.$art_id);

var_dump($canChange);

[/code]

Regards,

Pierre.

Get a Book for SEBLOD