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
00017 require_once(confGet('DIR_STREBER') . 'db/class_comment.inc.php');
00018 require_once(confGet('DIR_STREBER') . 'render/render_page.inc.php');
00019 require_once(confGet('DIR_STREBER') . 'render/render_list.inc.php');
00020 require_once(confGet('DIR_STREBER') . "db/db_itemchange.inc.php");
00021
00022 define('COMMENT_LEN_PREVIEW', 240);
00023 define('ITEM_DELETED', 1);
00024 define('ITEM_MODIFIED', 2);
00025 define('ITEM_NEW', 3);
00026
00027
00038 class ChangeLine extends BaseObject {
00039 public $project_id;
00040 public $timestamp;
00041 public $person_by;
00042 public $relavant_to_cur_user= true;
00043 public $html_what;
00044 public $txt_what;
00045 public $what;
00046 public $task;
00047 public $task_id;
00048 public $task_html;
00049 public $html_details;
00050 public $html_assignment;
00051
00052
00053 public function __construct($args)
00054 {
00055 parent::__construct($args);
00056 }
00057
00058
00059
00060 static function &getChangeLinesForPerson(&$person, $project=NULL, $date_compare=NULL)
00061 {
00062 global $PH;
00063 $query_options= array();
00064
00065 if(!$date_compare) {
00066 $date_compare= $person->last_logout;
00067 }
00068
00069 if($project) {
00070 $query_options['project']= $project->id;
00071 }
00072 fillMissingValues($query_options, array(
00073 'alive_only' => false,
00074 'date_min' => $date_compare,
00075 'not_modified_by'=> $person->id,
00076 ));
00077
00078 $change_lines= ChangeLine::getChangeLines($query_options);
00079 return $change_lines;
00080 }
00081
00082
00083 static function &getChangeLines(&$query_options)
00084 {
00085 global $PH;
00086
00087 global $auth;
00088 fillMissingValues($query_options, array(
00089 'alive_only' => false,
00090 ));
00091
00092
00093 $date_compare= isset($query_options['date_min'])
00094 ? $query_options['date_min']
00095 : "0000-00-00";
00096
00097
00101 $changed_items= DbProjectItem::getAll($query_options);
00102
00103
00104
00109 $changes= array();
00110 foreach($changed_items as $i) {
00111 $change_type= NULL;
00112
00113 if(!isset($query_options['project'])){
00114 $project= Project::getVisibleById($i->project);
00115 }
00116 else {
00117 $project= NULL;
00118 }
00119
00123 if($i->deleted >= $i->modified) {
00124 $change_type= ITEM_DELETED;
00125 }
00126 else if($i->modified > $i->created) {
00127 $change_type= ITEM_MODIFIED;
00128 }
00129 else {
00130 $change_type= ITEM_NEW;
00131 }
00132
00133
00137 switch($change_type) {
00138 case ITEM_NEW:
00139
00140 if($i->type == ITEM_TASK) {
00141 if(!$task= Task::getVisibleById($i->id)) {
00142 continue;
00143 }
00144
00145 if($assigned_persons= $task->getAssignedPersons()) {
00146 $tmp=array();
00147
00148 foreach($assigned_persons as $ap) {
00149 $tmp[]= $ap->getLink();
00150 }
00151
00152 $html_assignment= __('to','very short for assigned tasks TO...'). ' ' . implode(', ', $tmp);
00153 }
00154 else {
00155 $html_assignment= '';
00156 }
00157
00158
00159
00160 $html_details= '';
00161 if($tmp= $task->getFolderLinks(true, $project)) {
00162 $html_details .=__('in', 'very short for IN folder...'). ' '. $tmp;
00163 }
00164
00165 if($task->prio != PRIO_NORMAL && $task->prio != PRIO_UNDEFINED) {
00166 global $g_prio_names;
00167 $html_details .= ' / ' . $g_prio_names[$task->prio];
00168 }
00169
00170
00171 $change= new ChangeLine(array(
00172 'person_by' => $i->created_by,
00173 'timestamp' => $i->created,
00174 'task_id' => $i->id,
00175 'html_what' => '<span class=new>'. __('new') .' '. $task->getLabel() .'</span>',
00176 'txt_what' => __('new') .' '. $task->getLabel(),
00177 'html_assignment'=> $html_assignment,
00178 'html_details'=> $html_details,
00179 ));
00180 $changes[]= $change;
00181 }
00182 else {
00183
00184
00185 }
00186 break;
00187
00188 case ITEM_MODIFIED:
00189
00190 $timestamp_last_change= $date_compare; # make sure we use the last occured change type
00194 if($i->type == ITEM_TASK) {
00195
00196
00197 if(!$task= Task::getVisibleById($i->id)) {
00198 continue;
00199 }
00200
00201 if($assigned_persons= $task->getAssignedPersons()) {
00202 $tmp=array();
00203
00204 foreach($assigned_persons as $ap) {
00205 $tmp[]= $ap->getLink();
00206 }
00207
00208 $html_assignment= __('to','very short for assigned tasks TO...'). ' ' . implode(', ', $tmp);
00209 }
00210 else {
00211 $html_assignment= '';
00212 }
00213
00214 $html_details= '';
00215 if($tmp= $task->getFolderLinks(true, $project)) {
00216 $html_details .=__('in', 'very short for IN folder...'). ' '. $tmp;
00217 }
00218
00219 $html_what= __('modified');
00220
00221
00222 ### try to get comments
00223 {
00224 $html_comment= '';
00225 if($comments = Comment::getAll(array(
00226 'person' => $i->modified_by,
00227 'task' => $task->id,
00228 'date_min' => $timestamp_last_change,
00229 ))) {
00230 $last_comment= $comments[count($comments)-1];
00231 $timestamp_last_change= $last_comment->created;
00232
00233
00234 if($last_comment->name != __('New Comment')) { # ignore default title
00235 $html_comment= strip_tags($last_comment->name). ': ';
00236 }
00237 $html_comment.= strip_tags($last_comment->description);
00238 if(strlen($html_comment) > COMMENT_LEN_PREVIEW) {
00239 $html_comment= substr($html_comment, 0, COMMENT_LEN_PREVIEW). "...";
00240 }
00241 if(count($comments) > 1) {
00242 $html_comment= sprintf(__('Last of %s comments:'), count($comments)). ' '. $html_comment;
00243 }
00244 else {
00245 $html_comment= __('comment:'). ' '. $html_comment;
00246 }
00247 $html_comment = asHtml($html_comment);
00248 }
00249 }
00250
00251 ### get changed fields ###
00252 $changed_fields_hash=array();
00253 $html_functions= false; # this is to be added after the details
00254 {
00255 if($changed_fields_list= ItemChange::getItemChanges(array(
00256 'item' => $i->id,
00257 'person' => $i->modified_by,
00258 'date_min' => $date_compare,
00259 ))) {
00260 foreach($changed_fields_list as $cf) {
00261 $changed_fields_hash[$cf->field]= $cf;
00262 }
00263
00264 if(isset($changed_fields_hash['status'])) {
00265 $status_old= $changed_fields_hash['status']->value_old;
00266 if($task->status == STATUS_COMPLETED && $task->status > $status_old) {
00267 $html_what= __('completed') .' '. $task->getLabel();
00268 $html_functions= $PH->getLink('tasksApproved', __('Approve Task'),array('tsk' => $task->id));
00269 unset($changed_fields_hash['status']);
00270 }
00271 else if ($task->status == STATUS_APPROVED && $task->status > $status_old) {
00272 $html_what= __('approved');
00273 unset($changed_fields_hash['status']);
00274 }
00275 else if ($task->status == STATUS_CLOSED && $task->status > $status_old) {
00276 $html_what= __('closed');
00277 unset($changed_fields_hash['status']);
00278 }
00279 else if ($task->status == STATUS_OPEN && $task->status < $status_old) {
00280 $html_what= __('reopened');
00281 unset($changed_fields_hash['status']);
00282 }
00283 else if($task->status == STATUS_OPEN) {
00284 unset($changed_fields_hash['status']);
00285 }
00286 else if ($task->status == STATUS_BLOCKED) {
00287 $html_what= __('is blocked');
00288 unset($changed_fields_hash['status']);
00289 }
00290 }
00291 }
00292 if(isset($changed_fields_hash['parent_task'])) {
00293 $html_what= __('moved');
00294 unset($changed_fields_hash['parent_task']);
00295 }
00296
00297 else if(count($changed_fields_hash) == 1 && isset($changed_fields_hash['name'])) {
00298 $html_what= __('renamed');
00299 }
00300 else if(count($changed_fields_hash) == 1 && isset($changed_fields_hash['description'])) {
00301 $html_what= __('edit wiki');
00302 }
00303
00304 else if(count($changed_fields_hash)) { # status does not count
00305 $html_details .= ' / ' . __('changed:'). ' '. implode(', ', array_keys($changed_fields_hash));
00306 #if($html_comment) {
00307 # $html_details.= '<br> / '. $html_comment;
00308 #}
00309 }
00310
00314 else if($html_comment) {
00315 $html_what= __('commented');
00316 }
00317
00318 if($html_comment) {
00319 $html_details .= ' / ' . $html_comment;
00320 }
00321
00322 }
00323
00330 require_once "db/class_taskperson.inc.php";
00331 $count_assignments=0;
00332 if($assignments= TaskPerson::getTaskPersons(array(
00333 'task' => $task->id,
00334 'project' => $task->project,
00335 'date_min' => $task->modified,
00336 ))) {
00337 $t_timestamp= '';
00338 foreach($assignments as $a) {
00339
00340 if($a->person != $task->modified_by
00341 &&
00342 $a->created_by == $task->modified_by
00343 &&
00344 $a->assigntype != ASSIGNTYPE_INITIAL
00345 ) {
00346 $t_timestamp = $a->created;
00347 $count_assignments++;
00348 }
00349 }
00350 if($count_assignments
00351 &&
00352 $timestamp_last_change < $t_timestamp
00353 ) {
00354 $html_what= __('assigned');
00355 $timestamp_last_change = $t_timestamp;
00356 }
00357
00358 if($html_comment) {
00359 $html_details .= ' / ' . $html_comment;
00360 }
00361 }
00362
00366 require_once "db/class_file.inc.php";
00367 if($files= File::getAll(array(
00368 'parent_item' => $task->id,
00369 'project' => $task->project,
00370 'date_min' => $date_compare,
00371 'created_by' => $task->modified_by,
00372 ))) {
00373 $count_attached_files= 0;
00374 $html_attached=__("attached").": ";
00375 $t_timestamp='';
00376 $separator= '';
00377
00378 foreach($files as $f) {
00379 if($task->modified_by == $f->modified_by) {
00380 $t_timestamp= $f->created;
00381 $count_attached_files++;
00382 $html_attached.= $separator . $PH->getLink('fileView', $f->name, array('file'=>$f->id));
00383 $separator= ', ';
00384 }
00385 }
00386 if($count_attached_files) {
00387 $html_what= __('attached file to');
00388 if($timestamp_last_change < $t_timestamp) {
00389 $html_details.= ' / '. $html_attached;
00390 $timestamp_last_change = $t_timestamp;
00391 }
00392 }
00393 }
00394
00395
00396
00397 if(count($changed_fields_hash)){
00398 $html_details.=" / ". $PH->getLink('itemViewDiff',NULL, array('item'=>$task->id, 'date1' => $date_compare, 'date2' => gmdate("Y-m-d H:i:s")));
00399 }
00400
00401 if($html_functions) {
00402 $html_details.= " | ". $html_functions;
00403 }
00404
00405 $change= new ChangeLine(array(
00406 'person_by' => $i->modified_by,
00407 'timestamp' => $i->modified,
00408 'task_id' => $i->id,
00409 'html_what' => $html_what,
00410 'html_assignment'=> $html_assignment,
00411 'html_details'=> $html_details,
00412 #'project_id'=> $i->project,
00413 ));
00414 $changes[]= $change;
00415 }
00416
00417 break;
00418
00419
00420 case ITEM_DELETED:
00421
00425 if($i->type == ITEM_TASK) {
00426 if(!$task= Task::getVisibleById($i->id)) {
00427 continue;
00428 }
00429
00430 if($assigned_persons= $task->getAssignedPersons()) {
00431 $tmp=array();
00432
00433 foreach($assigned_persons as $ap) {
00434 $tmp[]= $ap->getLink();
00435 }
00436
00437 $html_assignment= __('to','very short for assigned tasks TO...'). ' ' . implode(', ', $tmp);
00438 }
00439 else {
00440 $html_assignment= '';
00441 }
00442
00443
00444 $html_details= '';
00445 if($tmp= $task->getFolderLinks(true, $project)) {
00446 $html_details .=__('in', 'very short for IN folder...'). ' '. $tmp;
00447 }
00448
00449 $html_details.= '|' . $PH->getLink('itemsRestore',__('restore'),array('item'=>$task->id));
00450
00451 $html_what= __('deleted');
00452
00453
00454 $change= new ChangeLine(array(
00455 'person_by' => $i->deleted_by,
00456 'timestamp' => $i->deleted,
00457 'task_id' => $i->id,
00458 'html_what' => $html_what,
00459 'html_assignment'=> $html_assignment,
00460 'html_details'=> $html_details,
00461 ));
00462 $changes[]= $change;
00463 }
00464
00468 if($i->type == ITEM_FILE) {
00469
00473 }
00474
00475 break;
00476
00477 default:
00478 trigger_error("unknown change-type $change_type", E_USER_WARNING);
00479 break;
00480 }
00481 }
00482 return $changes;
00483 }
00484 }
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494 class ListBlock_changes extends ListBlock
00495 {
00496 private $list_changes_newer_than= ''; # timestamp
00497 public $filters = array();
00498
00499 public function __construct($args=NULL)
00500 {
00501 parent::__construct($args);
00502
00503 $this->bg_style= 'bg_time';
00504
00505 global $PH;
00506 global $auth;
00507
00508 $this->id='changes';
00509
00510 $this->title=__("Changes");
00511 $this->id="changes";
00512 $this->no_items_html= sprintf(__('Other team members changed nothing since last logout (%s)'), renderDate($auth->cur_user->last_logout));
00513
00514
00515 $this->add_col( new ListBlockCol_ChangesDate());
00516 $this->add_col( new ListBlockCol_ChangesWhat());
00517 $this->add_col( new ListBlockCol_ChangesDetails());
00518
00519 }
00520
00521
00522
00523 public function print_automatic()
00524 {
00525 global $PH;
00526 global $auth;
00527
00528 ### add filter options ###
00529 foreach($this->filters as $f) {
00530 foreach($f->getQuerryAttributes() as $k=>$v) {
00531 $this->query_options[$k]= $v;
00532 }
00533 }
00534
00535 if($auth->cur_user->user_rights & RIGHT_VIEWALL){
00536 $this->query_options['visible_only'] = false;
00537 }
00538 else{
00539 $this->query_options['visible_only'] = true;
00540 }
00541 #$changes= ChangeLine::getChangeLinesForPerson($auth->cur_user, NULL);
00542 #$this->query_options['not_modified_by']= $auth->cur_user->id;
00543 $changes= ChangeLine::getChangeLines($this->query_options);
00544
00545 $this->render_list(&$changes);
00546
00547 }
00548
00549
00550
00554 public function render_list(&$changes=NULL)
00555 {
00556 global $PH;
00557
00558
00559
00560 $this->render_header();
00561
00562 if(!$changes && $this->no_items_html) {
00563 $this->render_tfoot_empty();
00564 }
00565 else {
00566
00567 $style='changeList';
00568
00569 ### render table lines ###
00570 $this->render_thead();
00571
00572 $last_group= NULL;
00573
00574 foreach($changes as $c) {
00575
00576 $this->render_trow(&$c,$style);
00577 }
00578
00579 $this->render_tfoot();
00580 }
00581 }
00582 }
00583
00584
00585
00590 class ListBlockCol_ChangesDate extends ListBlockCol
00591 {
00592
00593 public function __construct($args=NULL) {
00594 parent::__construct($args);
00595 $this->name =__('Date');
00596 $this->tooltip=__("Who changed what when...");
00597 }
00598
00599 function render_tr(&$change_line, $style="")
00600 {
00601 if($change_line instanceof ChangeLine) {
00602 if($change_line->person_by) {
00603 if($person= Person::getVisibleById($change_line->person_by)) {
00604 print '<td><span class=date>'.renderDateHtml($change_line->timestamp) .'</span><br><span class="sub who">by '. $person->getLink() .'</span></td>';
00605 return;
00606 }
00607
00608 }
00609 print '<td><span class=date>'.renderDateHtml($change_line->timestamp) .'</span></td>';
00610 }
00611 else {
00612 trigger_error('ListBlockCol_ChangesDate() requires instance of ChangeLine',E_USER_WARNING);
00613 print "<td></td>";
00614 }
00615 }
00616 }
00617
00618
00619
00624 class ListBlockCol_ChangesWhat extends ListBlockCol
00625 {
00626
00627 public function __construct($args=NULL) {
00628 parent::__construct($args);
00629 $this->name =__('what','column header in change list');
00630 $this->width ='10%';
00631 }
00632
00633 function render_tr(&$change_line, $style="")
00634 {
00635 if(!$change_line instanceof ChangeLine) {
00636 trigger_error('ListBlockCol_ChangesWhat() requires instance of ChangeLine',E_USER_WARNING);
00637 print "<td></td>";
00638 return;
00639 }
00640
00641 if($change_line->html_what) {
00642 $str_what= $change_line->html_what;
00643 }
00644 else {
00645 $str_what='';
00646 }
00647
00648 $html_assignment= $change_line->html_assignment
00649 ? '<span class=assigment>' . $change_line->html_assignment . '</span>'
00650 : '';
00651
00652 print '<td><span class=nowrap>'. $str_what .'</span><br><span class="sub who">'. $html_assignment .'</span></td>';
00653 }
00654 }
00655
00656
00657
00658
00663 class ListBlockCol_ChangesDetails extends ListBlockCol
00664 {
00665
00666 public function __construct($args=NULL) {
00667 parent::__construct($args);
00668 $this->name =__('Task');
00669 $this->width ='80%';
00670 }
00671
00672 function render_tr(&$change_line, $style="")
00673 {
00674 if(!$change_line instanceof ChangeLine) {
00675 trigger_error('ListBlockCol_ChangesDetails() requires instance of ChangeLine',E_USER_WARNING);
00676 print "<td></td>";
00677 return;
00678 }
00679
00680 if($change_line->task_html) {
00681 $str_task= $change_line->task_html;
00682 }
00683 else if($change_line->task) {
00684 $str_task= $task->getLink(false);
00685 }
00686 else if($change_line->task_id) {
00687 if($task= Task::getVisibleById($change_line->task_id)) {
00688 global $auth;
00689
00690 ### high light changes by others ###
00691 $str_task= $task->getLink(false);
00692
00693 if($task->status >= STATUS_COMPLETED) {
00694 $str_task= '<span class=isDone>'. $str_task.'</span>';
00695 }
00696
00697 if($change_line->person_by != $auth->cur_user->id) {
00698 $str_task= '<b' . $str_task . '</b>';
00699 }
00700 }
00701 }
00702 else {
00703 '';
00704 }
00705
00706 $str_details= $change_line->html_details
00707 ? $change_line->html_details
00708 : "";
00709
00710 print '<td>'.$str_task .'<br><span class="sub">'. $str_details.'</span></td>';
00711 }
00712 }
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00729 class ListBlockCol_ChangesDatePerson extends ListBlockCol
00730 {
00731
00732 public function __construct($args=NULL) {
00733 parent::__construct($args);
00734 $this->name =__('Date / by');
00735 $this->tooltip=__("Who changed what when...");
00736 }
00737
00738 function render_tr(&$item, $style="")
00739 {
00740 $date_created= $item->created;
00741 $date_modified= $item->modified;
00742 $date_deleted= $item->deleted;
00743
00744 $person=NULL;
00745 $str="";
00746 if($date_deleted >= $date_modified) {
00747 $person= Person::getVisibleById($item->deleted_by);
00748 }
00749 else if($date_modified > $date_created) {
00750 $person= Person::getVisibleById($item->modified_by);
00751 }
00752 else {
00753 $person= Person::getVisibleById($item->created_by);
00754 }
00755
00756 $str_link="";
00757 if($person) {
00758 $str_link=$person->getLink();
00759 }
00760 print '<td><span class=date>'.$renderTimestampHtml($date_modified) .'</span><span class=sub>'. $person->getLink() .'</span></td>';
00761 }
00762 }
00763
00764
00765 class ListBlock_AllChanges extends ListBlock
00766 {
00767 public $bg_style = "bg_time";
00768 public $filters = array();
00769
00770 public function __construct($args=NULL)
00771 {
00772 parent::__construct($args);
00773
00774 global $PH;
00775 global $auth;
00776
00777 $this->id = 'allchanges';
00778
00779 $this->title = __("Changes");
00780 $this->id = "allchanges";
00781 $this->no_items_html = __('Nothing has changed.');
00782
00783 $this->add_col( new ListBlockColSelect());
00784 ## from list_projectchanages.inc.php ##
00785 $this->add_col(new ListBlockCol_ChangesByPerson());
00786 $this->add_col(new ListBlockCol_ChangesEditType());
00787 $this->add_col(new ListBlockCol_ChangesItemType());
00788 $this->add_col(new ListBlockCol_AllChangesItemName());
00789 $this->add_col( new listBlockColDate(array(
00790 'key'=>'modified',
00791 'name'=>__('modified')
00792 )));
00793
00794
00795 ### block style functions ###
00796 $this->add_blockFunction(new BlockFunction(array(
00797 'target'=>'changeBlockStyle',
00798 'key'=>'list',
00799 'name'=>'List',
00800 'params'=>array(
00801 'style'=>'list',
00802 'block_id'=>$this->id,
00803 'page_id'=>$PH->cur_page->id,
00804 ),
00805 'default'=>true,
00806 )));
00807 $this->groupings= new BlockFunction_grouping(array(
00808 'target'=>'changeBlockStyle',
00809 'key'=>'grouped',
00810 'name'=>'Grouped',
00811 'params'=>array(
00812 'style'=>'grouped',
00813 'block_id'=>$this->id,
00814 'page_id'=>$PH->cur_page->id,
00815 ),
00816 ));
00817 $this->add_blockFunction($this->groupings);
00818
00819
00820 ### list groupings ###
00821 $this->groupings->groupings= array(
00822 new ListGroupingModifiedBy(),
00823 new ListGroupingItemType(),
00824 );
00825 }
00826
00827 public function print_automatic()
00828 {
00829 global $PH;
00830
00831 if(!$this->active_block_function=$this->getBlockStyleFromCookie()) {
00832 $this->active_block_function = 'list';
00833 }
00834
00835 $this->query_options['alive_only'] = false;
00836
00837 $this->group_by= get("blockstyle_{$PH->cur_page->id}_{$this->id}_grouping");
00838
00839 $s_cookie= "sort_{$PH->cur_page->id}_{$this->id}_{$this->active_block_function}";
00840 if($sort= get($s_cookie)) {
00841 $this->query_options['order_by']= $sort;
00842 }
00843
00844 ### add filter options ###
00845 foreach($this->filters as $f) {
00846 foreach($f->getQuerryAttributes() as $k=>$v) {
00847 $this->query_options[$k]= $v;
00848 }
00849 }
00850
00851 ### grouped view ###
00852 if($this->active_block_function == 'grouped') {
00853
00859 if(isset($this->columns[ $this->group_by ])) {
00860 unset($this->columns[$this->group_by]);
00861 }
00862
00863 ### prepend key to sorting ###
00864 if(isset($this->query_options['order_by'])) {
00865 $this->query_options['order_by'] = $this->groupings->getActiveFromCookie() . ",".$this->query_options['order_by'];
00866
00867 }
00868 else {
00869 $this->query_options['order_by'] = $this->groupings->getActiveFromCookie();
00870 }
00871 }
00872 ### list view ###
00873 else {
00874 $pass= true;
00875 }
00876
00877 $changes = DbProjectItem::getChanges($this->query_options);
00878
00879 $this->render_list(&$changes);
00880 }
00881 }
00882
00883 class ListBlockCol_AllChangesItemName extends ListBlockCol
00884 {
00885 public $width = "80%";
00886
00887 public function __construct($args=NULL) {
00888 parent::__construct($args);
00889 $this->name = __('Name');
00890 }
00891
00892 function render_tr(&$obj, $style="")
00893 {
00894 global $PH;
00895
00896 $str_url="";
00897 $str_name="";
00898 $str_addon="";
00899 switch($obj->type) {
00900 case ITEM_PROJECT:
00901 if($project = Project::getVisibleById($obj->id)) {
00902 $str_name = asHtml($project->name);
00903 $str_url = $PH->getUrl('projView',array('prj'=>$project->id));
00904 }
00905 break;
00906
00907 case ITEM_TASK:
00908 if($task = Task::getVisibleById($obj->id)) {
00909 $str_name = asHtml($task->name);
00910 $str_url = $PH->getUrl('taskView',array('tsk'=>$task->id));
00911 if($project = Project::GetVisibleById($task->project)){
00912 $str_addon = "(".$project->getLink(false).")";
00913 }
00914 }
00915 break;
00916
00917 case ITEM_COMMENT:
00918 if($comment = Comment::getVisibleById($obj->id)) {
00919 if($comment->name == ''){
00920 $str_name = "-";
00921 }
00922 else{
00923 $str_name = asHtml($comment->name);
00924 }
00925 $str_url = $PH->getUrl('taskView',array('tsk'=>$comment->task));
00926 $str_addon .= "(";
00927 if($task = Task::getVisibleById($comment->task)){
00928 if($project = Project::getVisibleById($task->project)){
00929 $str_addon .= $project->getLink(false) . " > ";
00930 }
00931 $str_addon .= $task->getLink(false);
00932 if($comment->comment){
00933 if($comm = Comment::getVisibleById($comment->comment)){
00934 $str_addon .= " > " . $comm->name;
00935 }
00936 }
00937 }
00938 $str_addon .= ")";
00939
00940 }
00941 break;
00942
00943 case ITEM_COMPANY:
00944 if($c = Company::getVisibleById($obj->id)) {
00945 $str_name = asHtml($c->name);
00946 $str_url = $PH->getUrl('companyView',array('company'=>$c->id));
00947 }
00948 break;
00949
00950 case ITEM_PERSON:
00951 if($person = Person::getVisibleById($obj->id)) {
00952 $str_name = asHtml($person->name);
00953 $str_url = $PH->getUrl('personView',array('person'=>$person->id));
00954 }
00955 break;
00956
00957 case ITEM_PROJECTPERSON:
00958 if($pp = ProjectPerson::getVisibleById($obj->id)) {
00959 if(!$person= new Person($pp->person)) {
00960 $PH->abortWarning("ProjectPerson has invalid person-pointer!",ERROR_BUG);
00961 }
00962 $str_name = asHtml($person->name);
00963 $str_url = $PH->getUrl('personView',array('person'=>$person->id));
00964 if($project = Project::getVisibleById($pp->project)){
00965 $str_addon = "(" . $project->getLink(false) .")";
00966 }
00967
00968 }
00969 break;
00970
00971 case ITEM_EMPLOYMENT:
00972 if($emp= Employment::getById($obj->id)) {
00973 if($person= Person::getVisibleById($emp->person)) {
00974 $str_name= asHtml($person->name);
00975 $str_url= $PH->getUrl('personView',array('person'=>$person->id));
00976 }
00977 if($company = Company::getVisibleById($emp->company)){
00978 $str_addon= "(". $company->getLink(false) .")";
00979 }
00980 }
00981 break;
00982
00983 case ITEM_EFFORT:
00984 if($e= Effort::getVisibleById($obj->id)) {
00985 $str_name= asHtml($e->name);
00986 $str_url= $PH->getUrl('effortEdit',array('effort'=>$e->id));
00987 if($task = Task::getVisibleById($e->task)){
00988 if($project = Project::getVisibleById($task->project)){
00989 $str_addon .= "(". $project->getLink(false) ;
00990 $str_addon .= " > ". $task->getLink(false) .")";
00991 }
00992 }
00993
00994 }
00995 break;
00996
00997 case ITEM_FILE:
00998 if($f= File::getVisibleById($obj->id)) {
00999 $str_name= asHtml($f->org_filename);
01000 $str_url= $PH->getUrl('fileView',array('file'=>$f->id));
01001 $str_addon .= "(";
01002 if($p = Project::getVisibleById($f->project)){
01003 $str_addon .= $p->getLink(false) ;
01004 }
01005 if($t = Task::getVisibleById($f->parent_item)){
01006 $str_addon .= " > " . $t->getLink(false) ;
01007 }
01008 $str_addon .= ")";
01009 }
01010 break;
01011
01012 case ITEM_ISSUE:
01013 if($i = Issue::getVisibleById($obj->id)) {
01014 if($t = Task::getVisibleById($i->task)){
01015 $str_name = asHtml($t->name);
01016 $str_url = $PH->getUrl('taskView',array('tsk'=>$t->id));
01017 if($p = Project::getVisibleById($t->project)){
01018 $str_addon .= "(". $p->getLink(false) .")";
01019 }
01020 }
01021 }
01022 break;
01023
01024 case ITEM_TASKPERSON:
01025 if($tp = TaskPerson::getVisibleById($obj->id)) {
01026 if($person = Person::getVisibleById($tp->person)){
01027 $str_name = asHtml($person->name);
01028 $str_url = $PH->getUrl('personView',array('person'=>$person->id));
01029 }
01030 if($task = Task::getVisibleById($tp->task)){
01031 if($project = Project::getVisibleById($task->project)){
01032 $str_addon .= "(". $project->getLink(false) ;
01033 $str_addon .= " > ". $task->getLink(false) .")";
01034 }
01035 }
01036 }
01037 break;
01038
01039 default:
01040 break;
01041
01042 }
01043 print "<td><a href='$str_url'>$str_name</a><span class='sub who'> $str_addon</span></td>";
01044 }
01045 }
01046
01047 ?>