X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fprofile.php;h=56e1f5a527b322b1534b5d1413490a1aa158c80d;hb=438b7a0c2a1b5c04ea3222fc3871a96882992eb5;hp=d75bf767f074048a048defb14ec6e5d23dc22051;hpb=348b3844f6a0a4eb12fcb7d8733b0e2fb9fe9ae3;p=platal.git diff --git a/classes/profile.php b/classes/profile.php index d75bf76..56e1f5a 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -411,6 +411,36 @@ class Profile } + /** + * Clears a profile. + * *always deletes in: profile_addresses, profile_binets, profile_job, + * profile_langskills, profile_mentor, profile_networking, + * profile_phones, profile_skills, watch_profile + * *always keeps in: profile_corps, profile_display, profile_education, + * profile_medals, profile_name, profile_photos, search_name + * *modifies: profiles + */ + public function clear() + { + $tables = array( + 'profile_job', 'profile_langskills', 'profile_mentor', + 'profile_networking', 'profile_skills', 'watch_profile', + 'profile_phones', 'profile_addresses', 'profile_binets'); + + foreach ($tables as $t) { + XDB::execute('DELETE FROM ' . $t . ' + WHERE pid = {?}', + $this->id()); + } + + XDB::execute("UPDATE profiles + SET cv = NULL, freetext = NULL, freetext_pub = 'private', + medals_pub = 'private', alias_pub = 'private', + email_directory = NULL + WHERE pid = {?}", + $this->id()); + } + /** Sets the level of visibility of the profile * Sets $this->visibility to a list of valid visibilities. * @param one of the self::VIS_* values @@ -516,14 +546,20 @@ class Profile $this->consolidateFields(); } - public function getAddresses($flags, $limit = null) + private function fetchAddresses() { if ($this->addresses == null && !$this->fetched(self::FETCH_ADDRESSES)) { $addr = $this->getProfileField(self::FETCH_ADDRESSES); if ($addr) { $this->setAddresses($addr); + $this->fetchPhones(); } } + } + + public function getAddresses($flags, $limit = null) + { + $this->fetchAddresses(); if ($this->addresses == null) { return array(); @@ -555,12 +591,16 @@ class Profile $this->consolidateFields(); } - public function getPhones($flags, $limit = null) + private function fetchPhones() { if ($this->phones == null && !$this->fetched(self::FETCH_PHONES)) { $this->setPhones($this->getProfileField(self::FETCH_PHONES)); } + } + public function getPhones($flags, $limit = null) + { + $this->fetchPhones(); if ($this->phones == null) { return array(); } @@ -650,14 +690,20 @@ class Profile $this->consolidateFields(); } - public function getJobs($flags, $limit = null) + private function fetchJobs() { if ($this->jobs == null && !$this->fetched(self::FETCH_JOBS)) { $jobs = $this->getProfileField(self::FETCH_JOBS); if ($jobs) { $this->setJobs($jobs); + $this->fetchAddresses(); } } + } + + public function getJobs($flags, $limit = null) + { + $this->fetchJobs(); if ($this->jobs == null) { return array();