| @@ 5312-5336 (lines=25) @@ | ||
| 5309 | * @param $userId |
|
| 5310 | * @return bool |
|
| 5311 | */ |
|
| 5312 | public static function getFirstStudentBoss($userId) |
|
| 5313 | { |
|
| 5314 | $userId = intval($userId); |
|
| 5315 | if ($userId > 0) { |
|
| 5316 | $userRelTable = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
| 5317 | $row = Database::select( |
|
| 5318 | 'DISTINCT friend_user_id AS boss_id', |
|
| 5319 | $userRelTable, |
|
| 5320 | array( |
|
| 5321 | 'where' => array( |
|
| 5322 | 'user_id = ? AND relation_type = ? LIMIT 1' => array( |
|
| 5323 | $userId, |
|
| 5324 | USER_RELATION_TYPE_BOSS, |
|
| 5325 | ) |
|
| 5326 | ) |
|
| 5327 | ) |
|
| 5328 | ); |
|
| 5329 | if (!empty($row)) { |
|
| 5330 | ||
| 5331 | return $row[0]['boss_id']; |
|
| 5332 | } |
|
| 5333 | } |
|
| 5334 | ||
| 5335 | return false; |
|
| 5336 | } |
|
| 5337 | ||
| 5338 | /** |
|
| 5339 | * Get the boss user ID from a followed user id |
|
| @@ 5343-5366 (lines=24) @@ | ||
| 5340 | * @param $userId |
|
| 5341 | * @return bool |
|
| 5342 | */ |
|
| 5343 | public static function getStudentBossList($userId) |
|
| 5344 | { |
|
| 5345 | $userId = intval($userId); |
|
| 5346 | if ($userId > 0) { |
|
| 5347 | $userRelTable = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
| 5348 | $result = Database::select( |
|
| 5349 | 'DISTINCT friend_user_id AS boss_id', |
|
| 5350 | $userRelTable, |
|
| 5351 | array( |
|
| 5352 | 'where' => array( |
|
| 5353 | 'user_id = ? AND relation_type = ? ' => array( |
|
| 5354 | $userId, |
|
| 5355 | USER_RELATION_TYPE_BOSS, |
|
| 5356 | ) |
|
| 5357 | ) |
|
| 5358 | ), |
|
| 5359 | 'all' |
|
| 5360 | ); |
|
| 5361 | ||
| 5362 | return $result; |
|
| 5363 | } |
|
| 5364 | ||
| 5365 | return false; |
|
| 5366 | } |
|
| 5367 | ||
| 5368 | /** |
|
| 5369 | * @param int $bossId |
|