Merge pull request #17504 from eileenmcnaughton/renewd
[civicrm-core.git] / CRM / Contact / Form / Edit / OpenID.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 /**
19 * Form helper class for an OpenID object.
20 */
21 class CRM_Contact_Form_Edit_OpenID {
22
23 /**
24 * Build the form object elements for an open id object.
25 *
26 * @param CRM_Core_Form $form
27 * Reference to the form object.
28 * @param int $blockCount
29 * Block number to build.
30 * @param bool $blockEdit
31 * Is it block edit.
32 */
33 public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE) {
34 if (!$blockCount) {
35 $blockId = ($form->get('OpenID_Block_Count')) ? $form->get('OpenID_Block_Count') : 1;
36 }
37 else {
38 $blockId = $blockCount;
39 }
40 $form->applyFilter('__ALL__', 'trim');
41
42 $form->addElement('text', "openid[$blockId][openid]", ts('OpenID'),
43 CRM_Core_DAO::getAttribute('CRM_Core_DAO_OpenID', 'openid')
44 );
45 $form->addRule("openid[$blockId][openid]", ts('OpenID is not a valid URL.'), 'url');
46
47 //Block type
48 $form->addElement('select', "openid[$blockId][location_type_id]", '', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'));
49
50 //is_Primary radio
51 $js = ['id' => "OpenID_" . $blockId . "_IsPrimary"];
52 if (!$blockEdit) {
53 $js['onClick'] = 'singleSelect( this.id );';
54 }
55
56 $form->addElement('radio', "openid[$blockId][is_primary]", '', '', '1', $js);
57 }
58
59 }