Skip to content
Browse files

added question for newVote

  • Loading branch information...
1 parent 6bec88d commit e2c5cf5e04e6c78fec546754a00cf3c3cf338fbd @DerWaldschrat committed
View
8 User/login.php
@@ -6,6 +6,8 @@
require IN . "validator" . PHP_EX;
require IN . "mapper" . PHP_EX;
require IN . "hasher" . PHP_EX;
+ini_set("log_errors", 1);
+ini_set("error_log", "log/log.txt");
post(function () {
global $crypt;
@@ -14,10 +16,10 @@
$db = db();
$oldPw = $userIn->passwort;
$userIn->passwort = hashme($userIn->passwort, $userIn->nickname);
- $st = $db->prepare("SELECT userid, email, vorname, nachname, passwort, profile, cat, rights, galeria FROM " . USER . " WHERE nickname = ?");
+ $st = $db->prepare("SELECT userid, email, vorname, nachname, passwort, profile, cat, rights, galeria, new_vote FROM " . USER . " WHERE nickname = ?");
$st->bind_param("s", $userIn->nickname);
$user = new stdClass();
- $st->bind_result($user->userid, $user->email, $user->vorname, $user->nachname, $user->passwort, $user->profile, $user->cat, $user->rights, $user->galeria);
+ $st->bind_result($user->userid, $user->email, $user->vorname, $user->nachname, $user->passwort, $user->profile, $user->cat, $user->rights, $user->galeria, $user->new_vote);
if ($st->execute()) {
$st->store_result();
if ($st->num_rows === 1) {
@@ -48,7 +50,7 @@
file_put_contents(IN . ".htpasswd", $file);
//sleep(1);*/
$_SESSTION["user"] = array();
- $toSet = array("userid", "email", "vorname", "nachname", "profile", "cat", "rights", "galeria", "nickhash");
+ $toSet = array("userid", "email", "vorname", "nachname", "profile", "cat", "rights", "galeria", "nickhash", "new_vote");
foreach($toSet as $field) {
$_SESSION["user"][$field] = $user->$field;
}
View
19 User/newVote.php
@@ -0,0 +1,19 @@
+<?php
+define("__EXEC", true);
+define("IN", "../");
+define("PHP_EX", ".php");
+
+require IN . "coreconfig" . PHP_EX;
+require IN . "mapper" . PHP_EX;
+require IN . "validator" . PHP_EX;
+if(isLoggedin(2)) {
+ post(function () {
+ $body = bodyAsJSON();
+ if (isset($body->new_vote) && is_numeric($body->new_vote) && userField("new_vote") == 0) {
+ setUserField("new_vote", $body->new_vote);
+ } else {
+ h404();
+ }
+ });
+}
+?>
View
6 design/index.php
@@ -32,6 +32,12 @@
?>
window.ROOT = "http://localhost/abi/";
window.WRITEMODE = <?php echo WRITEMODE === true ? "true" : "false"; ?>;
+// fix console
+if (!window.console) {
+ window.console = {
+ log: function () {}
+ }
+}
window.Messages = {
loginFail: "Der Login ist fehlgeschlagen. Bitte probiere es mit einem anderen Benutzernamen oder einem anderem Passwort!",
registrationFail: "Bei deiner Registrierung ist leider ein Fehler aufgetreten. Überprüfe bitte deine Daten und versuche es bitte noch einmal!",
View
6 design/index.production.php
@@ -42,6 +42,12 @@
}
?>
window.WRITEMODE = <?php echo WRITEMODE === true ? "true" : "false"; ?>;
+// fix console
+if (!window.console) {
+ window.console = {
+ log: function () {}
+ }
+}
window.Messages = {
loginFail: "Der Login ist fehlgeschlagen. Bitte probiere es mit einem anderen Benutzernamen oder einem anderem Passwort!",
registrationFail: "Bei deiner Registrierung ist leider ein Fehler aufgetreten. Überprüfe bitte deine Daten und versuche es bitte noch einmal!",
View
5 design/main.css
@@ -65,6 +65,11 @@ ul {
.commentToUser:after {
content: " > ";
}
+@media (max-width: 768px), (max-device-width: 768px) {
+ .affix {
+ position: static;
+ }
+}
#initialOverlay {
opacity: 1;
z-index: 1000;
View
5 design/main.less
@@ -50,6 +50,11 @@ ul {
content: " > ";
}
}
+@media (max-width: 768px), (max-device-width: 768px) {
+ .affix {
+ position: static;
+ }
+}
@import "startscreen.less";
@import "widgets.less";
View
35 jstree/app/app.js
@@ -2,12 +2,6 @@
* This is the app file which will be used for the rest of the app excepts from the __faster-object
*/
-// fix console
-if (!console) {
- window.console = {
- log: function () {}
- }
-}
steal("jstree/jquery", "jstree/lodash").then("jstree/backbone", "jstree/bootstrap").then(function () {
//window.WEB_SOCKET_SWF_LOCATION = "jstree/socket.io/WebSocketMain.swf";
var getValue = function(object, prop) {
@@ -257,6 +251,7 @@ steal("jstree/jquery", "jstree/lodash").then("jstree/backbone", "jstree/bootstra
this.on("__history", function () {
Backbone.history.start();
})
+ this.showNewVoteMessage();
// delete the raw user data
delete window.__User;
// delete the faster object
@@ -410,9 +405,35 @@ steal("jstree/jquery", "jstree/lodash").then("jstree/backbone", "jstree/bootstra
releaseBackgroundProcess: release
}
})());
+ // Disable feature for the moment
+ Abi.App.showNewVoteMessage = function () {
+ return;
+ if (Abi.App.user.rights() <= 1) return;
+ var vote = Abi.App.user.get("new_vote");
+ if (vote == 0) {
+ var handle = function (value) {
+ $("#voteAlert").remove();
+ var model = new Abi.Model.Base({
+ new_vote: value
+ }).save({},{
+ url: ROOT + "User/newVote.php",
+ error: function () {
+ alert("Speichern fehlgeschlagen!");
+ }
+ })
+ }
+ $("#head").after("<div class='alert alert-block' id='voteAlert'><h4>Bitte genau überlegen:</h4>Möchtest du, dass nochmal ein neues Motto für die Abizeitung gewählt wird? <button type='button' class='btn btn-warning yes' onclick='Abi.App.demandNewVote();'>Ja</button> <button type='button' class='btn btn-warning no' onclick='Abi.App.refuseNewVote();'>Nein</div>")
+ this.refuseNewVote = function () {
+ handle(1);
+ }
+ this.demandNewVote = function () {
+ handle(2);
+ }
+ }
+ };
window.Abi = Abi;
-}).then("jstree/app/models", "jstree/app/fileupload").then("jstree/jquery/ui", "jstree/jquery/ui/ui.css")
+}).then("jstree/app/models", "jstree/app/fileupload").then("jstree/jquery/ui/ui.js", "jstree/jquery/ui/ui.css")
// Select2 loaded
.then("jstree/select2", "jstree/select2/select2.css")
.then("jstree/app/views", "jstree/app/messages", "jstree/jquery/ui/localize.js")
View
58 jstree/app/views/views.js
@@ -76,7 +76,7 @@
}
}),
// A bad but working solution
- width: "220px"
+ width: "220px"
}).each(function () {
var $this = $(this)
, val = self.model.get($this.attr("id"))
@@ -428,8 +428,8 @@
/**
* @class View.AutocompleteUser
- */
- /* Abi.View.AutocompleteUser = Abi.View.Base.extend({
+ *//*
+ Abi.View.AutocompleteUser = Abi.View.Base.extend({
initialize: function (options) {
this.$el.data("real-value", -1).autocomplete({
source: _.bind(this.source, this)
@@ -457,7 +457,7 @@
source: function (request, response) {
var term = request.term.toLowerCase();
response(this.collection.filter(function (model) {
- var label = model.label.toLowerCase();
+ var label = model.text.toLowerCase();
// We need to be very fast
if (term === label) return true;
return label.indexOf(term) > -1;
@@ -484,11 +484,57 @@
}
}
});
- */
+
/**
* @View.AutocompleteUser.select2
* Try to reimplement
* */
+ /*Abi.View.AutocompleteUser = Abi.View.Base.extend({
+ events: {
+ change: "change"
+ },
+ initialize: function (options) {
+ var self = this
+ // Hide the original formField
+ this.$el.css("display", "none").select2({
+ initSelection: function (element, callback) {
+ console.log(arguments);
+ callback();
+ },
+ // The search function
+ query: _.bind(this.query, this),
+ placeholder: "Wähle einen Schüler...",
+ allowClear: true,
+ // A bad but working solution
+ width: "220px"
+ })
+ if (options.startid && options.startid !== "" && (options.startid + "") !== "0") {
+ //this.$el.select2("val", this.collection.get(options.startid));
+ }
+ },
+ query: function (request) {
+ var term = request.term.toLowerCase();
+ request.callback({
+ results: this.collection.filter(function (model) {
+ var label = model.text.toLowerCase();
+ // We need to be very fast
+ if (term === label) return true;
+ return label.indexOf(term) > -1;
+ })
+ });
+ },
+ value: function () {
+ return this.$el.select2("val");
+ },
+ change: function () {
+ this.trigger("selected", this.$el.select2("val"));
+ },
+ initSelection: function () {
+ console.log(arguments);
+ }
+ })*/
+ /**
+ Old version of AutocompleteUser*/
Abi.View.AutocompleteUser = Abi.View.Base.extend({
events: {
change: "change"
@@ -525,7 +571,7 @@
change: function () {
this.trigger("selected", this.$el.select2("val"));
}
- })
+ })/**/
/**
* @class View.Award
View
BIN jstree/jquery-ui-1.9.0.custom.zip
Binary file not shown.
View
3 session.php
@@ -20,4 +20,7 @@ function isLoggedin($required = 0) {
function userField($field) {
return $_SESSION["user"][$field];
}
+function setUserField($field, $value) {
+ $_SESSION["user"][$field] = $value;
+}
?>
View
3 sql/user.table.sql
@@ -7,4 +7,5 @@ CREATE TABLE abi_user (
vorname VARCHAR(60),
nachname VARCHAR(60),
passwort VARCHAR(140)
-)
+);
+ALTER TABLE abi_user ADD column new_vote TINYINT NOT NULL DEFAULT 0;

0 comments on commit e2c5cf5

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