3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
21 * This class contains function for Open Id
23 class CRM_Core_BAO_OpenID
extends CRM_Core_DAO_OpenID
{
26 * Takes an associative array and adds OpenID.
28 * @param array $params
29 * (reference ) an assoc array of name/value pairs.
32 * CRM_Core_BAO_OpenID object on success, null otherwise
34 public static function add(&$params) {
35 $hook = empty($params['id']) ?
'create' : 'edit';
36 CRM_Utils_Hook
::pre($hook, 'OpenID', CRM_Utils_Array
::value('id', $params), $params);
38 $openId = new CRM_Core_DAO_OpenID();
39 $openId->copyValues($params);
42 CRM_Utils_Hook
::post($hook, 'OpenID', $openId->id
, $openId);
47 * Given the list of params in the params array, fetch the object
48 * and store the values in the values array
50 * @param array $entityBlock
51 * Input parameters to find object.
55 public static function &getValues($entityBlock) {
56 return CRM_Core_BAO_Block
::getValues('openid', $entityBlock);
60 * Returns whether or not this OpenID is allowed to login.
62 * @param string $identity_url
63 * The OpenID to check.
67 public static function isAllowedToLogin($identity_url) {
68 $openId = new CRM_Core_DAO_OpenID();
69 $openId->openid
= $identity_url;
70 if ($openId->find(TRUE)) {
71 return $openId->allowed_to_login
== 1;
77 * Get all the openids for a specified contact_id, with the primary openid being first
82 * @param bool $updateBlankLocInfo
85 * the array of openid's
87 public static function allOpenIDs($id, $updateBlankLocInfo = FALSE) {
93 SELECT civicrm_openid.openid, civicrm_location_type.name as locationType, civicrm_openid.is_primary as is_primary,
94 civicrm_openid.allowed_to_login as allowed_to_login, civicrm_openid.id as openid_id,
95 civicrm_openid.location_type_id as locationTypeId
97 LEFT JOIN civicrm_openid ON ( civicrm_openid.contact_id = civicrm_contact.id )
98 LEFT JOIN civicrm_location_type ON ( civicrm_openid.location_type_id = civicrm_location_type.id )
100 civicrm_contact.id = %1
102 civicrm_openid.is_primary DESC, openid_id ASC ";
103 $params = [1 => [$id, 'Integer']];
105 $openids = $values = [];
106 $dao = CRM_Core_DAO
::executeQuery($query, $params);
108 while ($dao->fetch()) {
110 'locationType' => $dao->locationType
,
111 'is_primary' => $dao->is_primary
,
112 'id' => $dao->openid_id
,
113 'openid' => $dao->openid
,
114 'locationTypeId' => $dao->locationTypeId
,
115 'allowed_to_login' => $dao->allowed_to_login
,
118 if ($updateBlankLocInfo) {
119 $openids[$count++
] = $values;
122 $openids[$dao->openid_id
] = $values;
129 * Call common delete function.
135 public static function del($id) {
136 return CRM_Contact_BAO_Contact
::deleteObjectWithPrimary('OpenID', $id);