Commit 3ce13d04 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Create view/artefact objects in objectionable activity constructor


Get view owner from view object instead of passing it to the constructor

Change-Id: I7c41f9ce73b3efc010b433084a613053650f6247
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent cce9293b
......@@ -549,7 +549,6 @@ class ActivityTypeObjectionable extends ActivityTypeAdmin {
protected $view;
protected $artefact;
protected $owner;
protected $reporter;
/**
......@@ -562,21 +561,30 @@ class ActivityTypeObjectionable extends ActivityTypeAdmin {
function __construct($data, $cron=false) {
parent::__construct($data, $cron);
if ($this->owner) {
require_once('view.php');
$this->view = new View($this->view);
if (!empty($this->artefact)) {
require_once(get_config('docroot') . 'artefact/lib.php');
$this->artefact = artefact_instance_from_id($this->artefact);
}
if ($owner = $this->view->get('owner')) {
// Notify institutional admins of the view owner
if ($institutions = get_column('usr_institution', 'institution', 'usr', $this->owner)) {
if ($institutions = get_column('usr_institution', 'institution', 'usr', $owner)) {
$this->users = activity_get_users($this->get_id(), null, null, null, $institutions);
}
}
if (empty($this->artefact)) {
$this->url = get_config('wwwroot') . 'view/view.php?id=' . $this->view;
$this->url = $this->view->get_url();
}
else {
$this->url = get_config('wwwroot') . 'view/artefact.php?artefact=' . $this->artefact . '&view=' . $this->view;
$this->url = get_config('wwwroot') . 'view/artefact.php?artefact=' . $this->artefact->get('id') . '&view=' . $this->view->get('id');
}
if (empty($this->strings->subject)) {
$viewtitle = get_field('view', 'title', 'id', $this->view);
$viewtitle = $this->view->get('title');
if (empty($this->artefact)) {
$this->strings->subject = (object) array(
'key' => 'objectionablecontentview',
......@@ -585,7 +593,7 @@ class ActivityTypeObjectionable extends ActivityTypeAdmin {
);
}
else {
$title = get_field('artefact', 'title', 'id', $this->artefact);
$title = $this->artefact->get('title');
$this->strings->subject = (object) array(
'key' => 'objectionablecontentviewartefact',
'section' => 'activity',
......@@ -596,7 +604,7 @@ class ActivityTypeObjectionable extends ActivityTypeAdmin {
}
public function get_required_parameters() {
return array('message', 'view', 'owner', 'reporter');
return array('message', 'view', 'reporter');
}
}
......
......@@ -3938,7 +3938,6 @@ function objection_form_submit(Pieform $form, $values) {
$data = new StdClass;
$data->view = $view->get('id');
$data->owner = $view->get('owner');
$data->message = $values['message'];
$data->reporter = $USER->get('id');
if ($artefact) {
......@@ -3993,7 +3992,6 @@ function viewnotrude_submit(Pieform $form, $values) {
$data = (object) array(
'view' => $view->get('id'),
'owner' => $view->get('owner'),
'reporter' => $USER->get('id'),
'subject' => false,
'message' => false,
......
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