Commit 8fa70227 authored by Clare Lenihan's avatar Clare Lenihan Committed by Clare Lenihan

fixing weightings + update topics + minor display type stuff

parent 0c9728e4
......@@ -11,7 +11,7 @@
<FIELD NAME="value" TYPE="text" NOTNULL="true" />
</FIELDS>
<KEYS>
<KEY NAME="forumfk" TYPE="foreign" FIELDS="forum" REFTABLE="interaction_instance" REFFIELDS="id" />
<KEY NAME="forumfk" TYPE="foreign" FIELDS="forum" REFTABLE="interaction_instance" REFFIELDS="id" />
</KEYS>
</TABLE>
......
......@@ -45,6 +45,7 @@ $string['cantviewtopic'] = 'You are not allowed to view topics in this forum';
$string['chooseanaction'] = 'Choose an action';
$string['clicksetsubject'] = 'Click to set a subject';
$string['Closed'] = 'Closed';
$string['Close'] = 'Close';
$string['closeddescription'] = 'Closed topics can only be replied to by moderators and the group owner';
$string['Count'] = 'Count';
$string['currentmoderators'] = 'Current Moderators';
......
......@@ -28,7 +28,7 @@ class PluginInteractionForum extends PluginInteraction {
public static function instance_config_form($group, $instance=null) {
if (isset($instance)) {
$weight = get_field('interaction_forum_instance_config', 'value', 'field', '\'weight\'', 'forum', $instance->get('id'));
$weight = get_field('interaction_forum_instance_config', 'value', 'field', 'weight', 'forum', $instance->get('id'));
$moderators = get_column_sql(
'SELECT fm.user
FROM {interaction_forum_moderator} fm
......@@ -114,9 +114,12 @@ class PluginInteractionForum extends PluginInteraction {
}
// Re-order the forums according to their new ordering
delete_records(
'interaction_forum_instance_config',
'field', 'weight'
delete_records_sql(
'DELETE FROM {interaction_forum_instance_config}
WHERE field = \'weight\' AND forum IN (
SELECT id FROM {interaction_instance} WHERE "group" = ?
)',
array($instance->get('group'))
);
if (isset($values['weight'])) {
......
......@@ -10,8 +10,7 @@
</td>
{if !$forum->subscribed || $moderator}
<td>
<input type="checkbox" name="checkbox[{$topic->id|escape}]" class="topic-checkbox">
<input type="hidden" name="topics[{$topic->id|escape}]">
<input type="checkbox" name="checked[{$topic->id|escape}]" class="topic-checkbox">
</td>
{/if}
<td>
......
......@@ -47,7 +47,7 @@
{if $moderator}
<option value="sticky">{str tag="Sticky" section="interaction.forum"}</option>
<option value="unsticky">{str tag="Unsticky" section="interaction.forum"}</option>
<option value="closed">{str tag="Closed" section="interaction.forum"}</option>
<option value="closed">{str tag="Close" section="interaction.forum"}</option>
<option value="open">{str tag="Open" section="interaction.forum"}</option>
{/if}
</select>
......@@ -84,7 +84,7 @@
{if $moderator}
<option value="sticky">{str tag="Sticky" section="interaction.forum"}</option>
<option value="unsticky">{str tag="Unsticky" section="interaction.forum"}</option>
<option value="closed">{str tag="Closed" section="interaction.forum"}</option>
<option value="closed">{str tag="Close" section="interaction.forum"}</option>
<option value="open">{str tag="Open" section="interaction.forum"}</option>
{/if}
</select>
......
......@@ -76,9 +76,8 @@ $moderators = get_column_sql(
);
// updates the selected topics as subscribed/closed/sticky
if (isset($_POST['topics']) && isset($_POST['checkbox'])) {
$topics = array_keys($_POST['topics']);
$checked = array_keys($_POST['checkbox']);
if (isset($_POST['checked'])) {
$checked = array_keys($_POST['checked']);
// get type based on which button was pressed
if (isset($_POST['updatetopics1'])) {
$type = $_POST['type1'];
......@@ -88,7 +87,7 @@ if (isset($_POST['topics']) && isset($_POST['checkbox'])) {
}
// check that user is only messing with topics from this forum
$alltopics = get_column('interaction_forum_topic', 'id', 'forum', $forumid, 'deleted', 0);
if ($topics == array_intersect($topics, $alltopics) && $checked == array_intersect($checked, $topics)) { // $topics and $checked are ok
if ($checked == array_intersect($checked, $alltopics)) { // $checked is a subset of the topics in this forum
if ($moderator && $type == 'sticky') {
set_field_select('interaction_forum_topic', 'sticky', 1, 'id IN (' . implode($checked, ',') . ')', array());
$SESSION->add_ok_msg(get_string('topicstickysuccess', 'interaction.forum'));
......@@ -103,7 +102,7 @@ if (isset($_POST['topics']) && isset($_POST['checkbox'])) {
}
else if ($moderator && $type == 'open') {
set_field_select('interaction_forum_topic', 'closed', 0, 'id IN (' . implode($checked, ',') . ')', array());
$SESSION->add_ok_msg(get_string('topicopensuccess', 'interaction.forum'));
$SESSION->add_ok_msg(get_string('topicopenedsuccess', 'interaction.forum'));
}
else if ($type == 'subscribe' && !$forum->subscribed) {
db_begin();
......@@ -125,7 +124,7 @@ if (isset($_POST['topics']) && isset($_POST['checkbox'])) {
$SESSION->add_ok_msg(get_string('topicunsubscribesuccess', 'interaction.forum'));
}
}
else { // $topics or $checked contain bad values
else { // $checked contains bad values
$SESSION->add_error_msg(get_string('topicupdatefailed', 'interaction.forum'));
}
redirect('/interaction/forum/view.php?id=' . $forumid . '&offset=' . $offset);
......
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