ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilObjForumAccess Class Reference

Class ilObjForumAccess. More...

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

Public Member Functions

 _getCommands ()
 get commands
 _checkGoto ($a_target)
 check whether goto script will succeed
 _getThreadForPosting ($a_pos_id)
 Get thread id for posting.
 prepareMessageForLists ($text)
 Prepare message for container view.
- Public Member Functions inherited from ilObjectAccess
 _checkAccess ($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
 Checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess)
 _checkCondition ($a_obj_id, $a_operator, $a_value, $a_usr_id=0)
 check condition

Static Public Member Functions

static _lookupDiskUsage ($a_obj_id)
 Returns the number of bytes used on the harddisk by the specified forum.
static getNumberOfPostings ($a_obj_id, $a_only_active=false)
 Get number of postings.
static getNumberOfReadPostings ($a_obj_id, $a_only_active=false)
 Get number of read posts.
static getNumberOfNewPostings ($a_obj_id, $a_only_active=false)
 Count number of new posts.
static getLastPost ($a_obj_id)
 Count number of new posts.

Detailed Description

Class ilObjForumAccess.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
Id:
class.ilObjForumAccess.php 27655 2011-02-04 10:44:23Z mjansen

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

Member Function Documentation

ilObjForumAccess::_checkGoto (   $a_target)

check whether goto script will succeed

Reimplemented from ilObjectAccess.

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

{
global $ilAccess;
$t_arr = explode("_", $a_target);
if ($t_arr[0] != "frm" || ((int) $t_arr[1]) <= 0)
{
return false;
}
if ($ilAccess->checkAccess("read", "", $t_arr[1]))
{
return true;
}
return false;
}
ilObjForumAccess::_getCommands ( )

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"), );

Reimplemented from ilObjectAccess.

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

Referenced by ilObjForumListGUI\init().

{
$commands = array
(
array("permission" => "read", "cmd" => "showThreads", "lang_var" => "show",
"default" => true),
array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"),
);
return $commands;
}

+ Here is the caller graph for this function:

ilObjForumAccess::_getThreadForPosting (   $a_pos_id)

Get thread id for posting.

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

References $ilDB, $res, and DB_FETCHMODE_ASSOC.

Referenced by ilPDNewsTableGUI\fillRow(), and ilNewsForContextBlockGUI\showNews().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT pos_thr_fk FROM frm_posts WHERE pos_pk = %s',
array('integer'), array($a_pos_id));
$rec = $res->fetchRow(DB_FETCHMODE_ASSOC);
return $rec["pos_thr_fk"];
}

+ Here is the caller graph for this function:

static ilObjForumAccess::_lookupDiskUsage (   $a_obj_id)
static

Returns the number of bytes used on the harddisk by the specified forum.

Parameters
$forum_idid.

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

References $ilDB, $lng, $row, $size, DB_FETCHMODE_ASSOC, and ilUtil\getDataDir().

Referenced by ilObjForum\getDiskUsage().

{
global $ilDB, $lng;
require_once 'Modules/Forum/classes/class.ilFileDataForum.php';
$mail_data_dir = ilUtil::getDataDir('filesystem').DIRECTORY_SEPARATOR."forum";
$result_set = $ilDB->queryf('
SELECT top_frm_fk, pos_pk FROM frm_posts p
JOIN frm_data d ON d.top_pk = p.pos_top_fk
WHERE top_frm_fk = %s',
array('integer'), array($a_obj_id));
$size = 0;
//$count = 0; counts the number of attachments
while($row = $result_set->fetchRow(DB_FETCHMODE_ASSOC))
{
$fileDataForum = new ilFileDataForum($row['top_frm_fk'],$row['pos_pk']);
$filesOfPost = $fileDataForum->getFilesOfPost();
foreach ($filesOfPost as $attachment)
{
$size += $attachment['size'];
//$count++;
}
unset($fileDataForum);
unset($filesOfPost);
}
return $size;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilObjForumAccess::getLastPost (   $a_obj_id)
static

Count number of new posts.

Parameters
int$a_user_id

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

References $ilDB, $ilSetting, $res, and $row.

Referenced by ilObjForumListGUI\getProperties().

{
global $ilUser, $ilDB, $ilSetting;
$set = $ilDB->query("SELECT top_pk FROM frm_data ".
" WHERE top_frm_fk = ".$ilDB->quote($a_obj_id, "integer")
);
if ($rec = $ilDB->fetchAssoc($set))
{
$frm_id = $rec["top_pk"];
$ilDB->setLimit(1);
$res = $ilDB->queryf('
SELECT *
FROM frm_posts
WHERE pos_top_fk = %s
ORDER BY pos_date DESC',
array('integer'), array($frm_id));
$row = $ilDB->fetchAssoc($res);
if ($row["pos_pk"] > 0)
{
return $row;
}
}
return false;
}

+ Here is the caller graph for this function:

static ilObjForumAccess::getNumberOfNewPostings (   $a_obj_id,
  $a_only_active = false 
)
static

Count number of new posts.

Parameters
int$a_user_id

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

References $ilDB, $ilSetting, $res, and DB_FETCHMODE_ASSOC.

Referenced by ilObjForumListGUI\getProperties().

{
global $ilUser, $ilDB, $ilSetting;
$set = $ilDB->query("SELECT top_pk FROM frm_data ".
" WHERE top_frm_fk = ".$ilDB->quote($a_obj_id, "integer")
);
if ($rec = $ilDB->fetchAssoc($set))
{
$act_clause = $a_only_active
? " AND (pos_status = ".$ilDB->quote(1, "integer").
" OR pos_usr_id = ".$ilDB->quote($ilUser->getId(), "integer").") "
: "";
$frm_id = $rec["top_pk"];
$new_deadline = date('Y-m-d H:i:s',
time() - 60 * 60 * 24 * 7 * ($ilSetting->get('frm_store_new')));
$res = $ilDB->queryf('
SELECT COUNT(pos_pk) cnt
FROM frm_posts
LEFT JOIN frm_user_read ON (post_id = pos_pk AND frm_user_read.usr_id = %s)
LEFT JOIN frm_thread_access ON (pos_thr_fk = frm_thread_access.thread_id AND frm_thread_access.usr_id = %s)
WHERE pos_top_fk = %s
AND ((pos_date > frm_thread_access.access_old_ts OR pos_update > frm_thread_access.access_old_ts)
OR (frm_thread_access.access_old IS NULL AND (pos_date > %s OR pos_update > %s)))
AND pos_usr_id != %s
AND frm_user_read.usr_id IS NULL'.$act_clause,
array('integer','integer', 'integer', 'timestamp','timestamp','integer'),
array($ilUser->getId(), $ilUser->getId(), $frm_id, $new_deadline,$new_deadline, $ilUser->getId())
);
$rec = $res->fetchRow(DB_FETCHMODE_ASSOC);
return (int) $rec['cnt'];
}
return 0;
}

+ Here is the caller graph for this function:

static ilObjForumAccess::getNumberOfPostings (   $a_obj_id,
  $a_only_active = false 
)
static

Get number of postings.

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

References $ilDB, and $res.

Referenced by ilObjForumListGUI\getProperties().

{
global $ilDB, $ilUser;
$set = $ilDB->query("SELECT top_pk FROM frm_data ".
" WHERE top_frm_fk = ".$ilDB->quote($a_obj_id, "integer")
);
if ($rec = $ilDB->fetchAssoc($set))
{
$act_clause = $a_only_active
? " AND (pos_status = ".$ilDB->quote(1, "integer").
" OR pos_usr_id = ".$ilDB->quote($ilUser->getId(), "integer").") "
: "";
$frm_id = $rec["top_pk"];
$res = $ilDB->queryf("SELECT COUNT(*) cnt
FROM frm_posts JOIN frm_threads ON (frm_posts.pos_thr_fk = frm_threads.thr_pk)
WHERE frm_threads.thr_top_fk = %s".
$act_clause,
array('integer'), array($frm_id));
$rec = $ilDB->fetchAssoc($res);
return $rec["cnt"];
}
return 0;
}

+ Here is the caller graph for this function:

static ilObjForumAccess::getNumberOfReadPostings (   $a_obj_id,
  $a_only_active = false 
)
static

Get number of read posts.

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

References $ilDB, and $res.

Referenced by ilObjForumListGUI\getProperties().

{
global $ilDB, $ilUser;
$set = $ilDB->query("SELECT top_pk FROM frm_data ".
" WHERE top_frm_fk = ".$ilDB->quote($a_obj_id, "integer")
);
if ($rec = $ilDB->fetchAssoc($set))
{
$act_clause = $a_only_active
? " AND (pos_status = ".$ilDB->quote(1, "integer").
" OR pos_usr_id = ".$ilDB->quote($ilUser->getId(), "integer").") "
: "";
$frm_id = $rec["top_pk"];
$res = $ilDB->queryf("SELECT COUNT(*) cnt
FROM frm_user_read INNER JOIN frm_posts ON (frm_user_read.post_id = frm_posts.pos_pk)
WHERE frm_user_read.usr_id = %s AND frm_posts.pos_top_fk = %s".
$act_clause,
array('integer', 'integer'), array($ilUser->getId(), $frm_id));
$rec = $ilDB->fetchAssoc($res);
return $rec["cnt"];
}
return 0;
}

+ Here is the caller graph for this function:

ilObjForumAccess::prepareMessageForLists (   $text)

Prepare message for container view.

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

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

Referenced by ilObjForumListGUI\getProperties().

{
// remove quotings
$text = strip_tags($text);
$text = preg_replace('/\[(\/)?quote\]/', '', $text);
if(ilStr::strLen($text) > 40)
{
$text = ilStr::subStr($text, 0, 37).'...';
}
return $text;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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