/** * Returns true if the internal BE_USER has access to the module $name with $MCONF (based on security level set for that module) * * @param string Module name * @param array MCONF array (module configuration array) from the modules conf.php file (contains settings about what access level the module has) * @return boolean True if access is granted for $this->BE_USER */ function checkModAccess($name, $MCONF) { if ($MCONF['access']) { $access = strtolower($MCONF['access']); // Checking if admin-access is required if (strstr($access, 'admin')) { // If admin-permissions is required then return true if user is admin if ($this->BE_USER->isAdmin()) { return TRUE; } } // This will add modules to the select-lists of user and groups if (strstr($access, 'user')) { $this->modListUser[] = $name; } if (strstr($access, 'group')) { $this->modListGroup[] = $name; } // This checks if a user is permitted to access the module if ($this->BE_USER->isAdmin() || $this->BE_USER->check('modules', $name)) { return TRUE; } // If admin you can always access a module } else { return TRUE; } // If conf[access] is not set, then permission IS granted! }
/** * @test */ public function hasAccessForAccessToEventsTableAndAccessToRegistrationsTableAndNoAccessToSetPageReturnsFalse() { $this->backEndUser->expects(self::any())->method('check')->with('tables_select', self::anything())->will(self::returnValue(TRUE)); $pageUid = 12341; $this->subject->setPageUid($pageUid); $pageRecord = t3lib_BEfunc::getRecord('pages', $pageUid); $this->backEndUser->expects(self::any())->method('doesUserHaveAccess')->with($pageRecord, 1)->will(self::returnValue(FALSE)); self::assertFalse($this->subject->hasAccess()); }
/** * @test */ public function hasAccessForAccessToTableAndAccessToPageReturnsTrue() { $pageUid = 12341; $this->subject->setPageUid($pageUid); $pageRecord = t3lib_BEfunc::getRecord('pages', $pageUid); $this->backEndUser->expects(self::any())->method('check')->with('tables_select', 'tx_seminars_seminars')->will(self::returnValue(TRUE)); $this->backEndUser->expects(self::any())->method('doesUserHaveAccess')->with($pageRecord, 1)->will(self::returnValue(TRUE)); self::assertTrue($this->subject->hasAccess()); }
/** * Determines whether the donate window is allowed to be displayed. * * @return boolean Whether the donate window is allowed to be displayed. */ public function isDonateWindowAllowed() { $uc = $this->backendUser->uc; $isAdmin = $this->backendUser->isAdmin(); $firstLogin = $this->getFirstLoginTimeStamp(); $isTriggered = $firstLogin && $GLOBALS['EXEC_TIME'] - $firstLogin > self::VALUE_DonateWindowAppearsAfterDays * 86400; $isAllowed = (bool) $GLOBALS['TYPO3_CONF_VARS']['BE']['allowDonateWindow']; $isCancelled = isset($uc[self::FLAG_DonateWindowDisabled]) && !empty($uc[self::FLAG_DonateWindowDisabled]); $isPostponed = isset($uc[self::FLAG_DonateWindowPostponed]) && $uc[self::FLAG_DonateWindowPostponed] > $GLOBALS['EXEC_TIME'] - self::VALUE_DonateWindowPostponeDays * 86400; return $isAdmin && $isAllowed && $isTriggered && !$isCancelled && !$isPostponed; }
/** * Logging actions from TCEmain * * @param string Table name the log entry is concerned with. Blank if NA * @param integer Record UID. Zero if NA * @param integer Action number: 0=No category, 1=new record, 2=update record, 3= delete record, 4= move record, 5= Check/evaluate * @param integer Normally 0 (zero). If set, it indicates that this log-entry is used to notify the backend of a record which is moved to another location * @param integer The severity: 0 = message, 1 = error, 2 = System Error, 3 = security notice (admin) * @param string Default error message in english * @param integer This number is unique for every combination of $type and $action. This is the error-message number, which can later be used to translate error messages. 0 if not categorized, -1 if temporary * @param array Array with special information that may go into $details by '%s' marks / sprintf() when the log is shown * @param integer The page_uid (pid) where the event occurred. Used to select log-content for specific pages. * @param string NEW id for new records * @return integer Log entry UID * @see class.t3lib_userauthgroup.php */ function log($table, $recuid, $action, $recpid, $error, $details, $details_nr = -1, $data = array(), $event_pid = -1, $NEWid = '') { if ($this->enableLogging) { $type = 1; // Type value for tce_db.php if (!$this->storeLogMessages) { $details = ''; } if ($error > 0) { $this->errorLog[] = '[' . $type . '.' . $action . '.' . $details_nr . ']: ' . $details; } return $this->BE_USER->writelog($type, $action, $error, $details_nr, $details, $data, $table, $recuid, $recpid, $event_pid, $NEWid); } }
/** * Saves the content of ->stored (keeps track of expanded positions in the tree) * $this->treeName will be used as key for BE_USER->uc[] to store it in * * @return void * @access private */ function savePosition() { $this->BE_USER->uc['browseTrees'][$this->treeName] = serialize($this->stored); $this->BE_USER->writeUC(); }
/** * Saves the tokens so that they can be used by a later incarnation of this * class. * * @return void */ public function persistTokens() { if ($this->isPersistingRequired()) { $lockObject = $this->acquireLock(); $this->updateTokens(); $this->backendUser->setAndSaveSessionData('formTokens', $this->tokens); $this->resetPersistingRequiredStatus(); $this->releaseLock($lockObject); } }