Esempio n. 1
0
     echo Display::return_icon('exclamation.gif');
 }
 echo '</td>';
 echo '<td>';
 echo '<a href="viewthread.php?' . api_get_cidreq() . '&amp;forum=' . Security::remove_XSS($my_forum) . '&amp;origin=' . $origin . '&amp;thread=' . $row['thread_id'] . $origin_string . '&amp;search=' . Security::remove_XSS(urlencode($my_search)) . '" ' . class_visible_invisible($row['visibility']) . '>' . prepare4display($row['thread_title']) . '</a></td>';
 echo '<td>' . $row['thread_replies'] . '</td>';
 echo '<td>' . $row['thread_views'] . '</td>';
 // display the author name
 $tab_poster_info = api_get_user_info($row['user_id']);
 $poster_username = sprintf(get_lang('LoginX'), $tab_poster_info['username']);
 if ($origin != 'learnpath') {
     echo '<td>' . display_user_link($row['user_id'], api_get_person_name($row['firstname'], $row['lastname']), '', $poster_username) . '</td>';
 } else {
     echo '<td>' . Display::tag('span', api_get_person_name($row['firstname'], $row['lastname']), array("title" => api_htmlentities($poster_username, ENT_QUOTES))) . '</td>';
 }
 $last_post_info = get_last_post_by_thread($row['c_id'], $row['thread_id'], $row['forum_id'], is_allowed_to_edit());
 $last_post = null;
 if ($last_post_info) {
     $poster_info = api_get_user_info($last_post_info['poster_id']);
     $post_date = api_convert_and_format_date($last_post_info['post_date']);
     $last_post = $post_date . ' ' . get_lang('By') . ' ' . display_user_link($last_post_info['poster_id'], $poster_info['complete_name'], '', $poster_info['username']);
 }
 /*
             if ($row['last_poster_user_id'] == '0') {
                 $name = $row['poster_name'];
                 $last_poster_username = "";
             } else {
                 $name = api_get_person_name($row['last_poster_firstname'], $row['last_poster_lastname']);
                 $tab_last_poster_info = api_get_user_info($row['last_poster_user_id']);
                 $last_poster_username = sprintf(get_lang('LoginX'), $tab_last_poster_info['username']);
             }
Esempio n. 2
0
function is_allowed_to_edit($user_id, $theme_id)
{
    if ($user_id == 0) {
        return false;
    }
    $theme_editors = get_post_meta($theme_id, 'editors', true);
    if (is_array($theme_editors)) {
        if (in_array($user_id, $theme_editors)) {
            return true;
        }
    } elseif ($theme_editors == $user_id) {
        return true;
    }
}
$editor_user_id = get_current_user_id();
if (current_user_can('manage_options') || is_allowed_to_edit($editor_user_id, $theme_id)) {
    ?>
<div class="fg-editor inactive">
    <form action="<?php 
    echo get_template_directory_uri();
    ?>
/async/ajax-post.php">
        <input type="hidden" name="type" value="tema-post"/>
        <input type="hidden" name="theme_id" value="<?php 
    echo $theme_id;
    ?>
"/>
        <input type="hidden" name="existing" value="false"/>
        <div>
            <label for="title">Titel</label>
            <input required type="text" name="title" placeholder="Skriv titel her"/>
Esempio n. 3
0
if (empty($document_data['parents'])) {
    $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
} else {
    foreach ($document_data['parents'] as $document_sub_data) {
        if ($document_data['title'] == $document_sub_data['title']) {
            continue;
        }
        $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
    }
}
if (!api_is_allowed_to_edit()) {
    api_not_allowed(true);
}
event_access_tool(TOOL_DOCUMENT);
//TODO:check the below code and his funcionality
if (!is_allowed_to_edit()) {
    if (DocumentManager::check_readonly($course_info, $user_id, $file)) {
        api_not_allowed();
    }
}
/* MAIN TOOL CODE */
/*	Code to change the comment	*/
if (isset($_POST['comment'])) {
    // Fixing the path if it is wrong
    $comment = Database::escape_string(trim($_POST['comment']));
    $title = Database::escape_string(trim($_POST['title']));
    //Just in case see BT#3525
    if (empty($title)) {
        $title = $documen_data['title'];
    }
    if (empty($title)) {
Esempio n. 4
0
 */
/**
*	Chamilo Metadata: MD API test and demo
*   The API allows other Dokeos scripts to define & manipulate metadata
*   In this example, MD is defined for 'Document.1001', 1002, 1003
*/
require "../md_funcs.php";
define('EID_TYPE', 'Document');
require '../md_' . strtolower(EID_TYPE) . '.php';
// name of the language file that needs to be included
/*
$language_file = 'Whatever';
*/
require "../../inc/global.inc.php";
isset($_course) or give_up("Select a course first...");
$is_allowed_to_edit = isset($_user['user_id']) && $is_courseMember && is_allowed_to_edit();
if (!$is_allowed_to_edit) {
    give_up("You're not allowed to edit...");
}
$mdStore = new mdstore($is_allowed_to_edit);
// create table if needed
require api_get_path(LIBRARY_PATH) . 'xmd.lib.php';
// mds_update_xml_and_mdt
require api_get_path(LIBRARY_PATH) . 'xht.lib.php';
// mdo_generate_default_xml_metadata
$noPHP_SELF = TRUE;
Display::display_header($nameTools);
echo "\n";
// if the language file in use is not 'md_' . EID_TYPE ...
$langMdTitle = 'Default Title (if doc not in DB)';
$langMdDescription = 'Default description (if doc has no comment)';
/**
 * This function gets all the forum information of the all the forum of the group
 *
 * @param integer $group_id the id of the group we need the fora of (see forum.forum_of_group)
 * @return array
 *
 * @todo this is basically the same code as the get_forums function. Consider merging the two.
 */
function get_forums_of_group($group_id)
{
    $table_forums = Database::get_course_table(TABLE_FORUM);
    $table_threads = Database::get_course_table(TABLE_FORUM_THREAD);
    $table_posts = Database::get_course_table(TABLE_FORUM_POST);
    $table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
    $course_id = api_get_course_int_id();
    // Student
    // Select all the forum information of all forums (that are visible to students).
    $sql = "SELECT * FROM " . $table_forums . " forum , " . $table_item_property . " item_properties\n            WHERE\n                forum.forum_of_group = '" . Database::escape_string($group_id) . "' AND\n                forum.c_id = {$course_id} AND\n                item_properties.c_id = {$course_id} AND\n                forum.forum_id = item_properties.ref AND\n                item_properties.visibility = 1 AND\n                item_properties.tool = '" . TOOL_FORUM . "'\n            ORDER BY forum.forum_order ASC";
    // Select the number of threads of the forums (only the threads that are visible).
    $sql2 = "SELECT count(thread_id) AS number_of_threads, threads.forum_id\n            FROM {$table_threads} threads, " . $table_item_property . " item_properties\n            WHERE\n                threads.thread_id = item_properties.ref AND\n                threads.c_id = {$course_id} AND\n                item_properties.c_id = {$course_id} AND\n                item_properties.visibility = 1 AND\n                item_properties.tool='" . TOOL_FORUM_THREAD . "'\n            GROUP BY threads.forum_id";
    // Select the number of posts of the forum (post that are visible and that are in a thread that is visible).
    $sql3 = "SELECT count(post_id) AS number_of_posts, posts.forum_id\n            FROM {$table_posts} posts, {$table_threads} threads, " . $table_item_property . " item_properties\n            WHERE posts.visible=1 AND\n                posts.c_id = {$course_id} AND\n                item_properties.c_id = {$course_id} AND\n                threads.c_id = {$course_id}\n                AND posts.thread_id=threads.thread_id\n                AND threads.thread_id=item_properties.ref\n                AND item_properties.visibility = 1\n                AND item_properties.tool='" . TOOL_FORUM_THREAD . "'\n            GROUP BY threads.forum_id";
    // Course Admin
    if (is_allowed_to_edit()) {
        // Select all the forum information of all forums (that are not deleted).
        $sql = "SELECT *\n                FROM " . $table_forums . " forum , " . $table_item_property . " item_properties\n                WHERE\n                    forum.forum_of_group = '" . Database::escape_string($group_id) . "' AND\n                    forum.c_id = {$course_id} AND\n                    item_properties.c_id = {$course_id} AND\n                    forum.forum_id = item_properties.ref AND\n                    item_properties.visibility <> 2 AND\n                    item_properties.tool = '" . TOOL_FORUM . "'\n                ORDER BY forum_order ASC";
        // Select the number of threads of the forums (only the threads that are not deleted).
        $sql2 = "SELECT count(thread_id) AS number_of_threads, threads.forum_id\n                 FROM {$table_threads} threads, " . $table_item_property . " item_properties\n                 WHERE\n                    threads.thread_id=item_properties.ref AND\n                    threads.c_id = {$course_id} AND\n                    item_properties.c_id = {$course_id} AND\n                    item_properties.visibility <> 2 AND\n                    item_properties.tool='" . TOOL_FORUM_THREAD . "'\n                GROUP BY threads.forum_id";
        // Select the number of posts of the forum.
        $sql3 = "SELECT count(post_id) AS number_of_posts, forum_id\n                FROM {$table_posts}\n                WHERE c_id = {$course_id} GROUP BY forum_id";
    }
    // Handling all the forum information.
    $result = Database::query($sql);
    $forum_list = array();
    while ($row = Database::fetch_array($result, 'ASSOC')) {
        $forum_list[$row['forum_id']] = $row;
    }
    // Handling the thread count information.
    $result2 = Database::query($sql2);
    while ($row2 = Database::fetch_array($result2, 'ASSOC')) {
        if (is_array($forum_list)) {
            if (array_key_exists($row2['forum_id'], $forum_list)) {
                $forum_list[$row2['forum_id']]['number_of_threads'] = $row2['number_of_threads'];
            }
        }
    }
    // Handling the post count information.
    $result3 = Database::query($sql3);
    while ($row3 = Database::fetch_array($result3, 'ASSOC')) {
        if (is_array($forum_list)) {
            if (array_key_exists($row3['forum_id'], $forum_list)) {
                // This is needed because sql3 takes also the deleted forums into account.
                $forum_list[$row3['forum_id']]['number_of_posts'] = $row3['number_of_posts'];
            }
        }
    }
    // Finding the last post information (last_post_id, last_poster_id, last_post_date, last_poster_name, last_poster_lastname, last_poster_firstname).
    if (!empty($forum_list)) {
        foreach ($forum_list as $key => $value) {
            $last_post_info_of_forum = get_last_post_information($key, is_allowed_to_edit());
            $forum_list[$key]['last_post_id'] = $last_post_info_of_forum['last_post_id'];
            $forum_list[$key]['last_poster_id'] = $last_post_info_of_forum['last_poster_id'];
            $forum_list[$key]['last_post_date'] = $last_post_info_of_forum['last_post_date'];
            $forum_list[$key]['last_poster_name'] = $last_post_info_of_forum['last_poster_name'];
            $forum_list[$key]['last_poster_lastname'] = $last_post_info_of_forum['last_poster_lastname'];
            $forum_list[$key]['last_poster_firstname'] = $last_post_info_of_forum['last_poster_firstname'];
        }
    }
    return $forum_list;
}