lists/list_bookmarks.inc.php

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         /*$bookmark_items = ItemPerson::getAll(array(
00077             'person'        =>$auth->cur_user->id,
00078             'is_bookmark'   =>1,
00079             'order_by'      =>$order_by
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>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</td>";
00480             }
00481         }
00482         else{
00483             print "<td>&nbsp;</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'>&nbsp;</td>";
00523             }
00524         }
00525         else{
00526             $PH->abortWarning("Could not get modification date of the element.",ERROR_BUG);
00527             print "<td class='nowrap'>&nbsp;</td>";
00528         }
00529 
00530     }
00531 }
00532 
00537 /*class ListBlockCol_ItemStatus extends ListBlockCol
00538 {
00539 
00540     public function __construct($args=NULL)
00541     {
00542         parent::__construct($args);
00543         $this->name = __('Status');
00544         $this->width = '5%';
00545     }
00546 
00547 
00548     function render_tr(&$item, $style="")
00549     {
00550         global $g_status_names;
00551         global $PH;
00552 
00553         $str_name = "";
00554         if($type = $item->type){
00555             switch($type) {
00556                 case ITEM_TASK:
00557                     require_once("db/class_task.inc.php");
00558                     if($task = Task::getVisibleById($item->id)) {
00559                         $str_name = asHtml($g_status_names[$task->status]);
00560                         if($task->status >= STATUS_COMPLETED){
00561                             $str_name = "<span class=isDone>" . $str_name . "</span>";
00562                         }
00563                     }
00564                     break;
00565 
00566                 case ITEM_COMMENT:
00567                     $str_name = '';
00568                     break;
00569 
00570                 case ITEM_PERSON:
00571                     $str_name = '';
00572                     break;
00573 
00574                 case ITEM_EFFORT:
00575                     $str_name = '';
00576                     break;
00577 
00578                 case ITEM_FILE:
00579                     require_once("db/class_file.inc.php");
00580                     if($f = File::getVisibleById($item->id)) {
00581                         $str_name = asHtml($g_status_names[$f->status]);
00582                         if($f->status >= STATUS_COMPLETED){
00583                             $str_name = "<span class=isDone>" . $str_name . "</span>";
00584                         }
00585                     }
00586                     break;
00587 
00588                 case ITEM_PROJECT:
00589                     require_once("db/class_project.inc.php");
00590                     if($prj = Project::getVisibleById($item->id)) {
00591                         $str_name = asHtml($g_status_names[$prj->status]);
00592                         if($prj->status >= STATUS_COMPLETED){
00593                             $str_name = "<span class=isDone>" . $str_name . "</span>";
00594                         }
00595                     }
00596                     break;
00597 
00598                 case ITEM_COMPANY:
00599                     $str_name = '';
00600                     break;
00601 
00602                 case ITEM_VERSION:
00603                     require_once("db/class_task.inc.php");
00604                     if($tsk = Task::getVisibleById($item->id)) {
00605                         $str_name = asHtml($g_status_names[$tsk->status]);
00606                         if($tsk->status >= STATUS_COMPLETED){
00607                             $str_name = "<span class=isDone>" . $str_name . "</span>";
00608                         }
00609                     }
00610                     break;
00611 
00612                 default:
00613                     break;
00614             }
00615 
00616             print "<td>$str_name</td>";
00617         }
00618         else{
00619             $PH->abortWarning("Could not get the status of the element.",ERROR_BUG);
00620             print "<td>&nbsp;</td>";
00621         }
00622     }
00623 }*/
00624 
00629 /*class ListBlockCol_ItemProjectName extends ListBlockCol
00630 {
00631 
00632     public function __construct($args=NULL)
00633     {
00634         parent::__construct($args);
00635         $this->name = __('Project');
00636         $this->width = '14%';
00637     }
00638 
00639     function render_tr(&$item, $style="")
00640     {
00641         global $PH;
00642 
00643         $link = "";
00644         $isDone = "";
00645         if($type = $item->type){
00646             switch($type) {
00647                 case ITEM_TASK:
00648                     require_once("db/class_task.inc.php");
00649                     if($task = Task::getVisibleById($item->id)) {
00650                         if($prj = Project::getVisibleById($task->project)) {
00651                             $link = $PH->getLink('projView',$prj->getShort(),array('prj'=>$prj->id));
00652                             if($task->status >= STATUS_COMPLETED){
00653                                 $isDone = "class=isDone";
00654                             }
00655                         }
00656                     }
00657                     break;
00658 
00659                 case ITEM_EFFORT:
00660                     require_once("db/class_effort.inc.php");
00661                     if($e = Effort::getVisibleById($item->id)) {
00662                         if($prj = Project::getVisibleById($e->project)) {
00663                             $link = $PH->getLink('projView',$prj->getShort(),array('prj'=>$prj->id));
00664                         }
00665                     }
00666                     break;
00667 
00668                 case ITEM_FILE:
00669                     require_once("db/class_file.inc.php");
00670                     if($f = File::getVisibleById($item->id)) {
00671                         if($prj = Project::getVisibleById($f->project)) {
00672                             $link = $PH->getLink('projView',$prj->getShort(),array('prj'=>$prj->id));
00673                         }
00674                     }
00675                     break;
00676 
00677                 case ITEM_VERSION:
00678                     require_once("db/class_task.inc.php");
00679                     if($task = Task::getVisibleById($item->id)) {
00680                         if($prj = Project::getVisibleById($task->project)) {
00681                             $link = $PH->getLink('projView',$prj->getShort(),array('prj'=>$prj->id));
00682                             if($task->status >= STATUS_COMPLETED){
00683                                 $isDone = "class=isDone";
00684                             }
00685                         }
00686                     }
00687                     break;
00688 
00689                 case ITEM_PROJECT:
00690                     require_once("db/class_project.inc.php");
00691                     if($prj = Project::getVisibleById($item->id)) {
00692                         $link = '';
00693                     }
00694                     break;
00695                 default:
00696                     break;
00697 
00698             }
00699             print "<td><span $isDone>$link</td>";
00700         }
00701         else{
00702             $PH->abortWarning("Could not get project name of the element.",ERROR_BUG);
00703             print "<td>&nbsp;</td>";
00704         }
00705     }
00706 }*/
00707 
00712 /*class ListBlockCol_ItemState extends ListBlockCol
00713 {
00714 
00715     public function __construct($args=NULL)
00716     {
00717         parent::__construct($args);
00718         $this->name = __('State');
00719         $this->width = '1%';
00720     }
00721 
00722 
00723     function render_tr(&$item, $style=""){
00724         if($s = $item->state){
00725             if(isset($s) && $s == -1){
00726                  print '<td><img src="' . getThemeFile("icons/delete.gif") . '"></td>';
00727             }
00728             else{
00729                  print "<td>&nbsp;</td>";
00730             }
00731         }
00732         else{
00733             $PH->abortWarning("Could not get item.",ERROR_BUG);
00734             print "<td>&nbsp;</td>";
00735         }
00736     }
00737 }*/
00738 
00739 
00740 
00745 /*class ListBlockCol_ItemModifier extends ListBlockCol
00746 {
00747 
00748     public function __construct($args=NULL)
00749     {
00750         parent::__construct($args);
00751         $this->name = __('Modified by');
00752         $this->width = '15%';
00753     }
00754 
00755 
00756     function render_tr(&$item, $style="")
00757     {
00758         global $PH;
00759         $str_name = '';
00760         $str_url = '';
00761 
00762         if($i = DbProjectItem::getById($item->id)){
00763             if($i->modified_by){
00764                 if($person = Person::getVisibleById($i->modified_by)){
00765                     $str_name = asHtml($person->name);
00766                     $str_url = $PH->getUrl('personView',array('person'=>$person->id));
00767                 }
00768             }
00769             print "<td><a href='$str_url'>$str_name</a></td>";
00770         }
00771         else{
00772             $PH->abortWarning("Could not get modifier of the element.",ERROR_BUG);
00773             print "<td>&nbsp;</td>";
00774         }
00775 
00776     }
00777 }*/
00778 ?>

Generated on Sun Mar 4 17:19:30 2007 for streber by  doxygen 1.5.1-p1