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.3


From: Alejandro Borges (lex) <address@hidden>
Subject: [Phpgroupware-cvs] phpgwapi/inc class.contacts_sql.inc.php, 1.17.2.2.2.35, 1.17.2.2.2.36 class.vcard.inc.php, 1.4.4.1, 1.4.4.2
Date: Mon, 03 Nov 2003 20:25:04 +0000

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

Modified Files:
      Tag: Version-0_9_16-branch
        class.contacts_sql.inc.php class.vcard.inc.php 
Log Message:
Completed vcard export (jarg), also supports the new style addressmaster
which is entirely ACL based. No new user required. This change still needs
ceb to finish the accountmaster form in the admin app.



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.35
retrieving revision 1.17.2.2.2.36
diff -C2 -d -r1.17.2.2.2.35 -r1.17.2.2.2.36
*** class.contacts_sql.inc.php  31 Oct 2003 01:23:28 -0000      1.17.2.2.2.35
--- class.contacts_sql.inc.php  3 Nov 2003 20:25:01 -0000       1.17.2.2.2.36
***************
*** 450,456 ****
--- 450,460 ----
                                 'key_cat_id'           => 
array('phpgwapi.contact_categories', '13'));
                var $import_export_fields = array('contact_id', 
+                                               'access',
+                                               'owner',
                                                'per_full_name',
                                                'per_first_name',
                                                'per_middle_name',
+                                               'org_name',
+                                               'people',  
                                                'per_last_name',
                                                'per_suffix',
***************
*** 686,699 ****
                {
                        $person_data = $this->person_complete_data($id);
!                       $entry['fn']                    = 
$person_data['per_full_name'];
!                       $entry['sound']                 = 
$person_data['per_sound'];
                        $entry['org_name']              = '';
!                       $entry['org_unit']              = 
$person_data['per_departament'];
!                       $entry['title']                 = 
$person_data['per_title'];
!                       $entry['n_prefix']              = 
$person_data['per_prefix'];
!                         $entry['n_given']                     = 
$person_data['per_first_name'];
!                       $entry['n_middle']              = 
$person_data['per_middle_name'];
!                       $entry['n_family']              = 
$person_data['per_last_name'];
!                       $entry['n_suffix']              = 
$person_data['per_suffix'];
                        $entry['label']                 = '';
                        $entry['adr_one_street']        = 
$person_data['locations'][1]['add1'];
--- 690,703 ----
                {
                        $person_data = $this->person_complete_data($id);
!                       $entry['fn']                    = 
$person_data['full_name'];
!                       $entry['sound']                 = $person_data['sound'];
                        $entry['org_name']              = '';
!                       $entry['org_unit']              = 
$person_data['departament'];
!                       $entry['title']                 = $person_data['title'];
!                       $entry['n_prefix']              = 
$person_data['prefix'];
!                         $entry['n_given']                     = 
$person_data['first_name'];
!                       $entry['n_middle']              = 
$person_data['middle_name'];
!                       $entry['n_family']              = 
$person_data['last_name'];
!                       $entry['n_suffix']              = 
$person_data['suffix'];
                        $entry['label']                 = '';
                        $entry['adr_one_street']        = 
$person_data['locations'][1]['add1'];
***************
*** 731,735 ****
                        $entry['address3']              = 
$person_data['locations'][1]['add3'];
                        $entry['ophone']                = '';
!                       $entry['bday']                  = 
$person_data['per_birthday'];
                        $entry['url']                   = 
$person_data['website'];
                        $entry['pubkey']                = 
$person_data['per_pubkey'];
--- 735,739 ----
                        $entry['address3']              = 
$person_data['locations'][1]['add3'];
                        $entry['ophone']                = '';
!                       $entry['bday']                  = 
$person_data['birthday'];
                        $entry['url']                   = 
$person_data['website'];
                        $entry['pubkey']                = 
$person_data['per_pubkey'];
***************
*** 1401,1406 ****
                * @return array (Asociative with id and all data that we 
requested)
                */
!               function get_persons_by_cat($cat_id)
                {
                        $this->request('person_id');
                        if(is_array($cat_id))
--- 1405,1415 ----
                * @return array (Asociative with id and all data that we 
requested)
                */
!               function get_persons_by_cat($cat_id, $sub_cat=True)
                {
+                       if($sub_cat && $cat_id)
+                       {
+                               $cat_id = array_merge(array($cat_id), 
$this->get_sub_cats($cat_id));
+                       }
+                       
                        $this->request('person_id');
                        if(is_array($cat_id))
***************
*** 1662,1685 ****
                                $record = $this->db->Record;
                                $contact['contact_id']          = 
$record['contact_id'];
!                               $contact['per_full_name']       = 
$record['per_full_name'];
!                               $contact['per_first_name']      = 
$record['per_first_name'];
!                               $contact['per_last_name']       = 
$record['per_last_name'];
!                               $contact['per_middle_name']     = 
$record['per_middle_name'];
!                               $contact['per_suffix']          = 
$record['per_suffix'];
!                               $contact['per_prefix']          = 
$record['per_prefix'];
!                               $contact['per_birthday']        = 
$record['per_birthday'];
!                               $contact['per_pubkey']          = 
$record['per_pubkey'];
!                               $contact['per_title']           = 
$record['per_title'];
!                               $contact['per_departament']     = 
$record['per_departamet'];
!                               $contact['per_initials']        = 
$record['per_initials'];
!                               $contact['per_sound']           = 
$record['per_sound'];
!                               $contact['per_active']          = 
$record['per_active'];
!                               $contact['per_createon']        = 
$record['per_createon'];
!                               $contact['per_createby']        = 
$record['per_createby'];
!                               $contact['per_modby']           = 
$record['per_modby'];
!                               $contact['per_modon']           = 
$record['per_modon'];
                                $contact['account_id']          = 
$record['account_id'];
                                // Locations info
!                               $loc_id                                         
= $record['key_addr_id'];
                                if($loc_id)
                                {
--- 1671,1697 ----
                                $record = $this->db->Record;
                                $contact['contact_id']          = 
$record['contact_id'];
!                               $contact['access']              = 
$record['access'];
!                               $contact['owner']               = 
$record['owner'];
!                               $contact['full_name']           = 
$record['per_full_name'];
!                               $contact['first_name']          = 
$record['per_first_name'];
!                               $contact['last_name']           = 
$record['per_last_name'];
!                               $contact['middle_name']         = 
$record['per_middle_name'];
!                               $contact['suffix']              = 
$record['per_suffix'];
!                               $contact['prefix']              = 
$record['per_prefix'];
!                               $contact['birthday']            = 
$record['per_birthday'];
!                               $contact['pubkey']              = 
$record['per_pubkey'];
!                               $contact['title']               = 
$record['per_title'];
!                               $contact['department']          = 
$record['per_departmet'];
!                               $contact['initials']            = 
$record['per_initials'];
!                               $contact['sound']               = 
$record['per_sound'];
!                               $contact['active']              = 
$record['per_active'];
!                               $contact['createon']            = 
$record['per_createon'];
!                               $contact['createby']            = 
$record['per_createby'];
!                               $contact['modby']               = 
$record['per_modby'];
!                               $contact['modon']               = 
$record['per_modon'];
                                $contact['account_id']          = 
$record['account_id'];
+                               $contact['org_name']            = 
$record['org_name'];
                                // Locations info
!                               $loc_id                         = 
$record['key_addr_id'];
                                if($loc_id)
                                {
***************
*** 3114,3117 ****
--- 3126,3133 ----
                {
                        $this->grants = 
$GLOBALS['phpgw']->acl->get_grants('addressbook');
+                       if($GLOBALS['phpgw']->acl->check('addressmaster', 7, 
'addressbook'))
+                       {
+                               $required_grants[] = 
$GLOBALS['phpgw_info']['server']['addressmaster'];
+                       }                       
                        foreach($this->grants as $owner => $perm)
                        {
***************
*** 3128,3131 ****
--- 3144,3229 ----
                        return (!!($has & $needed) == True);
                }
+ 
+               /**
+               * Check if the contact has a specified permission or if is 
addressmaster
+               * 
+               * @param integer $contact_id The contact_id which you want to 
find
+               * @param integer $needed The permission what you need
+               * @param integer $owner_id The owner_id of the contact
+               */
+               function check_acl($contact_id, $needed, $owner_id='')
+               {
+                       $grants = 
$GLOBALS['phpgw']->acl->get_grants('addressbook');
+                       if($owner_id=='')
+                       {
+                               $owner_id = 
$this->get_contact_owner($contact_id);
+                       }
+                       if($this->check_perms($grants[$owner_id], $needed) || 
$GLOBALS['phpgw']->acl->check('addressmaster', 7, 'addressbook'))
+                       {
+                               return True;
+                       }
+                       else
+                       {
+                               return False;
+                       }
+               }
+               
+               /**
+               * Check if the contact has add permissions.
+               * 
+               * @param integer $contact_id The contact_id which you want to 
check
+               * @param integer $owner_id The owner_id of the contact which 
you want to check
+               */
+               function check_add($contact_id, $owner_id='')
+               {
+                       return $this->check_acl($contact_id, PHPGW_ACL_ADD, 
$owner_id);
+               }
+               
+               /**
+               * Check if the contact has edit permissions.
+               * 
+               * @param integer $contact_id The contact_id which you want to 
check
+               * @param integer $owner_id The owner_id of the contact which 
you want to check
+               */
+               function check_edit($contact_id, $owner_id='')
+               {
+                       return $this->check_acl($contact_id, PHPGW_ACL_EDIT, 
$owner_id);
+               }
+               
+               /**
+               * Check if the contact has read permissions.
+               * 
+               * @param integer $contact_id The contact_id which you want to 
check
+               * @param integer $owner_id The owner_id of the contact which 
you want to check
+               */
+               function check_read($contact_id, $owner_id='')
+               {
+                       return $this->check_acl($contact_id, PHPGW_ACL_READ, 
$owner_id);
+               }
+               
+               /**
+               * Check if the contact has delete permissions.
+               * 
+               * @param integer $contact_id The contact_id which you want to 
check
+               * @param integer $owner_id The owner_id of the contact which 
you want to check
+               */
+               function check_delete($contact_id, $owner_id='')
+               {
+                       return $this->check_acl($contact_id, PHPGW_ACL_DELETE, 
$owner_id);
+               }
+ 
+               /**
+               * Get the owner of the contact.
+               * 
+               * @param integer $contact_id The contact_id which you want to 
find
+               */
+               function get_contact_owner($contact_id)
+               {
+                       $this->request('owner');
+                       $this->criteria(array('contact_id' => $contact_id));
+                       $owner = $this->get_records(__LINE__, __FILE__);
+                       return $owner[0]['owner'];
+               }
+               
                /**
                * Copy all contact data to new contact
***************
*** 3135,3142 ****
                * @return integer Id of the new contact
                */
!               function copy_contact($contact_id, $contact_type='')
                {
!                       $type = ($contact_type)? $contact_type : 
$this->search_contact_type_id($this->get_type_contact($cid));
!                       $copy_type = ($type == $this->_contact_person) ? 
'person' : 'org';
  
                        $get_data_type= 'get_principal_' . $copy_type . '_data';
--- 3233,3240 ----
                * @return integer Id of the new contact
                */
!               function copy_contact($contact_id, $type='')
                {
!                       $type = ($contact_type)? $contact_type : 
$this->get_type_contact($contact_id);
!                       $copy_type = ($this->search_contact_type_id($type) == 
$this->_contact_person) ? 'persons' : 'organizations';
  
                        $get_data_type= 'get_principal_' . $copy_type . '_data';
***************
*** 3144,3147 ****
--- 3242,3246 ----
                        $principal = $this->$get_data_type($contact_id);
                        unset($principal[0]['owner']);
+                       unset($principal[0]['per_full_name']);
                        
                        $cats = explode(",", $principal[0]['cat_id']);

Index: class.vcard.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.vcard.inc.php,v
retrieving revision 1.4.4.1
retrieving revision 1.4.4.2
diff -C2 -d -r1.4.4.1 -r1.4.4.2
*** class.vcard.inc.php 28 Oct 2003 01:23:32 -0000      1.4.4.1
--- class.vcard.inc.php 3 Nov 2003 20:25:02 -0000       1.4.4.2
***************
*** 44,55 ****
  
                var $export = array(
!                       'fn'                  => 'FN',
!                       'n_given'             => 'N;GIVEN',
!                       'n_family'            => 'N;FAMILY',
!                       'n_middle'            => 'N;MIDDLE',
!                       'n_prefix'            => 'N;PREFIX',
!                       'n_suffix'            => 'N;SUFFIX',
                        'sound'               => 'SOUND',
!                       'bday'                => 'BDAY',
                        'note'                => 'NOTE',
                        'tz'                  => 'TZ',
--- 44,55 ----
  
                var $export = array(
!                       'full_name'                  => 'FN',
!                       'first_name'             => 'N;GIVEN',
!                       'last_name'            => 'N;FAMILY',
!                       'middle_name'            => 'N;MIDDLE',
!                       'prefix'            => 'N;PREFIX',
!                       'suffix'            => 'N;SUFFIX',
                        'sound'               => 'SOUND',
!                       'birthday'                => 'BDAY',
                        'note'                => 'NOTE',
                        'tz'                  => 'TZ',
***************
*** 164,189 ****
                {
                        $buffer = $this->_parse_in($buffer);
!                       return $buffer;
!                       
!                       //var_dump($buffer);
!                       
! //                    $contacts = CreateObject('phpgwapi.contacts');          
/* RB 2001/05/08 Lotus Organizer uses/needs extrafields from edit.php */
! //                    $all_fields = $contacts->stock_contact_fields + array(
! //                            'ophone'   => 'ophone',
! //                            'address2' => 'address2',
! //                            'address3' => 'address3'
! //                    );
! 
! //                    while (list($fname,$fvalue) = each($all_fields))
! //                    {
! //                            if($buffer[$fname])
! //                            {
! //                                    $entry[$fname] = $buffer[$fname];
! //                                    /* echo '<br>'.$fname.' = 
"'.$entry[$fname].'"'."\n"; */
! //                            }
! //                    }
!                       //var_dump($entry);
!                       
!                       //return $entry;
                }
  
--- 164,168 ----
                {
                        $buffer = $this->_parse_in($buffer);
!                       return $buffer;                 
                }
  





reply via email to

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