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

Allow internal notifications to set link text


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent ad52e990
......@@ -93,6 +93,7 @@ To unsubscribe from this %s, visit:
$string['forumsuccessfulsubscribe'] = 'Forum subscribed successfully';
$string['forumsuccessfulunsubscribe'] = 'Forum unsubscribed successfully';
$string['gotoforums'] = 'Go to forums';
$string['gototopic'] = 'Go to topic';
$string['groupadmins'] = 'Group administrators';
$string['groupadminlist'] = 'Group admins:';
$string['Key'] = 'Key';
......
......@@ -504,6 +504,10 @@ class ActivityTypeInteractionForumNewPost extends ActivityTypePlugin {
$this->message = $textbody;
$this->url = $postlink;
$this->add_urltext(array(
'key' => 'gototopic',
'section' => 'interaction.forum'
));
foreach ($this->users as &$user) {
$lang = (empty($user->lang) || $user->lang == 'default') ? get_config('lang') : $user->lang;
......
......@@ -350,17 +350,25 @@ abstract class ActivityType {
}
public function get_string_for_user($user, $string) {
if (empty($string)) {
return;
}
$args = array_merge(
array(
$user->lang,
$this->strings->{$string}->key,
$this->strings->{$string}->section,
),
$this->strings->{$string}->args
empty($this->strings->{$string}->args) ? array() : $this->strings->{$string}->args
);
return call_user_func_array('get_string_from_language', $args);
}
// Optional string to use for the link text.
public function add_urltext(array $stringdef) {
$this->strings->urltext = (object) $stringdef;
}
public function get_message($user) {
if (empty($this->message)) {
return $this->get_string_for_user($user, 'message');
......@@ -390,6 +398,7 @@ abstract class ActivityType {
if (!empty($user->url)) {
$userdata->url = $user->url;
}
$userdata->urltext = $this->get_string_for_user($user, 'urltext');
if (empty($user->lang) || $user->lang == 'default') {
$user->lang = get_config('lang');
}
......@@ -949,7 +958,7 @@ function activitylist_html($type='all', $limit=10, $offset=0) {
$r->date = format_date(strtotime($r->ctime), 'strfdaymonthyearshort');
$section = empty($r->plugintype) ? 'activity' : "{$r->plugintype}.{$r->pluginname}";
$r->strtype = get_string('type' . $r->type, $section);
$r->message = clean_html(format_whitespace($r->message));
$r->message = format_whitespace($r->message);
}
}
......
......@@ -1731,5 +1731,14 @@ function xmldb_core_upgrade($oldversion=0) {
execute_sql('ALTER TABLE {usr} ADD COLUMN showhomeinfo SMALLINT NOT NULL DEFAULT 1');
set_config('homepageinfo', 1);
}
if ($oldversion < 2010042604) {
// @todo: Move to notification/internal
$table = new XMLDBTable('notification_internal_activity');
$field = new XMLDBField('urltext');
$field->setAttributes(XMLDB_TYPE_TEXT);
add_field($table, $field);
}
return $status;
}
......@@ -28,7 +28,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2010042603;
$config->version = 2010042604;
$config->release = '1.3.0dev';
$config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
......
......@@ -13,6 +13,7 @@
<FIELD NAME="subject" TYPE="text" NOTNULL="false" />
<FIELD NAME="message" TYPE="text" NOTNULL="false" />
<FIELD NAME="url" TYPE="text" NOTNULL="false" />
<FIELD NAME="urltext" 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" />
......
......@@ -47,7 +47,9 @@ class PluginNotificationInternal extends PluginNotification {
if (!empty($data->url)) {
$toinsert->url = $data->url;
}
if (!empty($data->urltext)) {
$toinsert->urltext = $data->urltext;
}
if (!empty($data->fromuser)) {
$toinsert->from = $data->fromuser;
}
......
......@@ -7,7 +7,7 @@
{if $item->message}
<a href="" onclick="showHideMessage({$item->id}); return false;">{$item->subject|escape}</a>
<div id="message-{$item->id}" class="hidden">{$item->message|clean_html}
{if $item->url}<br><a href="{$item->url|escape}" class="s">{str tag="more..."}</a>{/if}
{if $item->url}<br><a href="{$item->url|escape}" class="s">{if $item->urltext}{$item->urltext|escape}{else}{str tag="more..."}{/if}</a>{/if}
</div>
{elseif $item->url}
<a href="{$item->url|escape}">{$item->subject|escape}</a>
......
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