summaryrefslogtreecommitdiff
path: root/ContactXrefType.php
blob: 434185a2ac58ec7aaf3b00ac2c1fe82325e80fd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
 * @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.
 */

/**
 * Required setup
 */
global $gBitSystem;
require_once( KERNEL_PKG_PATH."BitBase.php" );

/**
 * @package contact
 */
class ContactXrefType extends BitBase {

	function ContactXrefType() {
		parent::__construct();

	}

	public static function getContactXrefTypeList( $pOptionHash=NULL ) {
		global $gBitSystem;

		$where = '';
		$bindVars = array();
		if( !empty( $pOptionHash['active_role'] ) ) {
			$where = " WHERE cxs.`role_id` = ? ";
			$bindVars[] = $pOptionHash['active_role'];
		}
		if ( !empty(  $pOptionHash['source'] ) ) {
			$where = " WHERE cxs.`source` = ? ";
			$bindVars[] = $pOptionHash['source'];
		}

		$query = "SELECT cxs.*
				 FROM `".BIT_DB_PREFIX."contact_xref_source` cxs
				 $where ORDER BY cxs.`xref_type`, cxs.source`";

		$result = $gBitSystem->mDb->query( $query, $bindVars );

        $ret = array();

        while( $res = $result->fetchRow() ) {
			$res["num_entries"] = $gBitSystem->mDb->getOne( "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."contact_xref` WHERE `source`= ?", array( $res["source"] ) );

            $ret[] = $res;
        }

        return $ret;
    }

}
?>