public static function saveuser($user_id, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description) { //Since we are associating a user we will remove any old annotation of this user on this photo $item_old_users = ORM::factory("items_user")->where("user_id", "=", $user_id)->where("item_id", "=", $item_id)->find_all(); if (count($item_old_users) > 1) { foreach ($item_old_users as $item_old_user) { $item_old_user->delete(); } $item_user = ORM::factory("items_user"); } elseif (count($item_old_users) == 1) { $item_user = ORM::factory("items_user", $item_old_users[0]->id); } else { $item_user = ORM::factory("items_user"); photoannotation::send_notifications($user_id, $item_id, "newtag"); } $item_user->user_id = $user_id; $item_user->item_id = $item_id; $item_user->x1 = $str_x1; $item_user->y1 = $str_y1; $item_user->x2 = $str_x2; $item_user->y2 = $str_y2; $item_user->description = $description; $item_user->save(); return $item_user->id; }
static function comment_updated($comment) { //Check if there are any user annotations on the photo and send notification if applicable $item_users = ORM::factory("items_user")->where("item_id", "=", $comment->item_id)->find_all(); if (count($item_users) > 0) { foreach ($item_users as $item_user) { //Don't send if the commenter is the user to be notified if ($comment->author_id != $item_user->user_id && module::is_active("notification")) { photoannotation::send_notifications($item_user->user_id, $comment->item_id, "updatedcomment"); } } } }