diff --git a/action.php b/action.php index f7ed372..a554ac6 100644 --- a/action.php +++ b/action.php @@ -3,7 +3,6 @@ /** * Make things happen when buttons are pressed and forms submitted. */ - require_once __DIR__ . "/required.php"; if ($VARS['action'] !== "signout") { @@ -27,6 +26,52 @@ function returnToSender($msg, $arg = "") { } switch ($VARS['action']) { + case "editpub": + $insert = true; + if (is_empty($VARS['pubid'])) { + $insert = true; + } else { + if ($database->has('publications', ['pubid' => $VARS['pubid']])) { + $insert = false; + } else { + returnToSender("invalid_pubid"); + } + } + if (is_empty($VARS['name'])) { + returnToSender('invalid_parameters'); + } + if (!is_numeric($VARS['columns'])) { + returnToSender('invalid_parameters'); + } + if (!$database->has('pub_styles', ["styleid" => $VARS['style']])) { + returnToSender('invalid_parameters'); + } + if (!$database->has('pub_permissions', ["permid" => $VARS['perm']])) { + returnToSender('invalid_parameters'); + } + + $data = [ + 'pubname' => $VARS['name'], + 'pubdate' => date("Y-m-d H:i:s"), + 'styleid' => $VARS['style'], + 'columns' => $VARS['columns'], + 'permid' => $VARS['perm'] + ]; + + if ($insert) { + $data['uid'] = $_SESSION['uid']; + $database->insert('publications', $data); + } else { + $database->update('publications', $data, ['pubid' => $VARS['pubid']]); + } + + returnToSender("pub_saved"); + case "deletepub": + if ($database->has('publications', ['pubid' => $VARS['pubid']])) { + $database->delete('publications', ['pubid' => $VARS['pubid']]); + returnToSender("pub_deleted"); + } + returnToSender("invalid_parameters"); case "signout": session_destroy(); header('Location: index.php'); diff --git a/lang/en_us.php b/lang/en_us.php index 0c69d14..048537b 100644 --- a/lang/en_us.php +++ b/lang/en_us.php @@ -25,4 +25,23 @@ define("STRINGS", [ "login server user data error" => "The login server refused to provide account information. Try again or contact technical support.", "captcha error" => "There was a problem with the CAPTCHA (robot test). Try again.", "home" => "Home", + "new publication" => "New Publication", + "actions" => "Actions", + "name" => "Name", + "date" => "Date", + "author" => "Author", + "style" => "Style", + "columns" => "Columns", + "visibility" => "Visibility", + "adding publication" => "Adding Publication", + "cloning publication" => "Copying {opub} {npub}", + "editing publication" => "Editing {pub}", + "placeholder name" => "", + "content" => "Content", + "edit" => "Edit", + "clone" => "Clone", + "publication saved" => "Publication saved.", + "publication deleted" => "Publication deleted.", + "invalid pubid" => "Invalid publication ID.", + "mailing lists" => "Mailing Lists" ]); \ No newline at end of file diff --git a/lang/messages.php b/lang/messages.php index 8ac0b7a..4128300 100644 --- a/lang/messages.php +++ b/lang/messages.php @@ -12,5 +12,17 @@ define("MESSAGES", [ "404_error" => [ "string" => "page not found", "type" => "info" - ] + ], + "pub_saved" => [ + "string" => "publication saved", + "type" => "success" + ], + "pub_deleted" => [ + "string" => "publication deleted", + "type" => "success" + ], + "invalid_pubid" => [ + "string" => "invalid pubid", + "type" => "danger" + ], ]); diff --git a/lib/getpubtable.php b/lib/getpubtable.php index 1fdcb87..88e1aea 100644 --- a/lib/getpubtable.php +++ b/lib/getpubtable.php @@ -1,6 +1,7 @@ select('publications', [ 'stylename', 'columns', 'permname', - 'permid' + 'publications.permid' ], $where); + $out['status'] = "OK"; if ($filter) { $recordsFiltered = $database->count('publications', [ @@ -88,6 +90,7 @@ $usercache = []; for ($i = 0; $i < count($pubs); $i++) { $pubs[$i]["editbtn"] = ' ' . lang("edit", false) . ''; $pubs[$i]["clonebtn"] = ' ' . lang("clone", false) . ''; + $pubs[$i]["pubdate"] = date(DATETIME_FORMAT, strtotime($pubs[$i]["pubdate"])); if (is_null($pubs[$i]['uid'])) { $pubs[$i]["username"] = ""; } else { diff --git a/pages.php b/pages.php index 3565641..86c2918 100644 --- a/pages.php +++ b/pages.php @@ -22,6 +22,24 @@ define("PAGES", [ "static/js/editpub.js" ], ], + "content" => [ + "title" => "content", + "navbar" => true, + "icon" => "paragraph", + ], + "maillist" => [ + "title" => "mailing lists", + "navbar" => true, + "icon" => "envelope", + "styles" => [ + "static/css/datatables.min.css", + "static/css/tables.css" + ], + "scripts" => [ + "static/js/datatables.min.js", + "static/js/maillist.js" + ], + ], "404" => [ "title" => "404 error" ] diff --git a/pages/content.php b/pages/content.php new file mode 100644 index 0000000..e69de29 diff --git a/pages/editpub.php b/pages/editpub.php index 9a1eb8d..f87d6e5 100644 --- a/pages/editpub.php +++ b/pages/editpub.php @@ -1 +1,130 @@ -