[ Index ] |
|
Code source de e107 0.7.8 |
1 <?php 2 /* 3 +---------------------------------------------------------------+ 4 | e107 website system 5 | /admin/review.php 6 | 7 | ©Steve Dunstan 2001-2002 8 | http://e107.org 9 | jalist@e107.org 10 | 11 | Released under the terms and conditions of the 12 | GNU General Public License (http://gnu.org). 13 | 14 | $Source: /cvsroot/e107/e107_0.7/e107_plugins/content/handlers/content_db_class.php,v $ 15 | $Revision: 1.56 $ 16 | $Date: 2007/01/14 14:24:41 $ 17 | $Author: lisa_ $ 18 +---------------------------------------------------------------+ 19 */ 20 21 if (!defined('e107_INIT')) { exit; } 22 23 $plugindir = e_PLUGIN."content/"; 24 $plugintable = "pcontent"; //name of the table used in this plugin (never remove this, as it's being used throughout the plugin !!) 25 $datequery = " AND content_datestamp < ".time()." AND (content_enddate=0 || content_enddate>".time().") "; 26 27 if (!defined('ADMIN_WIDTH')) { define("ADMIN_WIDTH", "width:98%;"); } 28 29 //icon, file, image upload 30 if(isset($_POST['uploadfile'])){ 31 32 if($_POST['uploadtype']){ 33 $pref['upload_storagetype'] = "1"; 34 require_once(e_HANDLER."upload_handler.php"); 35 $mainparent = $aa -> getMainParent(intval($_POST['parent1'])); 36 $content_pref = $aa -> getContentPref($mainparent); 37 38 if($_POST['content_id']){ 39 $newpid = $_POST['content_id']; 40 }else{ 41 $sql -> db_select("pcontent", "MAX(content_id) as aid", "content_id!='0' "); 42 list($aid) = $sql -> db_Fetch(); 43 $newpid = $aid+1; 44 } 45 } 46 47 //icon 48 if($_POST['uploadtype'] == "1"){ 49 $pref['upload_storagetype'] = "1"; 50 $pathtmp = $_POST['tmppathicon']; 51 $uploaded = file_upload($pathtmp); 52 $new = ""; 53 if($uploaded){ 54 $uporg = $uploaded[0]['name']; 55 $resize = (isset($content_pref["content_upload_icon_size"]) && $content_pref["content_upload_icon_size"] ? $content_pref["content_upload_icon_size"] : "100"); 56 if($uporg){ 57 $new = $newpid."_".$uporg; 58 rename($pathtmp.$uporg, $pathtmp.$new); 59 require_once(e_HANDLER."resize_handler.php"); 60 resize_image($pathtmp.$new, $pathtmp.$new, $resize, "nocopy"); 61 } 62 } 63 $message = ($new ? CONTENT_ADMIN_ITEM_LAN_106 : CONTENT_ADMIN_ITEM_LAN_107); 64 65 //file 66 }elseif($_POST['uploadtype'] == "2"){ 67 $pref['upload_storagetype'] = "1"; 68 $pathtmp = $_POST['tmppathfile']; 69 $uploaded = file_upload($pathtmp); 70 $new = ""; 71 if($uploaded){ 72 $uporg = $uploaded[0]['name']; 73 if($uporg){ 74 $new = $newpid."_".$uporg; 75 rename($pathtmp.$uporg, $pathtmp.$new); 76 } 77 } 78 $message = ($new ? CONTENT_ADMIN_ITEM_LAN_108 : CONTENT_ADMIN_ITEM_LAN_109); 79 80 //image 81 }elseif($_POST['uploadtype'] == "3"){ 82 $pref['upload_storagetype'] = "1"; 83 $pathtmp = $_POST['tmppathimage']; 84 $uploaded = file_upload($pathtmp); 85 $new = ""; 86 if($uploaded){ 87 $uporg = $uploaded[0]['name']; 88 $resize = (isset($content_pref["content_upload_image_size"]) && $content_pref["content_upload_image_size"] ? $content_pref["content_upload_image_size"] : "500"); 89 $resizethumb = (isset($content_pref["content_upload_image_size_thumb"]) && $content_pref["content_upload_image_size_thumb"] ? $content_pref["content_upload_image_size_thumb"] : "100"); 90 if($uporg){ 91 $new = $newpid."_".$uporg; 92 rename($pathtmp.$uporg, $pathtmp.$new); 93 require_once(e_HANDLER."resize_handler.php"); 94 resize_image($pathtmp.$new, $pathtmp.$new, $resizethumb, "copy"); 95 resize_image($pathtmp.$new, $pathtmp.$new, $resize, "nocopy"); 96 } 97 } 98 $message = ($new ? CONTENT_ADMIN_ITEM_LAN_110 : CONTENT_ADMIN_ITEM_LAN_111); 99 } 100 } 101 102 class contentdb{ 103 104 //function dbContentUpdate($mode, $type){ 105 function dbContent($mode, $type){ 106 //$mode : create or update 107 //$type : none(=admin), submit, contentmanager 108 global $pref, $qs, $sql, $ns, $rs, $aa, $tp, $plugintable, $e107cache, $eArrayStorage, $e_event; 109 110 $_POST['content_heading'] = $tp -> toDB(trim($_POST['content_heading'])); 111 $_POST['content_subheading'] = $tp -> toDB($_POST['content_subheading']); 112 $_POST['content_summary'] = $tp -> toDB($_POST['content_summary']); 113 114 if(e_WYSIWYG){ 115 $_POST['content_text'] = $tp->createConstants($_POST['content_text']); // convert e107_images/ to {e_IMAGE} etc. 116 } 117 //the problem with tiny_mce is it's storing e_HTTP with an image path, while it should only use the {e_xxx} variables 118 //this small check resolves this, and stores the paths correctly 119 if(strstr($_POST['content_text'],e_HTTP."{e_")){ 120 $_POST['content_text'] = str_replace(e_HTTP."{e_", "{e_", $_POST['content_text']); 121 } 122 123 $_POST['content_text'] = $tp -> toDB($_POST['content_text']); 124 $_POST['content_class'] = ($_POST['content_class'] ? intval($_POST['content_class']) : "0"); 125 $_POST['content_meta'] = $tp -> toDB($_POST['content_meta']); 126 //content create 127 if( isset($qs[0]) && $qs[0]=='content' && isset($qs[1]) && ($qs[1]=='create' || $qs[1]=='submit') && isset($qs[2]) && is_numeric($qs[2]) ){ 128 $parent = intval($_POST['parent1']); 129 130 //content edit 131 }elseif( isset($qs[0]) && $qs[0]=='content' && isset($qs[1]) && ($qs[1]=='edit' || $qs[1]=='sa') && isset($qs[2]) && is_numeric($qs[2]) ){ 132 if( isset($_POST['parent1']) && strpos($_POST['parent1'], ".") ){ 133 $tmp = explode(".", $_POST['parent1']); 134 $parent = $tmp[1]; 135 }else{ 136 $parent = $_POST['parent1']; 137 } 138 } 139 $_POST['parent'] = $parent; 140 141 if(USER){ 142 if($_POST['content_author_id']){ 143 if(!($_POST['content_author_id'] == USERID && $_POST['content_author_name'] == USERNAME && $_POST['content_author_email'] == USEREMAIL) ){ 144 145 $author = $_POST['content_author_id']; 146 147 if($_POST['content_author_name'] != CONTENT_ADMIN_ITEM_LAN_14){ 148 $author .= "^".$_POST['content_author_name']; 149 } 150 if($_POST['content_author_email'] != CONTENT_ADMIN_ITEM_LAN_15){ 151 $author .= "^".$_POST['content_author_email']; 152 } 153 154 }else{ 155 $author = $_POST['content_author_id']; 156 } 157 }else{ 158 $author = $_POST['content_author_name']; 159 if($_POST['content_author_email'] != "" && $_POST['content_author_email'] != CONTENT_ADMIN_ITEM_LAN_15){ 160 $author .= "^".$_POST['content_author_email']; 161 } 162 } 163 }else{ 164 $author = $_POST['content_author_name']; 165 if($_POST['content_author_email'] != "" && $_POST['content_author_email'] != CONTENT_ADMIN_ITEM_LAN_15){ 166 $author .= "^".$_POST['content_author_email']; 167 } 168 } 169 170 $mainparent = $aa -> getMainParent(intval($_POST['parent'])); 171 $content_pref = $aa -> getContentPref($mainparent); 172 173 $content_pref["content_icon_path_tmp"] = ($content_pref["content_icon_path_tmp"] ? $content_pref["content_icon_path_tmp"] : $content_pref["content_icon_path"]."tmp/"); 174 $content_pref["content_file_path_tmp"] = ($content_pref["content_file_path_tmp"] ? $content_pref["content_file_path_tmp"] : $content_pref["content_file_path"]."tmp/"); 175 $content_pref["content_image_path_tmp"] = ($content_pref["content_image_path_tmp"] ? $content_pref["content_image_path_tmp"] : $content_pref["content_image_path"]."tmp/"); 176 177 $content_cat_icon_path_large = $tp -> replaceConstants($content_pref["content_cat_icon_path_large"]); 178 $content_cat_icon_path_small = $tp -> replaceConstants($content_pref["content_cat_icon_path_small"]); 179 $content_icon_path = $tp -> replaceConstants($content_pref["content_icon_path"]); 180 $content_image_path = $tp -> replaceConstants($content_pref["content_image_path"]); 181 $content_file_path = $tp -> replaceConstants($content_pref["content_file_path"]); 182 $content_tmppath_icon = $tp -> replaceConstants($content_pref["content_icon_path_tmp"]); 183 $content_tmppath_file = $tp -> replaceConstants($content_pref["content_file_path_tmp"]); 184 $content_tmppath_image = $tp -> replaceConstants($content_pref["content_image_path_tmp"]); 185 186 //move icon to correct folder 187 if($_POST['content_icon']){ 188 $icon = $tp->toDB($_POST['content_icon']); 189 if($icon && file_exists($content_tmppath_icon.$icon)){ 190 rename($content_tmppath_icon.$icon, $content_icon_path.$icon); 191 } 192 } 193 194 $sumf = 0; 195 $sumi = 0; 196 foreach($_POST as $k => $v){ 197 if(strpos($k, "content_files") === 0){ 198 $sumf = $sumf+1; 199 } 200 if(strpos($k, "content_images") === 0){ 201 $sumi = $sumi+1; 202 } 203 } 204 //move attachments to correct folder 205 $totalattach = ""; 206 for($i=0;$i<$sumf;$i++){ 207 $attach{$i} = $tp->toDB($_POST["content_files{$i}"]); 208 if($attach{$i} && file_exists($content_tmppath_file.$attach{$i})){ 209 rename($content_tmppath_file.$attach{$i}, $content_file_path.$attach{$i}); 210 } 211 if($attach{$i} && file_exists($content_file_path.$attach{$i})){ 212 $totalattach .= "[file]".$attach{$i}; 213 } 214 } 215 //move images to correct folder 216 $totalimages = ""; 217 for($i=0;$i<$sumi;$i++){ 218 $image{$i} = $tp->toDB($_POST["content_images{$i}"]); 219 if($image{$i} && file_exists($content_tmppath_image.$image{$i})){ 220 rename($content_tmppath_image.$image{$i}, $content_image_path.$image{$i}); 221 } 222 if($image{$i} && file_exists($content_tmppath_image."thumb_".$image{$i})){ 223 rename($content_tmppath_image."thumb_".$image{$i}, $content_image_path."thumb_".$image{$i}); 224 } 225 if($image{$i} && file_exists($content_image_path.$image{$i})){ 226 $totalimages .= "[img]".$image{$i}; 227 } 228 } 229 230 if($_POST['update_datestamp']){ 231 $starttime = time(); 232 }else{ 233 if( isset($_POST['ne_day']) && $_POST['ne_day']!='' && $_POST['ne_day']!='0' && $_POST['ne_day'] != "none" 234 && isset($_POST['ne_month']) && $_POST['ne_month']!='' && $_POST['ne_month']!='0' && $_POST['ne_month'] != "none" 235 && isset($_POST['ne_year']) && $_POST['ne_year']!='' && $_POST['ne_year']!='0' && $_POST['ne_year'] != "none" ){ 236 $newstarttime = mktime( 0, 0, 0, intval($_POST['ne_month']), intval($_POST['ne_day']), intval($_POST['ne_year'])); 237 }else{ 238 $newstarttime = time(); 239 } 240 if(isset($_POST['content_datestamp']) && $_POST['content_datestamp'] != "" && $_POST['content_datestamp'] != "0"){ 241 if($newstarttime != $starttime){ 242 $starttime = $newstarttime; 243 }else{ 244 $starttime = intval($_POST['content_datestamp']); 245 } 246 }else{ 247 $starttime = time(); 248 } 249 } 250 251 if( isset($_POST['end_day']) && $_POST['end_day']!='' && $_POST['end_day']!='0' && $_POST['end_day'] != "none" 252 && isset($_POST['end_month']) && $_POST['end_month']!='' && $_POST['end_month']!='0' && $_POST['end_month'] != "none" 253 && isset($_POST['end_year']) && $_POST['end_year']!='' && $_POST['end_year']!='0' && $_POST['end_year'] != "none" ){ 254 $endtime = mktime( 0, 0, 0, intval($_POST['end_month']), intval($_POST['end_day']), intval($_POST['end_year'])); 255 }else{ 256 $endtime = "0"; 257 } 258 259 //custom additional data tags 260 for($i=0;$i<$content_pref["content_admin_custom_number"];$i++){ 261 if(isset($_POST["content_custom_key_{$i}"]) && isset($_POST["content_custom_value_{$i}"]) && $_POST["content_custom_value_{$i}"] != ""){ 262 $keystring = $tp->toDB($_POST["content_custom_key_{$i}"]); 263 $custom["content_custom_{$keystring}"] = $tp->toDB($_POST["content_custom_value_{$i}"]); 264 } 265 } 266 //preset additional data tags 267 if(isset($_POST['content_custom_preset_key']) && $_POST['content_custom_preset_key']){ 268 $custom['content_custom_presettags'] = $tp->toDB($_POST['content_custom_preset_key']); 269 } 270 if($custom){ 271 $contentprefvalue = $eArrayStorage->WriteArray($custom); 272 }else{ 273 $contentprefvalue = ""; 274 } 275 276 $_POST['content_layout'] = (!$_POST['content_layout'] || $_POST['content_layout'] == "content_content_template.php" ? "" : $tp->toDB($_POST['content_layout'])); 277 278 //content_order : not added in the sql 279 //content_refer : only added in sql if posting submitted item 280 //$refer = (isset($_POST['content_refer']) && $_POST['content_refer']=='sa' ? ", content_refer='' " : ""); 281 282 if($mode == "create"){ 283 if($type == "submit"){ 284 $refer = ($content_pref["content_submit_directpost"] ? "" : "sa"); 285 }else{ 286 $refer = ""; 287 } 288 $sql -> db_Insert($plugintable, "'0', '".$_POST['content_heading']."', '".$_POST['content_subheading']."', '".$_POST['content_summary']."', '".$_POST['content_text']."', '".$tp->toDB($author)."', '".$icon."', '".$totalattach."', '".$totalimages."', '".$_POST['parent']."', '".intval($_POST['content_comment'])."', '".intval($_POST['content_rate'])."', '".intval($_POST['content_pe'])."', '".$refer."', '".$starttime."', '".$endtime."', '".$_POST['content_class']."', '".$contentprefvalue."', '0', '".intval($_POST['content_score'])."', '".$_POST['content_meta']."', '".$_POST['content_layout']."' "); 289 290 $e107cache->clear("$plugintable"); 291 292 //trigger event for notify 293 $edata_cs = array("content_heading" => $_POST['content_heading'], "content_subheading" => $_POST['content_subheading'], "content_author" => $_POST['content_author_name']); 294 $e_event->trigger("content", $edata_cs); 295 296 if(!$type || $type == "admin"){ 297 js_location(e_SELF."?".e_QUERY.".cc"); 298 }elseif($type == "contentmanager"){ 299 js_location(e_SELF."?c"); 300 }elseif($type == "submit"){ 301 if($content_pref["content_submit_directpost"]){ 302 js_location(e_SELF."?s"); 303 }else{ 304 js_location(e_SELF."?d"); 305 } 306 } 307 } 308 309 if($mode == "update"){ 310 if($type == "submit"){ 311 if(isset($_POST['content_refer']) && $_POST['content_refer']=='sa'){ 312 $refer = ", content_refer='' "; 313 }else{ 314 $refer = ""; 315 } 316 }else{ 317 if(isset($_POST['content_refer']) && $_POST['content_refer']=='sa'){ 318 $refer = ", content_refer='' "; 319 }else{ 320 $refer = ""; 321 } 322 } 323 $sql -> db_Update($plugintable, "content_heading = '".$_POST['content_heading']."', content_subheading = '".$_POST['content_subheading']."', content_summary = '".$_POST['content_summary']."', content_text = '".$_POST['content_text']."', content_author = '".$tp->toDB($author)."', content_icon = '".$icon."', content_file = '".$totalattach."', content_image = '".$totalimages."', content_parent = '".$_POST['parent']."', content_comment = '".intval($_POST['content_comment'])."', content_rate = '".intval($_POST['content_rate'])."', content_pe = '".intval($_POST['content_pe'])."' ".$refer.", content_datestamp = '".$starttime."', content_enddate = '".$endtime."', content_class = '".$_POST['content_class']."', content_pref = '".$contentprefvalue."', content_score='".intval($_POST['content_score'])."', content_meta='".$_POST['content_meta']."', content_layout='".$_POST['content_layout']."' WHERE content_id = '".intval($_POST['content_id'])."' "); 324 325 $e107cache->clear("$plugintable"); 326 $e107cache->clear("comment.$plugintable.{$_POST['content_id']}"); 327 if(!$type || $type == "admin"){ 328 js_location(e_SELF."?".e_QUERY.".cu"); 329 }elseif($type == "contentmanager"){ 330 js_location(e_SELF."?u"); 331 } 332 } 333 } 334 335 336 //function dbCategoryUpdate($mode){ 337 function dbCategory($mode){ 338 global $pref, $sql, $ns, $qs, $rs, $aa, $tp, $plugintable, $e107cache, $content_cat_icon_path_large, $content_cat_icon_path_small; 339 340 $_POST['cat_heading'] = $tp -> toDB($_POST['cat_heading']); 341 $_POST['cat_subheading'] = $tp -> toDB($_POST['cat_subheading']); 342 if(e_WYSIWYG){ 343 $_POST['cat_text'] = $tp->createConstants($_POST['cat_text']); // convert e107_images/ to {e_IMAGE} etc. 344 } 345 $_POST['cat_text'] = $tp -> toDB($_POST['cat_text']); 346 $_POST['cat_class'] = ($_POST['cat_class'] ? intval($_POST['cat_class']) : "0"); 347 348 //category create 349 if( isset($qs[0]) && $qs[0]=='cat' && isset($qs[1]) && $qs[1]=='create' ){ 350 if( isset($qs[2]) && is_numeric($qs[2]) ){ 351 $parent = "0.".intval($qs[2]); 352 }else{ 353 $parent = 0; 354 } 355 356 //category edit 357 }elseif( isset($qs[0]) && $qs[0]=='cat' && isset($qs[1]) && $qs[1]=='edit' ){ 358 if( isset($qs[2]) && is_numeric($qs[2]) ){ 359 360 if( isset($qs[3]) && is_numeric($qs[3]) ){ 361 if(intval($qs[3]) == 0){ 362 $parent = 0; 363 }elseif( $qs[2] == $qs[3] ){ 364 $parent = 0; 365 }else{ 366 $parent = "0.".intval($qs[3]); 367 } 368 }else{ 369 if($qs[2]==$_POST['cat_id']){ 370 $parent = intval($_POST['parent_id']); 371 $parent = ($parent!=0 ? "0.".$parent : 0); 372 }else{ 373 } 374 } 375 }else{ 376 $parent = 0; 377 } 378 } 379 $_POST['parent'] = $parent; 380 381 if( isset($_POST['ne_day']) && $_POST['ne_day']!='' && $_POST['ne_day']!='0' && $_POST['ne_day'] != "none" 382 && isset($_POST['ne_month']) && $_POST['ne_month']!='' && $_POST['ne_month']!='0' && $_POST['ne_month'] != "none" 383 && isset($_POST['ne_year']) && $_POST['ne_year']!='' && $_POST['ne_year']!='0' && $_POST['ne_year'] != "none" ){ 384 $starttime = mktime( 0, 0, 0, intval($_POST['ne_month']), intval($_POST['ne_day']), intval($_POST['ne_year'])); 385 }else{ 386 $starttime = time(); 387 } 388 389 if( isset($_POST['end_day']) && $_POST['end_day']!='' && $_POST['end_day']!='0' && $_POST['end_day'] != "none" 390 && isset($_POST['end_month']) && $_POST['end_month']!='' && $_POST['end_month']!='0' && $_POST['end_month'] != "none" 391 && isset($_POST['end_year']) && $_POST['end_year']!='' && $_POST['end_year']!='0' && $_POST['end_year'] != "none" ){ 392 $endtime = mktime( 0, 0, 0, intval($_POST['end_month']), intval($_POST['end_day']), intval($_POST['end_year'])); 393 }else{ 394 $endtime = "0"; 395 } 396 397 if($mode == "create"){ 398 $sql -> db_Insert($plugintable, "'0', '".$_POST['cat_heading']."', '".$_POST['cat_subheading']."', '', '".$_POST['cat_text']."', '".ADMINID."', '".$tp->toDB($_POST["cat_icon"])."', '', '', '".$_POST['parent']."', '".intval($_POST['cat_comment'])."', '".intval($_POST['cat_rate'])."', '".intval($_POST['cat_pe'])."', '', '".$starttime."', '".$endtime."', '".$_POST['cat_class']."', '', '0', '0', '', '' "); 399 400 // check and insert default pref values if new main parent + create menu file 401 if($_POST['parent'] == "0"){ 402 $iid = mysql_insert_id(); 403 $content_pref = $aa -> getContentPref($iid); 404 $aa -> CreateParentMenu($iid); 405 } 406 $e107cache->clear("$plugintable"); 407 js_location(e_SELF."?".e_QUERY.".pc"); 408 409 }elseif($mode == "update"){ 410 $sql -> db_Update($plugintable, "content_heading = '".$_POST['cat_heading']."', content_subheading = '".$_POST['cat_subheading']."', content_summary = '', content_text = '".$_POST['cat_text']."', content_author = '".ADMINID."', content_icon = '".$tp->toDB($_POST["cat_icon"])."', content_image = '', content_parent = '".$_POST['parent']."', content_comment = '".intval($_POST['cat_comment'])."', content_rate = '".intval($_POST['cat_rate'])."', content_pe = '".intval($_POST['cat_pe'])."', content_refer = '0', content_datestamp = '".$starttime."', content_enddate = '".$endtime."', content_class = '".intval($_POST['cat_class'])."' WHERE content_id = '".intval($_POST['cat_id'])."' "); 411 412 // check and insert default pref values if new main parent + create menu file 413 if($_POST['parent'] == "0"){ 414 @unlink(e_PLUGIN."content/menus/content_".$_POST['menuheading']."_menu.php"); 415 $content_pref = $aa -> getContentPref($_POST['cat_id']); 416 $aa -> CreateParentMenu($_POST['cat_id']); 417 } 418 $e107cache->clear("$plugintable"); 419 js_location(e_SELF."?".e_QUERY.".pu"); 420 } 421 } 422 423 424 function dbAssignAdmins($mode, $id, $value){ 425 global $plugintable, $qs, $sql, $eArrayStorage; 426 427 if($mode == "admin"){ 428 $id = intval($id); 429 $sql -> db_Select($plugintable, "content_pref", "content_id = '".intval($id)."' "); 430 $row = $sql -> db_Fetch(); 431 432 //get current preferences 433 $content_pref = $eArrayStorage->ReadArray($row['content_pref']); 434 435 //assign new preferences 436 if($value == "clear"){ 437 $content_pref["content_manager_allowed"] = ""; 438 }else{ 439 $content_pref["content_manager_allowed"] = $value; 440 } 441 442 //create new array of preferences 443 $tmp = $eArrayStorage->WriteArray($content_pref); 444 445 $sql -> db_Update($plugintable, "content_pref = '{$tmp}' WHERE content_id = '".intval($id)."' "); 446 447 $message = CONTENT_ADMIN_CAT_LAN_34; 448 return $message; 449 }else{ 450 return FALSE; 451 } 452 } 453 454 455 456 function dbDelete($mode, $cat, $del_id){ 457 global $plugintable, $sql, $_POST, $e107cache; 458 459 if($mode == "admin"){ 460 if($cat == "cat"){ 461 if($sql -> db_Delete($plugintable, "content_id='".intval($del_id)."' ")){ 462 $e107cache->clear("$plugintable"); 463 $message = CONTENT_ADMIN_CAT_LAN_23; 464 return $message; 465 } 466 }elseif($cat == "content"){ 467 if($sql -> db_Delete($plugintable, "content_id='".intval($del_id)."' ")){ 468 $e107cache->clear("$plugintable"); 469 $message = CONTENT_ADMIN_ITEM_LAN_3; 470 return $message; 471 } 472 } 473 }else{ 474 return FALSE; 475 } 476 } 477 478 479 480 function dbSetOrder($mode, $type, $order){ 481 global $plugintable, $sql, $aa, $qs, $_POST, $e107cache; 482 //$mode : all, inc, dec 483 //$type : cc (category order), ai (global all items), ci (items in category) 484 //$order : posted values or id-currentorder 485 486 if($mode == "all"){ 487 foreach ($order as $cid){ 488 //each order value in the db has two numbers (a-b) where a = category item order, and b = global item order 489 //146.3.cat : category order 490 //35.3.ci.1-0 : category item order 491 //35.3.ai.1-0 : global item order 492 493 $tmp = explode(".", $cid); 494 $old = explode("-", $tmp[3]); 495 $old[0] = ($old[0] == "" ? "0" : $old[0]); 496 $old[1] = ($old[1] == "" ? "0" : $old[1]); 497 498 $tmp[0] = intval($tmp[0]); 499 $tmp[1] = intval($tmp[1]); 500 $old[0] = intval($old[0]); 501 $old[1] = intval($old[1]); 502 503 if($tmp[2] == "cat"){ 504 $sql->db_Update($plugintable, "content_order='".$tmp[1]."' WHERE content_id='".$tmp[0]."' " ); 505 506 }elseif($tmp[2] == "ci"){ 507 $sql->db_Update($plugintable, "content_order='".$tmp[1].".".$old[1]."' WHERE content_id='".$tmp[0]."' " ); 508 509 }elseif($tmp[2] == "ai"){ 510 $sql->db_Update($plugintable, "content_order='".$old[0].".".$tmp[1]."' WHERE content_id='".$tmp[0]."' " ); 511 } 512 $message = CONTENT_ADMIN_ORDER_LAN_2; 513 } 514 515 }elseif($mode == "inc"){ 516 517 $tmp = explode("-", $order); 518 $tmp[0] = intval($tmp[0]); 519 $tmp[1] = intval($tmp[1]); 520 $tmp[2] = intval($tmp[2]); 521 522 if($type == "cc"){ 523 $mainparent = $aa -> getMainParent($tmp[0]); 524 $array = $aa -> getCategoryTree("", $mainparent, TRUE); 525 $validparent = implode(",", array_keys($array)); 526 $qry = " content_id REGEXP '".$aa -> CONTENTREGEXP($validparent)."' AND content_order='".($tmp[1]-1)."' "; 527 $sql->db_Update($plugintable, "content_order=content_order+1 WHERE ".$qry." " ); 528 $sql->db_Update($plugintable, "content_order=content_order-1 WHERE content_id='".$tmp[0]."' " ); 529 530 }elseif($type == "ci"){ 531 $sql->db_Update($plugintable, "content_order='".$tmp[1].".".$tmp[2]."' WHERE content_parent = '".intval($qs[2])."' AND SUBSTRING_INDEX(content_order, '.', 1) = '".($tmp[1]-1)."' " ); 532 $sql->db_Update($plugintable, "content_order='".($tmp[1]-1).".".$tmp[2]."' WHERE content_id='".$tmp[0]."' " ); 533 534 }elseif($type == "ai"){ 535 $array = $aa -> getCategoryTree("", intval($qs[1]), TRUE); 536 $validparent = implode(",", array_keys($array)); 537 $qry = " content_parent REGEXP '".$aa -> CONTENTREGEXP($validparent)."' AND SUBSTRING_INDEX(content_order, '.', -1) = '".($tmp[2]-1)."' "; 538 $sql->db_Update($plugintable, " content_order=content_order+0.1 WHERE ".$qry." " ); 539 $sql->db_Update($plugintable, "content_order='".$tmp[1].".".($tmp[2]-1)."' WHERE content_id='".$tmp[0]."' " ); 540 541 } 542 $message = CONTENT_ADMIN_ORDER_LAN_0; 543 544 }elseif($mode == "dec"){ 545 546 $tmp = explode("-", $order); 547 $tmp[0] = intval($tmp[0]); 548 $tmp[1] = intval($tmp[1]); 549 $tmp[2] = intval($tmp[2]); 550 if($type == "cc"){ 551 $mainparent = $aa -> getMainParent($tmp[0]); 552 $array = $aa -> getCategoryTree("", $mainparent, TRUE); 553 $validparent = implode(",", array_keys($array)); 554 $qry = " content_id REGEXP '".$aa -> CONTENTREGEXP($validparent)."' AND content_order='".($tmp[1]+1)."' "; 555 $sql->db_Update($plugintable, "content_order=content_order-1 WHERE ".$qry." " ); 556 $sql->db_Update($plugintable, "content_order=content_order+1 WHERE content_id='".$tmp[0]."' " ); 557 558 }elseif($type == "ci"){ 559 $sql->db_Update($plugintable, "content_order='".$tmp[1].".".$tmp[2]."' WHERE content_parent = '".intval($qs[2])."' AND SUBSTRING_INDEX(content_order, '.', 1) = '".($tmp[1]+1)."' " ); 560 $sql->db_Update($plugintable, "content_order='".($tmp[1]+1).".".$tmp[2]."' WHERE content_id='".$tmp[0]."' " ); 561 562 }elseif($type == "ai"){ 563 $array = $aa -> getCategoryTree("", intval($qs[1]), TRUE); 564 $validparent = implode(",", array_keys($array)); 565 $qry = " content_parent REGEXP '".$aa -> CONTENTREGEXP($validparent)."' AND SUBSTRING_INDEX(content_order, '.', -1) = '".($tmp[2]+1)."' "; 566 $sql->db_Update($plugintable, "content_order=content_order-0.1 WHERE ".$qry." " ); 567 $sql->db_Update($plugintable, "content_order='".$tmp[1].".".($tmp[2]+1)."' WHERE content_id='".$tmp[0]."' " ); 568 } 569 $message = CONTENT_ADMIN_ORDER_LAN_1; 570 } 571 $e107cache->clear("$plugintable"); 572 return $message; 573 } 574 } 575 576 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Apr 1 01:23:32 2007 | par Balluche grâce à PHPXref 0.7 |