CMS  Version 3.9
ForumManager Class Reference

Public Member Functions

 ForumManager ()
 

Static Public Member Functions

static initializeUserProfileHandler ()
 
static registerUserProfileHandler ($handler)
 
static formatUserProfile ($u)
 
static defaultUserProfileHandler ($user)
 
static displayForum ($identifier, &$continue)
 
static enumerateFora ($items)
 
static setDefaults ()
 
static deleteUser ($user)
 Respond to fired event DeleteUser. More...
 
static deleteForum ($forum)
 When deleting a forum, we must delete topics, messages, attachments and site xrefs. More...
 
static deleteForumMessage ($message)
 
static upgradeComponent ($version)
 
static registerTaxonomyClasses ($classes)
 

Static Public Attributes

static $userProfileHandler = null
 

Detailed Description

Definition at line 40 of file forum_manager.inc.

Member Function Documentation

◆ defaultUserProfileHandler()

static ForumManager::defaultUserProfileHandler (   $user)
static

Definition at line 69 of file forum_manager.inc.

70  {
71  return $user->getFullName();
72  }
global $user

◆ deleteForum()

static ForumManager::deleteForum (   $forum)
static

When deleting a forum, we must delete topics, messages, attachments and site xrefs.

Parameters
unknown$forum
Exceptions
Exception

Definition at line 183 of file forum_manager.inc.

184  {
185  $forum_id = $forum->forum_id;
186 
187  $tx = new DataTransaction();
188 
189  try
190  {
191  $forum->joinTransaction($tx);
192 
193  $topic = new ForumTopic();
194  $topic->joinTransaction($tx);
195  $topic->delete("WHERE forum_id={$forum_id}");
196 
197  $messages = $forum->Messages();
198 
199  if(count($messages))
200  {
201  foreach($messages as $message)
202  {
203  $message->joinTransaction($tx);
205  }
206  }
207 
208  $xref = new ForumSiteXref();
209  $xref->joinTransaction($tx);
210  $xref->delete("WHERE forum_id={$forum_id}");
211 
212  $forum->delete();
213 
214  $tx->commit();
215  }
216  catch(Exception $e)
217  {
218  $tx->rollback();
219  throw $e;
220  }
221  }
$forum_id
Definition: forum_form.inc:39
static deleteForumMessage($message)
$messages
$message
Definition: mail_to.inc:49
$topic
Definition: topic_form.inc:42

◆ deleteForumMessage()

static ForumManager::deleteForumMessage (   $message)
static

Definition at line 223 of file forum_manager.inc.

224  {
225  $tx = new DataTransaction();
226 
227  try
228  {
229  $message->joinTransaction($tx);
230 
231  $attachments = $message->Attachments();
232  if(count($attachments))
233  {
234  $xref = new ForumMessageAttachmentXref();
235  $xref->joinTransaction($tx);
236 
237  foreach($attachments as $attachment)
238  {
239  $attachment->joinTransaction($tx);
240  $attachment->delete();
241  $xref->delete("WHERE attachment_id={$attachment->attachment_id}");
242  }
243  }
244  $message->delete();
245 
246  $tx->commit();
247  }
248  catch(Exception $e)
249  {
250  $tx->rollback();
251  throw $e;
252  }
253  }
if(! $attachment_id) $attachment
Definition: delete.inc:42

◆ deleteUser()

static ForumManager::deleteUser (   $user)
static

Respond to fired event DeleteUser.

Delete any records in this component that have dependencies on user object.

Parameters
obj$user- class SiteUser or custom user class

Definition at line 128 of file forum_manager.inc.

129  {
130  $pk = $user->getPrimaryKey();
131  $user_id = $user->$pk;
132 
133  trace("Component forum is deleting objects dependent on user_id {$user_id}", 3);
134 
135  $tx = new DataTransaction();
136 
137  try
138  {
139  $forums = Query::create(Forum, "WHERE owner_id=:owner_id")
140  ->bind(":owner_id", $user_id)
141  ->execute();
142 
143  if(count($forums))
144  {
145  foreach($forums as $forum)
146  {
147  $forum->joinTransaction($tx);
149  }
150  }
151 
152  $messages = Query::create(ForumMessage, "WHERE author_id=:author_id")
153  ->bind(":author_id", $user_id)
154  ->execute();
155 
156  if(count($messages))
157  {
158  foreach($messages as $message)
159  {
160  $message->joinTransaction($tx);
162  }
163  }
164 
165  $tx->commit();
166  }
167  catch(Exception $e)
168  {
169  $tx->rollback();
170  throw $e;
171  }
172 
173  return $user;
174  }
$user_id
Definition: forum.inc:42
static deleteForum($forum)
When deleting a forum, we must delete topics, messages, attachments and site xrefs.

◆ displayForum()

static ForumManager::displayForum (   $identifier,
$continue 
)
static

Definition at line 74 of file forum_manager.inc.

75  {
76  global $page_role;
77 
78  try
79  {
81  $page = ComponentPage::findByIdentifier("forum_details", "WHERE enabled=1");
82  $_GET["forum_id"] = $forum->forum_id;
83 
84  $pageView = new ComponentPageView($page, "{$page->template}.tpl");
85 
86  $page_role = $page->role;
87 
88  if (!checkRole($page->role))
89  {
91  redirect("/login");
92  }
93 
94  echo $pageView->drawView();
95 
96  $continue = false;
97  }
98  catch(DataNotFoundException $e)
99  {
100 
101  }
102 
103  return $identifier;
104  }
$page
Definition: help.inc:39
static findByIdentifier($identifier, $constraint="")
ComponentPageView generates the page content for a component page, substituting page fields,...
static findByIdentifier($identifier)
Definition: forum.inc:131
static storeRedirectPage()
Store the page from which a user has been redirected when prompted to login or create an account.
Definition: login.inc:493
$identifier
Definition: rss.inc:37

◆ enumerateFora()

static ForumManager::enumerateFora (   $items)
static

Definition at line 106 of file forum_manager.inc.

107  {
108  $pages = Query::create(Forum, "WHERE identifier IS NOT NULL AND identifier != '' ORDER BY title")->execute();
109 
110  $items["Discussion Forums"] = $pages;
111  return $items;
112  }
$pages
Definition: export.inc:38

◆ formatUserProfile()

static ForumManager::formatUserProfile (   $u)
static

Definition at line 63 of file forum_manager.inc.

64  {
66  return call_user_func_array(ForumManager::$userProfileHandler, array($u));
67  }
static initializeUserProfileHandler()
static $userProfileHandler

◆ ForumManager()

ForumManager::ForumManager ( )

Definition at line 42 of file forum_manager.inc.

43  {
44 
45  }

◆ initializeUserProfileHandler()

static ForumManager::initializeUserProfileHandler ( )
static

Definition at line 49 of file forum_manager.inc.

50  {
52  {
54  ComponentManager::fireEvent("RegisterForumUserProfileHandler");
55  }
56  }
static fireEvent($event, $parameter=null, $mustBeConsumed=false)
Fire an event to all subscribers as detailed in their manifests.
static defaultUserProfileHandler($user)

◆ registerTaxonomyClasses()

static ForumManager::registerTaxonomyClasses (   $classes)
static

Definition at line 261 of file forum_manager.inc.

262  {
263  $classes[] = Forum;
264  return $classes;
265  }

◆ registerUserProfileHandler()

static ForumManager::registerUserProfileHandler (   $handler)
static

Definition at line 58 of file forum_manager.inc.

59  {
61  }
$handler
Definition: event_form.inc:62

◆ setDefaults()

static ForumManager::setDefaults ( )
static

Definition at line 114 of file forum_manager.inc.

115  {
116  Settings::setDefaultValue("forum", "forum_list_items_per_page", 0, Number, "Number of items per page on the forum list (0 for no pagination)");
117  Settings::setDefaultValue("forum", "forum_topics_per_page", 0, Number, "Number of topics per page on the forum list (0 for no pagination)");
118  }
static setDefaultValue($component, $name, $value, $field_type="String", $annotation="", $category="", $options="", $weight=0)
Sets the default value of the given component setting.
Definition: settings.inc:174

◆ upgradeComponent()

static ForumManager::upgradeComponent (   $version)
static

Definition at line 255 of file forum_manager.inc.

256  {
257  $mgr = new ForumUpgradeManager();
258  $mgr->upgrade($version);
259  }

Member Data Documentation

◆ $userProfileHandler

ForumManager::$userProfileHandler = null
static

Definition at line 47 of file forum_manager.inc.


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