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('db/db_itemperson.inc.php');
00018 require_once('db/db_item.inc.php');
00019
00020 class ListBlock_bookmarks extends ListBlock
00021 {
00022 public $bg_style = "bg_misc";
00023
00024 public function __construct($args=NULL)
00025 {
00026 parent::__construct($args);
00027
00028 global $PH;
00029 global $auth;
00030
00031 $this->id='bookmarks';
00032 $this->title=__('Your bookmarks');
00033 $this->no_items_html= __("You have no bookmarks");
00034 $this->show_icons = true;
00035
00036 $this->add_col(new ListBlockColSelect());
00037 $this->add_col(new ListBlockCol_ItemType());
00038 $this->add_col(new ListBlockCol_ItemMonitored());
00039 #$this->add_col(new ListBlockCol_ItemStatus());
00040 #$this->add_col(new ListBlockCol_ItemState());
00041 #$this->add_col(new ListBlockCol_ItemProjectName());
00042 $this->add_col(new ListBlockCol_ItemName());
00043 $this->add_col(new ListBlockCol_ItemComment());
00044 $this->add_col(new ListBlockCol_ItemRemind());
00045 #$this->add_col(new ListBlockCol_ItemModifier());
00046 $this->add_col(new ListBlockCol_ItemModified());
00047
00048 $this->add_function(new ListFunction(array(
00049 'target'=>$PH->getPage('itemMonitorEdit')->id,
00050 'name' =>__('Edit bookmark'),
00051 'id' =>'itemMonitorEdit',
00052 'icon' =>'edit',
00053 'context_menu'=>'submit',
00054 )));
00055 $this->add_function(new ListFunction(array(
00056 'target'=>$PH->getPage('itemsRemoveBookmark')->id,
00057 'name' =>__('Remove bookmark'),
00058 'id' =>'itemsRemoveBookmark',
00059 'context_menu'=>'submit',
00060 )));
00061 }
00062
00063 public function print_automatic()
00064 {
00065 global $PH;
00066 global $auth;
00067
00068 $this->active_block_function = 'list';
00069
00070 $this->initOrderQueryOption("created DESC");
00071
00072 $this->query_options['person'] = $auth->cur_user->id;
00073 $this->query_options['is_bookmark'] = 1;
00074
00075 $bookmark_items = ItemPerson::getAll($this->query_options);
00076
00077
00078
00079
00080
00081 $items= array();
00082
00083 foreach($bookmark_items as $bi) {
00084 if($item= DbProjectItem::getVisibleById($bi->item)) {
00085 $items[]= $item;
00086 }
00087 }
00088
00089 $this->render_list(&$items);
00090 }
00091 }
00092
00093
00098 class ListBlockCol_ItemType extends ListBlockCol
00099 {
00100
00101 public function __construct($args=NULL)
00102 {
00103 parent::__construct($args);
00104 $this->name = __('Type');
00105 $this->width = '10%';
00106 }
00107
00108
00109 function render_tr(&$item, $style="")
00110 {
00111 global $g_item_type_names;
00112 global $g_tcategory_names;
00113 global $g_status_names;
00114
00115 $type_name = '';
00116 $status_name = '';
00117 $isDone = '';
00118
00119 if($type = $item->type){
00120 $type_name = $g_item_type_names[$type];
00121 switch($type){
00122 case ITEM_TASK:
00123 require_once("db/class_task.inc.php");
00124 if($task = Task::getVisibleById($item->id)) {
00125 $type_name = $g_tcategory_names[$task->category];
00126 $status_name = asHtml($g_status_names[$task->status]);
00127 if($task->status >= STATUS_COMPLETED){
00128 $isDone = 'isDone';
00129 }
00130 }
00131 break;
00132
00133 case ITEM_COMMENT:
00134 $status_name = '';
00135 break;
00136
00137 case ITEM_PERSON:
00138 $status_name = '';
00139 break;
00140
00141 case ITEM_EFFORT:
00142 $status_name = '';
00143 break;
00144
00145 case ITEM_FILE:
00146 require_once("db/class_file.inc.php");
00147 if($f = File::getVisibleById($item->id)) {
00148 $status_name = asHtml($g_status_names[$f->status]);
00149 if($f->status >= STATUS_COMPLETED){
00150 $isDone = 'isDone';
00151 }
00152 }
00153 break;
00154
00155 case ITEM_PROJECT:
00156 require_once("db/class_project.inc.php");
00157 if($prj = Project::getVisibleById($item->id)) {
00158 $status_name = asHtml($g_status_names[$prj->status]);
00159 if($prj->status >= STATUS_COMPLETED){
00160 $isDone = 'isDone';
00161 }
00162 }
00163 break;
00164
00165 case ITEM_COMPANY:
00166 $status_name = '';
00167 break;
00168
00169 case ITEM_VERSION:
00170 require_once("db/class_task.inc.php");
00171 if($tsk = Task::getVisibleById($item->id)) {
00172 $status_name = asHtml($g_status_names[$tsk->status]);
00173 if($tsk->status >= STATUS_COMPLETED){
00174 $isDone = 'isDone';
00175 }
00176 }
00177 break;
00178
00179 default:
00180 break;
00181 }
00182
00183 if($s = $item->state){
00184 if(isset($s) && $s == -1){
00185 $status_name = __('deleted');
00186 }
00187 }
00188
00189 print "<td><span class=$isDone>$type_name</span><br><span class='sub who'>$status_name</span></td>";
00190 }
00191 else{
00192 print "<td> </td>";
00193 }
00194 }
00195 }
00196
00201 class ListBlockCol_ItemMonitored extends ListBlockCol
00202 {
00203 public function __construct($args=NULL)
00204 {
00205 parent::__construct($args);
00206 $this->name = __('');
00207 $this->width = '5%';
00208 }
00209
00210
00211 function render_tr(&$item, $style="")
00212 {
00213 global $PH;
00214
00215 ## notification on change ##
00216 if($notification_items = ItemPerson::getAll(array('item'=>$item->id,'notify_on_change'=>1))){
00217 print '<td><img title="' . __('Notify on change') . '" src="' . getThemeFile("icons/monitored.png"). '"></td>';
00218 }
00219 ## notification only on unchanged ##
00220 else if ($notification_items = ItemPerson::getAll(array('item'=>$item->id,'notify_if_unchanged_min'=>NOTIFY_1DAY))){
00221 print '<td><img title="' . __('Notify on change') . '" src="' . getThemeFile("icons/monitored.png"). '"></td>';
00222 }
00223 else{
00224 print "<td> </td>";
00225 }
00226 }
00227 }
00228
00233 class ListBlockCol_ItemName extends ListBlockCol
00234 {
00235
00236 public function __construct($args=NULL)
00237 {
00238 parent::__construct($args);
00239 $this->name = __('Name');
00240 $this->width = '30%';
00241 }
00242
00243
00244 function render_tr(&$item, $style="")
00245 {
00246 global $PH;
00247
00248 $str_url = "";
00249 $str_name = "";
00250 $str_addon = "";
00251 $isDone = "";
00252 $html_details= "";
00253 $link = "";
00254
00255 if($type = $item->type){
00256 switch($type) {
00257 case ITEM_TASK:
00258 require_once("db/class_task.inc.php");
00259 if($task = Task::getVisibleById($item->id)) {
00260 $str_name = asHtml($task->name);
00261 $str_url = $PH->getUrl('taskView',array('tsk'=>$task->id));
00262 if($task->status >= STATUS_COMPLETED){
00263 $isDone = "class=isDone";
00264 }
00265 if($prj = Project::getVisibleById($task->project)) {
00266 $link = $PH->getLink('projView',$prj->getShort(),array('prj'=>$prj->id));
00267 $html_details .=__('in', 'very short for IN folder...'). ' '. $link;
00268 if($tmp = $task->getFolderLinks()) {
00269 $html_details .= ' > ' . $tmp;
00270 }
00271 }
00272 }
00273 break;
00274
00275 case ITEM_COMMENT:
00276 require_once("db/class_comment.inc.php");
00277 if($comment = Comment::getVisibleById($item->id)) {
00278 $str_name = asHtml($comment->name);
00279 if($comment->comment) {
00280 $str_url = $PH->getUrl('taskView',array('tsk'=>$comment->task));
00281 $str_addon = __("(on comment)");
00282 }
00283 else if($comment->task) {
00284 $str_url = $PH->getUrl('taskView',array('tsk'=>$comment->task));
00285 $str_addon = __("(on task)");
00286 }
00287 else {
00288 $str_url = $PH->getUrl('projView',array('prj'=>$comment->project));
00289 $str_addon = __("(on project)");
00290 }
00291 }
00292 break;
00293
00294 case ITEM_PERSON:
00295 require_once("db/class_person.inc.php");
00296 if($person = Person::getVisibleById($item->id)) {
00297 $str_name = asHtml($person->name);
00298 $str_url = $PH->getUrl('personView',array('person'=>$person->id));
00299 }
00300 break;
00301
00302 case ITEM_EFFORT:
00303 require_once("db/class_effort.inc.php");
00304 if($e = Effort::getVisibleById($item->id)) {
00305 $str_name = asHtml($e->name);
00306 $str_url = $PH->getUrl('effortEdit',array('effort'=>$e->id));
00307 }
00308 if($prj = Project::getVisibleById($e->project)) {
00309 $link = $PH->getLink('projView',$prj->getShort(),array('prj'=>$prj->id));
00310 $html_details .=__('in', 'very short for IN folder...'). ' '. $link;
00311 }
00312 break;
00313
00314 case ITEM_FILE:
00315 require_once("db/class_file.inc.php");
00316 if($f = File::getVisibleById($item->id)) {
00317 $str_name = asHtml($f->org_filename);
00318 $str_url = $PH->getUrl('fileView',array('file'=>$f->id));
00319 if($f->status >= STATUS_COMPLETED){
00320 $isDone = "class=isDone";
00321 }
00322 if($prj = Project::getVisibleById($f->project)) {
00323 $link = $PH->getLink('projView',$prj->getShort(),array('prj'=>$prj->id));
00324 $html_details .=__('in', 'very short for IN folder...'). ' '. $link;
00325 }
00326 }
00327 break;
00328
00329 case ITEM_PROJECT:
00330 require_once("db/class_project.inc.php");
00331 if($prj = Project::getVisibleById($item->id)) {
00332 $str_name = asHtml($prj->name);
00333 $str_url = $PH->getUrl('projView',array('prj'=>$prj->id));
00334 if($prj->status >= STATUS_COMPLETED){
00335 $isDone = "class=isDone";
00336 }
00337 }
00338 break;
00339
00340 case ITEM_COMPANY:
00341 require_once("db/class_company.inc.php");
00342 if($c = Company::getVisibleById($item->id)) {
00343 $str_name = asHtml($c->name);
00344 $str_url = $PH->getUrl('companyView',array('company'=>$c->id));
00345 }
00346 break;
00347
00348 case ITEM_VERSION:
00349 require_once("db/class_task.inc.php");
00350 if($tsk = Task::getVisibleById($item->id)) {
00351 $str_name = asHtml($tsk->name);
00352 $str_url = $PH->getUrl('taskView',array('tsk'=>$tsk->id));
00353 if($tsk->status >= STATUS_COMPLETED){
00354 $isDone = "class=isDone";
00355 }
00356 if($prj = Project::getVisibleById($task->project)) {
00357 $link = $PH->getLink('projView',$prj->getShort(),array('prj'=>$prj->id));
00358 $html_details .=__('in', 'very short for IN folder...'). ' '. $link;
00359 }
00360 }
00361 break;
00362
00363 default:
00364 break;
00365
00366 }
00367 print "<td class='nowrap'><span $isDone><a href='$str_url'>$str_name</a> $str_addon</span>";
00368 if($html_details){
00369 print "<br><span class='sub who'>$html_details</span>";
00370 }
00371 print "</td>";
00372 }
00373 else{
00374 $PH->abortWarning("Could not get type of the element.",ERROR_BUG);
00375 print "<td> </td>";
00376 }
00377 }
00378 }
00379
00384 class ListBlockCol_ItemComment extends ListBlockCol
00385 {
00386
00387 public function __construct($args=NULL)
00388 {
00389 parent::__construct($args);
00390 $this->name = __('Comment');
00391 $this->width = '35%';
00392 }
00393
00394
00395 function render_tr(&$item, $style="")
00396 {
00397 global $PH;
00398
00399 $bookmark_items = ItemPerson::getAll(array(
00400 'item' =>$item->id,
00401 'is_bookmark' =>1
00402 ));
00403
00404 if($bookmark_items[0]->comment){
00405 print "<td><span>" . $bookmark_items[0]->comment . "</span></td>";
00406 }
00407 else{
00408 print "<td>-</td>";
00409 }
00410 }
00411 }
00412
00417 class ListBlockCol_ItemRemind extends ListBlockCol
00418 {
00419 public function __construct($args=NULL)
00420 {
00421 parent::__construct($args);
00422 $this->name = __('Remind');
00423 $this->width = '10%';
00424 }
00425
00426
00427 function render_tr(&$item, $style="")
00428 {
00429 if($ip = ItemPerson::getAll(array('item'=>$item->id,'notify_if_unchanged_min'=>NOTIFY_1DAY))){
00430 $period = '';
00431 switch($ip[0]->notify_if_unchanged){
00432 case NOTIFY_1DAY:
00433 $period = 24*60*60;
00434 break;
00435 case NOTIFY_2DAYS:
00436 $period = 2*24*60*60;
00437 break;
00438 case NOTIFY_3DAYS:
00439 $period = 3*24*60*60;
00440 break;
00441 case NOTIFY_4DAYS:
00442 $period = 4*24*60*60;
00443 break;
00444 case NOTIFY_5DAYS:
00445 $period = 5*24*60*60;
00446 break;
00447 case NOTIFY_1WEEK:
00448 $period = 7*24*60*60;
00449 break;
00450 case NOTIFY_2WEEKS:
00451 $period = 2*7*24*60*60;
00452 break;
00453 case NOTIFY_3WEEKS:
00454 $period = 3*7*24*60*60;
00455 break;
00456 case NOTIFY_1MONTH:
00457 $period = 4*7*24*60*60;
00458 break;
00459 case NOTIFY_2MONTH:
00460 $period = 2*4*7*24*60*60;
00461 break;
00462 }
00463
00464 $notify_date = $ip[0]->notify_date;
00465
00466 if($notify_date != '0000-00-00 00:00:00'){
00467 $send_date = strToGMTime($notify_date) + $period;
00468 $current_date = time();
00469 if($send_date > $current_date){
00470 $days = round(($send_date - $current_date) / 60 / 60 / 24);
00471 print "<td>". sprintf(__('in %s day(s)'), $days) . "</td>";
00472 }
00473 else{
00474 $days = round(($current_date - $send_date) / 60 / 60 / 24);
00475 print "<td>". sprintf(__('since %s day(s)'), $days) . "</td>";
00476 }
00477 }
00478 else{
00479 print "<td> </td>";
00480 }
00481 }
00482 else{
00483 print "<td> </td>";
00484 }
00485 }
00486 }
00491 class ListBlockCol_ItemModified extends ListBlockCol
00492 {
00493
00494 public function __construct($args=NULL)
00495 {
00496 parent::__construct($args);
00497 $this->name = __('Modified');
00498 $this->width = '10%';
00499 }
00500
00501
00502 function render_tr(&$item, $style="")
00503 {
00504 global $PH;
00505 $str_date = '';
00506 $str_name = '';
00507 $str_url = '';
00508
00509 if($i = DbProjectItem::getById($item->id)){
00510 if($i->modified){
00511 $mod_date = $i->modified;
00512 $str_date = renderDateHtml($mod_date);
00513 if($i->modified_by){
00514 if($person = Person::getVisibleById($i->modified_by)){
00515 $str_name = asHtml($person->name);
00516 $str_url = $person->getLink();
00517 }
00518 }
00519 print '<td><span class=date>'. $str_date .'</span><br><span class="sub who">by '. $str_url .'</span></td>';
00520 }
00521 else{
00522 print "<td class='nowrap'> </td>";
00523 }
00524 }
00525 else{
00526 $PH->abortWarning("Could not get modification date of the element.",ERROR_BUG);
00527 print "<td class='nowrap'> </td>";
00528 }
00529
00530 }
00531 }
00532
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778 ?>