Merge pull request #2352 from colemanw/4.4
[civicrm-core.git] / CRM / Core / BAO / File.php
index c10becaced6d29a70feb4e9b1d7d89d01120776c..8fae6a5ea83010ac982507518417211559d8c47f 100644 (file)
@@ -1,7 +1,7 @@
 <?php
  /*
   +--------------------------------------------------------------------+
-  | CiviCRM version 4.3                                                |
+  | CiviCRM version 4.4                                                |
   +--------------------------------------------------------------------+
   | Copyright CiviCRM LLC (c) 2004-2013                                |
   +--------------------------------------------------------------------+
    }
 
    /**
-    * The $useWhere is used so that the signature matches the parent class
+    * A static function wrapper that deletes the various objects that are
+    * connected to a file object (i.e. file, entityFile and customValue
     */
-   public function delete($useWhere = false) {
-     list($fileID, $entityID, $fieldID) = func_get_args();
-
+   public static function deleteFileReferences($fileID, $entityID, $fieldID) {
      $fileDAO = new CRM_Core_DAO_File();
      $fileDAO->id = $fileID;
      if (!$fileDAO->find(TRUE)) {
      CRM_Core_DAO::executeQuery($query, $params);
    }
 
+   /**
+    * 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);
+   }
+
    /**
     * delete all the files and associated object associated with this
     * combination
      }
 
      //fix tag names
-     $tags = CRM_Core_PseudoConstant::tag();
+     $tags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
 
      foreach($results as &$values) {
        if (!empty($values['tag'])) {
      // add attachments
      for ($i = 1; $i <= $numAttachments; $i++) {
        $form->addElement('file', "attachFile_$i", ts('Attach File'), 'size=30 maxlength=60');
+       $form->addUploadElement("attachFile_$i");
        $form->setMaxFileSize($maxFileSize * 1024 * 1024);
        $form->addRule("attachFile_$i",
          ts('File size should be less than %1 MByte(s)',
      }
 
      // build tagset widget
-     CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_file', NULL, FALSE, TRUE, FALSE);
+     CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_file', NULL, TRUE, TRUE, FALSE);
    }
 
    /**