public function adjustPermissions($insertId)
	{
		// The oncreate_callback passes $insertId as second argument
		if (\func_num_args() == 4)
		{
			$insertId = func_get_arg(1);
		}

		if ($this->User->isAdmin)
		{
			return;
		}

		// Set root IDs
		if (empty($this->User->calendarfeeds) || !\is_array($this->User->calendarfeeds))
		{
			$root = array(0);
		}
		else
		{
			$root = $this->User->calendarfeeds;
		}

		// The calendar feed is enabled already
		if (\in_array($insertId, $root))
		{
			return;
		}

		/** @var Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface $objSessionBag */
		$objSessionBag = Contao\System::getContainer()->get('session')->getBag('contao_backend');

		$arrNew = $objSessionBag->get('new_records');

		if (\is_array($arrNew['tl_calendar_feed']) && \in_array($insertId, $arrNew['tl_calendar_feed']))
		{
			// Add the permissions on group level
			if ($this->User->inherit != 'custom')
			{
				$objGroup = $this->Database->execute("SELECT id, calendarfeeds, calendarfeedp FROM tl_user_group WHERE id IN(" . implode(',', array_map('\intval', $this->User->groups)) . ")");

				while ($objGroup->next())
				{
					$arrCalendarfeedp = Contao\StringUtil::deserialize($objGroup->calendarfeedp);

					if (\is_array($arrCalendarfeedp) && \in_array('create', $arrCalendarfeedp))
					{
						$arrCalendarfeeds = Contao\StringUtil::deserialize($objGroup->calendarfeeds, true);
						$arrCalendarfeeds[] = $insertId;

						$this->Database->prepare("UPDATE tl_user_group SET calendarfeeds=? WHERE id=?")
									   ->execute(serialize($arrCalendarfeeds), $objGroup->id);
					}
				}
			}

			// Add the permissions on user level
			if ($this->User->inherit != 'group')
			{
				$objUser = $this->Database->prepare("SELECT calendarfeeds, calendarfeedp FROM tl_user WHERE id=?")
										   ->limit(1)
										   ->execute($this->User->id);

				$arrCalendarfeedp = Contao\StringUtil::deserialize($objUser->calendarfeedp);

				if (\is_array($arrCalendarfeedp) && \in_array('create', $arrCalendarfeedp))
				{
					$arrCalendarfeeds = Contao\StringUtil::deserialize($objUser->calendarfeeds, true);
					$arrCalendarfeeds[] = $insertId;

					$this->Database->prepare("UPDATE tl_user SET calendarfeeds=? WHERE id=?")
								   ->execute(serialize($arrCalendarfeeds), $this->User->id);
				}
			}

			// Add the new element to the user object
			$root[] = $insertId;
			$this->User->calendarfeeds = $root;
		}
	}
public function adjustPermissions($insertId)
	{
		
		if (\func_num_args() == 4)
		{
			$insertId = func_get_arg(1);
		}

		if ($this->User->isAdmin)
		{
			return;
		}

		
		if (empty($this->User->calendarfeeds) || !\is_array($this->User->calendarfeeds))
		{
			$root = array(0);
		}
		else
		{
			$root = $this->User->calendarfeeds;
		}

		
		if (\in_array($insertId, $root))
		{
			return;
		}

		
		$objSessionBag = Contao\System::getContainer()->get('session')->getBag('contao_backend');

		$arrNew = $objSessionBag->get('new_records');

		if (\is_array($arrNew['tl_calendar_feed']) && \in_array($insertId, $arrNew['tl_calendar_feed']))
		{
			
			if ($this->User->inherit != 'custom')
			{
				$objGroup = $this->Database->execute("SELECT id, calendarfeeds, calendarfeedp FROM tl_user_group WHERE id IN(" . implode(',', array_map('\intval', $this->User->groups)) . ")");

				while ($objGroup->next())
				{
					$arrCalendarfeedp = Contao\StringUtil::deserialize($objGroup->calendarfeedp);

					if (\is_array($arrCalendarfeedp) && \in_array('create', $arrCalendarfeedp))
					{
						$arrCalendarfeeds = Contao\StringUtil::deserialize($objGroup->calendarfeeds, true);
						$arrCalendarfeeds[] = $insertId;

						$this->Database->prepare("UPDATE tl_user_group SET calendarfeeds=? WHERE id=?")
									   ->execute(serialize($arrCalendarfeeds), $objGroup->id);
					}
				}
			}

			
			if ($this->User->inherit != 'group')
			{
				$objUser = $this->Database->prepare("SELECT calendarfeeds, calendarfeedp FROM tl_user WHERE id=?")
										   ->limit(1)
										   ->execute($this->User->id);

				$arrCalendarfeedp = Contao\StringUtil::deserialize($objUser->calendarfeedp);

				if (\is_array($arrCalendarfeedp) && \in_array('create', $arrCalendarfeedp))
				{
					$arrCalendarfeeds = Contao\StringUtil::deserialize($objUser->calendarfeeds, true);
					$arrCalendarfeeds[] = $insertId;

					$this->Database->prepare("UPDATE tl_user SET calendarfeeds=? WHERE id=?")
								   ->execute(serialize($arrCalendarfeeds), $this->User->id);
				}
			}

			
			$root[] = $insertId;
			$this->User->calendarfeeds = $root;
		}
	}
public function adjustPermissions ( $ insertId ) { // The oncreate_callback passes $insertId as second argument if ( \ func_num_args ( ) == 4 ) { $ insertId = func_get_arg ( 1 ) ; } if ( $ this -> User -> isAdmin ) { return ; } // Set root IDs if ( empty ( $ this -> User -> calendarfeeds ) || ! \ is_array ( $ this -> User -> calendarfeeds ) ) { $ root = array ( 0 ) ; } else { $ root = $ this -> User -> calendarfeeds ; } // The calendar feed is enabled already if ( \ in_array ( $ insertId , $ root ) ) { return ; } /** @var Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface $objSessionBag */ $ objSessionBag = Contao \ System :: getContainer ( ) -> get ( 'session' ) -> getBag ( 'contao_backend' ) ; $ arrNew = $ objSessionBag -> get ( 'new_records' ) ; if ( \ is_array ( $ arrNew [ 'tl_calendar_feed' ] ) && \ in_array ( $ insertId , $ arrNew [ 'tl_calendar_feed' ] ) ) { // Add the permissions on group level if ( $ this -> User -> inherit != 'custom' ) { $ objGroup = $ this -> Database -> execute ( "SELECT id, calendarfeeds, calendarfeedp FROM tl_user_group WHERE id IN(" . implode ( ',' , array_map ( '\intval' , $ this -> User -> groups ) ) . ")" ) ; while ( $ objGroup -> next ( ) ) { $ arrCalendarfeedp = Contao \ StringUtil :: deserialize ( $ objGroup -> calendarfeedp ) ; if ( \ is_array ( $ arrCalendarfeedp ) && \ in_array ( 'create' , $ arrCalendarfeedp ) ) { $ arrCalendarfeeds = Contao \ StringUtil :: deserialize ( $ objGroup -> calendarfeeds , true ) ; $ arrCalendarfeeds [ ] = $ insertId ; $ this -> Database -> prepare ( "UPDATE tl_user_group SET calendarfeeds=? WHERE id=?" ) -> execute ( serialize ( $ arrCalendarfeeds ) , $ objGroup -> id ) ; } } } // Add the permissions on user level if ( $ this -> User -> inherit != 'group' ) { $ objUser = $ this -> Database -> prepare ( "SELECT calendarfeeds, calendarfeedp FROM tl_user WHERE id=?" ) -> limit ( 1 ) -> execute ( $ this -> User -> id ) ; $ arrCalendarfeedp = Contao \ StringUtil :: deserialize ( $ objUser -> calendarfeedp ) ; if ( \ is_array ( $ arrCalendarfeedp ) && \ in_array ( 'create' , $ arrCalendarfeedp ) ) { $ arrCalendarfeeds = Contao \ StringUtil :: deserialize ( $ objUser -> calendarfeeds , true ) ; $ arrCalendarfeeds [ ] = $ insertId ; $ this -> Database -> prepare ( "UPDATE tl_user SET calendarfeeds=? WHERE id=?" ) -> execute ( serialize ( $ arrCalendarfeeds ) , $ this -> User -> id ) ; } } // Add the new element to the user object $ root [ ] = $ insertId ; $ this -> User -> calendarfeeds = $ root ; } }
Add the new calendar feed to the permissions

@param $insertId
Add the new calendar feed to the permissions