X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBAO%2FFile.php;h=064fa7b263c8f4da40328adc5af04ad70663990e;hb=ff7da3a6508d0a7059c6527216920b2efb896b93;hp=e888505821be16912434663044fb6d8e713f5749;hpb=fe6a56117db7e9dada18e60f91de717a89013d86;p=civicrm-core.git diff --git a/CRM/Core/BAO/File.php b/CRM/Core/BAO/File.php index e888505821..064fa7b263 100644 --- a/CRM/Core/BAO/File.php +++ b/CRM/Core/BAO/File.php @@ -1,7 +1,7 @@ entity_table = $entityTable; @@ -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,17 +211,17 @@ 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 */ - 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; } @@ -251,7 +251,7 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File { //delete tags from entity tag table $tagParams = array( 'entity_table' => 'civicrm_file', - 'entity_id' => $fId + 'entity_id' => $fId, ); CRM_Core_BAO_EntityTag::del($tagParams); @@ -274,7 +274,7 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File { * 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 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 = " @@ -345,7 +346,8 @@ FROM civicrm_file AS CF LEFT JOIN civicrm_entity_file AS CEF ON ( CEF.file_id = CF.id ) WHERE CF.id = %2"; - } else { + } + else { $sql = " SELECT CF.id as cfID, CF.uri as uri, @@ -385,7 +387,7 @@ AND CEF.entity_id = %2"; * @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 +421,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, + '  ', TRUE); // get tagset info $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_file'); @@ -439,7 +442,7 @@ AND CEF.entity_id = %2"; $form->addElement('text', "attachDesc_$i", NULL, array( 'size' => 40, 'maxlength' => 255, - 'placeholder' => ts('Description') + 'placeholder' => ts('Description'), )); if (!empty($tags)) { @@ -448,7 +451,7 @@ AND CEF.entity_id = %2"; 'id' => "tags_$i", 'multiple' => 'multiple', 'class' => 'huge crm-select2', - 'placeholder' => ts('- none -') + 'placeholder' => ts('- none -'), ) ); } @@ -460,14 +463,17 @@ 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 */ - static function attachmentInfo($entityTable, $entityID, $separator = '
') { + public static function attachmentInfo($entityTable, $entityID, $separator = '
') { if (!$entityID) { return NULL; } @@ -489,7 +495,7 @@ AND CEF.entity_id = %2"; * @param $entityTable * @param int $entityID */ - static function formatAttachment( + public static function formatAttachment( &$formValues, &$params, $entityTable, @@ -529,7 +535,7 @@ AND CEF.entity_id = %2"; 'description' => $formValues[$attachDesc], 'upload_date' => $now, 'tag' => $tagParams, - 'attachment_taglist' => CRM_Utils_Array::value($attachFreeTags, $formValues, array()) + 'attachment_taglist' => CRM_Utils_Array::value($attachFreeTags, $formValues, array()), ); $params[$attachName] = $fileParams; @@ -542,7 +548,7 @@ AND CEF.entity_id = %2"; * @param $entityTable * @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 +574,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(); @@ -579,17 +585,16 @@ 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 * @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; @@ -611,7 +616,7 @@ AND CEF.entity_id = %2"; * * @return string */ - static function deleteURLArgs($entityTable, $entityID, $fileID) { + public static function deleteURLArgs($entityTable, $entityID, $fileID) { $params['entityTable'] = $entityTable; $params['entityID'] = $entityID; $params['fileID'] = $fileID; @@ -624,10 +629,8 @@ AND CEF.entity_id = %2"; /** * 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); @@ -647,16 +650,17 @@ 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 - * @access public */ - static function paperIconAttachment($entityTable, $entityID) { + public static function paperIconAttachment($entityTable, $entityID) { if (empty($entityTable) || !$entityID) { $results = NULL; return $results; @@ -665,7 +669,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' || @@ -702,7 +705,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); @@ -713,4 +716,5 @@ AND CEF.entity_id = %2"; } return NULL; } + }