Changeset 1015:10227e338321
- Timestamp:
- 11/17/12 14:19:52 (13 years ago)
- Branch:
- default
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/categories.php
r907 r1015 20 20 try 21 21 { 22 # Check if category to delete exists 22 23 $c = $core->blog->getCategory((integer) $_POST['del_cat']); 23 24 if ($c->isEmpty()) { … … 25 26 } 26 27 unset($c); 28 29 # Check if category where to move posts exists 30 $mov_cat = (integer) $_POST['mov_cat']; 31 $mov_cat = $mov_cat ? $mov_cat : null; 32 if ($mov_cat !== null) { 33 $c = $core->blog->getCategory((integer) $_POST['del_cat']); 34 if ($c->isEmpty()) { 35 throw new Exception(__('This category does not exist.')); 36 } 37 unset($c); 38 } 39 40 # Move posts 41 $core->blog->updPostsCategory($_POST['del_cat'],$mov_cat); 42 43 # Delete category 27 44 $core->blog->delCategory($_POST['del_cat']); 45 28 46 http::redirect('categories.php?del=1'); 29 47 } … … 143 161 if (!$rs->isEmpty()) 144 162 { 145 $deletable = array(); 163 $cats = array(); 164 $dest = array(' ' => ''); 146 165 $l = $rs->level; 147 166 $full_name = array($rs->cat_title); … … 154 173 } 155 174 $full_name[] = html::escapeHTML($rs->cat_title); 156 if ($rs->nb_post == 0) { 157 $deletable[implode(' / ',$full_name)] = $rs->cat_id; 158 } 175 176 $cats[implode(' / ',$full_name)] = $rs->cat_id; 177 $dest[implode(' / ',$full_name)] = $rs->cat_id; 178 159 179 $l = $rs->level; 160 180 } 161 181 162 if (count($deletable) > 0) 163 { 164 echo 165 '<form action="categories.php" method="post" id="delete-category">'. 166 '<fieldset><legend>'.__('Remove a category').'</legend>'. 167 '<p><label for="del_cat">'.__('Choose a category to remove:').' '. 168 form::combo('del_cat',$deletable).'</label></p> '. 169 '<p><input type="submit" value="'.__('Delete').'" class="delete" /></p>'. 170 $core->formNonce(). 171 '</fieldset>'. 172 '</form>'; 173 } 182 echo 183 '<form action="categories.php" method="post" id="delete-category">'. 184 '<fieldset><legend>'.__('Remove a category').'</legend>'. 185 '<p><label for="del_cat">'.__('Choose a category to remove:').' '. 186 form::combo('del_cat',$cats).'</label></p> '. 187 '<p><label for="mov_cat">'.__('Move its content to another category:').' '. 188 form::combo('mov_cat',$dest).'</label></p> '. 189 '<p><input type="submit" value="'.__('Delete').'" class="delete" /></p>'. 190 $core->formNonce(). 191 '</fieldset>'. 192 '</form>'; 174 193 175 194 echo -
inc/core/class.dc.blog.php
r970 r1015 1339 1339 1340 1340 /** 1341 Updates posts category. <var>$new_cat_id</var> can be null. 1342 1343 @param old_cat_id <b>integer</b> Old category ID 1344 @param new_cat_id <b>integer</b> New category ID 1345 */ 1346 public function updPostsCategory($old_cat_id,$new_cat_id) 1347 { 1348 if (!$this->core->auth->check('contentadmin,categories',$this->id)) { 1349 throw new Exception(__('You are not allowed to change entries category')); 1350 } 1351 1352 $old_cat_id = (integer) $old_cat_id; 1353 $new_cat_id = (integer) $new_cat_id; 1354 1355 $cur = $this->con->openCursor($this->prefix.'post'); 1356 1357 $cur->cat_id = ($new_cat_id ? $new_cat_id : null); 1358 $cur->post_upddt = date('Y-m-d H:i:s'); 1359 1360 $cur->update( 1361 'WHERE cat_id = '.$old_cat_id.' '. 1362 "AND blog_id = '".$this->con->escape($this->id)."' " 1363 ); 1364 $this->triggerBlog(); 1365 } 1366 1367 /** 1341 1368 Deletes a post. 1342 1369
Note: See TracChangeset
for help on using the changeset viewer.