Commit 9aea196e authored by Piers Harding's avatar Piers Harding
Browse files

Merge branch 'master' of git@gitorious.org:mahara/mahara

parents 635ab613 eca7bfa6
......@@ -189,8 +189,8 @@ function edituser_site_submit(Pieform $form, $values) {
// Reset the sent and bounce counts otherwise mail will be disabled
// on the next send attempt
$u = new StdClass;
$u->email = $user->get('email');
$u->id = $user->get('id');
$u->email = $user->email;
$u->id = $user->id;
update_bounce_count($u,true);
update_send_count($u,true);
}
......
......@@ -377,12 +377,12 @@ function send_content_ready($token, $username, $format, $importdata, $fetchnow=f
foreach ($importer->get_return_data() as $k => $v) {
$result->querystring .= $k . '=' . $v . '&';
}
$importer->get('importertransport')->cleanup();
} else {
// or set ready to 1 for the next cronjob to go fetch it.
$result->status = set_field('import_queue', 'ready', 1, 'id', $queue->id);
$result->type = 'queued';
}
$importer->get('importertransport')->cleanup();
return $result;
}
......
......@@ -50,7 +50,7 @@ class HtmlExportBlog extends HtmlExportArtefactPlugin {
array('text' => $artefact->get('title'), 'path' => 'index.html'),
));
$rendered = $artefact->render_self(array('hidetitle' => true));
$outputfilter = new HtmlExportOutputFilter('../../../');
$outputfilter = new HtmlExportOutputFilter('../../../', $this->exporter);
$smarty->assign('rendered_blog', $outputfilter->filter($rendered['html']));
$content = $smarty->fetch('export:html/blog:index.tpl');
......
......@@ -103,10 +103,17 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
}
else {
// The blog can import any entry as a literal blog post
// Get files that this blogpost/catchall feels are a part of it
$otherrequiredentries = array();
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], '', 'enclosure') && isset($link['href'])) {
$otherrequiredentries[] = (string)$link['href'];
}
}
$strategies[] = array(
'strategy' => self::STRATEGY_IMPORT_AS_ENTRY,
'score' => 10,
'other_required_entries' => array(),
'other_required_entries' => $otherrequiredentries,
);
}
......@@ -201,6 +208,25 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
}
break;
case self::STRATEGY_IMPORT_AS_ENTRY:
$blogpostids = $importer->get_artefactids_imported_by_entryid((string)$entry->id);
if (!isset($blogpostids[0])) {
// weird!
break;
}
$blogpost = new ArtefactTypeBlogPost($blogpostids[0]);
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], '', 'enclosure') && isset($link['href'])) {
if (isset($artefactids[0])) {
$blogpost->attach($artefactids[0]);
} else {
if ($id = self::attach_linked_file($entry, $link, $importer)) {
$blogpost->attach($id);
$newartefactmapping[(string)$link['href']][] = $id;
}
}
}
}
$blogpost->commit();
self::setup_outoflinecontent_relationship($entry, $importer);
break;
default:
......@@ -241,7 +267,9 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
public static function cleanup(PluginImportLeap $importer) {
if (self::$importedablog && self::$firstblogid) {
$blog = artefact_instance_from_id(self::$firstblogid);
$blog->delete();
if (!$blog->has_children()) { // TODO see #544160
$blog->delete();
}
}
}
......
......@@ -138,10 +138,6 @@ class ArtefactTypeBlog extends ArtefactType {
}
}
public function is_container() {
return true;
}
/**
* This function updates or inserts the artefact. This involves putting
* some data in the artefact table (handled by parent::commit()), and then
......
......@@ -47,7 +47,7 @@ class HtmlExportInternal extends HtmlExportArtefactPlugin {
if ($profileviewid == $viewid) {
$smarty->assign('breadcrumbs', array(array('text' => 'Profile page', 'path' => 'profilepage.html')));
$view = $this->exporter->get('user')->get_profile_view();
$outputfilter = new HtmlExportOutputFilter('../../');
$outputfilter = new HtmlExportOutputFilter('../../', $this->exporter);
$smarty->assign('view', $outputfilter->filter($view->build_columns()));
$content = $smarty->fetch('export:html/internal:profilepage.tpl');
......@@ -80,7 +80,7 @@ class HtmlExportInternal extends HtmlExportArtefactPlugin {
$artefact = artefact_instance_from_id($id);
$rendered = $artefact->render_self(array('link' => true));
if ($artefact->get('artefacttype') == 'introduction') {
$outputfilter = new HtmlExportOutputFilter('../../');
$outputfilter = new HtmlExportOutputFilter('../../', $this->exporter);
$rendered['html'] = $outputfilter->filter($rendered['html']);
}
$sections[$this->get_category_for_artefacttype($artefact->get('artefacttype'))][$artefact->get('artefacttype')] = array(
......@@ -113,7 +113,7 @@ class HtmlExportInternal extends HtmlExportArtefactPlugin {
public function get_summary() {
$smarty = $this->exporter->get_smarty();
$outputfilter = new HtmlExportOutputFilter('.');
$outputfilter = new HtmlExportOutputFilter('.', $this->exporter);
$smarty->assign('introduction', $outputfilter->filter(get_profile_field($this->exporter->get('user')->get('id'), 'introduction')));
$smarty->assign('profileviewexported', $this->profileviewexported);
$iconid = $this->exporter->get('user')->get('profileicon');
......
......@@ -370,10 +370,6 @@ abstract class ArtefactType {
}
}
public function is_container() {
return false;
}
/**
* This method updates the contents of the artefact table only. If your
* artefact has extra information in other tables, you need to override
......@@ -635,16 +631,6 @@ abstract class ArtefactType {
}
/**
* By default public feedback can be placed on all artefacts.
* Artefact types which don't want to allow public feedback should
* redefine this function.
*/
public function public_feedback_allowed() {
return true;
}
/**
* By default users are notified of all feedback on artefacts
* which they own. Artefact types which want to allow this
......@@ -687,13 +673,6 @@ abstract class ArtefactType {
*/
public static abstract function is_singular();
/**
* Whether the 'note' field is for the artefact's private use
*/
public static function is_note_private() {
return false;
}
/**
* Returns a list of key => value pairs where the key is either '_default'
* or a langauge string, and value is a URL linking to that behaviour for
......@@ -1356,7 +1335,9 @@ function artefact_watchlist_notification($artefactids) {
function artefact_get_descendants($new) {
$seen = array();
$new = array_combine($new, $new);
if (!empty($new)) {
$new = array_combine($new, $new);
}
while (!empty($new)) {
$seen = $seen + $new;
$children = get_column_sql('
......
......@@ -35,22 +35,27 @@ require_once(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('pieforms/pieform.php');
require_once(get_config('docroot') . 'artefact/lib.php');
$personal = null;
$academic = null;
$career = null;
try {
$personal = artefact_instance_from_type('personalgoal');
$personal = artefact_instance_from_type('personalgoal');
$personal = $personal->get('description');
}
catch (Exception $e) {
$personal = get_string('defaultpersonalgoal', 'artefact.resume');
}
catch (Exception $e) {}
try {
$academic = artefact_instance_from_type('academicgoal');
$academic = $academic->get('description');
}
catch (Exception $e) {
$academic = get_string('defaultacademicgoal', 'artefact.resume');
}
catch (Exception $e) {}
try {
$career = artefact_instance_from_type('careergoal');
$career = $career->get('description');
}
catch (Exception $e) {
$career = get_string('defaultcareergoal', 'artefact.resume');
}
catch (Exception $e) {}
$gform = array(
'name' => 'goalform',
'jsform' => true,
......@@ -62,21 +67,21 @@ $gform = array(
'type' => 'wysiwyg',
'rows' => 10,
'cols' => 65,
'defaultvalue' => ((!empty($personal)) ? $personal->get('description') : null),
'defaultvalue' => $personal,
'title' => get_string('personalgoal', 'artefact.resume'),
),
'academicgoal' => array(
'type' => 'wysiwyg',
'rows' => 10,
'cols' => 65,
'defaultvalue' => ((!empty($academic)) ? $academic->get('description') : null),
'defaultvalue' => $academic,
'title' => get_string('academicgoal', 'artefact.resume'),
),
'careergoal' => array(
'type' => 'wysiwyg',
'rows' => 10,
'cols' => 65,
'defaultvalue' => ((!empty($career)) ? $career->get('description') : null),
'defaultvalue' => $career,
'title' => get_string('careergoal', 'artefact.resume'),
),
'submit' => array(
......
......@@ -75,6 +75,9 @@ $string['backtoresume'] = 'Back to My Resumé';
$string['personalgoal'] = 'Personal Goals';
$string['academicgoal'] = 'Academic Goals';
$string['careergoal'] = 'Career Goals';
$string['defaultpersonalgoal'] = '';
$string['defaultacademicgoal'] = '';
$string['defaultcareergoal'] = '';
$string['personalskill'] = 'Personal Skills';
$string['academicskill'] = 'Academic Skills';
$string['workskill'] = 'Work Skills';
......
......@@ -212,20 +212,15 @@ class ArtefactTypeContactinformation extends ArtefactTypeResume {
}
public static function setup_new($userid) {
$code = get_random_key(10, range(0, 9));
try {
$existing = artefact_instance_from_type('contactinformation', $userid);
throw new ParamOutOfRangeException("Cannot create a new Contactinformation artefact for $userid - they already have one!", $code);
} catch (Exception $e) {
if ($e->getCode() == $code) { // it is the exception we *just* threw
throw $e;
}
return artefact_instance_from_type('contactinformation', $userid);
} catch (ArtefactNotFoundException $e) {
$artefact = new ArtefactTypeContactinformation(null, array(
'owner' => $userid,
'title' => get_string('contactinformation', 'artefact.resume')
));
$artefact->commit();
}
$artefact = new ArtefactTypeContactinformation(null, array(
'owner' => $userid,
'title' => get_string('contactinformation', 'artefact.resume')
));
$artefact->commit();
return $artefact;
}
......
......@@ -322,7 +322,7 @@ class PluginExportHtml extends PluginExport {
}
}
$outputfilter = new HtmlExportOutputFilter($rootpath);
$outputfilter = new HtmlExportOutputFilter($rootpath, $this);
$smarty->assign('view', $outputfilter->filter($view->build_columns()));
$content = $smarty->fetch('export:html:view.tpl');
if (!file_put_contents("$directory/index.html", $content)) {
......@@ -343,6 +343,10 @@ class PluginExportHtml extends PluginExport {
);
}
}
function sort_by_title($a, $b) {
return strnatcasecmp($a['title'], $b['title']);
}
usort($views, 'sort_by_title');
$smarty->assign('views', $views);
if ($views) {
......@@ -461,12 +465,17 @@ class HtmlExportOutputFilter {
*/
private $htmlexportcopyproxy = null;
/**
*/
private $exporter = null;
/**
* @param string $basepath The relative path to the root of the generated export
*/
public function __construct($basepath) {
public function __construct($basepath, &$exporter=null) {
$this->basepath = preg_replace('#/$#', '', $basepath);
$this->htmlexportcopyproxy = HtmlExportCopyProxy::singleton();
$this->exporter = $exporter;
}
/**
......@@ -542,6 +551,10 @@ class HtmlExportOutputFilter {
*/
private function replace_view_link($matches) {
$viewid = $matches[1];
// Don't rewrite links to views that are not going to be included in the export
if (!isset($this->exporter->views[$viewid])) {
return $matches[0];
}
if (!isset($this->viewtitles[$viewid])) {
$this->viewtitles[$viewid] = PluginExportHtml::text_to_path(get_field('view', 'title', 'id', $viewid));
}
......
......@@ -97,7 +97,7 @@ abstract class PluginExport extends Plugin {
/**
* List of views to export. Set up by constructor.
*/
protected $views = array();
public $views = array();
/**
* User object for the user being exported.
......
......@@ -35,13 +35,13 @@ addLoadEvent(function() {
document.location.href = config.wwwroot + 'artefact/file/';
break;
case 'g':
document.location.href = config.wwwroot + 'group/';
document.location.href = config.wwwroot + 'group/mygroups.php';
break;
case 'o':
document.location.href = config.wwwroot + 'group/owned.php';
case 'v':
document.location.href = config.wwwroot + 'view';
break;
case '/':
document.searchform.query.focus();
document.usf.query.focus();
break;
}
config.commandMode = false;
......
......@@ -514,7 +514,6 @@ $string['institutionusersnonmembers'] = 'People who have not requested membershi
$string['institutionusersmembers'] = 'People who are already institution members';
$string['addnewmembers'] = 'Add new members';
$string['addnewmembersdescription'] = '';
$string['usersrequested'] = 'Users who have requested membership';
$string['userstobeadded'] = 'Users to be added as members';
$string['userstoaddorreject'] = 'Users to be added/rejected';
......
......@@ -91,6 +91,7 @@ $string['loggedinlower'] = 'logged in users';
$string['publiclower'] = 'public';
$string['everyoneingroup'] = 'Everyone in Group';
$string['token'] = 'Secret URL';
$string['peoplewiththesecreturl'] = 'People with the Secret URL';
// view user
$string['inviteusertojoingroup'] = 'Invite this user to join a group';
......
......@@ -573,15 +573,23 @@ class MaharaException extends Exception {
$outputmessage = trim($this->render_exception());
if (function_exists('smarty') && !$this instanceof ConfigSanityException) {
$smarty = smarty(array(), array(), array(), array('sidebars' => false));
$smarty->assign('title', $outputtitle);
$smarty->assign('message', $outputmessage);
$smarty->display('error.tpl');
try {
$smarty = smarty(array(), array(), array(), array('sidebars' => false));
$smarty->assign('title', $outputtitle);
$smarty->assign('message', $outputmessage);
$smarty->display('error.tpl');
die();
}
catch (Exception $e) {
// If an exception is thrown in smarty(), ignore it
// and print the message out the ugly way
log_warn("Exception thrown by smarty call while handling exception");
}
}
else {
$outputtitle = htmlspecialchars($outputtitle, ENT_COMPAT, 'UTF-8');
$outputmessage = nl2br(htmlspecialchars($outputmessage, ENT_COMPAT, 'UTF-8'));
echo <<<EOF
$outputtitle = htmlspecialchars($outputtitle, ENT_COMPAT, 'UTF-8');
$outputmessage = nl2br(htmlspecialchars($outputmessage, ENT_COMPAT, 'UTF-8'));
echo <<<EOF
<html>
<head>
<title>$outputtitle</title>
......@@ -618,13 +626,12 @@ class MaharaException extends Exception {
</head>
<body>
EOF;
echo <<<EOF
echo <<<EOF
<h1>$outputtitle</h1>
<div id="message">$outputmessage</div>
</body>
</html>
EOF;
}
// end of printing stuff to the screen...
die();
}
......
......@@ -384,7 +384,8 @@ function get_string_location($identifier, $section, $variables, $replacefunc='fo
}
// First check all the normal locations for the string in the current language
if ($result = get_string_local($langstringroot . $langdirectory, $lang . '/' . $section . '.php', $identifier)) {
$result = get_string_local($langstringroot . $langdirectory, $lang . '/' . $section . '.php', $identifier);
if ($result !== false) {
return $replacefunc($result, $variables);
}
......@@ -398,14 +399,16 @@ function get_string_location($identifier, $section, $variables, $replacefunc='fo
$langfile = $langstringroot . 'lang/' . $lang . '/langconfig.php';
if (is_readable($langfile)) {
if ($parentlang = get_string_from_file('parentlanguage', $langfile)) {
if ($result = get_string_local(get_language_root($parentlang) . 'lang/', $parentlang . '/' . $section . '.php', $identifier)) {
$result = get_string_local(get_language_root($parentlang) . 'lang/', $parentlang . '/' . $section . '.php', $identifier);
if ($result !== false) {
return $replacefunc($result, $variables);
}
}
}
/// Our only remaining option is to try English
if ($result = get_string_local(get_config('docroot') . $langdirectory, 'en.utf8/' . $section . '.php', $identifier)) {
$result = get_string_local(get_config('docroot') . $langdirectory, 'en.utf8/' . $section . '.php', $identifier);
if ($result !== false) {
return $replacefunc($result, $variables);
}
......@@ -421,7 +424,8 @@ function get_string_local($langpath, $langfile, $identifier) {
foreach (array(get_config('docroot') . 'local/lang/', $langpath) as $dir) {
$file = $dir . $langfile;
if (is_readable($file)) {
if ($result = get_string_from_file($identifier, $file)) {
$result = get_string_from_file($identifier, $file);
if ($result !== false) {
return $result;
}
}
......
......@@ -2028,6 +2028,8 @@ class View {
INNER JOIN {group} g ON g.id = vg.group AND g.deleted = 0
UNION SELECT view, \'user\' AS accesstype, NULL AS grouptype, NULL AS role, usr AS id, \'\' AS name, startdate, stopdate
FROM {view_access_usr} vu
UNION SELECT view, \'secreturl\' AS accesstype, NULL AS grouptype, NULL AS role, 0 AS id, \'\' AS name, startdate, stopdate
FROM {view_access_token} vt
UNION SELECT view, accesstype, NULL AS grouptype, NULL AS role, 0 AS id, \'\' AS name, startdate, stopdate
FROM {view_access} va
) AS a
......@@ -2092,7 +2094,7 @@ class View {
if ($accessgroups) {
foreach ($accessgroups as $access) {
$data[$index[$access->view]]['accessgroups'][] = array(
'accesstype' => $access->accesstype, // friends, group, loggedin, public, tutorsgroup, user
'accesstype' => $access->accesstype, // friends, group, loggedin, public, tutorsgroup, user, secreturl
'role' => $access->role,
'roledisplay' => $access->role ? get_string($access->role, 'grouptype.' . $access->grouptype) : null,
'id' => $access->id,
......
......@@ -173,6 +173,7 @@ tinyMCE.init({
});
}
},
remove_script_host: false,
relative_urls: false
});
function custom_urlconvert (u, n, e) {
......@@ -1859,12 +1860,14 @@ function mahara_standard_nav() {
'url' => '',
'title' => get_string('home'),
'weight' => 10,
'accesskey' => 'h',
),
array(
'path' => 'myportfolio',
'url' => 'view/',
'title' => get_string('myportfolio'),
'weight' => 30,
'accesskey' => 'v',
),
array(
'path' => 'myportfolio/views',
......@@ -1884,6 +1887,7 @@ function mahara_standard_nav() {
'url' => 'group/mygroups.php',
'title' => get_string('groups'),
'weight' => 40,
'accesskey' => 'g',
),
array(
'path' => 'groups/mygroups',
......
......@@ -107,7 +107,7 @@ class PluginSearchInternal extends PluginSearch {
$querydata = split(' ', preg_replace('/\s\s+/', ' ', strtolower(trim($query_string))));
$hidenameallowed = get_config('userscanhiderealnames') ? 'TRUE' : 'FALSE';
$namesql = "(u.preferredname $ilike '%' || ? || '%')
OR ((u.preferredname IS NULL OR u.preferredname = '' OR NOT $hidenameallowed OR h.value <> 1)
OR ((u.preferredname IS NULL OR u.preferredname = '' OR NOT $hidenameallowed OR h.value != '1')
AND (u.firstname $ilike '%' || ? || '%' OR u.lastname $ilike '%' || ? || '%'))
OR (a.artefacttype IN $fieldlist
AND ( a.title $ilike '%' || ? || '%'))";
......
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