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 * Create or update OpenID record.
28 * @param array $params
29 * @return CRM_Core_DAO_OpenID
31 public static function add($params) {
32 return self
::writeRecord($params);
36 * Given the list of params in the params array, fetch the object
37 * and store the values in the values array
39 * @param array $entityBlock
40 * Input parameters to find object.
44 public static function &getValues($entityBlock) {
45 return CRM_Core_BAO_Block
::getValues('openid', $entityBlock);
49 * Returns whether or not this OpenID is allowed to login.
51 * @param string $identity_url
52 * The OpenID to check.
56 public static function isAllowedToLogin($identity_url) {
57 $openId = new CRM_Core_DAO_OpenID();
58 $openId->openid
= $identity_url;
59 if ($openId->find(TRUE)) {
60 return $openId->allowed_to_login
== 1;
66 * Get all the openids for a specified contact_id, with the primary openid being first
71 * @param bool $updateBlankLocInfo
74 * the array of openid's
76 public static function allOpenIDs($id, $updateBlankLocInfo = FALSE) {
82 SELECT civicrm_openid.openid, civicrm_location_type.name as locationType, civicrm_openid.is_primary as is_primary,
83 civicrm_openid.allowed_to_login as allowed_to_login, civicrm_openid.id as openid_id,
84 civicrm_openid.location_type_id as locationTypeId
86 LEFT JOIN civicrm_openid ON ( civicrm_openid.contact_id = civicrm_contact.id )
87 LEFT JOIN civicrm_location_type ON ( civicrm_openid.location_type_id = civicrm_location_type.id )
89 civicrm_contact.id = %1
91 civicrm_openid.is_primary DESC, openid_id ASC ";
92 $params = [1 => [$id, 'Integer']];
94 $openids = $values = [];
95 $dao = CRM_Core_DAO
::executeQuery($query, $params);
97 while ($dao->fetch()) {
99 'locationType' => $dao->locationType
,
100 'is_primary' => $dao->is_primary
,
101 'id' => $dao->openid_id
,
102 'openid' => $dao->openid
,
103 'locationTypeId' => $dao->locationTypeId
,
104 'allowed_to_login' => $dao->allowed_to_login
,
107 if ($updateBlankLocInfo) {
108 $openids[$count++
] = $values;
111 $openids[$dao->openid_id
] = $values;
118 * Call common delete function.
124 public static function del($id) {
125 return CRM_Contact_BAO_Contact
::deleteObjectWithPrimary('OpenID', $id);