Example #1
0
 /**
  * Gets all public data as an array, used in public profile page
  *
  * @author joel peltonen
  * @param id int user whose data we are to get
  * @return array of user data
  */
 public function getPublicData($id = -1)
 {
     if ($id == -1) {
         return false;
         // don't allow default value
     }
     // get only key and value fields, others are not needed
     $select = $this->select()->from($this, array('profile_key_usp', 'profile_value_usp'))->where('id_usr_usp = ?', $id)->where('public_usp = ?', 1);
     // roll to array and return
     $results = $this->fetchAll($select);
     foreach ($results as $result) {
         $collection[$result->profile_key_usp] = htmlentities($result->profile_value_usp);
     }
     // Change gender to M or N
     if (isset($collection['gender']) && $collection['gender'] == 1) {
         $collection['gender'] = 'Male';
     } else {
         if (isset($collection['gender']) && $collection['gender'] == 2) {
             $collection['gender'] = 'Female';
         }
     }
     // Change employment "code" to text
     if (isset($collection['employment'])) {
         $collection['employment'] = $this->getEmploymentByEmployment($collection['employment']);
     }
     // User timezone
     if (isset($collection['usertimezone'])) {
         $timezone_model = new Default_Model_Timezones();
         $collection['usertimezone'] = $timezone_model->getTimezoneTextById($collection['usertimezone']);
     }
     // User country
     if (isset($collection['country'])) {
         $country_model = new Default_Model_Countries();
         $collection['country'] = $country_model->getCountryPrintableNameByIso($collection['country']);
     }
     return $collection;
 }