Skip to content
Browse files

users with more rights now can delete awards

  • Loading branch information...
1 parent 36d0604 commit a81c7b781891ee5008e71ea9bd8bb910f87cb91e @DerWaldschrat committed Sep 23, 2012
Showing with 60 additions and 2 deletions.
  1. +35 −0 Award/index.php
  2. +1 −1 Galeria/index.php
  3. +24 −1 jstree/app/views/views.js
View
35 Award/index.php
@@ -93,6 +93,41 @@
fail("awardSaveFail");
}
});
+
+ // Delete awards, only allowed level 3-members
+ if (isLoggedin(3)) {
+ delete(function () {
+ $q = $_SERVER["QUERY_STRING"];
+ $category = null;
+ if (preg_match("#^[0-9]+$#", $q) == 1) {
+ $db = db();
+ $st = $db->prepare("SELECT categoryid FROM " . AWARD . " WHERE awardid = ?");
+ $st->bind_param("i", $q);
+ $st->bind_result($category);
+ $st->execute();
+ $st->store_result();
+ if ($st->num_rows == 1) {
+ $st->fetch();
+ $st->close();
+ $st = $db->prepare("DELETE FROM " . CATEGORY . " WHERE categoryid = ?");
+ $st->bind_param("i", $category);
+ if (exQuery($st)) {
+ $st->close();
+ $st = $db->prepare("DELETE FROM " . AWARD . " WHERE categoryid = ?");
+ $st->bind_param("i", $category);
+ exQuery($st);
+ } else {
+ fail("awardDeleteFail" . $category);
+ }
+ } else {
+ fail("awardDeleteFail2");
+ }
+ } else {
+ fail("awardDeleteFail1");
+ }
+ });
+ }
+
} else {
h404();
}
View
2 Galeria/index.php
@@ -1,5 +1,5 @@
<?php
-// Hier kommt eigentlich die Überprüfung herein, wer welche Galerie anschauen kann
+// Hier kommt eigentlich die Überprüfung herein, wer welche Galerie anschauen kann
define("__EXEC", true);
define("IN", "../");
define("PHP_EX", ".php");
View
25 jstree/app/views/views.js
@@ -530,6 +530,22 @@
this._items[item.cid] = item;
this.table.append(item.el);
},
+ deleteAwardItem: function (event) {
+ var $target = $(event.target)
+ , cid = $target.attr("data-delete")
+ , view = this._items[cid]
+ , model = view.model
+ if (confirm("Willst du den Award \"" + model.escape("title") + "\" wirklich löschen?")) {
+ model.on("destroy", function (model) {
+ model.off()
+ view.remove()
+ }, null)
+ .destroy({
+ wait: true
+ })
+ }
+
+ },
events: {
"submit #createNewAward": function () {
var $title = this.$("#awardTitle"),model = new Abi.Model.Award({
@@ -539,7 +555,8 @@
$title.val("");
model.on("sync", this.add, this).save();
return false;
- }
+ },
+ "click .deleteAwardItem": "deleteAwardItem"
}
});
/**
@@ -579,6 +596,12 @@
//
this.maleAuto.on("selected", this.changeMale, this).value(this.model.get("maleid"));
this.femaleAuto.on("selected",this.changeFemale, this).value(this.model.get("femaleid"));
+
+ // Add award deletion for users with more rights
+ if (App.user.rights() >= 3) {
+ this.$middle.append("<span class='close deleteAwardItem' data-delete='" + this.cid + "'>&times;</span>");
+ }
+
this.$el.append(this.cells);
},
changeMale: function (id) {

0 comments on commit a81c7b7

Please sign in to comment.
Something went wrong with that request. Please try again.