<?php 
/*#################################################################*\
|# Licence Number 0H6R-0808-0UVQ-0111
|# -------------------------------------------------------------   #|
|# Copyright (c)2012 PHP Link Directory.                           #|
|# http://www.phplinkdirectory.com                                 #|
\*#################################################################*/
	 
	
/**
 # ################################################################################
 # Project:   PHP Link Directory
 #
 # **********************************************************************
 # Copyright (C) 2004-2012 NetCreated, Inc. (http://www.netcreated.com/)
 #
 # This software is for use only to those who have purchased a license.
 # A license must be purchased for EACH installation of the software.
 #
 # By using the software you agree to the terms:
 #
 #    - You may not redistribute, sell or otherwise share this software
 #      in whole or in part without the consent of the the ownership
 #      of PHP Link Directory. Please contact david@david-duval.com
 #      if you need more information.
 #
 #    - You agree to retain a link back to http://www.phplinkdirectory.com/
 #      on all pages of your directory if you purchased any of our "link back" 
 #      versions of the software.
 #
 #
 # In some cases, license holders may be required to agree to changes
 # in the software license before receiving updates to the software.
 # **********************************************************************
 #
 # For questions, help, comments, discussion, etc., please join the
 # PHP Link Directory Forum http://www.phplinkdirectory.com/forum/
 #
 # @link           http://www.phplinkdirectory.com/
 # @copyright      2004-2012 NetCreated, Inc. (http://www.netcreated.com/)
 # @projectManager David DuVal <david@david-duval.com>
 # @package        PHPLinkDirectory
 # @version        4.2.1
 # ################################################################################
 */
 
require_once 'init.php';

if ($_REQUEST['action'])
{
   list ($action, $id, $val) = explode(':', $_REQUEST['action']);

   $action = strtoupper (trim ($action));

   $tpl->assign('action', strtoupper ($action));
}

//Correct value for ID
if (isset ($id)) {
	$id = trim($id);	
}

//next one's the zone name
if (isset($val)) {
	$val    = trim($val);
}
   
if ($id != '') {
	
	if (empty ($_REQUEST['submit']) && !empty ($_SERVER['HTTP_REFERER']))
   		$_SESSION['return'] = $_SERVER['HTTP_REFERER'];
	
	$wd = new Widget($id, '');
	
	switch ($action)
	{
	   case 'UP': //move order up a spot
	   	  if ($wd->move_up($val)) {
	   	  	$tpl->assign('op_status', 1);
	   	  } else {
	   	  	$tpl->assign('op_status', -1);
	   	  }
	      if (isset ($_SESSION['return']))
	         http_custom_redirect($_SESSION['return']);
	      break;	
	   case 'DOWN': //move order down a spot
	   	  if ($wd->move_down($val)) {
	   	  	$tpl->assign('op_status', 1);
	   	  } else {
	   	  	$tpl->assign('op_status', -1);
	   	  }
	      if (isset ($_SESSION['return']))
	         http_custom_redirect($_SESSION['return']);
	      break;	   
	   case 'A' : //ACTIVATE
	   	 if ($id != 'MainContent') {
	   	  if ($wd->activate($val)) {
	   	  	$_SESSION['wid_message'] = "Changes made.";
	   	  	$tpl->assign('op_status', 1);
	   	  } else {
	   	  	$tpl->assign('op_status', -1);
	   	  }
	   	 }
	      if (isset ($_SESSION['return']))
	         http_custom_redirect($_SESSION['return']);
	      break;
	   case 'D' : //DEACTIVATE
		if ($id != 'MainContent') {
	   	  if ($wd->deactivate($val)) {
	   	  	$_SESSION['wid_message'] = "Changes made.";
	   	  	$tpl->assign('op_status', 1);
	   	  } else {
	   	  	$tpl->assign('op_status', -1);
	   	  }
		}
	      if (isset ($_SESSION['return']))
	         http_custom_redirect($_SESSION['return']);
	      break;
	   default :
	   	break;		
	
	}
	
} else {
	if (isset ($_SESSION['return']))
		http_custom_redirect($_SESSION['return']);
	break;
}
?>
