| [21] | 1 | <?php |
|---|
| 2 | |
|---|
| 3 | // Parse the parameters from the Ajax.Request |
|---|
| 4 | |
|---|
| 5 | //if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER ['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') { |
|---|
| 6 | require( dirname(__FILE__) . '/../../../../wp-config.php' ); |
|---|
| 7 | if (!(is_user_logged_in() && current_user_can('edit_posts'))) |
|---|
| 8 | die("Athentication failed!"); |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | global $wpdb, $canvas; |
|---|
| 12 | //print_r($_GET); |
|---|
| 13 | foreach ($_GET as $key => $values) { |
|---|
| 14 | if (!empty($values)) { |
|---|
| 15 | if (substr($key, 0, 1) != "_"){ |
|---|
| 16 | if ($key != "shelf"){ |
|---|
| 17 | $template_name = $_GET["_".$key."_template_name"][0]; |
|---|
| 18 | $template_size = $_GET["_".$key."_template_size"][0]; |
|---|
| 19 | //echo $block_template; |
|---|
| 20 | } |
|---|
| 21 | else{ |
|---|
| 22 | $template_name = ""; |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | foreach ($values as $k => $value) { |
|---|
| 26 | |
|---|
| 27 | if ($key != "_") { |
|---|
| 28 | |
|---|
| 29 | /*$pos = strrpos($value, "_"); |
|---|
| 30 | $temp = substr($value, 0, $pos); |
|---|
| 31 | $block_id = substr($value, $pos+1, strlen($value)); |
|---|
| 32 | $pos = strrpos($temp, "_"); |
|---|
| 33 | $oldlocation = substr($temp, 0, $pos); |
|---|
| 34 | $oldposition = substr($temp, $pos+1, strlen($temp));*/ |
|---|
| 35 | |
|---|
| 36 | $block_id = $value; |
|---|
| 37 | $position = $k + 1; |
|---|
| 38 | $newzone = $key; |
|---|
| 39 | |
|---|
| 40 | if (!$wpdb->get_var("SELECT template_name FROM ".$canvas->main." WHERE block_id='$block_id'")){ |
|---|
| 41 | // template name has not been set before |
|---|
| 42 | $template_name_query= " , template_name='$template_name' "; |
|---|
| 43 | $template_size_query= " , template_size='$template_size' "; |
|---|
| 44 | } |
|---|
| 45 | if ($newzone == "shelf") |
|---|
| 46 | $wpdb->query("UPDATE ".$canvas->main." |
|---|
| 47 | SET zone='$newzone', |
|---|
| 48 | position='$position', |
|---|
| 49 | template_name='', |
|---|
| 50 | template_size='' |
|---|
| 51 | WHERE block_id='$block_id'"); |
|---|
| 52 | else |
|---|
| 53 | $wpdb->query("UPDATE ".$canvas->main." |
|---|
| 54 | SET zone='$newzone', |
|---|
| 55 | position='$position' |
|---|
| 56 | $template_size_query |
|---|
| 57 | $template_name_query |
|---|
| 58 | WHERE block_id='$block_id'"); |
|---|
| 59 | |
|---|
| 60 | $wpdb->query("UPDATE ".$canvas->main." SET zone='$newzone' WHERE block_id='$block_id'"); |
|---|
| 61 | //} |
|---|
| 62 | } |
|---|
| 63 | } |
|---|
| 64 | } |
|---|
| 65 | } |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | // Update modules info |
|---|
| 69 | require_once('../canvas-core.php'); |
|---|
| 70 | $dir = CANVASPATH.'/modules/'; |
|---|
| 71 | $positions = $wpdb->get_var("SELECT MAX(position) FROM ".$canvas->main." WHERE theme = '".get_option('template')."' AND zone = 'shelf'"); |
|---|
| 72 | canvas_import_plugins($position, $dir); |
|---|
| 73 | |
|---|
| 74 | //} |
|---|
| 75 | ?> |
|---|