- Timestamp:
- 12/22/09 14:21:51 (2 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 7 edited
-
common/db/textblock.php (modified) (3 diffs)
-
www/controllers/attachment.php (modified) (1 diff)
-
www/controllers/round.php (modified) (5 diffs)
-
www/controllers/textblock.php (modified) (1 diff)
-
www/index.php (modified) (1 diff)
-
www/url.php (modified) (1 diff)
-
www/views/round_delete.php (added)
-
www/views/round_edit.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/common/db/textblock.php
r1074 r1086 243 243 244 244 // Grep through textblocks. This is mostly a hack needed for macro_grep.php 245 function textblock_grep($substr, $page, $regexp = false) { 245 // Also used for round deletion 246 function textblock_grep($substr, $page, $regexp = false, $offset = 0, $count = 0) { 246 247 if (!$regexp) { 247 248 $compare = "LIKE"; … … 255 256 WHERE `name` LIKE '%s' AND 256 257 (`text` $compare '%s' OR `title` $compare '%s') 257 ORDER BY `name`", 258 ORDER BY `name` 259 LIMIT %s, %s", 260 db_escape($page), db_escape($substr), db_escape($substr), 261 db_escape($offset), db_escape($count)); 262 return db_fetch_all($query); 263 } 264 265 function textblock_grep_count($substr, $page, $regexp = false) { 266 if (!$regexp) { 267 $compare = "LIKE"; 268 } else { 269 $compare = "REGEXP"; 270 } 271 $query = sprintf("SELECT COUNT(*) as `cnt` 272 FROM ia_textblock 273 WHERE `name` LIKE '%s' AND 274 (`text` $compare '%s' OR `title` $compare '%s')", 258 275 db_escape($page), db_escape($substr), db_escape($substr)); 259 return db_fetch _all($query);276 return db_fetch($query); 260 277 } 261 278 … … 278 295 db_query("DELETE FROM `ia_textblock_revision` WHERE `name` = '$pageesc'"); 279 296 db_query("DELETE FROM `ia_textblock` WHERE `name` = '$pageesc'"); 280 if (db_affected_rows() != 1) { 281 return true; 282 } 297 298 return (db_affected_rows() != 0); 283 299 } 284 300 -
trunk/www/controllers/attachment.php
r1068 r1086 311 311 $files = array(); 312 312 $deleted = 0; 313 313 314 foreach($arguments as $value) { 314 315 if(is_numeric($value)) { -
trunk/www/controllers/round.php
r1076 r1086 6 6 require_once(IA_ROOT_DIR."common/round.php"); 7 7 require_once(IA_ROOT_DIR."common/tags.php"); 8 require_once(IA_ROOT_DIR."common/textblock.php"); 9 require_once(IA_ROOT_DIR."www/format/pager.php"); 8 10 9 11 // Displays form to either create a new round or edit an existing one. … … 41 43 $round_types = array(); 42 44 foreach (round_get_types() as $round_type => $pretty_name) { 43 if (identity_can("round-edit", round_init('round_id', $round_type, 45 if (identity_can("round-edit", round_init('round_id', $round_type, 44 46 $identity_user))) 45 47 $round_types[$round_type] = $pretty_name; … … 51 53 $all_task_ids = array(); 52 54 foreach ($all_tasks as $idx => $task) { 53 if ($round['type'] != 'user-defined' || 55 if ($round['type'] != 'user-defined' || 54 56 identity_can('task-use-in-user-round', $task)) { 55 57 $all_task_ids[$task['id']] = true; … … 256 258 $round_types = array(); 257 259 foreach (round_get_types() as $round_type => $pretty_name) { 258 if (identity_can("round-create", round_init("round_id", $round_type, 260 if (identity_can("round-create", round_init("round_id", $round_type, 259 261 $identity_user))) 260 262 $round_types[$round_type] = $pretty_name; … … 272 274 } 273 275 276 function controller_round_delete($round_id) { 277 // Validate round_id 278 if (!is_round_id($round_id)) { 279 flash_error('Identificatorul rundei este invalid'); 280 redirect(url_home()); 281 } 282 283 // Get round 284 $round = round_get($round_id); 285 if (!$round) { 286 flash_error("Runda nu exista"); 287 redirect(url_home()); 288 } 289 290 // Security check 291 identity_require('round-delete', $round); 292 293 $options = pager_init_options(); 294 295 $textblock_list = textblock_grep('%"'.$round_id.'"%', '%', false, $options['first_entry'], 296 $options['display_entries']); 297 298 for ($i = 0; $i < count ($textblock_list); ++$i) { 299 $textblock_list[$i]['id'] = $options['first_entry'] + $i + 1; 300 } 301 302 // Form stuff. 303 $values = array(); 304 $errors = array(); 305 306 // Create view 307 $view = array(); 308 $view['textblock_list'] = $textblock_list; 309 $view['title'] = "Stergere textblockuri corelate cu $round_id"; 310 $view['page_name'] = url_round_delete($round_id); 311 $view['round_id'] = $round_id; 312 $view['round'] = $round; 313 $view['form_values'] = $values; 314 $view['form_errors'] = $errors; 315 $entries = textblock_grep_count('%"'.$round_id.'"%', '%', false); 316 $view['total_entries'] = $entries['cnt']; 317 $view['first_entry'] = $options['first_entry']; 318 $view['display_entries'] = $options['display_entries']; 319 320 execute_view_die("views/round_delete.php", $view); 321 } 322 274 323 ?> -
trunk/www/controllers/textblock.php
r1038 r1086 216 216 } 217 217 218 // Delete a list of textblocks 219 function controller_textblock_delete_many($textblocks, $redirect) { 220 $deleted = 0; 221 $not_deleted_because_of_permision = 0; 222 $bad_page_names = 0; 223 224 if (!is_array($textblocks)) { 225 flash_error("Nu au fost specificate pagini pentru a fi sterse"); 226 redirect($redirect); 227 } 228 229 foreach ($textblocks as $name) { 230 if (!is_page_name($name)) { 231 ++$bad_page_names; 232 } else if (identity_can("textblock-delete", textblock_get_revision($name))) { 233 $deleted += textblock_delete($name); 234 } else { 235 ++$not_deleted_because_of_permision; 236 } 237 } 238 239 flash($deleted." textblockuri au fost sterse."); 240 if ($not_deleted_because_of_permision) { 241 flash($not_deleted_because_of_permision. 242 " textblockuri nu au putut fi sterse din cauza permisiunilor."); 243 } 244 if ($bad_page_names) { 245 flash($bad_page_names." textblockuri au numele corupt"); 246 } 247 redirect($redirect); 248 } 249 218 250 // Delete a certain revision 219 251 function controller_textblock_delete_revision($page = null, $rev_num = null) { -
trunk/www/index.php
r1083 r1086 115 115 } 116 116 117 // Round detail editor 117 // Round detail editor and deleter 118 118 else if ($urlstart == 'admin' && getattr($pagepath, 1) == 'runda') { 119 119 $obj_id = implode("/", array_slice($pagepath, 2)); 120 120 require_once(IA_ROOT_DIR.'www/controllers/round.php'); 121 controller_round_details($obj_id); 121 require_once(IA_ROOT_DIR.'www/controllers/textblock.php'); 122 if ($action == 'sterge-runda') { 123 if (request('delete')) { 124 $v = request('textblocks'); 125 controller_textblock_delete_many($v, url_round_delete($obj_id)); 126 } else { 127 controller_round_delete($obj_id); 128 } 129 } else { 130 controller_round_details($obj_id); 131 } 122 132 } 123 133 -
trunk/www/url.php
r1083 r1086 306 306 } 307 307 308 function url_round_delete($round_id) { 309 log_assert(is_round_id($round_id)); 310 return url_complex("admin/runda/$round_id", array('action' => 'sterge-runda')); 311 } 312 308 313 // Job/monitor stuff. 309 314 -
trunk/www/views/round_edit.php
r1077 r1086 73 73 <h1>Editare runda <?= format_link(url_textblock($round['page_name']), $round['title']) ?></h1> 74 74 75 <form action="<?= html_escape(url_round_delete($round['id'])) ?>" method="post" style="float: right"> 76 <input type="hidden" name="" value="<?= html_escape($round['id']) ?>" /> 77 <input onclick="" type="submit" value="Sterge runda" id="form_delete" class="button important" /> 78 </form> 79 75 80 <?php if ($round['state'] == 'running') { ?> 76 81 <div class="warning">
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)