static function logout() { $user = identity::active_user(); if (!$user->guest) { try { Session::instance()->destroy(); } catch (Exception $e) { Kohana_Log::add("error", $e); } module::event("user_logout", $user); } log::info("user", t("User %name logged out", array("name" => $user->name)), t('<a href="%url">%user_name</a>', array("url" => user_profile::url($user->id), "user_name" => html::clean($user->name)))); }
static function thumb_info($theme, $item) { $results = ""; if ($item->view_count) { $results .= "<li>"; $results .= t("Views: %view_count", array("view_count" => $item->view_count)); $results .= "</li>"; } // rWatcher Edit: Display Tags on Thumbnails if (module::is_active("tag")) { $tags = ORM::factory("tag")->join("items_tags", "tags.id", "items_tags.tag_id")->where("items_tags.item_id", "=", $item->id)->find_all(); if (count($tags) > 0) { $results .= "<li>"; $results .= t("Tags:") . " "; $anchors = array(); foreach ($tags as $tag) { $anchors[] = "<a href=" . $tag->url() . ">" . html::clean($tag->name) . "</a>"; } $results .= join(", ", $anchors) . "</li>"; } } // rWatcher End Edit if ($item->owner) { // rWatcher Edit: Display profile instead of web site, if viewable. $str_owner_url = $item->owner->url; if (rwinfo_theme_Core::_can_view_profile_pages(identity::lookup_user($item->owner->id))) { $str_owner_url = user_profile::url($item->owner->id); } // rWatcher End Edit $results .= "<li>"; if ($str_owner_url) { //rW Edit str_owner_url $results .= t("By: <a href=\"%owner_url\">%owner_name</a>", array("owner_name" => $item->owner->display_name(), "owner_url" => $str_owner_url)); // rW Edit str_owner_url } else { $results .= t("By: %owner_name", array("owner_name" => $item->owner->display_name())); } $results .= "</li>"; } return $results; }
$user_text = $oneTag->name; } if ($showusers) { $legend_users .= "<span id=\"photoannotation-legend-user-" . $oneUser->id . "\"><a href=\"" . user_profile::url($oneUser->user_id) . "\">" . html::clean($user_text) . "</a></span> "; } $jscode .= "{ \"top\": " . $oneUser->y1 . ",\n"; $jscode .= "\"left\": " . $oneUser->x1 . ",\n"; $jscode .= "\"width\": " . ($oneUser->x2 - $oneUser->x1) . ",\n"; $jscode .= "\"height\": " . ($oneUser->y2 - $oneUser->y1) . ",\n"; $jscode .= "\"text\": \"" . html::clean($user_text) . "\",\n"; $jscode .= "\"internaltext\": \"" . $oneTag->display_name() . " (" . $oneTag->name . ")\",\n"; $jscode .= "\"description\": \"" . html::clean($oneUser->description) . "\",\n"; $jscode .= "\"noteid\": " . $oneUser->id . ",\n"; $jscode .= "\"notetype\": \"user\",\n"; $jscode .= "\"editable\": true,\n"; $jscode .= "\"url\": \"" . user_profile::url($oneUser->user_id) . "\" },\n"; } } foreach ($existingFaces as $oneFace) { $oneTag = ORM::factory("tag", $oneFace->tag_id); if ($oneTag->loaded()) { if ($showfaces) { $legend_faces .= "<span id=\"photoannotation-legend-face-" . $oneFace->id . "\"><a href=\"" . $oneTag->url() . "\">" . html::clean($oneTag->name) . "</a></span> "; } $jscode .= "{ \"top\": " . $oneFace->y1 . ",\n"; $jscode .= "\"left\": " . $oneFace->x1 . ",\n"; $jscode .= "\"width\": " . ($oneFace->x2 - $oneFace->x1) . ",\n"; $jscode .= "\"height\": " . ($oneFace->y2 - $oneFace->y1) . ",\n"; $jscode .= "\"text\": \"" . html::clean($oneTag->name) . "\",\n"; $jscode .= "\"description\": \"" . html::clean($oneFace->description) . "\",\n"; $jscode .= "\"noteid\": " . $oneFace->id . ",\n";
static function user_menu($menu, $theme) { if ($theme->page_subtype != "login") { $user = identity::active_user(); if ($user->guest) { $menu->append(Menu::factory("dialog")->id("user_menu_login")->css_id("g-login-link")->url(url::site("login/ajax"))->label(t("Login"))); } else { $csrf = access::csrf_token(); $menu->append(Menu::factory("link")->id("user_menu_edit_profile")->css_id("g-user-profile-link")->view("login_current_user.html")->url(user_profile::url($user->id))->label($user->display_name())); $menu->append(Menu::factory("link")->id("user_menu_logout")->css_id("g-logout-link")->url(url::site("logout?csrf={$csrf}&continue=" . urlencode(url::abs_current())))->label(t("Logout"))); } } }
<?php defined("SYSPATH") or die("No direct script access."); ?> <ul> <? foreach ($comments as $comment): ?> <li class="<?php echo text::alternate("g-even", "g-odd"); ?> "> <img src="<?php echo $comment->author()->avatar_url(32, $theme->url("images/avatar.jpg", true)); ?> " class="g-avatar" alt="<?php echo html::clean_attribute($comment->author_name()); ?> " width="32" height="32" /> <?php echo gallery::date_time($comment->created); ?> <?php echo t('<a href="%url">%author_name</a> said <em>%comment_text</em>', array("author_name" => html::clean($comment->author_name()), "url" => user_profile::url($comment->author_id), "comment_text" => text::limit_words(nl2br(html::purify($comment->text)), 50))); ?> </li> <? endforeach ?> </ul>
<?php echo $search_form; ?> <?php if (count($users)) { ?> <div class="g-message photoannotation-user-search"> <?php echo t("%count people found for <b>%term</b>", array("count" => $count, "term" => $q)); ?> </div> <?php foreach ($users as $user) { ?> <?php $profile_link = "<a href=\"" . user_profile::url($user->id) . "\">"; ?> <div class="g-block"> <h2><img src="<?php echo $user->avatar_url(40, $theme->url("images/avatar.jpg", true)); ?> " alt="<?php echo html::clean_attribute($user->display_name()); ?> " class="g-avatar" width="40" height="40" /> <?php echo $profile_link . $user->name; ?> </a></h2>
echo $comment->id; ?> "> <p class="g-author"> <a href="#"> <img src="<?php echo $comment->author()->avatar_url(40, $theme->url("images/avatar.jpg", true)); ?> " class="g-avatar" alt="<?php echo html::clean_attribute($comment->author_name()); ?> " width="40" height="40" /> </a> <?php echo t('on %date <a href="%url">%name</a> said', array("date" => date("Y-M-d H:i:s", $comment->created), "url" => user_profile::url($comment->author_id), "name" => html::clean($comment->author_name()))); ?> </p> <div> <?php echo nl2br(html::purify($comment->text)); ?> </div> </li> <? endforeach ?> </ul> </div>
static function user_menu($menu, $theme) { if ($theme->page_subtype != "login") { $user = identity::active_user(); if ($user->guest) { $menu->append(Menu::factory("dialog")->id("user_menu_login")->css_id("g-login-link")->url(url::site("login/ajax"))->label(t("Login"))); } else { $csrf = access::csrf_token(); $menu->append(Menu::factory("link")->id("user_menu_edit_profile")->css_id("g-user-profile-link")->view("login_current_user.html")->url(user_profile::url($user->id))->label($user->display_name())); if (Router::$controller == "admin") { $continue_url = url::abs_site(""); } else { if ($item = $theme->item()) { if (access::user_can(identity::guest(), "view", $theme->item)) { $continue_url = $item->abs_url(); } else { $continue_url = item::root()->abs_url(); } } else { $continue_url = url::abs_current(); } } $menu->append(Menu::factory("link")->id("user_menu_logout")->css_id("g-logout-link")->url(url::site("logout?csrf={$csrf}&continue_url=" . urlencode($continue_url)))->label(t("Logout"))); } } }
<?php defined("SYSPATH") or die("No direct script access."); ?> <ul> <? foreach ($entries as $entry): ?> <li class="<?php echo log::severity_class($entry->severity); ?> " style="direction: ltr"> <a href="<?php echo user_profile::url($entry->user->id); ?> "><?php echo html::clean($entry->user->name); ?> </a> <?php echo gallery::date_time($entry->timestamp); ?> <?php echo $entry->message; ?> <?php echo $entry->html; ?> </li> <? endforeach ?> </ul>
static function cloud($count) { $users = ORM::factory("user")->order_by("name", "ASC")->find_all(); if ($users) { $cloud = new View("photoannotation_cloud.html"); $fullname = module::get_var("photoannotation", "fullname", false); foreach ($users as $user) { $annotations = ORM::factory("items_user")->where("user_id", "=", $user->id)->count_all(); if ($annotations > 0) { if ($annotations > $maxcount) { $maxcount = $annotations; } if ($fullname) { $user_array[$user->name]->name = $user->display_name(); } else { $user_array[$user->name]->name = $user->name; } $user_array[$user->name]->size = $annotations; $user_array[$user->name]->url = user_profile::url($user->id); } } if (isset($user_array)) { $cloud->users = array_slice($user_array, 0, $count); $cloud->max_count = $maxcount; return $cloud; } else { return ""; } } }
public function save($item_id) { // Prevent Cross Site Request Forgery access::verify_csrf(); //Get form data $item = ORM::factory("item", $item_id); $annotate_id = $_POST["noteid"]; $notetype = $_POST["notetype"]; $str_y1 = $_POST["top"]; $str_x1 = $_POST["left"]; $str_y2 = $_POST["height"] + $str_y1; //Annotation uses area size, tagfaces uses positions $str_x2 = $_POST["width"] + $str_x1; //Annotation uses area size, tagfaces uses positions $item_title = $_POST["text"]; $tag_data = $_POST["tagsList"]; $user_id = ""; $user_id = $_POST["userlist"]; $description = $_POST["desc"]; $error_noselection = t("Please select a person or tag or specify a title."); $redir_uri = url::abs_site("{$item->type}s/{$item->id}"); //If this is a user then get the id if ($user_id != "") { $getuser = photoannotation::getuser($user_id); if (!$getuser->found) { json::reply(array("result" => "error", "message" => (string) t("Could not find anyone with the name %user.", array("user" => $user_id)))); return; } if ($getuser->isguest) { json::reply(array("result" => "error", "message" => (string) t("You cannot create an annotation for the guest user."))); return; } $user_id = $getuser->user->id; } //Add tag to item, create tag if not exists if ($tag_data != "") { $tag = ORM::factory("tag")->where("name", "=", $tag_data)->find(); if (!$tag->loaded()) { $tag->name = $tag_data; $tag->count = 0; } $tag->add($item); $tag->count++; $tag->save(); $tag_data = $tag->id; } else { $tag_data = ""; } //Save annotation if ($annotate_id == "new") { //This is a new annotation $annotate_id = -1; if ($user_id != "") { //Save user $new_id = photoannotation::saveuser($user_id, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); $dest_type = "user"; } elseif ($tag_data != "") { //Save face $new_id = photoannotation::saveface($tag_data, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); $dest_type = "face"; } elseif ($item_title != "") { //Save note $new_id = photoannotation::savenote($item_title, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); $dest_type = "note"; } else { //Something's wrong json::reply(array("result" => "error", "message" => (string) $error_noselection)); return; } } else { //This is an update to an existing annotation switch ($notetype) { case "user": //the original annotation is a user $updateduser = ORM::factory("items_user")->where("id", "=", $annotate_id)->find(); if ($user_id != "") { //Conversion user -> user $new_id = photoannotation::saveuser($user_id, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); $dest_type = "user"; } elseif ($tag_data != "") { //Conversion user -> face $new_id = photoannotation::saveface($tag_data, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); $dest_type = "face"; $updateduser->delete(); //delete old user } elseif ($item_title != "") { //Conversion user -> note $new_id = photoannotation::savenote($item_title, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); $dest_type = "note"; $updateduser->delete(); //delete old user } else { //Somethings wrong json::reply(array("result" => "error", "message" => (string) $error_noselection)); return; } break; case "face": //the original annotation is a face $updatedface = ORM::factory("items_face")->where("id", "=", $annotate_id)->find(); if ($user_id != "") { //Conversion face -> user $new_id = photoannotation::saveuser($user_id, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); $dest_type = "user"; $updatedface->delete(); //delete old face } elseif ($tag_data != "") { //Conversion face -> face $new_id = photoannotation::saveface($tag_data, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description, $annotate_id); $dest_type = "face"; } elseif ($item_title != "") { //Conversion face -> note $new_id = photoannotation::savenote($item_title, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); $dest_type = "note"; $updatedface->delete(); //delete old face } else { //Somethings wrong json::reply(array("result" => "error", "message" => (string) $error_noselection)); return; } break; case "note": //the original annotation is a note $updatednote = ORM::factory("items_note")->where("id", "=", $annotate_id)->find(); if ($user_id != "") { //Conversion note -> user $new_id = photoannotation::saveuser($user_id, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); $dest_type = "user"; $updatednote->delete(); //delete old note } elseif ($tag_data != "") { //Conversion note -> face $new_id = photoannotation::saveface($tag_data, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description); $dest_type = "face"; $updatednote->delete(); //delete old note } elseif ($item_title != "") { //Conversion note -> note $new_id = photoannotation::savenote($item_title, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description, $annotate_id); $dest_type = "note"; } else { //Somethings wrong json::reply(array("result" => "error", "message" => (string) $error_noselection)); return; } break; default: json::reply(array("result" => "error", "message" => (string) $error_noselection)); return; } } $int_text = ""; $editable = true; switch ($dest_type) { case "user": $fullname = module::get_var("photoannotation", "fullname", false); $int_text = $getuser->user->display_name() . " (" . $getuser->user->name . ")"; if ($fullname) { $note_text = $getuser->user->display_name(); } else { $note_text = $getuser->user->name; } $note_url = user_profile::url($getuser->user->id); break; case "face": $note_text = $tag->name; $note_url = $tag->url(); break; case "note": $note_text = $item_title; $note_url = ""; $editable = false; } if ($annotate_id == -1) { $annotation_id = ""; } else { $annotation_id = "photoannotation-area-" . $notetype . "-" . $annotate_id; } $reply = array("result" => "success", "notetype" => (string) $dest_type, "description" => (string) $description, "height" => (int) $_POST["height"], "internaltext" => (string) $int_text, "left" => (int) $str_x1, "noteid" => (int) $new_id, "text" => (string) $note_text, "top" => (int) $str_y1, "url" => (string) $note_url, "width" => (int) $_POST["width"], "editable" => (bool) $editable, "annotationid" => (string) $annotation_id, "oldid" => (string) $annotate_id, "oldtype" => (string) $notetype); json::reply($reply); }
?> " width="40" height="40" /> </a> <?php if ($comment->author()->guest) { ?> <?php echo t("on %date_time, %name said", array("date_time" => gallery::date_time($comment->created), "name" => html::clean($comment->author_name()))); ?> <?php } else { ?> <?php echo t("on %date_time, <a href=\"%url\">%name</a> said", array("date_time" => gallery::date_time($comment->created), "url" => user_profile::url($comment->author_id), "name" => html::clean($comment->author_name()))); ?> <?php } ?> </p> <div> <?php echo nl2br(html::purify($comment->text)); ?> </div> <?php if ($comment->state == "unpublished") { ?> <b> <?php echo t("Your comment is held for moderation. The site moderator will review and publish it.");
static function get($block_id, $theme) { $block = ""; switch ($block_id) { case "rwinfo": if ($theme->item()) { // rWatcher Edit: Don't display on root album. if ($theme->item->id == 1) { return ""; } // End rWatcher Edit $block = new Block(); $block->css_id = "g-metadata"; $block->title = $theme->item()->is_album() ? t("Album info") : ($theme->item()->is_movie() ? t("Movie info") : t("Photo info")); // rWatcher Edit: File Name change. $block->content = new View("rwinfo_block.html"); if ($theme->item->title && module::get_var("rwinfo", "show_title")) { //rWatcher Edit: rwinfo $info["title"] = array("label" => t("Title:"), "value" => html::purify($theme->item->title)); } if ($theme->item->description && module::get_var("rwinfo", "show_description")) { //rWatcher Edit: rwinfo $info["description"] = array("label" => t("Description:"), "value" => nl2br(html::purify($theme->item->description))); } if (!$theme->item->is_album() && module::get_var("rwinfo", "show_name")) { //rWatcher Edit: rwinfo $info["file_name"] = array("label" => t("File name:"), "value" => html::clean($theme->item->name)); } // rWatcher Edit: Display file size if (!$theme->item->is_album()) { // Calculate file size. $filesize_unit = array("B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"); $item_filesize = filesize($theme->item->file_path()); $unit_counter = 0; while ($item_filesize >= 1024) { $item_filesize = $item_filesize / 1024; $unit_counter++; } $item_filesize = number_format($item_filesize, 2) . " " . $filesize_unit[$unit_counter]; $info["file_size"] = array("label" => t("File size:"), "value" => $item_filesize); } // End rWatcher Edit // rWatcher Edit: Remove Show Captured for everything -- Show created DATE for album, captured DATE/TIME for everything else. //if ($theme->item->captured && module::get_var("info", "show_captured")) { // $info["captured"] = array( // "label" => t("Captured:"), // "value" => gallery::date_time($theme->item->captured) // ); //} if ($theme->item->is_album() && $theme->item->created && module::get_var("rwinfo", "show_captured")) { $info["captured"] = array("label" => t("Date:"), "value" => gallery::date($theme->item->created)); } if (!$theme->item->is_album() && $theme->item->created && module::get_var("rwinfo", "show_captured")) { $info["captured"] = array("label" => t("Date:"), "value" => gallery::date_time($theme->item->captured)); } // End rWatcher Edit if ($theme->item->owner && module::get_var("info", "show_owner")) { $display_name = $theme->item->owner->display_name(); // rWatcher Edit: Display profile instead of web site, if viewable. $str_owner_url = $theme->item->owner->url; if (rwinfo_block_Core::_can_view_profile_pages(identity::lookup_user($theme->item->owner->id))) { $str_owner_url = user_profile::url($theme->item->owner->id); } // rWatcher End Edit if ($str_owner_url) { //rW Edit $str_owner_url. $info["owner"] = array("label" => t("Owner:"), "value" => html::anchor(html::clean($str_owner_url), html::clean($display_name))); } else { $info["owner"] = array("label" => t("Owner:"), "value" => html::clean($display_name)); } } if ($theme->item->width && $theme->item->height && module::get_var("info", "show_dimensions")) { $info["size"] = array("label" => t("Dimensions:"), "value" => t("%width x %height px", array("width" => $theme->item->width, "height" => $theme->item->height))); } $block->content->metadata = $info; module::event("info_block_get_metadata", $block, $theme->item); } break; } return $block; }