Skip to content

Commit

Permalink
set default created_id value to BAO
Browse files Browse the repository at this point in the history
  • Loading branch information
monishdeb committed Apr 18, 2018
1 parent f7e5f5a commit 4d7f650
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
21 changes: 21 additions & 0 deletions CRM/Core/BAO/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,27 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File {

static $_signableFields = array('entityTable', 'entityID', 'fileID');

/**
* Takes an associative array and creates a File object.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
*
* @return CRM_Core_BAO_File
*/
public static function create($params) {
$fileDAO = new CRM_Core_DAO_File();
$fileDAO->copyValues($params);

if (empty($params['created_id'])) {
$fileDAO->created_id = CRM_Core_Session::getLoggedInContactID();
}

$fileDAO->save();

return $fileDAO;
}

/**
* @param int $fileID
* @param int $entityID
Expand Down
4 changes: 2 additions & 2 deletions CRM/Upgrade/Incremental/php/FiveTwo.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public static function addFileCreatedIdColumn(CRM_Queue_TaskContext $ctx) {
ON UPDATE CASCADE;
");

return TRUE;
}
return TRUE;
}

/*
* Important! All upgrade functions MUST add a 'runSql' task.
Expand Down
1 change: 0 additions & 1 deletion api/v3/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,6 @@ function _civicrm_api3_attachment_getfields() {
'title' => 'Created By Contact ID',
'type' => CRM_Utils_Type::T_INT,
'description' => 'FK to civicrm_contact, who uploaded this file',
'api.default' => 'user_contact_id',
);

return $spec;
Expand Down

0 comments on commit 4d7f650

Please sign in to comment.