implemented team/angeltype coordinators
This commit is contained in:
parent
e107dff1ce
commit
f1145b8a5e
6
README
6
README
|
@ -1,7 +1,7 @@
|
|||
= Installation eines frischen Engelsystems =
|
||||
|
||||
Mindestvorrausetzungen (bzw. getestet unter):
|
||||
* PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cgi-fcgi)
|
||||
* PHP 5.4.x with Suhosin-Patch (cgi-fcgi)
|
||||
* mysqld Ver 5.1.49-3 for debian-linux-gnu on x86_64 ((Debian))
|
||||
* Webserver mit PHP-Anbindung, z.B. lighttpd, nginx oder Apache
|
||||
|
||||
|
@ -13,10 +13,10 @@ Vorgehen:
|
|||
* Es muss eine MySQL-Datenbank angelegt werden und ein User existieren, der alle Rechte auf dieser Datenbank besitzt.
|
||||
* Es muss die db/install.sql importiert/ausgeführt werden.
|
||||
* Erstelle bei Bedarf eine config/config.php, die die Werte (z.B. DB-Zugang) aus der config/config.default.php überschreibt.
|
||||
* Engelsystem im Browser aufrufen, Anmeldung mit admin:admin vornehmen und Admin-Passwort ändern.
|
||||
* Engelsystem im Browser aufrufen, Anmeldung mit admin:asdfasdf vornehmen und Admin-Passwort ändern.
|
||||
|
||||
Das Engelsystem ist jetzt einsatzbereit.
|
||||
|
||||
Fehler bitte an bugs@engelsystem.de melden.
|
||||
|
||||
Trac: https://vcs.wybt.net/engelsystem/trac/
|
||||
Bugtracker: https://vcs.wybt.net/engelsystem/trac/
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
-- http://www.phpmyadmin.net
|
||||
--
|
||||
-- Host: localhost
|
||||
-- Erstellungszeit: 09. Mrz 2014 um 13:11
|
||||
-- Erstellungszeit: 13. Mai 2014 um 15:50
|
||||
-- Server Version: 5.6.12
|
||||
-- PHP-Version: 5.5.3
|
||||
|
||||
|
@ -14,8 +14,6 @@ SET time_zone = "+00:00";
|
|||
--
|
||||
-- Datenbank: `engelsystem`
|
||||
--
|
||||
CREATE DATABASE IF NOT EXISTS `engelsystem` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||
USE `engelsystem`;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
|
@ -23,7 +21,6 @@ USE `engelsystem`;
|
|||
-- Tabellenstruktur für Tabelle `AngelTypes`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `AngelTypes`;
|
||||
CREATE TABLE IF NOT EXISTS `AngelTypes` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(25) NOT NULL DEFAULT '',
|
||||
|
@ -31,7 +28,7 @@ CREATE TABLE IF NOT EXISTS `AngelTypes` (
|
|||
`description` text NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `Name` (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `AngelTypes`
|
||||
|
@ -46,35 +43,18 @@ INSERT INTO `AngelTypes` (`id`, `name`, `restricted`, `description`) VALUES
|
|||
-- Tabellenstruktur für Tabelle `Counter`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `Counter`;
|
||||
CREATE TABLE IF NOT EXISTS `Counter` (
|
||||
`URL` varchar(255) NOT NULL DEFAULT '',
|
||||
`Anz` bigint(20) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`URL`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Counter der Seiten';
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `Counter`
|
||||
--
|
||||
|
||||
INSERT INTO `Counter` (`URL`, `Anz`) VALUES
|
||||
('admin_user', 2),
|
||||
('angeltypes', 33),
|
||||
('login', 11),
|
||||
('news', 6),
|
||||
('register', 1),
|
||||
('user_angeltypes', 2),
|
||||
('user_meetings', 1),
|
||||
('user_myshifts', 2),
|
||||
('user_settings', 7);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Tabellenstruktur für Tabelle `GroupPrivileges`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `GroupPrivileges`;
|
||||
CREATE TABLE IF NOT EXISTS `GroupPrivileges` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`group_id` int(11) NOT NULL,
|
||||
|
@ -138,7 +118,6 @@ INSERT INTO `GroupPrivileges` (`id`, `group_id`, `privilege_id`) VALUES
|
|||
-- Tabellenstruktur für Tabelle `Groups`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `Groups`;
|
||||
CREATE TABLE IF NOT EXISTS `Groups` (
|
||||
`Name` varchar(35) NOT NULL,
|
||||
`UID` int(11) NOT NULL,
|
||||
|
@ -163,7 +142,6 @@ INSERT INTO `Groups` (`Name`, `UID`) VALUES
|
|||
-- Tabellenstruktur für Tabelle `LogEntries`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `LogEntries`;
|
||||
CREATE TABLE IF NOT EXISTS `LogEntries` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`timestamp` int(11) NOT NULL,
|
||||
|
@ -171,19 +149,7 @@ CREATE TABLE IF NOT EXISTS `LogEntries` (
|
|||
`message` text NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `timestamp` (`timestamp`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `LogEntries`
|
||||
--
|
||||
|
||||
INSERT INTO `LogEntries` (`id`, `timestamp`, `nick`, `message`) VALUES
|
||||
(1, 1390991375, 'admin', 'Created angeltype: testengel, restricted: 0'),
|
||||
(2, 1390991407, 'admin', 'User <a href="?p=user_myshifts&id=1">admin</a> joined testengel.'),
|
||||
(3, 1390991407, 'admin', 'User <a href="?p=user_myshifts&id=1">admin</a> confirmed as testengel.'),
|
||||
(4, 1394366820, 'admin', 'Updated angeltype: testengel, restricted: 0'),
|
||||
(5, 1394366908, 'admin', 'Updated angeltype: testengel, restricted: 0'),
|
||||
(6, 1394367023, 'admin', 'Own angel types set to: testengel');
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
|
@ -191,7 +157,6 @@ INSERT INTO `LogEntries` (`id`, `timestamp`, `nick`, `message`) VALUES
|
|||
-- Tabellenstruktur für Tabelle `Messages`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `Messages`;
|
||||
CREATE TABLE IF NOT EXISTS `Messages` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`Datum` int(11) NOT NULL,
|
||||
|
@ -211,7 +176,6 @@ CREATE TABLE IF NOT EXISTS `Messages` (
|
|||
-- Tabellenstruktur für Tabelle `NeededAngelTypes`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `NeededAngelTypes`;
|
||||
CREATE TABLE IF NOT EXISTS `NeededAngelTypes` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`room_id` int(11) DEFAULT NULL,
|
||||
|
@ -230,7 +194,6 @@ CREATE TABLE IF NOT EXISTS `NeededAngelTypes` (
|
|||
-- Tabellenstruktur für Tabelle `News`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `News`;
|
||||
CREATE TABLE IF NOT EXISTS `News` (
|
||||
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`Datum` int(11) NOT NULL,
|
||||
|
@ -240,7 +203,7 @@ CREATE TABLE IF NOT EXISTS `News` (
|
|||
`Treffen` tinyint(4) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`ID`),
|
||||
KEY `UID` (`UID`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
|
@ -248,7 +211,6 @@ CREATE TABLE IF NOT EXISTS `News` (
|
|||
-- Tabellenstruktur für Tabelle `NewsComments`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `NewsComments`;
|
||||
CREATE TABLE IF NOT EXISTS `NewsComments` (
|
||||
`ID` bigint(11) NOT NULL AUTO_INCREMENT,
|
||||
`Refid` int(11) NOT NULL DEFAULT '0',
|
||||
|
@ -266,7 +228,6 @@ CREATE TABLE IF NOT EXISTS `NewsComments` (
|
|||
-- Tabellenstruktur für Tabelle `Privileges`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `Privileges`;
|
||||
CREATE TABLE IF NOT EXISTS `Privileges` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(128) NOT NULL,
|
||||
|
@ -323,7 +284,6 @@ INSERT INTO `Privileges` (`id`, `name`, `desc`) VALUES
|
|||
-- Tabellenstruktur für Tabelle `Questions`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `Questions`;
|
||||
CREATE TABLE IF NOT EXISTS `Questions` (
|
||||
`QID` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`UID` int(11) NOT NULL DEFAULT '0',
|
||||
|
@ -341,7 +301,6 @@ CREATE TABLE IF NOT EXISTS `Questions` (
|
|||
-- Tabellenstruktur für Tabelle `Room`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `Room`;
|
||||
CREATE TABLE IF NOT EXISTS `Room` (
|
||||
`RID` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`Name` varchar(35) NOT NULL DEFAULT '',
|
||||
|
@ -359,7 +318,6 @@ CREATE TABLE IF NOT EXISTS `Room` (
|
|||
-- Tabellenstruktur für Tabelle `ShiftEntry`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `ShiftEntry`;
|
||||
CREATE TABLE IF NOT EXISTS `ShiftEntry` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`SID` int(11) NOT NULL DEFAULT '0',
|
||||
|
@ -381,7 +339,6 @@ CREATE TABLE IF NOT EXISTS `ShiftEntry` (
|
|||
-- Tabellenstruktur für Tabelle `Shifts`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `Shifts`;
|
||||
CREATE TABLE IF NOT EXISTS `Shifts` (
|
||||
`SID` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`start` int(11) NOT NULL,
|
||||
|
@ -401,7 +358,6 @@ CREATE TABLE IF NOT EXISTS `Shifts` (
|
|||
-- Tabellenstruktur für Tabelle `User`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `User`;
|
||||
CREATE TABLE IF NOT EXISTS `User` (
|
||||
`UID` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`Nick` varchar(23) NOT NULL DEFAULT '',
|
||||
|
@ -436,14 +392,14 @@ CREATE TABLE IF NOT EXISTS `User` (
|
|||
KEY `api_key` (`api_key`),
|
||||
KEY `password_recovery_token` (`password_recovery_token`),
|
||||
KEY `force_active` (`force_active`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `User`
|
||||
--
|
||||
|
||||
INSERT INTO `User` (`UID`, `Nick`, `Name`, `Vorname`, `Alter`, `Telefon`, `DECT`, `Handy`, `email`, `ICQ`, `jabber`, `Size`, `Passwort`, `password_recovery_token`, `Gekommen`, `Aktiv`, `force_active`, `Tshirt`, `color`, `Sprache`, `Avatar`, `Menu`, `lastLogIn`, `CreateDate`, `Art`, `kommentar`, `Hometown`, `api_key`) VALUES
|
||||
(1, 'admin', 'Gates', 'Bill', 42, '', '-', '', 'admin@example.com', '', '', 'XL', '$6$rounds=5000$hjXbIhoRTH3vKiRa$Wl2P2iI5T9iRR.HHu/YFHswBW0WVn0yxCfCiX0Keco9OdIoDK6bIAADswP6KvMCJSwTGdV8PgA8g8Xfw5l8BD1', NULL, 1, 0, 1, 0, 1, 'de_DE.UTF-8', 115, 'L', 1394367023, '0000-00-00 00:00:00', '', '', '', '038850abdd1feb264406be3ffa746235');
|
||||
(1, 'admin', 'Gates', 'Bill', 42, '', '-', '', 'admin@example.com', '', '', 'XL', '$6$rounds=5000$hjXbIhoRTH3vKiRa$Wl2P2iI5T9iRR.HHu/YFHswBW0WVn0yxCfCiX0Keco9OdIoDK6bIAADswP6KvMCJSwTGdV8PgA8g8Xfw5l8BD1', NULL, 1, 0, 1, 0, 1, 'de_DE.UTF-8', 115, 'L', 1399988887, '0000-00-00 00:00:00', '', '', '', '038850abdd1feb264406be3ffa746235');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
|
@ -451,24 +407,18 @@ INSERT INTO `User` (`UID`, `Nick`, `Name`, `Vorname`, `Alter`, `Telefon`, `DECT`
|
|||
-- Tabellenstruktur für Tabelle `UserAngelTypes`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `UserAngelTypes`;
|
||||
CREATE TABLE IF NOT EXISTS `UserAngelTypes` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` int(11) NOT NULL,
|
||||
`angeltype_id` int(11) NOT NULL,
|
||||
`confirm_user_id` int(11) DEFAULT NULL,
|
||||
`coordinator` tinyint(1) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `user_id` (`user_id`,`angeltype_id`,`confirm_user_id`),
|
||||
KEY `angeltype_id` (`angeltype_id`),
|
||||
KEY `confirm_user_id` (`confirm_user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `UserAngelTypes`
|
||||
--
|
||||
|
||||
INSERT INTO `UserAngelTypes` (`id`, `user_id`, `angeltype_id`, `confirm_user_id`) VALUES
|
||||
(1, 1, 1, 1);
|
||||
KEY `confirm_user_id` (`confirm_user_id`),
|
||||
KEY `coordinator` (`coordinator`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
|
@ -476,7 +426,6 @@ INSERT INTO `UserAngelTypes` (`id`, `user_id`, `angeltype_id`, `confirm_user_id`
|
|||
-- Tabellenstruktur für Tabelle `UserGroups`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `UserGroups`;
|
||||
CREATE TABLE IF NOT EXISTS `UserGroups` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`uid` int(11) NOT NULL,
|
||||
|
@ -484,7 +433,7 @@ CREATE TABLE IF NOT EXISTS `UserGroups` (
|
|||
PRIMARY KEY (`id`),
|
||||
KEY `uid` (`uid`,`group_id`),
|
||||
KEY `group_id` (`group_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=13 ;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=17 ;
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `UserGroups`
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
/* teamcoordinators */
|
||||
ALTER TABLE `UserAngelTypes` ADD `coordinator` BOOLEAN NOT NULL;
|
||||
ALTER TABLE `UserAngelTypes` ADD INDEX ( `coordinator` );
|
||||
|
||||
/* angeltype view */
|
||||
INSERT INTO `engelsystem`.`Privileges` (`id`, `name`, `desc`) VALUES (NULL , 'angeltypes', 'View angeltypes');
|
||||
INSERT INTO `Privileges` (`id`, `name`, `desc`) VALUES (NULL , 'angeltypes', 'View angeltypes');
|
||||
|
||||
/* force active */
|
||||
ALTER TABLE `User` ADD `force_active` BOOLEAN NOT NULL AFTER `Aktiv`, ADD INDEX ( `force_active` );
|
||||
|
|
|
@ -174,7 +174,7 @@ function angeltype_controller() {
|
|||
|
||||
return array(
|
||||
sprintf(_("Team %s"), $angeltype['name']),
|
||||
AngelType_view($angeltype, $members, $user_angeltype, in_array('admin_user_angeltypes', $privileges), in_array('admin_angel_types', $privileges))
|
||||
AngelType_view($angeltype, $members, $user_angeltype, in_array('admin_user_angeltypes', $privileges) || $user_angeltype['coordinator'], in_array('admin_angel_types', $privileges))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -201,18 +201,10 @@ function angeltypes_list_controller() {
|
|||
$actions[] = '<a class="delete" href="' . page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'] . '">' . _("delete") . '</a>';
|
||||
}
|
||||
|
||||
$angeltype['membership'] = "";
|
||||
$angeltype['membership'] = AngelType_render_membership($angeltype);
|
||||
if ($angeltype['user_angeltype_id'] != null) {
|
||||
if ($angeltype['restricted']) {
|
||||
if ($angeltype['confirm_user_id'] == null)
|
||||
$angeltype['membership'] = '<img src="pic/icons/lock.png" alt="' . _("Unconfirmed") . '" title="' . _("Unconfirmed") . '"> ' . _("Unconfirmed");
|
||||
else
|
||||
$angeltype['membership'] = '<img src="pic/icons/tick.png" alt="' . _("Member") . '" title="' . _("Member") . '"> ' . _("Member");
|
||||
} else
|
||||
$angeltype['membership'] = '<img src="pic/icons/tick.png" alt="' . _("Member") . '" title="' . _("Member") . '"> ' . _("Member");
|
||||
$actions[] = '<a class="cancel" href="' . page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'] . '">' . _("leave") . '</a>';
|
||||
} else {
|
||||
$angeltype['membership'] = '<img src="pic/icons/cross.png" alt="" title="">';
|
||||
$actions[] = '<a class="add" href="' . page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'] . '">' . _("join") . '</a>';
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,6 @@
|
|||
function user_angeltypes_delete_all_controller() {
|
||||
global $user, $privileges;
|
||||
|
||||
if (! in_array('admin_user_angeltypes', $privileges)) {
|
||||
error(_("You are not allowed to delete all users for this angeltype."));
|
||||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
||||
if (! isset($_REQUEST['angeltype_id'])) {
|
||||
error(_("Angeltype doesn't exist."));
|
||||
redirect(page_link_to('angeltypes'));
|
||||
|
@ -24,6 +19,11 @@ function user_angeltypes_delete_all_controller() {
|
|||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
||||
if (! User_is_AngelType_coordinator($user, $angeltype)) {
|
||||
error(_("You are not allowed to delete all users for this angeltype."));
|
||||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['confirmed'])) {
|
||||
$result = UserAngelTypes_delete_all($angeltype['id']);
|
||||
if ($result === false)
|
||||
|
@ -46,11 +46,6 @@ function user_angeltypes_delete_all_controller() {
|
|||
function user_angeltypes_confirm_all_controller() {
|
||||
global $user, $privileges;
|
||||
|
||||
if (! in_array('admin_user_angeltypes', $privileges)) {
|
||||
error(_("You are not allowed to confirm all users for this angeltype."));
|
||||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
||||
if (! isset($_REQUEST['angeltype_id'])) {
|
||||
error(_("Angeltype doesn't exist."));
|
||||
redirect(page_link_to('angeltypes'));
|
||||
|
@ -64,6 +59,19 @@ function user_angeltypes_confirm_all_controller() {
|
|||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
||||
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
||||
if ($user_angeltype === false)
|
||||
engelsystem_error("Unable to load user angeltype.");
|
||||
if ($user_angeltype == null) {
|
||||
error(_("User angeltype doesn't exist."));
|
||||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
||||
if (! in_array('admin_user_angeltypes', $privileges) && ! $user_angeltype['coordinator']) {
|
||||
error(_("You are not allowed to confirm all users for this angeltype."));
|
||||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['confirmed'])) {
|
||||
$result = UserAngelTypes_confirm_all($angeltype['id'], $user);
|
||||
if ($result === false)
|
||||
|
@ -86,11 +94,6 @@ function user_angeltypes_confirm_all_controller() {
|
|||
function user_angeltype_confirm_controller() {
|
||||
global $user, $privileges;
|
||||
|
||||
if (! in_array('admin_user_angeltypes', $privileges)) {
|
||||
error(_("You are not allowed to confirm this users angeltype."));
|
||||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
||||
if (! isset($_REQUEST['user_angeltype_id'])) {
|
||||
error(_("User angeltype doesn't exist."));
|
||||
redirect(page_link_to('angeltypes'));
|
||||
|
@ -112,6 +115,11 @@ function user_angeltype_confirm_controller() {
|
|||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
||||
if (! User_is_AngelType_coordinator($user, $angeltype)) {
|
||||
error(_("You are not allowed to confirm this users angeltype."));
|
||||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
||||
$user_source = User($user_angeltype['user_id']);
|
||||
if ($user_source === false)
|
||||
engelsystem_error("Unable to load user.");
|
||||
|
@ -171,7 +179,7 @@ function user_angeltype_delete_controller() {
|
|||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
||||
if ($user['UID'] != $user_angeltype['user_id'] && ! in_array('admin_user_angeltypes', $privileges)) {
|
||||
if ($user['UID'] != $user_angeltype['user_id'] && ! User_is_AngelType_coordinator($user, $angeltype)) {
|
||||
error(_("You are not allowed to delete this users angeltype."));
|
||||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
@ -198,7 +206,65 @@ function user_angeltype_delete_controller() {
|
|||
* Update an UserAngelType.
|
||||
*/
|
||||
function user_angeltype_update_controller() {
|
||||
global $user, $privileges;
|
||||
|
||||
if (! in_array('admin_angel_types', $privileges)) {
|
||||
error(_("You are not allowed to set coordinator rights."));
|
||||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
||||
if (! isset($_REQUEST['user_angeltype_id'])) {
|
||||
error(_("User angeltype doesn't exist."));
|
||||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['coordinator']) && preg_match("/^[01]$/", $_REQUEST['coordinator']))
|
||||
$coordinator = $_REQUEST['coordinator'] == "1";
|
||||
else {
|
||||
error(_("No coordinator update given."));
|
||||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
||||
$user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
|
||||
if ($user_angeltype === false)
|
||||
engelsystem_error("Unable to load user angeltype.");
|
||||
if ($user_angeltype == null) {
|
||||
error(_("User angeltype doesn't exist."));
|
||||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
||||
$angeltype = AngelType($user_angeltype['angeltype_id']);
|
||||
if ($angeltype === false)
|
||||
engelsystem_error("Unable to load angeltype.");
|
||||
if ($angeltype == null) {
|
||||
error(_("Angeltype doesn't exist."));
|
||||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
||||
$user_source = User($user_angeltype['user_id']);
|
||||
if ($user_source === false)
|
||||
engelsystem_error("Unable to load user.");
|
||||
if ($user_source == null) {
|
||||
error(_("User doesn't exist."));
|
||||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['confirmed'])) {
|
||||
$result = UserAngelType_update($user_angeltype['id'], $coordinator);
|
||||
if ($result === false)
|
||||
engelsystem_error("Unable to update coordinator rights.");
|
||||
|
||||
$success_message = sprintf($coordinator ? _("Added coordinator rights for %s to %s.") : _("Removed coordinator rights for %s from %s."), $angeltype['name'], User_Nick_render($user_source));
|
||||
engelsystem_log($success_message);
|
||||
success($success_message);
|
||||
|
||||
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
||||
}
|
||||
|
||||
return array(
|
||||
$coordinator ? _("Add coordinator rights") : _("Remove coordinator rights"),
|
||||
UserAngelType_update_view($user_angeltype, $user, $angeltype, $coordinator)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -220,38 +286,84 @@ function user_angeltype_add_controller() {
|
|||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
||||
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
||||
if ($user_angeltype === false)
|
||||
engelsystem_error("Unable to load user angeltype.");
|
||||
if ($user_angeltype != null) {
|
||||
error(sprintf(_("User is already an %s."), $angeltype['name']));
|
||||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
if (User_is_AngelType_coordinator($user, $angeltype)) {
|
||||
// Allow to add any user
|
||||
$user_id = $user['UID'];
|
||||
|
||||
if (isset($_REQUEST['confirmed'])) {
|
||||
$user_angeltype_id = UserAngelType_create($user, $angeltype);
|
||||
if ($user_angeltype_id === false)
|
||||
engelsystem_error("Unable to create user angeltype.");
|
||||
$users_source = Users_by_angeltype_inverted($angeltype);
|
||||
if ($users_source === false)
|
||||
engelsystem_error("Unable to load users.");
|
||||
|
||||
$success_message = sprintf(_("User %s joined %s."), User_Nick_render($user), $angeltype['name']);
|
||||
engelsystem_log($success_message);
|
||||
success($success_message);
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
$ok = true;
|
||||
|
||||
if (in_array('admin_user_angeltypes', $privileges)) {
|
||||
$result = UserAngelType_confirm($user_angeltype_id, $user);
|
||||
if ($result === false)
|
||||
engelsystem_error("Unable to confirm user angeltype.");
|
||||
$success_message = sprintf(_("User %s confirmed as %s."), User_Nick_render($user), $angeltype['name']);
|
||||
engelsystem_log($success_message);
|
||||
if (isset($_REQUEST['user_id']) && in_array($_REQUEST['user_id'], array_map(function ($user) {
|
||||
return $user['UID'];
|
||||
}, $users_source)))
|
||||
$user_id = $_REQUEST['user_id'];
|
||||
else {
|
||||
$ok = false;
|
||||
error(_("Please select a user."));
|
||||
}
|
||||
|
||||
if ($ok) {
|
||||
foreach ($users_source as $user_source)
|
||||
if ($user_source['UID'] == $user_id) {
|
||||
$user_angeltype_id = UserAngelType_create($user_source, $angeltype);
|
||||
if ($user_angeltype_id === false)
|
||||
engelsystem_error("Unable to create user angeltype.");
|
||||
|
||||
engelsystem_log(sprintf("User %s added to %s.", User_Nick_render($user_source), $angeltype['name']));
|
||||
success(sprintf(_("User %s added to %s."), User_Nick_render($user_source), $angeltype['name']));
|
||||
|
||||
$result = UserAngelType_confirm($user_angeltype_id, $user_source);
|
||||
if ($result === false)
|
||||
engelsystem_error("Unable to confirm user angeltype.");
|
||||
engelsystem_log(sprintf("User %s confirmed as %s.", User_Nick_render($user), $angeltype['name']));
|
||||
|
||||
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
||||
}
|
||||
return array(
|
||||
_("Add user to angeltype"),
|
||||
UserAngelType_add_view($angeltype, $users_source, $user_id)
|
||||
);
|
||||
} else {
|
||||
// Allow only me
|
||||
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
|
||||
if ($user_angeltype === false)
|
||||
engelsystem_error("Unable to load user angeltype.");
|
||||
if ($user_angeltype != null) {
|
||||
error(sprintf(_("You are already a %s."), $angeltype['name']));
|
||||
redirect(page_link_to('angeltypes'));
|
||||
}
|
||||
|
||||
return array(
|
||||
_("Add user to angeltype"),
|
||||
UserAngelType_add_view($user, $angeltype)
|
||||
);
|
||||
if (isset($_REQUEST['confirmed'])) {
|
||||
$user_angeltype_id = UserAngelType_create($user, $angeltype);
|
||||
if ($user_angeltype_id === false)
|
||||
engelsystem_error("Unable to create user angeltype.");
|
||||
|
||||
$success_message = sprintf(_("You joined %s."), $angeltype['name']);
|
||||
engelsystem_log(sprintf("User %s joined %s.", User_Nick_render($user), $angeltype['name']));
|
||||
success($success_message);
|
||||
|
||||
if (in_array('admin_user_angeltypes', $privileges)) {
|
||||
$result = UserAngelType_confirm($user_angeltype_id, $user);
|
||||
if ($result === false)
|
||||
engelsystem_error("Unable to confirm user angeltype.");
|
||||
engelsystem_log(sprintf("User %s confirmed as %s.", User_Nick_render($user), $angeltype['name']));
|
||||
}
|
||||
|
||||
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
|
||||
}
|
||||
|
||||
return array(
|
||||
sprintf(_("Become a %s"), $angeltype['name']),
|
||||
UserAngelType_join_view($user, $angeltype)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -92,7 +92,8 @@ function AngelTypes_with_user($user) {
|
|||
return sql_select("
|
||||
SELECT `AngelTypes`.*,
|
||||
`UserAngelTypes`.`id` as `user_angeltype_id`,
|
||||
`UserAngelTypes`.`confirm_user_id`
|
||||
`UserAngelTypes`.`confirm_user_id`,
|
||||
`UserAngelTypes`.`coordinator`
|
||||
FROM `AngelTypes`
|
||||
LEFT JOIN `UserAngelTypes` ON `AngelTypes`.`id`=`UserAngelTypes`.`angeltype_id`
|
||||
AND `UserAngelTypes`.`user_id`=" . $user['UID'] . "
|
||||
|
|
|
@ -1,4 +1,37 @@
|
|||
<?php
|
||||
/**
|
||||
* User angeltypes model
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns true if user is angeltype coordinator or has privilege admin_user_angeltypes.
|
||||
*
|
||||
* @param User $user
|
||||
* @param AngelType $angeltype
|
||||
*/
|
||||
function User_is_AngelType_coordinator($user, $angeltype) {
|
||||
return (sql_num_query("
|
||||
SELECT `id`
|
||||
FROM `UserAngelTypes`
|
||||
WHERE `user_id`=" . sql_escape($user['UID']) . "
|
||||
AND `angeltype_id`=" . sql_escape($angeltype['id']) . "
|
||||
AND `coordinator`=TRUE
|
||||
LIMIT 1") > 0) || in_array('admin_user_angeltypes', privileges_for_user($user['UID']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or remove coordinator rights.
|
||||
*
|
||||
* @param int $user_angeltype_id
|
||||
* @param bool $coordinator
|
||||
*/
|
||||
function UserAngelType_update($user_angeltype_id, $coordinator) {
|
||||
return sql_query("
|
||||
UPDATE `UserAngelTypes`
|
||||
SET `coordinator`=" . ($coordinator ? 'TRUE' : 'FALSE') . "
|
||||
WHERE `id`=" . sql_escape($user_angeltype_id) . "
|
||||
LIMIT 1");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all unconfirmed UserAngelTypes for given Angeltype.
|
||||
|
|
|
@ -1,12 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* User model
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns all users that are not member of given angeltype.
|
||||
*
|
||||
* @param Angeltype $angeltype
|
||||
*/
|
||||
function Users_by_angeltype_inverted($angeltype) {
|
||||
return sql_select("
|
||||
SELECT `User`.*
|
||||
FROM `User`
|
||||
LEFT JOIN `UserAngelTypes` ON (`User`.`UID`=`UserAngelTypes`.`user_id` AND `angeltype_id`=" . sql_escape($angeltype['id']) . ")
|
||||
WHERE `UserAngelTypes`.`id` IS NULL
|
||||
ORDER BY `Nick`");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all members of given angeltype.
|
||||
*
|
||||
* @param Angeltype $angeltype
|
||||
*/
|
||||
function Users_by_angeltype($angeltype) {
|
||||
return sql_select("
|
||||
SELECT `User`.*, `UserAngelTypes`.`id` as `user_angeltype_id`, `UserAngelTypes`.`confirm_user_id`
|
||||
SELECT
|
||||
`User`.*,
|
||||
`UserAngelTypes`.`id` as `user_angeltype_id`,
|
||||
`UserAngelTypes`.`confirm_user_id`,
|
||||
`UserAngelTypes`.`coordinator`
|
||||
FROM `User`
|
||||
JOIN `UserAngelTypes` ON `User`.`UID`=`UserAngelTypes`.`user_id`
|
||||
WHERE `UserAngelTypes`.`angeltype_id`=" . sql_escape($angeltype['id']) . "
|
||||
|
|
|
@ -1,4 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* AngelTypes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Render angeltype membership state
|
||||
*
|
||||
* @param UserAngelType $user_angeltype
|
||||
* UserAngelType and AngelType
|
||||
* @return string
|
||||
*/
|
||||
function AngelType_render_membership($user_angeltype) {
|
||||
$membership = "";
|
||||
if ($user_angeltype['user_angeltype_id'] != null) {
|
||||
if ($user_angeltype['restricted']) {
|
||||
if ($user_angeltype['confirm_user_id'] == null)
|
||||
$membership = '<img src="pic/icons/lock.png" alt="' . _("Unconfirmed") . '" title="' . _("Unconfirmed") . '"> ' . _("Unconfirmed");
|
||||
elseif ($user_angeltype['coordinator'])
|
||||
$membership = '<img src="pic/icons/tick.png" alt="' . _("Coordinator") . '" title="' . _("Coordinator") . '"> ' . _("Coordinator");
|
||||
else
|
||||
$membership = '<img src="pic/icons/tick.png" alt="' . _("Member") . '" title="' . _("Member") . '"> ' . _("Member");
|
||||
} elseif ($user_angeltype['coordinator'])
|
||||
$membership = '<img src="pic/icons/tick.png" alt="' . _("Coordinator") . '" title="' . _("Coordinator") . '"> ' . _("Coordinator");
|
||||
else
|
||||
$membership = '<img src="pic/icons/tick.png" alt="' . _("Member") . '" title="' . _("Member") . '"> ' . _("Member");
|
||||
} else {
|
||||
$membership = '<img src="pic/icons/cross.png" alt="" title="">';
|
||||
}
|
||||
return $membership;
|
||||
}
|
||||
|
||||
function AngelType_delete_view($angeltype) {
|
||||
return page(array(
|
||||
|
@ -56,7 +86,7 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
|
|||
|
||||
// Team-Coordinators list missing
|
||||
|
||||
$page[] = '<h3>' . _("Members") . '</h3>';
|
||||
$coordinators = array();
|
||||
$members_confirmed = array();
|
||||
$members_unconfirmed = array();
|
||||
foreach ($members as $member) {
|
||||
|
@ -67,14 +97,34 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
|
|||
'<a href="' . page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'] . '" class="cancel">' . _("deny") . '</a>'
|
||||
));
|
||||
$members_unconfirmed[] = $member;
|
||||
} elseif ($member['coordinator']) {
|
||||
if ($admin_angeltypes)
|
||||
$member['actions'] = '<a href="' . page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&coordinator=0" class="cancel">' . _("Remove coordinator rights") . '</a>';
|
||||
else
|
||||
$member['actions'] = '';
|
||||
$coordinators[] = $member;
|
||||
} else {
|
||||
if ($admin_user_angeltypes)
|
||||
$member['actions'] = join(" ", array(
|
||||
$admin_angeltypes ? '<a href="' . page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&coordinator=1" class="add">' . _("Add coordinator rights") . '</a>' : '',
|
||||
'<a href="' . page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'] . '" class="cancel">' . _("remove") . '</a>'
|
||||
));
|
||||
$members_confirmed[] = $member;
|
||||
}
|
||||
}
|
||||
if (count($coordinators) > 0) {
|
||||
$page[] = '<h3>' . _("Coordinators") . '</h3>';
|
||||
$page[] = table(array(
|
||||
'Nick' => _("Nick"),
|
||||
'DECT' => _("DECT"),
|
||||
'actions' => ""
|
||||
), $coordinators);
|
||||
}
|
||||
$page[] = '<h3>' . _("Members") . '</h3>';
|
||||
if ($admin_user_angeltypes)
|
||||
$page[] = buttons(array(
|
||||
button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("Add"), 'add')
|
||||
));
|
||||
$page[] = table(array(
|
||||
'Nick' => _("Nick"),
|
||||
'DECT' => _("DECT"),
|
||||
|
|
|
@ -1,4 +1,14 @@
|
|||
<?php
|
||||
function UserAngelType_update_view($user_angeltype, $user, $angeltype, $coordinator) {
|
||||
return page(array(
|
||||
msg(),
|
||||
info(sprintf($coordinator ? _("Do you really want to add coordinator rights for %s to %s?") : _("Do you really want to remove coordinator rights for %s from %s?"), $angeltype['name'], User_Nick_render($user)), true),
|
||||
buttons(array(
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
|
||||
button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $user_angeltype['id'] . '&coordinator=' . ($coordinator ? '1' : '0') . '&confirmed', _("yes"), 'ok')
|
||||
))
|
||||
));
|
||||
}
|
||||
|
||||
function UserAngelTypes_delete_all_view($angeltype) {
|
||||
return page(array(
|
||||
|
@ -44,7 +54,25 @@ function UserAngelType_delete_view($user_angeltype, $user, $angeltype) {
|
|||
));
|
||||
}
|
||||
|
||||
function UserAngelType_add_view($user, $angeltype) {
|
||||
function UserAngelType_add_view($angeltype, $users_source, $user_id) {
|
||||
$users = array();
|
||||
foreach ($users_source as $user_source)
|
||||
$users[$user_source['UID']] = User_Nick_render($user_source);
|
||||
|
||||
return page(array(
|
||||
msg(),
|
||||
buttons(array(
|
||||
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("back"), 'back')
|
||||
)),
|
||||
form(array(
|
||||
form_info(_("Angeltype"), $angeltype['name']),
|
||||
form_select('user_id', _("User"), $users, $user_id),
|
||||
form_submit('submit', _("Add"))
|
||||
))
|
||||
));
|
||||
}
|
||||
|
||||
function UserAngelType_join_view($user, $angeltype) {
|
||||
return page(array(
|
||||
msg(),
|
||||
info(sprintf(_("Do you really want to add %s to %s?"), User_Nick_render($user), $angeltype['name']), true),
|
||||
|
|
Loading…
Reference in New Issue