...
 
Commits (4)
......@@ -102,7 +102,7 @@ switch ($function) {
}
}
else {
$code = "Something went wrong while creating your User";
$code = User::getError();
}
}
else {
......@@ -158,6 +158,10 @@ switch ($function) {
"email",
""
);
$avatar = definePost(
'avatar',
""
);
if (Session::isLoggedIn()) {
if (User::exist($id)) {
$user = User::get($id);
......@@ -197,6 +201,17 @@ switch ($function) {
$code .= User::getError();
}
}
if ($avatar != "") {
if ($user->setAvatar(
"base64",
$avatar
)) {
$code .= "Changed avatar.";
}
else {
$code .= "Fehler";
}
}
}
else {
$status = false;
......@@ -210,7 +225,7 @@ switch ($function) {
break;
case "editAcp":
$id = definePost(
"id",
"user_id",
0
);
$username = definePost(
......@@ -231,7 +246,11 @@ switch ($function) {
);
$active = definePost(
"user_active",
""
null
);
$groups = definePost(
"groups",
array ()
);
if (Session::isLoggedIn()) {
if (User::exist($id)) {
......@@ -257,21 +276,24 @@ switch ($function) {
$code .= "Passwords not equals. ";
}
}
if ($active !== "") {
if ($active == "true") {
if ($active !== null) {
if ($active == "true" || $active) {
if (!$user->getActive()) {
$user->setActive(true);
if ($user->setActive(true)) {
$code .= "Benutzer wurde aktiviert";
}
else {
$status = false;
$code .= "Benutzer konnte nicht aktiviert werden";
}
}
}
elseif ($active == "false") {
elseif ($active == "false" || !$active) {
if ($user->getActive()) {
$user->setActive(false);
}
}
$code .= print_r(
$active,
true
);
}
if ($email != $user->getEmail()) {
if ($user->setEmail($email)) {
......@@ -282,6 +304,40 @@ switch ($function) {
$code .= User::getError();
}
}
//Routine Groups
if (is_array($groups)) {
$user_groups = $user->getGroups();
foreach ($user_groups as $item) {
if ($item instanceof Group) {
if (array_search(
$item->getID(),
$groups
) === false) {
$user->removeGroup($item);
$code .= "<p>Die Gruppe " . $item->getName() . " wurde entfernt.</p>";
}
else {
unset(
$groups[ array_search(
$item->getID(),
$groups
) ]
);
}
}
}
foreach ($groups as $item) {
$group = Group::get($item);
if ($user->addGroup($group)) {
$code .= "<p>Die Gruppe " . $group->getName() . " wurde hinzugefügt.</p>";
}
else {
$code .= "<p>Es gab einen Fehler beim hinzfügen der Gruppe " . $group->getName() . "</p>";
$status = false;
}
}
}
}
else {
$status = false;
......@@ -574,6 +630,14 @@ switch ($function) {
$code = "Bitte geben Sie einen Namen an";
}
break;
case 'getOwnUserID':
if (Session::isLoggedIn()) {
$status = true;
$code = User::getSession()->getID();
}
$status = false;
$code = "";
break;
default:
/*$dom = new \DOMDocument(
"1.0",
......
......@@ -19,6 +19,8 @@ use Iko\CMS\Init;
use Iko\CMS\Parser;
use Iko\CMS\Template;
use function Iko\defineGet;
use Iko\Language\Key;
use Iko\Language\Language;
use Iko\Module;
use Iko\User;
use Iko\Core;
......@@ -231,12 +233,12 @@ class ACP extends Init
$groups_entities = "";
foreach ($groups as $group) {
if ($group instanceof iGroup) {
if (User::getSession()->hasPermission("iko.group.delete") && !$group->hasPermission(
"iko.group.delete.restricted"
if (User::getSession()->hasPermission("iko.user.groups.delete") && !$group->hasPermission(
"iko.user.groups.delete.restricted"
) && array_search(
$group,
User::getSession()->getGroups()
) !== false) {
) === false) {
$edit = ' <a href="javascript:iko.group.delete(' . $group->getID(
) . ');" class="btn btn-danger btn-sm">Delete</a>';
}
......@@ -335,7 +337,25 @@ class ACP extends Init
$select_group .= '>' . $item->getName() . '</option>';
}
}
$members = $group->getMembers();
$member_entry = "";
foreach ($members as $member) {
if ($member instanceof iUser) {
$member_entry .= Entity::returnEntity(
"acp.group.edit.user.entry",
array (
"user_name" => $member->getName(),
"edit_links" => '<a href="' . Core::Link(
array (
"module" => "admin",
"sub" => "user",
"page" => "edit",
"id" => $member->getID())
) . '" class="btn btn-primary">Edit</a>'),
"user"
);
}
}
$this->template->content = Entity::returnEntity(
"acp.group.edit",
array (
......@@ -343,7 +363,8 @@ class ACP extends Init
"edit_group_id" => $group->getID(),
"groupname_disabled" => $name_disabled,
"parent_groups_disabled" => $parent_disabled,
"select_parent_groups" => $select_group),
"select_parent_groups" => $select_group,
"member_list" => $member_entry),
"user"
);
}
......@@ -370,23 +391,25 @@ class ACP extends Init
"module" => "admin",
"sub" => "user",
"page" => "all")
) . '" class="btn btn-primary">All User</a> <a href="' . Core::Link(
) . '" class="btn btn-primary">' . Key::getString("iko.user.acp.all") . '</a> <a href="' . Core::Link(
array (
"module" => "admin",
"sub" => "user",
"page" => "create")
) . '" class="btn btn-danger">Create User</a><br><br><a href="' . Core::Link(
) . '" class="btn btn-danger">' . Key::getString(
"iko.user.acp.create"
) . '</a><br><br><a href="' . Core::Link(
array (
"module" => "admin",
"sub" => "user",
"page" => "allGroups",
"extra" => "test")
) . '" class="btn btn-primary">All Groups</a> <a href="' . Core::Link(
) . '" class="btn btn-primary">' . Key::getString("iko.user.group.acp.all") . '</a> <a href="' . Core::Link(
array (
"module" => "admin",
"sub" => "user",
"page" => "createGroup",)
) . '" class="btn btn-danger">Create Group</a>';
) . '" class="btn btn-danger">' . Key::getString("iko.user.group.acp.create") . '</a>';
$template->content = Entity::returnEntity(
"default",
array (
......
......@@ -59,12 +59,42 @@ class CMS
{
$this->module = Module::get( "user" );
$this->template = Template::getInstance();
$this->template->module_js = '<script src="' . $this->module->getPath() . 'user.js"></script>';
$this->template->js = '<script src="' . $this->module->getPath() . 'user.js"></script>';
}
function list ()
{
$users = User::getAll();
$users_online_class = User::searches(array (User::ONLINE_STATUS => 1));
$users_online = array ();
$rang = 0;
foreach ($users_online_class as $user) {
if ($user instanceof iUser) {
$rang = $user->getDisplayGroup()->getRang();
if (!isset($users_online[ $rang ]) || !is_array($users_online[ $rang ])) {
$users_online[ $rang ] = array ();
}
array_push(
$users_online[ $rang ],
$user
);
}
}
$users_offline_class = User::searches(array (User::ONLINE_STATUS => 0));
$users_offline = array ();
foreach ($users_offline_class as $user) {
if ($user instanceof iUser) {
$rang = $user->getDisplayGroup()->getRang();
if (!isset($users_offline[ $rang ]) || !is_array($users_offline[ $rang ])) {
$users_offline[ $rang ] = array ();
}
array_push(
$users_offline[ $rang ],
$user
);
}
}
krsort($users_online);
krsort($users_offline);
$string = "";
Template::addBreadcrumb(
"List",
......@@ -73,31 +103,61 @@ class CMS
"page" => "list")
);
Template::addSidebar();
$user_string = "";
foreach ( $users as $user ) {
$online_status = ( $user->getOnlineStatus() ) ? "online" : "offline";
$user_string .= Entity::returnEntity(
"user-entries",
array (
"user_name" => $user->getName(),
"user_avatar" => $user->getAvatar(),
"group" => $user->getDisplayGroup()->getStyle(),
"user_link" => Core::Link(
array (
"module" => "user",
"page" => "view",
"id" => $user->getID() ),
"id"
),
"user_online_status" => $online_status ),
'user'
);
}
$user_string_online = "";
$user_string_offline = "";
foreach ($users_online as $rang) {
foreach ($rang as $user) {
$online_status = ($user->getOnlineStatus()) ? "online" : "offline";
$user_string_online .= Entity::returnEntity(
"user-entries",
array (
"user_name" => $user->getName(),
"user_avatar" => $user->getAvatar(),
"group" => $user->getDisplayGroup()->getStyle(),
"user_link" => Core::Link(
array (
"module" => "user",
"page" => "view",
"id" => $user->getID()),
"id"
),
"user_online_status" => $online_status),
'user'
);
}
}
foreach ($users_offline as $rang) {
foreach ($rang as $user) {
$online_status = ($user->getOnlineStatus()) ? "online" : "offline";
$user_string_offline .= Entity::returnEntity(
"user-entries",
array (
"user_name" => $user->getName(),
"user_avatar" => $user->getAvatar(),
"group" => $user->getDisplayGroup()->getStyle(),
"user_link" => Core::Link(
array (
"module" => "user",
"page" => "view",
"id" => $user->getID()),
"id"
),
"user_online_status" => $online_status),
'user'
);
}
}
$this->template->content = Entity::returnEntity(
"user-list",
array ( "user-entries" => $user_string ),
'user'
"user-list",
array ("user-entries" => $user_string_online),
'user'
);
$this->template->content .= Entity::returnEntity(
"user-list",
array ("user-entries" => $user_string_offline),
'user'
);
}
......@@ -194,6 +254,21 @@ class CMS
"content" => '<select name="language"><option value="english">English</option><option value="german">Deutsch</option></select>' ),
"user"
);
$this->template->css .= '<link rel="stylesheet" href="' . Core::getCorePath(
) . '/lib/croppie/croppie.css" type="text/css" >';
$this->template->js .= '<script src="' . Core::getCorePath() . '/lib/croppie/croppie.js"></script>';
$this->template->js .= '$uploadCrop = $(\'#upload-demo\').croppie({
enableExif: true,
viewport: {
width: 200,
height: 200,
},
boundary: {
width: 300,
height: 300
}
});
';
$this->template->content = Entity::returnEntity(
"own",
array (
......@@ -242,11 +317,11 @@ class CMS
);
}
else {
$this->user_list();
$this->list();
}
}
else {
$this->user_list();
$this->list();
}
}
......
<?php
/**
* Created by PhpStorm.
* User: Matze
* Date: 14.09.2018
* Time: 16:36
*/
namespace Iko\User\Extensions;
use Iko\Module;
class Blacklist
{
public static function checkMail ($name, $args, $pre)
{
if (isset($args["mail"])) {
$provider = explode(
"@",
$args["mail"]
)[1];
$blacklist = file_get_contents(Module::get("user")->getPath() . "classes/extensions/blacklist.txt");
$blacklist = explode(
PHP_EOL,
$blacklist
);
$status = true;
foreach ($blacklist as $item) {
if ($item == $provider) {
return false;
}
}
}
return true;
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -119,6 +119,7 @@ class Group extends Operators implements iGroup //Todo: Complete
return false;
}
/**
* Group constructor.
*
......
......@@ -38,16 +38,16 @@ class Center implements iCenter
public function getConversation (iOperators $operators)
{
// TODO: Implement get_conversation() method.
}
}
public function createConversation (iOperators $operators)
{
// TODO: Implement create_conversation() method.
}
}
public function deleteConversation (iOperators $operators)
{
// TODO: Implement delete_conversation() method.
}
}
}
\ No newline at end of file
......@@ -18,6 +18,7 @@
*/
namespace Iko\User\Permissions;
use Iko\Exception;
use Iko\Lib\Multiton\Cache\Mixed;
use Iko\Module;
use Iko\User\Permissions;
......@@ -28,8 +29,8 @@ class Value extends Mixed implements iValue
{
public static $cache = array ();
public static $cache_exist = array ();
public static $cache = array ();
public static $cache_exist = array ();
private static function checkBacktrace (Module $module)
{
......@@ -45,8 +46,8 @@ class Value extends Mixed implements iValue
if (count($exp) > 1) {
$file = "./" . $exp[1];
if (strpos(
$file,
$module->getPath()
$file,
$module->getPath()
) === 0) {
return true;
}
......@@ -63,7 +64,7 @@ class Value extends Mixed implements iValue
}
}
return false;
return true;
}
public static function addPermission (string $name, Module $module, string $comment = ""): bool
......@@ -103,45 +104,45 @@ class Value extends Mixed implements iValue
return false;
}
private $name;
private $module;
private $comment;
protected function __construct (string $name)
{
if (is_string($name) && self::exist($name)) {
$sql = "SELECT * FROM " . self::TABLE . " WHERE " . self::NAME . " = '" . $name . "'";
$statement = Core::PDO()->query($sql);
$fetch = $statement->fetch(PDO::FETCH_ASSOC);
foreach ($fetch as $key => $value) {
$temp_key = str_replace("permission_", "", $key);
$temp_key = str_replace("_name", "", $temp_key);
$this->{$temp_key} = $value;
}
}
}
public function getName (): string
{
return $this->name;
}
public function getModule (): Module
{
if (!$this->module instanceof Module) {
$this->module = Module::get($this->module);
}
return $this->module;
}
public function getComment (): string
{
return $this->comment;
}
public function __toString ()
{
return $this->getName();
}
private $name;
private $module;
private $comment;
protected function __construct (string $name)
{
if (is_string($name) && self::exist($name)) {
$sql = "SELECT * FROM " . self::TABLE . " WHERE " . self::NAME . " = '" . $name . "'";
$statement = Core::PDO()->query($sql);
$fetch = $statement->fetch(PDO::FETCH_ASSOC);
foreach ($fetch as $key => $value) {
$temp_key = str_replace("permission_", "", $key);
$temp_key = str_replace("_name", "", $temp_key);
$this->{$temp_key} = $value;
}
}
}
public function getName (): string
{
return $this->name;
}
public function getModule (): Module
{
if (!$this->module instanceof Module) {
$this->module = Module::get($this->module);
}
return $this->module;
}
public function getComment (): string
{
return $this->comment;
}
public function __toString ()
{
return $this->getName();
}
}
\ No newline at end of file
......@@ -25,12 +25,13 @@ use Iko\User\iUser;
class Avatar implements iAvatar// ToDo: Create a concept for User Avatar and how to save the needed Data over the user class
{
const TYPES = array (
"gravatar",
"identicon",
"mm",
"wavatar",
"retro",
"file" );
"gravatar",
"identicon",
"mm",
"wavatar",
"retro",
"file",
"base64");
private $data;
private $user;
......@@ -95,6 +96,9 @@ class Avatar implements iAvatar// ToDo: Create a concept for User Avatar and how
$string = $this->getGravatar($this->user->getEmail());
}
break;
case 'base64':
$string = $name;
break;
default:
$string = $this->getGravatar($this->user->getEmail());
break;
......
......@@ -16,7 +16,9 @@ namespace Iko;
use Iko\CMS\Template;
use Iko\Event\Handler;
use Iko\Event\Register;
use Iko\Language\Key;
use Iko\User\Activation;
use Iko\User\Extensions\DisplayName;
use Iko\User\Group;
use Iko\User\iActivation;
use Iko\User\iData;
......@@ -67,7 +69,7 @@ class User extends User\Operators implements iUser
protected $password_reset;
protected $display_group;
private $password;
protected $extension;
protected $extensions;
/**
* user constructor.
......@@ -100,7 +102,7 @@ class User extends User\Operators implements iUser
private function loadExtension ()
{
$this->extension = Register::generateAll(
$this->extensions = Register::generateAll(
"iko.user.extension",
$this,
"\\Iko\\User\\iExtension"
......@@ -151,31 +153,38 @@ class User extends User\Operators implements iUser
if ($class !== false && $class instanceof iUser && !$class instanceof System) {
if ($class->comparePassword($password)) {
if ($class->getActive()) {
setSession(
"user_id",
$class->getID()
);
if (intval(readSession("user_id")) == $class->getID()) {
Session::renewSalt($password);
self::session();
if (self::getSession()->updateLastLogin($password)) {
Handler::eventFinal(
"iko.user.login.success",
null,
$user
);
return true;
}
else {
self::$error .= "Konnte password nicht updaten.";
self::$session_user = null;
Handler::eventFinal(
"iko.user.login.failed",
null,
$user
);
if (Handler::event(
"iko.user.login",
$class,
null,
true
)) {
setSession(
"user_id",
$class->getID()
);
if (intval(readSession("user_id")) == $class->getID()) {
Session::renewSalt($password);
self::session();
if (self::getSession()->updateLastLogin($password)) {
Handler::eventFinal(
"iko.user.login.success",
null,
$user
);
return true;
}
else {
self::$error .= "Konnte password nicht updaten.";
self::$session_user = null;
Handler::eventFinal(
"iko.user.login.failed",
null,
$user
);
}
}
}
}
......@@ -237,7 +246,9 @@ class User extends User\Operators implements iUser
if ((!($search_1 instanceof iUser) && !($search_2 instanceof iUser)) || (($search_1 instanceof iUser) && ($search_2 instanceof iUser) && ($search_1 instanceof System) && ($search_2 instanceof System))) {
if (Handler::event(
"iko.user.registration",
$array
$array,
null,
true
)) {
Core::PDO()->beginTransaction();
$time = time();
......@@ -278,25 +289,25 @@ class User extends User\Operators implements iUser
}
else {
Core::PDO()->rollBack();
throw new Exception("User Error #1");
self::$error .= Key::getString("iko.user.register.failed.sql");
}
}
else {
throw new Exception("User Error");
self::$error .= Key::getString("iko.user.register.failed.general");
}
}
else {
Core::PDO()->rollBack();
throw new Exception("User Error #2");
self::$error .= Key::getString("iko.user.register.failed.sql");
}
}
else {
throw new Exception("User Error #3");
self::$error .= Key::getString("iko.user.register.failed.event");
}
}
else {
throw new Exception("" + var_dump($search_1));
self::$error .= Key::getString("iko.user.register.failed.exists");
}
return false;
......@@ -352,10 +363,31 @@ class User extends User\Operators implements iUser
$sql = "DELETE FROM " . self::TABLE . " WHERE user_id = " . $user->getID();
$statement = Core::PDO()->exec($sql);
if ($statement > 0) {
Core::PDO()->exec(
"DELETE FROM " . Permissions\User::USER_PERMISSIONS . " WHERE " . self::ID . " = " . $user->getID(
)
);
Core::PDO()->exec(
"DELETE FROM " . Permissions\User::USER_ASSIGNMENT . " WHERE " . self::ID . " = " . $user->getID(
)
);
Core::PDO()->exec(
"DELETE FROM " . Activation::TABLE . " WHERE " . self::ID . " = " . $user->getID()
);
Core::PDO()->exec(
"DELETE FROM " . Password::TABLE . " WHERE " . self::ID . " = " . $user->getID()
);
Handler::eventFinal(
"iko.user.delete",
$user->getID()
);
log::add(
"user",
"info",
1003,
"Deleted User " . $user->getID() . " | " . $user->getName(),
$user
);
unset(self::$cache[ $user->getID() ]);
unset(self::$cache_exist[ $user->getID() ]);
unset($user);
......@@ -950,7 +982,7 @@ class User extends User\Operators implements iUser
if (is_array($type)) {
return $this->set(
__FUNCTION__,
unserialize($type)
serialize($type)
);
}
......@@ -1079,7 +1111,7 @@ class User extends User\Operators implements iUser
private function changeGroup ($group, $func): bool
{
$func = str_replace(
"_group",
"Group",
"",
$func
);
......@@ -1145,6 +1177,9 @@ class User extends User\Operators implements iUser
}
}
}
else {
return true;
}
}
return false;
......@@ -1443,7 +1478,19 @@ class User extends User\Operators implements iUser
public function getExtension ($name): iExtension
{
return $this->extension[ $name ] ?? null;
return $this->extensions[ $name ] ?? null;
}
public function getDisplayName (): string
{
$str = "";
foreach ($this->extensions as $extension) {
if ($extension instanceof DisplayName) {
$str = $extension->getDisplayName();
}
}
return $str;
}
public function getSessionHandler (): iSessionHandler
......
This diff is collapsed.
<?php
/**
* Created by PhpStorm.
* User: Matze
* Date: 16.09.2018
* Time: 20:09
*/
namespace Iko\User\Extensions;
interface DisplayName
{
public function getPrefix (): string;
public function getSuffix (): string;
public function getName (): string;
public function getDisplayName (): string;
}
\ No newline at end of file
......@@ -46,6 +46,9 @@ interface iUser extends iOperators
*/
public function getID (): int;
public function addGroup ($group): bool;
public function removeGroup ($group): bool;
/**
* @return array|Group
*/
......@@ -179,4 +182,6 @@ interface iUser extends iOperators
public function getSessionHandler (): iSessionHandler;
public function updateLastActivity ();
public function getExtension ($name): iExtension;
}
......@@ -28,12 +28,19 @@ class Loader extends \Iko\Module\Loader
__NAMESPACE__ . "\\ACP",
'initPage'),
array (
"user",
"iko.user.registration",
__NAMESPACE__ . "\\Extensions\\Blacklist",
'checkMail',
null,
true),
/*array (
"user",
'iko.admin.menu',
__NAMESPACE__ . "\\Admin\\Menu",
"getMenu",
null,
true),
true),*/
/*array("user", "iko.user.registration",
__NAMESPACE__ . "\\MinimumAge"),*/);
protected $handler_final = array (
......@@ -61,10 +68,10 @@ class Loader extends \Iko\Module\Loader
"iko.user.profile",
"Comment",
"\\Iko\\User\\Profile\\Comment"),
array (
/*array (
"iko.user.extension",
"SessionHandler",
"\\Iko\\User\\SessionHandler"),);
"\\Iko\\User\\SessionHandler"),*/);
private $files = array (
"admin" => array ("*"),
"interfaces" => array (
......@@ -106,7 +113,10 @@ class Loader extends \Iko\Module\Loader
"iko.user.delete",
""),
array (
"iko.group.delete",
"iko.user.groups.delete",
""),
array (
"iko.user.groups.delete.restricted",
""),
array (
"iko.user.groups.add",
......
<?php
/**
* Created by PhpStorm.
* User: Matze
* Date: 31.07.2018
* Time: 16:57
*/
$permissions = array ();
\ No newline at end of file
......@@ -2,28 +2,7 @@
* Created by Marcel on 01.04.2017.
*/
iko.user = {
ajaxResponse: function (data) {
try {
var response = JSON.parse(data);
if (response.status) {
$(".alert-info span").html(response.code);
$(".alert-info").show("fast");
}
else {
$(".alert-danger span").html(response.code);
$(".alert-danger").show("fast");
}
if (response.link !== "" && response.link !== 'undefined') {
setTimeout(function () {
window.location = response.link
}, response.timer);
}
} catch (ex) {
console.info(data);
$(".alert-danger span").html("Please contact the system administrator.");
$(".alert-danger").show("fast");
}
}
};
iko.user.create = function (username, password, password_repeat, email, other) {
username = typeof username !== 'undefined' ? username : document.forms["registration"]["username"].value;
......@@ -41,7 +20,7 @@ iko.user.create = function (username, password, password_repeat, email, other) {
pass: password,
mail: email,
other: other
}, iko.user.ajaxResponse);
}, iko.ajaxResponse);
}
else {
......@@ -55,6 +34,7 @@ iko.user.edit = function () {
var password_repeat = form["password_repeat"].value;
var actual_password = typeof form["actual_password"] !== 'undefined' ? form["actual_password"].value : "";
var email = form["email"].value;
var avatar = iko.user.avatar.data;
$.post(iko.ajax, {
module: "user",
func: "edit",
......@@ -63,7 +43,8 @@ iko.user.edit = function () {
password: password,
password_repeat: password_repeat,
actual_password: actual_password,
email: email
email: email,
avatar: avatar
}, function (data, status, xhr) {
var code = JSON.parse(data);
if (code.status == true) {
......@@ -84,12 +65,18 @@ iko.user.acp = {
var password_repeat = form["password_repeat"].value;
var email = form["email"].value;
var active = null;
if (form["user_active"].checked == true) {
active = true;
}
else {
active = false;
}
var permissionGroups = typeof permissionGroups !== 'undefined' && Array.isArray(permissionGroups) ? permissionGroups : form["permissionGroups"].selectedOptions;
var groups = [];
for (var i = 0; i < permissionGroups.length; i++) {
groups.push(permissionGroups[i].value);
}
$.post(iko.ajax, {
module: "user",
func: "editAcp",
......@@ -98,7 +85,8 @@ iko.user.acp = {
password: password,
password_repeat: password_repeat,
email: email,
user_active: active
user_active: active,
groups: groups
}, function (data, status, xhr) {
var code = JSON.parse(data);
if (code.status == true) {
......@@ -138,22 +126,7 @@ iko.user.login = function (username, password) {
$.post(iko.ajax, {
module: "user", func: "login", user: username,
pass: password
}, function (data) {
try {
var code = JSON.parse(data);
} catch (ex) {
console.info(data);
}
if (code.status == true) {
$(".alert-success").show("fast");
setTimeout(function () {
window.location = iko.returnURL;
}, 2000);
} else {
$(".alert-danger span").html(code.code);
$(".alert-danger").show("fast");
}
});
}, iko.ajaxResponse);
};
iko.user.registration = function (username, password, password_repeat, email, other) {
......@@ -172,18 +145,7 @@ iko.user.registration = function (username, password, password_repeat, email, ot
user: username,
pass: password,
mail: email
}, function (data) {
var code = JSON.parse(data);
if (code.status == true) {
$(".alert-success").show("fast");
setTimeout(function () {
window.location = iko.returnURL;
}, 10000);
} else {
$(".alert-danger span").html(code.code);
$(".alert-danger").show("fast");
}
});
}, iko.ajaxResponse);
}
else {
......@@ -204,7 +166,7 @@ iko.user.activation = {
username: username,
email: email,
key: key
}, iko.user.ajaxResponse);
}, iko.ajaxResponse);
},
request: function (email) {
var forms = "request";
......@@ -249,14 +211,14 @@ iko.user.password = {
key: key,
password: password,
password_repeat: password_repeat
}, iko.user.ajaxResponse);
}, iko.ajaxResponse);
},
request: function (email) {
var forms = "request";
email = typeof email !== 'undefined' ? email : document.forms[forms]["email"].value;
$(".alert-info").hide("slow");
$(".alert-danger").hide("slow");
$.post(iko.ajax, {module: 'user', func: 'password', request: true, email: email}, iko.user.ajaxResponse)
$.post(iko.ajax, {module: 'user', func: 'password', request: true, email: email}, iko.ajaxResponse)
}
};
iko.user.group = {
......@@ -280,11 +242,56 @@ iko.user.group = {
id: id,
name: name,
parents: parents
}, iko.user.ajaxResponse)
}, iko.ajaxResponse)
},
create: function (name) {
var form = document.forms["group_create"];
name = typeof name !== 'undefined' ? name : form["name"].value;
$.post(iko.ajax, {module: "user", func: 'group_create', name: name}, iko.user.ajaxResponse);
$.post(iko.ajax, {module: "user", func: 'group_create', name: name}, iko.ajaxResponse);
}
}
\ No newline at end of file
};
iko.user.avatar = {
class: "",
data: "",
croppy: function (active) {
if (active) {
$(".user-profil-image").hide();
$(".user-profil-upload-image").hide();
iko.user.avatar.class = $(".user-profil-upload").croppie({
enableExif: true,
viewport: {
width: 100,
height: 100,
type: 'square'
},
boundary: {
width: 100,
height: 100
}
});
iko.user.avatar.class.on("update.croppie", function (ev, cropData) {
iko.user.avatar.croppy_gen();
});
var photo = document.forms["edit_user"]["avatar"].files;
var reader = new FileReader();
reader.onload = function (e) {
iko.user.avatar.class.croppie('bind', {
url: e.target.result
}).then(function () {
console.log("jQuery bind complete");
});
}
reader.readAsDataURL(photo[0]);
}
},
croppy_gen: function () {
iko.user.avatar.class.croppie('result', {
type: 'base64',
size: 'viewport',
format: 'png',
quality: 1
}).then(function (photo_data) {
iko.user.avatar.data = photo_data;
});
},
};
\ No newline at end of file