getMessage() . "\n" . $e->getTraceAsString()); } } static function item_created($item) { try { notification::send_item_add($item); } catch (Exception $e) { Kohana_Log::add("error", "@todo notification_event::item_created() failed"); Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString()); } } static function item_deleted($item) { try { notification::send_item_deleted($item); if (notification::is_watching($item)) { notification::remove_watch($item); } } catch (Exception $e) { Kohana_Log::add("error", "@todo notification_event::item_deleted() failed"); Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString()); } } static function user_deleted($user) { db::build() ->delete("subscriptions") ->where("user_id", "=", $user->id) ->execute(); } static function identity_provider_changed($old_provider, $new_provider) { db::build() ->delete("subscriptions") ->execute(); } static function comment_created($comment) { try { if ($comment->state == "published") { notification::send_comment_published($comment); } } catch (Exception $e) { Kohana_Log::add("error", "@todo notification_event::comment_created() failed"); Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString()); } } static function comment_updated($original, $new) { try { if ($new->state == "published" && $original->state != "published") { notification::send_comment_published($new); } } catch (Exception $e) { Kohana_Log::add("error", "@todo notification_event::comment_updated() failed"); Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString()); } } static function user_before_delete($user) { try { db::build() ->delete("subscriptions") ->where("user_id", "=", $user->id) ->execute(); } catch (Exception $e) { Kohana_Log::add("error", "@todo notification_event::user_before_delete() failed"); Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString()); } } static function batch_complete() { try { notification::send_pending_notifications(); } catch (Exception $e) { Kohana_Log::add("error", "@todo notification_event::batch_complete() failed"); Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString()); } } static function site_menu($menu, $theme) { if (!identity::active_user()->guest) { $item = $theme->item(); if ($item && $item->is_album() && access::can("view", $item)) { $watching = notification::is_watching($item); $label = $watching ? t("Remove notifications") : t("Enable notifications"); $menu->get("options_menu") ->append(Menu::factory("link") ->id("watch") ->label($label) ->css_id("g-notify-link") ->url(url::site("notification/watch/$item->id?csrf=" . access::csrf_token()))); } } } }