forked from Cavemanon/cavepaintings
PSR-2. I'm not a huge fan, but ugly consistency beats no consistency...
This commit is contained in:
@@ -7,14 +7,16 @@
|
||||
* Documentation:
|
||||
*/
|
||||
|
||||
class Notes extends Extension {
|
||||
public function onInitExt(InitExtEvent $event) {
|
||||
global $config, $database;
|
||||
class Notes extends Extension
|
||||
{
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
|
||||
// shortcut to latest
|
||||
if ($config->get_int("ext_notes_version") < 1) {
|
||||
$database->Execute("ALTER TABLE images ADD COLUMN notes INTEGER NOT NULL DEFAULT 0");
|
||||
$database->create_table("notes", "
|
||||
// shortcut to latest
|
||||
if ($config->get_int("ext_notes_version") < 1) {
|
||||
$database->Execute("ALTER TABLE images ADD COLUMN notes INTEGER NOT NULL DEFAULT 0");
|
||||
$database->create_table("notes", "
|
||||
id SCORE_AIPK,
|
||||
enable INTEGER NOT NULL,
|
||||
image_id INTEGER NOT NULL,
|
||||
@@ -29,9 +31,9 @@ class Notes extends Extension {
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE
|
||||
");
|
||||
$database->execute("CREATE INDEX notes_image_id_idx ON notes(image_id)", array());
|
||||
$database->execute("CREATE INDEX notes_image_id_idx ON notes(image_id)", []);
|
||||
|
||||
$database->create_table("note_request", "
|
||||
$database->create_table("note_request", "
|
||||
id SCORE_AIPK,
|
||||
image_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
@@ -39,9 +41,9 @@ class Notes extends Extension {
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE
|
||||
");
|
||||
$database->execute("CREATE INDEX note_request_image_id_idx ON note_request(image_id)", array());
|
||||
$database->execute("CREATE INDEX note_request_image_id_idx ON note_request(image_id)", []);
|
||||
|
||||
$database->create_table("note_histories", "
|
||||
$database->create_table("note_histories", "
|
||||
id SCORE_AIPK,
|
||||
note_enable INTEGER NOT NULL,
|
||||
note_id INTEGER NOT NULL,
|
||||
@@ -58,469 +60,505 @@ class Notes extends Extension {
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE
|
||||
");
|
||||
$database->execute("CREATE INDEX note_histories_image_id_idx ON note_histories(image_id)", array());
|
||||
$database->execute("CREATE INDEX note_histories_image_id_idx ON note_histories(image_id)", []);
|
||||
|
||||
$config->set_int("notesNotesPerPage", 20);
|
||||
$config->set_int("notesRequestsPerPage", 20);
|
||||
$config->set_int("notesHistoriesPerPage", 20);
|
||||
$config->set_int("notesNotesPerPage", 20);
|
||||
$config->set_int("notesRequestsPerPage", 20);
|
||||
$config->set_int("notesHistoriesPerPage", 20);
|
||||
|
||||
$config->set_int("ext_notes_version", 1);
|
||||
log_info("notes", "extension installed");
|
||||
}
|
||||
}
|
||||
$config->set_int("ext_notes_version", 1);
|
||||
log_info("notes", "extension installed");
|
||||
}
|
||||
}
|
||||
|
||||
public function onPageRequest(PageRequestEvent $event) {
|
||||
global $page, $user;
|
||||
if($event->page_matches("note")) {
|
||||
switch($event->get_arg(0)) {
|
||||
case "list": //index
|
||||
$this->get_notes_list($event); // This should show images like post/list but i don't know how do that.
|
||||
break;
|
||||
case "requests": // The same as post/list but only for note_request table.
|
||||
$this->get_notes_requests($event); // This should show images like post/list but i don't know how do that.
|
||||
break;
|
||||
case "search":
|
||||
if(!$user->is_anonymous())
|
||||
$this->theme->search_notes_page($page);
|
||||
break;
|
||||
case "updated": //Thinking how to build this function.
|
||||
$this->get_histories($event);
|
||||
break;
|
||||
case "history": //Thinking how to build this function.
|
||||
$this->get_history($event);
|
||||
break;
|
||||
case "revert":
|
||||
$noteID = $event->get_arg(1);
|
||||
$reviewID = $event->get_arg(2);
|
||||
if(!$user->is_anonymous()){
|
||||
$this->revert_history($noteID, $reviewID);
|
||||
}
|
||||
public function onPageRequest(PageRequestEvent $event)
|
||||
{
|
||||
global $page, $user;
|
||||
if ($event->page_matches("note")) {
|
||||
switch ($event->get_arg(0)) {
|
||||
case "list": //index
|
||||
$this->get_notes_list($event); // This should show images like post/list but i don't know how do that.
|
||||
break;
|
||||
case "requests": // The same as post/list but only for note_request table.
|
||||
$this->get_notes_requests($event); // This should show images like post/list but i don't know how do that.
|
||||
break;
|
||||
case "search":
|
||||
if (!$user->is_anonymous()) {
|
||||
$this->theme->search_notes_page($page);
|
||||
}
|
||||
break;
|
||||
case "updated": //Thinking how to build this function.
|
||||
$this->get_histories($event);
|
||||
break;
|
||||
case "history": //Thinking how to build this function.
|
||||
$this->get_history($event);
|
||||
break;
|
||||
case "revert":
|
||||
$noteID = $event->get_arg(1);
|
||||
$reviewID = $event->get_arg(2);
|
||||
if (!$user->is_anonymous()) {
|
||||
$this->revert_history($noteID, $reviewID);
|
||||
}
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("note/updated"));
|
||||
break;
|
||||
case "add_note":
|
||||
if(!$user->is_anonymous())
|
||||
$this->add_new_note();
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("note/updated"));
|
||||
break;
|
||||
case "add_note":
|
||||
if (!$user->is_anonymous()) {
|
||||
$this->add_new_note();
|
||||
}
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
|
||||
break;
|
||||
case "add_request":
|
||||
if(!$user->is_anonymous())
|
||||
$this->add_note_request();
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
|
||||
break;
|
||||
case "add_request":
|
||||
if (!$user->is_anonymous()) {
|
||||
$this->add_note_request();
|
||||
}
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
|
||||
break;
|
||||
case "nuke_notes":
|
||||
if($user->is_admin())
|
||||
$this->nuke_notes();
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
|
||||
break;
|
||||
case "nuke_notes":
|
||||
if ($user->is_admin()) {
|
||||
$this->nuke_notes();
|
||||
}
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
|
||||
break;
|
||||
case "nuke_requests":
|
||||
if($user->is_admin())
|
||||
$this->nuke_requests();
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
|
||||
break;
|
||||
case "nuke_requests":
|
||||
if ($user->is_admin()) {
|
||||
$this->nuke_requests();
|
||||
}
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
|
||||
break;
|
||||
case "edit_note":
|
||||
if (!$user->is_anonymous()) {
|
||||
$this->update_note();
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/" . $_POST["image_id"]));
|
||||
}
|
||||
break;
|
||||
case "delete_note":
|
||||
if ($user->is_admin()) {
|
||||
$this->delete_note();
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("note/list"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
|
||||
break;
|
||||
case "edit_note":
|
||||
if (!$user->is_anonymous()) {
|
||||
$this->update_note();
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/" . $_POST["image_id"]));
|
||||
}
|
||||
break;
|
||||
case "delete_note":
|
||||
if ($user->is_admin()) {
|
||||
$this->delete_note();
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("note/list"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE LOAD THE NOTES IN THE IMAGE
|
||||
*/
|
||||
public function onDisplayingImage(DisplayingImageEvent $event) {
|
||||
global $page, $user;
|
||||
/*
|
||||
* HERE WE LOAD THE NOTES IN THE IMAGE
|
||||
*/
|
||||
public function onDisplayingImage(DisplayingImageEvent $event)
|
||||
{
|
||||
global $page, $user;
|
||||
|
||||
//display form on image event
|
||||
$notes = $this->get_notes($event->image->id);
|
||||
$this->theme->display_note_system($page, $event->image->id, $notes, $user->is_admin());
|
||||
}
|
||||
//display form on image event
|
||||
$notes = $this->get_notes($event->image->id);
|
||||
$this->theme->display_note_system($page, $event->image->id, $notes, $user->is_admin());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE ADD THE BUTTONS ON SIDEBAR
|
||||
*/
|
||||
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) {
|
||||
global $user;
|
||||
if(!$user->is_anonymous()) {
|
||||
$event->add_part($this->theme->note_button($event->image->id));
|
||||
$event->add_part($this->theme->request_button($event->image->id));
|
||||
if($user->is_admin()) {
|
||||
$event->add_part($this->theme->nuke_notes_button($event->image->id));
|
||||
$event->add_part($this->theme->nuke_requests_button($event->image->id));
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* HERE WE ADD THE BUTTONS ON SIDEBAR
|
||||
*/
|
||||
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
|
||||
{
|
||||
global $user;
|
||||
if (!$user->is_anonymous()) {
|
||||
$event->add_part($this->theme->note_button($event->image->id));
|
||||
$event->add_part($this->theme->request_button($event->image->id));
|
||||
if ($user->is_admin()) {
|
||||
$event->add_part($this->theme->nuke_notes_button($event->image->id));
|
||||
$event->add_part($this->theme->nuke_requests_button($event->image->id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE ADD QUERYLETS TO ADD SEARCH SYSTEM
|
||||
*/
|
||||
public function onSearchTermParse(SearchTermParseEvent $event) {
|
||||
$matches = array();
|
||||
if(preg_match("/^note[=|:](.*)$/i", $event->term, $matches)) {
|
||||
$notes = int_escape($matches[1]);
|
||||
$event->add_querylet(new Querylet("images.id IN (SELECT image_id FROM notes WHERE note = $notes)"));
|
||||
}
|
||||
else if(preg_match("/^notes([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+)%/i", $event->term, $matches)) {
|
||||
$cmp = ltrim($matches[1], ":") ?: "=";
|
||||
$notes = $matches[2];
|
||||
$event->add_querylet(new Querylet("images.id IN (SELECT id FROM images WHERE notes $cmp $notes)"));
|
||||
}
|
||||
else if(preg_match("/^notes_by[=|:](.*)$/i", $event->term, $matches)) {
|
||||
$user = User::by_name($matches[1]);
|
||||
if(!is_null($user)) {
|
||||
$user_id = $user->id;
|
||||
} else {
|
||||
$user_id = -1;
|
||||
}
|
||||
/*
|
||||
* HERE WE ADD QUERYLETS TO ADD SEARCH SYSTEM
|
||||
*/
|
||||
public function onSearchTermParse(SearchTermParseEvent $event)
|
||||
{
|
||||
$matches = [];
|
||||
if (preg_match("/^note[=|:](.*)$/i", $event->term, $matches)) {
|
||||
$notes = int_escape($matches[1]);
|
||||
$event->add_querylet(new Querylet("images.id IN (SELECT image_id FROM notes WHERE note = $notes)"));
|
||||
} elseif (preg_match("/^notes([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+)%/i", $event->term, $matches)) {
|
||||
$cmp = ltrim($matches[1], ":") ?: "=";
|
||||
$notes = $matches[2];
|
||||
$event->add_querylet(new Querylet("images.id IN (SELECT id FROM images WHERE notes $cmp $notes)"));
|
||||
} elseif (preg_match("/^notes_by[=|:](.*)$/i", $event->term, $matches)) {
|
||||
$user = User::by_name($matches[1]);
|
||||
if (!is_null($user)) {
|
||||
$user_id = $user->id;
|
||||
} else {
|
||||
$user_id = -1;
|
||||
}
|
||||
|
||||
$event->add_querylet(new Querylet("images.id IN (SELECT image_id FROM notes WHERE user_id = $user_id)"));
|
||||
}
|
||||
else if(preg_match("/^notes_by_userno[=|:](\d+)$/i", $event->term, $matches)) {
|
||||
$user_id = int_escape($matches[1]);
|
||||
$event->add_querylet(new Querylet("images.id IN (SELECT image_id FROM notes WHERE user_id = $user_id)"));
|
||||
}
|
||||
}
|
||||
$event->add_querylet(new Querylet("images.id IN (SELECT image_id FROM notes WHERE user_id = $user_id)"));
|
||||
} elseif (preg_match("/^notes_by_userno[=|:](\d+)$/i", $event->term, $matches)) {
|
||||
$user_id = int_escape($matches[1]);
|
||||
$event->add_querylet(new Querylet("images.id IN (SELECT image_id FROM notes WHERE user_id = $user_id)"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* HERE WE GET ALL NOTES FOR DISPLAYED IMAGE.
|
||||
*/
|
||||
private function get_notes(int $imageID): array {
|
||||
global $database;
|
||||
/**
|
||||
* HERE WE GET ALL NOTES FOR DISPLAYED IMAGE.
|
||||
*/
|
||||
private function get_notes(int $imageID): array
|
||||
{
|
||||
global $database;
|
||||
|
||||
return $database->get_all(
|
||||
"SELECT * ".
|
||||
"FROM notes ".
|
||||
"WHERE enable = ? AND image_id = ? ".
|
||||
"ORDER BY date ASC",
|
||||
array('1', $imageID));
|
||||
}
|
||||
return $database->get_all(
|
||||
"SELECT * ".
|
||||
"FROM notes ".
|
||||
"WHERE enable = ? AND image_id = ? ".
|
||||
"ORDER BY date ASC",
|
||||
['1', $imageID]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE ADD A NOTE TO DATABASE
|
||||
*/
|
||||
private function add_new_note() {
|
||||
global $database, $user;
|
||||
/*
|
||||
* HERE WE ADD A NOTE TO DATABASE
|
||||
*/
|
||||
private function add_new_note()
|
||||
{
|
||||
global $database, $user;
|
||||
|
||||
$imageID = int_escape($_POST["image_id"]);
|
||||
$user_id = $user->id;
|
||||
$noteX1 = int_escape($_POST["note_x1"]);
|
||||
$noteY1 = int_escape($_POST["note_y1"]);
|
||||
$noteHeight = int_escape($_POST["note_height"]);
|
||||
$noteWidth = int_escape($_POST["note_width"]);
|
||||
$noteText = html_escape($_POST["note_text"]);
|
||||
$imageID = int_escape($_POST["image_id"]);
|
||||
$user_id = $user->id;
|
||||
$noteX1 = int_escape($_POST["note_x1"]);
|
||||
$noteY1 = int_escape($_POST["note_y1"]);
|
||||
$noteHeight = int_escape($_POST["note_height"]);
|
||||
$noteWidth = int_escape($_POST["note_width"]);
|
||||
$noteText = html_escape($_POST["note_text"]);
|
||||
|
||||
$database->execute("
|
||||
$database->execute(
|
||||
"
|
||||
INSERT INTO notes (enable, image_id, user_id, user_ip, date, x1, y1, height, width, note)
|
||||
VALUES (?, ?, ?, ?, now(), ?, ?, ?, ?, ?)",
|
||||
array(1, $imageID, $user_id, $_SERVER['REMOTE_ADDR'], $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText));
|
||||
[1, $imageID, $user_id, $_SERVER['REMOTE_ADDR'], $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText]
|
||||
);
|
||||
|
||||
$noteID = $database->get_last_insert_id('notes_id_seq');
|
||||
$noteID = $database->get_last_insert_id('notes_id_seq');
|
||||
|
||||
log_info("notes", "Note added {$noteID} by {$user->name}");
|
||||
log_info("notes", "Note added {$noteID} by {$user->name}");
|
||||
|
||||
$database->execute("UPDATE images SET notes=(SELECT COUNT(*) FROM notes WHERE image_id=?) WHERE id=?", array($imageID, $imageID));
|
||||
$database->execute("UPDATE images SET notes=(SELECT COUNT(*) FROM notes WHERE image_id=?) WHERE id=?", [$imageID, $imageID]);
|
||||
|
||||
$this->add_history(1, $noteID, $imageID, $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText);
|
||||
}
|
||||
$this->add_history(1, $noteID, $imageID, $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE ADD A REQUEST TO DATABASE
|
||||
*/
|
||||
private function add_note_request() {
|
||||
global $database, $user;
|
||||
/*
|
||||
* HERE WE ADD A REQUEST TO DATABASE
|
||||
*/
|
||||
private function add_note_request()
|
||||
{
|
||||
global $database, $user;
|
||||
|
||||
$image_id = int_escape($_POST["image_id"]);
|
||||
$user_id = $user->id;
|
||||
$image_id = int_escape($_POST["image_id"]);
|
||||
$user_id = $user->id;
|
||||
|
||||
$database->execute("
|
||||
$database->execute(
|
||||
"
|
||||
INSERT INTO note_request (image_id, user_id, date)
|
||||
VALUES (?, ?, now())",
|
||||
array($image_id, $user_id));
|
||||
[$image_id, $user_id]
|
||||
);
|
||||
|
||||
$resultID = $database->get_last_insert_id('note_request_id_seq');
|
||||
$resultID = $database->get_last_insert_id('note_request_id_seq');
|
||||
|
||||
log_info("notes", "Note requested {$resultID} by {$user->name}");
|
||||
}
|
||||
log_info("notes", "Note requested {$resultID} by {$user->name}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE EDIT THE NOTE
|
||||
*/
|
||||
private function update_note() {
|
||||
global $database;
|
||||
/*
|
||||
* HERE WE EDIT THE NOTE
|
||||
*/
|
||||
private function update_note()
|
||||
{
|
||||
global $database;
|
||||
|
||||
$note = array(
|
||||
"noteX1" => int_escape($_POST["note_x1"]),
|
||||
"noteY1" => int_escape($_POST["note_y1"]),
|
||||
"noteHeight" => int_escape($_POST["note_height"]),
|
||||
"noteWidth" => int_escape($_POST["note_width"]),
|
||||
"noteText" => sql_escape(html_escape($_POST["note_text"])),
|
||||
"imageID" => int_escape($_POST["image_id"]),
|
||||
"noteID" => int_escape($_POST["note_id"])
|
||||
);
|
||||
$note = [
|
||||
"noteX1" => int_escape($_POST["note_x1"]),
|
||||
"noteY1" => int_escape($_POST["note_y1"]),
|
||||
"noteHeight" => int_escape($_POST["note_height"]),
|
||||
"noteWidth" => int_escape($_POST["note_width"]),
|
||||
"noteText" => sql_escape(html_escape($_POST["note_text"])),
|
||||
"imageID" => int_escape($_POST["image_id"]),
|
||||
"noteID" => int_escape($_POST["note_id"])
|
||||
];
|
||||
|
||||
// validate parameters
|
||||
if (array_search(NULL, $note)|| strlen($note['noteText']) == 0) {
|
||||
return;
|
||||
}
|
||||
// validate parameters
|
||||
if (array_search(null, $note)|| strlen($note['noteText']) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$database->execute("UPDATE notes ".
|
||||
"SET x1 = ?, ".
|
||||
"y1 = ?, ".
|
||||
"height = ?, ".
|
||||
"width = ?,".
|
||||
"note = ? ".
|
||||
"WHERE image_id = ? AND id = ?", array_values($note));
|
||||
$database->execute("UPDATE notes ".
|
||||
"SET x1 = ?, ".
|
||||
"y1 = ?, ".
|
||||
"height = ?, ".
|
||||
"width = ?,".
|
||||
"note = ? ".
|
||||
"WHERE image_id = ? AND id = ?", array_values($note));
|
||||
|
||||
$this->add_history(1, $note['noteID'], $note['imageID'], $note['noteX1'], $note['noteY1'], $note['noteHeight'], $note['noteWidth'], $note['noteText']);
|
||||
}
|
||||
$this->add_history(1, $note['noteID'], $note['imageID'], $note['noteX1'], $note['noteY1'], $note['noteHeight'], $note['noteWidth'], $note['noteText']);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE DELETE THE NOTE
|
||||
*/
|
||||
private function delete_note() {
|
||||
global $user, $database;
|
||||
/*
|
||||
* HERE WE DELETE THE NOTE
|
||||
*/
|
||||
private function delete_note()
|
||||
{
|
||||
global $user, $database;
|
||||
|
||||
$imageID = int_escape($_POST["image_id"]);
|
||||
$noteID = int_escape($_POST["note_id"]);
|
||||
$imageID = int_escape($_POST["image_id"]);
|
||||
$noteID = int_escape($_POST["note_id"]);
|
||||
|
||||
// validate parameters
|
||||
if(is_null($imageID) || !is_numeric($imageID) || is_null($noteID) || !is_numeric($noteID)) {
|
||||
return;
|
||||
}
|
||||
// validate parameters
|
||||
if (is_null($imageID) || !is_numeric($imageID) || is_null($noteID) || !is_numeric($noteID)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$database->execute("UPDATE notes ".
|
||||
"SET enable = ? ".
|
||||
"WHERE image_id = ? AND id = ?", array(0, $imageID, $noteID));
|
||||
$database->execute("UPDATE notes ".
|
||||
"SET enable = ? ".
|
||||
"WHERE image_id = ? AND id = ?", [0, $imageID, $noteID]);
|
||||
|
||||
log_info("notes", "Note deleted {$noteID} by {$user->name}");
|
||||
}
|
||||
log_info("notes", "Note deleted {$noteID} by {$user->name}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE DELETE ALL NOTES FROM IMAGE
|
||||
*/
|
||||
private function nuke_notes() {
|
||||
global $database, $user;
|
||||
$image_id = int_escape($_POST["image_id"]);
|
||||
$database->execute("DELETE FROM notes WHERE image_id = ?", array($image_id));
|
||||
log_info("notes", "Notes deleted from {$image_id} by {$user->name}");
|
||||
}
|
||||
/*
|
||||
* HERE WE DELETE ALL NOTES FROM IMAGE
|
||||
*/
|
||||
private function nuke_notes()
|
||||
{
|
||||
global $database, $user;
|
||||
$image_id = int_escape($_POST["image_id"]);
|
||||
$database->execute("DELETE FROM notes WHERE image_id = ?", [$image_id]);
|
||||
log_info("notes", "Notes deleted from {$image_id} by {$user->name}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE DELETE ALL REQUESTS FOR IMAGE
|
||||
*/
|
||||
private function nuke_requests() {
|
||||
global $database, $user;
|
||||
$image_id = int_escape($_POST["image_id"]);
|
||||
/*
|
||||
* HERE WE DELETE ALL REQUESTS FOR IMAGE
|
||||
*/
|
||||
private function nuke_requests()
|
||||
{
|
||||
global $database, $user;
|
||||
$image_id = int_escape($_POST["image_id"]);
|
||||
|
||||
$database->execute("DELETE FROM note_request WHERE image_id = ?", array($image_id));
|
||||
$database->execute("DELETE FROM note_request WHERE image_id = ?", [$image_id]);
|
||||
|
||||
log_info("notes", "Requests deleted from {$image_id} by {$user->name}");
|
||||
}
|
||||
log_info("notes", "Requests deleted from {$image_id} by {$user->name}");
|
||||
}
|
||||
|
||||
/**
|
||||
* HERE WE ALL IMAGES THAT HAVE NOTES
|
||||
*/
|
||||
private function get_notes_list(PageRequestEvent $event) {
|
||||
global $database, $config;
|
||||
/**
|
||||
* HERE WE ALL IMAGES THAT HAVE NOTES
|
||||
*/
|
||||
private function get_notes_list(PageRequestEvent $event)
|
||||
{
|
||||
global $database, $config;
|
||||
|
||||
$pageNumber = $event->get_arg(1);
|
||||
if(is_null($pageNumber) || !is_numeric($pageNumber) || $pageNumber <= 0) {
|
||||
$pageNumber = 0;
|
||||
} else {
|
||||
$pageNumber--;
|
||||
}
|
||||
$pageNumber = $event->get_arg(1);
|
||||
if (is_null($pageNumber) || !is_numeric($pageNumber) || $pageNumber <= 0) {
|
||||
$pageNumber = 0;
|
||||
} else {
|
||||
$pageNumber--;
|
||||
}
|
||||
|
||||
$notesPerPage = $config->get_int('notesNotesPerPage');
|
||||
$notesPerPage = $config->get_int('notesNotesPerPage');
|
||||
|
||||
//$result = $database->get_all("SELECT * FROM pool_images WHERE pool_id=?", array($poolID));
|
||||
$result = $database->execute("SELECT DISTINCT image_id".
|
||||
"FROM notes ".
|
||||
"WHERE enable = ? ".
|
||||
"ORDER BY date DESC LIMIT ?, ?",
|
||||
array(1, $pageNumber * $notesPerPage, $notesPerPage));
|
||||
//$result = $database->get_all("SELECT * FROM pool_images WHERE pool_id=?", array($poolID));
|
||||
$result = $database->execute(
|
||||
"SELECT DISTINCT image_id".
|
||||
"FROM notes ".
|
||||
"WHERE enable = ? ".
|
||||
"ORDER BY date DESC LIMIT ?, ?",
|
||||
[1, $pageNumber * $notesPerPage, $notesPerPage]
|
||||
);
|
||||
|
||||
$totalPages = ceil($database->get_one("SELECT COUNT(DISTINCT image_id) FROM notes") / $notesPerPage);
|
||||
$totalPages = ceil($database->get_one("SELECT COUNT(DISTINCT image_id) FROM notes") / $notesPerPage);
|
||||
|
||||
$images = array();
|
||||
while($row = $result->fetch()) {
|
||||
$images[] = array(Image::by_id($row["image_id"]));
|
||||
}
|
||||
$images = [];
|
||||
while ($row = $result->fetch()) {
|
||||
$images[] = [Image::by_id($row["image_id"])];
|
||||
}
|
||||
|
||||
$this->theme->display_note_list($images, $pageNumber + 1, $totalPages);
|
||||
}
|
||||
$this->theme->display_note_list($images, $pageNumber + 1, $totalPages);
|
||||
}
|
||||
|
||||
/**
|
||||
* HERE WE GET ALL NOTE REQUESTS
|
||||
*/
|
||||
private function get_notes_requests(PageRequestEvent $event) {
|
||||
global $config, $database;
|
||||
/**
|
||||
* HERE WE GET ALL NOTE REQUESTS
|
||||
*/
|
||||
private function get_notes_requests(PageRequestEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
|
||||
$pageNumber = $event->get_arg(1);
|
||||
if(is_null($pageNumber) || !is_numeric($pageNumber) || $pageNumber <= 0) {
|
||||
$pageNumber = 0;
|
||||
} else {
|
||||
$pageNumber--;
|
||||
}
|
||||
$pageNumber = $event->get_arg(1);
|
||||
if (is_null($pageNumber) || !is_numeric($pageNumber) || $pageNumber <= 0) {
|
||||
$pageNumber = 0;
|
||||
} else {
|
||||
$pageNumber--;
|
||||
}
|
||||
|
||||
$requestsPerPage = $config->get_int('notesRequestsPerPage');
|
||||
$requestsPerPage = $config->get_int('notesRequestsPerPage');
|
||||
|
||||
|
||||
//$result = $database->get_all("SELECT * FROM pool_images WHERE pool_id=?", array($poolID));
|
||||
//$result = $database->get_all("SELECT * FROM pool_images WHERE pool_id=?", array($poolID));
|
||||
|
||||
|
||||
$result = $database->execute("
|
||||
$result = $database->execute(
|
||||
"
|
||||
SELECT DISTINCT image_id
|
||||
FROM note_request
|
||||
ORDER BY date DESC LIMIT ?, ?",
|
||||
array($pageNumber * $requestsPerPage, $requestsPerPage));
|
||||
[$pageNumber * $requestsPerPage, $requestsPerPage]
|
||||
);
|
||||
|
||||
$totalPages = ceil($database->get_one("SELECT COUNT(*) FROM note_request") / $requestsPerPage);
|
||||
$totalPages = ceil($database->get_one("SELECT COUNT(*) FROM note_request") / $requestsPerPage);
|
||||
|
||||
$images = array();
|
||||
while($row = $result->fetch()) {
|
||||
$images[] = array(Image::by_id($row["image_id"]));
|
||||
}
|
||||
$images = [];
|
||||
while ($row = $result->fetch()) {
|
||||
$images[] = [Image::by_id($row["image_id"])];
|
||||
}
|
||||
|
||||
$this->theme->display_note_requests($images, $pageNumber + 1, $totalPages);
|
||||
}
|
||||
$this->theme->display_note_requests($images, $pageNumber + 1, $totalPages);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE ADD HISTORY TO TRACK THE CHANGES OF THE NOTES FOR THE IMAGES.
|
||||
*/
|
||||
private function add_history($noteEnable, $noteID, $imageID, $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText){
|
||||
global $user, $database;
|
||||
/*
|
||||
* HERE WE ADD HISTORY TO TRACK THE CHANGES OF THE NOTES FOR THE IMAGES.
|
||||
*/
|
||||
private function add_history($noteEnable, $noteID, $imageID, $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText)
|
||||
{
|
||||
global $user, $database;
|
||||
|
||||
$reviewID = $database->get_one("SELECT COUNT(*) FROM note_histories WHERE note_id = ?", array($noteID));
|
||||
$reviewID = $reviewID + 1;
|
||||
$reviewID = $database->get_one("SELECT COUNT(*) FROM note_histories WHERE note_id = ?", [$noteID]);
|
||||
$reviewID = $reviewID + 1;
|
||||
|
||||
$database->execute("
|
||||
$database->execute(
|
||||
"
|
||||
INSERT INTO note_histories (note_enable, note_id, review_id, image_id, user_id, user_ip, date, x1, y1, height, width, note)
|
||||
VALUES (?, ?, ?, ?, ?, ?, now(), ?, ?, ?, ?, ?)",
|
||||
array($noteEnable, $noteID, $reviewID, $imageID, $user->id, $_SERVER['REMOTE_ADDR'], $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText));
|
||||
}
|
||||
[$noteEnable, $noteID, $reviewID, $imageID, $user->id, $_SERVER['REMOTE_ADDR'], $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* HERE WE GET ALL HISTORIES.
|
||||
*/
|
||||
private function get_histories(PageRequestEvent $event){
|
||||
global $config, $database;
|
||||
/**
|
||||
* HERE WE GET ALL HISTORIES.
|
||||
*/
|
||||
private function get_histories(PageRequestEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
|
||||
$pageNumber = $event->get_arg(1);
|
||||
if (is_null($pageNumber) || !is_numeric($pageNumber) || $pageNumber <= 0) {
|
||||
$pageNumber = 0;
|
||||
} else {
|
||||
$pageNumber--;
|
||||
}
|
||||
$pageNumber = $event->get_arg(1);
|
||||
if (is_null($pageNumber) || !is_numeric($pageNumber) || $pageNumber <= 0) {
|
||||
$pageNumber = 0;
|
||||
} else {
|
||||
$pageNumber--;
|
||||
}
|
||||
|
||||
$historiesPerPage = $config->get_int('notesHistoriesPerPage');
|
||||
$historiesPerPage = $config->get_int('notesHistoriesPerPage');
|
||||
|
||||
//ORDER BY IMAGE & DATE
|
||||
$histories = $database->get_all("SELECT h.note_id, h.review_id, h.image_id, h.date, h.note, u.name AS user_name ".
|
||||
"FROM note_histories AS h ".
|
||||
"INNER JOIN users AS u ".
|
||||
"ON u.id = h.user_id ".
|
||||
"ORDER BY date DESC LIMIT ?, ?",
|
||||
array($pageNumber * $historiesPerPage, $historiesPerPage));
|
||||
//ORDER BY IMAGE & DATE
|
||||
$histories = $database->get_all(
|
||||
"SELECT h.note_id, h.review_id, h.image_id, h.date, h.note, u.name AS user_name ".
|
||||
"FROM note_histories AS h ".
|
||||
"INNER JOIN users AS u ".
|
||||
"ON u.id = h.user_id ".
|
||||
"ORDER BY date DESC LIMIT ?, ?",
|
||||
[$pageNumber * $historiesPerPage, $historiesPerPage]
|
||||
);
|
||||
|
||||
$totalPages = ceil($database->get_one("SELECT COUNT(*) FROM note_histories") / $historiesPerPage);
|
||||
$totalPages = ceil($database->get_one("SELECT COUNT(*) FROM note_histories") / $historiesPerPage);
|
||||
|
||||
$this->theme->display_histories($histories, $pageNumber + 1, $totalPages);
|
||||
}
|
||||
$this->theme->display_histories($histories, $pageNumber + 1, $totalPages);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* HERE WE THE HISTORY FOR A SPECIFIC NOTE.
|
||||
*/
|
||||
private function get_history(PageRequestEvent $event){
|
||||
global $config, $database;
|
||||
/**
|
||||
* HERE WE THE HISTORY FOR A SPECIFIC NOTE.
|
||||
*/
|
||||
private function get_history(PageRequestEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
|
||||
$noteID = $event->get_arg(1);
|
||||
$noteID = $event->get_arg(1);
|
||||
|
||||
$pageNumber = $event->get_arg(2);
|
||||
if (is_null($pageNumber) || !is_numeric($pageNumber) || $pageNumber <= 0) {
|
||||
$pageNumber = 0;
|
||||
} else {
|
||||
$pageNumber--;
|
||||
}
|
||||
$pageNumber = $event->get_arg(2);
|
||||
if (is_null($pageNumber) || !is_numeric($pageNumber) || $pageNumber <= 0) {
|
||||
$pageNumber = 0;
|
||||
} else {
|
||||
$pageNumber--;
|
||||
}
|
||||
|
||||
$historiesPerPage = $config->get_int('notesHistoriesPerPage');
|
||||
$historiesPerPage = $config->get_int('notesHistoriesPerPage');
|
||||
|
||||
$histories = $database->get_all("SELECT h.note_id, h.review_id, h.image_id, h.date, h.note, u.name AS user_name ".
|
||||
"FROM note_histories AS h ".
|
||||
"INNER JOIN users AS u ".
|
||||
"ON u.id = h.user_id ".
|
||||
"WHERE note_id = ? ".
|
||||
"ORDER BY date DESC LIMIT ?, ?",
|
||||
array($noteID, $pageNumber * $historiesPerPage, $historiesPerPage));
|
||||
$histories = $database->get_all(
|
||||
"SELECT h.note_id, h.review_id, h.image_id, h.date, h.note, u.name AS user_name ".
|
||||
"FROM note_histories AS h ".
|
||||
"INNER JOIN users AS u ".
|
||||
"ON u.id = h.user_id ".
|
||||
"WHERE note_id = ? ".
|
||||
"ORDER BY date DESC LIMIT ?, ?",
|
||||
[$noteID, $pageNumber * $historiesPerPage, $historiesPerPage]
|
||||
);
|
||||
|
||||
$totalPages = ceil($database->get_one("SELECT COUNT(*) FROM note_histories WHERE note_id = ?", array($noteID)) / $historiesPerPage);
|
||||
$totalPages = ceil($database->get_one("SELECT COUNT(*) FROM note_histories WHERE note_id = ?", [$noteID]) / $historiesPerPage);
|
||||
|
||||
$this->theme->display_history($histories, $pageNumber + 1, $totalPages);
|
||||
}
|
||||
$this->theme->display_history($histories, $pageNumber + 1, $totalPages);
|
||||
}
|
||||
|
||||
/**
|
||||
* HERE GO BACK IN HISTORY AND SET THE OLD NOTE. IF WAS REMOVED WE RE-ADD IT.
|
||||
*/
|
||||
private function revert_history(int $noteID, int $reviewID){
|
||||
global $database;
|
||||
/**
|
||||
* HERE GO BACK IN HISTORY AND SET THE OLD NOTE. IF WAS REMOVED WE RE-ADD IT.
|
||||
*/
|
||||
private function revert_history(int $noteID, int $reviewID)
|
||||
{
|
||||
global $database;
|
||||
|
||||
$history = $database->get_row("SELECT * FROM note_histories WHERE note_id = ? AND review_id = ?", array($noteID, $reviewID));
|
||||
$history = $database->get_row("SELECT * FROM note_histories WHERE note_id = ? AND review_id = ?", [$noteID, $reviewID]);
|
||||
|
||||
$noteEnable = $history['note_enable'];
|
||||
$noteID = $history['note_id'];
|
||||
$imageID = $history['image_id'];
|
||||
$noteX1 = $history['x1'];
|
||||
$noteY1 = $history['y1'];
|
||||
$noteHeight = $history['height'];
|
||||
$noteWidth = $history['width'];
|
||||
$noteText = $history['note'];
|
||||
$noteEnable = $history['note_enable'];
|
||||
$noteID = $history['note_id'];
|
||||
$imageID = $history['image_id'];
|
||||
$noteX1 = $history['x1'];
|
||||
$noteY1 = $history['y1'];
|
||||
$noteHeight = $history['height'];
|
||||
$noteWidth = $history['width'];
|
||||
$noteText = $history['note'];
|
||||
|
||||
$database->execute("UPDATE notes ".
|
||||
"SET enable = ?, x1 = ?, y1 = ?, height = ?, width = ?, note = ? ".
|
||||
"WHERE image_id = ? AND id = ?",
|
||||
array(1, $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText, $imageID, $noteID));
|
||||
$database->execute(
|
||||
"UPDATE notes ".
|
||||
"SET enable = ?, x1 = ?, y1 = ?, height = ?, width = ?, note = ? ".
|
||||
"WHERE image_id = ? AND id = ?",
|
||||
[1, $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText, $imageID, $noteID]
|
||||
);
|
||||
|
||||
$this->add_history($noteEnable, $noteID, $imageID, $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText);
|
||||
}
|
||||
$this->add_history($noteEnable, $noteID, $imageID, $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText);
|
||||
}
|
||||
}
|
||||
|
@@ -1,74 +1,81 @@
|
||||
<?php
|
||||
class NotesTheme extends Themelet {
|
||||
public function note_button($image_id) {
|
||||
return '
|
||||
class NotesTheme extends Themelet
|
||||
{
|
||||
public function note_button($image_id)
|
||||
{
|
||||
return '
|
||||
<!-- <a href="#" id="addnotelink" >Add a note</a> -->
|
||||
<form action="" method="">
|
||||
<input type="button" id="addnote" value="Add Note">
|
||||
<input type="hidden" name="image_id" value="'.$image_id.'">
|
||||
</form>
|
||||
';
|
||||
}
|
||||
public function request_button($image_id) {
|
||||
return make_form(make_link("note/add_request")) . '
|
||||
}
|
||||
public function request_button($image_id)
|
||||
{
|
||||
return make_form(make_link("note/add_request")) . '
|
||||
<input id="noterequest" type="submit" value="Add Note Request">
|
||||
<input type="hidden" name="image_id" value="'.$image_id.'">
|
||||
</form>
|
||||
';
|
||||
}
|
||||
public function nuke_notes_button($image_id) {
|
||||
return make_form(make_link("note/nuke_notes")) . '
|
||||
}
|
||||
public function nuke_notes_button($image_id)
|
||||
{
|
||||
return make_form(make_link("note/nuke_notes")) . '
|
||||
<input id="noterequest" type="submit" value="Nuke Notes" onclick="return confirm_action(\'Are you sure?\')">
|
||||
<input type="hidden" name="image_id" value="'.$image_id.'">
|
||||
</form>
|
||||
';
|
||||
}
|
||||
public function nuke_requests_button($image_id) {
|
||||
return make_form(make_link("note/nuke_requests")) . '
|
||||
}
|
||||
public function nuke_requests_button($image_id)
|
||||
{
|
||||
return make_form(make_link("note/nuke_requests")) . '
|
||||
<input id="noterequest" type="submit" value="Nuke Requests" onclick="return confirm_action()">
|
||||
<input type="hidden" name="image_id" value="'.$image_id.'">
|
||||
</form>
|
||||
';
|
||||
}
|
||||
}
|
||||
|
||||
public function search_notes_page(Page $page) { //IN DEVELOPMENT, NOT FULLY WORKING
|
||||
$html = '<form method="GET" action="'.make_link("post/list/note=").'">
|
||||
public function search_notes_page(Page $page)
|
||||
{ //IN DEVELOPMENT, NOT FULLY WORKING
|
||||
$html = '<form method="GET" action="'.make_link("post/list/note=").'">
|
||||
<input placeholder="Search Notes" type="text" name="search"/>
|
||||
<input type="submit" style="display: none;" value="Find"/>
|
||||
</form>';
|
||||
|
||||
$page->set_title(html_escape("Search Note"));
|
||||
$page->set_heading(html_escape("Search Note"));
|
||||
$page->add_block(new Block("Search Note", $html, "main", 10));
|
||||
}
|
||||
$page->set_title(html_escape("Search Note"));
|
||||
$page->set_heading(html_escape("Search Note"));
|
||||
$page->add_block(new Block("Search Note", $html, "main", 10));
|
||||
}
|
||||
|
||||
// check action POST on form
|
||||
public function display_note_system(Page $page, $image_id, $recovered_notes, $adminOptions) {
|
||||
$base_href = get_base_href();
|
||||
// check action POST on form
|
||||
public function display_note_system(Page $page, $image_id, $recovered_notes, $adminOptions)
|
||||
{
|
||||
$base_href = get_base_href();
|
||||
|
||||
$page->add_html_header("<script src='$base_href/ext/notes/lib/jquery.imgnotes-1.0.min.js' type='text/javascript'></script>");
|
||||
$page->add_html_header("<script src='$base_href/ext/notes/lib/jquery.imgareaselect-1.0.0-rc1.min.js' type='text/javascript'></script>");
|
||||
$page->add_html_header("<link rel='stylesheet' type='text/css' href='$base_href/ext/notes/lib/jquery.imgnotes-1.0.min.css' />");
|
||||
$page->add_html_header("<script src='$base_href/ext/notes/lib/jquery.imgnotes-1.0.min.js' type='text/javascript'></script>");
|
||||
$page->add_html_header("<script src='$base_href/ext/notes/lib/jquery.imgareaselect-1.0.0-rc1.min.js' type='text/javascript'></script>");
|
||||
$page->add_html_header("<link rel='stylesheet' type='text/css' href='$base_href/ext/notes/lib/jquery.imgnotes-1.0.min.css' />");
|
||||
|
||||
$to_json = array();
|
||||
foreach($recovered_notes as $note) {
|
||||
$parsedNote = $note["note"];
|
||||
$parsedNote = str_replace("\n", "\\n", $parsedNote);
|
||||
$parsedNote = str_replace("\r", "\\r", $parsedNote);
|
||||
$to_json = [];
|
||||
foreach ($recovered_notes as $note) {
|
||||
$parsedNote = $note["note"];
|
||||
$parsedNote = str_replace("\n", "\\n", $parsedNote);
|
||||
$parsedNote = str_replace("\r", "\\r", $parsedNote);
|
||||
|
||||
$to_json[] = array(
|
||||
'x1' => $note["x1"],
|
||||
'y1' => $note["y1"],
|
||||
'height' => $note["height"],
|
||||
'width' => $note["width"],
|
||||
'note' => $parsedNote,
|
||||
'note_id' => $note["id"],
|
||||
);
|
||||
}
|
||||
$to_json[] = [
|
||||
'x1' => $note["x1"],
|
||||
'y1' => $note["y1"],
|
||||
'height' => $note["height"],
|
||||
'width' => $note["width"],
|
||||
'note' => $parsedNote,
|
||||
'note_id' => $note["id"],
|
||||
];
|
||||
}
|
||||
|
||||
$html = "<script type='text/javascript'>notes = ".json_encode($to_json)."</script>";
|
||||
$html = "<script type='text/javascript'>notes = ".json_encode($to_json)."</script>";
|
||||
|
||||
$html .= "
|
||||
$html .= "
|
||||
<div id='noteform'>
|
||||
".make_form(make_link("note/add_note"))."
|
||||
<input type='hidden' name='image_id' value='".$image_id."' />
|
||||
@@ -112,8 +119,8 @@ class NotesTheme extends Themelet {
|
||||
</table>
|
||||
</form>";
|
||||
|
||||
if($adminOptions)
|
||||
$html .= "
|
||||
if ($adminOptions) {
|
||||
$html .= "
|
||||
".make_form(make_link("note/delete_note"))."
|
||||
<input type='hidden' name='image_id' value='".$image_id."' />
|
||||
<input type='hidden' name='note_id' value='' id='DeleteNoteNoteID' />
|
||||
@@ -124,119 +131,120 @@ class NotesTheme extends Themelet {
|
||||
</table>
|
||||
</form>
|
||||
";
|
||||
}
|
||||
|
||||
$html .= "</div>";
|
||||
$html .= "</div>";
|
||||
|
||||
$page->add_block(new Block(null, $html, "main", 1, 'note_system'));
|
||||
}
|
||||
$page->add_block(new Block(null, $html, "main", 1, 'note_system'));
|
||||
}
|
||||
|
||||
|
||||
public function display_note_list($images, $pageNumber, $totalPages) {
|
||||
global $page;
|
||||
$pool_images = '';
|
||||
foreach($images as $pair) {
|
||||
$image = $pair[0];
|
||||
public function display_note_list($images, $pageNumber, $totalPages)
|
||||
{
|
||||
global $page;
|
||||
$pool_images = '';
|
||||
foreach ($images as $pair) {
|
||||
$image = $pair[0];
|
||||
|
||||
$thumb_html = $this->build_thumb_html($image);
|
||||
$thumb_html = $this->build_thumb_html($image);
|
||||
|
||||
$pool_images .= '<span class="thumb">'.
|
||||
' <a href="$image_link">'.$thumb_html.'</a>'.
|
||||
'</span>';
|
||||
$pool_images .= '<span class="thumb">'.
|
||||
' <a href="$image_link">'.$thumb_html.'</a>'.
|
||||
'</span>';
|
||||
}
|
||||
$this->display_paginator($page, "note/list", null, $pageNumber, $totalPages);
|
||||
|
||||
$page->set_title("Notes");
|
||||
$page->set_heading("Notes");
|
||||
$page->add_block(new Block("Notes", $pool_images, "main", 20));
|
||||
}
|
||||
|
||||
}
|
||||
$this->display_paginator($page, "note/list", null, $pageNumber, $totalPages);
|
||||
public function display_note_requests($images, $pageNumber, $totalPages)
|
||||
{
|
||||
global $page;
|
||||
|
||||
$page->set_title("Notes");
|
||||
$page->set_heading("Notes");
|
||||
$page->add_block(new Block("Notes", $pool_images, "main", 20));
|
||||
}
|
||||
$pool_images = '';
|
||||
foreach ($images as $pair) {
|
||||
$image = $pair[0];
|
||||
|
||||
public function display_note_requests($images, $pageNumber, $totalPages) {
|
||||
global $page;
|
||||
$thumb_html = $this->build_thumb_html($image);
|
||||
|
||||
$pool_images = '';
|
||||
foreach($images as $pair) {
|
||||
$image = $pair[0];
|
||||
$pool_images .= '<span class="thumb">'.
|
||||
' <a href="$image_link">'.$thumb_html.'</a>'.
|
||||
'</span>';
|
||||
}
|
||||
$this->display_paginator($page, "requests/list", null, $pageNumber, $totalPages);
|
||||
|
||||
$thumb_html = $this->build_thumb_html($image);
|
||||
$page->set_title("Note Requests");
|
||||
$page->set_heading("Note Requests");
|
||||
$page->add_block(new Block("Note Requests", $pool_images, "main", 20));
|
||||
}
|
||||
|
||||
$pool_images .= '<span class="thumb">'.
|
||||
' <a href="$image_link">'.$thumb_html.'</a>'.
|
||||
'</span>';
|
||||
private function get_history($histories)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$html = "<table id='poolsList' class='zebra'>".
|
||||
"<thead><tr>".
|
||||
"<th>Image</th>".
|
||||
"<th>Note</th>".
|
||||
"<th>Body</th>".
|
||||
"<th>Updater</th>".
|
||||
"<th>Date</th>";
|
||||
|
||||
}
|
||||
$this->display_paginator($page, "requests/list", null, $pageNumber, $totalPages);
|
||||
if (!$user->is_anonymous()) {
|
||||
$html .= "<th>Action</th>";
|
||||
}
|
||||
|
||||
$page->set_title("Note Requests");
|
||||
$page->set_heading("Note Requests");
|
||||
$page->add_block(new Block("Note Requests", $pool_images, "main", 20));
|
||||
}
|
||||
$html .= "</tr></thead>".
|
||||
"<tbody>";
|
||||
|
||||
private function get_history($histories) {
|
||||
global $user;
|
||||
foreach ($histories as $history) {
|
||||
$image_link = "<a href='".make_link("post/view/".$history['image_id'])."'>".$history['image_id']."</a>";
|
||||
$history_link = "<a href='".make_link("note/history/".$history['note_id'])."'>".$history['note_id'].".".$history['review_id']."</a>";
|
||||
$user_link = "<a href='".make_link("user/".$history['user_name'])."'>".$history['user_name']."</a>";
|
||||
$revert_link = "<a href='".make_link("note/revert/".$history['note_id']."/".$history['review_id'])."'>Revert</a>";
|
||||
|
||||
$html = "<table id='poolsList' class='zebra'>".
|
||||
"<thead><tr>".
|
||||
"<th>Image</th>".
|
||||
"<th>Note</th>".
|
||||
"<th>Body</th>".
|
||||
"<th>Updater</th>".
|
||||
"<th>Date</th>";
|
||||
$html .= "<tr>".
|
||||
"<td>".$image_link."</td>".
|
||||
"<td>".$history_link."</td>".
|
||||
"<td style='text-align:left;'>".$history['note']."</td>".
|
||||
"<td>".$user_link."</td>".
|
||||
"<td>".autodate($history['date'])."</td>";
|
||||
|
||||
if(!$user->is_anonymous()){
|
||||
$html .= "<th>Action</th>";
|
||||
}
|
||||
if (!$user->is_anonymous()) {
|
||||
$html .= "<td>".$revert_link."</td>";
|
||||
}
|
||||
}
|
||||
|
||||
$html .= "</tr></thead>".
|
||||
"<tbody>";
|
||||
$html .= "</tr></tbody></table>";
|
||||
|
||||
foreach($histories as $history) {
|
||||
$image_link = "<a href='".make_link("post/view/".$history['image_id'])."'>".$history['image_id']."</a>";
|
||||
$history_link = "<a href='".make_link("note/history/".$history['note_id'])."'>".$history['note_id'].".".$history['review_id']."</a>";
|
||||
$user_link = "<a href='".make_link("user/".$history['user_name'])."'>".$history['user_name']."</a>";
|
||||
$revert_link = "<a href='".make_link("note/revert/".$history['note_id']."/".$history['review_id'])."'>Revert</a>";
|
||||
return $html;
|
||||
}
|
||||
|
||||
$html .= "<tr>".
|
||||
"<td>".$image_link."</td>".
|
||||
"<td>".$history_link."</td>".
|
||||
"<td style='text-align:left;'>".$history['note']."</td>".
|
||||
"<td>".$user_link."</td>".
|
||||
"<td>".autodate($history['date'])."</td>";
|
||||
public function display_histories($histories, $pageNumber, $totalPages)
|
||||
{
|
||||
global $page;
|
||||
|
||||
if(!$user->is_anonymous()){
|
||||
$html .= "<td>".$revert_link."</td>";
|
||||
}
|
||||
$html = $this->get_history($histories);
|
||||
|
||||
}
|
||||
$page->set_title("Note Updates");
|
||||
$page->set_heading("Note Updates");
|
||||
$page->add_block(new Block("Note Updates", $html, "main", 10));
|
||||
|
||||
$html .= "</tr></tbody></table>";
|
||||
$this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
public function display_history($histories, $pageNumber, $totalPages)
|
||||
{
|
||||
global $page;
|
||||
|
||||
public function display_histories($histories, $pageNumber, $totalPages) {
|
||||
global $page;
|
||||
$html = $this->get_history($histories);
|
||||
|
||||
$html = $this->get_history($histories);
|
||||
$page->set_title("Note History");
|
||||
$page->set_heading("Note History");
|
||||
$page->add_block(new Block("Note History", $html, "main", 10));
|
||||
|
||||
$page->set_title("Note Updates");
|
||||
$page->set_heading("Note Updates");
|
||||
$page->add_block(new Block("Note Updates", $html, "main", 10));
|
||||
|
||||
$this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages);
|
||||
}
|
||||
|
||||
public function display_history($histories, $pageNumber, $totalPages) {
|
||||
global $page;
|
||||
|
||||
$html = $this->get_history($histories);
|
||||
|
||||
$page->set_title("Note History");
|
||||
$page->set_heading("Note History");
|
||||
$page->add_block(new Block("Note History", $html, "main", 10));
|
||||
|
||||
$this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages);
|
||||
}
|
||||
$this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user