Ejemplo n.º 1
0
function file_folder_view($folder)
{
    global $CFG;
    /*
     *    View a specific folder
     *    (Access rights are presumed)
     */
    // Find out who's the owner
    global $page_owner;
    $owner_username = user_info('username', $page_owner);
    // If we're not in the parent folder, provide a link to return to the parent
    /*
    if ($folder->ident != -1) {
        $folder->name = stripslashes($folder->name);
    }
    */
    $body = "<h2>" . $folder->name . "</h2>";
    // Firstly, get a list of folders
    // Display folders we actually have access to
    if ($folder->idents = get_records_select('file_folders', "parent = {$folder->ident} AND (" . run("users:access_level_sql_where") . ") and files_owner = {$page_owner}")) {
        $subFolders = __gettext("Subfolders");
        // gettext variable
        $body .= <<<END

                            <h3>
                                {$subFolders}
                            </h3>

END;
        foreach ($folder->idents as $folder->ident_details) {
            if (run("users:access_level_check", $folder->ident_details->access) == true) {
                $username = $owner_username;
                $ident = (int) $folder->ident_details->ident;
                $name = get_access_description($folder->ident_details->access);
                $name .= stripslashes($folder->ident_details->name);
                $folder->identmenu = file_folder_edit_links($folder->ident_details);
                $keywords = display_output_field(array("", "keywords", "folder", "folder", $ident, $folder->ident_details->owner));
                if ($keywords) {
                    $keywords = __gettext("Keywords: ") . $keywords;
                }
                $body .= templates_draw(array('context' => 'folder', 'username' => $username, 'url' => $CFG->wwwroot . "{$username}/files/{$ident}", 'ident' => $ident, 'name' => $name, 'menu' => $folder->identmenu, 'icon' => $CFG->wwwroot . "mod/file/folder.png", 'keywords' => $keywords));
            }
        }
    }
    // Then get a list of files
    // View files we actually have access to
    if ($files = get_records_select('files', "folder = ? AND files_owner = ?", array($folder->ident, $page_owner))) {
        foreach ($files as $file) {
            if (run("users:access_level_check", $file->access) == true || $file->owner == $_SESSION['userid']) {
                $username = $owner_username;
                $ident = (int) $file->ident;
                $folder->ident = $file->folder;
                $title = get_access_description($file->access);
                $title .= stripslashes($file->title);
                $description = nl2br(stripslashes($file->description));
                $filetitle = urlencode($title);
                $originalname = stripslashes($file->originalname);
                $filemenu = round($file->size / 1048576, 4) . "MB ";
                $icon = $CFG->wwwroot . "_icon/file/" . $file->ident;
                $filepath = $CFG->wwwroot . "{$username}/files/{$folder->ident}/{$ident}/" . urlencode($originalname);
                $mimetype = mimeinfo('type', $file->originalname);
                if ($mimetype == "audio/mpeg" || $mimetype == "audio/mp3") {
                    $filemenu .= " <object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\"\n        codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\"\n        width=\"17\" height=\"17\" >\n            <param name=\"allowScriptAccess\" value=\"sameDomain\" />\n            <param name=\"movie\" value=\"" . $CFG->wwwroot . "mod/file/mp3player/musicplayer.swf?song_url={$filepath}&amp;song_title={$filetitle}\" />\n            <param name=\"quality\" value=\"high\" />\n            <embed src=\"" . $CFG->wwwroot . "mod/file/mp3player/musicplayer.swf?song_url={$filepath}&amp;song_title={$filetitle}\"\n            quality=\"high\" bgcolor=\"#E6E6E6\" name=\"xspf_player\" allowscriptaccess=\"sameDomain\"\n            type=\"application/x-shockwave-flash\"\n            pluginspage=\"http://www.macromedia.com/go/getflashplayer\"\n            align=\"center\" height=\"17\" width=\"17\" />\n        </object>";
                }
                $filemenu = file_edit_links($file);
                $keywords = display_output_field(array("", "keywords", "file", "file", $ident, $file->owner));
                if ($keywords) {
                    $keywords = __gettext("Keywords: ") . $keywords;
                }
                $body .= templates_draw(array('context' => 'file', 'username' => $username, 'title' => $title, 'ident' => $ident, 'folder' => $folder->ident, 'description' => $description, 'originalname' => $originalname, 'url' => $filepath, 'menu' => $filemenu, 'icon' => $icon, 'keywords' => $keywords));
                $body .= display_run_displayobjectannotations($file, "file::file");
            }
        }
    }
    // Deliver an apologetic message if there aren't any files or folders
    if (empty($files) && empty($folder->idents)) {
        $body .= "<p>" . __gettext("This folder is currently empty.") . "</p>";
    }
    return $body;
}
Ejemplo n.º 2
0
            if ($keywords) {
                $keywords = gettext("Keywords: ") . $keywords;
            }
            $body .= templates_draw(array('context' => 'folder', 'username' => $username, 'url' => $CFG->wwwroot . "{$username}/files/{$ident}", 'ident' => $ident, 'name' => $name, 'menu' => $foldermenu, 'icon' => $CFG->wwwroot . "_files/folder.png", 'keywords' => $keywords));
        }
    }
}
// Then get a list of files
// View files we actually have access to
if ($files = get_records_select('files', "folder = ? AND files_owner = ?", array($folder, $page_owner))) {
    foreach ($files as $file) {
        if (run("users:access_level_check", $file->access) == true || $file->owner == $_SESSION['userid']) {
            $username = $owner_username;
            $ident = (int) $file->ident;
            $folder = $file->folder;
            $title = get_access_description($file->access);
            $title .= stripslashes($file->title);
            $description = nl2br(stripslashes($file->description));
            $filetitle = urlencode($title);
            $originalname = stripslashes($file->originalname);
            $filemenu = round($file->size / 1000000, 4) . "Mb ";
            $icon = $CFG->wwwroot . "_files/icon.php?id=" . $file->ident;
            $filepath = $CFG->wwwroot . "{$username}/files/{$folder}/{$ident}/{$originalname}";
            require_once $CFG->dirroot . 'lib/filelib.php';
            $mimetype = mimeinfo('type', $file->originalname);
            if ($mimetype == "audio/mpeg" || $mimetype == "audio/mp3") {
                $filemenu .= "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\"\r\ncodebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\"\r\nwidth=\"400\" height=\"15\" >\r\n    <param name=\"allowScriptAccess\" value=\"sameDomain\" />\r\n    <param name=\"movie\" value=\"" . $CFG->wwwroot . "_files/mp3player/musicplayer.swf?song_url={$filepath}&amp;song_title={$filetitle}\" />\r\n    <param name=\"quality\" value=\"high\" />\r\n    <embed src=\"" . $CFG->wwwroot . "_files/mp3player/musicplayer.swf?song_url={$filepath}&amp;song_title={$filetitle}\"\r\n    quality=\"high\" bgcolor=\"#E6E6E6\" name=\"xspf_player\" allowscriptaccess=\"sameDomain\"\r\n    type=\"application/x-shockwave-flash\"\r\n    pluginspage=\"http://www.macromedia.com/go/getflashplayer\"\r\n    align=\"center\" height=\"17\" width=\"17\"> </embed>\r\n</object>";
            }
            if (run("permissions:check", array("files:edit", $file->owner)) || run("permissions:check", array("files:edit", $file->files_owner))) {
                $areyouSure = gettext("Are you sure you want to permanently delete this file?");
                // gettext variable
Ejemplo n.º 3
0
 if ($specialicon == NULL) {
     $usericon = $post_authors[$post->owner]->icon;
     if ($usericon == "default.png") {
         $usericon = $post_authors[$post->weblog]->icon;
     }
 } else {
     $usericon = $specialicon;
 }
 // Allow plugins to set the name on the post
 $specialname = run("weblogs:posts:getname", $post);
 if (empty($specialname)) {
     $fullname = $post_authors[$post->owner]->fullname;
 } else {
     $fullname = $specialname;
 }
 $title = get_access_description($post->access);
 $title .= htmlspecialchars($post->title, ENT_COMPAT, 'utf-8');
 if ($post->owner != $post->weblog) {
     if ($post_authors[$post->owner]->icon == -1) {
         $usericon = $post_authors[$post->weblog]->icon;
     }
     $fullname .= " @ " . $post_authors[$post->weblog]->fullname;
     $username = run("users:id_to_name", $post->weblog);
 }
 $body = run("weblogs:text:process", $post->body);
 $More = gettext("More");
 $Keywords = gettext("Keywords:");
 $anyComments = gettext("comment(s)");
 $body = str_replace("{{more}}", "<a href=\"" . url . $username . "/weblog/{$post->ident}.html\">{$More} ...</a>", $body);
 $keywords = display_output_field(array("", "keywords", "weblog", "weblog", $post->ident, $post->owner));
 if ($keywords) {
Ejemplo n.º 4
0
                    $returnConfirm = gettext("Are you sure you want to permanently delete this weblog comment?");
                    if ($comment->access != "PUBLIC" && $USER->owner == -1) {
                        $Edit = "[<a href=\"" . $CFG->wwwroot . "_weblog/action_redirection.php?action=weblog_comment_public&amp;weblog_comment_public=" . $comment->ident . "\">" . gettext("Make visible") . "</a>]";
                    }
                    $Delete = "[<a href=\"" . $CFG->wwwroot . "_weblog/action_redirection.php?action=weblog_comment_delete&amp;weblog_comment_delete=" . $comment->ident . "\" onclick=\"return confirm('" . $returnConfirm . "')\">" . gettext("Delete") . "</a>]";
                    $commentmenu = <<<END
\t
\t        <p>
\t                {$Edit} {$Delete}
\t        </p>
END;
                }
                $comment->postedname = htmlspecialchars($comment->postedname, ENT_COMPAT, 'utf-8');
                // turn commentor name into a link if they're a registered user
                // add rel="nofollow" to comment links if they're not
                if ($comment->owner > 0) {
                    $commentownerusername = run("users:id_to_name", $comment->owner);
                    $comment->postedname = '<a href="' . url . $commentownerusername . '/">' . $comment->postedname . '</a>';
                    $comment->icon = '<a href="' . url . $commentownerusername . '/">' . "<img src=\"" . $CFG->wwwroot . $commentownerusername . "/icons/" . run("icons:get", $comment->owner) . "/w/50/h/50/\" border=\"0\" align=\"left\" alt=\"\" /></a>";
                    $comment->body = run("weblogs:text:process", array($comment->body, false));
                } else {
                    $comment->icon = "<img src=\"" . $CFG->wwwroot . "_icons/data/default.png\" width=\"50\" height=\"50\" align=\"left\" alt=\"\" />";
                    $comment->body = run("weblogs:text:process", array($comment->body, true));
                }
                $commentsbody .= templates_draw(array('context' => 'weblogcomment', 'postedname' => $comment->postedname, 'body' => $title = get_access_description($comment->access) . $comment->body . $commentmenu, 'posted' => strftime("%A, %e %B %Y, %R %Z", $comment->posted), 'usericon' => $comment->icon));
            }
        }
        $commentsbody = templates_draw(array('context' => 'weblogcomments', 'comments' => $commentsbody));
    }
    $run_result = $commentsbody;
}