1<?php 2/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */ 3 4/** 5 * Class ilForumPostsDeleted 6 * @author Nadia Matuschek <nmatuschek@databay.de> 7 */ 8class ilForumPostsDeleted 9{ 10 /** 11 * @var int 12 */ 13 protected $deleted_id = 0; 14 /** 15 * @var null 16 */ 17 protected $deleted_date = null; 18 /** 19 * @var string 20 */ 21 protected $deleted_by = ''; 22 23 /** 24 * @var string 25 */ 26 protected $forum_title = ''; 27 /** 28 * @var string 29 */ 30 protected $thread_title = ''; 31 32 /** 33 * @var string 34 */ 35 protected $post_title = ''; 36 /** 37 * @var string 38 */ 39 protected $post_message = ''; 40 41 /** 42 * @var string 43 */ 44 protected $post_date = ''; 45 46 /** 47 * @var int 48 */ 49 protected $obj_id = 0; 50 /** 51 * @var int 52 */ 53 protected $ref_id = 0; 54 /** 55 * @var int 56 */ 57 protected $thread_id = 0; 58 59 /** 60 * @var int 61 */ 62 protected $forum_id = 0; 63 64 /** 65 * @var int 66 */ 67 protected $pos_display_user_id = 0; 68 /** 69 * @var string 70 */ 71 protected $pos_usr_alias = ''; 72 73 /** 74 * @var bool 75 */ 76 protected $thread_deleted = false; 77 78 private $user; 79 private $db; 80 81 /** 82 * @param ilObjForumNotificationDataProvider|NULL $provider 83 */ 84 public function __construct(ilObjForumNotificationDataProvider $provider = null) 85 { 86 global $DIC; 87 $this->user = $DIC->user(); 88 $this->db = $DIC->database(); 89 90 if (is_object($provider)) { 91 $this->setDeletedBy($provider->getDeletedBy()); 92 93 $this->setDeletedDate(date('Y-m-d H:i:s')); 94 $this->setForumTitle($provider->getForumTitle()); 95 $this->setThreadTitle($provider->getThreadTitle()); 96 $this->setPostTitle($provider->getPostTitle()); 97 98 if ($provider->getPostCensored() == 1) { 99 $this->setPostMessage($provider->getCensorshipComment()); 100 } else { 101 $this->setPostMessage($provider->getPostMessage()); 102 } 103 104 $this->setPostDate($provider->getPostDate()); 105 $this->setObjId($provider->getObjId()); 106 $this->setRefId($provider->getRefId()); 107 $this->setThreadId($provider->getThreadId()); 108 $this->setForumId($provider->getForumId()); 109 $this->setPosDisplayUserId($provider->getPosDisplayUserId()); 110 $this->setPosUserAlias($provider->getPosUserAlias()); 111 } 112 } 113 114 /** 115 * 116 */ 117 public function insert() 118 { 119 $next_id = $this->db->nextId('frm_posts_deleted'); 120 121 $this->db->insert('frm_posts_deleted', array( 122 'deleted_id' => array('integer', $next_id), 123 'deleted_date' => array('timestamp', $this->getDeletedDate()), 124 'deleted_by' => array('text', $this->getDeletedBy()), 125 'forum_title' => array('text', $this->getForumTitle()), 126 'thread_title' => array('text', $this->getThreadTitle()), 127 'post_title' => array('text', $this->getPostTitle()), 128 'post_message' => array('text', $this->getPostMessage()), 129 130 'post_date' => array('timestamp', $this->getPostDate()), 131 'obj_id' => array('integer', $this->getObjId()), 132 'ref_id' => array('integer', $this->getRefId()), 133 'thread_id' => array('integer', $this->getThreadId()), 134 'forum_id' => array('integer', $this->getForumId()), 135 'pos_display_user_id' => array('integer', $this->getPosDisplayUserId()), 136 'pos_usr_alias' => array('text', $this->getPosUserAlias()), 137 'is_thread_deleted' => array('integer', $this->isThreadDeleted()) 138 )); 139 } 140 141 /** 142 * 143 */ 144 public function deleteNotifiedEntries() 145 { 146 $this->db->manipulateF('DELETE FROM frm_posts_deleted WHERE deleted_id > %s', array('integer'), array(0)); 147 } 148 149 150 //----------------// SETTER & GETTER //----------------// 151 /** 152 * @return int 153 */ 154 public function getDeletedId() 155 { 156 return $this->deleted_id; 157 } 158 159 /** 160 * @param int $deleted_id 161 */ 162 public function setDeletedId($deleted_id) 163 { 164 $this->deleted_id = $deleted_id; 165 } 166 167 /** 168 * @return null 169 */ 170 public function getDeletedDate() 171 { 172 return $this->deleted_date; 173 } 174 175 /** 176 * @param null $deleted_date 177 */ 178 public function setDeletedDate($deleted_date) 179 { 180 $this->deleted_date = $deleted_date; 181 } 182 183 /** 184 * @return string 185 */ 186 public function getDeletedBy() 187 { 188 return $this->deleted_by; 189 } 190 191 /** 192 * @param string $deleted_by 193 */ 194 public function setDeletedBy($deleted_by) 195 { 196 $this->deleted_by = $deleted_by; 197 } 198 199 /** 200 * @return string 201 */ 202 public function getForumTitle() 203 { 204 return $this->forum_title; 205 } 206 207 /** 208 * @param string $forum_title 209 */ 210 public function setForumTitle($forum_title) 211 { 212 $this->forum_title = $forum_title; 213 } 214 215 /** 216 * @return string 217 */ 218 public function getThreadTitle() 219 { 220 return $this->thread_title; 221 } 222 223 /** 224 * @param string $thread_title 225 */ 226 public function setThreadTitle($thread_title) 227 { 228 $this->thread_title = $thread_title; 229 } 230 231 /** 232 * @return string 233 */ 234 public function getPostTitle() 235 { 236 return $this->post_title; 237 } 238 239 /** 240 * @param string $post_title 241 */ 242 public function setPostTitle($post_title) 243 { 244 $this->post_title = $post_title; 245 } 246 247 /** 248 * @return string 249 */ 250 public function getPostMessage() 251 { 252 return $this->post_message; 253 } 254 255 /** 256 * @param string $post_message 257 */ 258 public function setPostMessage($post_message) 259 { 260 $this->post_message = $post_message; 261 } 262 263 /** 264 * @return string 265 */ 266 public function getPostDate() 267 { 268 return $this->post_date; 269 } 270 271 /** 272 * @param string $post_date 273 */ 274 public function setPostDate($post_date) 275 { 276 $this->post_date = $post_date; 277 } 278 279 /** 280 * @return int 281 */ 282 public function getObjId() 283 { 284 return $this->obj_id; 285 } 286 287 /** 288 * @param int $obj_id 289 */ 290 public function setObjId($obj_id) 291 { 292 $this->obj_id = $obj_id; 293 } 294 295 /** 296 * @return int 297 */ 298 public function getRefId() 299 { 300 return $this->ref_id; 301 } 302 303 /** 304 * @param int $ref_id 305 */ 306 public function setRefId($ref_id) 307 { 308 $this->ref_id = $ref_id; 309 } 310 311 /** 312 * @return int 313 */ 314 public function getThreadId() 315 { 316 return $this->thread_id; 317 } 318 319 /** 320 * @param int $thread_id 321 */ 322 public function setThreadId($thread_id) 323 { 324 $this->thread_id = $thread_id; 325 } 326 327 /** 328 * @return int 329 */ 330 public function getForumId() 331 { 332 return $this->forum_id; 333 } 334 335 /** 336 * @param int $forum_id 337 */ 338 public function setForumId($forum_id) 339 { 340 $this->forum_id = $forum_id; 341 } 342 343 /** 344 * @return int 345 */ 346 public function getPosDisplayUserId() 347 { 348 return $this->pos_display_user_id; 349 } 350 351 /** 352 * @param int $pos_display_user_id 353 */ 354 public function setPosDisplayUserId($pos_display_user_id) 355 { 356 $this->pos_display_user_id = $pos_display_user_id; 357 } 358 359 /** 360 * @return string 361 */ 362 public function getPosUserAlias() 363 { 364 return $this->pos_usr_alias; 365 } 366 367 /** 368 * @param string $pos_usr_alias 369 */ 370 public function setPosUserAlias($pos_usr_alias) 371 { 372 $this->pos_usr_alias = $pos_usr_alias; 373 } 374 375 /** 376 * @return boolean 377 */ 378 public function isThreadDeleted() 379 { 380 return $this->thread_deleted; 381 } 382 383 /** 384 * @param boolean $thread_deleted 385 */ 386 public function setThreadDeleted($thread_deleted) 387 { 388 $this->thread_deleted = $thread_deleted; 389 } 390} 391