- #451: vCard are RFC compliant -FRU
- #502: Use 'alias' instead of 'aka' to specify the nickname -FRU
- #536: Can use login.promo as a valid user identifier -FRU
+ - #539: Medals and deco need validation from admin -Car
- #540: Profile of unregistered user redirects to marketing -FRU
* Xnet:
}
if (Env::v('medal_op')=='ajouter' && Env::i('medal_id')) {
- XDB::execute("INSERT INTO profile_medals_sub (uid,mid) VALUES ({?}, {?})", S::v('uid', -1), Env::i('medal_id'));
+ require_once('validations.inc.php');
+ $req = new MedalReq(S::v('uid',-1),Env::i('medal_id'), Env::i('grade_id'));
+ if ($req->mid == 20) // defnat
+ {
+ $req->commit();
+ unset($_REQUEST['medal_op']); // pour ne pas avoir le message d'attente de validation
+ }
+ else
+ {
+ $req->submit();
+ }
}
}
if (Post::has('grade')) {
}
// }}}
- // {{{ function get_request()
+ // {{{ function get_typed_request()
/** fonction statique qui renvoie la requête de l'utilisateur d'id $uidau timestamp $t
* @param $uid l'id de l'utilisateur concerné
* @param $stamp le timestamp de la requête
*
* XXX fonction "statique" XXX
- * à utiliser uniquement pour récupérer un objet dans la BD avec Validate::get_request(...)
+ * à utiliser uniquement pour récupérer un objet dans la BD avec Validate::get_typed_request(...)
*/
- function get_request($uid, $type, $stamp = -1)
+ function get_typed_request($uid, $type, $stamp = -1)
{
if ($stamp == -1) {
$res = XDB::query('SELECT data FROM requests WHERE user_id={?} and type={?}', $uid, $type);
function get_request($uid)
{
- return parent::get_request($uid,'alias');
+ return parent::get_typed_request($uid,'alias');
}
// }}}
}
// }}}
- // {{{ function get_request()
-
- function get_request($uid)
- {
- return parent::get_request($uid,$this->title);
- }
-
- // }}}
// {{{ function formu()
function formu()
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2006 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 *
+ ***************************************************************************/
+
+// {{{ class MedalReq
+
+class MedalReq extends Validate
+{
+ // {{{ properties
+
+ var $mid;
+ var $gid;
+
+ // }}}
+ // {{{ constructor
+
+ function MedalReq ($_uid, $_idmedal, $_subidmedal, $_stamp=0)
+ {
+ $this->Validate($_uid, false, 'medal', $_stamp);
+ $this->mid = $_idmedal;
+ $this->gid = $_subidmedal;
+ }
+
+ // }}}
+ // {{{ function formu()
+
+ function formu()
+ {
+ return 'include/form.valid.medals.tpl';
+ }
+
+ // }}}
+ // {{{ function _mail_subj
+
+ function _mail_subj()
+ {
+ return "[Polytechnique.org/Décoration] Demande de décoration : ".$this->medal_name();
+ }
+
+ // }}}
+ // {{{ function _mail_body
+
+ function _mail_body($isok)
+ {
+ if ($isok) {
+ return " La décoration ".$this->medal_name()." que tu avais demandée vient d'être acceptée.";
+ } else {
+ return " La demande que tu avais faite pour la décoration ".$this->medal_name()." a été refusée.";
+ }
+ }
+
+ // }}}
+ // {{{ function medal_name
+
+ function medal_name()
+ {
+ //var_dump($this);
+ $r = XDB::query("
+ SELECT IF (g.text IS NOT NULL, CONCAT(m.text,' - ', g.text), m.text)
+ FROM profile_medals AS m
+ LEFT JOIN profile_medals_grades AS g ON(g.mid = m.id AND g.gid = {?})
+ WHERE m.id = {?}", $this->gid, $this->mid);
+ return $r->fetchOneCell();
+ }
+
+ // }}}
+ // {{{ function commit()
+
+ function commit ()
+ {
+ return XDB::execute('REPLACE INTO profile_medals_sub VALUES({?}, {?}, {?})', $this->uid, $this->mid, $this->gid);
+ }
+
+ // }}}
+}
+
+// }}}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
}
// }}}
- // {{{ function get_request()
-
- function get_request($uid)
- {
- return parent::get_request($uid,'usage');
- }
-
- // }}}
// {{{ function formu()
function formu()
}
// }}}
- // {{{ function get_request()
-
- function get_request($uid)
- {
- return parent::get_request($uid,'orange');
- }
-
- // }}}
// {{{ function formu()
function formu()
function get_request($uid)
{
- return parent::get_request($uid,'photo');
+ return parent::get_typed_request($uid,'photo');
}
// }}}
}
if(Env::has('uid') && Env::has('type') && Env::has('stamp')) {
- $req = Validate::get_request(Env::v('uid'), Env::v('type'), Env::v('stamp'));
+ $req = Validate::get_typed_request(Env::v('uid'), Env::v('type'), Env::v('stamp'));
if($req) { $req->handle_formu(); }
}
--- /dev/null
+{**************************************************************************}
+{* *}
+{* Copyright (C) 2003-2006 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 *}
+{* *}
+{**************************************************************************}
+
+
+<tr class="pair">
+ <td class="titre">Médaille :</td>
+ <td>{$valid->medal_name()}</td>
+</tr>
+
+{* vim:set et sw=2 sts=2 sws=2: *}
{
var selid = document.forms.prof_annu.medal_sel.selectedIndex;
document.forms.prof_annu.medal_id.value = document.forms.prof_annu.medal_sel.options[selid].value;
+ document.forms.prof_annu.grade_id.value = document.forms.prof_annu.grade_sel.value;
document.forms.prof_annu.medal_op.value = "ajouter";
document.forms.prof_annu.submit();
}
document.forms.prof_annu.medal_op.value = "retirer";
document.forms.prof_annu.submit();
}
+ var subgrades = new array();
+ function getoption( select_input, j)
+ {
+ if (!document.all)
+ {
+ return select_input.options[j];
+ }
+ else
+ {
+ return j;
+ }
+ }
+ function medal_grades( sel_medal )
+ {
+ var subg = subgrades[sel_medal.selectedIndex];
+ document.getElementById("grade_sel_div").style.display = subg?"inline":"none";
+ if (!subg) return;
+ var select = document.getElementById("grade_sel");
+ while (select.length > 1)
+ {
+ select.remove(1);
+ }
+
+ for (i=0; i < subg.length; i++)
+ {
+ var dmc = document.createElement("option");
+ dmc.text= subg[i][1];
+ dmc.value = subg[i][0];
+ select.add(dmc,getoption(select,i));
+ }
+ select.add(getoption(select,subg.length),getoption(select,0));
+ select.remove(subg.length+1);
+ }
//]]>
-</script>
{/literal}
+{foreach from=$medal_list key=type item=list}
+ {foreach from=$list item=m}{if $grades[$m.id]|@count}
+ subgrades[{$m.id}] = new array({$grades[$m.id]|@count});
+ i = 0;
+ {foreach from=$grades[$m.id] item=g}
+ subgrades[{$m.id}][i] = [{$g.gid},"{$g.text}"];
+ i++;
+ {/foreach}
+ {/if}{/foreach}
+{/foreach}
+
+</script>
+{if $smarty.request.medal_op eq "ajouter"}
+<div class="erreur">
+ Ta demande a bien été prise en compte, elle sera validée prochainement par un administrateur.
+</div>
+{/if}
<div class="blocunite_tab">
<input type="hidden" value="" name="medal_op" />
<input type="hidden" value="" name="medal_id" />
+ <input type="hidden" value="" name="grade_id" />
<table class="bicol" cellspacing="0" cellpadding="0">
<tr>
<th colspan="3">
<td class="colm">
<span class="valeur">{$m.medal}</span><br />
{if $grades[$m.id]|@count}
- <select name="grade[{$m.id}]">
- <option value='0'>-- non précisé --</option>
{foreach from=$grades[$m.id] item=g}
- <option value='{$g.gid}' {if $g.gid eq $m.gid}selected='selected'{/if}>{$g.text}</option>
+ {if $g.gid eq $m.gid}{$g.text}{/if}
{/foreach}
- </select>
- {else}
- -- non précisé --
{/if}
</td>
<td class="cold">
</td>
<td class="colm">
- <select name="medal_sel">
+ <select name="medal_sel" onchange="medal_grades(this)">
<option value=''></option>
{foreach from=$medal_list key=type item=list}
<optgroup label="{$trad[$type]}">
</optgroup>
{/foreach}
</select>
+ <div id="grade_sel_div" style="display:none"><br/>
+ <select name="grade_sel" id="grade_sel">
+ <option value="0"></option>
+ </select>
+ </div>
</td>
<td class="cold">
<span class="lien">