ILIAS  Release_3_10_x_branch Revision 61812
 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
 _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)
 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)
- 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)
 _getAllReferences ($a_id)
 get all reference ids of object
 _lookupTitle ($a_id)
 lookup object title
 _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.
 _lookupObjId ($a_id)
 _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree
 _resetDeletedDate ($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)
 _lookupType ($a_id, $a_reference=false)
 lookup object type
 _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 _getIdsForTitle ($title, $type= '')
 _exists ($a_id, $a_reference=false)
 checks if an object exists in object_data
static _getObjectsByType ($a_obj_type="")
 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)

Data Fields

 $Forum
- Data Fields inherited from ilObject
 $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 16857 2008-06-23 11:35:08Z mjansen

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

Member Function Documentation

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

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

References $res, __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
$query = "SELECT pos_pk FROM frm_posts ".
"WHERE pos_thr_fk = ".$ilDB->quote($a_thread_id)." ".
"AND ( pos_date > '".date('Y-m-d H:i:s',$timest)."' ".
"OR pos_update > '".date('Y-m-d H:i:s',$timest)."') ".
"AND pos_usr_id != ".$ilDB->quote($a_usr_id)."";
$res = $this->ilias->db->query($query);
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 688 of file class.ilObjForum.php.

References $res, and DB_FETCHMODE_OBJECT.

Referenced by __getCountNew(), and isNew().

{
global $ilDB;
$query = "SELECT * FROM frm_thread_access ".
"WHERE thread_id = ".$ilDB->quote( $a_thread_id )." ".
"AND usr_id = ".$ilDB->quote( $a_usr_id )."";
$res = $this->ilias->db->query($query);
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 426 of file class.ilObjForum.php.

Referenced by ilForum\deletePost().

{
global $ilDB;
$query = "DELETE FROM frm_thread_access ".
"WHERE thread_id = ".$ilDB->quote($a_thread_id)."";
$ilDB->query($query);
return true;
}

+ Here is the caller graph for this function:

ilObjForum::_deleteReadEntries (   $a_post_id)

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

Referenced by ilForum\deletePost().

{
global $ilDB;
$query = "DELETE FROM frm_user_read ".
"WHERE post_id = ".$ilDB->quote($a_post_id)."";
$ilDB->query($query);
return true;
}

+ Here is the caller graph for this function:

ilObjForum::_deleteUser (   $a_usr_id)

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

Referenced by ilObjUser\delete().

{
global $ilDB;
$query = "DELETE FROM frm_user_read ".
"WHERE usr_id = ".$ilDB->quote($a_usr_id)."";
$ilDB->query($query);
$query = "DELETE FROM frm_thread_access ".
"WHERE usr_id = ".$ilDB->quote($a_usr_id)."";
$ilDB->query($query);
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 104 of file class.ilObjForum.php.

References $ilBench, $res, and DB_FETCHMODE_OBJECT.

Referenced by getCountUnread().

{
global $ilBench, $ilDB;
$ilBench->start("Forum",'getCountRead');
if(!$a_thread_id)
{
// Get topic_id
$query = "SELECT top_pk FROM frm_data ".
"WHERE top_frm_fk = ".$ilDB->quote($a_frm_id)."";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$topic_id = $row->top_pk;
}
// Get number of posts
$query = "SELECT COUNT(pos_pk) as num_posts FROM frm_posts ".
"WHERE pos_top_fk = ".$ilDB->quote($topic_id)."";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$num_posts = $row->num_posts;
}
$query = "SELECT COUNT(post_id) count_read FROM frm_user_read ".
"WHERE obj_id = ".$ilDB->quote($a_frm_id)." ".
"AND usr_id = ".$ilDB->quote($a_usr_id)."";
$res = $ilDB->query($query);
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
{
$query = "SELECT COUNT(pos_pk) as num_posts FROM frm_posts ".
"WHERE pos_thr_fk = ".$ilDB->quote($a_thread_id)."";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$num_posts = $row->num_posts;
}
$query = "SELECT COUNT(post_id) as count_read FROM frm_user_read ".
"WHERE obj_id = ".$ilDB->quote($a_frm_id)." ".
"AND usr_id = ".$ilDB->quote($a_usr_id)." ".
"AND thread_id = ".$ilDB->quote($a_thread_id)."";
$res = $ilDB->query($query);
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 658 of file class.ilObjForum.php.

References $res, and DB_FETCHMODE_OBJECT.

Referenced by cloneAutoGeneratedRoles(), and cloneObject().

{
global $ilDB;
$mod_title = 'il_frm_moderator_'.$a_ref_id;
$query = "SELECT * FROM object_data WHERE title = ".$ilDB->quote($mod_title);
$res = $ilDB->query($query);
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 84 of file class.ilObjForum.php.

References $res, and DB_FETCHMODE_OBJECT.

Referenced by ilSearchResultPresentationGUI\__appendChildLinks().

{
global $ilDB;
$query = "SELECT thr_subject FROM frm_threads ".
"WHERE thr_pk = ".$ilDB->quote($a_thread_id)."";
$res = $ilDB->query($query);
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 372 of file class.ilObjForum.php.

References ilObject\$ilias.

Referenced by ilStartUpGUI\showLogin().

{
global $ilDB, $ilias;
$query = "UPDATE frm_thread_access ".
"SET access_old = access_last ".
"WHERE usr_id = ".$ilDB->quote($a_usr_id)."";
$ilDB->query($query);
// Delete old entries
$new_deadline = time() - 60 * 60 * 24 * 7 * ($ilias->getSetting('frm_store_new') ?
$ilias->getSetting('frm_store_new') :
8);
$query = "DELETE FROM frm_thread_access ".
"WHERE access_last < ".$ilDB->quote($new_deadline)."";
$ilDB->query($query);
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 544 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.');
}

+ 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 474 of file class.ilObjForum.php.

References ilCopyWizardOptions\_getInstance(), _lookupModeratorRole(), 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($a_target_id)->copy($new_obj->getId());
$this->Forum->setWhereCondition("top_frm_fk = ".$ilDB->quote($this->getId()));
$topData = $this->Forum->getOneTopic();
$query = "INSERT INTO frm_data ".
"VALUES('0',".$ilDB->quote($new_obj->getId()).",".$ilDB->quote($topData['top_name']).",".
$ilDB->quote($topData['top_description']).",'0','0','',".$ilDB->quote(ilObjForum::_lookupModeratorRole($new_obj->getRefId())).
",NOW(),'0',NOW(),'0',".
$ilDB->quote($ilUser->getId()).")";
$ilDB->query($query);
// read options
include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
$options = $cwo->getOptions($this->getRefId());
// Generate starting threads
if(!is_array($options['threads']))
{
return $new_obj;
}
include_once('Modules/Forum/classes/class.ilFileDataForum.php');
$new_frm = $new_obj->Forum;
$new_frm->setWhereCondition('top_frm_fk = '.$ilDB->quote($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)
{
$this->Forum->setWhereCondition('thr_pk = '.$ilDB->quote($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 673 of file class.ilObjForum.php.

References $_GET, 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 567 of file class.ilObjForum.php.

References 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->setWhereCondition('top_frm_fk = '.$ilDB->quote($this->getId()));
$topData = $this->Forum->getOneTopic();
$threads = $this->Forum->getAllThreads($topData['top_pk']);
foreach ($threads as $thread)
{
// delete tree
$query = "DELETE FROM frm_posts_tree WHERE thr_fk = ".$ilDB->quote($thread->getId())."";
$this->ilias->db->query($query);
// delete posts
$query = "DELETE FROM frm_posts WHERE pos_thr_fk = ".$ilDB->quote($thread->getId())."";
$this->ilias->db->query($query);
// delete threads
$query = "DELETE FROM frm_threads WHERE thr_pk = ".$ilDB->quote($thread->getId())."";
$this->ilias->db->query($query);
}
// delete forum
$query = "DELETE FROM frm_data WHERE top_frm_fk = ".$ilDB->quote($this->getId())."";
$this->ilias->db->query($query);
// delete settings
$query = "DELETE FROM frm_settings WHERE obj_id = ".$ilDB->quote($this->getId())."";
$this->ilias->db->query($query);
// delete read infos
$query = "DELETE FROM frm_user_read WHERE obj_id = ".$ilDB->quote($this->getId())."";
$this->ilias->db->query($query);
// delete thread access entries
$query = "DELETE FROM frm_thread_access WHERE obj_id = ".$ilDB->quote($this->getId())."";
$this->ilias->db->query($query);
return true;
}

+ Here is the call graph for this function:

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

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

References $ilBench, $res, __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
$query = "SELECT DISTINCT(pos_thr_fk) FROM frm_posts,frm_data ".
"WHERE top_pk = pos_top_fk ".
"AND top_frm_fk = ".$ilDB->quote($this->getId())." ";
$res = $this->ilias->db->query($query);
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 99 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::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 625 of file class.ilObjForum.php.

References $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
$query = "SELECT obj_id FROM object_data ".
" WHERE type='rolt' AND title='il_frm_moderator'";
$res = $this->ilias->db->getRow($query, 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 315 of file class.ilObjForum.php.

References $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);
$query = "SELECT * FROM frm_posts ".
"WHERE pos_pk = ".$ilDB->quote($a_post_id)." ".
"AND (pos_date > '".date('Y-m-d H:i:s',$timest)."' ".
"OR pos_update > '".date('Y-m-d H:i:s',$timest)."') ".
"AND pos_usr_id != ".$ilDB->quote($a_usr_id)."";
$res = $this->ilias->db->query($query);
return $res->numRows() ? true : false;
}

+ Here is the call graph for this function:

ilObjForum::isRead (   $a_usr_id,
  $a_post_id 
)

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

References $res.

Referenced by __getCountNew(), and isNew().

{
global $ilDB;
$query = "SELECT * FROM frm_user_read ".
"WHERE usr_id = ".$ilDB->quote($a_usr_id)." ".
"AND post_id = ".$ilDB->quote($a_post_id)."";
$res = $this->ilias->db->query($query);
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 717 of file class.ilObjForum.php.

References $result.

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

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

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

{
global $ilDB;
$query = "SELECT * FROM frm_data, frm_threads ".
"WHERE top_frm_fk = ".$ilDB->quote($this->getId())." ".
"AND top_pk = thr_top_fk ";
$res = $this->ilias->db->query($query);
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 211 of file class.ilObjForum.php.

References $res, and ilObject\getId().

Referenced by markThreadRead().

{
global $ilDB;
// CHECK IF ENTRY EXISTS
$query = "SELECT * FROM frm_user_read ".
"WHERE usr_id = ".$ilDB->quote($a_usr_id)." ".
"AND obj_id = ".$ilDB->quote($this->getId())." ".
"AND thread_id = ".$ilDB->quote($a_thread_id)." ".
"AND post_id = ".$ilDB->quote($a_post_id)."";
$res = $this->ilias->db->query($query);
if($res->numRows())
{
return true;
}
$query = "INSERT INTO frm_user_read ".
"SET usr_id = ".$ilDB->quote($a_usr_id).", ".
"obj_id = ".$ilDB->quote($this->getId()).", ".
"thread_id = ".$ilDB->quote($a_thread_id).", ".
"post_id = ".$ilDB->quote($a_post_id)."";
$this->ilias->db->query($query);
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjForum::markThreadRead (   $a_usr_id,
  $a_thread_id 
)

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

References $res, DB_FETCHMODE_OBJECT, and markPostRead().

Referenced by markAllThreadsRead().

{
global $ilDB;
// Get all post ids
$query = "SELECT * FROM frm_posts ".
"WHERE pos_thr_fk = ".$ilDB->quote($a_thread_id)."";
$res = $this->ilias->db->query($query);
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::update ( )

update forum data

public

Reimplemented from ilObject.

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

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

{
global $ilDB;
if (parent::update())
{
$query = "UPDATE frm_data ".
"SET ".
"top_name = ".$ilDB->quote($this->getTitle()).",".
"top_description = ".$ilDB->quote($this->getDescription()).",".
"top_update = '".date("Y-m-d H:i:s")."',".
"update_user = ".$ilDB->quote((int) $_SESSION["AccountId"])." ".
"WHERE top_frm_fk = ".$ilDB->quote((int) $this->getId())."";
$res = $this->ilias->db->query($query);
$this->ilias->db->query($query);
return true;
}
return false;
}

+ Here is the call graph for this function:

ilObjForum::updateLastAccess (   $a_usr_id,
  $a_thread_id 
)

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

References $res, and ilObject\getId().

{
global $ilDB;
$query = "SELECT * FROM frm_thread_access ".
"WHERE usr_id = ".$ilDB->quote($a_usr_id)." ".
"AND obj_id = ".$ilDB->quote($this->getId())." ".
"AND thread_id = ".$ilDB->quote($a_thread_id)."";
$res = $this->ilias->db->query($query);
if($res->numRows())
{
$query = "UPDATE frm_thread_access ".
"SET access_last = '".time()."' ".
"WHERE usr_id = ".$ilDB->quote($a_usr_id)." ".
"AND obj_id = ".$ilDB->quote($this->getId())." ".
"AND thread_id = ".$ilDB->quote($a_thread_id)."";
$this->ilias->db->query($query);
}
else
{
$query = "INSERT INTO frm_thread_access ".
"SET access_last = '".time()."', ".
"access_old = '0', ".
"usr_id = ".$ilDB->quote($a_usr_id).", ".
"obj_id = ".$ilDB->quote($this->getId()).", ".
"thread_id = ".$ilDB->quote($a_thread_id)."";
$this->ilias->db->query($query);
}
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: