lists/list_persons.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 
00016 class ListBlock_persons extends ListBlock
00017 {
00018 
00019     public function __construct($args=NULL)
00020     {
00021         parent::__construct($args);
00022 
00023         $this->id='persons';
00024         $this->bg_style='bg_people';
00025         $this->title=__("Your related persons");
00026 
00027 
00028         $this->add_col( new ListBlockColSelect());
00029         $this->add_col( new ListBlockCol_PersonNickname());
00030 
00031         #$this->add_col( new ListBlockColFormat(array(
00032         #   'key'=>'nickname',
00033         #   'name'=>__("Name Short"),
00034         #   'tooltip'=>__("Shortnames used in other lists"),
00035         #   'sort'=>0,
00036         #   'format'=>'<nobr><a href="index.php?go=personView&amp;person={?id}">{?nickname}</a></nobr>'
00037         #)));
00038 
00039         $this->add_col( new ListBlockCol_PersonName());
00040 
00041         #$this->add_col( new ListBlockColFormat(array(
00042         #   'key'=>'name',
00043         #   'name'=>__("Person"),
00044         #   'tooltip'=>__("Task name. More Details as tooltips"),
00045         #   'sort'=>0,
00046         #   'format'=>'<nobr><span class="item person"><a class="item person" href="index.php?go=personView&amp;person={?id}">{?name}</a></span></nobr>'
00047         #)));
00048 
00049         $this->add_col( new ListBlockCol_PersonProfile());
00050         $this->add_col( new ListBlockColFormat(array(
00051             'key'=>'personal_phone',
00052             'name'=>__("Private"),
00053             'format'=>'<nobr>{?personal_phone}</nobr>'
00054         )));
00055         $this->add_col( new ListBlockColFormat(array(
00056             'key'=>'mobile_phone',
00057             'name'=>__("Mobil"),
00058             'format'=>'<nobr>{?mobile_phone}</nobr>'
00059         )));
00060         $this->add_col( new ListBlockColFormat(array(
00061             'key'=>'office_phone',
00062             'name'=>__("Office"),
00063             'format'=>'<nobr>{?office_phone}</nobr>'
00064         )));
00065         $this->add_col( new ListBlockColFormat(array(
00066             'key'=>'tagline',
00067             'name'=>__("Tagline"),
00068             'format'=>'{?tagline}'
00069         )));
00070         $this->add_col( new ListBlockColMethod(array(
00071             'name'=>__("Companies"),
00072             'func'=>'getCompanyLinks',
00073             'id'=>'companies',
00074         )));
00075         $this->add_col( new ListBlockCol_PersonProjects());
00076         $this->add_col( new ListBlockColDate(array(
00077             'name'=>__("last login"),
00078             'key'=>'last_login',
00079         )));
00080         $this->add_col( new ListBlockCol_PersonChanges());
00081 
00082         /*$this->add_col( new ListBlockCol_ProjectEffortSum);
00083 
00084         $this->add_col( new ListBlockColMethod(array(
00085             'name'=>"Tasks",
00086             'tooltip'=>"Number of open Tasks",
00087             'sort'=>0,
00088             'func'=>'getNumTasks',
00089             'style'=>'right'
00090         )));
00091         $this->add_col( new ListBlockColDate(array(
00092             'key'=>'date_start',
00093             'name'=>"Opened",
00094             'tooltip'=>"Day the Project opened",
00095             'sort'=>0,
00096         )));
00097         $this->add_col( new ListBlockColDate(array(
00098             'key'=>'date_closed',
00099             'name'=>"Closed",
00100             'tooltip'=>"Day the Project state changed to closed",
00101             'sort'=>0,
00102         )));
00103         */
00104 
00105         #---- functions ----
00106         global $PH;
00107         $this->add_function(new ListFunction(array(
00108             'target'=>$PH->getPage('personEdit')->id,
00109             'name'  =>__('Edit person'),
00110             'id'    =>'personEdit',
00111             'icon'  =>'edit',
00112             'context_menu'=>'submit',
00113         )));
00114         $this->add_function(new ListFunction(array(
00115             'target'=>$PH->getPage('personEditRights')->id,
00116             'name'  =>__('Edit User Rights'),
00117             'id'    =>'personEditRights',
00118             'context_menu'=>'submit',
00119         )));
00120         $this->add_function(new ListFunction(array(
00121             'target'=>$PH->getPage('personDelete')->id,
00122             'name'  =>__('Delete person'),
00123             'id'    =>'personDelete',
00124             'icon'  =>'delete'
00125         )));
00126         $this->add_function(new ListFunction(array(
00127             'target'=>$PH->getPage('personNew')->id,
00128             'name'  =>__('Create new person'),
00129             'id'    =>'personNew',
00130             'icon'  =>'new',
00131             'context_menu'=>'submit',
00132         )));
00133         $this->add_function(new ListFunction(array(
00134             'target'=>$PH->getPage('itemsAsBookmark')->id,
00135             'name'  =>__('Mark as bookmark'),
00136             'id'    =>'itemsAsBookmark',
00137             'context_menu'=>'submit',
00138         )));
00139 
00140     }
00141 
00152     public function print_automatic($persons)
00153     {
00154         global $PH;
00155 
00156         #if(!$this->active_block_function=$this->getBlockStyleFromCookie()) {
00157             $this->active_block_function = 'list';
00158         #}
00159 
00160         $this->group_by= get("blockstyle_{$PH->cur_page->id}_{$this->id}_grouping");
00161 
00162 
00163         $s_cookie= "sort_{$PH->cur_page->id}_{$this->id}_{$this->active_block_function}";
00164         if($sort= get($s_cookie)) {
00165             $this->query_options['order_by']= $sort;
00166         }
00167 
00168         ### add filter options ###
00169         #foreach($this->filters as $f) {
00170         #    foreach($f->getQuerryAttributes() as $k=>$v) {
00171         #        $this->query_options[$k]= $v;
00172         #     }
00173         #}
00174 
00175         ### grouped view ###
00176         if($this->active_block_function == 'grouped') {
00177 
00183             if(isset($this->columns[ $this->group_by ])) {
00184                 unset($this->columns[$this->group_by]);
00185             }
00186 
00187             ### prepend key to sorting ###
00188             if(isset($this->query_options['order_by'])) {
00189                 $this->query_options['order_by'] = $this->groupings->getActiveFromCookie() . ",".$this->query_options['order_by'];
00190 
00191             }
00192             else {
00193                 $this->query_options['order_by'] = $this->groupings->getActiveFromCookie();
00194             }
00195         }
00196         ### list view ###
00197         else {
00198             $pass= true;
00199         }
00200 
00201         $this->render_list(&$persons);
00202     }
00203 }
00204 
00205 
00206 
00207 class ListBlockCol_PersonNickname extends ListBlockCol
00208 {
00209     public $id='nickname';
00210     public $key='nickname';
00211 
00212     function __construct($args= NULL)
00213     {
00214         parent::__construct($args);
00215         if(!$this->name) {
00216             $this->name= __('Nickname', 'column header');
00217         }
00218     }
00219 
00220     function render_tr(&$person, $style="")
00221     {
00222         global $PH;
00223         print "<td>". $PH->getLink('personView',asHtml($person->nickname), array('person' => $person->id)) ."</td>";
00224     }
00225 }
00226 
00227 
00228 
00229 class ListBlockCol_PersonName extends ListBlockCol
00230 {
00231     public $id='name';
00232     public $key='name';
00233 
00234     function __construct($args= NULL)
00235     {
00236         parent::__construct($args);
00237         if(!$this->name) {
00238             $this->name= __('Name', 'column header');
00239         }
00240     }
00241 
00242     function render_tr(&$person, $style="")
00243     {
00244         global $PH;
00245 
00246         print "<td><b><nobr>". $PH->getLink('personView',asHtml($person->name), array('person' => $person->id)) ."</b></nobr></td>";
00247     }
00248 }
00249 
00250 
00255 class ListBlockCol_PersonProfile extends ListBlockCol
00256 {
00257     public $id='profile';
00258     public $key='profile';
00259 
00260     function __construct($args= NULL)
00261     {
00262         parent::__construct($args);
00263         if(!$this->name) {
00264             $this->name= __('Profile', 'column header');
00265         }
00266      $this->tooltip=__("Account settings for user (do not confuse with project rights)");
00267 
00268     }
00269     function render_tr(&$person, $style="")
00270     {
00271         global $g_user_profile_names;
00272         global $g_user_profiles;
00273 
00274         $profile_num= $person->profile;
00275         $str_profile= $g_user_profile_names[$profile_num];
00276 
00277         #$default_rights= $g_user_profiles[$g_user_profile_names[$profile_num]]['default_user_rights'];
00278         $default_rights= $g_user_profiles[$profile_num]['default_user_rights'];
00279 
00280         if($default_rights != $person->user_rights) {
00281             $str_profile.=__("(adjusted)");
00282         }
00283 
00284         print "<td>$str_profile</td>";
00285 
00286     }
00287 }
00288 
00289 
00294 class ListBlockCol_PersonProjects extends ListBlockCol
00295 {
00296     public $id='projects';
00297     public $width="70%";
00298 
00299     function __construct($args= NULL)
00300     {
00301         parent::__construct($args);
00302         if(!$this->name) {
00303             $this->name= __('Active Projects', 'column header');
00304         }
00305     }
00306 
00307     function render_tr(&$person, $style="")
00308     {
00309         global $PH;
00310         global $g_prio_names;
00311 
00312         $projects= $person->getProjects();
00313         print "<td>";
00314 
00315         if($projects) {
00316             $str_delimiter="";
00317             foreach($projects as $p){
00318 
00319                 $tooltip="";
00320                 if(isset($g_prio_names[$p->prio])) {
00321                     $tooltip= 'title="' . sprintf(__('Priority is %s'), $g_prio_names[$p->prio]) . '"';
00322                 }
00323                 $img_prio= "<img $tooltip src=\"" . getThemeFile("img/prio_{$p->prio}.png") ."\">";
00324                 $link= $PH->getLink('projView',$p->getShort(),array('prj'=>$p->id));
00325 
00326                 print  $str_delimiter .  $img_prio.$link;
00327 
00328                 $str_delimiter=", ";
00329 
00330             }
00331         }
00332         print "</td>";
00333 
00334     }
00335 }
00336 
00337 
00338 
00339 
00340 class ListBlockCol_PersonChanges extends ListBlockCol
00341 {
00342     public $id='changes';
00343 
00344     function __construct($args= NULL)
00345     {
00346         parent::__construct($args);
00347         if(!$this->name) {
00348             $this->name= __('recent changes', 'column header');
00349         }
00350         $this->tooltip=__('changes since YOUR last logout');
00351     }
00352 
00353     function render_tr(&$person, $style="", $format="html")
00354     {
00355         global $PH;
00356         global $auth;
00357         global $g_prio_names;
00358         global $csv_args;
00359         global $csv_count;
00360 
00361         $changes= DbProjectItem::getAll(array(
00362             'modified_by'   => $person->id,
00363             'date_min'      => $auth->cur_user->last_logout,
00364             'not_modified_by'=> $auth->cur_user->id,
00365         ));
00366 
00367         if($format == 'csv'){
00368             if(count($changes)) {
00369                 $csv_args[$csv_count++] = count($changes);
00370             }
00371             else{
00372                 $csv_args[$csv_count++] = '';
00373             }
00374         }
00375         else{
00376             if(count($changes)) {
00377                 print "<td>".count($changes)."</td>";
00378             }
00379             else {
00380                 print "<td></td>";
00381             }
00382         }
00383     }
00384 }
00385 
00386 
00387 ?>

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