--- /dev/null
+function subscribe($forlife, $uid, $promo, $pass)
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2004 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 *
+ ***************************************************************************
+ $Id: banana.inc.php,v 1.1 2004-12-01 13:13:03 x2000habouzit Exp $
+ ***************************************************************************/
+
+// {{{ function banana_subscirbe()
+
+function &banana_subscribe($forlife, $uid, $promo, $password, &$result)
+{
+ global $globals;
+
+ $cible = array('xorg.general','xorg.pa.emploi','xorg.pa.divers','xorg.pa.logements');
+ $p_for = "xorg.promo.x$promo";
+
+ // récupération de l'id du forum promo
+ $res = $globals->db->query("SELECT fid FROM forums.list WHERE nom='$p_for'");
+ if (mysql_num_rows($res) == 1) {
+ $cible[] = $p_for;
+ } else { // pas de forum promo, il faut le créer
+ $req_au=$globals->db->query("SELECT SUM(perms IN ('admin','user') AND deces=0),COUNT(*) FROM auth_user_md5 WHERE promo='$promo'");
+ list($effau, $effid) = mysql_fetch_row($req_au);
+ mysql_free_result($req_au);
+ if (5*$effau>$effid) { // + de 20% d'inscrits
+ require_once("xorg.mailer.inc.php");
+ $mymail = new XOrgMailer('forums.promo.tpl');
+ $mymail->assign('promo', $promo);
+ $mymail->send();
+ }
+ }
+ mysql_free_result($res);
+
+ while (list ($key, $val) = each ($cible)) {
+ $globals->db->query("INSERT INTO forums.abos (fid,uid)
+ SELECT fid,'$uid'
+ FROM forums.list
+ WHERE nom='$val'");
+ }
+
+ return ($result = true);
+}
+
+// }}}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
* Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************
- $Id: step4.php,v 1.20 2004-11-30 21:11:39 x2000habouzit Exp $
+ $Id: step4.php,v 1.21 2004-12-01 13:13:03 x2000habouzit Exp $
***************************************************************************/
require_once("xorg.inc.php");
$sql = "UPDATE auth_user_md5 SET password='$password', nationalite=$nationalite, perms='user',
date='$date', naissance='$naissance', date_ins = NULL WHERE matricule='$matricule'";
$globals->db->query($sql);
- $sql = "INSERT INTO auth_user_quick (user_id)
- SELECT user_id
- FROM auth_user_md5
- WHERE matricule='$matricule'";
+ $sql = "REPLACE INTO auth_user_quick (user_id)
+ SELECT user_id
+ FROM auth_user_md5
+ WHERE matricule='$matricule'";
$globals->db->query($sql);
// on vérifie qu'il n'y a pas eu d'erreur
$mymail->send();
}
-
- /****************** inscription à la liste promo +nl ****************/
- $inspromo = inscription_listes_base($uid,$password,$promo);
- /****************** inscription aux forums de base ****************/
- $insforumpromo = inscription_forum_promo($uid,$promo);
- $insforums = inscription_forums($uid);
-
// effacer la pré-inscription devenue
$globals->db->query("update en_cours set loginbis='INSCRIT' WHERE username='$forlife'");
// s'il est dans la table envoidirect, on le marque comme inscrit
$globals->db->query("update envoidirect set date_succes=NOW() where matricule = $matricule");
+
+ require_once("xorg.hook.inc.php");
+ $hook = new XOrgHook('core');
+ $hook->subscribe($forlife, $uid, $promo, $password, true);
+
start_connexion($uid,false);
+ /****************** inscription à la liste promo +nl ****************/
+ $inspromo = inscription_listes_base($uid,$password,$promo);
} else
$page->assign('error',ERROR_REF);
* Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************
- $Id: user.func.inc.php,v 1.5 2004-11-22 07:40:17 x2000habouzit Exp $
+ $Id: user.func.inc.php,v 1.6 2004-12-01 13:13:03 x2000habouzit Exp $
***************************************************************************/
// {{{ function user_clear_all_subs()
}
// }}}
-// {{{ function inscription_forum_promo()
-
-/** inscrit l'uid donnée au forum promo
- * @param $uid UID
- * @param $promo promo
- * @return la reponse MySQL
- * @see step4.php
- */
-function inscription_forum_promo($uid,$promo)
-{
- global $globals;
- // récupération de l'id du forum promo
- $result=$globals->db->query("SELECT fid FROM forums.list WHERE nom='xorg.promo.x$promo'");
- if (!list($fid)=mysql_fetch_row($result)) { // pas de forum promo, il faut le créer
- $req_au=$globals->db->query("SELECT count(*) FROM auth_user_md5 WHERE promo='$promo' AND perms IN ('admin','user')");
- list($effau) = mysql_fetch_row($req_au);
- $req_id=$globals->db->query("SELECT count(*) FROM auth_user_md5 WHERE promo='$promo'");
- list($effid) = mysql_fetch_row($req_id);
- if (5*$effau>$effid) { // + de 20% d'inscrits
- require_once("xorg.mailer.inc.php");
- $mymail = new XOrgMailer('forums.promo.tpl');
- $mymail->assign('promo', $promo);
- $mymail->send();
- }
- $fid = false;
- }
- mysql_free_result($result);
- if ($fid) {
- $globals->db->query("INSERT INTO forums.abos (fid,uid) VALUES ('$fid','$uid')");
- $res = !($globals->db->err());
- } else $res = false;
- return $res;
-}
-
-// }}}
-// {{{ function inscription_forums()
-
-/** inscrit UID aux forums par défaut
- * @param $uid UID
- * @return la reponse MySQL globale
- * @see step4.php
- */
-function inscription_forums($uid)
-{
- global $globals;
- $res = true;
- $cible = array('xorg.general','xorg.pa.emploi','xorg.pa.divers','xorg.pa.logements');
- while (list ($key, $val) = each ($cible)) {
- $result=$globals->db->query("SELECT fid FROM forums.list WHERE nom='$val'");
- list($fid)=mysql_fetch_row($result);
- $globals->db->query("INSERT INTO forums.abos (fid,uid) VALUES ('$fid','$uid')");
- $res = $res and !($globals->db->err());
- }
- return $res;
-}
-
-// }}}
// {{{ function inscription_listes_base()
/** inscrit l'uid donnée à la promo
* @category XOrgCore
* @package XOrgCore
* @author Pierre Habouzit <pierre.habouzit@polytechnique.org>
- * @version $Id: xorg.hook.inc.php,v 1.7 2004-11-21 15:19:00 x2000habouzit Exp $
+ * @version $Id: xorg.hook.inc.php,v 1.8 2004-12-01 13:13:03 x2000habouzit Exp $
* @access public
* @link http://doc.polytechnique.org/XOrgModule/#hook
* @since Classe available since 0.9.3
}
foreach (glob($globals->root."/hooks/$name/*.inc.php") as $file) {
require_once("$file");
- $this->_mods[] = str_replace('.inc.php', '', $file);
+ $this->_mods[] = basename($file, '.inc.php');
}
}
*/
function __call($function, $arguments, &$return)
{
- if ( ($i = count($argument) - 1) < 0) {
+ if ( ($i = count($arguments) - 1) < 0) {
$this->raiseError("In the Hook « {$this->_name} » the function « $function » expects at least 1 argument");
}
foreach ($this->_mods as $mod) {
+ echo $mod.'_'.$function;
if (!function_exists($mod.'_'.$function)) continue;
- $argument[$i] =& call_user_func_array($mod.'_'.$function,$argument);
+ $arguments[$i] =& call_user_func_array($mod.'_'.$function,$arguments);
}
- $return =& $argument[$i];
+ $return =& $arguments[$i];
return true;
}