GetDb(); #****************************************************************************** # global vars definition #****************************************************************************** # this var is used to store any error that may occur. $error = ""; # this one is used later to store all the css found, because they won't appear in the dropdown $csslist = array(); $type = ""; $name = ''; #****************************************************************************** # we now get the parameters #****************************************************************************** # getting variables if (isset($_REQUEST["type"])) $type = trim($_REQUEST["type"]) ; else $error = lang('typenotvalid'); if (isset($_REQUEST["id"])) $id = (int)$_REQUEST["id"] ; else $error = lang('idnotvalid'); if( isset($_REQUEST['cssid'])) $cssid = (int)$_REQUEST['cssid']; # if type is template, we get the name if (isset($type) && "template" == $type) { $query = "SELECT template_name FROM ".cms_db_prefix()."templates WHERE template_id = ?"; $result = $db->Execute($query, array($id)); if ($result) { $line = $result->FetchRow(); $name = $line['template_name']; } else { $error = lang('errorretrievingtemplate'); } } #****************************************************************************** # first getting all user permissions #****************************************************************************** $userid = get_userid(); $modify = check_permission($userid, 'Modify Stylesheet Assoc'); $delasso = check_permission($userid, 'Remove Stylesheet Assoc'); $addasso = check_permission($userid, 'Add Stylesheet Assoc'); #****************************************************************************** # Handle moving of entries #****************************************************************************** if( isset($_REQUEST['dir']) && $modify ) { switch(trim($_REQUEST['dir'])) { case 'up': { // get the ord id for this item $q1 = 'SELECT assoc_order FROM '.cms_db_prefix().'css_assoc WHERE assoc_to_id = ? AND assoc_css_id = ?'; $ord = $db->GetOne($q1,array($id,$cssid)); if( $ord > 0 ) { // get the item with the prev ord id $q2 = 'SELECT assoc_css_id FROM '.cms_db_prefix().'css_assoc WHERE assoc_to_id = ? AND assoc_order = ?'; $other_css = $db->GetOne($q2,array($id,$ord-1)); if( $other_css ) { // swap em $q3 = 'UPDATE '.cms_db_prefix().'css_assoc SET assoc_order = ? WHERE assoc_to_id = ? AND assoc_css_id = ?'; $db->Execute($q3,array($ord,$id,$other_css)); $db->Execute($q3,array($ord-1,$id,$cssid)); } } } break; case 'down': { // get the ord id for this item $q1 = 'SELECT assoc_order FROM '.cms_db_prefix().'css_assoc WHERE assoc_to_id = ? AND assoc_css_id = ?'; $ord = $db->GetOne($q1,array($id,$cssid)); // get the item with the prev ord id $q2 = 'SELECT assoc_css_id FROM '.cms_db_prefix().'css_assoc WHERE assoc_to_id = ? AND assoc_order = ?'; $other_css = $db->GetOne($q2,array($id,$ord+1)); if( $other_css ) { // swap em $q3 = 'UPDATE '.cms_db_prefix().'css_assoc SET assoc_order = ? WHERE assoc_to_id = ? AND assoc_css_id = ?'; $db->Execute($q3,array($ord,$id,$other_css)); $db->Execute($q3,array($ord+1,$id,$cssid)); } } break; } } #****************************************************************************** # displaying errors if any #****************************************************************************** if (isset($_REQUEST["message"])) { $message = trim(preg_replace('/\','',$_REQUEST['message'])); if( !empty($message) ) { echo '
".$error."
".lang('noaccessto', array(lang('addcssassociation')))."