ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilObjForum Class Reference

Class ilObjForum. More...

+ Inheritance diagram for ilObjForum:
+ Collaboration diagram for ilObjForum:

Public Member Functions

 ilObjForum ($a_id=0, $a_call_by_reference=true)
 Constructor public.
 read ($a_force_db=false)
 read object data from db into object
 getDiskUsage ()
 Gets the disk usage of the object in bytes.
 _lookupThreadSubject ($a_thread_id)
 getCountUnread ($a_usr_id, $a_thread_id=0)
 _getCountUnread ($a_frm_id, $a_usr_id, $a_thread_id=0)
 markThreadRead ($a_usr_id, $a_thread_id)
 markAllThreadsRead ($a_usr_id)
 markPostRead ($a_usr_id, $a_thread_id, $a_post_id)
 markPostUnread ($a_user_id, $a_post_id)
 isRead ($a_usr_id, $a_post_id)
 getCountNew ($a_usr_id, $a_thread_id=0)
 __getCountNew ($a_usr_id, $a_thread_id=0)
 isNew ($a_usr_id, $a_thread_id, $a_post_id)
 updateLastAccess ($a_usr_id, $a_thread_id)
 _updateOldAccess ($a_usr_id)
 _deleteUser ($a_usr_id)
 _deleteReadEntries ($a_post_id)
 _deleteAccessEntries ($a_thread_id)
 update ()
 update forum data
 cloneObject ($a_target_id, $a_copy_id=0)
 Clone Object.
 cloneAutoGeneratedRoles ($new_obj)
 Clone forum moderator role.
 delete ()
 Delete forum and all related data.
 initDefaultRoles ()
 init default roles settings public
 createSettings ()
 __getLastThreadAccess ($a_usr_id, $a_thread_id)
 isThreadNotificationEnabled ($user_id, $thread_id)
 Check whether a user's notification about new posts in a thread is enabled (result > 0) or not (result == 0)
 saveData ($a_roles=array())
- Public Member Functions inherited from ilObject
 ilObject ($a_id=0, $a_reference=true)
 Constructor public.
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not)
 getId ()
 get object id public
 setId ($a_id)
 set object id public
 setRefId ($a_id)
 set reference id public
 getRefId ()
 get reference id public
 getType ()
 get object type public
 setType ($a_type)
 set object type public
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions
 getTitle ()
 get object title public
 getUntranslatedTitle ()
 get untranslated object title public
 setTitle ($a_title)
 set object title
 getDescription ()
 get object description
 setDescription ($a_desc)
 set object description
 getLongDescription ()
 get object long description (stored in object_description)
 getImportId ()
 get import id
 setImportId ($a_import_id)
 set import id
 _lookupObjIdByImportId ($a_import_id)
 getOwner ()
 get object owner
 getOwnerName ()
 _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id
 setOwner ($a_owner)
 set object owner
 getCreateDate ()
 get create date public
 getLastUpdateDate ()
 get last update date public
 setObjDataRecord ($a_record)
 set object_data record (note: this method should only be called from the ilObjectFactory class)
 create ()
 create
 MDUpdateListener ($a_element)
 Meta data update listener.
 createMetaData ()
 create meta data entry
 updateMetaData ()
 update meta data entry
 deleteMetaData ()
 delete meta data entry
 updateOwner ()
 update owner of object in db
 _getIdForImportId ($a_import_id)
 get current object id for import id (static)
 _lookupOwner ($a_id)
 lookup object owner
 _lookupDescription ($a_id)
 lookup object description
 _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update
 _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects.
 _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree
 _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes
 _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes
 _writeTitle ($a_obj_id, $a_title)
 write title to db (static)
 _writeDescription ($a_obj_id, $a_desc)
 write description to db (static)
 _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static)
 _isInTrash ($a_ref_id)
 checks wether object is in trash
 _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash
 _lookupObjectId ($a_ref_id)
 lookup object id
 _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!?
 setPermissions ($a_parent_ref)
 set permissions of object
 createReference ()
 creates reference for object
 countReferences ()
 count references of object
 createRoleFolder ()
 creates a local role folder
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event passed, each object may decide how it reacts.
 setRegisterMode ($a_bool)
 isUserRegistered ($a_user_id=0)
 requireRegistration ()
 getXMLZip ()
 getHTMLDirectory ()
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container.
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies.
 cloneMetaData ($target_obj)
 Copy meta data.

Static Public Member Functions

static _lookupModeratorRole ($a_ref_id)
 Lookup moderator role.
- Static Public Member Functions inherited from ilObject
static _getAllReferences ($a_id)
 get all reference ids of object
static _lookupTitle ($a_id)
 lookup object title
static _getIdsForTitle ($title, $type= '', $partialmatch=false)
static _lookupObjId ($a_id)
static _lookupType ($a_id, $a_reference=false)
 lookup object type
 _exists ($a_id, $a_reference=false)
 checks if an object exists in object_data
static _getObjectsByType ($a_obj_type="", $a_owner="")
 Get objects by type.
static _prepareCloneSelection ($a_ref_ids, $new_type)
 Prepare copy wizard object selection.
static _getIcon ($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 Get icon for repository item.
static collectDeletionDependencies (&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth=0)
 Collect deletion dependencies.
static getDeletionDependencies ($a_obj_id)
 Get deletion dependencies.

Data Fields

 $Forum
- Data Fields inherited from ilObject
const TITLE_LENGTH = 128
 max length of object title
 $ilias
 $lng
 $id
 $ref_id
 $type
 $title
 $untranslatedTitle
 $desc
 $long_desc
 $owner
 $create_date
 $last_update
 $import_id
 $register = false
 $referenced
 $objectList
 $max_title
 $max_desc
 $add_dots
 $obj_data_record
 object_data record

Private Attributes

 $objProperties = null

Detailed Description

Class ilObjForum.

Author
Wolfgang Merkens wmerk.nosp@m.ens@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
Id:
class.ilObjForum.php 29876 2011-07-15 09:08:17Z nkrzywon

Definition at line 40 of file class.ilObjForum.php.

Member Function Documentation

ilObjForum::__getCountNew (   $a_usr_id,
  $a_thread_id = 0 
)

Definition at line 324 of file class.ilObjForum.php.

References $ilDB, $res, $row, __getLastThreadAccess(), DB_FETCHMODE_OBJECT, and isRead().

Referenced by getCountNew().

{
global $ilDB;
$counter = 0;
$timest = $this->__getLastThreadAccess($a_usr_id,$a_thread_id);
// CHECK FOR NEW
$res = $ilDB->queryf('
SELECT pos_pk FROM frm_posts
WHERE pos_thr_fk = %s
AND ( pos_date > %s OR pos_update > %s)
AND pos_usr_id != %s',
array('integer', 'timestamp', 'timestamp', 'integer'),
array($a_thread_id, date('Y-m-d H:i:s',$timest), date('Y-m-d H:i:s',$timest), $a_usr_id));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
if(!$this->isRead($a_usr_id,$row->pos_pk))
{
++$counter;
}
}
return $counter;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjForum::__getLastThreadAccess (   $a_usr_id,
  $a_thread_id 
)

Definition at line 792 of file class.ilObjForum.php.

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

Referenced by __getCountNew(), and isNew().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM frm_thread_access
WHERE thread_id = %s
AND usr_id = %s',
array('integer', 'integer'),
array($a_thread_id, $a_usr_id));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$last_access = $row->access_old;
}
if(!$last_access)
{
// Set last access according to administration setting
$last_access = NEW_DEADLINE;
}
return $last_access;
}

+ Here is the caller graph for this function:

ilObjForum::_deleteAccessEntries (   $a_thread_id)

Definition at line 484 of file class.ilObjForum.php.

References $ilDB.

Referenced by ilForum\deletePost().

{
global $ilDB;
$statement = $ilDB->manipulateF('
DELETE FROM frm_thread_access WHERE thread_id = %s',
array('integer'), array($a_thread_id));
return true;
}

+ Here is the caller graph for this function:

ilObjForum::_deleteReadEntries (   $a_post_id)

Definition at line 473 of file class.ilObjForum.php.

References $ilDB.

Referenced by ilForum\deletePost().

{
global $ilDB;
$statement = $ilDB->manipulateF('
DELETE FROM frm_user_read WHERE post_id = %s',
array('integer'), array($a_post_id));
return true;
}

+ Here is the caller graph for this function:

ilObjForum::_deleteUser (   $a_usr_id)

Definition at line 452 of file class.ilObjForum.php.

References $data, $ilDB, and $res.

Referenced by ilObjUser\delete().

{
global $ilDB;
$data = array($a_usr_id);
$res = $ilDB->manipulateF('
DELETE FROM frm_user_read WHERE usr_id = %s',
array('integer'), $data
);
$res = $ilDB->manipulateF('
DELETE FROM frm_thread_access WHERE usr_id = %s',
array('integer'), $data
);
return true;
}

+ Here is the caller graph for this function:

ilObjForum::_getCountUnread (   $a_frm_id,
  $a_usr_id,
  $a_thread_id = 0 
)

Definition at line 117 of file class.ilObjForum.php.

References $ilBench, $ilDB, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by getCountUnread().

{
global $ilBench, $ilDB;
$ilBench->start("Forum",'getCountRead');
if(!$a_thread_id)
{
// Get topic_id
$res = $ilDB->queryf('
SELECT top_pk FROM frm_data WHERE top_frm_fk = %s',
array('integer'), array($a_frm_id));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$topic_id = $row->top_pk;
}
// Get number of posts
$res = $ilDB->queryf('
SELECT COUNT(pos_pk) num_posts FROM frm_posts
WHERE pos_top_fk = %s',
array('integer'), array($topic_id));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$num_posts = $row->num_posts;
}
$res = $ilDB->queryf('
SELECT COUNT(post_id) count_read FROM frm_user_read
WHERE obj_id = %s
AND usr_id = %s',
array('integer', 'integer'), array($a_frm_id, $a_usr_id));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$count_read = $row->count_read;
}
$unread = $num_posts - $count_read;
$ilBench->stop("Forum",'getCountRead');
return $unread > 0 ? $unread : 0;
}
else
{
$res = $ilDB->queryf('
SELECT COUNT(pos_pk) num_posts FROM frm_posts
WHERE pos_thr_fk = %s',
array('integer'), array($a_thread_id));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$num_posts = $row->num_posts;
}
$res = $ilDB->queryf('
SELECT COUNT(post_id) count_read FROM frm_user_read
WHERE obj_id = %s
AND usr_id = %s
AND thread_id = %s',
array('integer', 'integer', 'integer'), array($a_frm_id, $a_frm_id, $a_thread_id));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$count_read = $row->count_read;
}
$unread = $num_posts - $count_read;
$ilBench->stop("Forum",'getCountRead');
return $unread > 0 ? $unread : 0;
}
$ilBench->stop("Forum",'getCountRead');
return false;
}

+ Here is the caller graph for this function:

static ilObjForum::_lookupModeratorRole (   $a_ref_id)
static

Lookup moderator role.

public

Parameters
intref_id of forum

Definition at line 759 of file class.ilObjForum.php.

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

Referenced by cloneAutoGeneratedRoles(), and ilObjForumGUI\saveObject().

{
global $ilDB;
$mod_title = 'il_frm_moderator_'.$a_ref_id;
$res = $ilDB->queryf('
SELECT * FROM object_data WHERE title = %s',
array('text'), array($mod_title));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return $row->obj_id;
}
return 0;
}

+ Here is the caller graph for this function:

ilObjForum::_lookupThreadSubject (   $a_thread_id)

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

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

Referenced by ilShopResultPresentationGUI\__appendChildLinks(), and ilObjForumSubItemListGUI\getHTML().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT thr_subject FROM frm_threads WHERE thr_pk = %s',
array('integer'), array($a_thread_id));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return $row->thr_subject;
}
return '';
}

+ Here is the caller graph for this function:

ilObjForum::_updateOldAccess (   $a_usr_id)

Definition at line 415 of file class.ilObjForum.php.

References $ilDB, ilObject\$ilias, and $res.

Referenced by ilStartUpGUI\showLogin().

{
global $ilDB, $ilias;
$res = $ilDB->manipulateF('
UPDATE frm_thread_access
SET access_old = access_last
WHERE usr_id = %s',
array('integer'), array($a_usr_id));
// set access_old_ts value
$set = $ilDB->query("SELECT * FROM frm_thread_access ".
" WHERE usr_id = ".$ilDB->quote($a_usr_id, "integer")
);
while ($rec = $ilDB->fetchAssoc($set))
{
$ilDB->manipulate("UPDATE frm_thread_access SET ".
" access_old_ts = ".$ilDB->quote(date('Y-m-d H:i:s', $rec["access_old"]), "timestamp").
" WHERE usr_id = ".$ilDB->quote($rec["usr_id"], "integer").
" AND obj_id = ".$ilDB->quote($rec["obj_id"], "integer").
" AND thread_id = ".$ilDB->quote($rec["thread_id"], "integer")
);
}
// Delete old entries
$new_deadline = time() - 60 * 60 * 24 * 7 * ($ilias->getSetting('frm_store_new') ?
$ilias->getSetting('frm_store_new') :
8);
$res = $ilDB->manipulateF('
DELETE FROM frm_thread_access WHERE access_last < %s',
array('integer'), array($new_deadline));
return true;
}

+ Here is the caller graph for this function:

ilObjForum::cloneAutoGeneratedRoles (   $new_obj)

Clone forum moderator role.

public

Parameters
objectforum object

Definition at line 617 of file class.ilObjForum.php.

References $ilLog, _lookupModeratorRole(), and ilObject\getRefId().

Referenced by cloneObject().

{
global $ilLog,$rbacadmin,$rbacreview;
$new_moderator = ilObjForum::_lookupModeratorRole($new_obj->getRefId());
$source_rolf = $rbacreview->getRoleFolderIdOfObject($this->getRefId());
$target_rolf = $rbacreview->getRoleFolderIdOfObject($new_obj->getRefId());
if(!$moderator || !$new_moderator || !$source_rolf || !$target_rolf)
{
$ilLog->write(__METHOD__.' : Error cloning auto generated role: il_frm_moderator');
}
$rbacadmin->copyRolePermissions($moderator,$source_rolf,$target_rolf,$new_moderator,true);
$ilLog->write(__METHOD__.' : Finished copying of role il_frm_moderator.');
include_once './Modules/Forum/classes/class.ilForumModerators.php';
$obj_mods = new ilForumModerators($this->getRefId());
$old_mods = array();
$old_mods = $obj_mods->getCurrentModerators();
foreach($old_mods as $user_id)
{
$rbacadmin->assignUser($new_moderator, $user_id);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjForum::cloneObject (   $a_target_id,
  $a_copy_id = 0 
)

Clone Object.

public

Parameters
intsource_id int copy id

Reimplemented from ilObject.

Definition at line 536 of file class.ilObjForum.php.

References $ilDB, ilCopyWizardOptions\_getInstance(), ilForum\_lookupPostMessage(), cloneAutoGeneratedRoles(), ilObject\getId(), ilForumProperties\getInstance(), and ilObject\getRefId().

{
global $ilDB,$ilUser;
$new_obj = parent::cloneObject($a_target_id, $a_copy_id);
$this->cloneAutoGeneratedRoles($new_obj);
ilForumProperties::getInstance($this->getId())->copy($new_obj->getId());
$this->Forum->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($this->getId()));
$topData = $this->Forum->getOneTopic();
$nextId = $ilDB->nextId('frm_data');
$statement = $ilDB->insert('frm_data', array(
'top_pk' => array('integer', $nextId),
'top_frm_fk' => array('integer', $new_obj->getId()),
'top_name' => array('text', $topData['top_name']),
'top_description' => array('text', $topData['top_description']),
'top_num_posts' => array('integer', $topData['top_num_posts']),
'top_num_threads' => array('integer', $topData['top_num_threads']),
'top_last_post' => array('text', $topData['top_last_post']),
'top_mods' => array('integer', !is_numeric($topData['top_mods']) ? 0 : $topData['top_mods']),
'top_date' => array('timestamp', $topData['top_date']),
'visits' => array('integer', $topData['visits']),
'top_update' => array('timestamp', $topData['top_update']),
'update_user' => array('integer', $topData['update_user']),
'top_usr_id' => array('integer', $topData['top_usr_id'])
));
// read options
include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
$options = $cwo->getOptions($this->getRefId());
$options['threads'] = $this->Forum->_getThreads($this->getId());
// Generate starting threads
include_once('Modules/Forum/classes/class.ilFileDataForum.php');
$new_frm = $new_obj->Forum;
$new_frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($new_obj->getId()));
$new_frm->setForumId($new_obj->getId());
$new_frm->setForumRefId($new_obj->getRefId());
$new_topic = $new_frm->getOneTopic();
foreach($options['threads'] as $thread_id=>$thread_subject)
{
$this->Forum->setMDB2WhereCondition('thr_pk = %s ', array('integer'), array($thread_id));
$old_thread = $this->Forum->getOneThread();
$old_post_id = $this->Forum->getFirstPostByThread($old_thread['thr_pk']);
$old_post = $this->Forum->getOnePost($old_post_id);
// Now create new thread and first post
$new_post = $new_frm->generateThread($new_topic['top_pk'],
$old_thread['thr_usr_id'],
$old_thread['thr_subject'],
$old_post['notify'],
0,
$old_thread['thr_usr_alias'],
$old_thread['thr_date']);
// Copy attachments
$old_forum_files = new ilFileDataForum($this->getId(),$old_post_id);
$old_forum_files->ilClone($new_obj->getId(),$new_post);
}
return $new_obj;
}

+ Here is the call graph for this function:

ilObjForum::createSettings ( )

Definition at line 777 of file class.ilObjForum.php.

References $_GET, $ilDB, ilNewsItem\_getDefaultVisibilityForRefId(), ilBlockSetting\_write(), and ilObject\getId().

{
global $ilDB;
// news settings (public notifications yes/no)
include_once("./Services/News/classes/class.ilNewsItem.php");
$default_visibility = ilNewsItem::_getDefaultVisibilityForRefId($_GET["ref_id"]);
if ($default_visibility == "public")
{
ilBlockSetting::_write("news", "public_notifications", 1, 0, $this->getId());
}
return true;
}

+ Here is the call graph for this function:

ilObjForum::delete ( )

Delete forum and all related data.

public

Returns
boolean true if all object data were removed; false if only a references were removed

Reimplemented from ilObject.

Definition at line 651 of file class.ilObjForum.php.

References $data, $ilDB, and ilObject\getId().

{
global $ilDB;
// always call parent delete function first!!
if (!parent::delete())
{
return false;
}
// delete attachments
$tmp_file_obj =& new ilFileDataForum($this->getId());
$tmp_file_obj->delete();
unset($tmp_file_obj);
$this->Forum->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($this->getId()));
$topData = $this->Forum->getOneTopic();
$threads = $this->Forum->getAllThreads($topData['top_pk']);
foreach ($threads as $thread)
{
$data = array($thread->getId());
// delete tree
$statement = $ilDB->manipulateF('
DELETE FROM frm_posts_tree WHERE thr_fk = %s',
array('integer'), $data);
// delete posts
$statement = $ilDB->manipulateF('
DELETE FROM frm_posts WHERE pos_thr_fk = %s',
array('integer'), $data);
// delete threads
$statement = $ilDB->manipulateF('
DELETE FROM frm_threads WHERE thr_pk = %s',
array('integer'), $data);
}
$data = array($this->getId());
// delete forum
$statement = $ilDB->manipulateF('
DELETE FROM frm_data WHERE top_frm_fk = %s',
array('integer'), $data);
// delete settings
$statement = $ilDB->manipulateF('
DELETE FROM frm_settings WHERE obj_id = %s',
array('integer'), $data);
// delete read infos
$statement = $ilDB->manipulateF('
DELETE FROM frm_user_read WHERE obj_id = %s',
array('integer'), $data);
// delete thread access entries
$statement = $ilDB->manipulateF('
DELETE FROM frm_thread_access WHERE obj_id = %s',
array('integer'), $data);
return true;
}

+ Here is the call graph for this function:

ilObjForum::getCountNew (   $a_usr_id,
  $a_thread_id = 0 
)

Definition at line 290 of file class.ilObjForum.php.

References $ilBench, $ilDB, $res, $row, __getCountNew(), DB_FETCHMODE_OBJECT, and ilObject\getId().

{
global $ilBench, $ilDB;
$ilBench->start('Forum','getCountNew');
if($a_thread_id)
{
$num = $this->__getCountNew($a_usr_id,$a_thread_id);
$ilBench->stop('Forum','getCountNew');
return $num;
}
else
{
$counter = 0;
// Get threads
$res = $ilDB->queryf('
SELECT DISTINCT(pos_thr_fk) FROM frm_posts,frm_data
WHERE top_pk = pos_top_fk
AND top_frm_fk = %s',
array('integer'), array($this->getId()));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$counter += $this->__getCountNew($a_usr_id,$row->pos_thr_fk);
}
$ilBench->stop('Forum','getCountNew');
return $counter;
}
return 0;
}

+ Here is the call graph for this function:

ilObjForum::getCountUnread (   $a_usr_id,
  $a_thread_id = 0 
)

Definition at line 112 of file class.ilObjForum.php.

References _getCountUnread(), and ilObject\getId().

{
return $this->_getCountUnread($this->getId(),$a_usr_id,$a_thread_id);
}

+ Here is the call graph for this function:

ilObjForum::getDiskUsage ( )

Gets the disk usage of the object in bytes.

public

Returns
integer the disk usage in bytes

Reimplemented from ilObject.

Definition at line 90 of file class.ilObjForum.php.

References ilObjForumAccess\_lookupDiskUsage().

{
require_once("./Modules/File/classes/class.ilObjFileAccess.php");
}

+ Here is the call graph for this function:

ilObjForum::ilObjForum (   $a_id = 0,
  $a_call_by_reference = true 
)

Constructor public.

Parameters
integerreference_id or object_id
booleantreat the id as reference_id (true) or object_id (false)

Definition at line 57 of file class.ilObjForum.php.

References ilObject\$ilias, and ilObject\ilObject().

{
global $ilias;
/*
* this constant is used for the information if a single post is marked as new
* All threads/posts created before this date are never marked as new
* Default is 8 weeks
*
*/
$new_deadline = time() - 60 * 60 * 24 * 7 * ($ilias->getSetting('frm_store_new') ?
$ilias->getSetting('frm_store_new') :
8);
define('NEW_DEADLINE',$new_deadline);
$this->type = "frm";
$this->ilObject($a_id,$a_call_by_reference);
// TODO: needs to rewrite scripts that are using Forum outside this class
$this->Forum =& new ilForum();
}

+ Here is the call graph for this function:

ilObjForum::initDefaultRoles ( )

init default roles settings public

Returns
array object IDs of created local roles.

Reimplemented from ilObject.

Definition at line 721 of file class.ilObjForum.php.

References $ilDB, $res, ilObject\createRoleFolder(), DB_FETCHMODE_OBJECT, ilObject\getId(), and ilObject\getRefId().

{
global $rbacadmin,$rbacreview,$ilDB;
// Create a local role folder
$rolf_obj = $this->createRoleFolder();
// CREATE Moderator role
$role_obj = $rolf_obj->createRole("il_frm_moderator_".$this->getRefId(),"Moderator of forum obj_no.".$this->getId());
$roles[] = $role_obj->getId();
// SET PERMISSION TEMPLATE OF NEW LOCAL ADMIN ROLE
$statement = $ilDB->queryf('
SELECT obj_id FROM object_data
WHERE type = %s
AND title = %s',
array('text', 'text'),
array('rolt', 'il_frm_moderator'));
$res = $statement->fetchRow(DB_FETCHMODE_OBJECT);
$rbacadmin->copyRoleTemplatePermissions($res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
// SET OBJECT PERMISSIONS OF COURSE OBJECT
$ops = $rbacreview->getOperationsOfRole($role_obj->getId(),"frm",$rolf_obj->getRefId());
$rbacadmin->grantPermission($role_obj->getId(),$ops,$this->getRefId());
return $roles ? $roles : array();
}

+ Here is the call graph for this function:

ilObjForum::isNew (   $a_usr_id,
  $a_thread_id,
  $a_post_id 
)

Definition at line 351 of file class.ilObjForum.php.

References $ilDB, $res, __getLastThreadAccess(), and isRead().

{
global $ilDB;
if($this->isRead($a_usr_id,$a_post_id))
{
return false;
}
$timest = $this->__getLastThreadAccess($a_usr_id,$a_thread_id);
$res = $ilDB->queryf('
SELECT * FROM frm_posts
WHERE pos_pk = %s
AND (pos_date > %s OR pos_update > %s)
AND pos_usr_id != %s',
array('integer', 'timestamp', 'timestamp', 'integer'),
array($a_post_id, date('Y-m-d H:i:s',$timest), date('Y-m-d H:i:s',$timest), $a_usr_id));
return $res->numRows() ? true : false;
}

+ Here is the call graph for this function:

ilObjForum::isRead (   $a_usr_id,
  $a_post_id 
)

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

References $ilDB, and $res.

Referenced by __getCountNew(), and isNew().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM frm_user_read
WHERE usr_id = %s
AND post_id = %s',
array('integer', 'integer'),
array($a_usr_id, $a_post_id));
return $res->numRows() ? true : false;
}

+ Here is the caller graph for this function:

ilObjForum::isThreadNotificationEnabled (   $user_id,
  $thread_id 
)

Check whether a user's notification about new posts in a thread is enabled (result > 0) or not (result == 0)

Parameters
integeruser_id A user's ID
integerthread_id ID of the thread
Returns
integer Result private

Definition at line 822 of file class.ilObjForum.php.

References $ilDB, and $result.

{
global $ilDB;
$result = $ilDB->queryf("SELECT COUNT(*) cnt FROM frm_notification WHERE user_id = %s AND thread_id = %s",
array("integer", "integer"), array($user_id, $thread_id));
while($record = $ilDB->fetchAssoc($result))
{
return (bool)$record['cnt'];
}
return false;
}
ilObjForum::markAllThreadsRead (   $a_usr_id)

Definition at line 211 of file class.ilObjForum.php.

References $ilDB, $res, $row, DB_FETCHMODE_OBJECT, ilObject\getId(), and markThreadRead().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM frm_data, frm_threads
WHERE top_frm_fk = %s
AND top_pk = thr_top_fk',
array('integer'), array($this->getId()));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->markThreadRead($a_usr_id,$row->thr_pk);
}
return true;
}

+ Here is the call graph for this function:

ilObjForum::markPostRead (   $a_usr_id,
  $a_thread_id,
  $a_post_id 
)

Definition at line 230 of file class.ilObjForum.php.

References $ilDB, $res, and ilObject\getId().

Referenced by markThreadRead().

{
global $ilDB;
// CHECK IF ENTRY EXISTS
$res = $ilDB->queryf('
SELECT * FROM frm_user_read
WHERE usr_id = %s
AND obj_id = %s
AND thread_id = %s
AND post_id = %s',
array('integer', 'integer', 'integer', 'integer'),
array($a_usr_id, $this->getId(), $a_thread_id, $a_post_id));
if($res->numRows())
{
return true;
}
$res = $ilDB->manipulateF('
INSERT INTO frm_user_read
( usr_id,
obj_id,
thread_id,
post_id
)
VALUES (%s,%s,%s,%s)',
array('integer', 'integer', 'integer', 'integer'),
array($a_usr_id, $this->getId(), $a_thread_id, $a_post_id));
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjForum::markPostUnread (   $a_user_id,
  $a_post_id 
)

Definition at line 263 of file class.ilObjForum.php.

References $ilDB, and $res.

{
global $ilDB;
$res = $ilDB->manipulateF('
DELETE FROM frm_user_read
WHERE usr_id = %s
AND post_id = %s',
array('integer','integer'),
array($a_user_id, $a_post_id));
}
ilObjForum::markThreadRead (   $a_usr_id,
  $a_thread_id 
)

Definition at line 195 of file class.ilObjForum.php.

References $ilDB, $res, $row, DB_FETCHMODE_OBJECT, and markPostRead().

Referenced by markAllThreadsRead().

{
global $ilDB;
// Get all post ids
$res = $ilDB->queryf('
SELECT * FROM frm_posts WHERE pos_thr_fk = %s',
array('integer'), array($a_thread_id));
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->markPostRead($a_usr_id,$a_thread_id,$row->pos_pk);
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjForum::read (   $a_force_db = false)

read object data from db into object

Parameters
booleanpublic

Reimplemented from ilObject.

Definition at line 79 of file class.ilObjForum.php.

{
parent::read($a_force_db);
}
ilObjForum::saveData (   $a_roles = array())

Definition at line 837 of file class.ilObjForum.php.

References $ilDB, ilObject\getDescription(), ilObject\getId(), ilObject\getTitle(), and ilUtil\now().

{
global $ilUser, $ilDB;
$nextId = $ilDB->nextId('frm_data');
$top_data = array(
'top_frm_fk' => $this->getId(),
'top_name' => $this->getTitle(),
'top_description' => $this->getDescription(),
'top_num_posts' => 0,
'top_num_threads' => 0,
'top_last_post' => NULL,
'top_mods' => !is_numeric($a_roles[0]) ? 0 : $a_roles[0],
'top_usr_id' => $ilUser->getId(),
'top_date' => ilUtil::now()
);
$statement = $ilDB->manipulateF('
INSERT INTO frm_data
(
top_pk,
top_frm_fk,
top_name,
top_description,
top_num_posts,
top_num_threads,
top_last_post,
top_mods,
top_date,
top_usr_id
)
VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)',
array('integer', 'integer', 'text', 'text', 'integer', 'integer', 'text', 'integer', 'timestamp', 'integer'),
array(
$nextId,
$top_data['top_frm_fk'],
$top_data['top_name'],
$top_data['top_description'],
$top_data['top_num_posts'],
$top_data['top_num_threads'],
$top_data['top_last_post'],
$top_data['top_mods'],
$top_data['top_date'],
$top_data['top_usr_id']
));
}

+ Here is the call graph for this function:

ilObjForum::update ( )

update forum data

public

Reimplemented from ilObject.

Definition at line 500 of file class.ilObjForum.php.

References $_SESSION, $ilDB, ilObject\getDescription(), ilObject\getId(), and ilObject\getTitle().

{
global $ilDB;
if (parent::update())
{
$statement = $ilDB->manipulateF('
UPDATE frm_data
SET top_name = %s,
top_description = %s,
top_update = %s,
update_user = %s
WHERE top_frm_fk =%s',
array('text', 'text', 'timestamp', 'integer', 'integer'),
array( $this->getTitle(),
$this->getDescription(),
date("Y-m-d H:i:s"),
(int)$_SESSION["AccountId"],
(int)$this->getId()
));
return true;
}
return false;
}

+ Here is the call graph for this function:

ilObjForum::updateLastAccess (   $a_usr_id,
  $a_thread_id 
)

Definition at line 372 of file class.ilObjForum.php.

References $ilDB, $res, and ilObject\getId().

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM frm_thread_access
WHERE usr_id = %s
AND obj_id = %s
AND thread_id = %s',
array('integer', 'integer', 'integer'),
array($a_usr_id, $this->getId(), $a_thread_id));
if($res->numRows())
{
$res = $ilDB->manipulateF('
UPDATE frm_thread_access
SET access_last = %s
WHERE usr_id = %s
AND obj_id = %s
AND thread_id = %s',
array('timestamp', 'integer', 'integer', 'integer'),
array(time(), $a_usr_id, $this->getId(), $a_thread_id));
}
else
{
$res = $ilDB->manipulateF('
INSERT INTO frm_thread_access
( access_last,
access_old,
usr_id,
obj_id,
thread_id)
VALUES (%s,%s,%s,%s,%s)',
array('integer', 'integer', 'integer', 'integer', 'integer'),
array(time(), '0', $a_usr_id, $this->getId(), $a_thread_id));
}
return true;
}

+ Here is the call graph for this function:

Field Documentation

ilObjForum::$Forum

Definition at line 47 of file class.ilObjForum.php.

ilObjForum::$objProperties = null
private

Definition at line 49 of file class.ilObjForum.php.


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