Example #1
0
function list_videos()
{
    global $id, $tool_content, $themeimg, $course_id, $langTitle, $langDescr, $langDate, $langChoice, $langCatVideoDirectory, $langAddModulesButton, $langNoVideo, $course_code;
    $count = 0;
    $video_found = FALSE;
    $cnt1 = Database::get()->querySingle("SELECT COUNT(*) AS cnt FROM video WHERE course_id = ?d", $course_id)->cnt;
    $cnt2 = Database::get()->querySingle("SELECT COUNT(*) AS cnt FROM videolink WHERE course_id = ?d", $course_id)->cnt;
    $count = $cnt1 + $cnt2;
    if ($count > 0) {
        $video_found = TRUE;
        $tool_content .= "<form action='insert.php?course={$course_code}' method='post'><input type='hidden' name='id' value='{$id}' />";
        $tool_content .= "<table class='table-default'>";
        $tool_content .= "<tr>" . "<th width='200' class='text-left'>&nbsp;{$langTitle}</th>" . "<th class='text-left'>{$langDescr}</th>" . "<th width='100'>{$langDate}</th>" . "<th width='80'>{$langChoice}</th>" . "</tr>";
        foreach (array('video', 'videolink') as $table) {
            $result = Database::get()->queryArray("SELECT * FROM {$table} WHERE (category IS NULL OR category = 0) AND course_id = ?d", $course_id);
            foreach ($result as $row) {
                $row->course_id = $course_id;
                if ($table == 'video') {
                    $vObj = MediaResourceFactory::initFromVideo($row);
                    $videolink = MultimediaHelper::chooseMediaAhref($vObj);
                } else {
                    $vObj = MediaResourceFactory::initFromVideoLink($row);
                    $videolink = MultimediaHelper::chooseMedialinkAhref($vObj);
                }
                $tool_content .= "<td>&nbsp;" . icon('fa-film') . "&nbsp;&nbsp;" . $videolink . "</td>" . "<td>" . q($row->description) . "</td>" . "<td class='text-center'>" . nice_format($row->date, true, true) . "</td>" . "<td class='text-center'><input type='checkbox' name='video[]' value='{$table}:{$row->id}' /></td>" . "</tr>";
            }
        }
        $sql = Database::get()->queryArray("SELECT * FROM video_category WHERE course_id = ?d ORDER BY name", $course_id);
        if ($sql) {
            $tool_content .= "<tr><td colspan='3' class='bold'>&nbsp;{$langCatVideoDirectory}</td></tr>";
            foreach ($sql as $videocat) {
                $tool_content .= "<tr>";
                $tool_content .= "<td>" . icon('fa-folder-o') . "&nbsp;&nbsp;" . q($videocat->name) . "</td>";
                $tool_content .= "<td colspan='2'>" . standard_text_escape($videocat->description) . "</td>";
                $tool_content .= "<td align='center'><input type='checkbox' name='videocatlink[]' value='{$videocat->id}' /></td>";
                $tool_content .= "</tr>";
                foreach (array('video', 'videolink') as $table) {
                    $sql2 = Database::get()->queryArray("SELECT * FROM {$table} WHERE category = ?d", $videocat->id);
                    foreach ($sql2 as $linkvideocat) {
                        $tool_content .= "<tr>";
                        $tool_content .= "<td>&nbsp;&nbsp;&nbsp;&nbsp;<img src='{$themeimg}/links_on.png' />&nbsp;&nbsp;<a href='" . q($linkvideocat->url) . "' target='_blank'>" . q($linkvideocat->title == '' ? $linkvideocat->url : $linkvideocat->title) . "</a></td>";
                        $tool_content .= "<td>" . standard_text_escape($linkvideocat->description) . "</td>";
                        $tool_content .= "<td class='text-center'>" . nice_format($linkvideocat->date, true, true) . "</td>";
                        $tool_content .= "<td class='text-center'><input type='checkbox' name='video[]' value='{$table}:{$linkvideocat->id}' /></td>";
                        $tool_content .= "</tr>";
                    }
                }
            }
        }
        $tool_content .= "<tr><th colspan='4'><div align='right'><input class='btn btn-primary' type='submit' name='submit_video' value='" . q($langAddModulesButton) . "' />&nbsp;&nbsp;</div></th></tr></table></form>";
    }
    if (!$video_found) {
        $tool_content .= "<div class='alert alert-warning'>{$langNoVideo}</div>";
    }
}
Example #2
0
        // common docs
        if (!$common_doc_visible and !$is_admin) {
            // hide links to invisible common docs to non-admins
            continue;
        }
        $path = $real_path;
    } else {
        $path = $basedir . $row->path;
    }
    if (!$real_path and $row->extra_path) {
        // external file
        $size = 0;
    } else {
        $size = file_exists($path) ? filesize($path) : 0;
    }
    $fileinfo[] = array('is_dir' => $row->format == '.dir', 'size' => $size, 'title' => $row->title, 'filename' => $row->filename, 'format' => $row->format, 'path' => $row->path, 'extra_path' => $row->extra_path, 'visible' => $row->visible == 1, 'public' => $row->public, 'comment' => $row->comment, 'copyrighted' => $row->copyrighted, 'date' => $row->date_modified, 'object' => MediaResourceFactory::initFromDocument($row), 'editable' => $row->editable);
}
// end of common to teachers and students
// ----------------------------------------------
// Display
// ----------------------------------------------
$cmdCurDirPath = rawurlencode($curDirPath);
$cmdParentDir = rawurlencode($parentDir);
if ($can_upload) {
    // Action result message
    if (!empty($action_message)) {
        $tool_content .= $action_message;
    }
    // available actions
    if (!$is_in_tinymce) {
        if (isset($_GET['rename'])) {
Example #3
0
 * For a full list of contributors, see "credits.txt".
 *
 * Open eClass is an open platform distributed in the hope that it will
 * be useful (without any warranty), under the terms of the GNU (General
 * Public License) as published by the Free Software Foundation.
 * The full license can be read in "/info/license/license_gpl.txt".
 *
 * Contact address: GUnet Asynchronous eLearning Group,
 *                  Network Operations Center, University of Athens,
 *                  Panepistimiopolis Ilissia, 15784, Athens, Greece
 *                  e-mail: info@openeclass.org
 * ======================================================================== */


$require_current_course = true;
require_once '../../../include/init.php';
require_once 'include/lib/multimediahelper.class.php';
require_once 'include/lib/mediaresource.factory.php';

$nameTools = $langMediaTypeDesc;

if (isset($_GET['id'])) {
    $id = q($_GET['id']);

    $row = Database::get()->querySingle("SELECT * FROM videolink WHERE course_id = ?d AND url = ?s", $course_id, $id);
    if ($row) {
        $vObj = MediaResourceFactory::initFromVideoLink($row);
        echo MultimediaHelper::medialinkIframeObject($vObj);
    }
}
Example #4
0
/**
 * @brief display resource video category
 * @global type $is_editor
 * @global type $course_id
 * @global type $langInactiveModule
 * @param array $table
 * @param type $title
 * @param type $comments
 * @param type $resource_id
 * @param type $videolinkcat_id
 * @param type $visibility
 * @return string
 */
function show_videocat($table, $title, $comments, $resource_id, $videolinkcat_id, $visibility)
{
    global $is_editor, $course_id, $langInactiveModule;
    $content = $linkcontent = '';
    $module_visible = visible_module(MODULE_ID_VIDEO);
    // checks module visibility
    if (!$module_visible and !$is_editor) {
        return '';
    }
    $comment_box = $class_vis = $imagelink = $link = '';
    $class_vis = ($visibility == 0 or !$module_visible) ? ' class="not_visible"' : ' ';
    $title = q($title);
    $sql = Database::get()->queryArray("SELECT * FROM video_category WHERE id = ?d AND course_id = ?d", $videolinkcat_id, $course_id);
    foreach ($sql as $vlcat) {
        $content .= "\n            <tr{$class_vis}>\n              <td width='1'>" . icon('fa-folder-o') . "</td>\n              <td>" . q($vlcat->name);
        if (!empty($vlcat->description)) {
            $comment_box = "<br />{$vlcat->description}";
        } else {
            $comment_box = '';
        }
        foreach (array('video', 'videolink') as $table) {
            $sql2 = Database::get()->queryArray("SELECT * FROM {$table} WHERE category = ?d AND course_id = ?d", $vlcat->id, $course_id);
            foreach ($sql2 as $row) {
                if (!$is_editor and !resource_access(1, $row->public)) {
                    return '';
                }
                $status = $row->public;
                if ($table == 'video') {
                    $vObj = MediaResourceFactory::initFromVideo($row);
                    $videolink = MultimediaHelper::chooseMediaAhref($vObj);
                } else {
                    $vObj = MediaResourceFactory::initFromVideoLink($row);
                    $videolink = MultimediaHelper::chooseMedialinkAhref($vObj);
                }
                if (!$module_visible) {
                    $videolink .= " <i>({$langInactiveModule})</i>";
                }
                if (!empty($comments)) {
                    $comment_box = "<br />{$comments}";
                } else {
                    $comment_box = "";
                }
                $class_vis = ($visibility == 0 or !$module_visible or $status == 'del') ? ' class="not_visible"' : ' ';
                $ltitle = q($row->title == '' ? $row->url : $row->title);
                $linkcontent .= "<br />" . icon('fa-film') . "&nbsp;&nbsp;{$videolink}</a>";
                if (!$module_visible) {
                    $linkcontent .= " <i>({$langInactiveModule})</i>";
                }
            }
        }
    }
    return $content . $comment_box . $linkcontent . '
           </td>' . actions('videolinkcategory', $resource_id, $visibility) . '</tr>';
}
Example #5
0
/**
 * @brief display multimedia files
 * @global type $langName
 * @global type $langSelection
 * @global type $langAddModulesButton
 * @global type $course_code
 * @return string
 */
function showmedia() {
    global $langName, $langSelection, $langAddModulesButton, $course_code, $course_id;
        
    $output = "<form action='$_SERVER[SCRIPT_NAME]?course=$course_code' method='POST'>
               <div class='table-responsive'>
               <table class='table-default'>
               <thead>
               <tr class='list-header'>
               <th>$langName</th>
               <th width='50'>$langSelection</th>
               </tr>
               </thead>
               <tbody>";

    $i = 1;
    $resultMedia = Database::get()->queryArray("SELECT * FROM video WHERE visible = 1 AND course_id = ?d ORDER BY title", $course_id);
    foreach ($resultMedia as $myrow) {
        $vObj = MediaResourceFactory::initFromVideo($myrow);

        $output .= "<tr>                    
                    <td align='text-left'>" . MultimediaHelper::chooseMediaAhref($vObj) . "
                    <br />
                    <small class='comments'>" . q($myrow->description) . "</small></td>";
        $output .= "<td><div align='center'><input type='checkbox' name='insertMedia_" . $i . "' id='insertMedia_" . $i . "' value='" . $myrow->id . "' /></div></td></tr>";
        $i++;
    }

    $j = 1;
    $resultMediaLinks = Database::get()->queryArray("SELECT * FROM videolink WHERE visible = 1 AND course_id = ?d ORDER BY title", $course_id);
    foreach ($resultMediaLinks as $myrow) {
        $vObj = MediaResourceFactory::initFromVideoLink($myrow);
        $output .= "<tr>                    
                    <td align='left' valign='top'>" . MultimediaHelper::chooseMedialinkAhref($vObj) . "
                    <br />
                    <small class='comments'>" . q($myrow->description) . "</small></td>";
        $output .= "<td><div align='center'><input type='checkbox' name='insertMediaLink_" . $j . "' id='insertMediaLink_" . $j . "' value='" . $myrow->id . "' /></div></td></tr>";
        $j++;
    }

    $output .= "
                </tbody>
                <tfooter>
                <tr>
                <th colspan='3'>
                <div align='right'>
                  <input type='hidden' name='maxMediaForm' value ='" . ($i + $j - 2) . "' />
                  <input class='btn btn-primary' type='submit' name='submitInsertedMedia' value='$langAddModulesButton'/>
                </div></th>
                </tr>
                </tfooter>
                </table>
                </div>
                </form>";
    return $output;
}
Example #6
0
    header("Location: ${urlServer}");
    exit();
}

if ($uid) {
    require_once 'include/action.php';
    $action = new action();
    $action->record(MODULE_ID_VIDEO);
}

// ----------------------
// download video
// ----------------------
$res2 = Database::get()->querySingle("SELECT * FROM video
                  WHERE course_id = ?d AND id = ?d", $course_id, $_GET['id']);

if (!$res2) {
    header("Location: ${urlServer}");
    exit();
}

$valid = ($uid || course_status($course_id) == COURSE_OPEN) ? true : token_validate($row2['path'], $_GET['token'], 30);
if (!$valid) {
    header("Location: ${urlServer}");
    exit();
}

$vObj = MediaResourceFactory::initFromVideo($res2);
$real_file = $webDir . "/video/" . q($_GET['course']) . q($vObj->getPath());
send_file_to_client($real_file, my_basename(q($vObj->getUrl())), $disposition, true);
Example #7
0
/**
 * list documents while inserting them in course unit
 * @global type $id
 * @global type $webDir
 * @global type $course_code
 * @global type $tool_content
 * @global type $group_sql
 * @global type $langDirectory
 * @global type $langUp
 * @global type $langName
 * @global type $langSize
 * @global type $langDate
 * @global type $langType
 * @global type $langAddModulesButton
 * @global type $langChoice
 * @global type $langNoDocuments
 * @global type $course_code 
 */
function list_docs() {
    global $id, $webDir, $course_code, $tool_content,
    $group_sql, $langDirectory, $langUp, $langName, $langSize,
    $langDate, $langType, $langAddModulesButton, $langChoice,
    $langNoDocuments, $course_code, $langCommonDocs, $pageName;

    $basedir = $webDir . '/courses/' . $course_code . '/document';
    $path = get_dir_path('path');
    $dir_param = get_dir_path('dir');
    $dir_setter = $dir_param ? ('&amp;dir=' . $dir_param) : '';
    $dir_html = $dir_param ? "<input type='hidden' name='dir' value='$dir_param'>" : '';

    if ($id == -1) {
        $common_docs = true;
        $pageName = $langCommonDocs;
        $group_sql = "course_id = -1 AND subsystem = " . COMMON . "";
        $basedir = $webDir . '/courses/commondocs';
        $visible_sql = 'visible = 1 AND';
    } else {
        $common_docs = false;
        $visible_sql = '';
    }
    $result = Database::get()->queryArray("SELECT id, course_id, path, filename, format, title, extra_path, date_modified, visible, copyrighted, comment, IF(title = '', filename, title) AS sort_key FROM document
                                WHERE $group_sql AND $visible_sql
                                      path LIKE ?s AND
                                      path NOT LIKE ?s
                                ORDER BY sort_key COLLATE utf8_unicode_ci",
                                "$path/%", "$path/%/%");

    $fileinfo = array();
    $urlbase = $_SERVER['SCRIPT_NAME'] . "?course=$course_code$dir_setter&amp;type=doc&amp;id=$id&amp;path=";

    foreach ($result as $row) {
        $fullpath = $basedir . $row->path;
        if ($row->extra_path) {
            $size = 0;
        } else {
            $size = file_exists($fullpath)? filesize($fullpath): 0;
        }
        $fileinfo[] = array(
            'id' => $row->id,
            'is_dir' => is_dir($fullpath),
            'size' => $size,
            'title' => $row->title,
            'name' => htmlspecialchars($row->filename),
            'format' => $row->format,
            'path' => $row->path,
            'visible' => $row->visible,
            'comment' => $row->comment,
            'copyrighted' => $row->copyrighted,
            'date' => $row->date_modified,
            'object' => MediaResourceFactory::initFromDocument($row));
    }
    if (count($fileinfo) == 0) {
        $tool_content .= "<div class='alert alert-warning'>$langNoDocuments</div>";
    } else {
        if (!empty($path)) {
            $dirname = Database::get()->querySingle("SELECT filename FROM document
                                                                   WHERE $group_sql AND path = ?s", $path);
            $parentpath = dirname($path);
            $dirname =  htmlspecialchars($dirname->filename);
            $parentlink = $urlbase . $parentpath;
            $parenthtml = "<span class='pull-right'><a href='$parentlink'>$langUp " .
                    icon('fa-level-up') . "</a></span>";
            $colspan = 4;
        }
        $tool_content .= "<form action='insert.php?course=$course_code' method='post'><input type='hidden' name='id' value='$id' />" .
                "<table class='table-default'>";
        if( !empty($path)) {
        $tool_content .=
                "<tr>" .
                "<th colspan='$colspan'><div class='text-left'>$langDirectory: $dirname$parenthtml</div></th>" .
                "</tr>" ;
        }
        $tool_content .=
                "<tr class='list-header'>" .
                "<th class='text-left'>$langName</th>" .
                "<th class='text-center'>$langSize</th>" .
                "<th class='text-center'>$langDate</th>" .
                "<th style='width:20px;' class='text-center'>$langChoice</th>" .
                "</tr>";
        $counter = 0;
        foreach (array(true, false) as $is_dir) {
            foreach ($fileinfo as $entry) {
                if ($entry['is_dir'] != $is_dir) {
                    continue;
                }
                $dir = $entry['path'];
                if ($is_dir) {
                    $image = 'fa-folder-o';
                    $file_url = $urlbase . $dir;
                    $link_text = $entry['name'];

                    $link_href = "<a href='$file_url'>$link_text</a>";
                } else {
                    $image = choose_image('.' . $entry['format']);
                    $file_url = file_url($entry['path'], $entry['name'], $common_docs ? 'common' : $course_code);

                    $dObj = $entry['object'];
                    $dObj->setAccessURL($file_url);
                    $dObj->setPlayURL(file_playurl($entry['path'], $entry['name'], $common_docs ? 'common' : $course_code));

                    $link_href = MultimediaHelper::chooseMediaAhref($dObj);
                }
                if ($entry['visible'] == 'i') {
                    $vis = 'invisible';
                } else {
                    $vis = '';                    
                }
                $tool_content .= "<tr class='$vis'>";
                $tool_content .= "<td>" . icon($image, '')."&nbsp;&nbsp;&nbsp;$link_href";

                /* * * comments ** */
                if (!empty($entry['comment'])) {
                    $tool_content .= "<br /><div class='comment'>" .
                            standard_text_escape($entry['comment']) .
                            "</div>";
                }
                $tool_content .= "</td>";
                if ($is_dir) {
                    // skip display of date and time for directories
                    $tool_content .= "<td>&nbsp;</td><td>&nbsp;</td>";
                } else {
                    $size = format_file_size($entry['size']);
                    $date = nice_format($entry['date'], true, true);
                    $tool_content .= "<td class='text-right'>$size</td><td class='text-center'>$date</td>";
                }
                $tool_content .= "<td class='text-center'><input type='checkbox' name='document[]' value='$entry[id]' /></td>";
                $tool_content .= "</tr>";
                $counter++;
            }
        }
        $tool_content .= "</table>";
        $tool_content .= "<div class='text-right'>";
        $tool_content .= "<input class='btn btn-primary' type='submit' name='submit_doc' value='$langAddModulesButton' /></div>$dir_html</form>";
        
    }
}
Example #8
0
function showmedia()
{
    global $langName, $langSelection, $langAddModulesButton, $course_code, $themeimg;
    $sqlMedia = "SELECT * FROM video WHERE visible = 1 ORDER BY title";
    $sqlMediaLinks = "SELECT * FROM videolink WHERE visible = 1 ORDER BY title";
    $output = "<form action='{$_SERVER['SCRIPT_NAME']}?course={$course_code}' method='POST'>\n               <table width='100%' class='tbl_alt'>\n               <tr>\n               <th colspan='2'>{$langName}</th>\n               <th width='50'>{$langSelection}</th>\n               </tr>\n               <tbody>";
    $i = 1;
    $resultMedia = Database::get()->queryArray($sqlMedia);
    foreach ($resultMedia as $myrow) {
        $vObj = MediaResourceFactory::initFromVideo($myrow);
        $output .= "<tr>\n                    <td width='1' valign='top'><img src='{$themeimg}/arrow.png' border='0'></td>\n                    <td align='left' valign='top'>" . MultimediaHelper::chooseMediaAhref($vObj) . "\n                    <br />\n                    <small class='comments'>" . q($myrow->description) . "</small></td>";
        $output .= "<td><div align='center'><input type='checkbox' name='insertMedia_" . $i . "' id='insertMedia_" . $i . "' value='" . $myrow->id . "' /></div></td></tr>";
        $i++;
    }
    $j = 1;
    $resultMediaLinks = Database::get()->queryArray($sqlMediaLinks);
    foreach ($resultMediaLinks as $myrow) {
        $vObj = MediaResourceFactory::initFromVideoLink($myrow);
        $output .= "<tr>\n                    <td width='1' valign='top'><img src='{$themeimg}/arrow.png' border='0'></td>\n                    <td align='left' valign='top'>" . MultimediaHelper::chooseMedialinkAhref($vObj) . "\n                    <br />\n                    <small class='comments'>" . q($myrow->description) . "</small></td>";
        $output .= "<td><div align='center'><input type='checkbox' name='insertMediaLink_" . $j . "' id='insertMediaLink_" . $j . "' value='" . $myrow->id . "' /></div></td></tr>";
        $j++;
    }
    $output .= "<tr>\n                <th colspan='3'>\n                <div align='right'>\n                  <input type='hidden' name='maxMediaForm' value ='" . ($i + $j - 2) . "' />\n                  <input class='btn btn-primary' type='submit' name='submitInsertedMedia' value='{$langAddModulesButton}'/>\n                </div></th>\n                </tr>\n                </tbody>\n                </table>\n                </form>";
    return $output;
}
Example #9
0
/**
 * @brief display links of category (if category is defined) else display all
 * @global type $is_in_tinymce
 * @global type $themeimg
 * @global type $tool_content
 * @global type $is_editor
 * @global type $course_id
 * @global type $course_code
 * @global type $langDelete
 * @global type $langViewHide
 * @global type $langViewShow
 * @global type $langPreview
 * @global type $langDownload
 * @global type langResourceAccessLock
 * @global type langResourceAccessUnlock
 * @global type $langEditChange
 * @global type $langConfirmDelete
 * @global type $filterv
 * @global type $filterl
 * @param type $cat_id
 */
function showlinksofcategory($cat_id = 0) {
    global $course_id, $is_in_tinymce, $tool_content, $is_editor, $course_code,
        $langDelete, $langViewHide, $langViewShow, $langConfirmDelete,
        $display_tools, $is_in_tinymce, $langDownload, $langResourceAccessLock,
        $langResourceAccessUnlock, $langEditChange, $filterv, $filterl, $order,
        $compatiblePlugin, $langcreator, $langpublisher;

    if ($is_editor) {
        $vis_q = '';
    } else {
        $vis_q = "AND visible = 1";
    }
    if ($cat_id > 0) {
        $results['video'] = Database::get()->queryArray("SELECT * FROM video $filterv AND course_id = ?d AND category = ?d $vis_q $order", $course_id, $cat_id);
        $results['videolink'] = Database::get()->queryArray("SELECT * FROM videolink $filterl AND course_id = ?d AND category = ?d $vis_q $order", $course_id, $cat_id);
    } else {
        $results['video'] = Database::get()->queryArray("SELECT * FROM video $filterv AND course_id = ?d AND (category IS NULL OR category = 0) $vis_q $order", $course_id);
        $results['videolink'] = Database::get()->queryArray("SELECT * FROM videolink $filterl AND course_id = ?d AND (category IS NULL OR category = 0) $vis_q $order", $course_id);
    }

    foreach ($results as $table => $result) {
        foreach ($result as $myrow) {
            $myrow->course_id = $course_id;
            if (resource_access($myrow->visible, $myrow->public) || $is_editor) {
                switch ($table) {
                    case 'video':
                        $vObj = MediaResourceFactory::initFromVideo($myrow);
                        if ($is_in_tinymce && !$compatiblePlugin) { // use Access/DL URL for non-modable tinymce plugins
                            $vObj->setPlayURL($vObj->getAccessURL());
                        }
                        $link_href = MultimediaHelper::chooseMediaAhref($vObj);
                        $link_to_save = $vObj->getAccessURL() . '&amp;attachment';
                        break;
                    case "videolink":
                        $vObj = MediaResourceFactory::initFromVideoLink($myrow);
                        $link_href = MultimediaHelper::chooseMedialinkAhref($vObj);
                        $link_to_save = $vObj->getPath();
                        break;
                    default:
                        exit;
                }
                $row_class = !$myrow->visible ? "class='not_visible'" : "";
                $tool_content .= "<tr $row_class><td class='nocategory-link'>" . $link_href;
                if (!$is_in_tinymce and ( !empty($myrow->creator) or ! empty($myrow->publisher))) {
                    $tool_content .= '<br><small>';
                    if ($myrow->creator == $myrow->publisher) {
                        $tool_content .= "$langcreator: " . q($myrow->creator);
                    } else {
                        $emit = false;
                        if (!empty($myrow->creator)) {
                            $tool_content .= "$langcreator: " . q($myrow->creator);
                            $emit = true;
                        }
                        if (!empty($myrow->publisher)) {
                            $tool_content .= ($emit ? ', ' : '') . "$langpublisher: " . q($myrow->publisher);
                        }
                    }
                    $tool_content .= "</small>";
                }
                $tool_content .= "</td>
                    <td class='text-center'>" . nice_format(date('Y-m-d', strtotime($myrow->date))) . "</td>";
                if (!$is_in_tinymce) {
                    if ($display_tools) {
                        $tool_content .= "<td class='option-btn-cell'>" .
                            action_button(array(
                                array('title' => $langEditChange,
                                     'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;id=$myrow->id&amp;table_edit=$table",
                                     'icon' => 'fa-edit',
                                     'show' => !$is_in_tinymce and $is_editor),
                                array('title' => $myrow->visible ? $langViewHide : $langViewShow,
                                      'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;vid=$myrow->id&amp;table=$table&amp;vis=" .
                                          ($myrow->visible ? '0' : '1'),
                                      'icon' => $myrow->visible ? 'fa-eye-slash' : 'fa-eye'),
                                array('title' => $myrow->public ? $langResourceAccessLock : $langResourceAccessUnlock,
                                      'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;vid=$myrow->id&amp;table=$table&amp;" .
                                         ($myrow->public ? 'limited=1' : 'public=1'),
                                      'icon' => $myrow->public ? 'fa-lock' : 'fa-unlock',
                                      'show' => !$is_in_tinymce and $is_editor and course_status($course_id) == COURSE_OPEN),
                                array('title' => $langDownload,
                                      'url' => $link_to_save,
                                      'icon' => 'fa-download'),
                                array('title' => $langDelete,
                                      'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;id=$myrow->id&amp;delete=yes&amp;table=$table",
                                      'icon' => 'fa-times',
                                      'confirm' => $langConfirmDelete,
                                      'class' => 'delete'))) .
                            "</td>";
                    } else {
                        $tool_content .= "<td class='text-center'>" .
                            ($table == 'video'? icon('fa-download', $langDownload, $link_to_save): '&nbsp;') .
                            '</td>';
                    }
                }
                $tool_content .= "</tr>";
            } // end of check resource access
        } // foreach row
    } // foreach table
}
Example #10
0
/**
 * list documents while inserting them in course unit
 * @global type $id
 * @global type $webDir
 * @global type $course_code
 * @global type $tool_content
 * @global type $group_sql
 * @global type $langDirectory
 * @global type $langUp
 * @global type $langName
 * @global type $langSize
 * @global type $langDate
 * @global type $langType
 * @global type $langAddModulesButton
 * @global type $langChoice
 * @global type $langNoDocuments
 * @global type $course_code 
 */
function list_docs()
{
    global $id, $webDir, $course_code, $tool_content, $group_sql, $langDirectory, $langUp, $langName, $langSize, $langDate, $langType, $langAddModulesButton, $langChoice, $langNoDocuments, $course_code, $langCommonDocs, $pageName;
    $basedir = $webDir . '/courses/' . $course_code . '/document';
    $path = get_dir_path('path');
    $dir_param = get_dir_path('dir');
    $dir_setter = $dir_param ? '&amp;dir=' . $dir_param : '';
    $dir_html = $dir_param ? "<input type='hidden' name='dir' value='{$dir_param}'>" : '';
    if ($id == -1) {
        $common_docs = true;
        $pageName = $langCommonDocs;
        $group_sql = "course_id = -1 AND subsystem = " . COMMON . "";
        $basedir = $webDir . '/courses/commondocs';
        $result = Database::get()->queryArray("SELECT * FROM document\n                                    WHERE {$group_sql} AND\n                                          visible = 1 AND\n                                          path LIKE ?s AND\n                                          path NOT LIKE ?s", "{$path}/%", "{$path}/%/%");
    } else {
        $common_docs = false;
        $result = Database::get()->queryArray("SELECT * FROM document\n                                    WHERE {$group_sql} AND\n                                          path LIKE ?s AND\n                                          path NOT LIKE ?s", "{$path}/%", "{$path}/%/%");
    }
    $fileinfo = array();
    $urlbase = $_SERVER['SCRIPT_NAME'] . "?course={$course_code}{$dir_setter}&amp;type=doc&amp;id={$id}&amp;path=";
    foreach ($result as $row) {
        $fullpath = $basedir . $row->path;
        if ($row->extra_path) {
            $size = 0;
        } else {
            $size = file_exists($fullpath) ? filesize($fullpath) : 0;
        }
        $fileinfo[] = array('id' => $row->id, 'is_dir' => is_dir($fullpath), 'size' => $size, 'title' => $row->title, 'name' => htmlspecialchars($row->filename), 'format' => $row->format, 'path' => $row->path, 'visible' => $row->visible, 'comment' => $row->comment, 'copyrighted' => $row->copyrighted, 'date' => $row->date_modified, 'object' => MediaResourceFactory::initFromDocument($row));
    }
    if (count($fileinfo) == 0) {
        $tool_content .= "<div class='alert alert-warning'>{$langNoDocuments}</div>";
    } else {
        if (empty($path)) {
            $dirname = '';
            $parenthtml = '';
            $colspan = 5;
        } else {
            $dirname = Database::get()->querySingle("SELECT filename FROM document\n                                                                   WHERE {$group_sql} AND path = ?s", $path);
            $parentpath = dirname($path);
            $dirname = "/" . htmlspecialchars($dirname);
            $parentlink = $urlbase . $parentpath;
            $parenthtml = "<th class='right'><a href='{$parentlink}'>{$langUp}</a> " . icon('fa-upload', $langUp, $parentlink) . "</th>";
            $colspan = 4;
        }
        $tool_content .= "<form action='insert.php?course={$course_code}' method='post'><input type='hidden' name='id' value='{$id}' />" . "<table class='table-default'>" . "<tr>" . "<th colspan='{$colspan}'><div align='left'>{$langDirectory}: {$dirname}</div></th>" . $parenthtml . "</tr>" . "<tr>" . "<th>{$langType}</th>" . "<th><div align='left'>{$langName}</div></th>" . "<th width='100'>{$langSize}</th>" . "<th width='80'>{$langDate}</th>" . "<th width='80'>{$langChoice}</th>" . "</tr>";
        $counter = 0;
        foreach (array(true, false) as $is_dir) {
            foreach ($fileinfo as $entry) {
                if ($entry['is_dir'] != $is_dir) {
                    continue;
                }
                $dir = $entry['path'];
                if ($is_dir) {
                    $image = 'fa-folder-o';
                    $file_url = $urlbase . $dir;
                    $link_text = $entry['name'];
                    $link_href = "<a href='{$file_url}'>{$link_text}</a>";
                } else {
                    $image = choose_image('.' . $entry['format']);
                    $file_url = file_url($entry['path'], $entry['name'], $common_docs ? 'common' : $course_code);
                    $dObj = $entry['object'];
                    $dObj->setAccessURL($file_url);
                    $dObj->setPlayURL(file_playurl($entry['path'], $entry['name'], $common_docs ? 'common' : $course_code));
                    $link_href = MultimediaHelper::chooseMediaAhref($dObj);
                }
                if ($entry['visible'] == 'i') {
                    $vis = 'invisible';
                } else {
                    $vis = '';
                }
                $tool_content .= "<tr class='{$vis}'>";
                $tool_content .= "<td width='1' class='center'>" . icon($image, '') . "</td>";
                $tool_content .= "<td>{$link_href}";
                /* * * comments ** */
                if (!empty($entry['comment'])) {
                    $tool_content .= "<br /><div class='comment'>" . standard_text_escape($entry['comment']) . "</div>";
                }
                $tool_content .= "</td>";
                if ($is_dir) {
                    // skip display of date and time for directories
                    $tool_content .= "<td>&nbsp;</td><td>&nbsp;</td>";
                } else {
                    $size = format_file_size($entry['size']);
                    $date = nice_format($entry['date'], true, true);
                    $tool_content .= "<td class='center'>{$size}</td><td class='center'>{$date}</td>";
                }
                $tool_content .= "<td class='center'><input type='checkbox' name='document[]' value='{$entry['id']}' /></td>";
                $tool_content .= "</tr>";
                $counter++;
            }
        }
        $tool_content .= "<tr><th colspan={$colspan}><div align='right'>";
        $tool_content .= "<input class='btn btn-primary' type='submit' name='submit_doc' value='{$langAddModulesButton}' /></div></th>";
        $tool_content .= "</tr></table>{$dir_html}</form>";
    }
}
Example #11
0
        $updated = false;
    }
    $fileinfo[] = array(
        'is_dir' => $is_dir,
        'size' => $size,
        'title' => $row->title,
        'filename' => $row->filename,
        'format' => $row->format,
        'path' => $row->path,
        'extra_path' => $row->extra_path,
        'visible' => ($row->visible == 1),
        'public' => $row->public,
        'comment' => $row->comment,
        'copyrighted' => $row->copyrighted,
        'date' => $row->date_modified,
        'object' => MediaResourceFactory::initFromDocument($row),
        'editable' => $row->editable,
        'updated' => $updated);
}
// end of common to teachers and students
// ----------------------------------------------
// Display
// ----------------------------------------------

$cmdCurDirPath = rawurlencode($curDirPath);
$cmdParentDir = rawurlencode($parentDir);

if ($can_upload) {
    // Action result message
    if (!empty($action_message)) {
        $tool_content .= $action_message;
Example #12
0
/**
 * @brief get user documents newer than one month
 * @global type $langNoDocsExist
 * @param type $param
 * @return string
 */
function getUserDocuments($lesson_id)
{
    global $langNoDocsExist, $group_sql;
    $last_month = strftime('%Y-%m-%d', strtotime('now -1 month'));
    $found = false;
    $doc_content = '<table width="100%">';
    foreach ($lesson_id as $lid) {
        $q = Database::get()->queryArray("SELECT document.path, document.course_id, document.filename,\n                                            document.title, document.date_modified,\n                                            document.format, document.visible,\n                                            document.id\n                                     FROM document, course_module\n                                     WHERE document.course_id = ?d AND                             \n                                            subsystem = " . MAIN . " AND\n                                            document.visible = 1 AND\n                                            date_modified >= '{$last_month}' AND\n                                            format <> '.dir' AND\n                                            course_module.module_id = " . MODULE_ID_DOCS . " AND\n                                            course_module.visible = 1 AND\n                                            course_module.course_id = ?d\n                                    ORDER BY date_modified DESC", $lid, $lid);
        if ($q) {
            $found = true;
            $doc_content .= "<tr><td class='sub_title1'>" . q(ellipsize(course_id_to_title($lid), 70)) . "</td></tr>";
            foreach ($q as $course_file) {
                $group_sql = "course_id = " . $lid . " AND subsystem = " . MAIN;
                $url = file_url($course_file->path, $course_file->filename, course_id_to_code($lid));
                $dObj = MediaResourceFactory::initFromDocument($course_file);
                $dObj->setAccessURL($url);
                $dObj->setPlayURL(file_playurl($course_file->path, $course_file->filename, course_id_to_code($lid)));
                $href = MultimediaHelper::chooseMediaAhref($dObj);
                $doc_content .= "<tr><td class='smaller'><ul class='custom_list'><li>" . $href . ' - (' . nice_format(date('Y-m-d', strtotime($course_file->date_modified))) . ")</li></ul></td></tr>";
            }
        }
    }
    $doc_content .= "</table>";
    if ($found) {
        return $doc_content;
    } else {
        return "<div class='alert alert-warning'>{$langNoDocsExist}</div>";
    }
}
Example #13
0
/**
 * @brief display links of category (if category is defined) else display all
 * @global type $is_in_tinymce
 * @global type $themeimg
 * @global type $tool_content
 * @global type $is_editor
 * @global type $course_id
 * @global type $course_code
 * @global type $langDelete
 * @global type $langVisible
 * @global type $langPreview
 * @global type $langSave
 * @global type $langResourceAccess
 * @global type $langResourceAccess
 * @global type $langModify
 * @global type $langConfirmDelete
 * @global type $filterv
 * @global type $filterl
 * @param type $cat_id
 */
function showlinksofcategory($cat_id = 0)
{
    global $course_id, $is_in_tinymce, $themeimg, $tool_content, $is_editor, $course_code;
    global $langDelete, $langVisible, $langConfirmDelete;
    global $langPreview, $langSave, $langResourceAccess, $langResourceAccess, $langModify;
    global $filterv, $filterl, $compatiblePlugin, $langcreator, $langpublisher;
    if ($is_editor) {
        $vis_q = '';
    } else {
        $vis_q = "AND visible = 1";
    }
    if ($cat_id > 0) {
        $results['video'] = Database::get()->queryArray("SELECT * FROM video {$filterv} AND course_id = ?d AND category = ?d {$vis_q} ORDER BY title", $course_id, $cat_id);
        $results['videolink'] = Database::get()->queryArray("SELECT * FROM videolink {$filterl} AND course_id = ?d AND category = ?d {$vis_q} ORDER BY title", $course_id, $cat_id);
    } else {
        $results['video'] = Database::get()->queryArray("SELECT * FROM video {$filterv} AND course_id = ?d AND (category IS NULL OR category = 0) {$vis_q} ORDER BY title", $course_id);
        $results['videolink'] = Database::get()->queryArray("SELECT * FROM videolink {$filterl} AND course_id = ?d AND (category IS NULL OR category = 0) {$vis_q} ORDER BY title", $course_id);
    }
    $i = 0;
    foreach ($results as $table => $result) {
        foreach ($result as $myrow) {
            $myrow->course_id = $course_id;
            if (resource_access($myrow->visible, $myrow->public) || $is_editor) {
                switch ($table) {
                    case 'video':
                        $vObj = MediaResourceFactory::initFromVideo($myrow);
                        if ($is_in_tinymce && !$compatiblePlugin) {
                            // use Access/DL URL for non-modable tinymce plugins
                            $vObj->setPlayURL($vObj->getAccessURL());
                        }
                        $link_href = MultimediaHelper::chooseMediaAhref($vObj);
                        $link_to_save = $vObj->getAccessURL();
                        break;
                    case "videolink":
                        $vObj = MediaResourceFactory::initFromVideoLink($myrow);
                        $link_href = MultimediaHelper::chooseMedialinkAhref($vObj);
                        $link_to_save = $vObj->getPath();
                        break;
                    default:
                        exit;
                }
                $row_class = !$myrow->visible ? "class='not_visible'" : "";
                $tool_content .= "<tr {$row_class}><td>" . $link_href;
                if (!$is_in_tinymce and (!empty($myrow->creator) or !empty($myrow->publisher))) {
                    $tool_content .= '<br><small>';
                    if ($myrow->creator == $myrow->publisher) {
                        $tool_content .= "{$langcreator}: " . q($myrow->creator);
                    } else {
                        $emit = false;
                        if (!empty($myrow->creator)) {
                            $tool_content .= "{$langcreator}: " . q($myrow->creator);
                            $emit = true;
                        }
                        if (!empty($myrow->publisher)) {
                            $tool_content .= ($emit ? ', ' : '') . "{$langpublisher}: " . q($myrow->publisher);
                        }
                    }
                    $tool_content .= '</small>';
                }
                $tool_content .= "</td><td class='text-center'>" . nice_format(date('Y-m-d', strtotime($myrow->date))) . "</td><td class='option-btn-cell'>" . action_button(array(array('title' => $langDelete, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;id={$myrow->id}&amp;delete=yes&amp;table={$table}", 'icon' => 'fa-times', 'confirm' => $langConfirmDelete, 'class' => 'delete'), array('title' => $langSave, 'url' => $link_to_save, 'icon' => 'fa-floppy-o'), array('title' => $langModify, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;id={$myrow->id}&amp;table_edit={$table}", 'icon' => 'fa-edit', 'show' => !$is_in_tinymce and $is_editor), array('title' => $langVisible, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;vid={$myrow->id}&amp;table={$table}&amp;vis=" . ($myrow->visible ? '0' : '1'), 'icon' => $myrow->visible ? 'fa-eye-slash' : 'fa-eye'), array('title' => $langResourceAccess, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;vid={$myrow->id}&amp;table={$table}&amp;" . ($myrow->public ? 'limited=1' : 'public=1'), 'icon' => $myrow->public ? 'fa-unlock' : 'fa-lock', 'show' => !$is_in_tinymce and $is_editor and course_status($course_id) == COURSE_OPEN))) . "</td></tr>";
            }
            // end of check resource access
        }
        // foreach row
    }
    // foreach table
}