fix error where 4.6 change was not merged correctly to master.
[civicrm-core.git] / CRM / Core / BAO / File.php
index 5538b9282dc9b0cee4a3cce983d19ac64ad4fc39..e0ccca18db24ff1287891f4c98d9dfb709b6f70c 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | 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
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
@@ -85,7 +85,7 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File {
    *
    * @throws Exception
    */
-  static function filePostProcess(
+  public static function filePostProcess(
     $data,
     $fileTypeID,
     $entityTable,
@@ -211,19 +211,22 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File {
   /**
    * The $useWhere is used so that the signature matches the parent class
    *
-  public function delete($useWhere = FALSE) {
-    list($fileID, $entityID, $fieldID) = func_get_args();
-
-    self::deleteFileReferences($fileID, $entityID, $fieldID);
-  } */
+   * public function delete($useWhere = FALSE) {
+   * list($fileID, $entityID, $fieldID) = func_get_args();
+   *
+   * self::deleteFileReferences($fileID, $entityID, $fieldID);
+   * } */
 
   /**
    * Delete all the files and associated object associated with this
    * combination
+   * @return bool
+   *   Was file deleted?
    */
   public static function deleteEntityFile($entityTable, $entityID, $fileTypeID = NULL, $fileID = NULL) {
+    $isDeleted = FALSE;
     if (empty($entityTable) || empty($entityID)) {
-      return;
+      return $isDeleted;
     }
 
     $config = CRM_Core_Config::singleton();
@@ -242,6 +245,7 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File {
       $cefIDs = implode(',', $cefIDs);
       $sql = "DELETE FROM civicrm_entity_file where id IN ( $cefIDs )";
       CRM_Core_DAO::executeQuery($sql);
+      $isDeleted = TRUE;
     }
 
     if (!empty($cfIDs)) {
@@ -267,7 +271,9 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File {
         $sql = "DELETE FROM civicrm_file where id IN ( $deleteFiles )";
         CRM_Core_DAO::executeQuery($sql);
       }
+      $isDeleted = TRUE;
     }
+    return $isDeleted;
   }
 
   /**
@@ -463,15 +469,15 @@ AND       CEF.entity_id    = %2";
    * Return a clean url string and the number of attachment for a
    * given entityTable, entityID
    *
-   * @param $entityTable
-   *   String The entityTable to which the file is attached.
-   * @param $entityID
-   *   Int The id of the object in the above entityTable.
-   * @param $separator
-   *   String The string separator where to implode the urls.
+   * @param string $entityTable
+   *   The entityTable to which the file is attached.
+   * @param int $entityID
+   *   The id of the object in the above entityTable.
+   * @param string $separator
+   *   The string separator where to implode the urls.
    *
-   * @return array              An array with 2 elements. The string and the number of attachments
-   * @static
+   * @return array
+   *   An array with 2 elements. The string and the number of attachments
    */
   public static function attachmentInfo($entityTable, $entityID, $separator = '<br />') {
     if (!$entityID) {
@@ -495,7 +501,7 @@ AND       CEF.entity_id    = %2";
    * @param $entityTable
    * @param int $entityID
    */
-  static function formatAttachment(
+  public static function formatAttachment(
     &$formValues,
     &$params,
     $entityTable,
@@ -585,11 +591,10 @@ AND       CEF.entity_id    = %2";
     return $names;
   }
 
-  /*
+  /**
    * copy/attach an existing file to a different entity
    * table and id.
-   */
-  /**
+   *
    * @param $oldEntityTable
    * @param int $oldEntityId
    * @param $newEntityTable
@@ -630,7 +635,6 @@ AND       CEF.entity_id    = %2";
   /**
    * Delete a file attachment from an entity table / entity ID
    *
-   * @static
    */
   public static function deleteAttachment() {
     $params = array();
@@ -652,15 +656,15 @@ AND       CEF.entity_id    = %2";
   /**
    * Display paper icon for a file attachment -- CRM-13624
    *
-   * @param $entityTable
-   *   String The entityTable to which the file is attached. eg "civicrm_contact", "civicrm_note", "civicrm_activity".
+   * @param string $entityTable
+   *   The entityTable to which the file is attached. eg "civicrm_contact", "civicrm_note", "civicrm_activity".
    *                             If you have the ID of a specific row in civicrm_file, use $entityTable='*'
-   * @param $entityID
-   *   Int The id of the object in the above entityTable.
+   * @param int $entityID
+   *   The id of the object in the above entityTable.
    *
-   * @return array|NULL          list of HTML snippets; one HTML snippet for each attachment. If none found, then NULL
+   * @return array|NULL
+   *   list of HTML snippets; one HTML snippet for each attachment. If none found, then NULL
    *
-   * @static
    */
   public static function paperIconAttachment($entityTable, $entityID) {
     if (empty($entityTable) || !$entityID) {
@@ -671,7 +675,6 @@ AND       CEF.entity_id    = %2";
     foreach ($currentAttachmentInfo as $fileKey => $fileValue) {
       $fileID = $fileValue['fileID'];
       $fileType = $fileValue['mime_type'];
-      $eid = $entityID;
       if ($fileID) {
         if ($fileType == 'image/jpeg' ||
           $fileType == 'image/pjpeg' ||
@@ -719,4 +722,5 @@ AND       CEF.entity_id    = %2";
     }
     return NULL;
   }
+
 }