?
avatar infograf768
infograf768
5 Aug 2016

Not related to recent releases afaik.

For Newsfeeds, it is clear. We do not even take care of created_by in the newsfeeds model getListQuery() method. This should be implemented from scratch.

But for Contacts, I was hoping it would work.

Test instructions:
Create a sub-group of Manager with the following permissions for Contacts:
screen shot 2016-08-05 at 08 35 33

Access admin interface YES
Create YES
Delete NO
EDIT NO
EDIT STATE YES or NO
EDIT OWN YES

Log in back-end with a user member of that group

In Contacts Manager, create a new contact (You may not have permission to assign it to a user, but this is unrelated).
Save and Close that contact.

The contact is clickable in the Manager (Here the clickable one was created by this user)
screen shot 2016-08-05 at 08 41 23

Result of click to edit:
screen shot 2016-08-05 at 08 42 32

NOTE: It works fine for Articles with the same set of permissions. Did not test others.

avatar infograf768 infograf768 - open - 5 Aug 2016
avatar infograf768 infograf768 - change - 5 Aug 2016
Category ACL Administration Components
avatar infograf768
infograf768 - comment - 5 Aug 2016

@ggppdk
Can you confirm?

avatar ggppdk
ggppdk - comment - 5 Aug 2016

Yes, confirmed, tested and code review, edit not possible despite

the user both having core.edit.own on category and owning the contact record

avatar infograf768
infograf768 - comment - 5 Aug 2016

Looks like we need new permissions in the access.xml and changes in the controller for allowEdit() as it only takes care of category edit.
For newsfeeds, all code is missing. As well for weblinks.

avatar ggppdk
ggppdk - comment - 5 Aug 2016

Again in this case, it is not a security issue (it is not because the ACL check on core.edit of category asset forces a return ! if category id is non zero), but a usability issue,

  • the owners should be allowed to edit the records, if having core.edit.own, but this is not checked

I can see why this was not added, it is because

  • contacts, newsfeed, weblinks do not have individual assets

Thus you need core.edit.own checking that is a little different than e.g. articles
1. Check core.edit.own on their category (instead of the contact, weblink, newsfeed record)
2. Check owner (created_by property==current_user_id) as they do have this property

This :
https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_contact/controllers/contact.php#L60-L78

Should be something like:

$recordId = (int) isset($data[$key]) ? $data[$key] : 0;

// New record (id:0) only in this case fallback to component permissions !!
if (!$recordId)
{
    parent::allowEdit($data, $key);
}

// Need to do a lookup from the model.
$record = $this->getModel()->getItem($recordId);

// Not found or empty category
if (!$record || empty($record->catid))
{
    return false;
}

$categoryId = $record->catid;

// First test if having core.edit on the record's category
// If individual asset is added in the future then we need to check on the record asset itself)
if ($user->authorise('core.edit', $this->option . '.category.' . $categoryId))
{
    return true;
}

// Not having core.edit, test core.edit.own on the category (again because no individual asset)
if ($user->authorise('core.edit.own', $this->option . '.category.' . $categoryId))
{
    // If the owner matches 'me' then permission is granted.
    return $record->created_by == JFactory::getUser()->id;
}

return false;
avatar brianteeman brianteeman - change - 5 Aug 2016
Labels Added: ?
avatar infograf768
infograf768 - comment - 5 Aug 2016

I did not say it was a security issue. If it had been I would not have posted here.
I discovered these issues while working on the multilingual GSOC project

avatar infograf768
infograf768 - comment - 5 Aug 2016

your code does not work here.

avatar ggppdk
ggppdk - comment - 5 Aug 2016

your code does not work here.

yes you are right,
(but i did contribute some time to test the issue and propose code)

someone should take time to make a PR and then answer it, update it, etc etc .... and it will work, (it may need some small corrections)

i can do next days, (since this is not urgent and there are 3 controllers to patch), otherwise someone else can take time to do it now

avatar infograf768
infograf768 - comment - 5 Aug 2016

for newsfeeds, needs more work as even created_by is not fetched...

avatar ggppdk
ggppdk - comment - 5 Aug 2016

See the code above

Propably all of the code is same in all controllers:
This gets a model instance to get the owner id

            // Need to do a lookup from the model.
            $record = $this->getModel()->getItem($recordId);

            if (empty($record))
            {
                return false;
            }

            $ownerId = $record->created_by;
avatar ggppdk
ggppdk - comment - 5 Aug 2016

I am not sure (without testing) but we speak of the
allowEdit() method
of the singular controllers:

components\com_contacts\controllers\contact.php
components\com_newsfeeds\controllers\newsfeed.php
components\com_weblinks\controllers\weblink.php

I think

$record = $this->getModel()->getItem($recordId);

will use models:
components\com_contacts\models\contact.php
components\com_newsfeeds\models\newsfeed.php
components\com_weblinks\models\weblink.php

that already retrieve the created_by property ?

avatar infograf768
infograf768 - comment - 5 Aug 2016

without a correction in the model, we also get errors in the manager

avatar ggppdk
ggppdk - comment - 5 Aug 2016

without a correction in the model, we also get errors in the manager

aaa yes you are right we need to get the created_by property to be retrieved by these plural models,

  • for usage in "canEdit" calculation inside default.php of the backend lists

i see it is incomplete too only checking core.edit

e.g.
https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_newsfeeds/views/newsfeeds/tmpl/default.php#L98

$canEdit    = $user->authorise('core.edit',       'com_newsfeeds.category.' . $item->catid);

should be:

$canEdit = $user->authorise('core.edit',       'com_newsfeeds.category.' . $item->catid) ||
    (
        $user->authorise('core.edit.edit', 'com_newsfeeds.category.' . $item->catid) &&
        $item->created_by==$user->id
    );
avatar infograf768
infograf768 - comment - 6 Aug 2016

I suggest, if you can help, to solve the issue first with com_contacts with a specific PR (or first propose a .diff here).
Then it should be easy to go all over newsfeeds and implement it wherever needed.

avatar ggppdk
ggppdk - comment - 6 Aug 2016

Ok, this seems straghtforward, I will do today 1 PR for the 3 controllers and the 3 listing templates (i will update plurar models too), i think it will be much more time to test this that to code it)), since what needs to be done was discussed here

avatar andrepereiradasilva
andrepereiradasilva - comment - 7 Aug 2016

PR for newsfeeds is here #11502 please test

avatar andrepereiradasilva
andrepereiradasilva - comment - 7 Aug 2016

PR for com_contact #11503

avatar andrepereiradasilva
andrepereiradasilva - comment - 7 Aug 2016
avatar andrepereiradasilva
andrepereiradasilva - comment - 7 Aug 2016

cam be closed as there are 3 PR to test: #11502 | #11503 | joomla-extensions/weblinks#255

avatar infograf768 infograf768 - change - 7 Aug 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-08-07 05:38:10
Closed_By infograf768
avatar infograf768
infograf768 - comment - 7 Aug 2016

Closed as we have PRs


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11466.

avatar infograf768 infograf768 - close - 7 Aug 2016

Add a Comment

Login with GitHub to post a comment