[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 #CMS - CMS Made Simple 3 #(c)2004 by Ted Kulp (wishy@users.sf.net) 4 #This project's homepage is: http://cmsmadesimple.sf.net 5 # 6 #This program is free software; you can redistribute it and/or modify 7 #it under the terms of the GNU General Public License as published by 8 #the Free Software Foundation; either version 2 of the License, or 9 #(at your option) any later version. 10 # 11 #This program is distributed in the hope that it will be useful, 12 #but WITHOUT ANY WARRANTY; without even the implied warranty of 13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 #GNU General Public License for more details. 15 #You should have received a copy of the GNU General Public License 16 #along with this program; if not, write to the Free Software 17 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 # 19 #$Id: deletetemplateassoc.php 3783 2007-02-08 20:07:52Z dittmann $ 20 21 /** 22 * This page is used to delete CSS association. It doesn't show any HTML and only does 23 * treatments. 24 * For more explanations about CSS associations, please the the header of 25 * addcssassoc.php. 26 * 27 * Variable are passed by GET. Needed vars are : 28 * - $css_id : the id of the CSS link 29 * - $id : the id of the element the CSS is linked to 30 * - $type : the type of the element the CSS is linked to 31 * (only template for the moment) 32 * 33 * @since 0.6 34 * @author calexico 35 */ 36 37 38 $CMS_ADMIN_PAGE=1; 39 40 require_once ("../include.php"); 41 42 check_login(); 43 44 global $gCms; 45 $db =& $gCms->GetDb(); 46 47 #****************************************************************************** 48 # global vars definition 49 #****************************************************************************** 50 51 # this var is used to check if we'll delete or not 52 # it is set to false when an error is encountered 53 $dodelete = true; 54 55 #****************************************************************************** 56 # start of the treatment 57 #****************************************************************************** 58 if (isset($_GET["template_id"]) && isset($_GET["id"]) && isset($_GET["type"])) 59 { 60 61 # we get the parameters 62 $template_id = $_GET["template_id"]; 63 $id = $_GET["id"]; 64 $type = $_GET["type"]; 65 66 # we check the permissions 67 $userid = get_userid(); 68 $access = check_permission($userid, 'Remove Stylesheet Assoc'); 69 70 #****************************************************************************** 71 # the user has the right to delete association, we can go on 72 #****************************************************************************** 73 if ($access) 74 { 75 76 #****************************************************************************** 77 # we first have to get the name of the element the CSS is linked to 78 # this is for logging of actions 79 #****************************************************************************** 80 if ($type == 'template') 81 { 82 # first we get the name of the template for logging 83 $query = "SELECT css_name FROM ".cms_db_prefix()."css WHERE css_id = ?"; 84 $result = $db->Execute($query, array($id)); 85 86 if ($result && $result->RecordCount()) 87 { 88 $line = $result->FetchRow(); 89 $name = $line['css_name']; 90 } 91 else 92 { 93 $dodelete = false; 94 $error = lang('errorgettingcssname'); 95 } 96 } 97 98 #****************************************************************************** 99 # everythings look ok, we can delete 100 #****************************************************************************** 101 if ($dodelete) 102 { 103 $query = "DELETE FROM ".cms_db_prefix()."css_assoc where assoc_to_id = ? AND assoc_type = ? AND assoc_css_id = ?"; 104 $result = $db->Execute($query, array($template_id,$type,$id)); 105 106 if ($result) 107 { 108 audit($id, (isset($name)?$name:""), 'Deleted Stylesheet Association'); 109 110 # now updating template 111 if ("template" == $type) 112 { 113 $time = $db->DBTimeStamp(time()); 114 $tplquery = "UPDATE ".cms_db_prefix()."templates SET modified_date = ".$time." WHERE template_id = ?"; 115 $tplresult = $db->Execute($tplquery, array($template_id)); 116 } 117 } 118 else 119 { 120 $dodelete = false; 121 $error = lang('errordeletingassociation'); 122 } 123 } 124 } # end of if access 125 else 126 { 127 $dodelete = false; 128 $error = lang('noaccessto', array(lang('removecssassociation'))); 129 } 130 } # end of if params 131 else 132 { 133 $dodelete = false; 134 $error = lang('missingparams'); 135 } 136 137 #****************************************************************************** 138 # end of treatment, redirecting 139 #****************************************************************************** 140 if ($dodelete) 141 { 142 redirect("templatecss.php?id=$id&type=$type"); 143 } 144 else 145 { 146 redirect("templatecss.php?id=$id&type=$type&message=$error"); 147 } 148 149 # vim:ts=4 sw=4 noet 150 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |