CMS  Version 3.9
ForumTopicView Class Reference

Public Member Functions

 ForumTopicView ($topic, $id="topic_view")
 
 writeScript ()
 
 drawView ()
 
 formatAttachment ($icon, $attachment)
 

Public Attributes

 $forum
 
 $topic
 
 $subscriptionView
 

Detailed Description

Definition at line 39 of file topic_view.inc.

Member Function Documentation

◆ drawView()

ForumTopicView::drawView ( )

Definition at line 59 of file topic_view.inc.

60  {
61  global $user; // User Credentials from session
62 
63  $first = true;
64  $alt = false;
65 
66  $this->subscriptionView->drawLink();
67 
68  if (count($this->messages) > 0)
69  {
70  foreach($this->messages as $message)
71  {
72  $author = $message->Author();
73 
74  $userProfile = ForumManager::formatUserProfile($author);
75  $class = $alt ? "message alt" : "message"
76 ?>
77  <a name="message<?echo $message->message_id?>"></a>
78  <div id="message<?echo $message->message_id?>" class="<?echo $class?>">
79  <div class="title">
80 <?
81  if ($first && $user)
82  {
83 ?>
84  <button class="button" onclick="go('forum_message_form?forum_id=<?echo $this->topic->forum_id?>&topic_id=<? echo $this->topic->topic_id ?>&parent_id=<?echo $this->topic->message_id?>')"> Reply to this topic </button>
85 <?
86  }
87 ?>
88  <strong><?echo $message->title?></strong><br/>
89  <span class="small">Posted by <?echo $userProfile?> at <?echo $message->date_posted?></span>
90  </div>
91  <div class="message_content">
92  <?echo $message->message?>
93  </div>
94  <?
95  $attachments = $message->Attachments();
96  $userMgr = new UserManager();
97  $cl = $userMgr->getUserClass();
98  $u = new $cl;
99  $pk = $u->getPrimaryKey();
100 
101  if (count($attachments) > 0)
102  {
103  echo "<h4 style='margin-bottom: 4px'>Attachments</h4>";
104 
105  foreach($attachments as $attachment)
106  {
107  $icon = DocumentHandler::getDocIcon($attachment->filename);
108 
109  echo $this->formatAttachment($icon, $attachment);
110 
111  if ($author && $user && ($author->get($pk) == $user->get($pk)) || checkRole("admin,data"))
112  {
113 ?>
114 &nbsp;&nbsp;<a style="font-size: 10px" href="/action/forum/attachment_delete?forum_id=<?echo $this->topic->forum_id?>&message_id=<?echo $message->message_id?>&attachment_id=<?echo $attachment->attachment_id?>" onclick="return confirm('Are you sure you want to delete <?echo $attachment->filename?>?');">Delete this attachment</a>
115 <?
116  }
117 ?>
118  <br/>
119 <?
120  }
121  }
122 
123  $controls = array();
124  if ($user && $author->get($pk) == $user->get($pk) || checkRole("admin,data,moderator"))
125  {
126  $controls[] = "<a href=\"forum_message_form?forum_id={$this->topic->forum_id}&topic_id={$this->topic->topic_id}&message_id={$message->message_id}\">Edit</a>";
127  }
128 
129  if ($user && $author->get($pk) == $user->get($pk) || checkRole("admin,data,moderator"))
130  {
131  $controls[] = "<a href=\"/action/forum/message_delete?forum_id={$this->topic->forum_id}&topic_id={$this->topic->topic_id}&message_id={$message->message_id}\" onclick=\"return confirm('Are you sure you want to delete this message?');\">Delete</a>";
132  }
133 
134  if ($user)
135  {
136  $controls[] = "<a href=\"forum_message_form?forum_id={$this->topic->forum_id}&topic_id={$this->topic->topic_id}&parent_id={$message->message_id}\">Reply</a>";
137  }
138 
139 ?>
140  <div class="message_controls"><? echo implode("&nbsp;|&nbsp;", $controls);?></div>
141  </div>
142 <?
143  $first = false;
144  $alt = !$alt;
145  }
146 
147  $this->topic->updateExplicit("SET views=views+1");
148  }
149  else
150  {
151 ?>
152  <p><em>No messages have been posted for this topic.</em></p>
153 <?
154  }
155  }
& nbsp
Definition: index.inc:49
$helpTree style
Definition: tree.inc:46
if(! $attachment_id) $attachment
Definition: delete.inc:42
$icon
Definition: upload.inc:92
static formatUserProfile($u)
formatAttachment($icon, $attachment)
Definition: topic_view.inc:157
Provides the interface to the user model for the application.
global $user
$forumRequest to
$message
Definition: mail_to.inc:49

◆ formatAttachment()

ForumTopicView::formatAttachment (   $icon,
  $attachment 
)

Definition at line 157 of file topic_view.inc.

158  {
159  global $config;
160  $dir = $config["uploaddir"];
161 
162  $link = "<img src=\"{$icon}\" alt=\"Icon\" style=\"display:inline-block;vertical-align:middle\"/>&nbsp;";
163  $link .= "<a href='/action/attachment/download?attachment_id={$attachment->attachment_id}'>{$attachment->filename}
164  </a>&nbsp;({$attachment->file_size})\n";
165 
166  return $link;
167  }
$dir
Definition: delete.inc:44
global $config
Definition: import.inc:4

◆ ForumTopicView()

ForumTopicView::ForumTopicView (   $topic,
  $id = "topic_view" 
)

Definition at line 45 of file topic_view.inc.

46  {
47  $this->topic = $topic;
48  $this->forum = $topic->Forum();
49  $this->messages = $this->topic->Messages("WHERE deleted=0 ORDER BY date_posted");
50 
51  $this->subscriptionView = new ForumSubscriptionHelper($this->forum, $this->topic);
52  }

◆ writeScript()

ForumTopicView::writeScript ( )

Definition at line 54 of file topic_view.inc.

55  {
56  return $this->subscriptionView->writeScript();
57  }

Member Data Documentation

◆ $forum

ForumTopicView::$forum

Definition at line 41 of file topic_view.inc.

◆ $subscriptionView

ForumTopicView::$subscriptionView

Definition at line 43 of file topic_view.inc.

◆ $topic

ForumTopicView::$topic

Definition at line 42 of file topic_view.inc.


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