Merge pull request #4865 from eileenmcnaughton/my-first-factory
[civicrm-core.git] / CRM / Custom / Form / ChangeFieldType.php
index 4f3d0d7c526a4ce56fd1fe97cd7baf06c3df3732..d6f45443742edf51e8ec79b8d483e4631eb3146f 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
 class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form {
 
   /**
-   * the field id
+   * The field id
    *
    * @var int
-   * @access protected
    */
   protected $_id;
 
   /**
-   * array of custom field values
+   * Array of custom field values
    */
   protected $_values;
 
   /**
-   * mapper array of valid field type
+   * Mapper array of valid field type
    */
   protected $_htmlTypeTransitions;
 
   /**
-   * set up variables to build the form
+   * Set up variables to build the form
    *
    * @return void
    * @acess protected
    */
-  function preProcess() {
+  public function preProcess() {
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive',
       $this, TRUE
     );
@@ -91,10 +90,9 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form {
   }
 
   /**
-   * Function to actually build the form
+   * Build the form object
    *
    * @return void
-   * @access public
    */
   public function buildQuickForm() {
 
@@ -137,7 +135,6 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form {
    * Process the form when submitted
    *
    * @return void
-   * @access public
    */
   public function postProcess() {
     $params = $this->controller->exportValues($this->_name);
@@ -195,7 +192,13 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form {
       ), ts('Field Type Changed'), 'success');
   }
 
-  static function fieldTypeTransitions($dataType, $htmlType) {
+  /**
+   * @param $dataType
+   * @param $htmlType
+   *
+   * @return array|null
+   */
+  public static function fieldTypeTransitions($dataType, $htmlType) {
     // Text field is single value field,
     // can not be change to other single value option which contains option group
     if ($htmlType == 'Text') {
@@ -269,7 +272,8 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form {
         continue;
       }
       $value = CRM_Core_DAO::VALUE_SEPARATOR . $dao->{$column} . CRM_Core_DAO::VALUE_SEPARATOR;
-      $params = array(1 => array((string)$value, 'String'),
+      $params = array(
+      1 => array((string) $value, 'String'),
         2 => array($dao->id, 'Integer'),
       );
       CRM_Core_DAO::executeQuery($updateSql, $params);
@@ -286,14 +290,20 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form {
     $dao       = CRM_Core_DAO::executeQuery($selectSql);
     while ($dao->fetch()) {
       $values = self::explode($dao->{$column});
-      $params = array(1 => array((string)array_shift($values), 'String'),
+      $params = array(
+      1 => array((string) array_shift($values), 'String'),
         2 => array($dao->id, 'Integer'),
       );
       CRM_Core_DAO::executeQuery($updateSql, $params);
     }
   }
 
-  static function explode($str) {
+  /**
+   * @param $str
+   *
+   * @return array
+   */
+  public static function explode($str) {
     if (empty($str) || $str == CRM_Core_DAO::VALUE_SEPARATOR . CRM_Core_DAO::VALUE_SEPARATOR) {
       return array();
     }
@@ -302,4 +312,3 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form {
     }
   }
 }
-