aboutsummaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2009-03-21 18:12:50 +0000
committerCash Costello <cash.costello@gmail.com>2009-03-21 18:12:50 +0000
commit7acd3a2947f7bd92ded5bc5f02baa5db87f6b212 (patch)
tree7c1a8394f0aa6b1f1b384b445702329c55db8818 /actions
parent26be16aaf2189a4b50b06494aab6c6690480a371 (diff)
downloadelgg-7acd3a2947f7bd92ded5bc5f02baa5db87f6b212.tar.gz
elgg-7acd3a2947f7bd92ded5bc5f02baa5db87f6b212.tar.bz2
cleaned up actions - formatting
Diffstat (limited to 'actions')
-rw-r--r--actions/addalbum.php100
-rw-r--r--actions/delete.php6
-rw-r--r--actions/download.php7
-rw-r--r--actions/edit_multi.php58
-rw-r--r--actions/editalbum.php108
-rw-r--r--actions/icon.php13
-rw-r--r--actions/upload.php33
7 files changed, 156 insertions, 169 deletions
diff --git a/actions/addalbum.php b/actions/addalbum.php
index 127885270..f2d423abd 100644
--- a/actions/addalbum.php
+++ b/actions/addalbum.php
@@ -1,72 +1,66 @@
<?php
/**
- * Elgg blog: add post action
+ * Tidypics Add New Album Action
*
- * @package ElggBlog
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider Ltd <info@elgg.com>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.org/
*/
// Make sure we're logged in (send us to the front page if not)
- if (!isloggedin()) forward();
+ if (!isloggedin()) forward();
// Get input data
- $title = get_input('albumtitle');
- $body = get_input('albumbody');
- $tags = get_input('albumtags');
- $access = get_input('access_id');
- $container_guid = get_input('container_guid', $_SESSION['user']->getGUID());
- $back_url = 'pg/photos/new/' . get_entity($container_guid)->username;
+ $title = get_input('albumtitle');
+ $body = get_input('albumbody');
+ $tags = get_input('albumtags');
+ $access = get_input('access_id');
+ $container_guid = get_input('container_guid', $_SESSION['user']->getGUID());
+ $back_url = 'pg/photos/new/' . get_entity($container_guid)->username;
// Cache to the session
- $_SESSION['albumtitle'] = $title;
- $_SESSION['albumbody'] = $body;
- $_SESSION['albumtags'] = $tags;
+ $_SESSION['albumtitle'] = $title;
+ $_SESSION['albumbody'] = $body;
+ $_SESSION['albumtags'] = $tags;
// Convert string of tags into a preformatted array
- $tagarray = string_to_tag_array($tags);
+ $tagarray = string_to_tag_array($tags);
// Make sure the title / description aren't blank
- if (empty($title) || empty($body)) {
- register_error(elgg_echo("album:blank"));
- forward(get_input('forward_url', $_SERVER['HTTP_REFERER'])); //failed, so forward to previous page
+ if (empty($title) || empty($body)) {
+ register_error(elgg_echo("album:blank"));
+ forward(get_input('forward_url', $_SERVER['HTTP_REFERER'])); //failed, so forward to previous page
- // Otherwise, save the blog post
- } else {
+ // Otherwise, save the album
+ } else {
- // Initialise a new ElggObject
- $album = new ElggObject();
- // Tell the system it's an album
- $album->subtype = "album";
+ // Initialise a new ElggObject
+ $album = new ElggObject();
+ // Tell the system it's an album
+ $album->subtype = "album";
- // Set its owner to the current user
- $album->container_guid = $container_guid;
- $album->owner_guid = $_SESSION['user']->getGUID();
- // For now, set its access to public (we'll add an access dropdown shortly)
- $album->access_id = $access;
- // Set its title and description appropriately
- $album->title = $title;
- $album->description = $body;
- // Before we can set metadata, we need to save the blog post
- if (!$album->save()) {
- register_error(elgg_echo("album:error"));
- forward(get_input('forward_url', $_SERVER['HTTP_REFERER'])); //failed, so forward to previous page
- }
- // Now let's add tags. We can pass an array directly to the object property! Easy.
- if (is_array($tagarray)) {
- $album->tags = $tagarray;
- }
- // Success message
- system_message(elgg_echo("album:created"));
- // Remove the blog post cache
- unset($_SESSION['albumtitle']);
- unset($_SESSION['albumbody']);
- unset($_SESSION['albumtags']);
- // Forward to the main blog page
-
- forward("pg/photos/upload/" . $album->guid);
-
+ // Set its owner to the current user
+ $album->container_guid = $container_guid;
+ $album->owner_guid = $_SESSION['user']->getGUID();
+ // For now, set its access to public (we'll add an access dropdown shortly)
+ $album->access_id = $access;
+ // Set its title and description appropriately
+ $album->title = $title;
+ $album->description = $body;
+ // Before we can set metadata, we need to save the blog post
+ if (!$album->save()) {
+ register_error(elgg_echo("album:error"));
+ forward(get_input('forward_url', $_SERVER['HTTP_REFERER'])); //failed, so forward to previous page
}
+ // Now let's add tags. We can pass an array directly to the object property! Easy.
+ if (is_array($tagarray)) {
+ $album->tags = $tagarray;
+ }
+ // Success message
+ system_message(elgg_echo("album:created"));
+ // Remove the album post cache
+ unset($_SESSION['albumtitle']);
+ unset($_SESSION['albumbody']);
+ unset($_SESSION['albumtags']);
+
+ forward("pg/photos/upload/" . $album->guid);
+ }
+
?> \ No newline at end of file
diff --git a/actions/delete.php b/actions/delete.php
index 6b8789fb4..e142e9660 100644
--- a/actions/delete.php
+++ b/actions/delete.php
@@ -1,12 +1,8 @@
<?php
/**
- * Elgg file delete
+ * Tidypics Delete Action
*
- * @package ElggFile
- * @author Curverider Ltd
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
*/
//if not logged in, see world pictures instead
diff --git a/actions/download.php b/actions/download.php
index 31f21f0f5..fd23a21a7 100644
--- a/actions/download.php
+++ b/actions/download.php
@@ -1,13 +1,10 @@
<?php
/**
- * Elgg file browser download action.
+ * Tidypics Download File Action
*
- * @author Curverider Ltd
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
*/
- global $CONFIG;
+ global $CONFIG;
$file_guid = (int) get_input("file_guid");
$file = get_entity($file_guid);
diff --git a/actions/edit_multi.php b/actions/edit_multi.php
index 9bb9c4eed..a857e92d7 100644
--- a/actions/edit_multi.php
+++ b/actions/edit_multi.php
@@ -1,62 +1,62 @@
<?php
/**
- * Elgg album: multi image edit action
+ * Elgg album: multi image edit action
*
*/
// Make sure we're logged in (send us to the front page if not)
- if (!isloggedin()) forward();
+ if (!isloggedin()) forward();
// Get input data
- $cover = get_input('cover');
- $title_array = get_input('title');
- $caption_array = get_input('caption');
- $tags_array = get_input('tags');
- $image_guid_array = get_input('image_guid');
- $container_guid = get_input('container_guid');
- $album_entity = get_entity($container_guid);
- $not_updated = array();
+ $cover = get_input('cover');
+ $title_array = get_input('title');
+ $caption_array = get_input('caption');
+ $tags_array = get_input('tags');
+ $image_guid_array = get_input('image_guid');
+ $container_guid = get_input('container_guid');
+ $album_entity = get_entity($container_guid);
+ $not_updated = array();
- foreach($image_guid_array as $key => $im){
+ foreach($image_guid_array as $key => $im) {
$image = get_entity($im);
- if ($image->canEdit()){
+ if ($image->canEdit()) {
- // Convert string of tags into a preformatted array
+ // Convert string of tags into a preformatted array
$tagarray = string_to_tag_array($tags_array[$key]);
- //set description appropriately
+ //set description appropriately
$image->title = $title_array[$key];
- //set description appropriately
+ //set description appropriately
$image->description = $caption_array[$key];
- // Before we can set metadata, we need to save the image
+ // Before we can set metadata, we need to save the image
if (!$image->save()) {
array_push($not_updated, $image->guid);
}
- // Now let's add tags. We can pass an array directly to the object property! Easy.
+ // Now let's add tags. We can pass an array directly to the object property! Easy.
$image->clearMetadata('tags');
if (is_array($tagarray)) {
$image->tags = $tagarray;
}
- //if cover meta is sent from image save as metadata
- if($cover == $im){
+ //if cover meta is sent from image save as metadata
+ if ($cover == $im) {
$album_entity->cover = $im;
}
}
- }
- // Success message
- if (count($not_updated) > 0) {
- register_error(elgg_echo("images:notedited"));
- } else {
- system_message(elgg_echo("images:edited"));
- }
+ }
+
+ // Success message
+ if (count($not_updated) > 0) {
+ register_error(elgg_echo("images:notedited"));
+ } else {
+ system_message(elgg_echo("images:edited"));
+ }
- // Forward to the main album page
- forward($album_entity->getURL());
-
+ // Forward to the main album page
+ forward($album_entity->getURL());
?> \ No newline at end of file
diff --git a/actions/editalbum.php b/actions/editalbum.php
index 36b0f7379..78b1f1653 100644
--- a/actions/editalbum.php
+++ b/actions/editalbum.php
@@ -1,91 +1,85 @@
<?php
/**
- * Elgg album: edit album action
+ * Tidypics edit album action
*
- * @package ElggBlog
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider Ltd <info@elgg.com>
- * @copyright Curverider Ltd 2008
- * @link http://elgg.org/
*/
// Make sure we're logged in (send us to the front page if not)
- if (!isloggedin()) forward();
+ if (!isloggedin()) forward();
// Get input data
- $guid = (int) get_input('albumpost');
- $title = get_input('albumtitle');
- $body = get_input('albumbody');
- $access = get_input('access_id');
- $tags = get_input('albumtags');
- $back_url = 'mod/tidypics/edit.php?file_guid=' . $guid;
+ $guid = (int) get_input('albumpost');
+ $title = get_input('albumtitle');
+ $body = get_input('albumbody');
+ $access = get_input('access_id');
+ $tags = get_input('albumtags');
+ $back_url = 'mod/tidypics/edit.php?file_guid=' . $guid;
// Make sure we actually have permission to edit
- $album = get_entity($guid);
- if ($album->canEdit())
- {
+ $album = get_entity($guid);
+ if ($album->canEdit())
+ {
- // Cache to the session
- $_SESSION['albumtitle'] = $title;
- $_SESSION['albumbody'] = $body;
- $_SESSION['albumtags'] = $tags;
+ // Cache to the session
+ $_SESSION['albumtitle'] = $title;
+ $_SESSION['albumbody'] = $body;
+ $_SESSION['albumtags'] = $tags;
- // Convert string of tags into a preformatted array
- $tagarray = string_to_tag_array($tags);
+ // Convert string of tags into a preformatted array
+ $tagarray = string_to_tag_array($tags);
- // Get owning user
- $owner = get_entity($album->getOwner());
+ // Get owning user
+ $owner = get_entity($album->getOwner());
- // edit access only if access is different from current
-
- if($album->access_id != $access)
- {
- $album->access_id = $access;
+ // edit access only if access is different from current
+ if ($album->access_id != $access)
+ {
+ $album->access_id = $access;
- //get images from album and update access on image entities
- $images = get_entities("object","image", $guid, '', 999, '', false);
- foreach($images as $im){
- $im->access_id = $access;
- $im->save();
- //new core updates all metadata access as well!
- }
+ //get images from album and update access on image entities
+ $images = get_entities("object","image", $guid, '', 999, '', false);
+ foreach ($images as $im) {
+ $im->access_id = $access;
+ $im->save();
+ //new core updates all metadata access as well!
}
+ }
// Set its title and description appropriately
- $album->title = $title;
- $album->description = $body;
+ $album->title = $title;
+ $album->description = $body;
// Before we can set metadata, we need to save the image
- if (!$album->save()) {
- register_error(elgg_echo("album:error"));
- $album->delete();
- forward(get_input('forward_url', $_SERVER['HTTP_REFERER'])); //failed, so forward to previous page
- }
+ if (!$album->save()) {
+ register_error(elgg_echo("album:error"));
+ $album->delete();
+ forward(get_input('forward_url', $_SERVER['HTTP_REFERER'])); //failed, so forward to previous page
+ }
// Now let's add tags. We can pass an array directly to the object property! Easy.
- $album->clearMetadata('tags');
- if (is_array($tagarray)) {
- $album->tags = $tagarray;
- }
+ $album->clearMetadata('tags');
+ if (is_array($tagarray)) {
+ $album->tags = $tagarray;
+ }
//if cover meta is sent from image save as metadata
- if(get_input('cover') == elgg_echo('album:cover:yes')){
- $container = get_entity($album->container_guid);
- $container->cover = $album->guid;
- }
+ if (get_input('cover') == elgg_echo('album:cover:yes')) {
+ $container = get_entity($album->container_guid);
+ $container->cover = $album->guid;
+ }
// Success message
- system_message(elgg_echo("album:edited"));
+ system_message(elgg_echo("album:edited"));
// Remove the image cache
- unset($_SESSION['albumtitle']);
- unset($_SESSION['albumbody']);
- unset($_SESSION['albumtags']);
+ unset($_SESSION['albumtitle']);
+ unset($_SESSION['albumbody']);
+ unset($_SESSION['albumtags']);
// Forward to the main blog page
- forward($album->getURL());
+ forward($album->getURL());
- }
+ }
?> \ No newline at end of file
diff --git a/actions/icon.php b/actions/icon.php
index 718425819..bfc18198a 100644
--- a/actions/icon.php
+++ b/actions/icon.php
@@ -1,18 +1,13 @@
<?php
/**
- * Elgg tidypics icon action
+ * tidypics icon action
*
- * @package ElggFile
- * @author Curverider Ltd
- * @copyright Curverider Ltd 2008
- * @link http://elgg.com/
*/
$file_guid = get_input("file_guid");
$file = get_entity($file_guid);
- if ($file)
- {
+ if ($file) {
$filename = $file->thumbnail;
$mime = $file->mimetype;
@@ -35,7 +30,7 @@
echo $contents;
exit;
- }
- else
+ } else {
register_error(elgg_echo("file:downloadfailed"));
+ }
?> \ No newline at end of file
diff --git a/actions/upload.php b/actions/upload.php
index f969f6f40..896cce8e7 100644
--- a/actions/upload.php
+++ b/actions/upload.php
@@ -17,12 +17,12 @@
$uploaded_images = array();
foreach($_FILES as $key => $sent_file) {
- if(!empty($sent_file['name'])) {
+ if (!empty($sent_file['name'])) {
$name = $_FILES[$key]['name'];
$mime = $_FILES[$key]['type'];
- //make sure file is an image
- if($mime == 'image/jpeg' || $mime == 'image/gif' || $mime == 'image/png' || $mime == 'image/pjpeg') {
+ //make sure file is an image
+ if ($mime == 'image/jpeg' || $mime == 'image/gif' || $mime == 'image/png' || $mime == 'image/pjpeg') {
//this will save to users folder in /image/ and organize by photo album
$prefix = "image/" . $container_guid . "/";
$file = new ElggFile();
@@ -52,18 +52,27 @@
$maxfilesize = 10240; //if the file size limit is not set, default to 10MB
}
$maxfilesize = 1024 * $maxfilesize; //convert to bytes
-
+
//check file size and remove picture if it exceeds the maximum
if (filesize($file->getFilenameOnFilestore())<= $maxfilesize) {
array_push($uploaded_images, $file->guid);
-
+
// Generate thumbnail
//TODO: REMOVE THE BELOW IF STATEMENT ONCE get_resized_image_from_existing_file() ACCEPTS IMAGES OVER 0.9MB IN SIZE
if (filesize($file->getFilenameOnFilestore())<= 943718) { //create thumbnails if file size < 0.9MB
- try {$thumblarge = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),600,600, false); } catch (Exception $e) { $thumblarge = false; }
- try {$thumbsmall = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),153,153, true); } catch (Exception $e) { $thumbsmall = false; }
- try {$thumbnail = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),60,60, true); } catch (Exception $e) { $thumbnail = false; }
+ try {
+ $thumblarge = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),600,600, false);
+ } catch (Exception $e) { $thumblarge = false; }
+
+ try {
+ $thumbsmall = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),153,153, true);
+ } catch (Exception $e) { $thumbsmall = false; }
+
+ try {
+ $thumbnail = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),60,60, true);
+ } catch (Exception $e) { $thumbnail = false; }
}
+
if ($thumbnail) {
$thumb = new ElggFile();
$thumb->setMimeType($mime);
@@ -76,6 +85,7 @@
}
$thumb->close();
}
+
if ($thumbsmall) {
$thumb = new ElggFile();
$thumb->setMimeType($mime);
@@ -88,6 +98,7 @@
}
$thumb->close();
}
+
if ($thumblarge) {
$thumb = new ElggFile();
$thumb->setMimeType($mime);
@@ -107,11 +118,11 @@
} else { //file was not saved for some unknown reason
array_push($not_uploaded, $name);
} //end of file saved check and thumbnail creation
- } else { // file is not a supported image type
+ } else { // file is not a supported image type
array_push($not_uploaded, $name);
- } //end of mimetype block
+ } //end of mimetype block
} //end of file name empty check
- } //end of loop
+ } //end of for loop
if (count($not_uploaded) == 0) {
system_message(elgg_echo("images:saved"));