Commit ca6e328a authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Remove unneccessary view submission code from groupmessage activity



The groupmessage activity type is currently only used for view
submissions, but it would be good to clean it up and make it more
useful for other group-related notifications.

Part of bug #845293

This change moves submission-specific strings to the submit view page.

Change-Id: I413df0ab9df833cc4a17ede83a34a3eefae383a1
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 6acb78c2
......@@ -982,14 +982,9 @@ class ActivityTypeGroupMessage extends ActivityType {
protected $group;
protected $roles;
protected $submittedview;
private $viewinfo;
private $groupinfo;
/**
* @param array $data Parameters:
* - subject (string)
* - message (string)
* - group (integer)
* - roles (list of roles)
*/
......@@ -998,34 +993,12 @@ class ActivityTypeGroupMessage extends ActivityType {
parent::__construct($data, $cron);
$this->groupinfo = get_record('group', 'id', $this->group);
$members = group_get_member_ids($this->group, isset($this->roles) ? $this->roles : null);
$this->users = activity_get_users($this->get_id(), $members);
if ($this->submittedview) {
$this->viewinfo = get_record('view', 'id', $this->submittedview);
$this->viewinfo->ownername = display_name($this->viewinfo->owner);
$this->url = get_config('wwwroot') . 'view/view.php?id=' . $this->submittedview;
}
}
public function get_subject($user) {
if ($this->submittedview) {
return get_string_from_language($user->lang, 'viewsubmittedsubject', 'activity', $this->groupinfo->name);
}
return $this->subject;
}
public function get_message($user) {
if ($this->submittedview) {
return get_string_from_language($user->lang, 'viewsubmittedmessage', 'activity', $this->viewinfo->ownername, $this->viewinfo->title, $this->groupinfo->name);
}
return $this->subject;
}
public function get_required_parameters() {
return array('message', 'subject', 'group');
return array('group');
}
}
......
......@@ -74,7 +74,7 @@ $smarty->assign('form', $form);
$smarty->display('view/submit.tpl');
function submitview_submit(Pieform $form, $values) {
global $SESSION, $USER, $viewid, $groupid, $group;
global $SESSION, $USER, $viewid, $view, $groupid, $group;
db_begin();
update_record('view', array('submittedgroup' => $groupid, 'submittedtime' => db_format_timestamp(time())), array('id' => $viewid));
$roles = get_column('grouptype_roles', 'role', 'grouptype', $group->grouptype, 'see_submitted_views', 1);
......@@ -92,14 +92,27 @@ function submitview_submit(Pieform $form, $values) {
}
ArtefactType::update_locked($USER->get('id'));
activity_occurred('groupmessage', array(
'subject' => get_string('viewsubmitted', 'view'), // will be overwritten
'message' => get_string('viewsubmitted', 'view'), // will be overwritten
'submittedview' => $viewid,
'viewowner' => $USER->get('id'),
'group' => $groupid,
'roles' => $roles,
'url' => get_config('wwwroot') . 'view/view.php?id=' . $viewid,
'strings' => (object) array(
'urltext' => (object) array('key' => 'view'),
'subject' => (object) array(
'key' => 'viewsubmittedsubject',
'section' => 'activity',
'args' => array(hsc($group->name)),
),
'message' => (object) array(
'key' => 'viewsubmittedmessage',
'section' => 'activity',
'args' => array(
hsc(display_name($USER, null, false, true)),
hsc($view->title),
hsc($group->name),
),
),
),
));
db_commit();
......
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