notify coordinators about unconfirmed angeltypes
This commit is contained in:
parent
f1145b8a5e
commit
d394ed2fee
|
@ -85,9 +85,6 @@ function angeltype_delete_controller() {
|
||||||
function angeltype_edit_controller() {
|
function angeltype_edit_controller() {
|
||||||
global $privileges, $user;
|
global $privileges, $user;
|
||||||
|
|
||||||
if (! in_array('admin_angel_types', $privileges))
|
|
||||||
redirect(page_link_to('angeltypes'));
|
|
||||||
|
|
||||||
$name = "";
|
$name = "";
|
||||||
$restricted = false;
|
$restricted = false;
|
||||||
$description = "";
|
$description = "";
|
||||||
|
@ -102,11 +99,21 @@ function angeltype_edit_controller() {
|
||||||
$name = $angeltype['name'];
|
$name = $angeltype['name'];
|
||||||
$restricted = $angeltype['restricted'];
|
$restricted = $angeltype['restricted'];
|
||||||
$description = $angeltype['description'];
|
$description = $angeltype['description'];
|
||||||
|
|
||||||
|
if (! User_is_AngelType_coordinator($user, $angeltype))
|
||||||
|
redirect(page_link_to('angeltypes'));
|
||||||
|
} else {
|
||||||
|
if (! in_array('admin_angel_types', $privileges))
|
||||||
|
redirect(page_link_to('angeltypes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In coordinator mode only allow to modify description
|
||||||
|
$coordinator_mode = ! in_array('admin_angel_types', $privileges);
|
||||||
|
|
||||||
if (isset($_REQUEST['submit'])) {
|
if (isset($_REQUEST['submit'])) {
|
||||||
$ok = true;
|
$ok = true;
|
||||||
|
|
||||||
|
if (! $coordinator_mode) {
|
||||||
if (isset($_REQUEST['name'])) {
|
if (isset($_REQUEST['name'])) {
|
||||||
list($valid, $name) = AngelType_validate_name($_REQUEST['name'], $angeltype);
|
list($valid, $name) = AngelType_validate_name($_REQUEST['name'], $angeltype);
|
||||||
if (! $valid) {
|
if (! $valid) {
|
||||||
|
@ -116,6 +123,7 @@ function angeltype_edit_controller() {
|
||||||
}
|
}
|
||||||
|
|
||||||
$restricted = isset($_REQUEST['restricted']);
|
$restricted = isset($_REQUEST['restricted']);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST['description']))
|
if (isset($_REQUEST['description']))
|
||||||
$description = strip_request_item_nl('description');
|
$description = strip_request_item_nl('description');
|
||||||
|
@ -142,7 +150,7 @@ function angeltype_edit_controller() {
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
isset($angeltype) ? sprintf(_("Edit %s"), $name) : _("Add new angeltype"),
|
isset($angeltype) ? sprintf(_("Edit %s"), $name) : _("Add new angeltype"),
|
||||||
AngelType_edit_view($name, $restricted, $description)
|
AngelType_edit_view($name, $restricted, $description, $coordinator_mode)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +182,7 @@ function angeltype_controller() {
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
sprintf(_("Team %s"), $angeltype['name']),
|
sprintf(_("Team %s"), $angeltype['name']),
|
||||||
AngelType_view($angeltype, $members, $user_angeltype, in_array('admin_user_angeltypes', $privileges) || $user_angeltype['coordinator'], 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), $user_angeltype['coordinator'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,20 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a hint for team/angeltype coordinators if there are unconfirmed users for his angeltype.
|
||||||
|
*/
|
||||||
|
function user_angeltypes_unconfirmed_hint() {
|
||||||
|
global $user;
|
||||||
|
$unconfirmed_user_angeltypes = User_unconfirmed_AngelTypes($user);
|
||||||
|
if ($unconfirmed_user_angeltypes === false)
|
||||||
|
engelsystem_error("Unable to load user angeltypes.");
|
||||||
|
if (count($unconfirmed_user_angeltypes) == 0)
|
||||||
|
return '';
|
||||||
|
if ($_REQUEST['p'] == 'angeltypes' && $_REQUEST['action'] == 'view' && $_REQUEST['angeltype_id'] == $unconfirmed_user_angeltypes[0]['angeltype_id'])
|
||||||
|
return '';
|
||||||
|
return error(sprintf(ngettext("There is %d unconfirmed angeltype.", "There are %d unconfirmed angeltypes.", count($unconfirmed_user_angeltypes)), count($unconfirmed_user_angeltypes)) . " " . sprintf(_("The first wants to join %s."), '<a href="' . page_link_to('angeltypes') . '&action=view&angeltype_id=' . $unconfirmed_user_angeltypes[0]['angeltype_id'] . '">' . $unconfirmed_user_angeltypes[0]['name'] . '</a>'), true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove all unconfirmed users from a specific angeltype.
|
* Remove all unconfirmed users from a specific angeltype.
|
||||||
*/
|
*/
|
||||||
|
@ -263,7 +278,7 @@ function user_angeltype_update_controller() {
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
$coordinator ? _("Add coordinator rights") : _("Remove coordinator rights"),
|
$coordinator ? _("Add coordinator rights") : _("Remove coordinator rights"),
|
||||||
UserAngelType_update_view($user_angeltype, $user, $angeltype, $coordinator)
|
UserAngelType_update_view($user_angeltype, $user_source, $angeltype, $coordinator)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,21 @@
|
||||||
* User angeltypes model
|
* User angeltypes model
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets unconfirmed user angeltypes for angeltypes of which the given user is a coordinator.
|
||||||
|
*
|
||||||
|
* @param User $user
|
||||||
|
*/
|
||||||
|
function User_unconfirmed_AngelTypes($user) {
|
||||||
|
return sql_select("
|
||||||
|
SELECT `UnconfirmedMembers`.*, `AngelTypes`.`name` FROM `UserAngelTypes`
|
||||||
|
JOIN `AngelTypes` ON `UserAngelTypes`.`angeltype_id`=`AngelTypes`.`id`
|
||||||
|
JOIN `UserAngelTypes` as `UnconfirmedMembers` ON `UserAngelTypes`.`angeltype_id`=`UnconfirmedMembers`.`angeltype_id`
|
||||||
|
WHERE `UserAngelTypes`.`user_id`=" . sql_escape($user['UID']) . "
|
||||||
|
AND `AngelTypes`.`restricted`=TRUE
|
||||||
|
AND `UnconfirmedMembers`.`confirm_user_id` IS NULL");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if user is angeltype coordinator or has privilege admin_user_angeltypes.
|
* Returns true if user is angeltype coordinator or has privilege admin_user_angeltypes.
|
||||||
*
|
*
|
||||||
|
|
|
@ -40,15 +40,15 @@ function AngelType_delete_view($angeltype) {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
function AngelType_edit_view($name, $restricted, $description) {
|
function AngelType_edit_view($name, $restricted, $description, $coordinator_mode) {
|
||||||
return page(array(
|
return page(array(
|
||||||
buttons(array(
|
buttons(array(
|
||||||
button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
|
button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
|
||||||
)),
|
)),
|
||||||
msg(),
|
msg(),
|
||||||
form(array(
|
form(array(
|
||||||
form_text('name', _("Name"), $name),
|
$coordinator_mode ? form_info(_("Name"), $name) : form_text('name', _("Name"), $name),
|
||||||
form_checkbox('restricted', _("Restricted"), $restricted),
|
$coordinator_mode ? form_info(_("Restricted"), $restricted ? _("Yes") : _("No")) : form_checkbox('restricted', _("Restricted"), $restricted),
|
||||||
form_info("", _("Restricted angel types can only be used by an angel if enabled by an archangel (double opt-in).")),
|
form_info("", _("Restricted angel types can only be used by an angel if enabled by an archangel (double opt-in).")),
|
||||||
form_textarea('description', _("Description"), $description),
|
form_textarea('description', _("Description"), $description),
|
||||||
form_info("", _("Please use markdown for the description.")),
|
form_info("", _("Please use markdown for the description.")),
|
||||||
|
@ -57,7 +57,7 @@ function AngelType_edit_view($name, $restricted, $description) {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angeltypes, $admin_angeltypes) {
|
function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angeltypes, $admin_angeltypes, $coordinator) {
|
||||||
$buttons = array(
|
$buttons = array(
|
||||||
button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
|
button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
|
||||||
);
|
);
|
||||||
|
@ -70,10 +70,10 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
|
||||||
$buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'], _("leave"), 'cancel');
|
$buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'], _("leave"), 'cancel');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($admin_angeltypes) {
|
if ($admin_angeltypes || $coordinator)
|
||||||
$buttons[] = button(page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'], _("edit"), 'edit');
|
$buttons[] = button(page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'], _("edit"), 'edit');
|
||||||
|
if ($admin_angeltypes)
|
||||||
$buttons[] = button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], _("delete"), 'delete');
|
$buttons[] = button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], _("delete"), 'delete');
|
||||||
}
|
|
||||||
|
|
||||||
$page = array(
|
$page = array(
|
||||||
msg(),
|
msg(),
|
||||||
|
@ -175,7 +175,7 @@ function AngelTypes_about_view($angeltypes, $user_logged_in) {
|
||||||
buttons(array(
|
buttons(array(
|
||||||
! $user_logged_in ? button(page_link_to('register'), register_title()) : '',
|
! $user_logged_in ? button(page_link_to('register'), register_title()) : '',
|
||||||
! $user_logged_in ? button(page_link_to('login'), login_title()) : '',
|
! $user_logged_in ? button(page_link_to('login'), login_title()) : '',
|
||||||
$user_logged_in ? button(page_link_to('angeltypes'), '« ' . angeltypes_title()) : 'back',
|
$user_logged_in ? button(page_link_to('angeltypes'), angeltypes_title(), 'back') : '',
|
||||||
button($faq_url, _("FAQ"))
|
button($faq_url, _("FAQ"))
|
||||||
)),
|
)),
|
||||||
'<p>' . _("Here is the list of teams and their tasks. If you have questions, read the FAQ.") . '</p>'
|
'<p>' . _("Here is the list of teams and their tasks. If you have questions, read the FAQ.") . '</p>'
|
||||||
|
|
|
@ -232,6 +232,8 @@ if (isset($user)) {
|
||||||
// Erzengel Hinweis für unbeantwortete Fragen
|
// Erzengel Hinweis für unbeantwortete Fragen
|
||||||
if ($p != "admin_questions")
|
if ($p != "admin_questions")
|
||||||
$content = admin_new_questions() . $content;
|
$content = admin_new_questions() . $content;
|
||||||
|
|
||||||
|
$content = user_angeltypes_unconfirmed_hint() . $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo template_render('../templates/layout.html', array(
|
echo template_render('../templates/layout.html', array(
|
||||||
|
|
Loading…
Reference in New Issue