00001 <?php if(!function_exists('startedIndexPhp')) { header("location:../index.php"); exit();}
00002 # streber - a php based project management system
00003 # Copyright (c) 2005 Thomas Mann - thomas@pixtur.de
00004 # Distributed under the terms and conditions of the GPL as stated in docs/license.txt
00005
00016 class ListBlock_comments extends ListBlock
00017 {
00018
00019 public function __construct($args=NULL) {
00020 global $PH;
00021
00022 parent::__construct();
00023
00024 $this->id ='comments';
00025 $this->bg_style ='bg_misc';
00026
00027 $this->no_items_html=$PH->getLink('commentNew');;
00028
00029 $this->title =__("Comments");
00030
00031
00032 #--- columns ----
00033 $this->add_col( new ListBlockCol_CommentPoster());
00034 $this->add_col( new ListBlockCol_CommentText());
00035
00036 #--- functions -------
00037 $this->add_function(new ListFunction(array(
00038 'target'=>$PH->getPage('commentNew')->id,
00039 'name' =>__('New Comment'),
00040 'id' =>'commentNew',
00041 'label' => __('Add Comment'),
00042 'context_menu'=>'submit',
00043 )));
00044 $this->add_function(new ListFunction(array(
00045 'target'=>$PH->getPage('itemsAsBookmark')->id,
00046 'name' =>__('Mark as bookmark'),
00047 'id' =>'itemsAsBookmark',
00048 'context_menu'=>'submit',
00049 )));
00072 }
00073 }
00074
00075
00076
00080 class ListBlockCol_CommentPoster extends ListBlockCol
00081 {
00082
00083 public $key= 'created_by';
00084 public $width='15%';
00085
00086 function __construct($args=NULL) {
00087 parent::__construct($args);
00088 #$this->name= __('By','column header');
00089 }
00090 function render_tr(&$obj, $style="") {
00091
00092 global $PH;
00093 global $auth;
00094 global $COMMENTTYPE_NAMES;
00095
00096 if(!isset($obj) || !$obj instanceof Comment) {
00097 trigger_error("ListBlock->render_tr() called without valid object",E_USER_WARNING);
00098 return;
00099 }
00100
00101
00102 $style_cur_user='';
00103 if($obj->created_by != 0 && $person=Person::getById($obj->created_by)) {
00104 if($obj->created_by == $auth->cur_user->id) {
00105 $style_cur_user= 'by_cur_user';
00106 }
00107 }
00108 $column_poster= '<td class="details ' . $style_cur_user . '">';
00109
00110
00111 ### get user ###
00112 {
00113
00114 if($obj->created_by != 0 && $person=Person::getById($obj->created_by)) {
00115 $column_poster.= '<p class="poster">'.$person->getLink().'</p>';
00116 }
00117 }
00118
00119
00120
00121 if(!$obj->view_collapsed) {
00122 ### time ###
00123 $p_time=renderDateHtml($obj->time);
00124
00125
00126 $column_poster.= "<span class=date>$p_time</span>";
00127 ### pub level if not open ###
00128 if($obj->pub_level != PUB_LEVEL_OPEN) {
00129 global $g_pub_level_names;
00130 $column_poster .= "<br>(". $g_pub_level_names[$obj->pub_level]. ')<br>';
00131 }
00132
00133 ### get version ###
00134 {
00135 require_once(confGet('DIR_STREBER') . "db/db_itemchange.inc.php");
00136 $versions= ItemVersion::getFromItem($obj);
00137 if(count($versions) > 1) {
00138 $column_poster.= "<br>" .
00139 $PH->getLink('itemViewDiff',
00140 sprintf(__("version %s"), count($versions)),
00141 array('item' => $obj->id)
00142 );
00143 }
00144
00145
00146 }
00147
00148
00149 ### edit functions - depending on the relation of the current user ###
00150 {
00151 $column_poster.= "<div class=edit_functions>";
00152
00153
00154 # if current user is the creator of the comment
00155 if($obj->created_by == $auth->cur_user->id) {
00156 if($pp= $obj->getProjectPerson()) {
00157 if($pp->level_edit < $obj->pub_level) {
00158 $column_poster.= $PH->getLink('commentEdit', __('Edit'), array('comment'=>$obj->id));
00159 }
00160 if($pp->level_delete < $obj->pub_level) {
00161 $column_poster.= $PH->getLink('commentsDelete', __('Delete'), array('comment'=>$obj->id));
00162 }
00163 }
00164 }
00165 else
00166 {
00167 ### check sufficient rights ###
00168 if($parent_task= Task::getEditableById($obj->task)) {
00169 # have to send the task-id otherwise the reply function doesn't work
00170 $column_poster.= $PH->getLink('commentNew', __('Reply'), array( 'comment'=>$obj->id, 'parent_task'=>$obj->task));
00171
00172 if($obj->pub_level != PUB_LEVEL_OPEN) {
00173 $column_poster.= $PH->getLink('itemsSetPubLevel', __('Publish'), array( 'item'=>$obj->id, 'item_pub_level'=>PUB_LEVEL_OPEN));
00174 }
00175
00176 }
00177 }
00178 $column_poster.= "</div>";
00179 }
00180 }
00181
00182 $column_poster.= "</td>";
00183
00184 print $column_poster;
00185 }
00186 }
00187
00188
00189
00190
00191
00192
00193 class ListBlockCol_CommentText extends ListBlockCol
00194 {
00195 public $key='name'; # for sql-column for sorting
00196
00197 public function __construct($args=NULL)
00198 {
00199 parent::__construct($args);
00200 $this->width='80%';
00201 $this->id='topic';
00202 }
00203
00204 function render_tr(&$obj, $style="")
00205 {
00206 global $PH;
00207 if(!isset($obj) || !$obj instanceof Comment) {
00208 trigger_error("ListBlock->render_tr() called without valid object",E_USER_WARNING);
00209 return;
00210 }
00211
00212
00213 global $auth;
00214 if($obj->created_by == $auth->cur_user->id) {
00215 $column_text= '<td class="comment_text by_cur_user">';
00216 }
00217 else {
00218 $column_text= "<td class=comment_text>";
00219 }
00220
00221
00222 $column_text.= "<div class=comment_block style='padding-left:".($obj->level*2.0)."em'>";
00223
00224 if($obj->view_collapsed) {
00225 $column_text.= $PH->getLink('commentToggleViewCollapsed',"<img src=\"" . getThemeFile("img/toggle_folder_closed.gif") . "\">",array('comment'=>$obj->id),NULL, true);
00226 $column_text.= "<span class=title>" . $PH->getLink('commentView',$obj->name, array('comment' => $obj->id)) . "</span>";
00227 if($obj->num_children) {
00228 $column_text.= "<span class=children> (";
00229 if($obj->num_children == 1) {
00230 $column_text.= __("1 sub comment");
00231 }
00232 else {
00233 $column_text.= printf(__("%s sub comments"), $obj->num_children);
00234 }
00235 $column_text.= ")</span>";
00236 }
00237 }
00238 else {
00239 $column_text.= $PH->getLink('commentToggleViewCollapsed',"<img src=\"" . getThemeFile("img/toggle_folder_open.gif") . "\">",array('comment'=>$obj->id),NULL,true);
00240 $column_text.= "<span class=title>" . $PH->getLink('commentView',$obj->name, array('comment' => $obj->id)) . "</span>";
00241
00242 require_once(confGet('DIR_STREBER') . 'render/render_wiki.inc.php');
00243 $project= Project::getVisibleById($obj->project);
00244 $obj->nowViewedByUser();
00245
00246
00247 ### editable? ###
00248 $editable= false;
00249 if($obj->created_by == $auth->cur_user->id) {
00250 if($pp= $obj->getProjectPerson()) {
00251 if($pp->level_edit < $obj->pub_level) {
00252 $editable= true;
00253 }
00254 }
00255 }
00256 if($editable) {
00257 $diz= wiki2html($obj->description, $project, $obj->id, 'description');
00258 }
00259 else {
00260 $diz= wiki2html($obj->description, $project);
00261 }
00262
00263
00264 if($diz) {
00265 $column_text.= "<div class=comment_text>$diz</div>";
00266 }
00267 }
00268
00269 $column_text.= "</div>";
00270 $column_text.= "</td>";
00271
00272 print $column_text;
00273 }
00274 }
00275
00276
00277
00278
00279 ?>