3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
37 * This class contains function for Open Id
39 class CRM_Core_BAO_OpenID
extends CRM_Core_DAO_OpenID
{
42 * Takes an associative array and adds OpenID
44 * @param array $params (reference ) an assoc array of name/value pairs
46 * @return object CRM_Core_BAO_OpenID object on success, null otherwise
49 public static function add(&$params) {
50 $hook = empty($params['id']) ?
'create' : 'edit';
51 CRM_Utils_Hook
::pre($hook, 'OpenID', CRM_Utils_Array
::value('id', $params), $params);
53 $openId = new CRM_Core_DAO_OpenID();
54 $openId->copyValues($params);
57 CRM_Utils_Hook
::post($hook, 'OpenID', $openId->id
, $openId);
62 * Given the list of params in the params array, fetch the object
63 * and store the values in the values array
65 * @param array $entityBlock input parameters to find object
70 public static function &getValues($entityBlock) {
71 return CRM_Core_BAO_Block
::getValues('openid', $entityBlock);
75 * Returns whether or not this OpenID is allowed to login
77 * @param string $identity_url the OpenID to check
82 public static function isAllowedToLogin($identity_url) {
83 $openId = new CRM_Core_DAO_OpenID();
84 $openId->openid
= $identity_url;
85 if ($openId->find(TRUE)) {
86 return $openId->allowed_to_login
== 1;
92 * Get all the openids for a specified contact_id, with the primary openid being first
94 * @param int $id the contact id
96 * @param bool $updateBlankLocInfo
98 * @return array the array of openid's
101 public static function allOpenIDs($id, $updateBlankLocInfo = FALSE) {
107 SELECT civicrm_openid.openid, civicrm_location_type.name as locationType, civicrm_openid.is_primary as is_primary,
108 civicrm_openid.allowed_to_login as allowed_to_login, civicrm_openid.id as openid_id,
109 civicrm_openid.location_type_id as locationTypeId
111 LEFT JOIN civicrm_openid ON ( civicrm_openid.contact_id = civicrm_contact.id )
112 LEFT JOIN civicrm_location_type ON ( civicrm_openid.location_type_id = civicrm_location_type.id )
114 civicrm_contact.id = %1
116 civicrm_openid.is_primary DESC, openid_id ASC ";
117 $params = array(1 => array($id, 'Integer'));
119 $openids = $values = array();
120 $dao = CRM_Core_DAO
::executeQuery($query, $params);
122 while ($dao->fetch()) {
124 'locationType' => $dao->locationType
,
125 'is_primary' => $dao->is_primary
,
126 'id' => $dao->openid_id
,
127 'openid' => $dao->openid
,
128 'locationTypeId' => $dao->locationTypeId
,
129 'allowed_to_login' => $dao->allowed_to_login
,
132 if ($updateBlankLocInfo) {
133 $openids[$count++
] = $values;
136 $openids[$dao->openid_id
] = $values;
143 * Call common delete function
145 public static function del($id) {
146 return CRM_Contact_BAO_Contact
::deleteObjectWithPrimary('OpenID', $id);