CMS  Version 3.9
forum_search_results_view.inc
Go to the documentation of this file.
1 <?php
7 /**************************************************************
8 
9 Copyright (c) 2010 Sonjara, Inc
10 
11 Permission is hereby granted, free of charge, to any person
12 obtaining a copy of this software and associated documentation
13 files (the "Software"), to deal in the Software without
14 restriction, including without limitation the rights to use,
15 copy, modify, merge, publish, distribute, sublicense, and/or sell
16 copies of the Software, and to permit persons to whom the
17 Software is furnished to do so, subject to the following
18 conditions:
19 
20 The above copyright notice and this permission notice shall be
21 included in all copies or substantial portions of the Software.
22 
23 Except as contained in this notice, the name(s) of the above
24 copyright holders shall not be used in advertising or otherwise
25 to promote the sale, use or other dealings in this Software
26 without prior written authorization.
27 
28 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
30 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
32 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
34 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35 OTHER DEALINGS IN THE SOFTWARE.
36 
37 *****************************************************************/
38 
40 {
41  var $messages;
43 
44  function __construct($messages, $searchText, $id = "forum_search_results")
45  {
46  $this->messages = $messages;
47  $this->searchText = $searchText;
48  }
49 
50  function writeScript()
51  {
52  }
53 
54  function drawView()
55  {
56  global $user; // User Credentials from session
57 
58  $first = true;
59  $alt = false;
60 
61  $forum_id = checkNumeric($_GET["forum_id"]);
62  $forum = new Forum($forum_id);
63 
64 ?>
65 <p><label>Search Results for</label> <?echo htmlSafe($this->searchText)?>
66 <a class='button' style='float: right' href='<?echo $forum->identifier?>'>&laquo; Back to Forum</a>
67 </p>
68 <?
69  if (count($this->messages) > 0)
70  {
71  foreach($this->messages as $message)
72  {
73  $author = $message->Author();
74 
75  $userProfile = ForumManager::formatUserProfile($author);
76  $class = $alt ? "message alt" : "message"
77  ?>
78  <a name="message<?echo $message->message_id?>"></a>
79  <div id="message<?echo $message->message_id?>" class="<?echo $class?>">
80  <div class="title">
81 
82  <a class="button" style='float: right' href='forum_topic?forum_id=<?echo $message->forum_id?>&topic_id=<? echo $message->topic_id ?>'> View this topic </a>
83 
84  <strong><?echo $message->title?></strong><br/>
85  <span class="small">Posted by <?echo $userProfile?> at <?echo $message->date_posted?></span>
86  </div>
87  <div class="message_content">
88  <?echo $message->message?>
89  </div>
90  <?
91  $attachments = $message->Attachments();
92  $userMgr = new UserManager();
93  $cl = $userMgr->getUserClass();
94  $u = new $cl;
95  $pk = $u->getPrimaryKey();
96 
97  if (count($attachments) > 0)
98  {
99  echo "<h4 style='margin-bottom: 4px'>Attachments</h4>";
100 
101  foreach($attachments as $attachment)
102  {
103  $icon = DocumentHandler::getDocIcon($attachment->filename);
104 
105  echo $this->formatAttachment($icon, $attachment);
106 
107  if ($author && $user && ($author->get($pk) == $user->get($pk)) || checkRole("admin,data"))
108  {
109  ?>
110  &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>
111  <?
112  }
113  ?>
114  <br/>
115  <?
116  }
117  }
118 
119  $controls = array();
120  if ($user && $author->get($pk) == $user->get($pk) || checkRole("admin,data,moderator"))
121  {
122  $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>";
123  }
124 
125  if ($user && $author->get($pk) == $user->get($pk) || checkRole("admin,data,moderator"))
126  {
127  $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>";
128  }
129 
130  if ($user)
131  {
132  $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>";
133  }
134 
135  ?>
136  <div class="message_controls"><? echo implode("&nbsp;|&nbsp;", $controls);?></div>
137  </div>
138  <?
139  $first = false;
140  $alt = !$alt;
141  }
142  }
143  else
144  {
145  ?>
146  <p><em>No messages have been posted for this topic.</em></p>
147  <?
148  }
149  }
150 
152  {
153  global $config;
154  $dir = $config["uploaddir"];
155 
156  $link = "<img src=\"{$icon}\" alt=\"Icon\" style=\"display:inline-block;vertical-align:middle\"/>&nbsp;";
157  $link .= "<a href='/action/attachment/download?attachment_id={$attachment->attachment_id}'>{$attachment->filename}
158  </a>&nbsp;({$attachment->file_size})\n";
159 
160  return $link;
161  }
162 }
163 ?>
& nbsp
Definition: index.inc:49
$forum_id
Definition: forum_form.inc:39
$helpTree style
Definition: tree.inc:46
$dir
Definition: delete.inc:44
if(! $attachment_id) $attachment
Definition: delete.inc:42
$icon
Definition: upload.inc:92
Definition: forum.inc:42
static formatUserProfile($u)
__construct($messages, $searchText, $id="forum_search_results")
formatAttachment($icon, $attachment)
Provides the interface to the user model for the application.
global $user
$forumRequest to
global $config
Definition: import.inc:4
$message
Definition: mail_to.inc:49