public static function userBadges($user) { $user_badges = array(); if (!$user) { return $user_badges; } $badges_data = Model_Badges::getAllFront(); $other_badges = isset($user['badges']) ? array_map('trim', explode(',', $user['badges'])) : array(); if (isset($user['exclusive_author']) && $user['exclusive_author'] == 'true' && isset($badges_data['system']['is_exclusive_author'])) { if ($badges_data['system']['is_exclusive_author']['photo'] && file_exists("uploads/badges/" . $badges_data['system']['is_exclusive_author']['photo'])) { $user_badges[] = array('name' => $badges_data['system']['is_exclusive_author']['name'], 'photo' => 'uploads/badges/' . $badges_data['system']['is_exclusive_author']['photo']); } } if (isset($user['featured_author']) && $user['featured_author'] == 'true' && isset($badges_data['system']['has_been_featured'])) { if ($badges_data['system']['has_been_featured']['photo'] && file_exists("uploads/badges/" . $badges_data['system']['has_been_featured']['photo'])) { $user_badges[] = array('name' => $badges_data['system']['has_been_featured']['name'], 'photo' => 'uploads/badges/' . $badges_data['system']['has_been_featured']['photo']); } } if (isset($user['statuses']['freefile']) && $user['statuses']['freefile'] && isset($badges_data['system']['has_free_file_month'])) { if ($badges_data['system']['has_free_file_month']['photo'] && file_exists("uploads/badges/" . $badges_data['system']['has_free_file_month']['photo'])) { $user_badges[] = array('name' => $badges_data['system']['has_free_file_month']['name'], 'photo' => 'uploads/badges/' . $badges_data['system']['has_free_file_month']['photo']); } } if (isset($user['statuses']['featured']) && $user['statuses']['featured'] && isset($badges_data['system']['has_had_item_featured'])) { if ($badges_data['system']['has_free_file_month']['photo'] && file_exists("uploads/badges/" . $badges_data['system']['has_had_item_featured']['photo'])) { $user_badges[] = array('name' => $badges_data['system']['has_had_item_featured']['name'], 'photo' => 'uploads/badges/' . $badges_data['system']['has_had_item_featured']['photo']); } } if (isset($user['buy']) && $user['buy'] && isset($badges_data['buyers']) && is_array($badges_data['buyers'])) { foreach ($badges_data['buyers'] as $k => $v) { list($from, $to) = explode('-', $k); if ($from <= $user['buy'] && $to >= $user['buy']) { if ($v['photo'] && file_exists("uploads/badges/" . $v['photo'])) { $user_badges[] = array('name' => $v['name'], 'photo' => 'uploads/badges/' . $v['photo']); } break; } } } if (isset($user['sold']) && $user['sold'] && isset($badges_data['authors']) && is_array($badges_data['authors'])) { foreach ($badges_data['authors'] as $k => $v) { list($from, $to) = explode('-', $k); if ($from <= $user['sold'] && $to >= $user['sold']) { if ($v['photo'] && file_exists("uploads/badges/" . $v['photo'])) { $user_badges[] = array('name' => $v['name'], 'photo' => 'uploads/badges/' . $v['photo']); } break; } } } if (isset($user['referals']) && $user['referals'] && isset($badges_data['referrals']) && is_array($badges_data['referrals'])) { foreach ($badges_data['referrals'] as $k => $v) { list($from, $to) = explode('-', $k); if ($from <= $user['referals'] && $to >= $user['referals']) { if ($v['photo'] && file_exists("uploads/badges/" . $v['photo'])) { $user_badges[] = array('name' => $v['name'], 'photo' => 'uploads/badges/' . $v['photo']); } break; } } } if (isset($badges_data['other']) && is_array($badges_data['other'])) { foreach ($badges_data['other'] as $k => $b) { if (in_array($k, $other_badges) && $b['photo'] && file_exists("uploads/badges/" . $b['photo'])) { $user_badges[] = array('name' => $b['name'], 'photo' => 'uploads/badges/' . $b['photo']); } } } if (isset($user['country_id']) && $user['country_id']) { $country = Model_Countries::get($user['country_id']); if ($country) { $user['country'] = $country; } } if (isset($user['country']['photo']) && $user['country']['photo'] && file_exists("uploads/countries/" . $user['country']['photo'])) { $user_badges[] = array('name' => $user['country']['name'], 'photo' => 'uploads/countries/' . $user['country']['photo']); } elseif (isset($badges_data['system']['location_global_community']) && $badges_data['system']['location_global_community']['photo'] && file_exists("uploads/badges/" . $badges_data['system']['location_global_community']['photo'])) { $user_badges[] = array('name' => $badges_data['system']['location_global_community']['name'], 'photo' => 'uploads/badges/' . $badges_data['system']['location_global_community']['photo']); } return $user_badges; }