} //TODO handle these with ajax calls $userInput->setValidator('notification', new Claro_Validator_ValueType('string')); $notify = $userInput->get('notification', ''); //collect forum-topic-post settings and init some vars $postSettingList = get_post_settings($postId); $topicSettingList = get_topic_settings($topicId); if (false !== $postSettingList && $editMode != 'quote') { $forumSettingList = get_forum_settings($postSettingList['forum_id']); $topicSettingList = get_topic_settings($postSettingList['topic_id']); $topicId = $topicSettingList['topic_id']; } elseif (false !== $topicSettingList) { $forumSettingList = get_forum_settings($topicSettingList['forum_id']); $forumId = $forumSettingList['forum_id']; } else { $forumSettingList = get_forum_settings($forumId); } $incrementViewCount = 'show' == $cmd ? true : false; //init anonymity status if (get_conf('clfrm_anonymity_enabled') == 'TRUE') { $anonymityStatus = $forumSettingList['anonymity']; } else { $anonymityStatus = 'forbidden'; } //check access rights $is_postAllowed = !claro_is_current_user_enrolment_pending() && claro_is_course_member() && $forumSettingList['forum_access'] != 0 && (!$topicId || !$topicSettingList['topic_status']) || claro_is_allowed_to_edit() ? true : false; $is_viewAllowed = !is_null($forumSettingList['idGroup']) && !($forumSettingList['idGroup'] == claro_get_current_group_id() || claro_is_in_a_group() || claro_is_group_allowed()) && !claro_is_allowed_to_edit() ? false : true; // NOTE : $forumSettingList['idGroup'] != claro_get_current_group_id() is necessary to prevent any hacking // attempt like rewriting the request without $cidReq. If we are in group // forum and the group of the concerned forum isn't the same as the session // one, something weird is happening, indeed ...
$dialogBox->form($htmlEditForum); } if ($cmd == 'exDelCat') { if (delete_category($_REQUEST['catId'])) { $dialogBox->success(get_lang('Category deleted')); } else { $dialogBox->error(get_lang('Unable to delete category')); if (claro_failure::get_last_failure() == 'GROUP_FORUMS_CATEGORY_REMOVALE_FORBIDDEN') { $dialogBox->error(get_lang('Group forums category can\'t be deleted')); } elseif (claro_failure::get_last_failure() == 'GROUP_FORUM_REMOVALE_FORBIDDEN') { $dialogBox->error(get_lang('You can not remove a group forum. You have to remove the group first')); } } } if ($cmd == 'exDelForum') { $forumSettingList = get_forum_settings($_REQUEST['forumId']); if (is_null($forumSettingList['idGroup'])) { if (delete_forum($_REQUEST['forumId'])) { $dialogBox->success(get_lang('Forum deleted')); } else { $dialogBox->error(get_lang('Unable to delete Forum')); } } else { $dialogBox->error(get_lang('You can\'t remove a group forum. You have to remove the group first')); } } if ($cmd == 'exEmptyForum') { if (delete_all_post_in_forum($_REQUEST['forumId'])) { $dialogBox->success(get_lang('Forum emptied')); } else { $dialogBox->error(get_lang('Unable to empty forum'));
$dialogBox->success(get_lang('This topic is now open to new contributions')); } else { $dialogBox->error(get_lang('Error while updating topic lock status')); } break; } } if (claro_is_course_member()) { if ($cmd == 'exNotify') { request_forum_notification($forumId, claro_get_current_user_id()); } elseif ($cmd == 'exdoNotNotify') { cancel_forum_notification($forumId, claro_get_current_user_id()); } } //load forum settings and check access rights if (false === ($forumSettingList = get_forum_settings($forumId))) { $dialogBox->error(get_lang('Unknown forum')); $viewAllowed = false; } elseif (!is_null($forumSettingList['idGroup']) && ($forumSettingList['idGroup'] != claro_get_current_group_id() || !claro_is_in_a_group() || !claro_is_group_allowed())) { //this forum is attached to a group which the current user is not member of $dialogBox->error(get_lang('You are not allowed to access this forum')); $viewAllowed = false; } else { $forum_name = $forumSettingList['forum_name']; $forum_cat_id = $forumSettingList['cat_id']; $forum_post_allowed = $forumSettingList['forum_access'] != 0 ? true : false; $display_name = $forum_name; if (get_conf('clfrm_anonymity_enabled', true)) { if ('allowed' == $forumSettingList['anonymity']) { $display_name .= ' (' . get_lang('anonymity allowed') . ')'; } elseif ('default' == $forumSettingList['anonymity']) {
Main Section =================================================================*/ if (isset($_REQUEST['post_id'])) { $post_id = (int) $_REQUEST['post_id']; } else { $post_id = 0; } $is_allowedToEdit = claro_is_allowed_to_edit() || claro_is_group_tutor() && !claro_is_course_manager(); // ( claro_is_group_tutor() // is added to give admin status to tutor // && !claro_is_course_manager()) // is added to let course admin, tutor of current group, use student mode $postSettingList = get_post_settings($post_id); if ($postSettingList && $is_allowedToEdit) { $topic_id = $postSettingList['topic_id']; $forumSettingList = get_forum_settings($postSettingList['forum_id']); $forum_name = stripslashes($forumSettingList['forum_name']); $forum_cat_id = $forumSettingList['cat_id']; /* * Check if the topic isn't attached to a group, or -- if it is attached --, * check the user is allowed to see the current group forum. */ if (!is_null($forumSettingList['idGroup']) && ($forumSettingList['idGroup'] != claro_get_current_group_id() || !claro_is_group_allowed())) { // NOTE : $forumSettingList['idGroup'] != claro_get_current_group_id() is necessary to prevent any hacking // attempt like rewriting the request without $cidReq. If we are in group // forum and the group of the concerned forum isn't the same as the session // one, something weird is happening, indeed ... $allowed = false; $dialogBox->error(get_lang('Not allowed')); } else { if (isset($_REQUEST['cancel'])) {
/** * swap rank of a forum in a category with his neiborgth * * @param integer $currForumId * @param string $direction (UP|DOWN) * @return boolean true whether success else claro_failure result */ function move_forum_rank($currForumId, $direction) { if (strtoupper($direction) == 'UP') { $operator = ' < '; $orderDirection = ' DESC '; } elseif (strtoupper($direction) == 'DOWN') { $operator = ' > '; $orderDirection = ' ASC '; } else { return claro_failure::set_failure('WRONG DIRECTION'); } $tbl_cdb_names = claro_sql_get_course_tbl(); $forumSettingList = get_forum_settings($currForumId); $cat_id = $forumSettingList['cat_id']; $currForumRank = $forumSettingList['forum_rank']; $sql = "SELECT forum_id AS id,\n forum_order AS rank\n FROM `" . $tbl_cdb_names['bb_forums'] . "`\n WHERE cat_id = " . (int) $cat_id . "\n AND forum_order " . $operator . " " . (int) $currForumRank . "\n ORDER BY forum_order " . $orderDirection . " LIMIT 1"; $adjacentForum = claro_sql_query_get_single_row($sql); if (is_array($adjacentForum)) { // SWAP BOTH FORUM RANKS $sql = "UPDATE `" . $tbl_cdb_names['bb_forums'] . "`\n SET `forum_order` = " . (int) $currForumRank . "\n WHERE `forum_id` = " . (int) $adjacentForum['id']; if (claro_sql_query($sql) == false) { return false; } $sql = "UPDATE `" . $tbl_cdb_names['bb_forums'] . "`\n SET `forum_order` = " . (int) $adjacentForum['rank'] . "\n WHERE `forum_id` = " . (int) $currForumId; if (claro_sql_query($sql) == false) { return false; } } else { return false; } return true; }