aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mod/blog/lib/blog.php2
-rw-r--r--mod/file/download.php46
-rw-r--r--mod/file/index.php54
-rw-r--r--mod/file/start.php9
-rw-r--r--mod/file/thumbnail.php82
-rw-r--r--mod/file/upload.php6
-rw-r--r--mod/file/views/default/file/groupprofile_files.php2
7 files changed, 113 insertions, 88 deletions
diff --git a/mod/blog/lib/blog.php b/mod/blog/lib/blog.php
index 354bf561d..c0b24f92e 100644
--- a/mod/blog/lib/blog.php
+++ b/mod/blog/lib/blog.php
@@ -82,7 +82,7 @@ function blog_get_page_content_list($container_guid = NULL) {
if ($container_guid == $loggedin_userid) {
$return['filter_context'] = 'mine';
- } else{
+ } else {
// do not show button or select a tab when viewing someone else's posts
$return['filter_context'] = 'none';
$return['buttons'] = '';
diff --git a/mod/file/download.php b/mod/file/download.php
index d7625901e..a386d490f 100644
--- a/mod/file/download.php
+++ b/mod/file/download.php
@@ -11,32 +11,30 @@ $file_guid = get_input("file_guid");
// Get the file
$file = get_entity($file_guid);
+if (!$file) {
+ register_error(elgg_echo("file:downloadfailed"));
+ forward();
+}
-if ($file) {
- $mime = $file->getMimeType();
- if (!$mime) {
- $mime = "application/octet-stream";
- }
-
- $filename = $file->originalfilename;
+$mime = $file->getMimeType();
+if (!$mime) {
+ $mime = "application/octet-stream";
+}
- // fix for IE https issue
- header("Pragma: public");
+$filename = $file->originalfilename;
- header("Content-type: $mime");
- if (strpos($mime, "image/") !== false) {
- header("Content-Disposition: inline; filename=\"$filename\"");
- } else {
- header("Content-Disposition: attachment; filename=\"$filename\"");
- }
+// fix for IE https issue
+header("Pragma: public");
- $contents = $file->grabFile();
- $splitString = str_split($contents, 8192);
- foreach ($splitString as $chunk) {
- echo $chunk;
- }
- exit;
+header("Content-type: $mime");
+if (strpos($mime, "image/") !== false) {
+ header("Content-Disposition: inline; filename=\"$filename\"");
} else {
- register_error(elgg_echo("file:downloadfailed"));
- forward();
-} \ No newline at end of file
+ header("Content-Disposition: attachment; filename=\"$filename\"");
+}
+
+$contents = $file->grabFile();
+$splitString = str_split($contents, 8192);
+foreach ($splitString as $chunk) {
+ echo $chunk;
+}
diff --git a/mod/file/index.php b/mod/file/index.php
index 3706f65b3..bdda62786 100644
--- a/mod/file/index.php
+++ b/mod/file/index.php
@@ -5,6 +5,8 @@
* @package ElggFile
*/
+elgg_set_page_owner_guid(get_input('guid'));
+
// access check for closed groups
group_gatekeeper();
@@ -13,21 +15,44 @@ $owner = elgg_get_page_owner();
elgg_push_breadcrumb(elgg_echo('file'), "pg/file/all/");
elgg_push_breadcrumb($owner->name);
+$params = array();
-//set the title
-if (elgg_get_page_owner_guid() == get_loggedin_userid()) {
+if ($owner->guid == get_loggedin_userid()) {
+ // user looking at own files
$title = elgg_echo('file:yours');
- $area1 = elgg_view('page/elements/content_header', array('context' => "mine", 'type' => 'file'));
+ $params['filter_context'] = 'mine';
+} else if (elgg_instanceof($owner, 'user')) {
+ // someone else's files
+ $title = elgg_echo("file:user", array($owner()->name));
+ // do not show button or select a tab when viewing someone else's posts
+ $params['filter_context'] = 'none';
+ $params['buttons'] = '';
} else {
- $title = elgg_echo("file:user",array(elgg_get_page_owner()->name));
- $area1 = elgg_view('page/elements/content_header', array('context' => "friends", 'type' => 'file'));
+ // group files
+ $title = elgg_echo("file:user", array($owner->name));
+ $params['filter'] = '';
+ if ($owner->isMember(get_loggedin_user())) {
+ $url = "pg/file/new/$owner->guid";
+ $vars = array(
+ 'href' => $url,
+ 'text' => elgg_echo("file:new"),
+ 'class' => 'elgg-action-button',
+ );
+ $button = elgg_view('output/url', $vars);
+ $params['buttons'] = $button;
+ } else {
+ $params['buttons'] = '';
+ }
}
// Get objects
-elgg_push_context('search');
-$offset = (int)get_input('offset', 0);
-$content = elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'container_guid' => elgg_get_page_owner_guid(), 'limit' => 10, 'offset' => $offset, 'full_view' => FALSE));
-elgg_pop_context();
+$content = elgg_list_entities(array(
+ 'types' => 'object',
+ 'subtypes' => 'file',
+ 'container_guid' => $owner->guid,
+ 'limit' => 10,
+ 'full_view' => FALSE,
+));
$get_filter = get_filetype_cloud(elgg_get_page_owner_guid());
if ($get_filter) {
@@ -40,10 +65,9 @@ if ($get_filter) {
$comments = get_annotations(0, "object", "file", "generic_comment", "", 0, 4, 0, "desc",0,0,elgg_get_page_owner_guid());
$area3 = elgg_view('comments/latest', array('comments' => $comments));
-$body = elgg_view_layout('content', array(
- 'filter_context' => 'mine',
- 'content' => $content,
- 'title' => $title,
-));
+$params['content'] = $content;
+$params['title'] = $title;
+
+$body = elgg_view_layout('content', $params);
-echo elgg_view_page($title, $body); \ No newline at end of file
+echo elgg_view_page($title, $body);
diff --git a/mod/file/start.php b/mod/file/start.php
index ff0dcbc48..d58940f40 100644
--- a/mod/file/start.php
+++ b/mod/file/start.php
@@ -59,7 +59,7 @@ function file_init() {
* Friends' files: pg/file/friends/<username>
* View file: pg/file/view/<guid>/<title>
* New file: pg/file/new/<guid>
- * Edit file: pg/file/edit/<guid>/<revision>
+ * Edit file: pg/file/edit/<guid>
* Group files: pg/file/group/<guid>/owner
*
* Title is ignored
@@ -78,7 +78,8 @@ function file_page_handler($page) {
$page_type = $page[0];
switch ($page_type) {
case 'owner':
- set_input('username', $page[1]);
+ $owner = get_user_by_username($page[1]);
+ set_input('guid', $owner->guid);
include "$file_dir/index.php";
break;
case 'friends':
@@ -98,6 +99,8 @@ function file_page_handler($page) {
include "$file_dir/edit.php";
break;
case 'group':
+ set_input('guid', $page[1]);
+ include "$file_dir/index.php";
break;
case 'all':
default:
@@ -150,7 +153,7 @@ function file_owner_block_menu($hook, $type, $return, $params) {
$return[] = $item;
} else {
if ($params['entity']->file_enable != "no") {
- $url = "pg/file/owner/{$params['entity']->username}";
+ $url = "pg/file/group/{$params['entity']->guid}/owner";
$item = new ElggMenuItem('file', elgg_echo('file:group'), $url);
$return[] = $item;
}
diff --git a/mod/file/thumbnail.php b/mod/file/thumbnail.php
index 4da560a6c..35bf8c7f7 100644
--- a/mod/file/thumbnail.php
+++ b/mod/file/thumbnail.php
@@ -14,50 +14,44 @@ $file_guid = (int) get_input('file_guid', 0);
// Get file thumbnail size
$size = get_input('size', 'small');
-// Get file entity
-if ($file = get_entity($file_guid)) {
-
- if ($file->getSubtype() == "file") {
-
- $simpletype = $file->simpletype;
- if ($simpletype == "image") {
-
- // Get file thumbnail
- switch ($size) {
- case "small":
- $thumbfile = $file->thumbnail;
- break;
- case "medium":
- $thumbfile = $file->smallthumb;
- break;
- case "large":
- default:
- $thumbfile = $file->largethumb;
- break;
- }
-
- // Grab the file
- if ($thumbfile && !empty($thumbfile)) {
- $readfile = new ElggFile();
- $readfile->owner_guid = $file->owner_guid;
- $readfile->setFilename($thumbfile);
- $mime = $file->getMimeType();
- $contents = $readfile->grabFile();
-
- // caching images for 10 days
- header("Content-type: $mime");
- header('Expires: ' . date('r',time() + 864000));
- header("Pragma: public", true);
- header("Cache-Control: public", true);
- header("Content-Length: " . strlen($contents));
-
- echo $contents;
- exit;
-
- }
-
- }
+$file = get_entity($file_guid);
+if (!$file || $file->getSubtype() != "file") {
+ exit;
+}
+
+$simpletype = $file->simpletype;
+if ($simpletype == "image") {
+
+ // Get file thumbnail
+ switch ($size) {
+ case "small":
+ $thumbfile = $file->thumbnail;
+ break;
+ case "medium":
+ $thumbfile = $file->smallthumb;
+ break;
+ case "large":
+ default:
+ $thumbfile = $file->largethumb;
+ break;
+ }
+
+ // Grab the file
+ if ($thumbfile && !empty($thumbfile)) {
+ $readfile = new ElggFile();
+ $readfile->owner_guid = $file->owner_guid;
+ $readfile->setFilename($thumbfile);
+ $mime = $file->getMimeType();
+ $contents = $readfile->grabFile();
+
+ // caching images for 10 days
+ header("Content-type: $mime");
+ header('Expires: ' . date('r',time() + 864000));
+ header("Pragma: public", true);
+ header("Cache-Control: public", true);
+ header("Content-Length: " . strlen($contents));
+ echo $contents;
+ exit;
}
-
}
diff --git a/mod/file/upload.php b/mod/file/upload.php
index 0c89e64a5..ef0899f20 100644
--- a/mod/file/upload.php
+++ b/mod/file/upload.php
@@ -6,11 +6,17 @@
*/
elgg_set_page_owner_guid(get_input('guid'));
+$owner = elgg_get_page_owner();
gatekeeper();
group_gatekeeper();
elgg_push_breadcrumb(elgg_echo('file'), "pg/file/all/");
+if (elgg_instanceof($owner, 'user')) {
+ elgg_push_breadcrumb($owner->name, "pg/file/owner/$owner->username");
+} else {
+ elgg_push_breadcrumb($owner->name, "pg/file/group/$owner->guid/owner");
+}
elgg_push_breadcrumb(elgg_echo('file:new'));
$container_guid = elgg_get_page_owner_guid();
diff --git a/mod/file/views/default/file/groupprofile_files.php b/mod/file/views/default/file/groupprofile_files.php
index 4c7321e48..5cbf75bce 100644
--- a/mod/file/views/default/file/groupprofile_files.php
+++ b/mod/file/views/default/file/groupprofile_files.php
@@ -41,7 +41,7 @@
//get a link to the users files
- $users_file_url = elgg_get_site_url() . "pg/file/" . elgg_get_page_owner()->username;
+ $users_file_url = elgg_get_site_url() . "pg/file/group/" . elgg_get_page_owner()->guid;
echo "<p><a href=\"{$users_file_url}\">" . elgg_echo('file:more') . "</a></p>";