Esempio n. 1
0
 public function public_data($user, $basic_only = false, $show_email = false)
 {
     if (in_array('password', array_keys($user))) {
         unset($user['password']);
     }
     $me = Bootstrap::$main->user;
     if (!$basic_only) {
         $user['images'] = $this->get_images($user['id'], 'public');
     }
     $user_id = $user['id'];
     if ($basic_only || !isset($me['id']) || $me['id'] != $user['id']) {
         if (!$show_email) {
             unset($user['email']);
             unset($user['phone']);
         }
         foreach (['id', 'md5hash', 'lat', 'lng', 'lang', 'address', 'postal', 'payment', 'ical', 'delta', 'ref_login', 'ref_site', 'ref_user', 'host_agreement', 'guest_agreement'] as $k) {
             if (in_array($k, array_keys($user))) {
                 unset($user[$k]);
             }
         }
         foreach ($user as $k => $v) {
             if ($k[0] == '_') {
                 unset($user[$k]);
             }
         }
     } else {
         $user['me'] = true;
     }
     $user['tags'] = [];
     $tags = new tagModel();
     $t = $tags->for_user($user_id) ?: [];
     if (count($t)) {
         $user['tags'] = Tools::tags($t);
     }
     if ($user['birthyear']) {
         $user['age'] = date('Y') - $user['birthyear'];
     }
     return $user;
 }