phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] phpgwapi/inc class.contacts_sql.inc.php, 1.17.2.2.2.1


From: Dave Hall <address@hidden>
Subject: [Phpgroupware-cvs] phpgwapi/inc class.contacts_sql.inc.php, 1.17.2.2.2.19, 1.17.2.2.2.20
Date: Sat, 11 Oct 2003 08:22:57 +0000

Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv8153

Modified Files:
      Tag: Version-0_9_16-branch
        class.contacts_sql.inc.php 
Log Message:
bug fix #5835 from jarg

Index: class.contacts_sql.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.contacts_sql.inc.php,v
retrieving revision 1.17.2.2.2.19
retrieving revision 1.17.2.2.2.20
diff -C2 -d -r1.17.2.2.2.19 -r1.17.2.2.2.20
*** class.contacts_sql.inc.php  9 Oct 2003 00:25:20 -0000       1.17.2.2.2.19
--- class.contacts_sql.inc.php  11 Oct 2003 08:22:54 -0000      1.17.2.2.2.20
***************
*** 899,909 ****
                * @return Array|string Array with records or string with sql 
query
                */
!               function get_principal_persons_data($contact_id, 
$action=PHPGW_SQL_RUN_SQL)
                {
!                       $data = array('contact_id', 
!                                     'owner',  
!                                     'access', 
!                                     'cat_id', 
!                                     'per_first_name', 
                                      'per_last_name', 
                                      'per_middle_name', 
--- 899,909 ----
                * @return Array|string Array with records or string with sql 
query
                */
!               function get_principal_persons_data($contact_id, 
$action=PHPGW_SQL_RUN_SQL, $get_org=True)
                {
!                       $data = array('contact_id',
!                                     'owner',
!                                     'access',
!                                     'cat_id',
!                                     'per_first_name',
                                      'per_last_name', 
                                      'per_middle_name', 
***************
*** 915,923 ****
                                      'per_department',
                                      'per_initials',
!                                     'per_sound',
!                                     'org_name',
!                                     'people');
                        $this->request($data);
!                       $this->criteria(array('contact_id' => $contact_id, 
'my_preferred' => 'Y'));
                        return $this->get_query($action, __LINE__, __FILE__);
                }
--- 915,927 ----
                                      'per_department',
                                      'per_initials',
!                                     'per_sound');
                        $this->request($data);
!                       $this->criteria(array('contact_id' => $contact_id));
! 
!                       if($get_org==True)
!                       {
!                               $this->request(array('org_name', 'people'));
!                               $this->criteria(array('my_preferred' => 'Y'));
!                       }
                        return $this->get_query($action, __LINE__, __FILE__);
                }
***************
*** 958,962 ****
                        $this->request($fields);
                        $person_fields = array('per_full_name', 
'per_first_name', 'per_last_name');
!                       if(array_intersect($person_fields, $fields) > 0)
                        {
                                $this->request(array('organizations'));
--- 962,966 ----
                        $this->request($fields);
                        $person_fields = array('per_full_name', 
'per_first_name', 'per_last_name');
!                       if(count(array_intersect($person_fields, $fields)) > 0)
                        {
                                $this->request(array('organizations'));
***************
*** 1601,1604 ****
--- 1605,1635 ----
                        return $comm->update($data, 
sql_criteria::_equal('contact_id',sql::integer($id)), $action);
                }
+ 
+               /**
+               * Allow edit org-person relation of an contact
+               * @param integer $org_id Organization Id that want to be edited.
+               * @param integer $person_id Person Id that want to be edited.
+               * @param array $data Information for contact
+               * @param integer $action PHPGW_SQL_RETURN_SQL | 
PHPGW_SQL_RUN_SQL depending what we want
+               */
+               function edit_org_person_relation($org_id='', $person_id='', 
$data=array(), $action=PHPGW_SQL_RETURN_SQL)
+               {
+                       $relation = CreateObject('phpgwapi.contact_org_person');
+                       if($org_id && $person_id)
+                       {
+                               $criteria = 
sql_criteria::and_(sql_criteria::equal('org_id',sql::integer($org_id)),
+                                                              
sql_criteria::equal('person_id',sql::integer($person_id)));
+                       }
+                       elseif($org_id)
+                       {
+                               $criteria = 
sql_criteria::equal('org_id',sql::integer($org_id));
+                       }
+                       elseif($person_id)
+                       {
+                               $criteria = 
sql_criteria::equal('person_id',sql::integer($person_id));
+                       }
+ 
+                       return $relation->update($data, $criteria, $action);
+               }
                
                /*************************************************************\
***************
*** 1746,1749 ****
--- 1777,1791 ----
                                $data['my_creaton'] = $this->get_mkdate();
                                $data['my_creatby'] = $this->get_user_id();
+                               $orgs = $this->has_preferred_org($person);
+                               if(count($orgs[0]) == 0)
+                               {
+                                       $data['my_preferred'] = 'Y';
+                               }
+                               else
+                               {
+                                       $data['my_preferred'] = 'N';
+                               }
+                               
+ 
                                $sql[] = $this->_add($data,'relations', 
'my_org_id', $cid, $action);
                                $this->unlock_table();
***************
*** 1751,1755 ****
                        return $sql;
                }
! 
                /**
                 * Add a organizations for a person
--- 1793,1797 ----
                        return $sql;
                }
!               
                /**
                 * Add a organizations for a person
***************
*** 2388,2391 ****
--- 2430,2450 ----
  
                /**
+               * Decide if the person has preferred organization
+               *
+               * @param integer $person_id Person id which want to check.
+               * @return Array|Boolean False if has't preferred org or
+               * array with all id which has preferred org.
+               */
+               function has_preferred_org($person_id)
+               {
+                       $this->request('my_person_id');
+                       $this->request('my_org_id');
+                       $this->criteria(array('my_person_id' => $person_id,
+                                             'my_preferred' => 'Y'));
+                       $persons = $this->get_records(__LINE__, __FILE__);
+                       return $persons;
+               }
+               
+               /**
                * Decide if contact exist
                *
***************
*** 2897,2901 ****
                *
                * @param integer $org_id  The organization id which want to 
check.
!               * @param integer $action PHPGW_SQL_RETURN_SQL | 
PHPGW_SQL_RUN_SQL depending what we want
                * @return integer The addr_id.
                */
--- 2956,2960 ----
                *
                * @param integer $org_id  The organization id which want to 
check.
!               * @param integer $action PHPGW_SQL_RETURN_SQL | 
PHPGW_SQL_RUN_SQL depending what we want
                * @return integer The addr_id.
                */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]