// {{{ class EntrReq
-class EntrReq extends Validate
+class EntrReq extends ProfileValidate
{
// {{{ properties
// }}}
// {{{ constructor
- public function __construct(User &$_user, $_id, $_name, $_acronym, $_url, $_email, $_tel, $_fax, $_address, $_stamp = 0)
+ public function __construct(User &$_user, Profile &$_profile, $_id, $_name, $_acronym, $_url, $_email, $_tel, $_fax, $_address, $_stamp = 0)
{
- parent::__construct($_user, false, 'entreprise', $_stamp);
+ parent::__construct($_user, $_profile, false, 'entreprise', $_stamp);
$this->id = $_id;
$this->name = $_name;
$this->acronym = $_acronym;
protected function handle_editor()
{
if (Env::has('holdingid')) {
- $this->holdingid = trim(Env::v('holdingid'));
+ $this->holdingid = Env::t('holdingid');
}
if (Env::has('name')) {
- $this->name = trim(Env::v('name'));
+ $this->name = Env::t('name');
if (Env::has('acronym')) {
- $this->acronym = trim(Env::v('acronym'));
+ $this->acronym = Env::t('acronym');
if (Env::has('url')) {
- $this->url = trim(Env::v('url'));
+ $this->url = Env::t('url');
if (Env::has('NAF_code')) {
- $this->NAF_code = trim(Env::v('NAF_code'));
+ $this->NAF_code = Env::t('NAF_code');
if (Env::has('AX_code')) {
- $this->AX_code = trim(Env::v('AX_code'));
+ $this->AX_code = Env::t('AX_code');
return true;
}
}
return XDB::execute('UPDATE profile_job
SET jobid = {?}
WHERE pid = {?} AND id = {?}',
- $jobid, $this->user->profile()->id(), $this->id);
+ $jobid, $this->profile->id(), $this->id);
}
// }}}
// {{{ class MedalReq
-class MedalReq extends Validate
+class MedalReq extends ProfileValidate
{
// {{{ properties
// }}}
// {{{ constructor
- public function __construct(User &$_user, $_idmedal, $_subidmedal, $_stamp=0)
+ public function __construct(User &$_user, Profile &$_profile, $_idmedal, $_subidmedal, $_stamp = 0)
{
- parent::__construct($_user, false, 'medal', $_stamp);
+ parent::__construct($_user, $_profile, false, 'medal', $_stamp);
$this->mid = $_idmedal;
$this->gid = $_subidmedal;
if (is_null($this->gid)) {
protected function _mail_subj()
{
- return "[Polytechnique.org/Décoration] Demande de décoration : ".$this->medal_name();
+ return '[Polytechnique.org/Décoration] Demande de décoration : ' . $this->medal_name();
}
// }}}
protected function _mail_body($isok)
{
if ($isok) {
- return " La décoration ".$this->medal_name()." vient d'être ajoutée à ta fiche.";
+ return ' La décoration ' . $this->medal_name() . ' vient d\'être ajoutée à ta fiche.';
} else {
- return " La demande que tu avais faite pour la décoration ".$this->medal_name()." a été refusée.";
+ return ' La demande que tu avais faite pour la décoration ' . $this->medal_name() . ' a été refusée.';
}
}
public function medal_name()
{
- $r = XDB::query("
- SELECT m.text
- FROM profile_medal_enum AS m
- WHERE m.id = {?}", $this->mid);
- return $r->fetchOneCell();
+ $res = XDB::query('SELECT m.text
+ FROM profile_medal_enum AS m
+ WHERE m.id = {?}', $this->mid);
+ return $res->fetchOneCell();
}
// }}}
{
return XDB::execute('REPLACE INTO profile_medals
VALUES ({?}, {?}, {?})',
- $this->user->profile()->id(), $this->mid,
+ $this->profile->id(), $this->mid,
is_null($this->gid) ? 0 : $this->gid);
}
// }}}
// {{{ function get_request($medal)
- static public function get_request($uid, $type)
+ static public function get_request($pid, $type)
{
- $reqs = Validate::get_typed_requests($uid, 'medal');
+ $reqs = parent::get_typed_requests($pid, 'medal');
foreach ($reqs as &$req) {
if ($req->mid == $type) {
return $req;
// {{{ class NamesReq4
-class NamesReq extends Validate
+class NamesReq extends ProfileValidate
{
// {{{ properties
// }}}
// {{{ constructor
- public function __construct(User &$_user, $_search_names, $_private_name_end)
+ public function __construct(User &$_user, Profile &$_profile, $_search_names, $_private_name_end)
{
- parent::__construct($_user, true, 'usage');
+ parent::__construct($_user, $_profile, true, 'usage');
require_once 'name.func.inc.php';
$this->sn_types = build_types();
- $this->sn_old = build_sn_pub($this->user->profile()->id());
+ $this->sn_old = build_sn_pub($this->profile->id());
$this->sn_new = $_search_names;
$this->new_alias = true;
$this->display_names = array();
build_display_names($this->display_names, $_search_names,
- $this->user->profile()->isFemale(), $_private_name_end, $this->new_alias);
+ $this->profile->isFemale(), $_private_name_end, $this->new_alias);
foreach ($this->sn_new AS $key => &$sn) {
if (!isset($sn['pub'])) {
unset($this->sn_new[$key]);
}
}
- $res = XDB::query("SELECT alias
- FROM aliases
- WHERE uid = {?} AND type = 'alias' AND FIND_IN_SET('usage', flags)",
- $this->user->id());
- $this->old_alias = $res->fetchOneCell();
- if ($this->old_alias != $this->new_alias) {
- $res = XDB::query("SELECT uid
+
+ if (!is_null($this->profileOwner)) {
+ $res = XDB::query("SELECT alias
FROM aliases
- WHERE alias = {?}",
- $this->new_alias);
- if ($res->fetchOneCell()) {
- $this->new_alias = null;
+ WHERE uid = {?} AND type = 'alias' AND FIND_IN_SET('usage', flags)",
+ $this->profileOwner->id());
+ $this->old_alias = $res->fetchOneCell();
+ if ($this->old_alias != $this->new_alias) {
+ $res = XDB::query("SELECT uid
+ FROM aliases
+ WHERE alias = {?}",
+ $this->new_alias);
+ if ($res->fetchOneCell()) {
+ $this->new_alias = null;
+ }
}
}
}
global $globals;
if ($isok) {
$res = " Le changement de nom que tu as demandé vient d'être effectué.";
- if ($this->old_alias != $this->new_alias) {
- if ($this->old_alias) {
- $res .= "\n\n Les alias {$this->old_alias}@{$globals->mail->domain} et @{$globals->mail->domain2} ont été supprimés.";
+ if (!is_null($this->profileOwner)) {
+ if ($this->old_alias != $this->new_alias) {
+ if ($this->old_alias) {
+ $res .= "\n\n Les alias {$this->old_alias}@{$globals->mail->domain} et @{$globals->mail->domain2} ont été supprimés.";
+ }
+ if ($this->new_alias) {
+ $res .= "\n\n Les alias {$this->new_alias}@{$globals->mail->domain} et @{$globals->mail->domain2} sont maintenant à ta disposition !";
+ }
}
- if ($this->new_alias) {
- $res .= "\n\n Les alias {$this->new_alias}@{$globals->mail->domain} et @{$globals->mail->domain2} sont maintenant à ta disposition !";
- }
- }
- if ($globals->mailstorage->googleapps_domain) {
- require_once 'googleapps.inc.php';
- $account = new GoogleAppsAccount($this->user);
- if ($account->active()) {
- $res .= "\n\n Si tu utilises Google Apps, tu peux changer ton nom d'usage sur https://mail.google.com/a/polytechnique.org/#settings/accounts.";
+ if ($globals->mailstorage->googleapps_domain) {
+ require_once 'googleapps.inc.php';
+ $account = new GoogleAppsAccount($this->profileOwner);
+ if ($account->active()) {
+ $res .= "\n\n Si tu utilises Google Apps, tu peux changer ton nom d'usage sur https://mail.google.com/a/polytechnique.org/#settings/accounts.";
+ }
}
}
return $res;
{
require_once 'name.func.inc.php';
- set_profile_display($this->display_names, $this->user->profile()->id());
- set_alias_names($this->sn_new, $this->sn_old, $this->user->profile()->id(),
- $this->user->id(), true, $this->new_alias);
+ set_profile_display($this->display_names, $this->profile->id());
- // Update the local User object, to pick up the new bestalias.
- $this->user = User::getSilent($this->user->id());
+ if (!is_null($this->profileOwner)) {
+ set_alias_names($this->sn_new, $this->sn_old, $this->profile->id(),
+ $this->profileOwner->id(), true, $this->new_alias);
+
+ // Update the local User object, to pick up the new bestalias.
+ $this->profileOwner = User::getSilent($this->profileOwner->id());
+ }
return true;
}
// {{{ class OrangeReq
-class OrangeReq extends Validate
+class OrangeReq extends ProfileValidate
{
// {{{ properties
// }}}
// {{{ constructor
- public function __construct(User &$_user, $_newGradYear)
+ public function __construct(User &$_user, Profile &$_profile, $_newGradYear)
{
- parent::__construct($_user, true, 'orange');
+ parent::__construct($_user, $_profile, true, 'orange');
$this->newGradYear = $_newGradYear;
$res = XDB::query("SELECT entry_year, grad_year
FROM profile_education
- WHERE pid = {?} AND FIND_IN_SET('primary', flags)", $this->user->profile()->id());
+ WHERE pid = {?} AND FIND_IN_SET('primary', flags)",
+ $this->profile->id());
$years = $res->fetchOneRow();
$this->entryYear = $years[0];
$this->oldGradYear = $years[1];
XDB::execute("UPDATE profile_education
SET grad_year = {?}
WHERE pid = {?} AND FIND_IN_SET('primary', flags)",
- $this->newGradYear, $this->user->profile()->id());
+ $this->newGradYear, $this->profile->id());
return true;
}
// {{{ class PhotoReq
-class PhotoReq extends Validate
+class PhotoReq extends ProfileValidate
{
// {{{ properties
// }}}
// {{{ constructor
- public function __construct(User &$_user, PlUpload &$upload, $_stamp=0)
+ public function __construct(User &$_user, Profile &$_profile, PlUpload &$upload, $_stamp = 0)
{
- parent::__construct($_user, true, 'photo', $_stamp);
+ parent::__construct($_user, $_profile, true, 'photo', $_stamp);
$this->read($upload);
}
{
$this->valid = $upload->resizeImage(240, 300, 160, 0, SIZE_MAX);
if (!$this->valid) {
- $this->trigError('Le fichier que tu as transmis n\'est pas une image valide, ou est trop gros pour être traité');
+ $this->trigError('Le fichier que tu as transmis n\'est pas une image valide, ou est trop gros pour être traité.');
}
$this->data = $upload->getContents();
list($this->x, $this->y, $this->mimetype) = $upload->imageInfo();
}
// }}}
- // {{{ function isValid()
+ // {{{ function isValid()
public function isValid()
{
// }}}
// {{{ function get_request()
- static public function get_request($uid)
+ static public function get_request($pid)
{
- return parent::get_typed_request($uid, 'photo');
+ return parent::get_typed_request($pid, 'photo');
}
// }}}
if (isset($_FILES['userfile'])) {
$upload =& PlUpload::get($_FILES['userfile'], S::user()->login(), 'photo');
if (!$upload) {
- $this->trigError('Une erreur est survenue lors du téléchargement du fichier');
+ $this->trigError('Une erreur est survenue lors du téléchargement du fichier.');
return false;
}
$this->read($upload);
{
XDB::execute('REPLACE INTO profile_photos (pid, attachmime, attach, x, y)
VALUES ({?},{?},{?},{?},{?})',
- $this->user->profile()->id(), $this->mimetype, $this->data, $this->x, $this->y);
+ $this->profile->id(), $this->mimetype, $this->data, $this->x, $this->y);
return true;
}