Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xnetevents non x subscription #26

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
16 changes: 16 additions & 0 deletions classes/xorgsession.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,22 @@ protected function startSessionAs($user, $level)
return true;
}

/**
* Directly start a session as the given user, without authentication
* TODO describe "auth by email"...
*/
public function logAsUser(User $user)
{
// Kill any current session
$this->destroy();

// It is like the user has authenticated with a cookie
S::set('auth', AUTH_COOKIE);

// Enter the session
return $this->startSessionAs($user, AUTH_COOKIE);
}

private function securityChecks()
{
$mail_subject = array();
Expand Down
253 changes: 165 additions & 88 deletions modules/xnetevents.php

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions modules/xnetevents/xnetevents.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function get_events($asso_id, $order, $archive)
if ($order != 'asc' && $order != 'desc') {
$order = 'desc';
}
$evts = XDB::fetchAllAssoc('eid', "SELECT ge.eid, ge.uid, ge.intitule, ge.debut, ge.fin, ge.show_participants, ge.deadline_inscription, ge.accept_nonmembre, ge.paiement_id
$evts = XDB::fetchAllAssoc('eid', "SELECT ge.eid, ge.uid, ge.intitule, ge.debut, ge.fin, ge.show_participants, ge.deadline_inscription, ge.access_control, ge.paiement_id
FROM group_events as ge
WHERE asso_id = {?} and archive = {?}
ORDER BY ge.debut $order",
Expand All @@ -66,7 +66,7 @@ function get_event(&$eid)
$eid);
$eid = $id;
}
$evt = XDB::fetchOneAssoc('SELECT ge.uid, ge.intitule, ge.descriptif, ge.debut, ge.fin, ge.deadline_inscription, ge.accept_nonmembre, ge.noinvite, ge.paiement_id
$evt = XDB::fetchOneAssoc('SELECT ge.uid, ge.intitule, ge.descriptif, ge.debut, ge.fin, ge.deadline_inscription, ge.access_control, ge.noinvite, ge.paiement_id
FROM group_events as ge
WHERE eid = {?}',
$eid);
Expand Down Expand Up @@ -167,7 +167,7 @@ function get_event_detail($eid, $item_id = false, $asso_id = null)
if (!$evt) {
return null;
}
if ($GLOBALS['IS_XNET_SITE'] && $evt['accept_nonmembre'] == 0 && !is_member() && !may_update()) {
if ($GLOBALS['IS_XNET_SITE'] && $evt['access_control'] == AccessControl::Group && !is_member() && !may_update()) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion templates/xnetevents/calendar.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ UID:event-{$e.short_name}-{$e.eid}@{$asso->diminutif}.polytechnique.org
ATTENDEE;CN="{$m.user->fullName('promo')}":MAILTO:{$m.user->bestEmail()}
{/foreach}
{/if}
{if $e.accept_nonmembre}
{if $e.access_control!=AccessControl::Group}
CLASS:PUBLIC
{else}
CLASS:PRIVATE
Expand Down
11 changes: 6 additions & 5 deletions templates/xnetevents/edit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,12 @@ function deadlineChange(box)
non</label>

<br />
Autoriser les non-membres&nbsp;:
<label><input type="radio" name="accept_nonmembre" value="1" {if $evt.accept_nonmembre}checked="checked"{/if} />
oui</label>
<label><input type="radio" name="accept_nonmembre" value="0" {if !$evt.accept_nonmembre}checked="checked"{/if}/>
non</label>
Accepter les&nbsp;:
<select name="access_control">
<option value="group" {if $evt.access_control eq group}selected{/if}>membres du groupe</option>
<option value="registered" {if $evt.access_control eq registered}selected{/if}>utilisateurs de polytechnique.net</option>
<option value="all" {if $evt.access_control eq all}selected{/if}>tout le monde</option>
</select>

<br />
Autoriser les invités&nbsp;:
Expand Down
55 changes: 55 additions & 0 deletions templates/xnetevents/subscribe_not_logged.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{**************************************************************************}
{* *}
{* Copyright (C) 2003-2016 Polytechnique.org *}
{* http://opensource.polytechnique.org/ *}
{* *}
{* This program is free software; you can redistribute it and/or modify *}
{* it under the terms of the GNU General Public License as published by *}
{* the Free Software Foundation; either version 2 of the License, or *}
{* (at your option) any later version. *}
{* *}
{* This program is distributed in the hope that it will be useful, *}
{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
{* GNU General Public License for more details. *}
{* *}
{* You should have received a copy of the GNU General Public License *}
{* along with this program; if not, write to the Free Software *}
{* Foundation, Inc., *}
{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
{* *}
{**************************************************************************}

<h1>{$asso->nom}&nbsp;: Evénement {$event.intitule}</h1>

<p class='descr'>
{assign var=profile value=$event.organizer->profile()}
Cet événement a lieu <strong>{$event.date}</strong> et a été proposé par
<a href='https://www.polytechnique.org/profile/{$profile->hrpid}' class='popup2'>
{$event.organizer->fullName('promo')}
</a>.
</p>

<p class='descr'>
{$event.descriptif|nl2br}
</p>

{if $form_sent}
Un email de confirmation vous à été envoyé à {$email}.
{else}
<form action="{$platal->ns}events/sub/{$eid}" method="post">
{xsrf_token_field}
<p style="text-align:center">
Nom : <input type="text" name='nom' />
Prénom : <input type="text" name='prenom' />
E-mail : <input type="text" name='email' />
<br/>
<br/>
<br/>
<input type="submit" name='submit' value="Valider mes inscriptions" />
</p>
</form>
{/if}

{* vim:set et sw=2 sts=2 sws=2 fenc=utf-8: *}

37 changes: 37 additions & 0 deletions templates/xnetevents/subscribe_not_logged_confirm.mail.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{**************************************************************************}
{* *}
{* Copyright (C) 2003-2016 Polytechnique.org *}
{* http://opensource.polytechnique.org/ *}
{* *}
{* This program is free software; you can redistribute it and/or modify *}
{* it under the terms of the GNU General Public License as published by *}
{* the Free Software Foundation; either version 2 of the License, or *}
{* (at your option) any later version. *}
{* *}
{* This program is distributed in the hope that it will be useful, *}
{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
{* GNU General Public License for more details. *}
{* *}
{* You should have received a copy of the GNU General Public License *}
{* along with this program; if not, write to the Free Software *}
{* Foundation, Inc., *}
{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
{* *}
{**************************************************************************}

{config_load file="mails.conf" section="xnet_notification"}
{if $mail_part eq 'head'}
{from full=#from#}
{subject text="[`$group`] $event"}
{elseif $mail_part eq 'wiki'}
M. {$prenom} {$nom},

Pour valider votre inscription l'événement {$event}, veuillez suivre ce lien de confirmation :

{$url}

{include file="include/signature.mail.tpl"}
{/if}
{* vim:set et sw=2 sts=2 sws=2: *}

3 changes: 3 additions & 0 deletions upgrade/1.1.21/01_add_group_events_access_control.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
alter table group_events add access_control enum('group','registered','all') default 'registered' after accept_nonmembre;
update group_events set access_control='group' where accept_nonmembre=0;
update group_events set access_control='registered' where accept_nonmembre=1;