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
00005
00019 global $g_cache_persons;
00020 $g_cache_persons=array();
00021
00022
00023
00027 class Person extends DbProjectItem {
00028 public $name;
00029 public $project;
00030
00034 function __construct ($id_or_array)
00035 {
00036 global $g_person_fields;
00037 $this->fields= &$g_person_fields;
00038
00039 parent::__construct($id_or_array);
00040 if(!$this->type) {
00041 $this->type= ITEM_PERSON;
00042 }
00043 }
00044
00051 static function initFields()
00052 {
00053 global $g_person_fields;
00054 $g_person_fields=array();
00055 addProjectItemFields(&$g_person_fields);
00056
00057 foreach(array(
00058 new FieldInternal(array( 'name'=>'id',
00059 'default'=>0,
00060 'in_db_object'=>1,
00061 'in_db_item'=>1,
00062 'log_changes'=>false,
00063
00064 )),
00065 new FieldInternal(array( 'name'=>'state', ### cached in project-table to speed up queries ###
00066 'default'=>1,
00067 'in_db_object'=>1,
00068 'in_db_item'=>1,
00069 )),
00070 new FieldString(array( 'name'=>'name',
00071 'title' =>__('Full name'),
00072 'tooltip' =>__('Required. Full name like (e.g. Thomas Mann)'),
00073 'required'=>true,
00074 )),
00075 new FieldString(array( 'name'=>'nickname',
00076 'title' =>__('Nickname'),
00077 'tooltip' =>__('only required if user can login (e.g. pixtur)'),
00078 )),
00079 new FieldString(array( 'name'=>'tagline',
00080 'title' =>__('Tagline'),
00081 'tooltip' =>__('Optional: Additional tagline (eg. multimedia concepts)'),
00082 )),
00083 new FieldString(array( 'name'=>'mobile_phone',
00084 'title' =>__('Mobile Phone'),
00085 'tooltip' =>__('Optional: Mobile phone (eg. +49-172-12345678)'),
00086 )),
00087
00088 ### office stuff ###
00089 new FieldString(array( 'name'=>'office_phone',
00090 'title' =>__('Office Phone'),
00091 'tooltip' =>__('Optional: Office Phone (eg. +49-30-12345678)'),
00092 )),
00093 new FieldString(array( 'name'=>'office_fax',
00094 'title' =>__('Office Fax'),
00095 'tooltip' =>__('Optional: Office Fax (eg. +49-30-12345678)'),
00096 )),
00097 new FieldString(array( 'name'=>'office_street',
00098 'title' =>__('Office Street'),
00099 'tooltip' =>__('Optional: Official Street and Number (eg. Poststreet 28)'),
00100 )),
00101 new FieldString(array( 'name'=>'office_zipcode',
00102 'title' =>__('Office Zipcode'),
00103 'tooltip' =>__('Optional: Official Zip-Code and City (eg. 12345 Berlin)'),
00104 )),
00105 new FieldString(array( 'name'=>'office_homepage',
00106 'title' =>__('Office Page'),
00107 'tooltip' =>__('Optional: (eg. www.pixtur.de)'),
00108 )),
00109 new FieldString(array( 'name'=>'office_email',
00110 'title' =>__('Office E-Mail'),
00111 'tooltip' =>__('Optional: (eg. thomas@pixtur.de)'),
00112 )),
00113
00114
00115 ### personal stuff ###
00116 new FieldString(array( 'name'=>'personal_phone',
00117 'title' =>__('Personal Phone'),
00118 'tooltip' =>__('Optional: Private Phone (eg. +49-30-12345678)'),
00119 )),
00120 new FieldString(array( 'name'=>'personal_fax',
00121 'title' =>__('Personal Fax'),
00122 'tooltip' =>__('Optional: Private Fax (eg. +49-30-12345678)'),
00123 )),
00124 new FieldString(array( 'name'=>'personal_street',
00125 'title' =>__('Personal Street'),
00126 'tooltip' =>__('Optional: Private (eg. Poststreet 28)'),
00127 )),
00128 new FieldString(array( 'name'=>'personal_zipcode',
00129 'title' =>__('Personal Zipcode'),
00130 'tooltip' =>__('Optional: Private (eg. 12345 Berlin)'),
00131 )),
00132 new FieldString(array( 'name'=>'personal_homepage',
00133 'title' =>__('Personal Page'),
00134 'tooltip' =>__('Optional: (eg. www.pixtur.de)'),
00135 )),
00136 new FieldString(array( 'name'=>'personal_email',
00137 'title' =>__('Personal E-Mail'),
00138 'tooltip' =>__('Optional: (eg. thomas@pixtur.de)'),
00139 )),
00140 new FieldDate(array( 'name'=>'birthdate',
00141 'title' =>__('Birthdate'),
00142 'tooltip' =>__('Optional')
00143 )),
00144
00145 new FieldString(array( 'name'=>'color',
00146 'title' =>__('Color'),
00147 'tooltip' =>__('Optional: Color for graphical overviews (e.g. #FFFF00)'),
00148 'view_in_forms'=>false,
00149 )),
00150
00151 new FieldText(array( 'name'=>'description',
00152 'title' =>__('Comments'),
00153 'tooltip' =>'Optional'
00154 )),
00155 new FieldPassword(array( 'name'=>'password',
00156 'view_in_forms'=>false,
00157 'title' =>__('Password'),
00158 'tooltip' =>__('Only required if user can login','tooltip'),
00159 'log_changes'=>false,
00160 )),
00161
00165 new FieldInternal(array( 'name'=>'security_question',
00166 'view_in_forms' =>false,
00167 'export' =>false,
00168 )),
00169
00170 new FieldInternal(array( 'name'=>'security_answer',
00171 'view_in_forms'=>false,
00172 'export' =>false,
00173 )),
00174
00180 new FieldInternal(array( 'name'=>'profile',
00181 'title' =>__('Profile'),
00182 'view_in_forms'=>false,
00183 'default'=>3,
00184 'log_changes'=>true,
00185 )),
00186
00190 new FieldInternal(array(
00191 'name' =>'theme',
00192 'title' =>__('Theme','Formlabel'),
00193 'view_in_forms' =>false,
00194 'default' => confGet('THEME_DEFAULT'),
00195 'log_changes' =>true,
00196 'export' =>false,
00197 )),
00198
00202 new FieldInternal(array(
00203 'name' =>'language',
00204 'view_in_forms' =>false,
00205 'default' => confGet('DEFAULT_LANGUAGE'),
00206 'log_changes'=>true,
00207 )),
00208
00214 new FieldInternal(array(
00215 'name' =>'show_tasks_at_home',
00216 'view_in_forms' =>false,
00217 'default' => confGet('SHOW_TASKS_AT_HOME_DEFAULT'),
00218 )),
00219
00220
00224 new FieldDatetime(array( 'name'=>'date_highlight_changes',
00225 'view_in_forms' =>false,
00226 'log_changes'=>false,
00227 'default' =>FINIT_NOW
00228 )),
00229
00233 new FieldInternal(array( 'name'=>'can_login',
00234 'view_in_forms' =>false,
00235 'log_changes'=>true,
00236 )),
00237
00238
00239 new FieldDatetime(array( 'name'=>'last_login',
00240 'view_in_forms' =>false,
00241 'log_changes'=>false,
00242 'default'=> FINIT_NEVER
00243 )),
00244
00248 new FieldDatetime(array( 'name'=>'last_logout',
00249 'view_in_forms' =>false,
00250 'log_changes'=>false,
00251 'default'=>FINIT_NOW,
00252 )),
00253
00257 new FieldInternal(array( 'name'=>'user_rights',
00258 'tooltip'=>'Optional',
00259 'log_changes' =>true,
00260 'export' =>false,
00261 )),
00262
00266 new FieldInternal(array( 'name'=>'cookie_string',
00267 'log_changes' =>false,
00268 'export' =>false,
00269 )),
00270
00275 new FieldInternal(array( 'name'=>'ip_address',
00276 'log_changes' =>false,
00277 'export' =>false,
00278 )),
00279
00286 new FieldInternal(array( 'name'=>'identifier',
00287 'default' =>FINIT_RAND_MD5,
00288 'log_changes' =>false,
00289 'export' =>false,
00290 )),
00291
00295 new FieldInternal(array( 'name'=>'settings',
00296 'default'=> (
00297 USER_SETTING_HTML_MAIL
00298 | USER_SETTING_NOTIFY_ASSIGNED_TO_PROJECT),
00299 'log_changes' =>false,
00300 'export' =>false,
00301
00302 )),
00303
00304 new FieldInternal(array( 'name'=>'notification_last',
00305 'default' => FINIT_NEVER,
00306 'log_changes' =>false,
00307 'export' =>false,
00308 )),
00309
00313 new FieldInternal(array( 'name'=>'notification_period',
00314 'default' => 0,
00315 'log_changes'=>false,
00316 )),
00317
00318
00324 new FieldInternal(array( 'name'=>'time_zone',
00325 'default' =>TIME_OFFSET_AUTO,
00326 'export' =>false,
00327 )),
00328
00332 new FieldInternal(array( 'name'=>'time_offset',
00333 'default' =>0,
00334 'export' =>false,
00335 )),
00336
00340 new FieldInternal(array( 'name'=>'user_level_create',
00341 'log_changes'=>false,
00342 'export' =>false,
00343 )),
00344 new FieldInternal(array( 'name'=>'user_level_view',
00345 'log_changes'=>false,
00346 'export' =>false,
00347 )),
00348 new FieldInternal(array( 'name'=>'user_level_edit',
00349 'log_changes'=>false,
00350 'export' =>false,
00351 )),
00352 new FieldInternal(array( 'name'=>'user_level_reduce',
00353 'log_changes'=>false,
00354 'export' =>false,
00355 )),
00356
00357
00358 new FieldInternal(array( 'name'=>'category',
00359 'view_in_forms' =>false,
00360 'default' =>0,
00361 'log_changes' =>true,
00362 )),
00363
00364 ) as $f) {
00365 $g_person_fields[$f->name]=$f;
00366 }
00367 }
00368
00369
00375 static function getById($id, $use_cache= true)
00376 {
00377
00378 global $g_cache_persons;
00379 if($use_cache && isset($g_cache_persons[$id])) {
00380 $p= $g_cache_persons[$id];
00381 }
00382 else {
00383 $p= new Person($id);
00384 $g_cache_persons[$p->id]= $p;
00385 }
00386 if(!$p->id) {
00387 return NULL;
00388 }
00389 return $p;
00390 }
00391
00397 static function getVisibleById($id, $use_cache= true)
00398 {
00399 if(!is_int($id) && !is_string($id)) {
00400 trigger_error('Person::getVisibleById() requires int-paramter',E_USER_WARNING);
00401 return NULL;
00402 }
00403 global $g_cache_persons;
00404 if($use_cache && isset($g_cache_persons[$id])) {
00405 $p= $g_cache_persons[$id];
00406 return $p;
00407 }
00408 else {
00409 $p=NULL;
00410 $persons= Person::getPersons(array(
00411 'id'=>$id
00412 ));
00413 if(count($persons) == 1) {
00414
00415
00416 if($persons[0]->id) {
00417 $p=$persons[0];
00418 $g_cache_persons[$p->id]= $p;
00419 return $p;
00420 }
00421 }
00422 }
00423
00424 return NULL;
00425 }
00426
00430 static function getEditableById($id, $use_cache= false)
00431 {
00432 if(!is_int($id) && !is_string($id)) {
00433 trigger_error('Person::getVisibleById() requires int-paramter',E_USER_WARNING);
00434 return NULL;
00435 }
00436 global $auth;
00437 if(
00438 (
00439 $auth->cur_user->id == $id
00440 &&
00441 $auth->cur_user->user_rights & RIGHT_PERSON_EDIT_SELF
00442 )
00443 ||
00444 $auth->cur_user->user_rights & RIGHT_PERSON_EDIT
00445 ) {
00446 $persons= Person::getPersons(array(
00447 'id'=>$id
00448 ));
00449 if(count($persons) == 1) {
00450 if($persons[0]->id) {
00451 return $persons[0];
00452 }
00453 }
00454 }
00455 return NULL;
00456 }
00457
00458
00459 public function getLink()
00460 {
00461 global $PH;
00462 if($this->nickname) {
00463 $out='<span title="'.$this->name.'" class="item person">'.$PH->getLink('personView',$this->nickname,array('person'=>$this->id)).'</span>';
00464 }
00465 else {
00466 $out='<span title="'.$this->name.'" class="item person">'.$PH->getLink('personView',$this->getShort(),array('person'=>$this->id)).'</span>';
00467 }
00468 return $out;
00469 }
00470
00474 static function &queryFromDb($query_string)
00475 {
00476
00477 $dbh = new DB_Mysql;
00478
00479 $sth= $dbh->prepare($query_string);
00480
00481 $sth->execute("",1);
00482 $tmp=$sth->fetchall_assoc();
00483 $persons=array();
00484 foreach($tmp as $t) {
00485 $person=new Person($t);
00486 $persons[]=$person;
00487 }
00488 return $persons;
00489 }
00490
00496 #$order_by=NULL, $accounts_only=false, $has_id=NULL, $search=NULL)
00497 public static function &getPersons($args=NULL)
00498 {
00499 global $auth;
00500 $prefix = confGet('DB_TABLE_PREFIX');
00501
00502 ### default params ###
00503 $order_by = 'name';
00504 $visible_only = 'auto'; #
00505 $can_login = NULL;
00506 $id = NULL;
00507 $search = NULL;
00508 $nickname = NULL;
00509 $identifier = NULL;
00510 $cookie_string = NULL;
00511 $is_alive = true;
00512 $perscat = NULL;
00513
00514 ### filter params ###
00515 if($args) {
00516 foreach($args as $key=>$value) {
00517 if(!isset($$key) && !is_null($$key) && !$$key==="") {
00518 trigger_error("unknown parameter",E_USER_NOTICE);
00519 }
00520 else {
00521 $$key= $value;
00522 }
00523 }
00524 }
00525
00526 if(!is_null($can_login)) {
00527 $str_can_login= $can_login
00528 ?"AND pers.can_login=1"
00529 :"AND pers.can_login=0";
00530 }
00531 else {
00532 $str_can_login = '';
00533 }
00534
00535
00536 $str_id= $id
00537 ? 'AND pers.id='.intval($id)
00538 : '';
00539
00540
00541 $AND_match= $search
00542 ? "AND MATCH (pers.name,pers.nickname,pers.tagline,pers.description) AGAINST ('". asCleanString($search) ."*' IN BOOLEAN MODE)"
00543 : "";
00544
00545 if($visible_only == 'auto') {
00546 $visible_only= $auth->cur_user->user_rights & RIGHT_PERSON_VIEWALL
00547 ? false
00548 : true;
00549 }
00550
00551
00552 if(is_null($is_alive)) { # ignore
00553 $str_alive= "";
00554 }
00555 else {
00556 $str_alive = $is_alive
00557 ? "AND pers.state=1"
00558 : "AND pers.state=-1";
00559 }
00560
00561 if(is_null($perscat))
00562 {
00563 $str_perscat = "";
00564 }
00565 else
00566 {
00567 if($perscat == PCATEGORY_EMPLOYEE)
00568 {
00569 $str_perscat = "AND (pers.category BETWEEN " . PCATEGORY_STAFF . " AND " . PCATEGORY_EXEMPLOYEE . ")";
00570 }
00571 else if($perscat == PCATEGORY_CONTACT)
00572 {
00573 $str_perscat = "AND (pers.category BETWEEN " . PCATEGORY_CLIENT . " AND " . PCATEGORY_PARTNER . ")";
00574 }
00575 else
00576 {
00577 $str_perscat = "";
00578 }
00579 }
00580
00581 ### all persons ###
00582 if(!$visible_only) {
00583 $str=
00584 "SELECT i.*, pers.* from {$prefix}person pers, {$prefix}item i
00585 WHERE 1
00586 $str_perscat
00587 $str_alive
00588 $str_id
00589 $str_can_login
00590 AND i.id = pers.id
00591 $AND_match
00592
00593
00594 ". getOrderByString($order_by);
00595 }
00596
00597 ### only related persons ###
00598 else {
00599 $str=
00600 "SELECT DISTINCT pers.*, ipers.* from {$prefix}person pers, {$prefix}project p, {$prefix}projectperson upp, {$prefix}projectperson pp, {$prefix}item ipp, {$prefix}item ipers
00601 WHERE
00602 upp.person = {$auth->cur_user->id}
00603 AND upp.state = 1 /* upp all user projectpersons */
00604 AND upp.project = p.id /* all user projects */
00605
00606 AND p.state = 1
00607 AND p.status > 0 /* ignore templates */
00608 AND p.id = pp.project /* all projectpersons in user's project*/
00609
00610 AND pp.state = 1
00611 AND pp.id = ipp.id
00612
00613 AND ( ipp.pub_level >= upp.level_view
00614 OR
00615 ipp.created_by = {$auth->cur_user->id}
00616 )
00617 AND pp.person = pers.id /* all belonging person*/
00618 $str_alive
00619 $str_id
00620 $str_can_login
00621 $str_perscat
00622 $AND_match
00623 AND pers.id = ipers.id
00624
00625 ". getOrderByString($order_by);
00626 }
00627 $persons = self::queryFromDb($str); # store in variable to pass by reference
00628
00635 if( !$search
00636 &&
00637 $auth && $auth->cur_user && $auth->cur_user->id
00638 &&
00639 (!$id || $id == $auth->cur_user->id)
00640 &&
00641 $is_alive !== false
00642 ) {
00643
00644 $flag_user_found = false;
00645 foreach($persons as $p) {
00646 if($p->id == $auth->cur_user->id) {
00647 $flag_user_found= true;
00648 break;
00649 }
00650 }
00651 if(!$flag_user_found) {
00652 $persons[]= $auth->cur_user;
00653 }
00654 }
00655
00656 return $persons;
00657 }
00658
00659 #------------------------------------------------------------
00660 # get person by nickname
00661 #------------------------------------------------------------
00662 public static function getByNickname($nickname)
00663 {
00664 $prefix= confGet('DB_TABLE_PREFIX');
00665 $tmp=self::queryFromDb("SELECT * FROM {$prefix}person WHERE nickname='" . asCleanString($nickname) . "'");
00666 if(!$tmp || count($tmp)!=1) {
00667 return false;
00668 }
00669 return $tmp[0];
00670 }
00671
00672 #------------------------------------------------------------
00673 # get person by cookie_string (md5)
00674 #------------------------------------------------------------
00675 public static function getByCookieString($f_cookie_string)
00676 {
00677 $prefix= confGet('DB_TABLE_PREFIX');
00678
00679
00680 $tmp=self::queryFromDb("SELECT * FROM {$prefix}person WHERE cookie_string='".asAlphaNumeric($f_cookie_string)."'");
00681 if(!$tmp || count($tmp)!=1) {
00682 return false;
00683 }
00684 return $tmp[0];
00685 }
00686
00687 #------------------------------------------------------------
00688 # get person by identifer_string (md5)
00689 #------------------------------------------------------------
00690 public static function getByIdentifierString($f_identifier_string)
00691 {
00692 $prefix= confGet('DB_TABLE_PREFIX');
00693
00694 $tmp=self::queryFromDb("SELECT * FROM {$prefix}person WHERE identifier='".asAlphaNumeric($f_identifier_string)."'");
00695 if(!$tmp || count($tmp)!=1) {
00696 return false;
00697 }
00698 return $tmp[0];
00699 }
00700
00701 #---------------------------
00702 # get Employments
00703 #---------------------------
00704 function getEmployments()
00705 {
00706 $prefix = confGet('DB_TABLE_PREFIX');
00707 require_once(confGet('DIR_STREBER') . 'db/class_employment.inc.php');
00708 $dbh = new DB_Mysql;
00709 $sth= $dbh->prepare("
00710 SELECT * FROM {$prefix}employment em, {$prefix}item i
00711 WHERE i.type = ".ITEM_EMPLOYMENT."
00712 AND i.state = 1
00713 AND i.id = em.id
00714 AND em.person = \"$this->id\"
00715 " );
00716 $sth->execute("",1);
00717 $tmp=$sth->fetchall_assoc();
00718 $es=array();
00719 foreach($tmp as $t) {
00720 $es[]=new Employment($t);
00721 }
00722 return $es;
00723 }
00724
00728 function &getProjectPersons($f_order_by=NULL,$alive_only=true,$visible_only= true)
00729 {
00730 $prefix= confGet('DB_TABLE_PREFIX');
00731 global $auth;
00732
00733 $AND_state= $alive_only
00734 ? 'AND i.state = 1'
00735 : '';
00736
00737
00738 require_once(confGet('DIR_STREBER') . 'db/class_projectperson.inc.php');
00739 $dbh = new DB_Mysql;
00740
00741 ### ignore rights ###
00742 if(!$visible_only || $auth->cur_user->user_rights & RIGHT_PROJECT_ASSIGN) {
00743 $sth= $dbh->prepare(
00744 "SELECT i.*, pp.* from {$prefix}item i, {$prefix}projectperson pp
00745 WHERE
00746
00747 i.type = '".ITEM_PROJECTPERSON."'
00748 $AND_state
00749 AND i.project = pp.project
00750
00751 AND pp.person = $this->id
00752 AND pp.id = i.id
00753
00754 ". getOrderByString($f_order_by, "name desc")
00755 );
00756
00757 }
00758 else {
00759 $sth= $dbh->prepare(
00760 "SELECT i.*, pp.* from {$prefix}item i, {$prefix}projectperson pp, {$prefix}projectperson upp
00761 WHERE
00762 upp.person = {$auth->cur_user->id}
00763 AND upp.state = 1
00764
00765 AND i.type = '".ITEM_PROJECTPERSON."'
00766 $AND_state
00767 AND i.project = upp.project
00768
00769 AND (
00770 i.pub_level >= upp.level_view
00771 OR
00772 i.created_by= {$auth->cur_user->id}
00773 )
00774 AND pp.id = i.id
00775 AND pp.person = $this->id
00776
00777 ". getOrderByString($f_order_by, "name desc")
00778 );
00779 }
00780 $sth->execute("",1);
00781 $tmp=$sth->fetchall_assoc();
00782 $ppersons=array();
00783 foreach($tmp as $n) {
00784 $pperson=new ProjectPerson($n);
00785 $ppersons[]= $pperson;
00786 }
00787 return $ppersons;
00788 }
00789
00795 public function getProjects($f_order_by=NULL, $f_status_min=STATUS_UPCOMING, $f_status_max= STATUS_COMPLETED)
00796 {
00797 global $auth;
00798 $prefix= confGet('DB_TABLE_PREFIX');
00799 $status_min= intval($f_status_min);
00800 $status_max= intval($f_status_max);
00801
00802 ### all projects ###
00803 if($auth->cur_user->user_rights & RIGHT_PROJECT_ASSIGN) {
00804 $str=
00805 "SELECT p.* from {$prefix}project p, {$prefix}projectperson pp
00806 WHERE
00807 p.status <= $status_max
00808 AND p.status >= $status_min
00809 AND p.state = 1
00810
00811 AND pp.person = $this->id
00812 AND pp.project = p.id
00813 AND pp.state=1
00814 ". getOrderByString($f_order_by, 'prio, name');
00815 }
00816
00817 ### only assigned projects ###
00818 else {
00819 $str=
00820 "SELECT p.* from {$prefix}project p, {$prefix}projectperson upp , {$prefix}projectperson pp
00821 WHERE
00822 upp.person = {$auth->cur_user->id}
00823 AND upp.state = 1
00824 AND upp.project = pp.project
00825
00826 AND pp.person = $this->id
00827 AND pp.project = p.id
00828 AND pp.state=1
00829
00830 AND p.id = upp.project
00831 AND p.status <= $status_max
00832 AND p.status >= $status_min
00833 AND p.state = 1
00834
00835 ". getOrderByString($f_order_by, 'prio, name');
00836 }
00837
00838 $dbh = new DB_Mysql;
00839 $sth= $dbh->prepare($str);
00840 $sth->execute("",1);
00841 $tmp=$sth->fetchall_assoc();
00842
00843 $projects=array();
00844 foreach($tmp as $n_array) {
00845 require_once(confGet('DIR_STREBER') . 'db/class_project.inc.php');
00846 if($n_array['id']){
00847 if($proj = Project::getById($n_array['id'])){
00848 $projects[] = $proj;
00849 }
00850 }
00851 }
00852 return $projects;
00853 }
00854
00860 function getEfforts($f_order_by=NULL)
00861 {
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894 require_once(confGet('DIR_STREBER') . 'db/class_effort.inc.php');
00895 $efforts= Effort::getAll(array(
00896 'person'=> $this->id
00897 ));
00898
00899
00900 return $efforts;
00901 }
00902
00903
00909 function getTaskAssignments()
00910 {
00911 $dbh = new DB_Mysql;
00912 $prefix= confGet('DB_TABLE_PREFIX');
00913
00914 $sth= $dbh->prepare(
00915
00916 "
00917 SELECT itp.*, tp.* from {$prefix}taskperson tp, {$prefix}item itp
00918 WHERE
00919 tp.person = {$this->id}
00920 AND tp.id = itp.id
00921 AND itp.state = 1
00922 ");
00923
00924 $sth->execute("",1);
00925 $tmp=$sth->fetchall_assoc();
00926 $taskpersons=array();
00927 require_once(confGet('DIR_STREBER') . 'db/class_taskperson.inc.php');
00928
00929 foreach($tmp as $tp) {
00930 $taskpersons[]=new TaskPerson($tp);
00931 }
00932 return $taskpersons;
00933
00934 }
00935
00936 #---------------------------
00937 # get Companies
00938 #---------------------------
00939 function getCompanies()
00940 {
00941 require_once(confGet('DIR_STREBER') . 'db/class_company.inc.php');
00942 $emps= $this->getEmployments();
00943 $cs=array();
00944 foreach($emps as $e) {
00945 if($e->company) {
00946 $c= Company::getById($e->company);
00947 if($c) {
00948 $cs[]= $c;
00949 }
00950 }
00951 }
00952 return $cs;
00953 }
00954
00955
00956
00957 function getCompanyLinks($show_max_number=3)
00958 {
00959 $cs= $this->getCompanies();
00960 $buffer= '';
00961 $sep= '';
00962 $num=0;
00963 foreach($cs as $c) {
00964 $buffer.= $c->getLink().$sep;
00965 if(++$num>$show_max_number) {
00966 break;
00967 }
00968 $sep=", ";
00969 }
00970 return $buffer;
00971 }
00972
00973
00974
00975
00980 public function calcCookieString()
00981 {
00982 if(!function_exists('md5')) {
00983 trigger_error('md5() is not available.', E_USER_ERROR);
00984 return NULL;
00985 }
00986 return md5($this->name . $this->password. md5(time().microtime(). rand(12312,123213). rand(234423,123213)));
00987 }
00988
00989
00990
00996 public function calcIdentifierString()
00997 {
00998 if(!function_exists('md5')) {
00999 trigger_error('md5() is not available.', E_USER_ERROR);
01000 }
01001 return md5($this->name .$this->nickname. $this->password);
01002 }
01003 }
01004
01005 Person::initFields();
01006
01007 ?>