INFRA-132 - Remove white space after an opening "(" or before a closing ")"
[civicrm-core.git] / CRM / Profile / Form.php
index 3c98c3b2e62d886f1d91bdce76acf9190bd4b687..3bcc0e73d9eb8bf12bc47d5d537886580afcc1a3 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -42,7 +42,7 @@
  *
  */
 class CRM_Profile_Form extends CRM_Core_Form {
-  CONST
+  const
     MODE_REGISTER = 1,
     MODE_SEARCH   = 2,
     MODE_CREATE   = 4,
@@ -91,14 +91,14 @@ class CRM_Profile_Form extends CRM_Core_Form {
   protected $_title;
 
   /**
-   * the fields needed to build this form
+   * The fields needed to build this form
    *
    * @var array
    */
   public $_fields;
 
   /**
-   * to store contact details
+   * To store contact details
    *
    * @var array
    */
@@ -157,7 +157,7 @@ class CRM_Profile_Form extends CRM_Core_Form {
   protected $_recordId = NULL;
 
   /**
-   * action for multi record profile (create/edit/delete)
+   * Action for multi record profile (create/edit/delete)
    *
    * @var string
    */
@@ -177,7 +177,7 @@ class CRM_Profile_Form extends CRM_Core_Form {
   protected $_session       = NULL;
 
   /**
-   * pre processing work done here.
+   * Pre processing work done here.
    *
    * gets session variables for table name, id of entity in table, type of entity and stores them.
    *
@@ -185,9 +185,8 @@ class CRM_Profile_Form extends CRM_Core_Form {
    *
    * @return void
    *
-   * @access public
    */
-  function preProcess() {
+  public function preProcess() {
     $this->_id         = $this->get('id');
     $this->_profileIds = $this->get('profileIds');
     $this->_grid       = CRM_Utils_Request::retrieve('grid', 'Integer', $this);
@@ -210,8 +209,7 @@ class CRM_Profile_Form extends CRM_Core_Form {
     if ($this->_mode == self::MODE_EDIT) {
       //specifies the action being done on a multi record field
       $multiRecordAction = CRM_Utils_Request::retrieve('multiRecord', 'String', $this);
-      $this->_multiRecord = (!is_numeric($multiRecordAction)) ?
-        CRM_Core_Action::resolve($multiRecordAction) : $multiRecordAction;
+      $this->_multiRecord = (!is_numeric($multiRecordAction)) ? CRM_Core_Action::resolve($multiRecordAction) : $multiRecordAction;
       if ($this->_multiRecord) {
         $this->set('multiRecord', $this->_multiRecord);
       }
@@ -311,7 +309,8 @@ class CRM_Profile_Form extends CRM_Core_Form {
         if ($this->_multiRecord) {
           if ($this->_multiRecord != CRM_Core_Action::ADD) {
             $this->_recordId = CRM_Utils_Request::retrieve('recordId', 'Positive', $this);
-          } else {
+          }
+          else {
             $this->_recordId = NULL;
             $this->set('recordId', NULL);
           }
@@ -321,8 +320,9 @@ class CRM_Profile_Form extends CRM_Core_Form {
             CRM_Core_Error::fatal(ts('The requested Profile (gid=%1) requires record id while performing this action',
               array(1 => $this->_gid)
             ));
-          } elseif (empty($this->_multiRecordFields)) {
-              CRM_Core_Error::fatal(ts('No Multi-Record Fields configured for this profile (gid=%1)',
+          }
+          elseif (empty($this->_multiRecordFields)) {
+            CRM_Core_Error::fatal(ts('No Multi-Record Fields configured for this profile (gid=%1)',
               array(1 => $this->_gid)
             ));
           }
@@ -341,7 +341,8 @@ class CRM_Profile_Form extends CRM_Core_Form {
 
             if (array_key_exists($this->_recordId, $getValues)) {
               $this->_recordExists = TRUE;
-            } else {
+            }
+            else {
               $this->_recordExists = FALSE;
               if ($this->_multiRecord & CRM_Core_Action::UPDATE) {
                 CRM_Core_Session::setStatus(ts('Note: The record %1 doesnot exists. Upon save a new record will be create', array(1 => $this->_recordId)), ts('Record doesnot exist'), 'alert');
@@ -355,8 +356,9 @@ class CRM_Profile_Form extends CRM_Core_Form {
             }
           }
 
-        } elseif (!empty($this->_multiRecordFields)
-           && (!$this->_multiRecord || !in_array($this->_multiRecord, array(CRM_Core_Action::DELETE, CRM_Core_Action::UPDATE)) )) {
+        }
+        elseif (!empty($this->_multiRecordFields)
+           && (!$this->_multiRecord || !in_array($this->_multiRecord, array(CRM_Core_Action::DELETE, CRM_Core_Action::UPDATE)))) {
           CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js', 1, 'html-header');
           //multirecord listing page
           $multiRecordFieldListing = TRUE;
@@ -393,7 +395,8 @@ class CRM_Profile_Form extends CRM_Core_Form {
       if ($this->_multiRecord && !empty($this->_multiRecordFields)) {
         $this->_fields = $this->_multiRecordFields;
         $this->_multiRecordProfile = TRUE;
-      } elseif ($this->_multiRecord && empty($this->_multiRecordFields)) {
+      }
+      elseif ($this->_multiRecord && empty($this->_multiRecordFields)) {
         CRM_Core_Session::setStatus(ts('This feature is not currently available.'), ts('Sorry'), 'error');
         CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm', 'reset=1'));
       }
@@ -409,11 +412,10 @@ class CRM_Profile_Form extends CRM_Core_Form {
    * Set default values for the form. Note that in edit/view mode
    * the default values are retrieved from the database
    *
-   * @access public
    *
    * @return void
    */
-  function setDefaultsValues() {
+  public function setDefaultsValues() {
     $this->_defaults = array();
     if ($this->_multiRecordProfile && ($this->_multiRecord == CRM_Core_Action::DELETE)) {
       return;
@@ -452,12 +454,13 @@ class CRM_Profile_Form extends CRM_Core_Form {
         $fieldIds[] = CRM_Core_BAO_CustomField::getKeyID($key);
       }
 
-      $defaultValues = array( );
+      $defaultValues = array();
       if ($this->_multiRecord && $this->_multiRecord == CRM_Core_Action::UPDATE) {
         $defaultValues = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_id, NULL, $fieldIds, TRUE);
         if ($this->_recordExists == TRUE) {
           $defaultValues = $defaultValues[$this->_recordId];
-        } else {
+        }
+        else {
           $defaultValues = NULL;
         }
       }
@@ -475,7 +478,8 @@ class CRM_Profile_Form extends CRM_Core_Form {
                 $this->_mode,
                 $value
               );
-            } else {
+            }
+            else {
               $this->_defaults[$name] = "";
             }
           }
@@ -582,7 +586,6 @@ class CRM_Profile_Form extends CRM_Core_Form {
    * Build the form object
    *
    * @return void
-   * @access public
    */
   public function buildQuickForm() {
     $this->add('hidden', 'gid', $this->_gid);
@@ -593,9 +596,11 @@ class CRM_Profile_Form extends CRM_Core_Form {
       case self::MODE_REGISTER:
         CRM_Utils_Hook::buildProfile($this->_ufGroup['name']);
         break;
+
       case self::MODE_SEARCH:
         CRM_Utils_Hook::searchProfile($this->_ufGroup['name']);
         break;
+
       default:
     }
 
@@ -652,7 +657,7 @@ class CRM_Profile_Form extends CRM_Core_Form {
 
         if (
           ($profileType != 'Contact' && !$this->_isContactActivityProfile) &&
-          (($profileSubType && !empty($contactSubtypes) && (!in_array($profileSubType,$contactSubtypes))) ||
+          (($profileSubType && !empty($contactSubtypes) && (!in_array($profileSubType, $contactSubtypes))) ||
             ($profileType != $contactType))
         ) {
           $return = TRUE;
@@ -766,7 +771,7 @@ class CRM_Profile_Form extends CRM_Core_Form {
       if ($this->_currentUserID) {
         $this->_isAddCaptcha = FALSE;
       }
-      else if (!$this->_isAddCaptcha && !empty($addCaptcha)) {
+      elseif (!$this->_isAddCaptcha && !empty($addCaptcha)) {
         $this->_isAddCaptcha = TRUE;
       }
 
@@ -835,7 +840,7 @@ class CRM_Profile_Form extends CRM_Core_Form {
    *
    * @return array
    */
-  static function validateContactActivityProfile($activityId, $contactId, $gid) {
+  public static function validateContactActivityProfile($activityId, $contactId, $gid) {
     $errors = array();
     if (!$activityId) {
       $errors[] = 'Profile is using one or more activity fields, and is missing the activity Id (aid) in the URL.';
@@ -867,17 +872,19 @@ class CRM_Profile_Form extends CRM_Core_Form {
   }
 
   /**
-   * global form rule
+   * Global form rule
    *
-   * @param array  $fields the input form values
-   * @param array  $files  the uploaded files if any
-   * @param CRM_Core_Form $form   the form object
+   * @param array $fields
+   *   The input form values.
+   * @param array $files
+   *   The uploaded files if any.
+   * @param CRM_Core_Form $form
+   *   The form object.
    *
    * @return true if no errors, else array of errors
-   * @access public
    * @static
    */
-  static function formRule($fields, $files, $form) {
+  public static function formRule($fields, $files, $form) {
     CRM_Utils_Hook::validateProfile($form->_ufGroup['name']);
 
     $errors = array();
@@ -1049,7 +1056,6 @@ class CRM_Profile_Form extends CRM_Core_Form {
   /**
    * Process the user submitted custom data values.
    *
-   * @access public
    *
    * @return void
    */
@@ -1069,8 +1075,8 @@ class CRM_Profile_Form extends CRM_Core_Form {
                           1 => array($this->_recordId, 'Integer'),
                           2 => array($this->_id, 'Integer')
                          );
-           CRM_Core_DAO::executeQuery($sql, $sqlParams);
-           CRM_Core_Session::setStatus(ts('Your record has been deleted.'), ts('Deleted'), 'success');
+            CRM_Core_DAO::executeQuery($sql, $sqlParams);
+            CRM_Core_Session::setStatus(ts('Your record has been deleted.'), ts('Deleted'), 'success');
           }
         }
         return;
@@ -1313,7 +1319,7 @@ class CRM_Profile_Form extends CRM_Core_Form {
    *
    * @return null|string
    */
-  function checkTemplateFileExists($suffix = NULL) {
+  public function checkTemplateFileExists($suffix = NULL) {
     if ($this->_gid) {
       $templateFile = "CRM/Profile/Form/{$this->_gid}/{$this->_name}.{$suffix}tpl";
       $template = CRM_Core_Form::getTemplate();
@@ -1337,12 +1343,11 @@ class CRM_Profile_Form extends CRM_Core_Form {
    * Use the form name to create the tpl file name
    *
    * @return string
-   * @access public
    */
   /**
    * @return string
    */
-  function getTemplateFileName() {
+  public function getTemplateFileName() {
     $fileName = $this->checkTemplateFileExists();
     return $fileName ? $fileName : parent::getTemplateFileName();
   }
@@ -1352,14 +1357,12 @@ class CRM_Profile_Form extends CRM_Core_Form {
    * i.e. we dont override
    *
    * @return string
-   * @access public
    */
   /**
    * @return string
    */
-  function overrideExtraTemplateFileName() {
+  public function overrideExtraTemplateFileName() {
     $fileName = $this->checkTemplateFileExists('extra.');
     return $fileName ? $fileName : parent::overrideExtraTemplateFileName();
   }
 }
-