コード例 #1
0
ファイル: decos.inc.php プロジェクト: Ekleog/platal
 public function value(ProfilePage $page, $field, $value, &$success)
 {
     $success = true;
     if (is_null($value) || !S::user()->isMyProfile($profile) && $page->values['medals_pub'] == 'private' && !S::user()->checkPerms(User::PERM_DIRECTORY_PRIVATE)) {
         // Fetch already attributed medals
         $value = XDB::fetchAllAssoc("SELECT  m.mid AS id, m.gid AS grade, 1 AS valid, FIND_IN_SET('has_levels', e.flags) AS has_levels, m.level\n                                           FROM  profile_medals     AS m\n                                     INNER JOIN  profile_medal_enum AS e ON (m.mid = e.id)\n                                          WHERE  m.pid = {?}", $page->pid());
         // Fetch not yet validated medals
         $medals = ProfileValidate::get_typed_requests($page->pid(), 'medal');
         foreach ($medals as &$medal) {
             $value[] = array('id' => $medal->mid, 'grade' => $medal->gid, 'level' => $medal->level, 'has_levels' => $medal->has_levels, 'valid' => '0');
         }
     } elseif (!is_array($value)) {
         $value = array();
     }
     usort($value, 'self::compareMedals');
     return $value;
 }
コード例 #2
0
ファイル: medals.inc.php プロジェクト: Ekleog/platal
 public static function get_request($pid, $type, $grade, $level)
 {
     $reqs = parent::get_typed_requests($pid, 'medal');
     foreach ($reqs as &$req) {
         if ($req->mid == $type && $req->gid == $grade && $req->level == $level) {
             return $req;
         }
     }
     return null;
 }
コード例 #3
0
ファイル: jobs.inc.php プロジェクト: Ekleog/platal
 public function value(ProfilePage $page, $field, $value, &$success)
 {
     $entreprise = ProfileValidate::get_typed_requests($page->pid(), 'entreprise');
     $entr_val = 0;
     $init = false;
     if (is_null($value)) {
         $value = $this->fetchJobs($page);
         $init = true;
     }
     $success = true;
     foreach ($value as $key => $job) {
         $job['name'] = trim($job['name']);
         if ($job['name'] == '' && $entreprise[$entr_val]->id == $key) {
             $job['tmp_name'] = $entreprise[$entr_val]->name;
             ++$entr_val;
         } else {
             if ($job['name'] == '') {
                 if ($job['description'] == '' && $job['w_url'] == '' && $job['w_address']['text'] == '' && $job['w_email'] == '' && count($job['w_phone']) >= 1 && $job['w_phone'][0]['display'] == '') {
                     unset($value[$key]);
                     continue;
                 }
                 if (!$init) {
                     $job['name_error'] = true;
                     $success = false;
                 }
             }
         }
         if (isset($job['removed']) && $job['removed']) {
             if (!S::user()->checkPerms('directory_private') && (Phone::hasPrivate($job['w_phone']) || Address::hasPrivate($job['w_address']) || $job['w_email_pub'] == 'private')) {
                 Platal::page()->trigWarning("L'entreprise ne peut être supprimée car elle contient des informations pour lesquelles vous n'avez pas le droit d'édition.");
             } else {
                 if ($job['name'] == '' && $entreprise && isset($entreprise[$entr_val - 1])) {
                     $entreprise[$entr_val - 1]->clean();
                 }
                 unset($value[$key]);
                 continue;
             }
         }
         if (!isset($job['pub']) || !$job['pub']) {
             $job['pub'] = 'private';
         }
         $value[$key] = $job;
     }
     foreach ($value as $key => &$job) {
         $address = new Address($job['w_address']);
         $s = $address->format();
         // Force the address publicity to be at least as restricted as
         // the job publicity.
         $job_level = $job['pub'];
         if (Visibility::isLessRestrictive($job_level, $address->pub)) {
             $address->pub = $job_level;
         }
         $job['w_address'] = $address->toFormArray();
         $this->cleanJob($page, $key, $job, $s, $job_level);
         if (!$init) {
             $success = $success && $s;
         }
     }
     usort($value, 'Visibility::comparePublicity');
     return $value;
 }
コード例 #4
0
ファイル: address.inc.php プロジェクト: Ekleog/platal
 public static function get_request($pid, $jobid, $groupid, $type, $id)
 {
     $reqs = parent::get_typed_requests($pid, 'address');
     foreach ($reqs as &$req) {
         if ($req->key_pid == $pid && $req->key_jobid == $jobid && $req->key_groupid == $groupid && $req->key_type == $type && $req->key_id == $id) {
             return $req;
         }
     }
     return null;
 }
コード例 #5
0
ファイル: profilefields.inc.php プロジェクト: Ekleog/platal
 /** Fields are:
  * pid, id, company_id, description, url, email
  */
 public function __construct($data)
 {
     foreach ($data as $key => $val) {
         $this->{$key} = $val;
     }
     $this->company = CompanyList::get($this->jobid);
     if (is_null($this->company)) {
         $entreprises = ProfileValidate::get_typed_requests($this->pid, 'entreprise');
         foreach ($entreprises as $entreprise) {
             if ($entreprise->id == $this->id) {
                 $this->company = new Company(array('name' => $entreprise->name));
             }
         }
     }
 }