Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Always add new resources to all user/groups granting the permission (…
Browse files Browse the repository at this point in the history
…see #8583).
  • Loading branch information
leofeyer committed Jan 16, 2017
1 parent 0c59f0f commit e057dc4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 34 deletions.
32 changes: 15 additions & 17 deletions src/Resources/contao/dca/tl_news_archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,30 +317,28 @@ public function checkPermission()

if (is_array($arrNew['tl_news_archive']) && in_array(Input::get('id'), $arrNew['tl_news_archive']))
{
$blnDone = false;

// Try to add the permissions on group level
if ($this->User->inherit != 'custom' && !empty($this->User->groups[0]))
// Add the permissions on group level
if ($this->User->inherit != 'custom')
{
$objGroup = $this->Database->prepare("SELECT news, newp FROM tl_user_group WHERE id=?")
->limit(1)
->execute($this->User->groups[0]);

$arrNewp = deserialize($objGroup->newp);
$objGroup = $this->Database->execute("SELECT id, news, newp FROM tl_user_group WHERE id IN(" . implode(',', array_map('intval', $this->User->groups)) . ")");

if (is_array($arrNewp) && in_array('create', $arrNewp))
while ($objGroup->next())
{
$blnDone = true;
$arrNews = deserialize($objGroup->news, true);
$arrNews[] = Input::get('id');
$arrNewp = deserialize($objGroup->newp);

if (is_array($arrNewp) && in_array('create', $arrNewp))
{
$arrNews = deserialize($objGroup->news, true);
$arrNews[] = Input::get('id');

$this->Database->prepare("UPDATE tl_user_group SET news=? WHERE id=?")
->execute(serialize($arrNews), $this->User->groups[0]);
$this->Database->prepare("UPDATE tl_user_group SET news=? WHERE id=?")
->execute(serialize($arrNews), $objGroup->id);
}
}
}

// Add permissions on user level
if (!$blnDone)
// Add the permissions on user level
if ($this->User->inherit != 'group')
{
$objUser = $this->Database->prepare("SELECT news, newp FROM tl_user WHERE id=?")
->limit(1)
Expand Down
32 changes: 15 additions & 17 deletions src/Resources/contao/dca/tl_news_feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,30 +270,28 @@ public function checkPermission()

if (is_array($arrNew['tl_news_feed']) && in_array(Input::get('id'), $arrNew['tl_news_feed']))
{
$blnDone = false;

// Try to add the permissions on group level
if ($this->User->inherit != 'custom' && !empty($this->User->groups[0]))
// Add the permissions on group level
if ($this->User->inherit != 'custom')
{
$objGroup = $this->Database->prepare("SELECT newsfeeds, newsfeedp FROM tl_user_group WHERE id=?")
->limit(1)
->execute($this->User->groups[0]);

$arrNewsfeedp = deserialize($objGroup->newsfeedp);
$objGroup = $this->Database->execute("SELECT id, newsfeeds, newsfeedp FROM tl_user_group WHERE id IN(" . implode(',', array_map('intval', $this->User->groups)) . ")");

if (is_array($arrNewsfeedp) && in_array('create', $arrNewsfeedp))
while ($objGroup->next())
{
$blnDone = true;
$arrNewsfeeds = deserialize($objGroup->newsfeeds, true);
$arrNewsfeeds[] = Input::get('id');
$arrNewsfeedp = deserialize($objGroup->newsfeedp);

if (is_array($arrNewsfeedp) && in_array('create', $arrNewsfeedp))
{
$arrNewsfeeds = deserialize($objGroup->newsfeeds, true);
$arrNewsfeeds[] = Input::get('id');

$this->Database->prepare("UPDATE tl_user_group SET newsfeeds=? WHERE id=?")
->execute(serialize($arrNewsfeeds), $this->User->groups[0]);
$this->Database->prepare("UPDATE tl_user_group SET newsfeeds=? WHERE id=?")
->execute(serialize($arrNewsfeeds), $objGroup->id);
}
}
}

// Add permissions on user level
if (!$blnDone)
// Add the permissions on user level
if ($this->User->inherit != 'group')
{
$objUser = $this->Database->prepare("SELECT newsfeeds, newsfeedp FROM tl_user WHERE id=?")
->limit(1)
Expand Down

0 comments on commit e057dc4

Please sign in to comment.