From: <cvs...@us...> - 2003-09-15 06:48:57
|
Update of /cvsroot/egroupware/phpgwapi/inc In directory sc8-pr-cvs1:/tmp/cvs-serv5829/phpgwapi/inc Modified Files: Tag: Version-0_9_16-branch class.bojsaddressbook.inc.php Log Message: cvs-sync: 2003/09/13 07:11:42, skwashd: fix jsaddressbook Index: class.bojsaddressbook.inc.php =================================================================== RCS file: /cvsroot/egroupware/phpgwapi/inc/Attic/class.bojsaddressbook.inc.php,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** class.bojsaddressbook.inc.php 8 Sep 2003 15:41:21 -0000 1.1.2.1 --- class.bojsaddressbook.inc.php 15 Sep 2003 06:48:53 -0000 1.1.2.2 *************** *** 31,36 **** --- 31,38 ---- can use it from anyware. */ + class bojsaddressbook { + var $soaddressbook; //@param $contacts phpgwapi contacts object var $contacts; *************** *** 60,69 **** //A list of contacts, each having their own fields given by this array. var $mass_query_cols = array ( ! 'title' => 'title', ! 'n_given' => 'n_given', ! 'n_family' => 'n_family', ! 'email' => 'email', 'org_name' => 'org_name', ! 'email_home' => 'email_home' ); //@param single_query_cols This array is similar to the one above except this is for --- 62,70 ---- //A list of contacts, each having their own fields given by this array. var $mass_query_cols = array ( ! 'per_title' => 'per_title', ! 'per_first_name' => 'per_first_name', ! 'per_last_name' => 'per_last_name', 'org_name' => 'org_name', ! 'contact_id' => 'contact_id' ); //@param single_query_cols This array is similar to the one above except this is for *************** *** 75,87 **** //the names of each field in english. Use it to decide what values to add here var $single_query_cols = array ( ! 'title' => 'title', ! 'n_given' => 'n_given', ! 'n_family' => 'n_family', 'org_name' => 'org_name', ! 'tel_work' => 'tel_work', ! 'cat_id' => 'cat_id' ); //@param use_session Not used at the moment var $use_session=true; //@function bojsaddressbook --- 76,92 ---- //the names of each field in english. Use it to decide what values to add here var $single_query_cols = array ( ! 'per_title' => 'per_title', ! 'per_first_name' => 'per_first_name', ! 'per_last_name' => 'per_last_name', 'org_name' => 'org_name', ! 'contact_id' => 'contact_id' ! ! ); ! var $commtypes= array( ! 'work email' => 'work email' ); //@param use_session Not used at the moment var $use_session=true; + var $filters; //@function bojsaddressbook *************** *** 109,112 **** --- 114,146 ---- { $this->contactsobject=CreateObject('phpgwapi.contacts'); + + $this->grants = $GLOBALS['phpgw']->acl->get_grants('addressbook'); + if(!isset($GLOBALS['owner'])) + { + $GLOBALS['owner'] = 0; + } + + $this->owner = $GLOBALS['owner']; + + if(!isset($this->owner) || !$this->owner) + { + $this->owner = $GLOBALS['phpgw_info']['user']['account_id']; + /* echo $this->owner; */ + $this->rights = PHPGW_ACL_READ + PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE + 16; + /* echo $rights; */ + } + else + { + if($this->grants[$this->owner]) + { + $this->rights = $this->grants[$this->owner]; + if (!($this->rights & PHPGW_ACL_READ)) + { + $this->owner = $GLOBALS['phpgw_info']['user']['account_id']; + $this->rights = PHPGW_ACL_READ + PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE + 16; + } + } + } + //the idea is that here, right here, nowhere else, do we decide what to keep //from the cache and what to go and query again *************** *** 115,129 **** { $this->parse_contactquery($contactquery); ! $data['result']=$this->contactsobject->read($this->contactquery['start'],$this->contactquery['offset'], ! $this->mass_query_cols,$this->contactquery['query'], ! $this->contactquery['filter'], ! $this->contactquery['sort'], ! $this->sortby); $this->save_sessiondata($data); } $this->result=$data['result']; } //@function parse_contactquery //@param contactquery As described in the constructor's param --- 149,207 ---- { $this->parse_contactquery($contactquery); ! if(is_array($this->filters)) ! { ! // print '<BR><B>NORMAL QUERY</B><BR>'; ! $data['result']=$this->contactsobject->get_persons( ! $this->mass_query_cols,'','','','', ! $this->filters ! ); ! } ! elseif($this->filters == 'directory') ! { ! // print '<BR><B>DIRECTORY QUERY</B><BR>'; ! $data['result']=$this->contactsobject->get_system_contacts($this->mass_query_cols); ! } ! if(count($data['result']) > 1) ! { ! foreach ($data['result'] as $id) ! { ! $contacts[] = $id['contact_id']; ! } ! // print '<BR><B>Fed to comm_contact'.var_export($contacts).'</B><BR>'; ! ! $entries_comm = $this->contactsobject->get_comm_contact_data($contacts, $this->commtypes); ! ! $data['result']=$this->merge_emails_to_results($data['result'],$entries_comm); ! //print '<BR><B>entries com'.var_export($entries_comm).'</B><br>'; ! } ! ! // print '<B><BR>DATA<BR></B>'; ! // print_r($data); $this->save_sessiondata($data); } + $this->result=$data['result']; } + function merge_emails_to_results($result,$entries_comm) + { + reset($result); + while(list($rk,$rv)=each($result)) + { + while (list($ek,$ev)=each($entries_comm)) + { + //macth comtype <-> contact + if(($ev['comm_contact_id']==$rv['contact_id']) && $ev['comm_description']=='work email') + { + // print '<BR><B>Done merge for '."$rv[email]=$ev[comm_data]".'</B><BR>'; + $rv['email']=$ev['comm_data']; + $ret[$rk]=$rv; + } + } + reset($entries_comm); + } + return $ret; + } //@function parse_contactquery //@param contactquery As described in the constructor's param *************** *** 134,141 **** //later what we want to fetch from the contacts backend by this parameters so all other //functions respect and think that thisone builds the start and offset ! function parse_contactquery($contactquery) { $notfirsttime=False; // while(list($k,$v)=each($contactquery)) foreach ($contactquery as $k => $v) { --- 212,221 ---- //later what we want to fetch from the contacts backend by this parameters so all other //functions respect and think that thisone builds the start and offset ! function parse_contactquery($contactquery) { $notfirsttime=False; // while(list($k,$v)=each($contactquery)) + // print '<BR><B>Contactyquery</B><BR>'; + // print_r($contactquery); foreach ($contactquery as $k => $v) { *************** *** 149,179 **** case 'none': { ! $this->contactquery['filter']=$this->contactquery['filter']. ! ($notfirsttime ? "," :"")."tid=n"; ! $notfirsttime=True; ! break; } case 'user_only': { ! $this->contactquery['filter']=$this->contactquery['filter']. ! ($notfirsttime ? "," :""). ! 'owner='.$GLOBALS['phpgw_info']['user']['account_id']; ! $notfirsttime=True; break; } case 'directory': { ! if(!$contactquery['directory_uid']) ! { ! ! $this->contactquery['filter']=$this->contactquery['filter']. ! ($notfirsttime ? "," :"")."tid=p"; ! } ! else ! { ! $this->contactquery['filter']=$this->contactquery['filter']. ! ($notfirsttime ? "," :"")."owner=". ! $contactquery['directory_uid']; ! } $notfirsttime=True; break; --- 229,242 ---- case 'none': { ! $this->filters = array('owner' => array_keys(array_keys($this->grants))); } case 'user_only': { ! $this->filters= array('owner' => $GLOBALS['phpgw_info']['user']['account_id']); break; } case 'directory': { ! $this->filters='directory'; $notfirsttime=True; break; *************** *** 181,188 **** case 'private': { ! $this->contactquery['filter']=$this->contactquery['filter']. ! ($notfirsttime ? "," :"").'owner='. ! $GLOBALS['phpgw_info']['user']['account_id']. ! ',access=private'; $notfirsttime=True; break; --- 244,255 ---- case 'private': { ! $this->filters=array( ! 'owner' => $GLOBALS['phpgw_info']['user']['account_id'], ! 'access' => 'private'); ! break; ! } ! case 'directory': ! { ! $notfirsttime=True; break; *************** *** 196,201 **** if($v) { - $this->contactquery['filter']=$this->contactquery['filter']. - ($notfirsttime ? "," :"")."cat_id=".$v; $notfirsttime=true; } --- 263,266 ---- *************** *** 206,210 **** if($v) { - $this->contactquery['query']=$v; } } --- 271,274 ---- *************** *** 212,217 **** }//end switch }//end while ! // print "<BR> built query"; ! // print_r($this->contactquery); }//end function --- 276,281 ---- }//end switch }//end while ! // print "<BR> built query"; ! // print_r($this->filters); }//end function *************** *** 232,236 **** function recordinfo($addy_id) { ! $entry = $this->contactsobject->read("","",$this->single_query_cols,"","id=$addy_id"); if(!$entry[0]) { --- 296,301 ---- function recordinfo($addy_id) { ! $entry = $this->contactsobject->get_persons( ! $this->single_query_cols,"",array("contact_id" => "$addy_id")); if(!$entry[0]) { *************** *** 326,332 **** $found=false; //We iterate into each box ! //while(list($ak,$li)=each($aryboxes)) ! ! foreach($aryboxes as $ak => $li) { // print $ak." ".$li."<BR>"; --- 391,395 ---- $found=false; //We iterate into each box ! while(list($ak,$li)=each($aryboxes)) { // print $ak." ".$li."<BR>"; *************** *** 338,343 **** //We iterate into the incoming box to search //for its values in the cache ! // while(list($numary,$ary)=each($aryboxes[$ak])) ! foreach($aryboxes[$ak] as $numary => $ary) { // print "<br> Iterating aryboxes $numary"; --- 401,405 ---- //We iterate into the incoming box to search //for its values in the cache ! while(list($numary,$ary)=each($aryboxes[$ak])) { // print "<br> Iterating aryboxes $numary"; *************** *** 349,354 **** //Well, we found that we have this destboxed cached so //now we will iterate through that ! //while(list($numarysave,$arysave)=each($saveddestboxes[$ak])) ! foreach($saveddestboxes[$ak] as $numarysave => $arysave) { //We will try and get each addressbook key --- 411,415 ---- //Well, we found that we have this destboxed cached so //now we will iterate through that ! while(list($numarysave,$arysave)=each($saveddestboxes[$ak])) { //We will try and get each addressbook key *************** *** 377,386 **** //it all goes borken //We iterate into the query cache ! // while(list($num,$record)=each($this->result)) ! foreach($this->result as $num => $record) { // print "<br> Iterating results $id ---> $name <br>$record[id]---> $record[email]"; //Found what we are looking for ! if($id == $record["id"]) { //Set the mail record to what it should be --- 438,446 ---- //it all goes borken //We iterate into the query cache ! while(list($num,$record)=each($this->result)) { // print "<br> Iterating results $id ---> $name <br>$record[id]---> $record[email]"; //Found what we are looking for ! if($id == $record["contact_id"]) { //Set the mail record to what it should be *************** *** 431,435 **** if ($this->use_session) { ! $GLOBALS['phpgw']->session->appsession('session_data',"jsbook_data".($location ? '_'.$location :""),$data); } if($this->debug) --- 491,495 ---- if ($this->use_session) { ! $GLOBALS['phpgw']->session->appsession('session_data',"jsbook_".($location ? '_'.$location :""),$data); } if($this->debug) *************** *** 447,451 **** function read_sessiondata($location="") { ! $data = $GLOBALS['phpgw']->session->appsession('session_data','jsbook_data'.($location ? '_'.$location :"")); if($this->debug) { --- 507,511 ---- function read_sessiondata($location="") { ! $data = $GLOBALS['phpgw']->session->appsession('session_data','jsbook_'.($location ? '_'.$location :"")); if($this->debug) { |