Changeset 1095 for trunk/common
- Timestamp:
- 12/24/09 01:10:43 (2 years ago)
- File:
-
- 1 edited
-
trunk/common/db/task.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/common/db/task.php
r1036 r1095 173 173 } 174 174 175 function task_get_authors($task_id, $no_cache = false) { 176 log_assert(is_task_id($task_id), 'Invalid task_id'); 177 178 $authors = false; 179 if (!$no_cache) { 180 $authors = mem_cache_get("task-authors-by-id:".$task_id); 181 } 182 183 if ($authors === false) { 184 $authors = tag_get("task", $task_id, "author"); 185 mem_cache_set("task-authors-by-id:".$task_id, $authors); 186 } 187 188 return $authors; 189 } 190 191 // Task filter 192 // Returns only tasks that contain all the tags 193 // and are in 'arhiva' or in 'arhiva-educationala' 194 // Task from 'arhiva-educationala' are shown first 195 function task_filter_by_tags($tag_ids, $scores = true, $user_id = null) { 196 log_assert(is_array($tag_ids), "tag_ids must be an array"); 197 foreach ($tag_ids as $tag_id) { 198 log_assert(is_tag_id($tag_id), "invalid tag id"); 199 } 200 201 if (count($tag_ids) > 0) { 202 $tag_filter = "AND ".tag_build_where('task', $tag_ids); 203 } else { 204 $tag_filter = ""; 205 } 206 207 if ($user_id == null || $scores == false) { 208 $join_score = ""; 209 $score_fields = ""; 210 } else { 211 $join_score = "LEFT JOIN ia_score ON ia_score.user_id = ".db_quote($user_id)." AND 212 ia_score.round_id = round.id AND 213 ia_score.task_id = ia_task.id AND 214 ia_score.name = 'score'"; 215 $score_fields = "ia_score.score,"; 216 } 217 218 $query = "SELECT ia_task.id AS task_id, 219 ia_task.title AS task_title, 220 ia_task.order AS 'order', 221 ia_task.page_name AS page_name, 222 ia_task.open_source AS open_source, 223 ia_task.open_tests AS open_tests, 224 round.id AS round_id, 225 $score_fields 226 round.title AS round_title 227 FROM ia_task 228 LEFT JOIN ia_round_task AS round_task ON round_task.task_id = ia_task.id 229 LEFT JOIN ia_round AS round ON round.id = round_task.round_id 230 $join_score 231 WHERE (round.id = 'arhiva' OR round.id = 'arhiva-educationala') 232 AND ia_task.hidden = '0' $tag_filter 233 ORDER BY round.id DESC, ia_task.order"; 234 $tasks = db_fetch_all($query); 235 236 return $tasks; 237 } 175 238 ?>
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)