================================================================================
+VERSION 1.1.1 XX XX XXXX
+
+Bug/Wish:
+
+ * Emails:
+ - #1459: Lists and administrates aliases on main domain -JAC
+
+From 1.1.0 branch:
+
+ * Search:
+ - #1449: Load json2 on IE because IE<=7 do not implement JSON -FRU
+
+================================================================================
VERSION 1.1.0 26 03 2011
New:
## openid
##
-openid: get-openid spool/openid/store
-
-# There is no obvious way to automatically use the latest version
-OPENID_VERSION = 2.2.2
-OPENID_COMMIT = 782224d
-get-openid:
- @if ! test -d include/Auth; then \
- wget --no-check-certificate \
- https://github.com/openid/php-openid/tarball/$(OPENID_VERSION) \
- -O php-openid-$(OPENID_VERSION).tar.gz; \
- tar -xzf php-openid-$(OPENID_VERSION).tar.gz; \
- mv openid-php-openid-$(OPENID_COMMIT)/Auth include/; \
- rm php-openid-$(OPENID_VERSION).tar.gz; \
- rm -r openid-php-openid-$(OPENID_COMMIT); \
- fi
-
-spool/openid/store:
- mkdir -p $@
- chmod o+w $@
+openid:
+ -rm -rf include/Auth
##
## banana
--- /dev/null
+Deps
+====
+
+Debian
+------
+* php5-cli
+* php5-tidy
+* php5-mysql
+* php5-xmlrpc
+* php5-curl
+* php5-gd
+* php-date
+* php-fpdf
+* php-mail
+* php-mail-mime
+* smarty
+* apache2
+* libapache2-mod-php5
+* python
+* mysql-server
+* mysql-client
+* phpunit
+
+Recommended
+-----------
+* php5-xdebug
+* php5-xcache
+
+Languages and countries administration
+--------------------------------------
+* pkg-isocodes
+* isoquery
+
+// vim:ft=asciidoc:
-Subproject commit de2d442deb5be66b2bbe677b490588e470cfce8c
+Subproject commit 212ada1babbd46d48b44e47f24bb129370c24b6a
; command line. The value is computed automatically when php serves a web page.
baseurl = "https://www.example.org/"
+; The base url of the url shortener.
+baseurl_shortener = ""
+
; $globals->sitename
; The name of the site
;
-Subproject commit cab6c1c15dfa75c04b433447e608edb59171c376
+Subproject commit 13cec5adcabc015959a87a75ef67cc354242a6bd
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2011 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 *
+ ***************************************************************************/
+
+require_once 'xorg.inc.php';
+
+$platal = new Xorg('core');
+
+global $globals;
+$alias = ltrim($platal->pl_self(), '/');
+
+if (preg_match('/^[a-zA-Z0-9\-\/]+$/i', $alias)) {
+ $url = XDB::fetchOneCell('SELECT url
+ FROM url_shortener
+ WHERE alias = {?}',
+ $alias);
+ if ($url) {
+ http_redirect($url);
+ }
+}
+
+header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
+?>
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
+<html>
+ <head>
+ <title>404 Not Found</title>
+ </head>
+ <body>
+ <h1>Not Found</h1>
+ The requested URL <?php echo $_SERVER['REQUEST_URI'] ?> was not found on this server.<p>
+ <hr>
+ <address><?php echo $_SERVER['SERVER_SIGNATURE'] ?></address>
+ </body>
+</html>
+<?php
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
define('ERROR_INVALID_EMAIL', 3);
define('ERROR_LOOP_EMAIL', 4);
+// Checks if an email update is required in MLs and aliases.
+// This occurs when the user don't have email permissions and her email has changed.
+function require_email_update(User $user, $new_email)
+{
+ Platal::assert(!is_null($user), 'User cannot be null.');
+
+ return !$user->checkPerms(User::PERM_MAIL) && $new_email != $user->forlifeEmail();
+}
+
function format_email_alias($email)
{
if ($user = User::getSilent($email)) {
return true;
}
+// Updates an email in all aliases (groups and events).
+function update_alias_user($former_email, $new_email)
+{
+ XDB::execute('UPDATE email_virtual
+ SET redirect = {?}
+ WHERE redirect = {?} AND (type = \'alias\' OR type = \'event\')',
+ $new_email, $former_email);
+}
+
function list_alias_members($local_part, $domain)
{
$emails = XDB::fetchColumn('SELECT DISTINCT(redirect)
}
// Account Form {{{
+ require_once 'emails.inc.php';
$to_update = array();
if (Post::has('disable_weak_access')) {
$to_update['weak_password'] = null;
if (Post::t('comment') != $user->comment) {
$to_update['comment'] = Post::blank('comment') ? null : Post::t('comment');
}
- if (!$user->checkPerms(User::PERM_MAIL) && Post::t('email') != $user->forlifeEmail()) {
+ if (require_email_update($user, Post::t('email'))) {
$to_update['email'] = Post::t('email');
$listClient->change_user_email($user->forlifeEmail(), Post::t('email'));
+ update_alias_user($user->forlifeEmail(), Post::t('email'));
}
}
if (!empty($to_update)) {
// }}}
// Email forwards form {{{
- require_once("emails.inc.php");
$redirect = ($registered ? new Redirect($user) : null);
if (Post::has('add_fwd')) {
$email = Post::t('email');
'lists/soptions' => $this->make_hook('soptions', AUTH_MDP),
'lists/check' => $this->make_hook('check', AUTH_MDP),
'admin/lists' => $this->make_hook('admin_all', AUTH_MDP, 'admin'),
+ 'admin/aliases' => $this->make_hook('aaliases', AUTH_MDP, 'admin')
);
}
$listes = $this->client->get_all_lists();
$page->assign_by_ref('listes', $listes);
}
+
+ function handler_aaliases($page, $alias = null)
+ {
+ global $globals;
+ require_once 'emails.inc.php';
+ $page->setTitle('Administration - Aliases');
+
+ if (Post::has('new_alias')) {
+ pl_redirect('admin/aliases/' . Post::t('new_alias') . '@' . $globals->mail->domain);
+ }
+
+ // If no alias, list them all.
+ if (is_null($alias)) {
+ $page->changeTpl('lists/admin_aliases.tpl');
+ $page->assign('aliases', array_merge(iterate_list_alias($globals->mail->domain), iterate_list_alias($globals->mail->domain2)));
+ return;
+ }
+
+ list($local_part, $domain) = explode('@', $alias);
+ if (!($globals->mail->domain == $domain || $globals->mail->domain2 == $domain)
+ || !preg_match("/^[a-zA-Z0-9\-\.]*$/", $local_part)) {
+ $page->trigErrorRedirect('Le nom de l\'alias est erroné.', $globals->asso('diminutif') . 'admin/aliases');
+ }
+
+ // Now we can perform the action.
+ if (Post::has('del_alias')) {
+ S::assert_xsrf_token();
+
+ delete_list_alias($local_part, $domain);
+ $page->trigSuccessRedirect($alias . ' supprimé.', 'admin/aliases');
+ }
+
+ if (Post::has('add_member')) {
+ S::assert_xsrf_token();
+
+ if (add_to_list_alias(Post::t('add_member'), $local_part, $domain)) {
+ $page->trigSuccess('Ajout réussit.');
+ } else {
+ $page->trigError('Ajout infructueux.');
+ }
+ }
+
+ if (Get::has('del_member')) {
+ S::assert_xsrf_token();
+
+ if (delete_from_list_alias(Get::t('del_member'), $local_part, $domain)) {
+ $page->trigSuccess('Suppression réussie.');
+ } else {
+ $page->trigError('Suppression infructueuse.');
+ }
+ }
+
+ $page->changeTpl('lists/admin_edit_alias.tpl');
+ $page->assign('members', list_alias_members($local_part, $domain));
+ $page->assign('alias', $alias);
+ }
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
// Determines and displays the virtual alias.
if (!is_null($owner) && $profile->alias_pub == 'public') {
- $page->assign('virtualalias', $owner->emailAliases());
+ $page->assign('virtualalias', $owner->emailAlias());
}
$page->assign_by_ref('profile', $profile);
function handlers()
{
return array(
- 'url' => $this->make_hook('url', AUTH_COOKIE),
+ 'url' => $this->make_hook('url', AUTH_PUBLIC),
'admin/url' => $this->make_hook('admin_url', AUTH_MDP, 'admin')
);
}
function handler_url($page, $alias)
{
- $url = XDB::fetchOneCell('SELECT url
- FROM url_shortener
- WHERE alias = {?}',
- $alias);
-
- if (is_null($url)) {
- return PL_NOT_FOUND;
- }
- http_redirect($url);
+ http_redirect(Platal::globals()->core->base_url_shortener . $alias);
}
function handler_admin_url($page)
$alias = Post::t('alias');
$url_regex = '{^(https?|ftp)://[a-zA-Z0-9._%#+/?=&~-]+$}i';
- if (!preg_match($url_regex, $url)) {
+ if (strlen($url) > 255 || !preg_match($url_regex, $url)) {
$page->trigError("L'url donnée n'est pas valide.");
return;
}
$page->assign('url', $url);
if ($alias != '') {
- if (!preg_match('/^[a-zA-Z0-9\-]{6}$/i', $alias)) {
+ if (!preg_match('/^[a-zA-Z0-9\-\/]+$/i', $alias)) {
$page->trigError("L'alias proposé n'est pas valide.");
return;
}
+ if (preg_match('/^a\//i', $alias)) {
+ $page->trigError("L'alias commence par le préfixe 'a/' qui est réservé et donc non autorisé.");
+ return;
+ }
$page->assign('alias', $alias);
$used = XDB::fetchOneCell('SELECT COUNT(*)
}
} else {
do {
- $alias = rand_token(6);
+ $alias = 'a/' . rand_token(6);
$used = XDB::fetchOneCell('SELECT COUNT(*)
FROM url_shortener
WHERE alias = {?}',
XDB::execute('INSERT INTO url_shortener (url, alias)
VALUES ({?}, {?})',
$url, $alias);
- $page->trigSuccess("L'url « " . $url . ' » est maintenant accessible depuis « ' . Platal::globals()->baseurl . '/url/' . $alias . ' ».');
+ $page->trigSuccess("L'url « " . $url . ' » est maintenant accessible depuis « http://u.w4x.org/' . $alias . ' ».');
}
}
Post::t('full_name'), Post::t('directory_name'), Post::t('display_name'),
(Post::t('sex') == 'male') ? 'male' : 'female', Post::t('email'), $user->id());
if (XDB::affectedRows()) {
+ require_once 'emails.inc.php';
+ if (require_email_update($user, Post::t('email'))) {
+ $listClient = new MMList(S::user());
+ $listClient->change_user_email($user->forlifeEmail(), Post::t('email'));
+ update_alias_user($user->forlifeEmail(), Post::t('email'));
+ }
$user = User::getWithUID($user->id());
S::set('user', $user);
$page->trigSuccess('Données mises à jour.');
$mmlist = new MMList(S::user(), $globals->asso('mail_domain'));
if (Post::has('change')) {
+ require_once 'emails.inc.php';
S::assert_xsrf_token();
// Convert user status to X
WHERE uid = {?}',
Post::t('email'), $user->id());
}
+ if (require_email_update($user, Post::t('email'))) {
+ $listClient = new MMList(S::user());
+ $listClient->change_user_email($user->forlifeEmail(), Post::t('email'));
+ update_alias_user($user->forlifeEmail(), Post::t('email'));
+ }
if (XDB::affectedRows()) {
$page->trigSuccess('Données de l\'utilisateur mises à jour.');
}
$page->assign('listes', $listes);
$page->assign('aliases', iterate_list_alias($globals->asso('mail_domain')));
$page->assign('may_update', may_update());
+ if (S::suid()) {
+ $page->trigWarning("Attention : l'affichage des listes de diffusion ne tient pas compte de l'option « Voir le site comme… ».");
+ }
if (count($listes) > 0 && !$globals->asso('has_ml')) {
XDB::execute("UPDATE groups
<td>
<a href="admin/lists">MLs</a>
|
+ <a href="admin/aliases">aliases</a>
+ |
<a href="admin/mx/broken">MX défaillants</a>
|
<a href="admin/emails/lost">Perdus de vue</a>
{/if}
</td>
</tr>
- </table><br />
-</form>
+ </table>
+</form><br />
<table class="bicol" style="text-align: center">
<tr>
--- /dev/null
+{**************************************************************************}
+{* *}
+{* Copyright (C) 2003-2011 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>Aliases</h1>
+
+<table cellspacing="0" cellpadding="0" class="tinybicol">
+ <tr>
+ <th>Aliases</th>
+ </tr>
+ {if $aliases|@count}
+ {foreach from=$aliases item=alias}
+ <tr>
+ <td><a href="admin/aliases/{$alias}">{$alias}</a></td>
+ </tr>
+ {/foreach}
+ {else}
+ <tr>
+ <td>Aucun alias</td>
+ </tr>
+ {/if}
+</table>
+
+<form method="post" action="admin/aliases">
+ {xsrf_token_field}
+ <p class="center">
+ <input type="text" name="new_alias" />
+ <input type="submit" value="Créer l'alias" />
+ </p>
+</form>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
--- /dev/null
+{**************************************************************************}
+{* *}
+{* Copyright (C) 2003-2011 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 *}
+{* *}
+{**************************************************************************}
+
+<p>[<a href="admin/aliases">Retour à la liste des aliases</a>]</p>
+
+<h1>Membres de {$alias}</h1>
+
+<table class="tinybicol">
+ {if $members.users|@count}
+ {foreach from=$members.users item=member}
+ <tr>
+ <td>
+ {if $member->hasProfile()}
+ <a href="https://www.polytechnique.org/profile/{$member->hruid}" class="popup2">{$member->fullName()}</a>
+ {else}
+ {$member->fullName()}
+ {/if}
+ </td>
+ <td class="right">{$member->promo()}</td>
+ <td class="center">
+ <a href="admin/aliases/{$alias}?del_member={$member->id()}&token={xsrf_token}">
+ {icon name=delete title="retirer membre"}
+ </a>
+ </td>
+ </tr>
+ {/foreach}
+ {/if}
+ {if $members.nonusers|@count}
+ {foreach from=$members.nonusers item=member}
+ <tr>
+ <td>{$member}</td>
+ <td></td>
+ <td class="center">
+ <a href="admin/aliases/{$alias}?del_member={$member}&token={xsrf_token}">
+ {icon name=delete title="retirer membre"}
+ </a>
+ </td>
+ </tr>
+ {/foreach}
+ {/if}
+ {if $members.users|@count eq 0 && $members.nonusers|@count eq 0}
+ <tr>
+ <td colspan="3">
+ <em>aucun membre…</em>
+ </td>
+ </tr>
+ {/if}
+ <tr>
+ <th colspan="3">Ajouter</th>
+ </tr>
+ <tr>
+ <td colspan="3" class="center">
+ <form method="post" action="admin/aliases/{$alias}">
+ {xsrf_token_field}
+ <div>
+ <input type="text" name="add_member" />
+
+ <input type="submit" value="ajouter" />
+ </div>
+ </form>
+ </td>
+ </tr>
+</table>
+
+
+<form method="post" action="admin/aliases/{$alias}">
+ {xsrf_token_field}
+ <p class="center">
+ <input type="submit" name="del_alias" value="Supprimer l'alias" onclick="return confirm('ES tu sûr de vouloir supprimer cet alias.')" />
+ </p>
+</form>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
<td><input type="text" name="url" value="{if t($url)}{$url}{/if}" /></td>
</tr>
<tr>
- <th>Alias (6 caractères, optionnel) :</th>
+ <th>Alias (optionnel) :</th>
<td>
- <input type="text" name="alias" size="6" maxlength="6" value="{if t($alias)}{$alias}{/if}" />
- <small>(peut contenir lettres, chiffres et tirets)</small>
+ <input type="text" name="alias" size="42" maxlength="255" value="{if t($alias)}{$alias}{/if}" />
+ <small>(peut contenir lettres, chiffres, tirets et /)</small>
</td>
</tr>
</table>
<p class="center"><input type="submit" value="Raccourcir" /></p>
</form>
+<h3>Explications</h3>
+<p>
+ L'alias peut être demandé. Dans ce cas, sa longueur maximal autorisée est
+ de 255 lettres, chiffres, tirets ou /. Ce dernier permet de définir des
+ domaines pour regrouper des raccourcis liés. Par exemple, « nl-04-04/ »
+ pourrait être utilisé comme base pour les urls de la lettre mensuelle d'avril
+ 2004.<br />
+ Si aucun alias n'est fournit, le site en génère un de 6 caractères aléatoires
+ accolés à la la base « a/ » (par exemple : « a/azerty ». Ce
+ préfixe « a/ » et réservé à cet usage et ne peut être utilisé pour
+ former une url choisie.
+</p>
+
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
<td>
<label><input type="checkbox" name="ml[{$l.list}]" value="1" {if $smarty.request.ml[$l.list]}checked="checked"{/if} />
{$l.addr}</label>
- <a href="{$platal->ns}lists/admin/{$l.list}" class="popup">(voir composition)</a>
+ <a href="{$platal->ns}lists/members/{$l.list}" class="popup">(voir composition)</a>
</td>
</tr>
{/foreach}
--- /dev/null
+-- Updates serbian iso code.
+UPDATE profile_langskills
+ SET lid = 'srp'
+ WHERE lid = 'scc';
+DELETE FROM profile_langskill_enum
+ WHERE iso_639_2b = 'scc';
+
+-- vim:set syntax=mysql:
--- /dev/null
+ DELETE e2
+ FROM email_virtual AS e1
+INNER JOIN email_virtual AS e2
+ WHERE e1.email = e2.email AND e1.domain = e2.domain AND e1.redirect != e2.redirect
+ AND e1.redirect = REPLACE(e2.redirect, '@m4x.org', '@polytechnique.org');
+UPDATE email_virtual
+ SET redirect = REPLACE(redirect, '@m4x.org', '@polytechnique.org')
+ WHERE redirect LIKE '%@m4x.org';
+
+-- vim:set syntax=mysql:
--- /dev/null
+DROP TABLE IF EXISTS tmp_url_shortener;
+CREATE TEMPORARY TABLE tmp_url_shortener LIKE url_shortener;
+INSERT INTO tmp_url_shortener SELECT * FROM url_shortener;
+DROP TABLE url_shortener;
+CREATE TABLE url_shortener (
+ alias VARCHAR(255) NOT NULL DEFAULT '',
+ url TEXT NOT NULL,
+ PRIMARY KEY (alias)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+INSERT INTO url_shortener (alias, url)
+ SELECT alias, url
+ FROM tmp_url_shortener;
+DROP TABLE IF EXISTS tmp_url_shortener;
+
+-- vim:set syntax=mysql:
--- /dev/null
+The following variable should be set:
+[Core]
+baseurl_shortener = "http://u.w4x.org/"
--- /dev/null
+../../bin/connect.db.inc.php
\ No newline at end of file
--- /dev/null
+#!/bin/bash
+
+. ../inc/pervasive.sh
+
+###########################################################
+[ "$DATABASE" != "x4dat" ] || die "Cannot target x4dat"
+
+confirm "* Running database upgrade scripts"
+mysql_run_directory .