Commit 83ccf40e authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Edit styling on message thread page; add from column to notifications and show...


Edit styling on message thread page; add from column to notifications and show the correct message authors
Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 3d83a609
......@@ -648,6 +648,9 @@ class ActivityTypeUsermessage extends ActivityType {
*/
public function __construct($data, $cron=false) {
parent::__construct($data, $cron);
if ($this->userfrom) {
$this->fromuser = $this->userfrom;
}
$this->users = activity_get_users($this->get_id(), array($this->userto));
}
......
......@@ -1619,6 +1619,28 @@ function xmldb_core_upgrade($oldversion=0) {
$key = new XMLDBKey('parentfk');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('parent'), 'notification_internal_activity', array('id'));
add_key($table, $key);
$field = new XMLDBField('from');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10');
add_field($table, $field);
$key = new XMLDBKey('fromfk');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('from'), 'usr', array('id'));
add_key($table, $key);
// Set from column for old user messages
$usermessages = get_records_array(
'notification_internal_activity',
'type',
get_field('activity_type', 'id', 'name', 'usermessage')
);
if ($usermessages) {
foreach ($usermessages as &$m) {
if (preg_match('/sendmessage\.php\?id=(\d+)/', $m->url, $match)) {
set_field('notification_internal_activity', 'from', $match[1], 'id', $m->id);
}
}
}
}
return $status;
......
......@@ -1143,7 +1143,7 @@ function activate_user($userid) {
*/
function get_message_thread($replyto) {
$message = get_record('notification_internal_activity', 'id', $replyto);
if (!isset($message->parent)) {
if (empty($message->parent)) {
return array($message);
}
return array_merge(get_message_thread($message->parent), array($message));
......
......@@ -15,12 +15,14 @@
<FIELD NAME="url" TYPE="text" NOTNULL="false" />
<FIELD NAME="read" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="parent" TYPE="int" LENGTH="10" NOTNULL="false" />
<FIELD NAME="from" TYPE="int" LENGTH="10" NOTNULL="false" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
<KEY NAME="typefk" TYPE="foreign" FIELDS="type" REFTABLE="activity_type" REFFIELDS="id" />
<KEY NAME="userfk" TYPE="foreign" FIELDS="usr" REFTABLE="usr" REFFIELDS="id" />
<KEY NAME="parentfk" TYPE="foreign" FIELDS="parent" REFTABLE="notification_internal_activity" REFFIELDS="id" />
<KEY NAME="fromfk" TYPE="foreign" FIELDS="from" REFTABLE="usr" REFFIELDS="id" />
</KEYS>
</TABLE>
</TABLES>
......
......@@ -48,6 +48,10 @@ class PluginNotificationInternal extends PluginNotification {
$toinsert->url = $data->url;
}
if (!empty($data->fromuser)) {
$toinsert->from = $data->fromuser;
}
return insert_record('notification_internal_activity', $toinsert, 'id', true);
}
......
......@@ -728,8 +728,6 @@ div.sideblock #friendscontrol label {
}
#wall .private {
}
.wallpost .postedon {
}
.wallpost .controls {
}
......
......@@ -690,8 +690,6 @@ div.sideblock #friendscontrol label {
}
#wall .private {
}
.wallpost .postedon {
}
.wallpost .controls {
}
......
......@@ -781,8 +781,6 @@ div.sideblock #friendscontrol label {
}
#wall .private {
}
.wallpost .postedon {
}
.wallpost .controls {
}
......
......@@ -196,7 +196,7 @@ td.narrow {
border-bottom: 2px solid #FFF;
}
/* table with preserved whitespace */
#messagethread td {
#messagethread .messagebody {
white-space: pre;
}
/* table without border */
......@@ -382,6 +382,12 @@ input.error, select.error {
padding-left: 2em;
}
.postedon {
color: #888;
font-style: italic;
font-size: .9em;
line-height: 1.2em;
}
/****************************** Buttons ****************************/
/** input buttons **/
......@@ -1195,12 +1201,6 @@ a.tag {
.wallpost .userinforight {
padding: .25em;
}
.wallpost .postedon {
color: #888;
font-style: italic;
font-size: .9em;
line-height: 1.2em;
}
.wallpost .text p {
margin: 0 0 .25em 0;
}
......
......@@ -5,12 +5,20 @@
<tbody>
{foreach from=$messages item=message}
<tr class="{cycle values='r0,r1'}">
{if $message->usr == $user->id}
<th>{include file="user/simpleuser.tpl" user=$USER}</th>
<td style="width: 20px;">
<img src="{profile_icon_url user=$user maxwidth=20 maxheight=20}" alt="">
</td>
<td>
<h5>
{if $message->from == $user->id}
{$user|display_name|escape}
{else}
<th>{include file="user/simpleuser.tpl" user=$user}</th>
{$USER|display_name|escape}
{/if}
<td>{$message->message}</td>
<span class="postedon">{$message->ctime|strtotime|format_date}</span>
</h5>
<div class="messagebody">{$message->message|escape}</div>
</td>
</tr>
{/foreach}
</tbody>
......
......@@ -741,8 +741,6 @@ div.sideblock #friendscontrol label {
}
#wall .private {
}
.wallpost .postedon {
}
.wallpost .controls {
}
......
......@@ -752,8 +752,6 @@ div.sideblock #friendscontrol label {
}
#wall .private {
}
.wallpost .postedon {
}
.wallpost .controls {
}
......
......@@ -42,9 +42,7 @@ if (!is_null($replytoid)) {
throw new AccessDeniedException(get_string('cantviewmessage', 'group'));
}
// Make sure the thread was start by either the user being replied to, or the current user
$bits = parse_url($messages[0]->url);
parse_str($bits['query'], $params);
if (empty($params['id']) || ($params['id'] != $id && $params['id'] != $USER->get('id'))) {
if (empty($messages[0]->from) || ($messages[0]->from != $id && $messages[0]->from != $USER->get('id'))) {
throw new AccessDeniedException(get_string('cantviewmessage', 'group'));
}
}
......@@ -57,7 +55,7 @@ if (!$user || !can_send_message($USER->to_stdclass(), $id)) {
throw new AccessDeniedException(get_string('cantmessageuser', 'group'));
}
define('TITLE', get_string('sendmessageto', 'group', display_name($id)));
define('TITLE', get_string('sendmessageto', 'group', display_name($user)));
$form = pieform(array(
'name' => 'sendmessage',
......
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