diff options
| author | lsces <lester@lsces.co.uk> | 2013-08-22 15:45:11 +0100 |
|---|---|---|
| committer | lsces <lester@lsces.co.uk> | 2013-08-22 15:45:11 +0100 |
| commit | 5845db3b1398a1db52afa8c5eb3224b4df1d652c (patch) | |
| tree | fcbb4f75756a2c9824c144a84a1be558ddd92314 | |
| parent | 650ee28714ab4666ee37d0a230bf21a2bce812fc (diff) | |
| download | contact-5845db3b1398a1db52afa8c5eb3224b4df1d652c.tar.gz contact-5845db3b1398a1db52afa8c5eb3224b4df1d652c.tar.bz2 contact-5845db3b1398a1db52afa8c5eb3224b4df1d652c.zip | |
Add getContactTypeList function
| -rw-r--r-- | ContactType.php | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/ContactType.php b/ContactType.php index e332482..c01a711 100644 --- a/ContactType.php +++ b/ContactType.php @@ -2,7 +2,7 @@ /** * @version $Header$ * @package articles - * + * * @copyright Copyright (c) 2004-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. @@ -40,7 +40,7 @@ class ContactType extends BitBase { LEFT OUTER JOIN `".BIT_DB_PREFIX."users_roles_map` purm ON ( purm.`user_id`=".$gBitUser->mUserId." ) AND ( purm.`role_id`=r.`role_id` ) WHERE r.xref_type = 0 AND (r.`role_id` IN(". implode(',', array_fill(0, count($roles), '?')) ." ) OR purm.`user_id`=?) ORDER BY r.`source`"; - + $result = $this->mDb->query( $sql, $bindVars ); while( $res = $result->fetchRow() ) { @@ -71,5 +71,36 @@ class ContactType extends BitBase { } } + public static function getContactTypeList( $pOptionHash=NULL ) { + global $gBitSystem; + + $where = ''; + $bindVars = array(); + if( !empty( $pOptionHash['active_role'] ) ) { + $where = " WHERE cxt.`role_id` = ? "; + $bindVars[] = $pOptionHash['active_role']; + } + if ( !empty( $pOptionHash['title'] ) ) { + $where = " WHERE cxt.`title` = ? "; + $bindVars[] = $pOptionHash['title']; + } + + $query = "SELECT cxt.* + FROM `".BIT_DB_PREFIX."contact_xref_type` cxt + $where ORDER BY cxt.`xref_type`"; + + $result = $gBitSystem->mDb->query( $query, $bindVars ); + + $ret = array(); + + while( $res = $result->fetchRow() ) { + $res["num_types"] = $gBitSystem->mDb->getOne( "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."contact_xref_source` WHERE `xref_type`= ?", array( $res["xref_type"] ) ); + + $ret[] = $res; + } + + return $ret; + } + } ?> |
