Merge pull request #6559 from jitendrapurohit/CRM-16877
[civicrm-core.git] / CRM / Contact / Form / Inline / OpenID.php
index 4b0c3828d5294b704804e1e1e316c38db52358c4..b0cb88ff59f1d8cf5a96c5cd6aacf9d1990cea35 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.6                                                |
+ | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
- * $Id$
- *
+ * @copyright CiviCRM LLC (c) 2004-2015
  */
 
 /**
- * form helper class for an OpenID object
+ * Form helper class for an OpenID object.
  */
 class CRM_Contact_Form_Inline_OpenID extends CRM_Contact_Form_Inline {
 
   /**
-   * Ims of the contact that is been viewed
+   * Ims of the contact that is been viewed.
    */
   private $_openids = array();
 
   /**
-   * No of openid blocks for inline edit
+   * No of openid blocks for inline edit.
    */
   private $_blockCount = 6;
 
   /**
-   * Call preprocess
+   * Call preprocess.
    */
   public function preProcess() {
     parent::preProcess();
@@ -62,9 +60,7 @@ class CRM_Contact_Form_Inline_OpenID extends CRM_Contact_Form_Inline {
   }
 
   /**
-   * Build the form object elements for openID object
-   *
-   * @return void
+   * Build the form object elements for openID object.
    */
   public function buildQuickForm() {
     parent::buildQuickForm();
@@ -96,7 +92,7 @@ class CRM_Contact_Form_Inline_OpenID extends CRM_Contact_Form_Inline {
   }
 
   /**
-   * Global validation rules for the form
+   * Global validation rules for the form.
    *
    * @param array $fields
    *   Posted values of the form.
@@ -104,7 +100,6 @@ class CRM_Contact_Form_Inline_OpenID extends CRM_Contact_Form_Inline {
    *   List of errors to be posted back to the form.
    *
    * @return array
-   * @static
    */
   public static function formRule($fields, $errors) {
     $hasData = $hasPrimary = $errors = array();
@@ -117,7 +112,7 @@ class CRM_Contact_Form_Inline_OpenID extends CRM_Contact_Form_Inline {
           if (!empty($blockValues['is_primary'])) {
             $hasPrimary[] = $instance;
             if (!$primaryID && !empty($blockValues['openid'])) {
-                $primaryID = $blockValues['openid'];
+              $primaryID = $blockValues['openid'];
             }
           }
         }
@@ -135,7 +130,7 @@ class CRM_Contact_Form_Inline_OpenID extends CRM_Contact_Form_Inline {
   }
 
   /**
-   * Set defaults for the form
+   * Set defaults for the form.
    *
    * @return array
    */
@@ -155,9 +150,7 @@ class CRM_Contact_Form_Inline_OpenID extends CRM_Contact_Form_Inline {
   }
 
   /**
-   * Process the form
-   *
-   * @return void
+   * Process the form.
    */
   public function postProcess() {
     $params = $this->exportValues();
@@ -165,9 +158,16 @@ class CRM_Contact_Form_Inline_OpenID extends CRM_Contact_Form_Inline {
     // Process / save openID
     $params['contact_id'] = $this->_contactId;
     $params['updateBlankLocInfo'] = TRUE;
+    $params['openid']['isIdSet'] = TRUE;
+    foreach ($this->_openids as $count => $value) {
+      if (!empty($value['id']) && isset($params['openid'][$count])) {
+        $params['openid'][$count]['id'] = $value['id'];
+      }
+    }
     CRM_Core_BAO_Block::create('openid', $params);
 
     $this->log();
     $this->response();
   }
+
 }