aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2009-04-04 19:56:26 +0000
committerCash Costello <cash.costello@gmail.com>2009-04-04 19:56:26 +0000
commit1ca3a630454e1ce752d9cb7b5cb2b84318e60ece (patch)
treeda0018797748f6d0684bf66c1cbcc38c587d3c75
parenta9ea0333fa16c96377952ac5129a6871455181f8 (diff)
downloadelgg-1ca3a630454e1ce752d9cb7b5cb2b84318e60ece.tar.gz
elgg-1ca3a630454e1ce752d9cb7b5cb2b84318e60ece.tar.bz2
putting tags in the database
-rw-r--r--actions/addtag.php47
-rw-r--r--views/default/object/image.php16
2 files changed, 49 insertions, 14 deletions
diff --git a/actions/addtag.php b/actions/addtag.php
index 8974d9a28..309058e1c 100644
--- a/actions/addtag.php
+++ b/actions/addtag.php
@@ -4,19 +4,54 @@
*
*/
- // Make sure we're logged in (send us to the front page if not)
- if (!isloggedin()) forward();
-
+ gatekeeper();
+ action_gatekeeper();
+
$coordinates_str = get_input('coordinates');
error_log($coordinates_str);
-
+
$user_id = get_input('user_id');
- //$entity_guid = get_input('entity_guid', null);
+ $image_guid = get_input('image_guid');
$word = get_input('word');
-
+
error_log($word);
error_log($user_id);
+ if ($image_guid == 0) {
+ register_error("error");
+ forward($_SERVER['HTTP_REFERER']);
+ }
+
+ $image = get_entity($image_guid);
+ if (!$image)
+ {
+ register_error(elgg_echo("image:phototagging:notexists"));
+ forward($_SERVER['HTTP_REFERER']);
+ }
+
+ if ($user_id != 0) {
+ $relationships_type = 'user';
+ $value = $user_id;
+ } else {
+ $relationships_type = 'word';
+ $value = $word;
+ }
+
+ // test for empty tag
+
+ // create string for javascript tag object
+ $tag->coords = $coordinates_str;
+ $tag->type = $relationships_type;
+ $tag->value = $value;
+
+ $access_id = $image->getAccessID();
+ $owner_id = get_loggedin_userid();
+
+ //Save annotation
+ if ($image->annotate('phototag', serialize($tag), $access_id, $owner_id)) {
+ system_message(elgg_echo("image:tagged"));
+ }
+
forward($_SERVER['HTTP_REFERER']);
diff --git a/views/default/object/image.php b/views/default/object/image.php
index e4cd4d067..af4a46b4b 100644
--- a/views/default/object/image.php
+++ b/views/default/object/image.php
@@ -104,7 +104,7 @@
$viewer = get_loggedin_user();
$friends = get_entities_from_relationship('friend', $viewer->getGUID(), false, 'user', '', 0);
- $content = "<input type='hidden' name='entity_guid' value='{$file_guid}' />";
+ $content = "<input type='hidden' name='image_guid' value='{$file_guid}' />";
$content .= "<input type='hidden' name='coordinates' id='coordinates' value='' />";
$content .= "<input type='hidden' name='user_id' id='user_id' value='' />";
$content .= "<input type='hidden' name='word' id='word' value='' />";
@@ -378,17 +378,17 @@
function addTag()
{
+ // do I need a catch for no tag?
+
$("input#user_id").val(user_id);
$("input#word").val( $("input.input-filter").val() );
- if (coordinates.x1 != 0)
- {
- coord_string = "";
- for (x in coordinates)
- coord_string += x + ':' + coordinates[x] + '/';
+ coord_string = '"x1":"' + coordinates.x1 + '",';
+ coord_string += '"y1":"' + coordinates.y1 + '",';
+ coord_string += '"width":"' + coordinates.width + '",';
+ coord_string += '"height":"' + coordinates.height + '"';
- $("input#coordinates").val(coord_string);
- }
+ $("input#coordinates").val(coord_string);
/*
//Show loading
jQuery("#cont-menu label, #cont-menu input, #cont-menu p, #cont-menu span, #cont-menu button, #cont-menu ul, #cont-menu fieldset").hide();