diff --git a/homepage/participo/config/participo.php b/homepage/participo/config/participo.php
index d3b7012..33887f9 100644
--- a/homepage/participo/config/participo.php
+++ b/homepage/participo/config/participo.php
@@ -5,4 +5,8 @@ $config['basePath'] = "/users/cwsvjudo/www";
$config['baseUrl'] = "http://cwsvjudo.bplaced.net";
$config['ressourceUrl'] = "http://cwsvjudo.bplaced.net/ressourcen";
+setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
+set_include_path(get_include_path() . PATH_SEPARATOR . "./lib/");
+set_include_path(get_include_path() . PATH_SEPARATOR . $config['basePath']."/ressourcen/");
+
?>
diff --git a/homepage/participo/index.php b/homepage/participo/index.php
index 27490eb..2b22f0a 100644
--- a/homepage/participo/index.php
+++ b/homepage/participo/index.php
@@ -1,19 +1,13 @@
@@ -80,7 +74,7 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
".
diff --git a/homepage/participo/infoZettel.php b/homepage/participo/infoZettel.php
index b4e9bae..2032553 100644
--- a/homepage/participo/infoZettel.php
+++ b/homepage/participo/infoZettel.php
@@ -1,9 +1,7 @@
['value'=>$loginName, 'data_type'=>PDO::PARAM_STR]]
);
+ $user = $user[0];
// If there is no such user OR the password isn't valid the login fails
- if( empty($user || !password_verify( $password, $user['pwHash']) )){
+ if( empty($user) || !password_verify( $password, $user['pwHash'])){
sleep(5); // discourage brute force attacks
self::addMessage('error', "
Falsches Passwort oder LoginName
");
return false;
@@ -80,9 +84,9 @@ class participo{
$_SESSION = array(
'login' => true,
'user' => array(
- 'username' => $row['loginName'],
- 'userId' => $row['id'],
- 'userConfig' => json_decode($row['config'], true)
+ 'username' => $user['loginName'],
+ 'userId' => $user['id'],
+ 'userConfig' => json_decode($user['config'], true)
)
);
@@ -92,6 +96,44 @@ class participo{
self::addMessage('success', "
Anmeldung erfolgreich
");
return true;
}
+
+ /**
+ * Checks, if a user is an admin
+ *
+ * @param [type] $userId id of the user to check
+ * @retval true user with id $userId has attribute "isAdmin"
+ * @retval false otherwise
+ */
+ static function isUserAdmin($userId){
+ return self::hasUserAttribute( $userId, "isAdmin");
+ }
+
+ /**
+ * Checks, if a user as a certain attribute
+ *
+ * @param [type] $userId id of the user to check
+ * @param [type] $attributeName string name of the attribute to check
+ * @return boolean
+ */
+ static public function hasUserAttribute($userId, $attributeName){
+ // sqlQuery: Select the user if it has the given attribute
+ $query = <<
userAttributes`.userId, `wkParticipo_userAttributes`.name
+FROM `wkParticipo_user<=>userAttributes` LEFT JOIN `wkParticipo_userAttributes`
+ON `wkParticipo_user<=>userAttributes`.`attributeId` = `wkParticipo_userAttributes`.`id`
+WHERE `wkParticipo_userAttributes`.name = :attributeName AND userId=:userId;
+SQL;
+ $params = array(
+ ':userId' => array('value'=>$userId, 'data_type'=>PDO::PARAM_INT),
+ ':attributeName' => array('value'=>$attributeName, 'data_type'=>PDO::PARAM_STR)
+ );
+ $attributedUsers = dbConnector::query($query, $params);
+ // Since the id should be unique, there should only be one result this is just for dealing with empty arrays
+ foreach($attributedUsers as $u)
+ if($u['userId']==$userId)
+ return true;
+ return false;
+ }
}
/**
@@ -310,6 +352,9 @@ function loadMarkdownFile($fileName){
function logLoginsToJsonFile($userName, $fileName="lastLogins.json"){
try{
$lastLogins = json_decode(file_get_contents($fileName), true);
+ if ($lastLogins == NULL){
+ return;
+ }
if(!array_key_exists($userName, $lastLogins))
$lastLogins[$userName] = [];
if(!array_key_exists('lastLogins', $lastLogins[$userName]))
@@ -340,7 +385,7 @@ class dbConnector{
/// ':userId' => array('value'=>$anUserId, 'data_type'=>PDO::PARAM_INT),
/// ':attributeId'=> array('value'=>$anAttributeId, 'data_type'=>PDO::PARAM_INT) )
/// @param $someOption
- function query($aQueryString, $aBindArray = array(), $someOptions = array()){
+ public static function query($aQueryString, $aBindArray = array(), $someOptions = array()){
// Standardbelegungen
if( empty($someOptions['dbCharset' ]) ) $someOptions['dbCharset' ] = "ISO-8859-1";
if( empty($someOptions['outCharset']) ) $someOptions['outCharset'] = "UTF-8";
diff --git a/homepage/participo/login.php b/homepage/participo/login.php
index 9d12351..c3bf93a 100644
--- a/homepage/participo/login.php
+++ b/homepage/participo/login.php
@@ -1,9 +1,7 @@
4. Kyu - orange-grĂ¼n
+
+ Nage-no-kata
+