pages/project_view.inc.php

00001 <?php if(!function_exists('startedIndexPhp')) { header("location:../index.php"); exit();}
00002 
00003 # streber - a php based project management system
00004 # Copyright (c) 2005 Thomas Mann - thomas@pixtur.de
00005 # Distributed under the terms and conditions of the GPL as stated in docs/license.txt
00006 
00016 require_once(confGet('DIR_STREBER') . "db/class_task.inc.php");
00017 require_once(confGet('DIR_STREBER') . "db/class_project.inc.php");
00018 require_once(confGet('DIR_STREBER') . "db/class_projectperson.inc.php");
00019 require_once(confGet('DIR_STREBER') . "db/db_itemperson.inc.php");
00020 require_once(confGet('DIR_STREBER') . "render/render_list.inc.php");
00021 require_once(confGet('DIR_STREBER') . "lists/list_taskfolders.inc.php");
00022 require_once(confGet('DIR_STREBER') . "lists/list_comments.inc.php");
00023 require_once(confGet('DIR_STREBER') . "lists/list_tasks.inc.php");
00024 require_once(confGet('DIR_STREBER') . "lists/list_project_team.inc.php");
00025 
00026 
00027 
00028 
00029 
00030 #---------------------------------------------------------------------------
00031 # view Project
00032 #---------------------------------------------------------------------------
00033 function ProjView()
00034 {
00035     global $PH;
00036     global $auth;
00037     require_once(confGet('DIR_STREBER') . "render/render_wiki.inc.php");
00038 
00039 
00040     ### get current project ###
00041     $id=getOnePassedId('prj','projects_*');
00042     if($project= Project::getEditableById($id)) {
00043         $editable= true;        
00044     }
00045     else if ($project= Project::getVisibleById($id)) {
00046         $editable= false;        
00047     }
00048     else {
00049         $PH->abortWarning(__("invalid project-id"));
00050         return;
00051     }
00052 
00053     ### define from-handle ###
00054     $PH->defineFromHandle(array('prj'=>$project->id));
00055 
00056     ## is viewed by user ##
00057     $project->nowViewedByUser();
00058 
00059     ## next milestone ##
00060     $next=$project->getNextMilestone();
00061 
00062     ### set up page ####
00063     {
00064         $page= new Page();
00065 
00066         $page->crumbs= build_project_crumbs($project);
00067         $page->options= build_projView_options($project);
00068 
00069         $page->cur_tab='projects';
00070         $page->title=$project->name;
00071         $page->title_minor=__("Overview");
00072 
00073         if($project->status == STATUS_TEMPLATE) {
00074             $page->type=__("Project Template");
00075         }
00076         else if ($project->status >= STATUS_COMPLETED){
00077             $page->type=__("Inactive Project");
00078         }
00079         else {
00080             $page->type=__("Project","Page Type");
00081         }
00082 
00083         ### page functions ###
00084         
00085         if($editable) {
00086             $page->add_function(new PageFunctionGroup(array(
00087                 'name'      => __('edit:')
00088             )));
00089             $page->add_function(new PageFunction(array(
00090                 'target'    =>'projEdit',
00091                 'params'    =>array('prj'=>$project->id),
00092                 'icon'      =>'edit',
00093                 'tooltip'   =>__('Edit this project'),
00094                 'name'      => __('Project')
00095     
00096             )));
00097         }
00098 
00099         /*
00100         $item = ItemPerson::getAll(array('person'=>$auth->cur_user->id,'item'=>$project->id));
00101         if((!$item) || ($item[0]->is_bookmark == 0)){
00102             $page->add_function(new PageFunction(array(
00103                 'target'    =>'itemsAsBookmark',
00104                 'params'    =>array('proj'=>$project->id),
00105                 'tooltip'   =>__('Mark this project as bookmark'),
00106                 'name'      =>__('Bookmark'),
00107             )));
00108         }
00109         else{
00110             $page->add_function(new PageFunction(array(
00111                 'target'    =>'itemsRemoveBookmark',
00112                 'params'    =>array('proj'=>$project->id),
00113                 'tooltip'   =>__('Remove this bookmark'),
00114                 'name'      =>__('Remove Bookmark'),
00115             )));
00116         }
00117         */
00118 
00119         /*
00120         if($project->state == 1) {
00121                 $page->add_function(new PageFunction(array(
00122                     'target'=>'projDelete',
00123                     'params'=>array('prj'=>$project->id),
00124                     'icon'=>'delete',
00125                     'tooltip'=>__('Delete this project'),
00126                     'name'=>__('Delete')
00127                 )));
00128         }
00129         */
00130 
00131 
00132         $page->add_function(new PageFunctionGroup(array(
00133             'name'      => __('new:')
00134         )));
00135         /*
00136         $page->add_function(new PageFunction(array(
00137             'target'    =>'projAddPerson',
00138             'params'    =>array('prj'=>$project->id),
00139             'icon'      =>'add',
00140             'tooltip'   =>__('Add person as team-member to project'),
00141             'name'      =>__('Team member')
00142         )));
00143         */
00144         $page->add_function(new PageFunction(array(
00145             'target'    =>'taskNew',
00146             'params'    =>array('prj'=>$project->id),
00147             'icon'      =>'new',
00148             'tooltip'   =>__('Create task'),
00149             'name'      =>__('Task')
00150         )));
00151         $page->add_function(new PageFunction(array(
00152             'target'    =>'taskNewBug',
00153             'params'    =>array('prj'=>$project->id,'add_issue'=>1),
00154             'icon'      =>'new',
00155             'tooltip'   =>__('Create task with issue-report'),
00156             'name'      =>__('Bug'),
00157         )));
00158         $page->add_function(new PageFunction(array(
00159             'target'    =>'effortNew',
00160             'params'    =>array('prj'=>$project->id),
00161             'icon'      =>'loghours',
00162             'tooltip'   =>__('Book effort for this project'),
00163             'name'      =>__('Effort'),
00164         )));
00165 
00166         $url= $PH->getUrl("projViewAsRSS", array('prj' => $project->id));
00167         $page->extra_header_html.=
00168                 '<link rel="alternate" type="application/rss+xml" title="' .asHtml($project->name) .' '. __("News")  . '"'
00169                 .' href="' . $url . '" />';
00170 
00171         ### render title ###
00172         echo(new PageHeader);
00173     }
00174     echo (new PageContentOpen_Columns);
00175 
00176     measure_stop('init2');
00177     measure_start('info');
00178 
00179     #--- write info-block ------------
00180     {
00181         $block=new PageBlock(array('title'=>__('Details','block title'),'id'=>'summary'));
00182         $block->render_blockStart();
00183         echo "<div class=text>";
00184         /*
00185         if($project->description) {
00186             $diz= wiki2html($project->description, $project);
00187             #$diz=preg_replace("/\n\r/","<br>#",$project->description);
00188             echo "$diz";
00189         }
00190         */
00191 
00192         if($project->company) {
00193             require_once(confGet('DIR_STREBER') . "db/class_company.inc.php");
00194             if( $company= Company::getVisibleById($project->company)) {
00195                 echo "<p><label>".__('Client','label')."</label>". $project->getCompanyLink(true) ."</p>";
00196                 if($company->phone) {
00197                     echo "<p><label>" . __('Phone','label') . "</label>". asHtml($company->phone)."</p>";
00198                 }
00199                 if($company->email) {
00200                     echo "<p><label>" . __('E-Mail','label') . "</label>". url2LinkMail($company->email)."</p>";
00201                 }
00202             }
00203             echo "<br>";
00204         }
00205 
00206 
00207         global $g_status_names;
00208         if($status=$g_status_names[$project->status]) {
00209             $ssummary= $project->status_summary
00210                      ? ' ('. asHtml($project->status_summary).')'
00211                      : '';
00212 
00213             echo "<p><label>".__("Status","Label in summary").'</label>'. asHtml($status) . $ssummary. '</p>';
00214         }
00215 
00216 
00217         if($project->wikipage) {
00218             echo "<p><label>".__("Wikipage","Label in summary")."</label>".url2linkExtern($project->wikipage)."</p>";
00219         }
00220 
00221         if($project->projectpage) {
00222             echo "<p><label>".__("Projectpage","Label in summary")."</label>".url2linkExtern($project->projectpage)."</p>";
00223         }
00224 
00225 
00226         if($project->date_start !="0000-00-00") {
00227             echo "<p><label>".__("Opened","Label in summary")."</label>".renderDateHtml($project->date_start)."</p>";
00228         }
00229 
00230 
00231         if($project->date_closed !="0000-00-00") {
00232             echo "<p><label>".__("Closed","Label in summary")."</label>".renderDateHtml($project->date_closed)."</p>";
00233         }
00234 
00235         if($person_creator= Person::getVisibleById($project->created_by)) {
00236             echo "<p><label>".__("Created by","Label in summary")."</label>".$person_creator->getLink()."</p>" ;
00237         }
00238 
00239         if($project->modified_by != $project->created_by) {
00240             if($person_modify= Person::getVisibleById($project->modified_by)) {
00241                 echo "<p><label>".__("Last modified by","Label in summary")."</label>".$person_modify->getLink()."</p>" ;
00242             }
00243         }
00244 
00245 
00246         $sum_efforts= $project->getEffortsSum();
00247         if($sum_efforts) {
00248             echo "<p><label>" . __("Logged effort") . "</label>"
00249                 .$PH->getLink('projViewEfforts',round($sum_efforts/60/60,1),array('prj'=>$project->id))
00250                 ." ".__("hours")."</p>" ;
00251         }
00252 
00253         $sum_progress= $project->getProgressSum();
00254         if($sum_progress) {
00255             echo "<p><label>" . __("Completed") . "</label><b>"
00256                 .$PH->getLink('projViewTasks',number_format($sum_progress, 1, ',', ''),array('prj'=>$project->id))
00257                 ."%</b></p>" ;
00258         }
00259         $num_tasks= $project->getNumTasks();
00260         if($num_tasks) {
00261             echo "<p><label>" . __("Tasks") . "</label>"
00262                 .$PH->getLink('projViewTasks',$num_tasks,array('prj'=>$project->id))
00263                 ."</p>" ;
00264         }
00265 
00266 
00267 
00268 
00269         echo "</div>";
00270 
00271         $block->render_blockEnd();
00272     }
00273 
00274     measure_stop('info');
00275 
00280     /*
00281     measure_start('folders');
00282 
00283     #--- list folders -----------------------------------------------------------
00284     $list= new ListBlock_taskFolders($project);
00285     $list->render();
00286 
00287     measure_stop('folders');
00288     */
00289     measure_start('team');
00290 
00291     #--- list team -----------------------------------------------------------
00292     {
00293 
00294         $list= new ListBlock_projectTeam();
00295         $list->title= __('Team members');
00296         $list->show_icons=true;
00297         $list->active_block_function = 'list';
00298         $list->print_automatic($project);
00299     }
00300 
00301 
00302 
00303     ### write list of folders ###
00304     /*{
00305         $list= new ListBlock_tasks(array(
00306             'use_short_names'=>true,
00307             'show_summary'  =>false,
00308         ));
00309         $list->title=__('Folders');
00310         $list->query_options['show_folders']= true;
00311         $list->query_options['folders_only']= true;
00312         $list->query_options['project']= $project->id;
00313         $list->groupings= NULL;
00314         $list->block_functions= NULL;
00315         $list->id= 'folders';
00316         $list->show_functions=false;
00317         unset($list->columns['status']);
00318         unset($list->columns['date_start']);
00319         unset($list->columns['days_left']);
00320         unset($list->columns['created_by']);
00321         unset($list->columns['label']);
00322         unset($list->columns['project']);
00323         unset($list->columns['modified']);
00324         unset($list->columns['assigned_to']);
00325         unset($list->columns['planned_start']);
00326         unset($list->columns['pub_level']);
00327         unset($list->columns['prio']);
00328         unset($list->columns['for_milestone']);
00329         unset($list->columns['estimate_complete']);
00330         unset($list->columns['efforts']);
00331 
00332         unset($list->functions['tasksDelete']);
00333         unset($list->functions['tasksCompleted']);
00334         unset($list->functions['taskEdit']);
00335 
00336         #$list->functions= array();
00337 
00338         $list->active_block_function = 'tree';
00339 
00340 
00341         $list->print_automatic($project);
00342     }*/
00343 
00344     ### write docu structure ###
00345     {
00346         require_once(confGet('DIR_STREBER') . 'lists/list_docustructure.inc.php');
00347         if(Task::getDocuTasks($project->id,0)) {
00348             $list=new Block_docuNavigation(array(
00349                 'project_id' => $project->id
00350             ));
00351             $list->print_all();
00352         }
00353     }
00354 
00355 
00356 
00357     echo(new PageContentNextCol);
00358     measure_stop('team');
00359 
00360 
00361     #--- description ----------------------------------------------------------------
00362     if($project->description!="") {
00363         $block=new PageBlock(array(
00364             'title'=>__('Description'),
00365             'id'=>'description',
00366             #'reduced_header'=>true,
00367 
00368         ));
00369         $block->render_blockStart();
00370 
00371         #echo $str;
00372 
00373 
00374         echo "<div class=description>";
00375         if($editable) {
00376             echo  wiki2html($project->description, $project, $project->id, 'description');
00377         }
00378         else {
00379             echo  wiki2html($project->description, $project);
00380         }
00381         echo "</div>";
00382 
00383 
00384         #echo "<div class=text>";
00385 
00386         #echo wiki2html($project->description, $project);
00387 
00388         ### update task if relative links have been converted to ids ###
00389         global $g_wiki_auto_adjusted;
00390         if(isset($g_wiki_auto_adjusted) && $g_wiki_auto_adjusted) {
00391             $project->description= $g_wiki_auto_adjusted;
00392             $project->update(array('description'),false);
00393         }
00394 
00395         #echo "</div>";
00396 
00397         $block->render_blockEnd();
00398     }
00399 
00400     #--- list changes (new) -----------------------------------------------------------
00401     measure_start('changes');
00402     {
00403         require_once(confGet('DIR_STREBER') . './lists/list_changes.inc.php');
00404 
00405         $list= new ListBlock_changes();
00406         $list->query_options['date_min']= $auth->cur_user->last_logout;
00407         $list->query_options['not_modified_by']= $auth->cur_user->id;
00408         $list->query_options['project']= $project->id;
00409         //$list->print_automatic($project);
00410         $list->print_automatic();
00411     }
00412     measure_stop('changes');
00413 
00414 
00415 
00416 
00417 
00418 
00419 
00420     if(confGet("PROJECT_COMMENTS")) {
00421         $order_str=get("sort_".$PH->cur_page->id ."_comments");
00422 
00423         if($auth->cur_user->user_rights & RIGHT_VIEWALL) {
00424             $comments= $project->getComments(array(
00425                 'order_by'=>$order_str,
00426                 'visible_only'=>false,
00427             ));
00428         }
00429         else{
00430             $comments= $project->getComments(array(
00431                 'order_by'=>$order_str,
00432             ));
00433         }
00437         if(count($comments)) {
00438 
00439             $list_comments= new ListBlock_comments();
00440             $list_comments->title=__("Comments on project");
00441             $list_comments->title_append_hidden=
00442                 count($comments)
00443                 ? "(".count($comments).")"
00444                 : '';
00445             $list_comments->no_items_html=$PH->getLink('commentNew','',array('prj'=>$project->id));
00446             $list_comments->render_list(&$comments);
00447         }
00448     }
00449 
00450     echo "<br><br>";                                        # @@@ hack for firefox overflow problems
00451     ### HACKING: 'add new task'-field ###
00452     $PH->go_submit='taskNew';
00453     echo '<input type="hidden" name="prj" value="'.$project->id.'">';
00454 
00455 
00456     ### rss link ###
00457     {
00458         #$rss_url = confGet('SELF_PROTOCOL').'://'.confGet('SELF_URL');
00459         #$rss_url = str_replace("index.php", "rss/", $rss_url);
00460         #$prj_id  = $this->page->options[0]->target_params['prj'];
00461         $url= $PH->getUrl('projViewAsRSS',array('prj'=> $project->id));
00462         echo  "<a style='margin:0px; border-width:0px;' href='{$url}' target='_blank'>"
00463                 ."<img style='margin:0px; border-width:0px;' src='" . getThemeFile("icons/rss_icon.gif") ."'>"
00464                 ."</a>";
00465     }
00466     echo (new PageContentClose);
00467     echo (new PageHtmlEnd());
00468 }
00469 
00470 
00471 
00472 
00473 
00474 
00475 
00476 
00477 ?>

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