From d66faaf360f2f629fa96dd5e04ff0c6e38eb8213 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 28 Mar 2009 13:03:15 +0000 Subject: changing name of edit action since it works for both images and albums --- actions/edit.php | 85 +++++++++++++++++++++++++++++++++++ actions/editalbum.php | 85 ----------------------------------- start.php | 2 +- views/default/tidypics/forms/edit.php | 2 +- 4 files changed, 87 insertions(+), 87 deletions(-) create mode 100644 actions/edit.php delete mode 100644 actions/editalbum.php diff --git a/actions/edit.php b/actions/edit.php new file mode 100644 index 000000000..78b1f1653 --- /dev/null +++ b/actions/edit.php @@ -0,0 +1,85 @@ +canEdit()) + { + + // 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); + + // 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; + + //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; + + // 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 + } + + // 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; + } + + //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; + } + + // Success message + system_message(elgg_echo("album:edited")); + + // Remove the image cache + unset($_SESSION['albumtitle']); + unset($_SESSION['albumbody']); + unset($_SESSION['albumtags']); + + // Forward to the main blog page + forward($album->getURL()); + + } +?> \ No newline at end of file diff --git a/actions/editalbum.php b/actions/editalbum.php deleted file mode 100644 index 78b1f1653..000000000 --- a/actions/editalbum.php +++ /dev/null @@ -1,85 +0,0 @@ -canEdit()) - { - - // 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); - - // 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; - - //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; - - // 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 - } - - // 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; - } - - //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; - } - - // Success message - system_message(elgg_echo("album:edited")); - - // Remove the image cache - unset($_SESSION['albumtitle']); - unset($_SESSION['albumbody']); - unset($_SESSION['albumtags']); - - // Forward to the main blog page - forward($album->getURL()); - - } -?> \ No newline at end of file diff --git a/start.php b/start.php index 798becce4..f9df12603 100644 --- a/start.php +++ b/start.php @@ -196,7 +196,7 @@ // Register actions register_action("tidypics/upload", false, $CONFIG->pluginspath . "tidypics/actions/upload.php"); register_action("tidypics/addalbum", false, $CONFIG->pluginspath. "tidypics/actions/addalbum.php"); - register_action("tidypics/editalbum", false, $CONFIG->pluginspath. "tidypics/actions/editalbum.php"); + register_action("tidypics/edit", false, $CONFIG->pluginspath. "tidypics/actions/edit.php"); register_action("tidypics/delete", false, $CONFIG->pluginspath. "tidypics/actions/delete.php"); register_action("tidypics/icon", true, $CONFIG->pluginspath. "tidypics/actions/icon.php"); register_action("tidypics/edit_multi", false, $CONFIG->pluginspath. "tidypics/actions/edit_multi.php"); diff --git a/views/default/tidypics/forms/edit.php b/views/default/tidypics/forms/edit.php index 08fe5cc81..d59d029cc 100644 --- a/views/default/tidypics/forms/edit.php +++ b/views/default/tidypics/forms/edit.php @@ -10,7 +10,7 @@ //set stuff if we are editing existing album or image if (isset($vars['entity'])) { $title = sprintf(elgg_echo("album:edit"),$object->title); - $action = "tidypics/editalbum"; + $action = "tidypics/edit"; $title = $vars['entity']->title; $body = $vars['entity']->description; $tags = $vars['entity']->tags; -- cgit v1.2.3