pages/home.inc.php

Go to the documentation of this file.
00001 <?php if(!function_exists('startedIndexPhp')) { header("location:../index.php"); exit();}
00002 # streber - a php5 based project management system  (c) 2005-2007  / www.streber-pm.org
00003 # Distributed under the terms and conditions of the GPL as stated in lang/license.html
00004 
00012 require_once(confGet('DIR_STREBER') . 'db/class_task.inc.php');
00013 require_once(confGet('DIR_STREBER') . 'db/class_project.inc.php');
00014 require_once(confGet('DIR_STREBER') . 'render/render_list.inc.php');
00015 require_once(confGet('DIR_STREBER') . 'render/render_form.inc.php');
00016 require_once(confGet('DIR_STREBER') . 'lists/list_tasks.inc.php');
00017 require_once(confGet('DIR_STREBER') . 'lists/list_project_team.inc.php');
00018 
00022 function build_home_options()
00023 {
00024     return array(
00025 
00026         new NaviOption(array(
00027                 'target_id'=>'home',
00028                 'name'=>__('Today')
00029             )),
00030             new NaviOption(array(
00031                 'target_id'     =>'homeAllChanges',
00032                 'name'=>__('Changes'),
00033             ))
00034     );
00035 }
00036 
00037 
00038 
00039 
00043 function home() {
00044     global $PH;
00045     global $auth;
00046 
00047     ### create from handle ###
00048     $PH->defineFromHandle(array());
00049 
00050     ### set up page ####
00051     {
00052         $page= new Page();
00053         $page->cur_tab='home';
00054         $page->options=build_home_options();
00055 
00056         $page->title=__("Today"); # $auth->cur_user->name;
00057         $page->type=__("At Home");
00058         $page->title_minor=renderTitleDate(time());
00059         echo(new PageHeader);
00060     }
00061     echo (new PageContentOpen_Columns);
00062     measure_stop('init2');
00063 
00064 
00065     #--- functions block ------------
00066     {
00067         $block=new PageBlock(array(
00068             'title' =>__('Functions'),
00069             'id'    =>'functions'
00070         ));
00071         $block->render_blockStart();
00072         echo "<div class=text>";
00073 
00074         ### write functions ###
00075         $function_links=array();
00076         $function_links[]=$PH->getLink('projNew','',array());
00077         $function_links[]=$PH->getLink('companyNew','',array());
00078         $function_links[]=$PH->getLink('personNew','',array());
00079         $function_links[]=$PH->getLink('personViewEfforts',__('View your efforts'),array('person'=>$auth->cur_user->id));
00080         $function_links[]=$PH->getLink('personEdit',__('Edit your profile'),array('person'=>$auth->cur_user->id));
00081         $function_links[]=$PH->getLink('personAllItemsViewed','',array('person' => $auth->cur_user->id));
00082 
00083         if($function_links) {
00084 
00085             echo "<ul>";
00086             foreach($function_links as $f){
00087                 if($f) {
00088                     echo "<li>$f" ;
00089                 }
00090             }
00091             echo "</ul>";
00092         }
00093         echo "</div>";
00094 
00095         $block->render_blockEnd();
00096     }
00097 
00098     #--- list projects --------------------------------------------------------
00099     {
00100         require_once(confGet('DIR_STREBER') . 'lists/list_projects.inc.php');
00101         #$projects=Project::getActive($order_str);
00102         $list= new ListBlock_projects();
00103         $list->reduced_header= true;
00104 
00105         unset($list->functions['projNewFromTemplate']);
00106         unset($list->columns['status']);
00107         unset($list->columns['persons']);
00108         unset($list->columns['status_summary']);
00109         unset($list->columns['efforts']);
00110         unset($list->columns['date_start']);
00111         unset($list->columns['date_closed']);
00112         $list->show_functions=false;
00113         $list->title=__('Projects');
00114         $list->reduced_header= false;
00115 
00116         $list->query_options['status_min']= STATUS_UPCOMING;
00117         $list->query_options['status_max']= STATUS_OPEN;
00118 
00119 
00120         if($auth->cur_user->user_rights & RIGHT_VIEWALL) {
00121             $warning="";
00122             if(! ($auth->cur_user->user_rights & RIGHT_VIEWALL)) {
00123                 $warning=__("<b>NOTE</b>: Some projects are hidden from your view. Please ask an administrator to adjust you rights to avoid double-creation of projects");
00124             }
00125 
00126             $list->no_items_html= $PH->getLink('projNew',__('create new project'),array()). $warning;
00127         }
00128         else {
00129             $list->no_items_html= __("not assigned to a project");
00130         }
00131 
00132         $list->print_automatic();
00133     }
00134 
00135     echo(new PageContentNextCol);
00136 
00137     #--- list tasks -------------------------------------------------------------
00138     if($show_tasks = $auth->cur_user->show_tasks_at_home) {
00139         measure_start('get_tasks');
00140 
00141         $order_str=get('sort_'.$PH->cur_page->id.'_home_tasks');
00142         $tasks= Task::getHomeTasks($order_str);
00143 
00144         measure_stop('get_tasks');
00145         measure_start('list_tasks');
00146 
00147 
00148         $list_tasks= new ListBlock(array(
00149             'id' => 'tasks'
00150         ));
00151         $list_tasks->show_functions=false;
00152         $list_tasks->no_items_html=__("You have no open tasks");
00153 
00154         switch($show_tasks) {
00155             case SHOW_NOTHING:
00156             case SHOW_ASSIGNED_ONLY:
00157                 $list_tasks->title=__("Open tasks assigned to you");
00158                 break;
00159             case SHOW_ALSO_UNASSIGNED:
00160                 $list_tasks->title=__("Open tasks (including unassigned)");
00161                 break;
00162             case SHOW_ALL_OPEN:
00163                 $list_tasks->title=__("All open tasks");
00164                 break;
00165 
00166             default:
00167                 trigger_error("Undefined value '$show_tasks' for show tasks at home", E_USER_WARNING);
00168         }
00169 
00170         #--- columns ---
00171         $list_tasks->add_col( new ListBlockColSelect());
00172         #$list_tasks->add_col( new ListBlockCol(array(
00173         #   'key'=>'_select_col_',
00174         #   'name'=>"S",
00175         #   'tooltip'=>__("Select lines to use functions at end of list"),
00176         #)));
00177         $list_tasks->add_col( new ListBlockColPrio(array(
00178             'key'=>'prio',
00179             'name'=>__('P','column header'),
00180             'tooltip'=>__('Priority'),
00181             'sort'=>1,
00182             'width'=>1,
00183         )));
00184         #$list_tasks->add_col( new ListBlockColStatus(array(
00185         #   'key'=>'status',
00186         #   'name'=>__('S','column header'),
00187         #   'tooltip'=>__('Task-Status'),
00188         #   'sort'=>0,
00189         #    'width'=>1,
00190         #)));
00191         $list_tasks->add_col( new ListBlockCol_TaskLabel);
00192         $list_tasks->add_col(new ListBlockColMethod(array(
00193             'key'=>'project',
00194             'name'=>__('Project','column header'),
00195             'func'=>'getProjectLink'
00196         )));
00197         $list_tasks->add_col(new ListBlockColMethod(array(
00198             'key'=>'parent_task',
00199             'name'=>__('Folder','column header'),
00200             'func'=>'getFolderLinks',
00201             'width'=>'30%'
00202         )));
00203         /*$list_tasks->add_col( new ListBlock_ColHtml(array(
00204             'key'=>'name',
00205             'name'=>"Task",
00206             'tooltip'=>"Task name. More Details as tooltips",
00207             'width'=>'90%',
00208             'sort'=>0,
00209             'format'=>'<a href="index.php?go=taskView&tsk={?id}">{?name}</a>'
00210         )));*/
00211 
00212         $list_tasks->add_col( new ListBlockCol_TaskName);
00213         #$list_tasks->add_col( new ListBlockCol_TaskCreatedBy(array('use_short_names'=>false,'indention'=>true)));
00214 
00215         $list_tasks->add_col( new listBlockColDate(array(
00216             'key'=>'modified',
00217             'name'=>__('Modified','column header')
00218         )));
00219 
00220 
00221 
00222         $list_tasks->add_col( new ListBlockCol_DaysLeft);
00223         #$list_tasks->add_col( new ListBlockColTime(array(
00224         #   'key'=>'estimated',
00225         #   'name'=>__('Est.','column header estimated time'),
00226         #   'tooltip'=>__('Estimated time in hours'),
00227         #)));
00228 
00229         /* functions don't work
00230         $list_tasks->add_col( new ListBlockColFormat(array(
00231             'name'=>"FN",
00232             'tooltip'=>"Function for tasks.",
00233             'width'=>'1',
00234             'sort'=>0,
00235             'format'=>'<nobr><a href="index.php?go=tasksDelete&tsk={?id}" title="Delete this task"> X </a>'.
00236             '<a href="index.php?go=taskEdit&tsk={?id}" title="Edit this task"> E </a>'.
00237             '<a href="index.php?go=tasksComplete&tsk={?id}" title="Mark as done"> � </a></nobr>'
00238         )));
00239         */
00240 
00241         #--- functions -------
00242         $list_tasks->add_function(new ListFunction(array(
00243             'target'=>$PH->getPage('taskEdit')->id,
00244             'name'  =>__('Edit','context menu function'),
00245             'id'    =>'taskEdit',
00246             'icon'  =>'edit',
00247             'context_menu'=>'submit',
00248         )));
00249         $list_tasks->add_function(new ListFunction(array(
00250             'target'=>$PH->getPage('tasksComplete')->id,
00251             'name'  =>__('status->Completed','context menu function'),
00252             'id'    =>'tasksCompleted',
00253             'icon'  =>'complete',
00254             'context_menu'=>'submit',
00255         )));
00256 
00257         $list_tasks->add_function(new ListFunction(array(
00258             'target'=>$PH->getPage('tasksApproved')->id,
00259             'name'  =>__('status->Approved','context menu function'),
00260             'id'    =>'tasksApproved',
00261             'icon'  =>'approve',
00262             'context_menu'=>'submit',
00263         )));
00264 
00265         $list_tasks->add_function(new ListFunction(array(
00266             'target'=>$PH->getPage('tasksClosed')->id,
00267             'name'  =>__('status->Closed','context menu function'),
00268             'id'    =>'tasksClosed',
00269             'icon'  =>'close',
00270             'context_menu'=>'submit',
00271         )));
00272 
00273         /*
00274         $list_tasks->add_function(new ListFunction(array(
00275             'target'=>$PH->getPage('tasksDelete')->id,
00276             'name'  =>__('Delete','context menu function'),
00277             'id'    =>'tasksDelete',
00278             'icon'  =>'delete',
00279             'context_menu'=>'submit',
00280         )));
00281         */
00282         $list_tasks->add_function(new ListFunction(array(
00283             'target'=>$PH->getPage('effortNew')->id,
00284             'name'  =>__('Log hours for select tasks','context menu function'),
00285             'id'    =>'effortNew',
00286             'icon'    =>'loghours',
00287             'context_menu'=>'submit'
00288         )));
00289 
00290 
00291         $list_tasks->render_header();
00292         if($tasks || !$list_tasks->no_items_html) {
00293             $list_tasks->render_thead();
00294             if($tasks) {
00295                 $count_estimated=0;
00296                 foreach($tasks as $t) {
00297                     $style="";
00298                     $style.=($t->category == TCATEGORY_FOLDER)
00299                         ?' isFolder'
00300                         :'';
00301 
00302                     ### done ###
00303                     if($t->status>3) {
00304                         $style.='isDone';
00305                     }
00306                     else {
00307                         $count_estimated+=$t->estimated/60/60 * 1.0;
00308                     }
00309                     $list_tasks->render_trow(&$t,$style);
00310                 }
00311             }
00312             $list_tasks->summary=sprintf(__("%s tasks with estimated %s hours of work"),count($tasks),$count_estimated);
00313             $list_tasks->render_tfoot();
00314         }
00315         else {
00316             $list_tasks->render_tfoot_empty();
00317         }
00318         measure_stop('list_tasks');
00319     }
00320 
00321     ### list bookmarks ###
00322     {
00323         require_once(confGet('DIR_STREBER') . 'lists/list_bookmarks.inc.php');
00324         $list_bookmarks = new ListBlock_bookmarks();
00325         $list_bookmarks->print_automatic();
00326     }
00327 
00328     echo (new PageContentClose);
00329     echo (new PageHtmlEnd);
00330 }
00331 
00332 
00333 
00337 function homeAllChanges()
00338 {
00339     global $PH;
00340     global $auth;
00341 
00342     ### create from handle ###
00343     //$PH->defineFromHandle();
00344 
00345     ### sets the presets ###
00346     $presets= array(
00347         ## last logout ##
00348         'last_logout' => array(
00349             'name'=> __('last logout'),
00350             'filters'=> array(
00351                 'last_logout'   => array(
00352                     'id'        => 'last_logout',
00353                     'visible'   => true,
00354                     'active'    => true,
00355                     'value'     => $auth->cur_user->id,
00356                 ),
00357             ),
00358             'list_settings' => array(
00359                 'changes' =>array(
00360                     'hide_columns'  => array(''),
00361                     'style'=> 'list',
00362                 )
00363             ),
00364         ),
00365         ## today ##
00366         'today' => array(
00367             'name'=> __('today'),
00368             'filters'=> array(
00369                 'today'   => array(
00370                     'id'        => 'today',
00371                     'visible'   => true,
00372                     'active'    => true,
00373                     'value'     => $auth->cur_user->id,
00374                 ),
00375             ),
00376             'list_settings' => array(
00377                 'changes' =>array(
00378                     'hide_columns'  => array(''),
00379                     'style'=> 'list',
00380                 )
00381             ),
00382         ),
00383         ## yesterday ##
00384         'yesterday' => array(
00385             'name'=> __('yesterday'),
00386             'filters'=> array(
00387                 'yesterday'   => array(
00388                     'id'        => 'yesterday',
00389                     'visible'   => true,
00390                     'active'    => true,
00391                     'factor'    => 1,
00392                     'value'     => $auth->cur_user->id,
00393                 ),
00394             ),
00395             'list_settings' => array(
00396                 'changes' =>array(
00397                     'hide_columns'  => array(''),
00398                     'style'=> 'list',
00399                 )
00400             ),
00401         ),
00402         ## 1 week ##
00403         'last_week' => array(
00404             'name'=> __('1 week'),
00405             'filters'=> array(
00406                 'last_week'   => array(
00407                     'id'        => 'last_week',
00408                     'visible'   => true,
00409                     'active'    => true,
00410                     'factor'    => 7,
00411                     'value'     => $auth->cur_user->id,
00412                 ),
00413             ),
00414             'list_settings' => array(
00415                 'changes' =>array(
00416                     'hide_columns'  => array(''),
00417                     'style'=> 'list',
00418                 )
00419             ),
00420         ),
00421         ## 2 weeks ##
00422         'last_two_weeks' => array(
00423             'name'=> __('2 weeks'),
00424             'filters'=> array(
00425                 'last_two_weeks'   => array(
00426                     'id'        => 'last_two_weeks',
00427                     'visible'   => true,
00428                     'active'    => true,
00429                     'factor'    => 14,
00430                     'value'     => $auth->cur_user->id,
00431                 ),
00432             ),
00433             'list_settings' => array(
00434                 'changes' =>array(
00435                     'hide_columns'  => array(''),
00436                     'style'=> 'list',
00437                 )
00438             ),
00439         )
00440     );
00441 
00442     ## set preset location ##
00443     $preset_location = 'homeAllChanges';
00444 
00445      ### get preset-id ###
00446     {
00447         $preset_id = 'last_two_weeks';                           # default value
00448         if($tmp_preset_id = get('preset')) {
00449             if(isset($presets[$tmp_preset_id])) {
00450                 $preset_id = $tmp_preset_id;
00451             }
00452 
00453             ### set cookie
00454             setcookie(
00455                 'STREBER_homeAllChanges_preset',
00456                 $preset_id,
00457                 time()+60*60*24*30,
00458                 '',
00459                 '',
00460                 0);
00461         }
00462         else if($tmp_preset_id = get('STREBER_homeAllChanges_preset')) {
00463             if(isset($presets[$tmp_preset_id])) {
00464                 $preset_id = $tmp_preset_id;
00465             }
00466         }
00467     }
00468 
00469     ### create from handle ###
00470     $PH->defineFromHandle(array('preset_id'=>$preset_id));
00471 
00472     ### set up page ####
00473 
00474     $page= new Page();
00475 
00476     #$list = new ListBlock_AllChanges();
00477     require_once(confGet('DIR_STREBER') . 'lists/list_changes.inc.php');
00478     $list = new ListBlock_Changes();
00479     #$list->query_options['']
00480     #require_once(confGet('DIR_STREBER') . './lists/list_changes.inc.php');
00481 
00482     #$list= new ListBlock_changes();
00483 
00484 
00485     $list->filters[] = new ListFilter_changes();
00486     {
00487         $preset = $presets[$preset_id];
00488         foreach($preset['filters'] as $f_name=>$f_settings) {
00489             switch($f_name) {
00490                 case 'last_logout':
00491                     $list->filters[]= new ListFilter_last_logout(array(
00492                         'value'=>$f_settings['value'],
00493                     ));
00494                     break;
00495                 /*case 'today':
00496                     $list->filters[]= new ListFilter_today(array(
00497                         'value'=>$f_settings['value'],
00498                     ));
00499                     break;*/
00500                 case 'today':
00501                     $list->filters[]= new ListFilter_min_week(array(
00502                         'value'=>$f_settings['value'], 'factor'=>0
00503                     ));
00504                     $list->filters[]= new ListFilter_max_week(array(
00505                         'value'=>$f_settings['value'],
00506                     ));
00507                     break;
00508                 case 'yesterday':
00509                     $list->filters[]= new ListFilter_min_week(array(
00510                         'value'=>$f_settings['value'], 'factor'=>$f_settings['factor']
00511                     ));
00512                     $list->filters[]= new ListFilter_max_week(array(
00513                         'value'=>$f_settings['value'],
00514                     ));
00515                     break;
00516                 case 'last_week':
00517                     $list->filters[]= new ListFilter_min_week(array(
00518                         'value'=>$f_settings['value'], 'factor'=>$f_settings['factor']
00519                     ));
00520                     $list->filters[]= new ListFilter_max_week(array(
00521                         'value'=>$f_settings['value'],
00522                     ));
00523                     break;
00524                 case 'last_two_weeks':
00525                     $list->filters[]= new ListFilter_min_week(array(
00526                         'value'=>$f_settings['value'], 'factor'=>$f_settings['factor']
00527                     ));
00528                     $list->filters[]= new ListFilter_max_week(array(
00529                         'value'=>$f_settings['value'],
00530                     ));
00531                     break;
00532                 default:
00533                     trigger_error("Unknown filter setting $f_name", E_USER_WARNING);
00534                     break;
00535             }
00536         }
00537 
00538         $filter_empty_folders =  (isset($preset['filter_empty_folders']) && $preset['filter_empty_folders'])
00539                               ? true
00540                               : NULL;
00541     }
00542 
00543 
00544 
00545     $page->cur_tab = 'home';
00546     $page->options = build_home_options();
00547 
00548     $page->title = __("Changes");
00549     $page->type = __('List','page type');
00550     $page->title_minor = renderTitleDate(time());
00551 
00552     echo(new PageHeader);
00553     echo (new PageContentOpen);
00554 
00555     $page->print_presets(array(
00556     'target' => $preset_location,
00557     'project_id' => '',
00558     'preset_id' => $preset_id,
00559     'presets' => $presets,
00560     'person_id' => ''));
00561 
00562     #echo(new PageContentNextCol);
00563 
00564 
00565     $list->print_automatic();
00566 
00567     echo (new PageContentClose);
00568     echo (new PageHtmlEnd);
00569 
00570 }
00571 
00572 
00573 ?>

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