Commit 6fb51c2a authored by Richard Mansfield's avatar Richard Mansfield
Browse files
parents 3452e2d1 d6d08592
......@@ -49,5 +49,25 @@
<KEY NAME="filefk" TYPE="foreign" FIELDS="file" REFTABLE="artefact" REFFIELDS="id" />
</KEYS>
</TABLE>
<!-- This table keeps track of files that are to be associated with a blog
post, but for which the post has not yet been created, or the association
has not yet been confirmed. No file should ever be in both this table and
artefact_blog_blogpost_file.
This table only keeps track of files that are specifically uploaded for a
blog post, not ones that have been uploaded already some other way, that
the user wants to associate with a blog post. -->
<TABLE NAME="artefact_blog_blogpost_file_pending">
<FIELDS>
<FIELD NAME="file" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="when" TYPE="datetime" NOTNULL="true" />
</FIELDS>
<KEYS>
<KEY NAME="blogpost_file_pending_pk" TYPE="primary" FIELDS="file" />
<KEY NAME="filefk" TYPE="foreign" FIELDS="file" REFTABLE="artefact" REFFIELDS="id" />
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
......@@ -31,13 +31,25 @@ function xmldb_artefact_blog_upgrade($oldversion=0) {
$status = true;
// There was no database prior to this version.
if ($oldversion < 2006120501) {
if ($status && $oldversion < 2006120501) {
$status = $status && install_from_xmldb_file(
get_config('docroot') .
'artefact/blog/db/install.xml'
);
}
if ($status && $oldversion < 2006121501) {
$table = new XMLDBTable('artefact_blog_blogpost_file_pending');
$table->addFieldInfo('file', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
$table->addFieldInfo('when', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL);
$table->addKeyInfo('blogpost_file_pending_pk', XMLDB_KEY_PRIMARY, array('file'));
$table->addKeyInfo('filefk', XMLDB_KEY_FOREIGN, array('file'), 'artefact', array('id'));
$status = $status && create_table($table);
}
return $status;
}
......
......@@ -31,6 +31,11 @@ defined('INTERNAL') || die();
*/
class PluginArtefactBlog extends PluginArtefact {
/**
* This is a postgresql time constant.
*/
const maxpending = '10 minutes';
public static function get_artefact_types() {
return array(
'blog',
......@@ -54,6 +59,34 @@ class PluginArtefactBlog extends PluginArtefact {
public static function get_toplevel_artefact_types() {
return array('blog');
}
public static function get_cron() {
return array(
(object)array(
'callfunction' => 'clean_post_files',
'minute' => '1'
)
);
}
/**
* This function cleans out any files that have been uploaded, but which
* are not associated with a blog, because of an aborted blog creation.
*/
public static function clean_post_files() {
safe_require('artefact', 'file');
($files = get_records_sql_array("
SELECT file
FROM artefact_blog_blogpost_file_pending
WHERE when + ?::INTERVAL < CURRENT_TIMESTAMP", array(self::maxpending)))
|| ($files = array());
foreach ($files as $file) {
$file_obj = new ArtefactTypeFile($file->file);
$file_obj->delete();
}
}
}
/**
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2006120501;
$config->version = 2006121501;
$config->release = '0.1';
?>
......@@ -27,15 +27,16 @@
defined('INTERNAL') || die();
// General form strings
$string['add'] = 'Add';
$string['cancel'] = 'Cancel';
$string['delete'] = 'Delete';
$string['edit'] = 'Edit';
$string['save'] = 'Save';
$string['submit'] = 'Submit';
$string['update'] = 'Update';
$string['change'] = 'Change';
$string['go'] = 'Go';
$string['add'] = 'Add';
$string['cancel'] = 'Cancel';
$string['delete'] = 'Delete';
$string['edit'] = 'Edit';
$string['save'] = 'Save';
$string['submit'] = 'Submit';
$string['update'] = 'Update';
$string['change'] = 'Change';
$string['go'] = 'Go';
$string['loading'] = 'Loading ...';
$string['no'] = 'no';
$string['yes'] = 'yes';
......
......@@ -59,3 +59,12 @@ $string['empty_block'] = 'Select an artefact from the tree on the left to place
$string['viewinformationsaved'] = 'View information saved successfully';
$string['canteditdontown'] = 'You can\'t edit this view because you don\'t own it';
$string['chooseformat'] = 'Select how you would like to display this artefact in this block ...';
$string['format.listself'] = 'List item (you can put multiple artefacts in this block like this)';
$string['format.listchildren'] = 'List children of this artefact';
$string['format.renderfull'] = 'Display entire artefact';
$string['format.rendermetadata'] = 'Display metadata for this artefact';
......@@ -96,8 +96,15 @@ EOF;
$javascript_array[] = $jsroot . 'MochiKit/MochiKit.js';
$strings = array();
foreach ($pagestrings as $string => $section) {
$strings[$string] = '"' . $string . '":"' . addslashes(get_raw_string($string, $section)) . '"';
foreach ($pagestrings as $k => $v) {
if (is_array($v)) {
foreach ($v as $tag) {
$strings[$tag] = get_raw_string($tag, $k);
}
}
else {
$strings[$k] = get_raw_string($k, $v);
}
}
$jsstrings = jsstrings();
......@@ -112,8 +119,7 @@ EOF;
if (isset($jsstrings[$jsfile])) {
foreach ($jsstrings[$jsfile] as $string => $section) {
if (!isset($strings[$string])) {
$strings[$string] = '"' . $string . '":"'
. addslashes(get_raw_string($string, $section)) . '"';
$strings[$string] = get_raw_string($string, $section);
}
}
}
......@@ -132,8 +138,7 @@ EOF;
$tempstrings = call_static_method($pluginclass, 'jsstrings', $name);
foreach ($tempstrings as $string => $section) {
if (!isset($strings[$string])) {
$strings[$string] = '"' . $string . '":"'
. addslashes(get_raw_string($string, $section)) . '"';
$strings[$string] = get_raw_string($string, $section);
}
}
}
......@@ -146,12 +151,12 @@ EOF;
foreach ($jsstrings['mahara'] as $string => $section) {
if (!isset($strings[$string])) {
$strings[$string] = '"' . $string . '":"' . addslashes(get_raw_string($string, $section)) . '"';
$strings[$string] = get_raw_string($string, $section);
}
}
$stringjs = '<script type="text/javascript">';
$stringjs .= 'var strings={' . implode(',', $strings) . '};';
$stringjs .= 'var strings = ' . json_encode($strings) . ';';
$stringjs .= '</script>';
$headers[] = $stringjs;
......
......@@ -118,7 +118,21 @@ if (isset($parsed_template['css'])) {
$headers[] = '<link rel="stylesheet" type="text/css" href="' . get_config('wwwroot') . 'view/template.css.php?template=' . $data['template'] . '">';
}
$smarty = smarty(array('collapsabletree', 'move', 'tablerenderer'), $headers);
$smarty = smarty(
array('collapsabletree', 'move', 'tablerenderer'),
$headers,
array(
'view' => array(
'chooseformat',
'format.listself',
'format.listchildren',
'format.renderfull',
'format.rendermetadata',
'empty_block',
'empty_label',
),
)
);
$smarty->assign('rootinfo', $rootinfo);
$smarty->assign('plusicon', theme_get_image_path('plus.png'));
$smarty->assign('minusicon', theme_get_image_path('minus.png'));
......
......@@ -180,7 +180,21 @@ if (isset($parsed_template['css'])) {
$headers[] = '<link rel="stylesheet" type="text/css" href="' . get_config('wwwroot') . 'view/template.css.php?template=' . $data['template'] . '">';
}
$smarty = smarty(array('collapsabletree', 'move', 'tablerenderer'), $headers);
$smarty = smarty(
array('collapsabletree', 'move', 'tablerenderer'),
$headers,
array(
'view' => array(
'chooseformat',
'format.listself',
'format.listchildren',
'format.renderfull',
'format.rendermetadata',
'empty_block',
'empty_label',
),
)
);
$smarty->assign('rootinfo', $rootinfo);
$smarty->assign('plusicon', theme_get_image_path('plus.png'));
$smarty->assign('minusicon', theme_get_image_path('minus.png'));
......
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