<?php
/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
+ * Copyright (C) 2003-2010 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
public function submit()
{
if ($this->unique) {
- XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?}', $this->user->id(), $this->type);
+ XDB::execute('DELETE FROM requests
+ WHERE uid = {?} AND type = {?}',
+ $this->user->id(), $this->type);
}
$this->stamp = date('YmdHis');
- XDB::execute('INSERT INTO requests (user_id, type, data, stamp) VALUES ({?}, {?}, {?}, {?})',
+ XDB::execute('INSERT INTO requests (uid, type, data, stamp)
+ VALUES ({?}, {?}, {?}, {?})',
$this->user->id(), $this->type, $this, $this->stamp);
global $globals;
protected function update()
{
- XDB::execute('UPDATE requests SET data={?}, stamp=stamp
- WHERE user_id={?} AND type={?} AND stamp={?}',
+ XDB::execute('UPDATE requests
+ SET data = {?}, stamp = stamp
+ WHERE uid = {?} AND type = {?} AND stamp = {?}',
$this, $this->user->id(), $this->type, $this->stamp);
return true;
}
global $globals;
if ($this->unique) {
- $success = XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?}',
+ $success = XDB::execute('DELETE FROM requests
+ WHERE uid = {?} AND type = {?}',
$this->user->id(), $this->type);
} else {
- $success = XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?} AND stamp={?}',
+ $success = XDB::execute('DELETE FROM requests
+ WHERE uid = {?} AND type = {?} AND stamp = {?}',
$this->user->id(), $this->type, $this->stamp);
}
$globals->updateNbValid();
$this->trigSuccess('Email de refus envoyé');
return true;
} else {
- $this->trigError('pas de motivation pour le refus !!!');
+ $this->trigError('Pas de motivation pour le refus !!!');
}
}
$body = ($this->user->isFemale() ? "Chère camarade,\n\n" : "Cher camarade,\n\n")
. $this->_mail_body($isok)
- . (Env::has('comm') ? "\n\n".Env::v('comm') : '')
- . "\n\nCordialement,\n\n-- \nL'équipe de Polytechnique.org\n";
+ . (Env::has('comm') ? "\n\n" . Env::v('comm') : '')
+ . "\n\nCordialement,\n-- \nL'équipe de Polytechnique.org\n"
+ . $this->_mail_ps($isok);
$mailer->setTxtBody(wordwrap($body));
$mailer->send();
static public 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);
+ $res = XDB::query('SELECT data
+ FROM requests
+ WHERE uid = {?} and type = {?}',
+ $uid, $type);
} else {
- $res = XDB::query('SELECT data, DATE_FORMAT(stamp, "%Y%m%d%H%i%s") FROM requests WHERE user_id={?} AND type={?} and stamp={?}', $uid, $type, $stamp);
+ $res = XDB::query('SELECT data, DATE_FORMAT(stamp, "%Y%m%d%H%i%s")
+ FROM requests
+ WHERE uid = {?} AND type = {?} and stamp = {?}',
+ $uid, $type, $stamp);
}
if ($result = $res->fetchOneCell()) {
$result = Validate::unserialize($result);
*/
static public function get_typed_requests($uid, $type)
{
- $res = XDB::iterRow('SELECT data FROM requests WHERE user_id={?} and type={?}', $uid, $type);
+ $res = XDB::iterRow('SELECT data
+ FROM requests
+ WHERE uid = {?} and type = {?}',
+ $uid, $type);
$array = array();
while (list($data) = $res->next()) {
$array[] = Validate::unserialize($data);
*/
static public function get_typed_requests_count($uid, $type)
{
- $res = XDB::query('SELECT COUNT(data) FROM requests WHERE user_id={?} and type={?}', $uid, $type);
+ $res = XDB::query('SELECT COUNT(data)
+ FROM requests
+ WHERE uid = {?} and type = {?}',
+ $uid, $type);
return $res->fetchOneCell();
}
abstract protected function _mail_subj();
// }}}
+ // {{{ function _mail_ps
+
+ protected function _mail_ps($isok)
+ {
+ return '';
+ }
+
+ // }}}
// {{{ function commit()
/** fonction à utiliser pour insérer les données dans x4dat
static $answers_table;
if (!isset($answers_table[$this->type])) {
$r = XDB::query("SELECT id, title, answer FROM requests_answers WHERE category = {?}", $this->type);
- $answers_table[$this->type] = $r->fetchAllAssoc($r);
+ $answers_table[$this->type] = $r->fetchAllAssoc();
}
return $answers_table[$this->type];
}