X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fprofile.php;h=7065598a0233c3245ece6425322fe9276cbbea12;hb=fda78a6777a5f385537fc9f291afb310e12525e5;hp=b11e31d7ddd36adf8327e6e09184660072106192;hpb=3eaeedd1621a4ad6f3b89b01dcab4143e6f27545;p=platal.git diff --git a/classes/profile.php b/classes/profile.php index b11e31d..7065598 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -1,6 +1,6 @@ 'Nom affiché', 'freetext' => 'Commentaire', 'freetext_pub' => 'Affichage du commentaire', + 'axfreetext' => 'Commentaire AX', 'photo' => 'Photographie', 'photo_pub' => 'Affichage de la photographie', 'addresses' => 'Adresses', @@ -171,6 +172,13 @@ class Profile implements PlExportable $this->visibility = $visibility; } + public function __destruct() + { + // Need to delete objects allocated by the profile + // http://www.php.net/manual/en/function.unset.php#98692 + unset($this->owner); + } + public function id() { return $this->pid; @@ -492,7 +500,7 @@ class Profile implements PlExportable } XDB::execute("UPDATE profiles - SET cv = NULL, freetext = NULL, freetext_pub = 'private', + SET cv = NULL, freetext = NULL, freetext_pub = 'private', axfreetext = NULL, medals_pub = 'private', alias_pub = 'hidden', email_directory = NULL WHERE pid = {?}", @@ -724,6 +732,34 @@ class Profile implements PlExportable return $this->corps; } + /** + * Retrieve the name of the corps which has been done. + * + * Note: this function first tries getCorps(), and if this field is blank + * tries to find an education which degree is "Corps". + * + * Returns an empty string if nothing has been found. + */ + public function getCorpsName() + { + $corps = $this->getCorps(); + if ($corps && $corps->current) { + $corpsList = DirEnum::getOptions(DirEnum::CURRENTCORPS); + return $corpsList[$corps->current]; + } + + foreach ($this->getExtraEducations() as $edu) { + if (!strcasecmp($edu->degree, 'Corps')) { + if ($edu->school_short) { + return $edu->school_short; + } elseif ($edu->school) { + return $edu->school; + } + } + } + return ''; + } + /** Networking */ private $networks = null; @@ -977,6 +1013,22 @@ class Profile implements PlExportable } } + /* Hobbies + */ + public function getHobbies() { + if ($this->visibility->isVisible(Visibility::EXPORT_PRIVATE)) { + return XDB::fetchAllAssoc('type', 'SELECT type, GROUP_CONCAT(text) + FROM profile_hobby + WHERE pid = {?} + GROUP BY type', $this->id()); + } else { + return XDB::fetchAllAssoc('type', 'SELECT type, GROUP_CONCAT(text) + FROM profile_hobby + WHERE pub = \'public\' AND pid = {?} + GROUP BY type', $this->id()); + } + } + /* Medals */ private $medals = null; @@ -1469,5 +1521,5 @@ class ProfileIterator implements PlIterator } } -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: ?>