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
19 * This class contains function for Open Id
21 class CRM_Core_BAO_OpenID
extends CRM_Core_DAO_OpenID
{
22 use CRM_Contact_AccessTrait
;
25 * Create or update OpenID record.
27 * @param array $params
29 * @return CRM_Core_DAO_OpenID
31 * @throws \API_Exception
32 * @throws \CRM_Core_Exception
34 public static function create($params) {
35 CRM_Core_BAO_Block
::handlePrimary($params, __CLASS__
);
36 return self
::writeRecord($params);
40 * Create or update OpenID record.
44 * @param array $params
46 * @return \CRM_Core_DAO|\CRM_Core_DAO_IM
47 * @throws \CRM_Core_Exception
48 * @throws \API_Exception
50 public static function add($params) {
51 CRM_Core_Error
::deprecatedFunctionWarning('use the v4 api');
52 return self
::create($params);
56 * Given the list of params in the params array, fetch the object
57 * and store the values in the values array
59 * @param array $entityBlock
60 * Input parameters to find object.
63 * @throws \CRM_Core_Exception
65 public static function &getValues($entityBlock) {
66 return CRM_Core_BAO_Block
::getValues('openid', $entityBlock);
70 * Get all the openids for a specified contact_id, with the primary openid being first
75 * @param bool $updateBlankLocInfo
78 * the array of openid's
80 public static function allOpenIDs($id, $updateBlankLocInfo = FALSE) {
86 SELECT civicrm_openid.openid, civicrm_location_type.name as locationType, civicrm_openid.is_primary as is_primary,
87 civicrm_openid.allowed_to_login as allowed_to_login, civicrm_openid.id as openid_id,
88 civicrm_openid.location_type_id as locationTypeId
90 LEFT JOIN civicrm_openid ON ( civicrm_openid.contact_id = civicrm_contact.id )
91 LEFT JOIN civicrm_location_type ON ( civicrm_openid.location_type_id = civicrm_location_type.id )
93 civicrm_contact.id = %1
95 civicrm_openid.is_primary DESC, openid_id ASC ";
96 $params = [1 => [$id, 'Integer']];
98 $openids = $values = [];
99 $dao = CRM_Core_DAO
::executeQuery($query, $params);
101 while ($dao->fetch()) {
103 'locationType' => $dao->locationType
,
104 'is_primary' => $dao->is_primary
,
105 'id' => $dao->openid_id
,
106 'openid' => $dao->openid
,
107 'locationTypeId' => $dao->locationTypeId
,
108 'allowed_to_login' => $dao->allowed_to_login
,
111 if ($updateBlankLocInfo) {
112 $openids[$count++
] = $values;
115 $openids[$dao->openid_id
] = $values;
122 * Call common delete function.
124 * @see \CRM_Contact_BAO_Contact::on_hook_civicrm_post
130 public static function del($id) {
131 return (bool) self
::deleteRecord(['id' => $id]);