Commit 9d3feb99 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Move feedback activity type to the artefact plugin


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 154fe6f1
......@@ -26,6 +26,8 @@
defined('INTERNAL') || die();
require_once('activity.php');
class PluginArtefactComment extends PluginArtefact {
public static function get_artefact_types() {
......@@ -575,7 +577,7 @@ function add_feedback_form_submit(Pieform $form, $values) {
require_once('activity.php');
$data->message = html2text($data->description);
$data->view = $view->get('id');
activity_occurred('feedback', $data);
activity_occurred('feedback', $data, 'artefact', 'comment');
db_commit();
......@@ -601,4 +603,73 @@ function add_feedback_form_cancel_submit(Pieform $form) {
));
}
class ActivityTypeArtefactCommentFeedback extends ActivityTypePlugin {
protected $view;
protected $onview;
protected $onartefact;
private $viewrecord;
private $artefactinstance;
/**
* @param array $data Parameters:
* - view (int)
* - onview (int) (optional)
* - onartefact (int) (optional)
* - message (string)
*/
public function __construct($data, $cron=false) {
parent::__construct($data, $cron);
if (!empty($this->onartefact)) { // feedback on artefact
$userid = null;
require_once(get_config('docroot') . 'artefact/lib.php');
$this->artefactinstance = artefact_instance_from_id($this->onartefact);
if ($this->artefactinstance->feedback_notify_owner()) {
$userid = $this->artefactinstance->get('owner');
}
if (empty($this->url)) {
$this->url = get_config('wwwroot') . 'view/artefact.php?artefact='
. $this->onartefact . '&view=' . $this->view;
}
}
else { // feedback on view.
if (!$this->viewrecord = get_record('view', 'id', $this->onview)) {
throw new ViewNotFoundException(get_string('viewnotfound', 'error', $this->onview));
}
$userid = $this->viewrecord->owner;
if (empty($this->url)) {
$this->url = get_config('wwwroot') . 'view/view.php?id=' . $this->onview;
}
}
if ($userid) {
$this->users = activity_get_users($this->get_id(), array($userid));
}
}
public function get_subject($user) {
if (!empty($this->onartefact)) { // feedback on artefact
return get_string_from_language($user->lang, 'newfeedbackonartefact', 'activity')
. ' ' . $this->artefactinstance->get('title');
}
else {
return get_string_from_language($user->lang, 'newfeedbackonview', 'activity')
. ' ' . $this->viewrecord->title;
}
}
public function get_plugintype(){
return 'artefact';
}
public function get_pluginname(){
return 'comment';
}
public function get_required_parameters() {
return array('message', 'view');
}
}
?>
......@@ -649,67 +649,6 @@ class ActivityTypeUsermessage extends ActivityType {
}
class ActivityTypeFeedback extends ActivityType {
protected $view;
protected $onview;
protected $onartefact;
private $viewrecord;
private $artefactinstance;
/**
* @param array $data Parameters:
* - view (int)
* - onview (int) (optional)
* - onartefact (int) (optional)
* - message (string)
*/
public function __construct($data, $cron=false) {
parent::__construct($data, $cron);
if (!empty($this->onartefact)) { // feedback on artefact
$userid = null;
require_once(get_config('docroot') . 'artefact/lib.php');
$this->artefactinstance = artefact_instance_from_id($this->onartefact);
if ($this->artefactinstance->feedback_notify_owner()) {
$userid = $this->artefactinstance->get('owner');
}
if (empty($this->url)) {
$this->url = get_config('wwwroot') . 'view/artefact.php?artefact='
. $this->onartefact . '&view=' . $this->view;
}
}
else { // feedback on view.
if (!$this->viewrecord = get_record('view', 'id', $this->onview)) {
throw new ViewNotFoundException(get_string('viewnotfound', 'error', $this->onview));
}
$userid = $this->viewrecord->owner;
if (empty($this->url)) {
$this->url = get_config('wwwroot') . 'view/view.php?id=' . $this->onview;
}
}
if ($userid) {
$this->users = activity_get_users($this->get_id(), array($userid));
}
}
public function get_subject($user) {
if (!empty($this->onartefact)) { // feedback on artefact
return get_string_from_language($user->lang, 'newfeedbackonartefact', 'activity')
. ' ' . $this->artefactinstance->get('title');
}
else {
return get_string_from_language($user->lang, 'newfeedbackonview', 'activity')
. ' ' . $this->viewrecord->title;
}
}
public function get_required_parameters() {
return array('message', 'view');
}
}
class ActivityTypeWatchlist extends ActivityType {
protected $view;
......
......@@ -1480,6 +1480,13 @@ function xmldb_core_upgrade($oldversion=0) {
drop_table($table);
$table = new XMLDBTable('artefact_feedback');
drop_table($table);
// Move feedback activity type to artefact plugin
execute_sql("
UPDATE {activity_type}
SET plugintype = 'artefact', pluginname = 'comment'
WHERE name = 'feedback'
");
}
return $status;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment