コード例 #1
0
ファイル: div_left_details.php プロジェクト: jingyexu/ezcast
                        <a class="slide-button" title="®Watch_slide®" href="javascript:switch_video('slide');"></a>
                    </li>
                <?php 
}
?>
                <li>
                    <a class="high-button" title="®Watch_high®" href="javascript:toggle_video_quality('high');"></a>
                    <a class="low-button active" title="®Watch_low®" href="javascript:toggle_video_quality('low');"></a>
                </li>
                <?php 
if (acl_user_is_logged() && acl_has_album_permissions($album)) {
    ?>
                    <li>
                        <a class="add-bookmark-button" title="®Add_bookmark®" href="javascript:toggle_bookmark_form('custom');"></a>
                        <?php 
    if (acl_has_album_moderation($album) || acl_is_admin()) {
        ?>
                            <a class="add-toc-button" title="®Add_toc®" href="javascript:toggle_bookmark_form('official');"></a>
                            <?php 
    }
    if (acl_display_threads()) {
        ?>
                            <a class="add-thread-button" title="®Add_discussion®" href="javascript:toggle_thread_form();"></a>
                        <?php 
    }
    ?>
                    </li>
                <?php 
}
?>
                
コード例 #2
0
ファイル: web_index.php プロジェクト: jingyexu/ezcast
/**
 * Used to remove a thread
 * @global array $input
 * @return boolean
 */
function thread_delete()
{
    global $input;
    $id = $input['thread_id'];
    $album = $input['thread_album'];
    $asset = $input['thread_asset'];
    if (!acl_is_admin()) {
        return false;
    }
    if (!isset($album) || $album == '') {
        $album = $_SESSION['album'];
    }
    if (!isset($asset) || $asset == '') {
        $asset = $_SESSION['asset'];
    }
    thread_delete_by_id($id, $album, $asset);
    cache_asset_threads_unset($album, $asset);
    cache_album_threads_unset($album);
    trace_append(array('3', 'thread_delete', $album, $asset, $id));
    return threads_list_update();
}
コード例 #3
0
<?php

if (isset($threads_list) && sizeof($threads_list) > 0) {
    ?>

    <div class="threads_header">
        <span class="thread-logo"></span>
        <span id="threads_header-label">®Last_discussions®</span>
    </div>
    <div class="threads_list">
        <?php 
    $DTZ = new DateTimeZone('Europe/Paris');
    foreach ($threads_list as $thread) {
        if ($thread['studentOnly'] == '0' || $thread['studentOnly'] == '1' && !acl_has_moderated_album() || acl_is_admin()) {
            $editDate = get_lang() == 'fr' ? new DateTimeFrench($thread['lastEditDate'], $DTZ) : new DateTime($thread['lastEditDate'], $DTZ);
            $editDateVerbose = get_lang() == 'fr' ? $editDate->format('j F Y à H\\hi') : $editDate->format("F j, Y, g:i a");
            //@TODO go to real asset
            $meth_to_call = 'javascript:show_thread(\'' . $thread['albumName'] . '\', \'' . $thread['assetName'] . '\', \'' . $thread['timecode'] . '\', ' . $thread['id'] . ', \'\')';
            ?>
                <div class="item-thread">
                    <div onclick="<?php 
            echo $meth_to_call;
            ?>
">
                        <div class="item-thread-content" >
                                                            <?php 
            if ($thread['studentOnly'] == '1') {
                ?>
                                <img src="images/Generale/visibility-students.png" title="®Visibility_students®" class="visibility"/>
                                <?php 
            } else {
コード例 #4
0
ファイル: lib_threads_pdo.php プロジェクト: jingyexu/ezcast
function thread_search($words, $fields, $albums, $asset = '')
{
    global $db_object;
    // set $relevancy to true if the result is aimed to be sorted by relevancy.
    // With $relevancy = false, as soon as a word is found in any of the fields,
    // we stop the search and check for the next discussion.
    // With $relevancy = true, we search for every words in every fields and
    // give a score to each discussion, according to certain rules.
    $relevancy = true;
    if (count($fields) <= 0) {
        return null;
    }
    if (count($albums) <= 0) {
        return null;
    }
    $albums_in_query = implode(',', array_fill(0, count($albums), '?'));
    $where_base = 'WHERE ' . 'albumName IN (' . $albums_in_query . ') ' . (isset($asset) && $asset != '' ? ' AND assetName LIKE ' . $db_object->quote("%{$asset}%") . ' ' : ' ') . (acl_has_moderated_album() && !acl_is_admin() ? ' AND studentOnly = 0 ' : ' ') . 'AND c.deleted = 0 ';
    if (in_array('title', $fields)) {
        // search in threads titles
        if (count($words) > 0) {
            $where = $where_base . 'AND ( ';
            foreach ($words as $index => $word) {
                if ($index > 0) {
                    $where .= ' OR ';
                }
                $where .= 'title LIKE ' . $db_object->quote("%" . $word . "%") . ' ';
            }
            $where .= ') ';
        }
        /*
         * SELECT DISTINCT ... FROM threads
         * WHERE albumName IN ( ' ... ' )  <-- selection of albums
         * AND assetName LIKE '%$asset%' <-- if $asset != ''
         * AND studentOnly == 0 <-- if user is a teacher
         * AND deleted != 1
         * AND (title LIKE '%$word[i]%' OR title LIKE '%word[i+1]%' ...)
         * GROUP BY albumName, assetName, id;
         */
        $stmt = 'SELECT DISTINCT id, title, message, timecode, albumName, assetName, assetTitle, studentOnly ' . 'FROM ' . db_gettable('threads') . ' c ' . $where . 'GROUP BY albumName, assetName, id';
        $prepared_stmt = $db_object->prepare($stmt);
        $prepared_stmt->execute($albums);
        $result_threads = $prepared_stmt->fetchAll(PDO::FETCH_ASSOC);
    }
    if (in_array('message', $fields)) {
        // search in threads messages and comments
        if (count($words) > 0) {
            $where = $where_base . 'AND ( ';
            foreach ($words as $index => $word) {
                if ($index > 0) {
                    $where .= ' OR ';
                }
                $where .= 'c.message LIKE ' . $db_object->quote("%" . $word . "%") . ' ';
            }
            $where .= ') ';
        }
        /*
         * SELECT DISTINCT ... FROM threads
         * WHERE albumName IN ( ' ... ' )  <-- selection of albums
         * AND assetName LIKE '%$asset%' <-- if $asset != ''
         * AND studentOnly == 0 <-- if user is a teacher
         * AND deleted != 1
         * AND (message LIKE '%$word[i]%' OR message LIKE '%word[i+1]%' ...)
         * GROUP BY albumName, assetName, id;
         */
        $stmt = 'SELECT DISTINCT id, title, message, timecode, albumName, assetName, assetTitle, studentOnly ' . 'FROM ' . db_gettable('threads') . ' c ' . $where . 'GROUP BY albumName, assetName, id';
        $prepared_stmt = $db_object->prepare($stmt);
        $prepared_stmt->execute($albums);
        $result_messages = $prepared_stmt->fetchAll(PDO::FETCH_ASSOC);
        /*
         * SELECT DISTINCT ... FROM comments c
         * JOIN threads t ON ...
         * WHERE albumName IN ( ' ... ' )  <-- selection of albums
         * AND assetName LIKE '%$asset%' <-- if $asset != ''
         * AND studentOnly == 0 <-- if user is a teacher
         * AND c.deleted != 1
         * AND (c.message LIKE '%$word[i]%' OR c.message LIKE '%word[i+1]%' ...)
         * AND t.deleted != 1
         * GROUP BY albumName, assetName, id;
         */
        $stmt = 'SELECT DISTINCT thread, title, c.message, t.message as thread_message, timecode, albumName, assetName, assetTitle, c.id, studentOnly ' . 'FROM ' . db_gettable('comments') . ' c ' . 'JOIN ' . db_gettable('threads') . ' t on c.thread = t.id ' . $where . ' AND t.deleted = 0 ' . 'GROUP BY albumName, assetName, t.id, c.id';
        $prepared_stmt = $db_object->prepare($stmt);
        $prepared_stmt->execute($albums);
        $result_comments = $prepared_stmt->fetchAll(PDO::FETCH_ASSOC);
    }
    // we have now 1/2/3 arrays (depending on fields 'title' and 'message')
    // $result_threads contains all threads where one of the words is in the title
    // $result_messages contains all threads where one of the words is in the message
    // $result_comments contains all the comments where one of the words is in the message
    $threads_array = array();
    // loop on threads that contain at least one word in the title
    foreach ($result_threads as $thread) {
        $score = 0;
        if ($relevancy) {
            foreach ($words as $word) {
                // search the word in the title
                $offset = stripos($thread['title'], $word);
                if ($offset !== false) {
                    // the word has been found, we increment the score
                    $last_index = $offset + strlen($word);
                    $score++;
                    // there is nothing before and/or after the word, we increment the score
                    if ($offset == 0) {
                        $score++;
                    }
                    if ($last_index == strlen($thread['title'])) {
                        $score++;
                    }
                    if ($offset > 0 && $thread['title'][$offset - 1] == ' ') {
                        $score++;
                    }
                    if ($last_index < strlen($thread['title']) && $thread['title'][$last_index] == ' ') {
                        $score++;
                    }
                    // There are multiple occurences of the word, we increment the score
                    $count = substr_count(strtoupper($thread['title']), strtoupper($word));
                    if ($count > 1) {
                        $score += ($count - 1) * 2;
                    }
                }
            }
            $threads_array[$thread['albumName']][$thread['assetName']][$thread['id']]['score'] = $score;
        }
        $threads_array[$thread['albumName']][$thread['assetName']][$thread['id']]['title'] = $thread['title'];
        $threads_array[$thread['albumName']][$thread['assetName']][$thread['id']]['message'] = $thread['message'];
        $threads_array[$thread['albumName']][$thread['assetName']][$thread['id']]['timecode'] = $thread['timecode'];
        $threads_array[$thread['albumName']][$thread['assetName']][$thread['id']]['comments'] = array();
    }
    // loop on thread that contain at least one word in message
    foreach ($result_messages as $thread) {
        $score = 0;
        if ($relevancy) {
            foreach ($words as $word) {
                // search the word in the message
                $offset = stripos($thread['message'], $word);
                if ($offset !== false) {
                    // the word has been found, we increment the score
                    $last_index = $offset + strlen($word);
                    $score++;
                    // there is nothing before and/or after the word, we increment the score
                    if ($offset == 0) {
                        $score++;
                    }
                    if ($last_index == strlen($thread['message'])) {
                        $score++;
                    }
                    if ($offset > 0 && $thread['message'][$offset - 1] == ' ') {
                        $score++;
                    }
                    if ($last_index < strlen($thread['message']) && $thread['message'][$last_index] == ' ') {
                        $score++;
                    }
                    // There are multiple occurences of the word, we increment the score
                    $count = substr_count(strtoupper($thread['message']), strtoupper($word));
                    if ($count > 1) {
                        $score += ($count - 1) * 2;
                    }
                }
            }
        }
        if (isset($threads_array[$thread['albumName']][$thread['assetName']][$thread['id']])) {
            // updates the score of the thread
            if ($relevancy) {
                $threads_array[$thread['albumName']][$thread['assetName']][$thread['id']]['score'] += $score;
            }
        } else {
            if ($relevancy) {
                $threads_array[$thread['albumName']][$thread['assetName']][$thread['id']]['score'] = $score;
            }
            $threads_array[$thread['albumName']][$thread['assetName']][$thread['id']]['title'] = $thread['title'];
            $threads_array[$thread['albumName']][$thread['assetName']][$thread['id']]['message'] = $thread['message'];
            $threads_array[$thread['albumName']][$thread['assetName']][$thread['id']]['timecode'] = $thread['timecode'];
            $threads_array[$thread['albumName']][$thread['assetName']][$thread['id']]['comments'] = array();
        }
    }
    // loop on comments that contain at least one word
    foreach ($result_comments as $thread_comment) {
        $score = 0;
        if ($relevancy) {
            foreach ($words as $word) {
                // search the word in the message
                $offset = stripos($thread_comment['message'], $word);
                if ($offset !== false) {
                    // the word has been found, we increment the score
                    $last_index = $offset + strlen($word);
                    $score++;
                    // there is nothing before and/or after the word, we increment the score
                    if ($offset == 0) {
                        $score++;
                    }
                    if ($last_index == strlen($thread_comment['message'])) {
                        $score++;
                    }
                    if ($offset > 0 && $thread_comment['message'][$offset - 1] == ' ') {
                        $score++;
                    }
                    if ($last_index < strlen($thread_comment['message']) && $thread_comment['message'][$last_index] == ' ') {
                        $score++;
                    }
                    // There are multiple occurences of the word, we increment the score
                    $count = substr_count(strtoupper($thread_comment['message']), strtoupper($word));
                    if ($count > 1) {
                        $score += ($count - 1) * 2;
                    }
                }
            }
        }
        // the thread is already in the list
        if (isset($threads_array[$thread_comment['albumName']][$thread_comment['assetName']][$thread_comment['thread']])) {
            // updates the score of the thread
            if ($relevancy) {
                $threads_array[$thread_comment['albumName']][$thread_comment['assetName']][$thread_comment['thread']]['score'] += $score;
            }
            $threads_array[$thread_comment['albumName']][$thread_comment['assetName']][$thread_comment['thread']]['comments'][$thread_comment['id']] = $thread_comment['message'];
        } else {
            if ($relevancy) {
                $threads_array[$thread_comment['albumName']][$thread_comment['assetName']][$thread_comment['thread']]['score'] = $score;
            }
            $threads_array[$thread_comment['albumName']][$thread_comment['assetName']][$thread_comment['thread']]['title'] = $thread_comment['title'];
            $threads_array[$thread_comment['albumName']][$thread_comment['assetName']][$thread_comment['thread']]['message'] = $thread_comment['thread_message'];
            $threads_array[$thread_comment['albumName']][$thread_comment['assetName']][$thread_comment['thread']]['timecode'] = $thread_comment['timecode'];
            $threads_array[$thread_comment['albumName']][$thread_comment['assetName']][$thread_comment['thread']]['comments'][$thread_comment['id']] = $thread_comment['message'];
        }
    }
    return $threads_array;
}
コード例 #5
0
        </form>
    </div>
</div>
<div id="thread-options" class="right-options">
    <a class="button-empty green2 pull-right inline-block" href="javascript:toggle_comment_form();" >
        ®Reply_discussion®
    </a>
    <?php 
if ($_SESSION['user_login'] == $thread['authorId'] || acl_is_admin()) {
    ?>
        <a class="edit-button green2 pull-right inline-block" title="®Edit_discussion®" onclick="edit_asset_thread(<?php 
    echo $thread['id'];
    ?>
)"></a>
        <?php 
    if (acl_is_admin()) {
        ?>
     
            <a class="delete-button green2 pull-right inline-block" title="®Delete_discussion®" data-reveal-id="popup_delete_thread_<?php 
        echo $thread['id'];
        ?>
" ></a>
            <?php 
    }
}
?>
</div>

<br/><br/>

<?php 
コード例 #6
0
ファイル: div_main_header.php プロジェクト: jingyexu/ezcast
        <?php 
if (acl_user_is_logged()) {
    ?>
            <a id="user-settings" class="pull-right" onclick="javascript:toggle_settings_form()" title="®Preferences_title®">
                <span>®Preferences®</span> 
            </a>    
        <?php 
}
?>
        <?php 
if (acl_admin_user()) {
    ?>
            <span style="float: right; margin: 1px 3px; font-size: 15px;">|</span>
            <a href="javascript:admin_mode_update()" title="®Admin_mode_update®">
                <span class="logout"><?php 
    echo acl_is_admin() ? '®Admin_mode_enabled®' : '®Admin_mode_disabled®';
    ?>
</span>
            </a>
            
        <?php 
}
?>
        <?php 
if (acl_runas()) {
    ?>
            <span style="float: right; margin: 1px 3px; font-size: 15px;">|</span>
            <span class="logout">®connected_as® <b><?php 
    echo $_SESSION['user_full_name'];
    ?>
</b></span>