Commit 395a6ba9 authored by Evan Goldenberg's avatar Evan Goldenberg
Browse files

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

parents ca50981b c048ebab
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2009 Nigel McNie (http://nigel.mcnie.name/)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage blocktype-recentforumposts
* @author Nigel McNie
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2009 Nigel McNie http://nigel.mcnie.name/
*
*/
defined('INTERNAL') || die();
$string['title'] = 'Recent Forum Posts for <group>';
$string['description'] = 'Display recent forum posts for a group';
$string['group'] = 'Group';
$string['nogroupstochoosefrom'] = 'Sorry, no groups to choose from';
$string['poststoshow'] = 'Maximum number of posts to show';
$string['poststoshowdescription'] = 'Between 1 and 100';
$string['recentforumpostsforgroup'] = "Recent Forum Posts for %s";
?>
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2009 Nigel McNie (http://nigel.mcnie.name/)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage blocktype-recentforumposts
* @author Nigel McNie
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2009 Nigel McNie http://nigel.mcnie.name/
*
*/
defined('INTERNAL') || die();
class PluginBlocktypeRecentForumPosts extends SystemBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.recentforumposts');
}
public static function get_description() {
return get_string('description', 'blocktype.recentforumposts');
}
public static function get_categories() {
return array('general');
}
public static function get_viewtypes() {
return array('profile', 'portfolio');
}
public static function render_instance(BlockInstance $instance, $editing=false) {
// When this block is in a group view it should always display the
// forum posts from that group
$groupid = $instance->get_view()->get('group');
$configdata = $instance->get('configdata');
if (!$groupid && !empty($configdata['groupid'])) {
$groupid = intval($configdata['groupid']);
}
if ($groupid) {
$group = get_record_select('group', 'id = ? AND deleted = 0', array($groupid), '*, ' . db_format_tsfield('ctime'));
require_once('group.php');
$role = group_user_access($group->id);
if ($role || $group->public) {
$limit = 5;
if (!empty($configdata['limit'])) {
$limit = intval($configdata['limit']);
}
$foruminfo = get_records_sql_array('
SELECT
p.id, p.subject, p.body, p.poster, p.topic, t.forum, pt.subject AS topicname
FROM
{interaction_forum_post} p
INNER JOIN {interaction_forum_topic} t ON (t.id = p.topic)
INNER JOIN {interaction_instance} i ON (i.id = t.forum)
INNER JOIN {interaction_forum_post} pt ON (pt.topic = p.topic AND pt.parent IS NULL)
WHERE
i.group = ?
AND i.deleted = 0
AND t.deleted = 0
AND p.deleted = 0
ORDER BY
p.ctime DESC
LIMIT ?', array($groupid, $limit));
$smarty = smarty_core();
$smarty->assign('group', $group);
$smarty->assign('foruminfo', $foruminfo);
return $smarty->fetch('blocktype:recentforumposts:recentforumposts.tpl');
}
}
return '';
}
public static function has_instance_config() {
return true;
}
public static function instance_config_form($instance) {
global $USER;
$elements = array();
$groupid = $instance->get_view()->get('group');
$configdata = $instance->get('configdata');
if ($groupid || $instance->get_view()->get('institution')) {
// This block will show recent forum posts from this group
$elements['groupid'] = array(
'type' => 'hidden',
'value' => $groupid,
);
}
else {
// Allow the user to choose a group they're in to show posts for
if (!empty($configdata['groupid'])) {
$groupid = intval($configdata['groupid']);
$group = get_record_select('group', 'id = ? AND deleted = 0', array($groupid), '*, ' . db_format_tsfield('ctime'));
}
$usergroups = get_records_sql_array(
"SELECT g.id, g.name
FROM {group} g
JOIN {group_member} gm ON (gm.group = g.id)
WHERE gm.member = ?
AND g.deleted = 0
ORDER BY g.name", array($USER->get('id')));
if ($usergroups) {
$choosablegroups = array();
foreach ($usergroups as $group) {
$choosablegroups[$group->id] = $group->name;
}
$elements['groupid'] = array(
'type' => 'select',
'title' => get_string('group', 'blocktype.recentforumposts'),
'options' => $choosablegroups,
'collapseifoneoption' => false,
'defaultvalue' => $groupid,
'rules' => array(
'required' => true,
),
);
}
}
if (isset($elements['groupid'])) {
$elements['limit'] = array(
'type' => 'text',
'title' => get_string('poststoshow', 'blocktype.recentforumposts'),
'description' => get_string('poststoshowdescription', 'blocktype.recentforumposts'),
'defaultvalue' => (isset($configdata['limit'])) ? intval($configdata['limit']) : 5,
'size' => 3,
'minvalue' => 1,
'maxvalue' => 100,
);
}
else {
$elements = array(
'whoops' => array(
'type' => 'html',
'value' => '<p class="noartefacts">' . get_string('nogroupstochoosefrom', 'blocktype.recentforumposts') . '</p>',
),
);
}
return $elements;
}
public static function default_copy_type() {
return 'shallow';
}
public static function override_instance_title(BlockInstance $instance) {
$groupid = $instance->get_view()->get('group');
if (!$groupid) {
$configdata = $instance->get('configdata');
if (isset($configdata['groupid'])) {
$groupid = intval($configdata['groupid']);
}
}
if (!empty($groupid)) {
return str_replace('<group>',
get_field('group', 'name', 'id', $groupid),
$instance->get('title')
);
}
else {
return $instance->get('title');
}
}
}
?>
<div>
{if $foruminfo}
{foreach from=$foruminfo item=postinfo}
<h4><a href="{$WWWROOT}interaction/forum/topic.php?id={$postinfo->topic|escape}#post{$postinfo->id|escape}">{$postinfo->topicname|escape}</a></h4>
<div>
<img src="{$WWWROOT}thumb.php?type=profileicon&amp;maxsize=20&amp;id={$postinfo->poster|escape}" alt="">
<a href="{$WWWROOT}user/view.php?id={$postinfo->poster|escape}">{$postinfo->poster|display_name|escape}</a>
</div>
<div>{$postinfo->body|str_shorten_html:100:true}</div>
{/foreach}
{else}
<p>{str tag=noforumpostsyet section=interaction.forum}</p>
{/if}
<p><a href="{$WWWROOT}interaction/forum/?group={$group->id|escape}" target="_blank">{str tag=gotoforums section=interaction.forum} &raquo;</a></p>
</div>
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2009 Nigel McNie (http://nigel.mcnie.name/)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage blocktype-recentforumposts
* @author Nigel McNie
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2009 Nigel McNie http://nigel.mcnie.name/
*
*/
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2009120700;
$config->release = '1.0.0';
?>
......@@ -1348,6 +1348,12 @@ function xmldb_core_upgrade($oldversion=0) {
}
}
if ($oldversion < 2010021500) {
if ($data = check_upgrades('blocktype.recentforumposts')) {
upgrade_plugin($data);
}
}
return $status;
}
......
......@@ -97,15 +97,14 @@ function pieform_element_wysiwyg_get_headdata() {
global $USER, $_PIEFORM_WYSIWYGS;
if ($USER->get_account_preference('wysiwyg') || defined('PUBLIC')) {
$result = '<script type="text/javascript">'
. "\nvar focusEditor = '$_PIEFORM_WYSIWYGS[0]';"
. "\nPieformManager.connect('onsubmit', null, tinyMCE.triggerSave);"
. "\nPieformManager.connect('onload', null, function() {\n";
foreach ($_PIEFORM_WYSIWYGS as $editor) {
$result .= " tinyMCE.execCommand('mceAddControl', false, '$editor');\n";
$result .= " tinyMCE.execCommand('mceFocus', false, '$editor');\n";
}
$result .= "});\nPieformManager.connect('onreply', null, function() {\n";
foreach ($_PIEFORM_WYSIWYGS as $editor) {
$result .= " tinyMCE.execCommand('mceFocus', false, '$editor');\n";
$result .= " tinyMCE.execCommand('mceRemoveControl', false, '$editor');\n";
}
$result .= "});</script>";
......
......@@ -28,7 +28,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2010012702;
$config->version = 2010021500;
$config->release = '1.3.0dev';
$config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
......
......@@ -166,6 +166,13 @@ tinyMCE.init({
directionality: "{$tinymce_langdir}",
content_css : {$content_css},
//document_base_url: {$jswwwroot},
setup: function(ed) {
if (focusEditor && ed.id == focusEditor) {
ed.onInit.add(function(ed) {
ed.focus();
});
}
},
relative_urls: false
});
function custom_urlconvert (u, n, e) {
......
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