| @@ 5131-5155 (lines=25) @@ | ||
| 5128 | * @param $userId |
|
| 5129 | * @return bool |
|
| 5130 | */ |
|
| 5131 | public static function getFirstStudentBoss($userId) |
|
| 5132 | { |
|
| 5133 | $userId = intval($userId); |
|
| 5134 | if ($userId > 0) { |
|
| 5135 | $userRelTable = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
| 5136 | $row = Database::select( |
|
| 5137 | 'DISTINCT friend_user_id AS boss_id', |
|
| 5138 | $userRelTable, |
|
| 5139 | array( |
|
| 5140 | 'where' => array( |
|
| 5141 | 'user_id = ? AND relation_type = ? LIMIT 1' => array( |
|
| 5142 | $userId, |
|
| 5143 | USER_RELATION_TYPE_BOSS, |
|
| 5144 | ) |
|
| 5145 | ) |
|
| 5146 | ) |
|
| 5147 | ); |
|
| 5148 | if (!empty($row)) { |
|
| 5149 | ||
| 5150 | return $row[0]['boss_id']; |
|
| 5151 | } |
|
| 5152 | } |
|
| 5153 | ||
| 5154 | return false; |
|
| 5155 | } |
|
| 5156 | ||
| 5157 | /** |
|
| 5158 | * Get the boss user ID from a followed user id |
|
| @@ 5162-5185 (lines=24) @@ | ||
| 5159 | * @param $userId |
|
| 5160 | * @return bool |
|
| 5161 | */ |
|
| 5162 | public static function getStudentBossList($userId) |
|
| 5163 | { |
|
| 5164 | $userId = intval($userId); |
|
| 5165 | if ($userId > 0) { |
|
| 5166 | $userRelTable = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
| 5167 | $result = Database::select( |
|
| 5168 | 'DISTINCT friend_user_id AS boss_id', |
|
| 5169 | $userRelTable, |
|
| 5170 | array( |
|
| 5171 | 'where' => array( |
|
| 5172 | 'user_id = ? AND relation_type = ? ' => array( |
|
| 5173 | $userId, |
|
| 5174 | USER_RELATION_TYPE_BOSS, |
|
| 5175 | ) |
|
| 5176 | ) |
|
| 5177 | ), |
|
| 5178 | 'all' |
|
| 5179 | ); |
|
| 5180 | ||
| 5181 | return $result; |
|
| 5182 | } |
|
| 5183 | ||
| 5184 | return false; |
|
| 5185 | } |
|
| 5186 | ||
| 5187 | /** |
|
| 5188 | * @param int $bossId |
|