<?php
class post{
private $ID;
private $user;
private $type;
private $typeID;
private $visibility;
private $message;
private $time;
private $wallID;
private $priority;
public function __construct($ID){
$post=mysql_query("SELECT * FROM bullentin_message WHERE ID='".$ID."'");
if(mysql_num_rows($post)!=0){
$post=mysql_fetch_array($post);
$this->ID = $ID;
$this->user = new user($post['sendID']);
$this->message = $post['message'];
$this->visibility = $post['visibleFor'];
$this->time = $post['time'];
$this->typeID = $post['wallID'];
$this->type = $post['type'];
$this->priority = $post['priority'];
}
}
public function isVisibleForUser(){
$isVisible = isVisible($visibility,$this->user);
return $isVisible;
}
public function out($width='none'){
$senderInfo = getUserInformation($this->user);
$typeIdInfo = getUserInformation($this->typeID);
if($this->priority=='top'){
$style="top";
} else {
$style='';
}
switch($this->visibility){
case 'me': $visibility='eye-close';
break;
case 'friend': $visibility='user';
break;
case 'all':$visibility='globe';
break;
case '':$visibility='globe';
break;
default: $visibility = 'remove';
}
if($width!='none'){
$styleWidth='style="width:'.$width.'px;"';
} else {
$styleWidth;
}
$out.='
<div class="indexNews box'.$boxID.' '.$style.'" '.$styleWidth.'>';
if($this->typeID==USER_ID OR $this->sender==USER_ID){
/*$out.='
<a href="/'.RELATIVE_SYSTEM_PATH.'site/post/'.$postId.'/remove/" class="close fw-remove">×</a>';*/
$out.='
<div class="btn-group" style="position:absolute; right:20px; top:20px;">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
<span class="caret"></span>
</a>
<ul class="dropdown-menu" style="left:auto; right:0px;">
<li><a href="/'.RELATIVE_SYSTEM_PATH.'site/post/'.$this->ID.'/change-visibility/all/"><i class="icon-globe"></i> für alle sichtbar</a></li>
<li><a href="/'.RELATIVE_SYSTEM_PATH.'site/post/'.$this->ID.'/change-visibility/friend/"><i class="icon-user"></i> nur für Freunde sichtbar</a></li>
<li><a href="/'.RELATIVE_SYSTEM_PATH.'site/post/'.$this->ID.'/change-visibility/me/"><i class="icon-eye-close"></i> nur für mich sichtbar</a></li>
<li class="divider"></li>
<li><a href="/'.RELATIVE_SYSTEM_PATH.'site/post/'.$this->ID.'/remove/"><i class="icon-trash"></i> Löschen</a></li>
</ul>
</div>';
}
$out.='
<div class="right"><img src="/'.RELATIVE_SYSTEM_PATH.'site/img/phpImages/userImage.php?id='.$this->user->getID().'"></div>
<div class="left"> <a class="user" href="/'.RELATIVE_SYSTEM_PATH.'site/profile/'.$senderInfo['ID'].'/">'.$this->user->getName().'</a>
<div class="message">'.stripcslashes(bbcChat($this->message)).'</div>
<div class="foot">';
$out.='<div class="fw-clearfix"> <div class="time">'.checkTimeDistance($this->time );
/*if($sender!=$this->typeID){
$out.=' auf '.$typeIdInfo['username'].'s Pinnwand';
}*/
$out.= '</div><div class="likeBox">';
$out.= generateLikeButton($this->ID,'wall',$this->ID,'like');
$out.= '</div><div class="visibility"><i class="icon-'.$visibility.'"></i></div></div><div id="wallComments'.$this->ID.'">';
$out.= generateCommentBox('wall',$this->ID);
$out.= '</div>';
$out.='
</div></div>
</div>';
return $out;
}
}