autogenerate missing comments
[civicrm-core.git] / CRM / Contribute / Import / Parser.php
index 907eaec1ce8d13012200cdf3163e5e26810eb9fe..a0ede60f2375607d537ad63b7e5bc330c84890c7 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -115,13 +115,25 @@ abstract class CRM_Contribute_Import_Parser extends CRM_Import_Parser {
    */
   protected $_haveColumnHeader;
 
+  /**
+   * @param $fileName
+   * @param string $seperator
+   * @param $mapper
+   * @param bool $skipColumnHeader
+   * @param int $mode
+   * @param int $contactType
+   * @param int $onDuplicate
+   *
+   * @return mixed
+   * @throws Exception
+   */
   function run($fileName,
     $seperator = ',',
     &$mapper,
     $skipColumnHeader = FALSE,
-    $mode             = self::MODE_PREVIEW,
-    $contactType      = self::CONTACT_INDIVIDUAL,
-    $onDuplicate      = self::DUPLICATE_SKIP
+    $mode = self::MODE_PREVIEW,
+    $contactType = self::CONTACT_INDIVIDUAL,
+    $onDuplicate = self::DUPLICATE_SKIP
   ) {
     if (!is_array($fileName)) {
       CRM_Core_Error::fatal();
@@ -414,12 +426,23 @@ pppp   * @return void
     }
   }
 
+  /**
+   * @param $elements
+   */
   function setActiveFieldSoftCredit($elements) {
     for ($i = 0; $i < count($elements); $i++) {
       $this->_activeFields[$i]->_softCreditField = $elements[$i];
     }
   }
 
+  /**
+   * @param $elements
+   */
+  function setActiveFieldSoftCreditType($elements) {
+    for ($i = 0; $i < count($elements); $i++) {
+      $this->_activeFields[$i]->_softCreditType = $elements[$i];
+    }
+  }
   /**
    * function to format the field values for input to the api
    *
@@ -434,7 +457,10 @@ pppp   * @return void
           if (!isset($params[$this->_activeFields[$i]->_name])) {
             $params[$this->_activeFields[$i]->_name] = array();
           }
-          $params[$this->_activeFields[$i]->_name][$this->_activeFields[$i]->_softCreditField] = $this->_activeFields[$i]->_value;
+          $params[$this->_activeFields[$i]->_name][$i][$this->_activeFields[$i]->_softCreditField] = $this->_activeFields[$i]->_value;
+          if(isset($this->_activeFields[$i]->_softCreditType)){
+            $params[$this->_activeFields[$i]->_name][$i]['soft_credit_type_id'] = $this->_activeFields[$i]->_softCreditType;
+          }
         }
 
         if (!isset($params[$this->_activeFields[$i]->_name])) {
@@ -447,6 +473,13 @@ pppp   * @return void
     return $params;
   }
 
+  /**
+   * @param $name
+   * @param $title
+   * @param int $type
+   * @param string $headerPattern
+   * @param string $dataPattern
+   */
   function addField($name, $title, $type = CRM_Utils_Type::T_INT, $headerPattern = '//', $dataPattern = '//') {
     if (empty($name)) {
       $this->_fields['doNotImport'] = new CRM_Contribute_Import_Field($name, $title, $type, $headerPattern, $dataPattern);
@@ -469,6 +502,8 @@ pppp   * @return void
    *
    * @param CRM_Core_Session $store
    *
+   * @param int $mode
+   *
    * @return void
    * @access public
    */
@@ -535,10 +570,11 @@ pppp   * @return void
   /**
    * Export data to a CSV file
    *
-   * @param string $filename
+   * @param $fileName
    * @param array $header
    * @param data $data
    *
+   * @internal param string $filename
    * @return void
    * @access public
    */
@@ -554,7 +590,7 @@ pppp   * @return void
 
     foreach ($data as $datum) {
       foreach ($datum as $key => $value) {
-        if (is_array($value[0])) {
+        if (isset($value[0]) && is_array($value)) {
           foreach ($value[0] as $k1 => $v1) {
             if ($k1 == 'location_type_id') {
               continue;
@@ -572,7 +608,19 @@ pppp   * @return void
     fclose($fd);
   }
 
-  function errorFileName($type) {
+  /**
+   * Determines the file extension based on error code
+   *
+   * @var $type error code constant
+   * @return string
+   * @static
+   */
+  /**
+   * @param error $type
+   *
+   * @return string
+   */
+  static function errorFileName($type) {
     $fileName = NULL;
     if (empty($type)) {
       return $fileName;
@@ -598,7 +646,19 @@ pppp   * @return void
     return $fileName;
   }
 
-  function saveFileName($type) {
+  /**
+   * Determines the file name based on error code
+   *
+   * @var $type error code constant
+   * @return string
+   * @static
+   */
+  /**
+   * @param error $type
+   *
+   * @return string
+   */
+  static function saveFileName($type) {
     $fileName = NULL;
     if (empty($type)) {
       return $fileName;