ILIAS  release_8 Revision v8.23
ilObjForumAccess Class Reference

Class ilObjForumAccess. More...

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

Static Public Member Functions

static _getCommands ()
 
static _checkGoto (string $target)
 
static _getThreadForPosting (int $a_pos_id)
 
static prepareMessageForLists (string $text)
 
static _preloadData (array $obj_ids, array $ref_ids)
 
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)
 

Detailed Description

Member Function Documentation

◆ _checkGoto()

static ilObjForumAccess::_checkGoto ( string  $target)
static

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

References $DIC.

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  if (
59  $DIC->access()->checkAccess('read', '', (int) $t_arr[1]) ||
60  $DIC->access()->checkAccess('visible', '', (int) $t_arr[1])
61  ) {
62  return true;
63  }
64 
65  return false;
66  }
global $DIC
Definition: feed.php:28

◆ _getCommands()

static ilObjForumAccess::_getCommands ( )
static

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

Referenced by ilObjForumListGUI\init().

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  }
+ Here is the caller graph for this function:

◆ _getThreadForPosting()

static ilObjForumAccess::_getThreadForPosting ( int  $a_pos_id)
static

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

References $DIC, $ilDB, and $res.

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

68  : int
69  {
70  global $DIC;
71  $ilDB = $DIC->database();
72 
73  $res = $ilDB->queryF(
74  'SELECT pos_thr_fk FROM frm_posts WHERE pos_pk = %s',
75  ['integer'],
76  [$a_pos_id]
77  );
78 
79  $row = $ilDB->fetchAssoc($res);
80 
81  return (int) $row['pos_thr_fk'];
82  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ _preloadData()

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

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

References ilObjForum\preloadForumIdsByRefIds().

96  : void
97  {
98  /*
99  We are only able to preload the top_pk values for the forum ref_ids.
100  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
101  */
103  }
static preloadForumIdsByRefIds(array $ref_ids)
+ Here is the call graph for this function:

◆ getCachedUserInstance()

static ilObjForumAccess::getCachedUserInstance ( int  $usr_id)
static

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

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

Referenced by ilForumAuthorInformation\initUserInstance().

119  : ?ilObjUser
120  {
121  if (!isset(self::$userInstanceCache[$usr_id]) && ilObjUser::userExists([$usr_id])) {
122  $user = ilObjectFactory::getInstanceByObjId($usr_id, false);
123  if ($user instanceof ilObjUser) {
124  self::$userInstanceCache[$usr_id] = $user;
125  }
126  }
127 
128  return self::$userInstanceCache[$usr_id] ?? null;
129  }
static userExists(array $a_usr_ids=array())
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
+ 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 105 of file class.ilObjForumAccess.php.

References ilObjForum\lookupLastPostByRefId().

Referenced by ilObjForumListGUI\getProperties().

105  : ?array
106  {
108  }
$ref_id
Definition: ltiauth.php:67
static lookupLastPostByRefId(int $ref_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStatisticsByRefId()

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

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

References ilObjForum\lookupStatisticsByRefId().

Referenced by ilObjForumListGUI\getProperties().

114  : array
115  {
117  }
$ref_id
Definition: ltiauth.php:67
static lookupStatisticsByRefId(int $ref_id)
+ 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 84 of file class.ilObjForumAccess.php.

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

Referenced by ilObjForumListGUI\getProperties().

84  : string
85  {
86  $text = str_replace('<br />', ' ', $text);
87  $text = strip_tags($text);
88  $text = preg_replace('/\[(\/)?quote\]/', '', $text);
89  if (ilStr::strLen($text) > 40) {
90  $text = ilStr::subStr($text, 0, 37) . '...';
91  }
92 
93  return $text;
94  }
static subStr(string $a_str, int $a_start, ?int $a_length=null)
Definition: class.ilStr.php:24
static strLen(string $a_string)
Definition: class.ilStr.php:63
+ 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: