diff options
| author | Lester Caine <lsces@lsces.co.uk> | 2010-10-24 08:02:10 +0100 |
|---|---|---|
| committer | Lester Caine <lsces@lsces.co.uk> | 2010-10-24 08:02:10 +0100 |
| commit | a9ab35c101cd78bcfd8f87409c5c68e069ff4e24 (patch) | |
| tree | c6b5cc6b21fa0ffbcec31a3f4c1327a5ae5a7911 | |
| parent | a58ca8acc6cc46a2836cfff061fd6109d938c341 (diff) | |
| download | contact-a9ab35c101cd78bcfd8f87409c5c68e069ff4e24.tar.gz contact-a9ab35c101cd78bcfd8f87409c5c68e069ff4e24.tar.bz2 contact-a9ab35c101cd78bcfd8f87409c5c68e069ff4e24.zip | |
Move phx data import functions to import directory
| -rw-r--r-- | Contact.php | 99 | ||||
| -rw-r--r-- | import/ImportPhx2.php | 111 |
2 files changed, 115 insertions, 95 deletions
diff --git a/Contact.php b/Contact.php index 40e143f..891ae06 100644 --- a/Contact.php +++ b/Contact.php @@ -626,104 +626,13 @@ class Contact extends LibertyContent { * Uncomment to enable */ // include( CONTENT_PKG_PATH.'import/ImportPhx2.php'); - /** - * PhxRecordLoad( $data ); - * phx seurity file import - */ - function PhxRecordLoad( &$data, $cnt ) { - $ctable = BIT_DB_PREFIX."contact"; - $ptable = BIT_DB_PREFIX."contact_phx"; - $atable = BIT_DB_PREFIX."contact_address"; - $pDataHash['contact_store']['parent_id'] = 1; - $pDataHash['contact_store']['xkey'] = $data[0]; - $pDataHash['title'] = $data[2]; - if ( strlen($data[4]) > 0 ) { - $pDataHash['title'] = $data[4]; - if ( strlen($data[3]) > 0 ) $pDataHash['title'] .= ', '.$data[3].' '.$data[5]; - else if ( strlen($data[3]) > 0 ) $pDataHash['title'] .= ', '.$data[5]; - if ( strlen($data[6]) > 0 ) $pDataHash['title'] = trim($pDataHash['title']).' ('.$data[6].')'; - } - $pDataHash['phx_store']['content_id'] = $cnt; - $pDataHash['address_store']['content_id'] = $cnt; - $pDataHash['phx_store']['contract'] = $data[0]; - if ( $data[1] == 'D' ) $type = 0; else $type = 1; - $pDataHash['phx_store']['cltype'] = $type; - $pDataHash['address_store']['cltype'] = $type; - $pDataHash['phx_store']['organisation'] = $data[2]; - $pDataHash['phx_store']['prefix'] = $data[3]; - $pDataHash['phx_store']['surname'] = $data[4]; - $pDataHash['phx_store']['forename'] = $data[5]; - $pDataHash['phx_store']['spouse'] = $data[6]; - $pDataHash['address_store']['sao'] = ''; - $pDataHash['address_store']['pao'] = ''; - $pDataHash['address_store']['number'] = ''; - $pDataHash['address_store']['street'] = $data[7]; - $pDataHash['address_store']['locality'] = $data[8]; - $pDataHash['address_store']['town'] = $data[9]; - $pDataHash['address_store']['county'] = $data[10]; - $pDataHash['address_store']['postcode'] = $data[11]; - $pDataHash['phx_store']['contact1'] = $data[12]; - $pDataHash['phx_store']['cname2'] = $data[13]; - $pDataHash['phx_store']['contact2'] = $data[14]; - $pDataHash['phx_store']['cname3'] = $data[15]; - $pDataHash['phx_store']['contact3'] = $data[16]; - $pDataHash['phx_store']['key1'] = $data[17]; - $pDataHash['phx_store']['tel1'] = $data[18]; - $pDataHash['phx_store']['mob1'] = $data[19]; - $pDataHash['phx_store']['key2'] = $data[20]; - $pDataHash['phx_store']['tel2'] = $data[21]; - $pDataHash['phx_store']['mob2'] = $data[22]; - $pDataHash['phx_store']['key3'] = $data[23]; - $pDataHash['phx_store']['tel3'] = $data[24]; - $pDataHash['phx_store']['mob3'] = $data[25]; - $pDataHash['phx_store']['key4'] = $data[26]; - $pDataHash['phx_store']['tel4'] = $data[27]; - $pDataHash['phx_store']['mob4'] = $data[28]; - $pDataHash['phx_store']['passwd'] = $data[29]; - $pDataHash['phx_store']['prompt'] = $data[30]; - $pDataHash['phx_store']['email1'] = $data[31]; - $pDataHash['phx_store']['email2'] = $data[32]; - $pDataHash['phx_store']['memo'] = $data[33]; - $pDataHash['phx_store']['full_start_date'] = $data[34].'-'.$data[35].'-'.$data[36]; - $pDataHash['phx_store']['payment'] = $data[37]; - $pDataHash['phx_store']['maintain'] = $data[38]; - $pDataHash['phx_store']['code'] = $data[39]; - $pDataHash['phx_store']['key_seal'] = $data[40]; - $pDataHash['phx_store']['break_seal'] = $data[41]; - - $this->mDb->StartTrans(); - $this->mContentId = 0; - $pDataHash['content_id'] = 0; - if ( LibertyContent::store( $pDataHash ) ) { - $pDataHash['contact_store']['content_id'] = $pDataHash['content_id']; - $pDataHash['contact_store']['address_id'] = $pDataHash['content_id']; - $pDataHash['phx_store']['content_id'] = $pDataHash['content_id']; - $pDataHash['address_store']['content_id'] = $pDataHash['content_id']; - - $result = $this->mDb->associateInsert( $ctable, $pDataHash['contact_store'] ); - $result = $this->mDb->associateInsert( $ptable, $pDataHash['phx_store'] ); - $result = $this->mDb->associateInsert( $atable, $pDataHash['address_store'] ); - $this->mDb->CompleteTrans(); - } else { - $this->mDb->RollbackTrans(); - $this->mErrors['store'] = 'Failed to store this contact.'; - } - return( count( $this->mErrors ) == 0 ); - } - /** - * Delete contact object and all related records + * wandeRecordLoad( $data ); + * wande data file import + * Uncomment to enable */ - function PhxDataExpunge() - { - $ret = FALSE; - $query = "DELETE FROM `".BIT_DB_PREFIX."contact_phx`"; - $result = $this->mDb->query( $query ); -// $query = "DELETE FROM `".BIT_DB_PREFIX."address_phx`"; -// $result = $this->mDb->query( $query ); - return $ret; - } +// include( CONTENT_PKG_PATH.'import/ImportWande.php'); } ?> diff --git a/import/ImportPhx2.php b/import/ImportPhx2.php new file mode 100644 index 0000000..f2cded2 --- /dev/null +++ b/import/ImportPhx2.php @@ -0,0 +1,111 @@ +<?php +/** + * @version $Header:$ + * + * Copyright ( c ) 2006 bitweaver.org + * All Rights Reserved. See below for details and a complete list of authors. + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details + * + * @package contact + */ + + /** + * PhxRecordLoad( $data ); + * phx seurity file import + */ + function PhxRecordLoad( &$data, $cnt ) { + $ctable = BIT_DB_PREFIX."contact"; + $ptable = BIT_DB_PREFIX."contact_phx"; + $atable = BIT_DB_PREFIX."contact_address"; + + $pDataHash['contact_store']['parent_id'] = 1; + $pDataHash['contact_store']['xkey'] = $data[0]; + $pDataHash['title'] = $data[2]; + if ( strlen($data[4]) > 0 ) { + $pDataHash['title'] = $data[4]; + if ( strlen($data[3]) > 0 ) $pDataHash['title'] .= ', '.$data[3].' '.$data[5]; + else if ( strlen($data[3]) > 0 ) $pDataHash['title'] .= ', '.$data[5]; + if ( strlen($data[6]) > 0 ) $pDataHash['title'] = trim($pDataHash['title']).' ('.$data[6].')'; + } + $pDataHash['phx_store']['content_id'] = $cnt; + $pDataHash['address_store']['content_id'] = $cnt; + $pDataHash['phx_store']['contract'] = $data[0]; + if ( $data[1] == 'D' ) $type = 0; else $type = 1; + $pDataHash['phx_store']['cltype'] = $type; + $pDataHash['address_store']['cltype'] = $type; + $pDataHash['phx_store']['organisation'] = $data[2]; + $pDataHash['phx_store']['prefix'] = $data[3]; + $pDataHash['phx_store']['surname'] = $data[4]; + $pDataHash['phx_store']['forename'] = $data[5]; + $pDataHash['phx_store']['spouse'] = $data[6]; + $pDataHash['address_store']['sao'] = ''; + $pDataHash['address_store']['pao'] = ''; + $pDataHash['address_store']['number'] = ''; + $pDataHash['address_store']['street'] = $data[7]; + $pDataHash['address_store']['locality'] = $data[8]; + $pDataHash['address_store']['town'] = $data[9]; + $pDataHash['address_store']['county'] = $data[10]; + $pDataHash['address_store']['postcode'] = $data[11]; + $pDataHash['phx_store']['contact1'] = $data[12]; + $pDataHash['phx_store']['cname2'] = $data[13]; + $pDataHash['phx_store']['contact2'] = $data[14]; + $pDataHash['phx_store']['cname3'] = $data[15]; + $pDataHash['phx_store']['contact3'] = $data[16]; + $pDataHash['phx_store']['key1'] = $data[17]; + $pDataHash['phx_store']['tel1'] = $data[18]; + $pDataHash['phx_store']['mob1'] = $data[19]; + $pDataHash['phx_store']['key2'] = $data[20]; + $pDataHash['phx_store']['tel2'] = $data[21]; + $pDataHash['phx_store']['mob2'] = $data[22]; + $pDataHash['phx_store']['key3'] = $data[23]; + $pDataHash['phx_store']['tel3'] = $data[24]; + $pDataHash['phx_store']['mob3'] = $data[25]; + $pDataHash['phx_store']['key4'] = $data[26]; + $pDataHash['phx_store']['tel4'] = $data[27]; + $pDataHash['phx_store']['mob4'] = $data[28]; + $pDataHash['phx_store']['passwd'] = $data[29]; + $pDataHash['phx_store']['prompt'] = $data[30]; + $pDataHash['phx_store']['email1'] = $data[31]; + $pDataHash['phx_store']['email2'] = $data[32]; + $pDataHash['phx_store']['memo'] = $data[33]; + $pDataHash['phx_store']['full_start_date'] = $data[34].'-'.$data[35].'-'.$data[36]; + $pDataHash['phx_store']['payment'] = $data[37]; + $pDataHash['phx_store']['maintain'] = $data[38]; + $pDataHash['phx_store']['code'] = $data[39]; + $pDataHash['phx_store']['key_seal'] = $data[40]; + $pDataHash['phx_store']['break_seal'] = $data[41]; + + $this->mDb->StartTrans(); + $this->mContentId = 0; + $pDataHash['content_id'] = 0; + if ( LibertyContent::store( $pDataHash ) ) { + $pDataHash['contact_store']['content_id'] = $pDataHash['content_id']; + $pDataHash['contact_store']['address_id'] = $pDataHash['content_id']; + $pDataHash['phx_store']['content_id'] = $pDataHash['content_id']; + $pDataHash['address_store']['content_id'] = $pDataHash['content_id']; + + $result = $this->mDb->associateInsert( $ctable, $pDataHash['contact_store'] ); + $result = $this->mDb->associateInsert( $ptable, $pDataHash['phx_store'] ); + $result = $this->mDb->associateInsert( $atable, $pDataHash['address_store'] ); + $this->mDb->CompleteTrans(); + } else { + $this->mDb->RollbackTrans(); + $this->mErrors['store'] = 'Failed to store this contact.'; + } + return( count( $this->mErrors ) == 0 ); + } + + /** + * Delete contact object and all related records + */ + function PhxDataExpunge() + { + $ret = FALSE; + $query = "DELETE FROM `".BIT_DB_PREFIX."contact_phx`"; + $result = $this->mDb->query( $query ); +// $query = "DELETE FROM `".BIT_DB_PREFIX."address_phx`"; +// $result = $this->mDb->query( $query ); + return $ret; + } + +?>
\ No newline at end of file |
