2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
15 * This script handles the ajax post submit from "content editor" =? "adpated content"
16 * to remove selected alternative from database
17 * @see mods/_core/editor/editor_tabs/alternatives.inc.php
19 * pid: primary resource id
20 * a_type: alternative type, must be one of the values in resource_types.type_id
23 define('AT_INCLUDE_PATH', '../../../include/');
24 require (AT_INCLUDE_PATH.'vitals.inc.php');
26 $pid = intval($_POST['pid']);
27 $type_id = intval($_POST['a_type']);
30 if ($pid == 0 || $type_id == 0) exit;
33 // delete the existing alternative for this (pid, a_type)
34 $sql = "SELECT sr.secondary_resource_id
35 FROM ".TABLE_PREFIX."secondary_resources sr, ".TABLE_PREFIX."secondary_resources_types srt
36 WHERE sr.secondary_resource_id = srt.secondary_resource_id
37 AND sr.primary_resource_id = ".$pid."
38 AND sr.language_code = '".$_SESSION['lang']."'
39 AND srt.type_id=".$type_id;
40 $existing_secondary_result = mysql_query($sql, $db);
42 while ($existing_secondary = mysql_fetch_assoc($existing_secondary_result))
44 $sql = "DELETE FROM ".TABLE_PREFIX."secondary_resources
45 WHERE secondary_resource_id = ".$existing_secondary['secondary_resource_id'];
46 $result = mysql_query($sql, $db);
48 $sql = "DELETE FROM ".TABLE_PREFIX."secondary_resources_types
49 WHERE secondary_resource_id = ".$existing_secondary['secondary_resource_id']."
50 AND type_id=".$type_id;
51 $result = mysql_query($sql, $db);