Added a series of hooks to trigger backup jobs when files are uploaded/deleted.
This commit is contained in:
parent
982b330739
commit
7a952215aa
@ -276,6 +276,7 @@ class IDF_Form_IssueCreate extends Pluf_Form
|
||||
$comment->create();
|
||||
// If we have a file, create the IDF_IssueFile and attach
|
||||
// it to the comment.
|
||||
$created_files = array();
|
||||
for ($i=1;$i<4;$i++) {
|
||||
if ($this->cleaned_data['attachment'.$i]) {
|
||||
$file = new IDF_IssueFile();
|
||||
@ -283,8 +284,36 @@ class IDF_Form_IssueCreate extends Pluf_Form
|
||||
$file->submitter = $this->user;
|
||||
$file->comment = $comment;
|
||||
$file->create();
|
||||
$created_files[] = $file;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* [signal]
|
||||
*
|
||||
* IDF_Issue::create
|
||||
*
|
||||
* [sender]
|
||||
*
|
||||
* IDF_Form_IssueCreate
|
||||
*
|
||||
* [description]
|
||||
*
|
||||
* This signal allows an application to perform a set of tasks
|
||||
* just after the creation of an issue. The comment contains
|
||||
* the description of the issue.
|
||||
*
|
||||
* [parameters]
|
||||
*
|
||||
* array('issue' => $issue,
|
||||
* 'comment' => $comment,
|
||||
* 'files' => $attached_files);
|
||||
*
|
||||
*/
|
||||
$params = array('issue' => $issue,
|
||||
'comment' => $comment,
|
||||
'files' => $created_files);
|
||||
Pluf_Signal::send('IDF_Issue::create', 'IDF_Form_IssueCreate',
|
||||
$params);
|
||||
return $issue;
|
||||
}
|
||||
|
||||
|
@ -305,6 +305,7 @@ class IDF_Form_IssueUpdate extends IDF_Form_IssueCreate
|
||||
$this->issue->submitter != $this->user->id) {
|
||||
$this->issue->setAssoc($this->user); // interested user.
|
||||
}
|
||||
$attached_files = array();
|
||||
for ($i=1;$i<4;$i++) {
|
||||
if ($this->cleaned_data['attachment'.$i]) {
|
||||
$file = new IDF_IssueFile();
|
||||
@ -312,8 +313,36 @@ class IDF_Form_IssueUpdate extends IDF_Form_IssueCreate
|
||||
$file->submitter = $this->user;
|
||||
$file->comment = $comment;
|
||||
$file->create();
|
||||
$attached_files[] = $file;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* [signal]
|
||||
*
|
||||
* IDF_Issue::update
|
||||
*
|
||||
* [sender]
|
||||
*
|
||||
* IDF_Form_IssueUpdate
|
||||
*
|
||||
* [description]
|
||||
*
|
||||
* This signal allows an application to perform a set of tasks
|
||||
* just after the update of an issue.
|
||||
*
|
||||
* [parameters]
|
||||
*
|
||||
* array('issue' => $issue,
|
||||
* 'comment' => $comment,
|
||||
* 'files' => $attached_files);
|
||||
*
|
||||
*/
|
||||
$params = array('issue' => $this->issue,
|
||||
'comment' => $comment,
|
||||
'files' => $attached_files);
|
||||
Pluf_Signal::send('IDF_Issue::update', 'IDF_Form_IssueUpdate',
|
||||
$params);
|
||||
|
||||
return $this->issue;
|
||||
}
|
||||
}
|
||||
|
@ -205,6 +205,30 @@ class IDF_Form_ReviewCreate extends Pluf_Form
|
||||
$patch->patch = $this->cleaned_data['patch'];
|
||||
$patch->create();
|
||||
$patch->notify($this->project->getConf());
|
||||
/**
|
||||
* [signal]
|
||||
*
|
||||
* IDF_Review::create
|
||||
*
|
||||
* [sender]
|
||||
*
|
||||
* IDF_Form_ReviewCreate
|
||||
*
|
||||
* [description]
|
||||
*
|
||||
* This signal allows an application to perform a set of tasks
|
||||
* just after the creation of a review and the notification.
|
||||
*
|
||||
* [parameters]
|
||||
*
|
||||
* array('review' => $review,
|
||||
* 'patch' => $patch);
|
||||
*
|
||||
*/
|
||||
$params = array('review' => $review,
|
||||
'patch' => $patch);
|
||||
Pluf_Signal::send('IDF_Review::create', 'IDF_Form_ReviewCreate',
|
||||
$params);
|
||||
return $review;
|
||||
}
|
||||
|
||||
|
@ -146,6 +146,28 @@ class IDF_Form_UpdateUpload extends Pluf_Form
|
||||
$this->upload->modif_dtime = gmdate('Y-m-d H:i:s');
|
||||
$this->upload->update();
|
||||
$this->upload->batchAssoc('IDF_Tag', $tags);
|
||||
/**
|
||||
* [signal]
|
||||
*
|
||||
* IDF_Upload::update
|
||||
*
|
||||
* [sender]
|
||||
*
|
||||
* IDF_Form_UpdateUpload
|
||||
*
|
||||
* [description]
|
||||
*
|
||||
* This signal allows an application to perform a set of tasks
|
||||
* just after the update of an uploaded file.
|
||||
*
|
||||
* [parameters]
|
||||
*
|
||||
* array('upload' => $upload);
|
||||
*
|
||||
*/
|
||||
$params = array('upload' => $this->upload);
|
||||
Pluf_Signal::send('IDF_Upload::update',
|
||||
'IDF_Form_UpdateUpload', $params);
|
||||
return $this->upload;
|
||||
}
|
||||
}
|
||||
|
@ -176,6 +176,28 @@ class IDF_Form_Upload extends Pluf_Form
|
||||
}
|
||||
// Send the notification
|
||||
$upload->notify($this->project->getConf());
|
||||
/**
|
||||
* [signal]
|
||||
*
|
||||
* IDF_Upload::create
|
||||
*
|
||||
* [sender]
|
||||
*
|
||||
* IDF_Form_Upload
|
||||
*
|
||||
* [description]
|
||||
*
|
||||
* This signal allows an application to perform a set of tasks
|
||||
* just after the upload of a file and after the notification run.
|
||||
*
|
||||
* [parameters]
|
||||
*
|
||||
* array('upload' => $upload);
|
||||
*
|
||||
*/
|
||||
$params = array('upload' => $upload);
|
||||
Pluf_Signal::send('IDF_Upload::create', 'IDF_Form_Upload',
|
||||
$params);
|
||||
return $upload;
|
||||
}
|
||||
}
|
||||
|
@ -152,6 +152,29 @@ class IDF_Views_Download
|
||||
if ($request->method == 'POST') {
|
||||
$fname = $upload->file;
|
||||
@unlink(Pluf::f('upload_path').'/'.$prj->shortname.'/files/'.$fname);
|
||||
/**
|
||||
* [signal]
|
||||
*
|
||||
* IDF_Upload::delete
|
||||
*
|
||||
* [sender]
|
||||
*
|
||||
* IDF_Form_UpdateUpload
|
||||
*
|
||||
* [description]
|
||||
*
|
||||
* This signal allows an application to perform a set of tasks
|
||||
* just before the deletion of the corresponding object in the
|
||||
* database but just after the deletion from the storage.
|
||||
*
|
||||
* [parameters]
|
||||
*
|
||||
* array('upload' => $upload);
|
||||
*
|
||||
*/
|
||||
$params = array('upload' => $upload);
|
||||
Pluf_Signal::send('IDF_Upload::delete',
|
||||
'IDF_Views_Download', $params);
|
||||
$upload->delete();
|
||||
$request->user->setMessage(__('The file has been deleted.'));
|
||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Download::index',
|
||||
|
Loading…
Reference in New Issue
Block a user