1

Is it possible to store all records of the news extension (ext:news) on the same storage page, but show only records, which are created by the loggedin backend user?

So the current backend user can just see and edit his own records? Admins should see all records of course.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
chris
  • 2,109
  • 2
  • 23
  • 33

2 Answers2

1

No, this is not possible, since backend user permissions on record level are not implemented in TYPO3.

So you either have to separate the news records of the users in separate sysfolders or you could try to use hooks (e.g. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable']) or XClass to customize TYPO3 backend to your needs. I do not recommend the latter, since the TYPO3 backend permission system is complex and you would need to make sure to restrict record access in several parts of TYPO3 (e.g. recordlist, element browser, related news field, ...)

derhansen
  • 5,585
  • 1
  • 19
  • 29
  • Thanks, that worked perfectly! Find a working example [here](https://gist.github.com/cdaecke/b10ba38ae02f8e94d1cdd8221781f05e). – chris Sep 19 '19 at 12:12
0

There are two ways to archive that:

  1. If the backend user is not too much. You can just create a page(type is folder) named with the backend user name. And in the backend user module you can set the permission(Not for the group user but for the single backend user only).
  2. if the backend user is too much. and You just wanna set permissions for the group and all backend users are sharing the same rules. You can refer to Hook:https://docs.typo3.org/p/georgringer/news/main/en-us/Tutorials/ExtendNews/Hooks/Index.html so that the basic logic is like this: 2.1 get current logged-in user group. 2.2 if the group is Reporter, we can use the hook for the listing page:
    $constraints[] = $query->equals('cruser_id', $be_id);
    

Edit(3/3/2022):

Hi Chris, Yes you are right. Today, I have got a chance to dig into the news extension. I think we can still make it by the hook

  1. in your ext_localconf.php
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList::class]['modifyQuery'][$_EXTKEY]
 = \T3docs\SitePackage\Hooks\DatabaseRecordListHook::class;

(Please make sure the namespace is correct)

  1. within the file : T3docs\SitePackage\Hooks\DatabaseRecordListHook.Create a function named modifyQuery:

public function modifyQuery($parameters,
                             $table,
                             $pageId,
                             $additionalConstraints,
                             $fields,
                             $queryBuilder)
 {
     if ($table === 'tx_news_domain_model_news') {
         $tsconfig = $GLOBALS['BE_USER']->getTSConfig();
         if (!empty($tsconfig['options.']['be_users'])) {
             $be_users = $tsconfig['options.']['be_users'];
             $queryBuilder->andWhere('cruser_id IN (' . $be_users . ')');
         }
     }
     return $queryBuilder;
 }

  1. in the user Options tab set Tsconfg : options.be_users = 3,100 (3,100 is the be_user id. And the 2 two backend users's news will show up) enter image description here

thus, it works for me.

Zike
  • 67
  • 1
  • 1
  • 4
  • 1
    I think the second solution is working for the listing in the frontend, but not in the TYPO3 backend. – chris Feb 23 '22 at 08:26