From 1ca3a630454e1ce752d9cb7b5cb2b84318e60ece Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 4 Apr 2009 19:56:26 +0000 Subject: putting tags in the database --- actions/addtag.php | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) (limited to 'actions') 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']); -- cgit v1.2.3