Ejemplo n.º 1
0
            $form->assign('is_allowedToEdit', $is_allowedToEdit);
            $form->assign('editor', claro_html_textarea_editor('message', $message));
        } else {
            $form = null;
            $dialogBox->error(get_lang('Your are not allowed to edit a contribution'));
            $cmd = 'show';
        }
    }
}
if ($is_viewAllowed || $is_postAllowed) {
    //notification commands should be handled by ajax calls
    if ('exNotify' == $cmd) {
        request_topic_notification($topicId, claro_get_current_user_id());
        $cmd = 'show';
    } elseif ('exdoNotNotify' == $cmd) {
        cancel_topic_notification($topicId, claro_get_current_user_id());
        $cmd = 'show';
    }
}
//load required js and css files
JavaScriptLoader::getInstance()->load('forum');
CssLoader::getInstance()->load('clfrm', 'screen');
// Javascript confirm pop up declaration for header
JavascriptLanguage::getInstance()->addLangVar('Are you sure to delete %name ?');
JavascriptLanguage::getInstance()->addLangVar('Do you really want to sign your contribution ?');
JavascriptLoader::getInstance()->load('forum');
// Prepare display
$out = '';
// Command list
$cmdList = array();
$nameTools = get_lang('Forums');
Ejemplo n.º 2
0
/**
 * Update summary info in forum and topic table
 * @param int forumId
 * @param int topicId (optionnal)
 * @return boolean true if succeeds, false otherwise
 */
function sync($forumId, $topicId = null)
{
    $tbl_cdb_names = claro_sql_get_course_tbl();
    $tbl_forums = $tbl_cdb_names['bb_forums'];
    $tbl_topics = $tbl_cdb_names['bb_topics'];
    $tbl_posts = $tbl_cdb_names['bb_posts'];
    // TOPIC SYNC PART
    if ($topicId) {
        $sql = "SELECT COUNT(post_id) AS total\n                FROM `" . $tbl_posts . "`\n                WHERE topic_id = " . (int) $topicId;
        $total_posts = claro_sql_query_get_single_value($sql);
        if ($total_posts < 1) {
            // no post anymore in the topic --> delete topic
            $sql = "DELETE FROM `" . $tbl_topics . "`\n                    WHERE topic_id = " . (int) $topicId;
            if (claro_sql_query($sql) == false) {
                return false;
            }
            if (!cancel_topic_notification($topicId)) {
                return false;
            }
        } else {
            $sql = "SELECT MAX(post_id) AS last_post\n                    FROM `" . $tbl_posts . "`\n                    WHERE topic_id = " . (int) $topicId;
            $last_post = claro_sql_query_get_single_value($sql);
            $sql = "UPDATE `" . $tbl_topics . "`\n                    SET topic_replies = " . (int) $total_posts . ",\n                    # note. topic_replies should be renamed topic_posts'\n                        topic_last_post_id = " . (int) $last_post . "\n                    WHERE topic_id = " . (int) $topicId;
            if (claro_sql_query($sql) == false) {
                return false;
            }
        }
    }
    // else noop
    // FORUM SYNC PART
    $sql = "SELECT COUNT(post_id) AS total\n            FROM `" . $tbl_posts . "`\n            WHERE forum_id = " . (int) $forumId;
    $total_posts = claro_sql_query_get_single_value($sql);
    $sql = "SELECT MAX(post_id) AS last_post\n            FROM `" . $tbl_posts . "`\n            WHERE forum_id = '" . (int) $forumId . "'";
    $last_post = claro_sql_query_get_single_value($sql);
    $sql = "SELECT COUNT(topic_id) AS total\n            FROM `" . $tbl_topics . "`\n            WHERE forum_id = '" . (int) $forumId . "'";
    $total_topics = claro_sql_query_get_single_value($sql);
    $sql = "UPDATE `" . $tbl_forums . "`\n            SET forum_last_post_id = '" . (int) $last_post . "',\n                forum_posts = '" . (int) $total_posts . "',\n                forum_topics = '" . (int) $total_topics . "'\n            WHERE forum_id = '" . (int) $forumId . "'";
    if (claro_sql_query($sql) == false) {
        return false;
    }
    return true;
}