INFRA-132 - CRM/Contribute - Misc
[civicrm-core.git] / CRM / Core / BAO / File.php
index 8bb38e85a8854ce4611fe54fbb7259e9182a8ab5..ee584c68a0878f7197051e7ea8f54c3b231c21f8 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -41,13 +41,13 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File {
   static $_signableFields = array('entityTable', 'entityID', 'fileID');
 
   /**
-   * @param $fileID
-   * @param $entityID
+   * @param int $fileID
+   * @param int $entityID
    * @param null $entityTable
    *
    * @return array
    */
-  static function path($fileID, $entityID, $entityTable = NULL) {
+  public static function path($fileID, $entityID, $entityTable = NULL) {
     $entityFileDAO = new CRM_Core_DAO_EntityFile();
     if ($entityTable) {
       $entityFileDAO->entity_table = $entityTable;
@@ -74,9 +74,9 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File {
 
   /**
    * @param $data
-   * @param $fileTypeID
+   * @param int $fileTypeID
    * @param $entityTable
-   * @param $entityID
+   * @param int $entityID
    * @param $entitySubtype
    * @param bool $overwrite
    * @param null|array $fileParams
@@ -218,10 +218,10 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File {
   } */
 
   /**
-   * delete all the files and associated object associated with this
+   * Delete all the files and associated object associated with this
    * combination
    */
-  static function deleteEntityFile($entityTable, $entityID, $fileTypeID = NULL, $fileID = NULL) {
+  public static function deleteEntityFile($entityTable, $entityID, $fileTypeID = NULL, $fileID = NULL) {
     if (empty($entityTable) || empty($entityID)) {
       return;
     }
@@ -271,10 +271,10 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File {
   }
 
   /**
-   * get all the files and associated object associated with this
+   * Get all the files and associated object associated with this
    * combination
    */
-  static function getEntityFile($entityTable, $entityID, $addDeleteArgs = FALSE) {
+  public static function getEntityFile($entityTable, $entityID, $addDeleteArgs = FALSE) {
     if (empty($entityTable) || !$entityID) {
       $results = NULL;
       return $results;
@@ -323,14 +323,15 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File {
   }
 
   /**
-   * @param string $entityTable table-name or "*" (to reference files directly by file-id)
+   * @param string $entityTable
+   *   Table-name or "*" (to reference files directly by file-id).
    * @param int $entityID
-   * @param null $fileTypeID
-   * @param null $fileID
+   * @param int $fileTypeID
+   * @param int $fileID
    *
    * @return array
    */
-  static function sql($entityTable, $entityID, $fileTypeID = NULL, $fileID = NULL) {
+  public static function sql($entityTable, $entityID, $fileTypeID = NULL, $fileID = NULL) {
     if ($entityTable == '*') {
       // $entityID is the ID of a specific file
       $sql = "
@@ -381,11 +382,11 @@ AND       CEF.entity_id    = %2";
   /**
    * @param CRM_Core_Form $form
    * @param string $entityTable
-   * @param null $entityID
+   * @param int $entityID
    * @param null $numAttachments
    * @param bool $ajaxDelete
    */
-  static function buildAttachment(&$form, $entityTable, $entityID = NULL, $numAttachments = NULL, $ajaxDelete = FALSE) {
+  public static function buildAttachment(&$form, $entityTable, $entityID = NULL, $numAttachments = NULL, $ajaxDelete = FALSE) {
 
     if (!$numAttachments) {
       $numAttachments = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'max_attachments');
@@ -419,7 +420,8 @@ AND       CEF.entity_id    = %2";
 
     $form->assign('numAttachments', $numAttachments);
 
-    $tags = CRM_Core_BAO_Tag::getTags('civicrm_file');
+    CRM_Core_BAO_Tag::getTags('civicrm_file', $tags, NULL,
+      '&nbsp;&nbsp;', TRUE);
 
     // get tagset info
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_file');
@@ -457,17 +459,20 @@ AND       CEF.entity_id    = %2";
   }
 
   /**
-   * Function to return a clean url string and the number of attachment for a
+   * 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 $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.
    *
    * @return array              An array with 2 elements. The string and the number of attachments
    * @static
    */
-  static function attachmentInfo($entityTable, $entityID, $separator = '<br />') {
+  public static function attachmentInfo($entityTable, $entityID, $separator = '<br />') {
     if (!$entityID) {
       return NULL;
     }
@@ -485,9 +490,9 @@ AND       CEF.entity_id    = %2";
 
   /**
    * @param $formValues
-   * @param $params
+   * @param array $params
    * @param $entityTable
-   * @param null $entityID
+   * @param int $entityID
    */
   static function formatAttachment(
     &$formValues,
@@ -538,11 +543,11 @@ AND       CEF.entity_id    = %2";
   }
 
   /**
-   * @param $params
+   * @param array $params
    * @param $entityTable
-   * @param $entityID
+   * @param int $entityID
    */
-  static function processAttachment(&$params, $entityTable, $entityID) {
+  public static function processAttachment(&$params, $entityTable, $entityID) {
     $numAttachments = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'max_attachments');
 
     for ($i = 1; $i <= $numAttachments; $i++) {
@@ -568,7 +573,7 @@ AND       CEF.entity_id    = %2";
   /**
    * @return array
    */
-  static function uploadNames() {
+  public static function uploadNames() {
     $numAttachments = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'max_attachments');
 
     $names = array();
@@ -580,16 +585,16 @@ AND       CEF.entity_id    = %2";
   }
 
   /*
-   * Function to copy/attach an existing file to a different entity
+   * copy/attach an existing file to a different entity
    * table and id.
    */
   /**
    * @param $oldEntityTable
-   * @param $oldEntityId
+   * @param int $oldEntityId
    * @param $newEntityTable
-   * @param $newEntityId
+   * @param int $newEntityId
    */
-  static function copyEntityFile($oldEntityTable, $oldEntityId, $newEntityTable, $newEntityId) {
+  public static function copyEntityFile($oldEntityTable, $oldEntityId, $newEntityTable, $newEntityId) {
     $oldEntityFile = new CRM_Core_DAO_EntityFile();
     $oldEntityFile->entity_id = $oldEntityId;
     $oldEntityFile->entity_table = $oldEntityTable;
@@ -606,12 +611,12 @@ AND       CEF.entity_id    = %2";
 
   /**
    * @param $entityTable
-   * @param $entityID
-   * @param $fileID
+   * @param int $entityID
+   * @param int $fileID
    *
    * @return string
    */
-  static function deleteURLArgs($entityTable, $entityID, $fileID) {
+  public static function deleteURLArgs($entityTable, $entityID, $fileID) {
     $params['entityTable'] = $entityTable;
     $params['entityID'] = $entityID;
     $params['fileID'] = $fileID;
@@ -622,12 +627,11 @@ AND       CEF.entity_id    = %2";
   }
 
   /**
-   * function to delete a file attachment from an entity table / entity ID
+   * Delete a file attachment from an entity table / entity ID
    *
    * @static
-   * @access public
    */
-  static function deleteAttachment() {
+  public static function deleteAttachment() {
     $params = array();
     $params['entityTable'] = CRM_Utils_Request::retrieve('entityTable', 'String', CRM_Core_DAO::$_nullObject, TRUE);
     $params['entityID'] = CRM_Utils_Request::retrieve('entityID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
@@ -645,18 +649,19 @@ AND       CEF.entity_id    = %2";
 
 
   /**
-   * function to display paper icon for a file attachment -- CRM-13624
+   * 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 $entityTable
+   *   String 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 $entityID
+   *   Int 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
    *
    * @static
-   * @access public
    */
-  static function paperIconAttachment($entityTable, $entityID) {
+  public static function paperIconAttachment($entityTable, $entityID) {
     if (empty($entityTable) || !$entityID) {
       $results = NULL;
       return $results;
@@ -702,7 +707,7 @@ AND       CEF.entity_id    = %2";
    *
    * @return CRM_Core_FileSearchInterface|NULL
    */
-  static function getSearchService() {
+  public static function getSearchService() {
     $fileSearches = array();
     CRM_Utils_Hook::fileSearches($fileSearches);