ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilObjForumAccess Class Reference

Class ilObjForumAccess. More...

+ Inheritance diagram for ilObjForumAccess:
+ Collaboration diagram for ilObjForumAccess:

Static Public Member Functions

static _getCommands ()
 get commands More...
 
static _checkGoto (string $target)
 check whether goto script will succeed More...
 
static _getThreadForPosting (int $a_pos_id)
 
static prepareMessageForLists (string $text)
 
static _preloadData (array $obj_ids, array $ref_ids)
 Preload data. More...
 
static getLastPostByRefId (int $ref_id)
 
static getStatisticsByRefId (int $ref_id)
 
static getCachedUserInstance (int $usr_id)
 
- Static Public Member Functions inherited from ilObjectAccess
static _getCommands ()
 get commands More...
 
static _checkGoto (string $target)
 check whether goto script will succeed More...
 
static _isOffline (int $obj_id)
 Type-specific implementation of general status, has to be overwritten if object type does not support centralized offline handling. More...
 
static _preloadData (array $obj_ids, array $ref_ids)
 Preload data. More...
 

Static Protected Attributes

static array $userInstanceCache = []
 

Additional Inherited Members

- Public Member Functions inherited from ilObjectAccess
 _checkAccess (string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
 Checks whether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess) More...
 
 canBeDelivered (ilWACPath $ilWACPath)
 
 canBeDelivered (ilWACPath $ilWACPath)
 

Detailed Description

Member Function Documentation

◆ _checkGoto()

static ilObjForumAccess::_checkGoto ( string  $target)
static

check whether goto script will succeed

Reimplemented from ilObjectAccess.

Definition at line 48 of file class.ilObjForumAccess.php.

48 : bool
49 {
50 global $DIC;
51
52 $t_arr = explode('_', $target);
53
54 if ($t_arr[0] !== 'frm' || ((int) $t_arr[1]) <= 0) {
55 return false;
56 }
57
58 return (
59 $DIC->access()->checkAccess('read', '', (int) $t_arr[1]) ||
60 $DIC->access()->checkAccess('visible', '', (int) $t_arr[1])
61 );
62 }
global $DIC
Definition: shib_login.php:26

References $DIC.

◆ _getCommands()

static ilObjForumAccess::_getCommands ( )
static

get commands

this method returns an array of all possible commands/permission combinations

example: $commands = array ( array("permission" => "read", "cmd" => "view", "lang_var" => "show"), array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"), );

Returns
array{permission?:string, cmd?:string, lang_var?:string, default?:bool}[]

Reimplemented from ilObjectAccess.

Definition at line 31 of file class.ilObjForumAccess.php.

31 : array
32 {
33 return [
34 [
35 'permission' => 'read',
36 'cmd' => 'showThreads',
37 'lang_var' => 'show',
38 'default' => true
39 ],
40 [
41 'permission' => 'write',
42 'cmd' => 'edit',
43 'lang_var' => 'settings'
44 ],
45 ];
46 }
return true

References true.

Referenced by ilObjForumListGUI\init().

+ Here is the caller graph for this function:

◆ _getThreadForPosting()

static ilObjForumAccess::_getThreadForPosting ( int  $a_pos_id)
static

Definition at line 64 of file class.ilObjForumAccess.php.

64 : int
65 {
66 global $DIC;
67 $ilDB = $DIC->database();
68
69 $res = $ilDB->queryF(
70 'SELECT pos_thr_fk FROM frm_posts WHERE pos_pk = %s',
71 ['integer'],
72 [$a_pos_id]
73 );
74
75 $row = $ilDB->fetchAssoc($res);
76
77 return (int) $row['pos_thr_fk'];
78 }
$res
Definition: ltiservices.php:69

References $DIC, $ilDB, and $res.

Referenced by ilObjectFeedWriter\__construct(), ilUserFeedWriter\__construct(), ilPDNewsTableGUI\fillRow(), ilForumNewsRendererGUI\getObjectLink(), and ilNewsForContextBlockGUI\showNews().

+ Here is the caller graph for this function:

◆ _preloadData()

static ilObjForumAccess::_preloadData ( array  $obj_ids,
array  $ref_ids 
)
static

Preload data.

Reimplemented from ilObjectAccess.

Definition at line 92 of file class.ilObjForumAccess.php.

92 : void
93 {
94 /*
95 We are only able to preload the top_pk values for the forum ref_ids.
96 Other data like statistics and last posts require permission checks per reference, so there is no added value for using an SQL IN() function in the queries
97 */
99 }
static preloadForumIdsByRefIds(array $ref_ids)

References ilObjForum\preloadForumIdsByRefIds().

+ Here is the call graph for this function:

◆ getCachedUserInstance()

static ilObjForumAccess::getCachedUserInstance ( int  $usr_id)
static

Definition at line 114 of file class.ilObjForumAccess.php.

114 : ?ilObjUser
115 {
116 if (!isset(self::$userInstanceCache[$usr_id]) && ilObjUser::userExists([$usr_id])) {
117 $user = ilObjectFactory::getInstanceByObjId($usr_id, false);
118 if ($user instanceof ilObjUser) {
119 self::$userInstanceCache[$usr_id] = $user;
120 }
121 }
122
123 return self::$userInstanceCache[$usr_id] ?? null;
124 }
User class.
static userExists(array $a_usr_ids=[])
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id

References ilObjectFactory\getInstanceByObjId(), and ilObjUser\userExists().

Referenced by ilForumAuthorInformation\initUserInstance().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLastPostByRefId()

static ilObjForumAccess::getLastPostByRefId ( int  $ref_id)
static

Definition at line 101 of file class.ilObjForumAccess.php.

101 : ?array
102 {
104 }
static lookupLastPostByRefId(int $ref_id)
$ref_id
Definition: ltiauth.php:66

References $ref_id, and ilObjForum\lookupLastPostByRefId().

Referenced by ilObjForumListGUI\getProperties().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStatisticsByRefId()

static ilObjForumAccess::getStatisticsByRefId ( int  $ref_id)
static
Returns
array{num_posts: int, num_unread_posts: int}

Definition at line 109 of file class.ilObjForumAccess.php.

109 : array
110 {
112 }
static lookupStatisticsByRefId(int $ref_id)

References $ref_id, and ilObjForum\lookupStatisticsByRefId().

Referenced by ilObjForumListGUI\getProperties().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepareMessageForLists()

static ilObjForumAccess::prepareMessageForLists ( string  $text)
static

Definition at line 80 of file class.ilObjForumAccess.php.

80 : string
81 {
82 $text = str_replace('<br />', ' ', $text);
83 $text = strip_tags($text);
84 $text = preg_replace('/\[(\/)?quote\]/', '', $text);
85 if (ilStr::strLen($text) > 40) {
86 $text = ilStr::subStr($text, 0, 37) . '...';
87 }
88
89 return $text;
90 }
static subStr(string $a_str, int $a_start, ?int $a_length=null)
Definition: class.ilStr.php:21
static strLen(string $a_string)
Definition: class.ilStr.php:60

References ilStr\strLen(), and ilStr\subStr().

Referenced by ilObjForumListGUI\getProperties().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $userInstanceCache

array ilObjForumAccess::$userInstanceCache = []
staticprotected

Definition at line 29 of file class.ilObjForumAccess.php.


The documentation for this class was generated from the following file: