[help] ACL reject access to model

77 views
Skip to first unread message

Viktor Iwan

unread,
Mar 30, 2012, 2:59:45 AM3/30/12
to Joomla! General Development
Hello all,
currently i'm using/accessing model from com_content to manage article
with these following code:

JLoader::import("joomla.application.component.model");
JLoader::import("article",JPATH_ADMINISTRATOR.DS.'components'.DS.'com_content'.DS.'models');
$items_model=JModel::getInstance('article','ContentModel');
$items_model->delete($cid);

the proble arise on this line 652:
if ($this->canDelete($table))

coz it always return false as it can not access canDelete() method,
however if i replace that code with:

$user = JFactory::getUser();
if($user->authorise('core.delete', $this->option))

There's no problem....
However i don't want to use the second approach as it modified the
core joomla component (com_content).

So i'm looking for workaround on how the model can access canDelete()
method

For the reference here's the declaration of canDelete() function on
JModelAdmin:
protected function canDelete($record)
{
$user = JFactory::getUser();
return $user->authorise('core.delete', $this->option);
}



Thanks !

Hannes Papenberg

unread,
Mar 30, 2012, 3:07:10 AM3/30/12
to joomla-de...@googlegroups.com

Please use this line of code
JLoader::register("ContentModelArticle", JPATH_ADMINISTRATOR.'/components/com_content/models/article.php');

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.

Viktor Iwan

unread,
Apr 4, 2012, 9:51:58 AM4/4/12
to Joomla! General Development
Hello,
i tried using
JLoader::register("ContentModelArticle",JPATH_ADMINISTRATOR.'/
components/com_content/models/article.php');
$items_model=
$items_model=JModel::getInstance('article','ContentModel');
$items_model->delete($cid);

but still i get "Delete not permitted", did i miss something ?

the canDelete() function declared in jModelAdmin is 'protected', if i
remove it, it return this error:
Fatal error: Access level to ContentModelArticle::canDelete() must be
public (as in class JModelAdmin) in D:\zend\Apache2\htdocs\seblod
\administrator\components\com_content\models\article.php on line 25

and i still really hope to be able to use com_content model without
modify core joomla codes.....
if i replace if ($this->canDelete($table))

with

$user = JFactory::getUser();
if($user->authorise('core.delete', $this->option))

it works !

it's been days of wonder.. hope someone can provide better solution

Viktor Iwan

unread,
Apr 8, 2012, 11:17:43 PM4/8/12
to Joomla! General Development
Hello All,
Anybody can help me throughout this issue ?

Thanks

Viktor Iwan

unread,
Apr 11, 2012, 8:39:28 AM4/11/12
to Joomla! General Development
Hello all,
anybody had the solution for me ?

elin

unread,
Apr 11, 2012, 10:10:04 AM4/11/12
to joomla-de...@googlegroups.com
Are you accessing that model from the site or admin?

Elin
> > > > To unsubscribe from this group, send email to

Viktor Iwan

unread,
Apr 12, 2012, 6:26:06 AM4/12/12
to Joomla! General Development
Basically i create a custom extension to import content to joomla,
there will be parameter force empty. When it click i have to delete
the article within a category.

To make the deletion behave properly, i'm thinking not to delete the
article directly from the #__content, instead i simulate the deletion
process that done by jModelAdmin. That's why i use the model to
interact with database, but at the moment the ACL is always forbid me

if i cannot use the model, can anyone give me another way to delete
the articles properly along with the dispatcher (event_before_delete
and event_after_delete), coz there's 'trigger' on that from 3DP
Component (for example, seblod did !)

Thanks
> > > > > > joomla-de...@googlegroups.com.
> > > > > > To unsubscribe from this group, send email to
> > > > > > joomla-dev-gene...@googlegroups.com.

elin

unread,
Apr 12, 2012, 9:55:31 AM4/12/12
to joomla-de...@googlegroups.com
I think that is possibly a bug. Can you dump out the permissions that are actually being used both explicit and calculated?  Can you try making it so that user has specific permission to delete content (i.e. not just based on being super admin)? Does that work?

Elin
> > > > > > To unsubscribe from this group, send email to

Viktor Iwan

unread,
Apr 12, 2012, 1:23:42 PM4/12/12
to Joomla! General Development
At the moment, i'm on superadmin...
can you clarify what your mean about "Can you dump out the permissions
that are
actually being used both explicit and calculated?"

Tommorow, I will create a simple dummy component for you to test
it..

Thanks
> > > > > > > > joomla-de...@googlegroups.com.
> > > > > > > > To unsubscribe from this group, send email to
> > > > > > > > joomla-dev-gene...@googlegroups.com.

Viktor Iwan

unread,
Apr 13, 2012, 5:11:05 AM4/13/12
to Joomla! General Development
Hello All,
i create a simple component to show my problem, please download here
http://www.doxadigital.com/com_victest.zip

you only need to enter article ID(s) you like to delete

if you drill down the issue the real problem arise on:
/libraries/joomla/application/component/modeladmin.php (line 638) :
if ($this->canDelete($table))

Hope anyone can make it work...

Viktor Iwan

unread,
Apr 19, 2012, 10:56:55 PM4/19/12
to Joomla! General Development
Sorry to bump this issue again... hopefully someone can test my sample
component, and let me know where did i go wrong ?

Thanks

On Apr 13, 4:11 pm, Viktor Iwan <vic...@doxadigital.com> wrote:
> Hello All,
> i create a simple component to show my problem, please download herehttp://www.doxadigital.com/com_victest.zip
Reply all
Reply to author
Forward
0 new messages