Commit 8a6c8816 authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files
parents e6f8aa4d a5fb8a07
......@@ -362,6 +362,13 @@ class ArtefactTypeBlog extends ArtefactType {
public function public_feedback_allowed() {
return $this->get('commentsallowed');
}
public function feedback_notify_owner() {
return $this->get('commentsnotify');
}
}
/**
......@@ -770,6 +777,14 @@ class ArtefactTypeBlogPost extends ArtefactType {
}
public function feedback_notify_owner() {
// Notify owner of comments on posts when the blog has
// commentsnotify set to 1;
$parent = get_field('artefact', 'parent', 'id', $this->get('id'));
return get_field('artefact_blog_blog', 'commentsnotify', 'blog', $parent);
}
}
?>
......@@ -203,7 +203,7 @@ var attached = new TableRenderer(
'attachedfiles',
'attachedfiles.json.php',
[
function (r) { return TD(null, IMG({'src':config.themeurl + 'images/' + r.artefacttype + '.gif',
function (r) { return TD(null, IMG({'src':get_themeurl('images/' + r.artefacttype + '.gif'),
'alt':r.artefacttype})); },
'title',
'description',
......@@ -255,7 +255,7 @@ function attachtopost(data) {
appendChildNodes(attached.tbody,
TR({'id':rowid},
map(partial(TD,null),
[IMG({'src':config.themeurl+'images/'+data.artefacttype+'.gif',
[IMG({'src':get_themeurl('images/'+data.artefacttype+'.gif'),
'alt':data.artefacttype}),
data.title, data.description,
INPUT({'type':'button', 'class':'button',
......@@ -609,6 +609,7 @@ EOF;
// Override the default Mahara tinyMCE.init(); Add an image button and
// the execcommand_callback.
$content_css = json_encode(theme_get_url('style/tinymce.css'));
$tinymceinit = <<<EOF
<script type="text/javascript">
tinyMCE.init({
......@@ -622,7 +623,7 @@ tinyMCE.init({
theme_advanced_buttons3 : "fontselect,separator,fontsizeselect,separator,formatselect",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "center",
content_css : config.themeurl + 'style/tinymce.css',
content_css : {$content_css},
execcommand_callback : "blogpostExecCommandHandler"
});
</script>
......
......@@ -129,7 +129,7 @@ postlist.rowfunction = function(d, n, gd) {
var filerows = [TR(null, TD({'colSpan':3}, {$enc_files}))];
for (var i = 0; i < d.files.length; i++) {
filerows.push(TR({'class':'r'+((i+1)%2)},
TD(null, IMG({'src':config.themeurl + d.files[i].artefacttype + '.gif'})),
TD(null, IMG({'src':get_themeurl(d.files[i].artefacttype + '.gif')})),
TD(null, A({'href':config.wwwroot+'artefact/file/download.php?file='+d.files[i].file},
d.files[i].title)),
TD(null, d.files[i].description)));
......
......@@ -227,7 +227,7 @@ function FileBrowser(element, source, statevars, changedircallback, actionname,
}
this.icon = function (type) {
return IMG({'src':config.themeurl+'images/'+type+'.gif'});
return IMG({'src':get_themeurl('images/'+type+'.gif')});
}
this.formatname = function(r) {
......@@ -441,7 +441,7 @@ function FileUploader(element, uploadscript, statevars, foldername, folderid, up
// Display upload status
insertSiblingNodesBefore(self.form,
DIV({'id':'uploadstatusline'+self.nextupload},
IMG({'src':config.themeurl+'loading.gif'}), ' ',
IMG({'src':get_themeurl('loading.gif')}), ' ',
get_string('uploadingfiletofolder',localname,self.foldername)));
self.nextupload += 1;
return true;
......@@ -457,7 +457,7 @@ function FileUploader(element, uploadscript, statevars, foldername, folderid, up
quotaUpdate(data.quotaused, data.quota);
replaceChildNodes($('uploadstatusline'+data.uploadnumber),
IMG({'src':config.themeurl+image}), ' ',
IMG({'src':get_themeurl(image)}), ' ',
data.message, ' ',
A({'style': 'cursor: pointer;',
'onclick':'removeElement(this.parentNode)'},'[X]'));
......
......@@ -83,6 +83,17 @@ class PluginArtefactFile extends PluginArtefact {
return strnatcasecmp($a->text, $b->text);
}
public static function themepaths($type) {
static $themepaths = array(
'file' => array(
'images/file.gif',
'images/folder.gif',
'images/image.gif',
),
);
return $themepaths[$type];
}
public static function jsstrings($type) {
static $jsstrings = array(
'file' => array(
......
......@@ -521,6 +521,16 @@ abstract class ArtefactType {
}
/**
* By default users are notified of all feedback on artefacts
* which they own. Artefact types which want to allow this
* notification to be turned off should redefine this function.
*/
public function feedback_notify_owner() {
return true;
}
/**
* returns path to icon
* can be called statically but not defined so
......
......@@ -93,7 +93,7 @@ $contactform = pieform(array(
function contactus_submit(Pieform $form, $values) {
$data = new StdClass;
$data->fromname = $values['name'];
$data->fromaddress = $values['email'];
$data->fromemail = $values['email'];
$data->subject = $values['subject'];
$data->message = $values['message'];
if ($values['userid']) {
......
......@@ -14,6 +14,17 @@ function get_string(s) {
return str;
}
// Expects an image/css path to fetch url for (requires config.theme[] to be
// set)
function get_themeurl(s) {
// log('get_themeurl(' + s + ')');
if (!config || !config.theme || !config.theme[s]) {
logError('Location of ' + s + ' is unknown, ensure config.theme is set correctly');
}
return config.theme[s];
}
function globalErrorHandler(data) {
if (data.returnCode == 3) {
// Logged out!
......@@ -73,7 +84,7 @@ function formGlobalError(form, data) {
// Message related functions
function makeMessage(message, type) {
var a = A({'href': ''}, IMG({'src': config.themeurl + 'images/icon_close.gif', 'alt': '[X]'}));
var a = A({'href': ''}, IMG({'src': get_themeurl('images/icon_close.gif'), 'alt': '[X]'}));
connect(a, 'onclick', function(e) {
removeElement(a.parentNode.parentNode);
e.stop();
......
......@@ -368,6 +368,7 @@ $string['addtowatchlist'] = 'Add %s to watchlist';
$string['addtowatchlistwithchildren'] = 'Add entire %s contents to watchlist';
$string['alreadyinwatchlist'] = 'This %s is already in your watchlist';
$string['attachedfileaddedtofolder'] = "The attached file %s has been added to your '%s' folder.";
$string['attachfile'] = "Attach file";
$string['complaint'] = 'Complaint';
$string['date'] = 'Date';
$string['feedback'] = 'Feedback';
......
......@@ -180,11 +180,15 @@ function handle_activity($activitytype, $data, $cron=false) {
}
if (!empty($data->artefact)) { // feedback on artefact
$data->subject = get_string('newfeedbackonartefact', 'activity');
if (!$artefact = get_record('artefact', 'id', $data->artefact)) {
throw new InvalidArgumentException("Couldn't find artefact with id " . $data->artefact);
require_once('artefact.php');
$artefact = artefact_instance_from_id($data->artefact);
if ($artefact->feedback_notify_owner()) {
$userid = $artefact->get('owner');
}
$userid = $artefact->owner;
$data->subject .= ' ' .$artefact->title;
else {
$userid = null;
}
$data->subject .= ' ' .$artefact->get('title');
if (empty($data->url)) {
// @todo this might change later
$data->url = get_config('wwwroot') . 'view/view.php?artefact='
......@@ -203,7 +207,12 @@ function handle_activity($activitytype, $data, $cron=false) {
$data->url = get_config('wwwroot') . 'view/view.php?view=' . $data->view;
}
}
$users = activity_get_users($activitytype->name, array($userid));
if ($userid) {
$users = activity_get_users($activitytype->name, array($userid));
}
else {
$users = array();
}
break;
// and now the harder ones
case 'watchlist':
......
......@@ -57,6 +57,8 @@ function &smarty($javascript = array(), $headers = array(), $pagestrings = array
require_once(get_config('libroot') . 'smarty/Smarty.class.php');
$wwwroot = get_config('wwwroot');
$theme_list = array();
if (function_exists('pieform_get_headdata')) {
$headers = array_merge($headers, pieform_get_headdata());
......@@ -74,6 +76,7 @@ function &smarty($javascript = array(), $headers = array(), $pagestrings = array
if (isset($extraconfig['tinymceinit'])) {
$headers[] = $extraconfig['tinymceinit'];
} else {
$content_css = json_encode(theme_get_url('style/tinymce.css'));
$headers[] = <<<EOF
<script type="text/javascript">
tinyMCE.init({
......@@ -87,7 +90,7 @@ tinyMCE.init({
theme_advanced_buttons3 : "fontselect,separator,fontsizeselect,separator,formatselect",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "center",
content_css : config.themeurl + 'style/tinymce.css'
content_css : {$content_css}
});
</script>
......@@ -113,6 +116,7 @@ EOF;
}
$jsstrings = jsstrings();
$themepaths = themepaths();
foreach ($javascript as $jsfile) {
// For now, if there's no path in the js file, assume it's in
......@@ -128,6 +132,11 @@ EOF;
}
}
}
if (isset($themepaths[$jsfile])) {
foreach ($themepaths[$jsfile] as $themepath) {
$theme_list[$themepath] = theme_get_url($themepath);
}
}
}
else {
// A .js file with a fully specified path
......@@ -147,6 +156,13 @@ EOF;
}
}
}
if (is_callable(array($pluginclass, 'themepaths'))) {
$name = substr($bits[3], 0, strpos($bits[3], '.js'));
$tmpthemepaths = call_static_method($pluginclass, 'themepaths', $name);
foreach ($tmpthemepaths as $themepath) {
$theme_list[$themepath] = theme_get_url($themepath);
}
}
}
}
}
......@@ -159,6 +175,9 @@ EOF;
$strings[$tag] = get_raw_string($tag, $section);
}
}
foreach ($themepaths['mahara'] as $themepath) {
$theme_list[$themepath] = theme_get_url($themepath);
}
$stringjs = '<script type="text/javascript">';
$stringjs .= 'var strings = ' . json_encode($strings) . ';';
......@@ -180,6 +199,7 @@ EOF;
$smarty->assign('THEMEURL', get_config('themeurl'));
$smarty->assign('STYLESHEETLIST', array_reverse(theme_get_url('style/style.css', null, true)));
$smarty->assign('WWWROOT', $wwwroot);
$smarty->assign('THEMELIST', json_encode($theme_list));
if (defined('TITLE')) {
$smarty->assign('PAGETITLE', TITLE . ' - ' . get_config('sitename'));
......@@ -254,6 +274,16 @@ function jsstrings() {
);
}
function themepaths() {
return array(
'mahara' => array(
'images/icon_close.gif',
'loading.gif',
'success.gif',
),
);
}
/**
* Takes an array of string identifiers and returns an array of the
* corresponding strings, quoted for use in inline javascript here
......
......@@ -4,7 +4,7 @@
<title>{$PAGETITLE|escape}</title>
<script type="text/javascript">
var config = {literal}{{/literal}
'themeurl': '{$THEMEURL}',
'theme': {$THEMELIST},
'wwwroot': '{$WWWROOT}'
{literal}}{/literal};
</script>
......
......@@ -100,6 +100,10 @@ if (!insert_record('view_feedback', $data)) {
$f->delete();
}
require_once('activity.php');
activity_occurred('feedback', $data);
redirect(get_config('wwwroot') . 'view/view.php?view=' . $viewid);
?>
Supports Markdown
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