Location: PHPKode > projects > Netautor Professional > netautor/napro4/admin/database/queum.php
<?php
/* +----------------------------------------------------------------------+
   | Netautor Professional Application Server                             |
   +----------------------------------------------------------------------+
   | Copyright (C) 1998-2005 digiconcept GmbH. <www.digiconcept.net>      |
   +----------------------------------------------------------------------+
   | This file is subject to license, that is bundled with this package   |
   | in the file LICENSE.TXT, and is available at through the             |
   | world-wide-web at http://www.netautor.com/license/                   |
   |                                                                      |
   | If you did not receive a copy of the license and are unable to       |
   | obtain it through the world-wide-web, please send a note to          |
   | hide@address.com so we can mail you a copy.                      |
   +----------------------------------------------------------------------+
   | Authors: Stefan Rottensteiner <hide@address.com>    |
   |          Marek  Kadziela      <hide@address.com>	      |
   |          Gregor Wollner                                              |
   |          Christian Unger                                             |
   |          Helli  Kleinhans  									      |
   +----------------------------------------------------------------------+*/

   /**
    * @version	$Revision: 1.9 $
	*/
	require_once('../../include/init.inc');
	if(!$USER->check_feature('Admin') && !$USER->check_feature('ac_queu'))
	{
		$USER->login_call();
	}

	$LOCALE->textdomain('database');


	//	include necessary functions
	includeNaPro('array,form,string');

	$n_sta 		= (empty($n_sta) || !empty($clear) 		? '' : $n_sta 	);
	$n_action 	= (empty($n_action) || !empty($clear) 	? '' : $n_action);
	$n_typ 		= (empty($n_typ) || !empty($clear) 		? '' : $n_typ);
	$mn_naid 	= (empty($mn_naid) || !empty($clear) 	? '' : $mn_naid);
	$n_tab 		= (empty($n_tab) || !empty($clear)	 	? '' : $n_tab);
	$n_from 	= (empty($n_from) || !empty($clear)	 	? '' : $n_from);
	$n_to 		= (empty($n_to) || !empty($clear)	 	? '' : $n_to);
	$search		= (empty($search) || !empty($clear)	 	? '' : $search);
	$n_tab_frm	= $n_tab;

	$message="";

	function add_nbsp($str,$len)
	{
		$str.= str_repeat( ' ', max(0, $len - strlen($str)));

		if(strlen($str)>$len) $str=substr($str,0,strlen($str)-5)."... ";

		return str_replace(' ','&nbsp;',$str);
	}

//#######################
//Add to Queu
//#######################
if(!empty($addtab))
{
	$n_tab_act=(empty($n_action) ? "rep_creation" : $n_action);

	switch($n_typ)
	{
		case 'mnames':	
			if(empty($n_tab_frm))
			{
				$query="select mn_id from mnames order by mn_id";
				$n_erg=$sql_world->select($query,0,0);
				includeNaPro('queu');

				for($i=0;$i<count($n_erg);$i++)
				{
					$my_queu = new queu;
					$my_queu->set_queu('mnames',$n_tab_act,'mn_id='.$n_erg[$i]['mn_id']);
					$my_queu->write_queu();	
					unset($my_queu);
				}	
			}
			else
			{
				$query="select mn_id from mnames where mn_naid='".$n_tab_frm."' order by mn_id";
				$n_erg=$sql_world->select($query,0,0);
				includeNaPro('queu');
				$my_queu = new queu; 
				$my_queu->set_queu('mnames',$n_tab_act,'mn_id='.$n_erg[0]['mn_id']);
				$my_queu->write_queu();		
			}
		break;

		case 'mlayouts':	
			if(empty($n_tab_frm))
			{
				$query="select mlay_id from mlayouts order by mlay_id";
				$n_erg=$sql_world->select($query,0,0);
				includeNaPro('queu');
				for($i=0;$i<count($n_erg);$i++)
				{
					$my_queu = new queu; 
					$my_queu->set_queu('mlayouts',$n_tab_act,'mlay_id='.$n_erg[$i]['mlay_id']);
					$my_queu->write_queu();	
					unset($my_queu);
				}	
			}
			else
			{
				$query="select mlay_id from mlayouts where mlay_mn_naid='".$n_tab_frm."' order by mlay_id";
				$n_erg=$sql_world->select($query,0,0);
				includeNaPro('queu');

		        for($i=0;$i<count($n_erg);$i++)
		        {
		        	$my_queu = new queu;
		        	$my_queu->set_queu('mlayouts',$n_tab_act,'mlay_id='.$n_erg[$i]['mlay_id']);
		        	$my_queu->write_queu(); 
		        	unset($my_queu);
		        }
			}
		break;
	
		case 'melements':
			if(empty($n_tab_frm))
			{
				$query="select me_id from melements where me_me_id IS NOT NULL order by me_id";
				$n_erg=$sql_world->select($query,0,0);
				includeNaPro('queu');
				if($n_tab_act=='rep_delete')
				{
					for($i=count($n_erg)-1;$i>=0;$i--)
					{
						$my_queu = new queu;
						$my_queu->set_queu('melements',$n_tab_act,'me_id='.$n_erg[$i]['me_id']);
						$my_queu->write_queu();
						unset($my_queu);
					}
				}
				else
				{
					for($i=0;$i<count($n_erg);$i++)
					{
						$my_queu = new queu;
						$my_queu->set_queu('melements',$n_tab_act,'me_id='.$n_erg[$i]['me_id']);
						$my_queu->write_queu();
						unset($my_queu);
					}
				}
			}
			else
			{
				$query="select me_id from melements where me_me_id IS NOT NULL AND me_mn_naid='".$n_tab_frm."' order by me_id";
				$n_erg=$sql_world->select($query,0,0);
				includeNaPro('queu');
				if($n_tab_act=='rep_delete')
				{
					for($i=count($n_erg)-1;$i>=0;$i--)
					{
						$my_queu = new queu;
						$my_queu->set_queu('melements',$n_tab_act,'me_id='.$n_erg[$i]['me_id']);
						$my_queu->write_queu();
						unset($my_queu);
					}
				}
				else
				{
					for($i=0;$i<count($n_erg);$i++)
					{
						$my_queu = new queu;
						$my_queu->set_queu("melements",$n_tab_act,"me_id=".$n_erg[$i]["me_id"]);
						$my_queu->write_queu();
						unset($my_queu);
					}
				}
			}
		break;
		case 'me_settings':
			if(empty($n_tab_frm))
			{
				$query="select mes_id from me_settings order by mes_id";
				$n_erg=$sql_world->select($query,0,0);
				includeNaPro('queu');
				for($i=0;$i<count($n_erg);$i++)
				{
					$my_queu = new queu; 
					$my_queu->set_queu("me_settings",$n_tab_act,"mes_id=".$n_erg[$i]["mes_id"]);
					$my_queu->write_queu();	
					unset($my_queu);
				}	
			}
			else
			{
				$in_query="select me_id from melements where me_content='select' AND me_mn_naid='".$n_tab_frm."' order by me_id";
				$i_erg=$sql_world->select($in_query,0,0);

				if(!empty($i_erg))
				{
					$in="";
					for($i=0;$i<count($i_erg);$i++)
					{
						$in.=$i_erg[$i]["me_id"].",";
					}

					$in=rchopright(",",$in);
					$query="select mes_id from me_settings where mes_me_id in (".$in.") order by mes_id";
					$n_erg=$sql_world->select($query,0,0);

					includeNaPro('queu');
					for($i=0;$i<count($n_erg);$i++)
					{
						$my_queu = new queu; 
						$my_queu->set_queu("me_settings",$n_tab_act,"mes_id=".$n_erg[$i]["mes_id"]);
						$my_queu->write_queu();		
						unset($my_queu);
					}
				}
			}
		break;

		case 'mdocs':

			if(!$n_tab_frm)
			{
				$query="select mdoc_id from mdocs order by mdoc_id";
				$n_erg=$sql_world->select($query,0,0);
				includeNaPro('queu');
				for($i=0;$i<count($n_erg);$i++)
				{
					$my_queu = new queu; 
					$my_queu->set_queu("mdocs",$n_tab_act,"mdoc_id=".$n_erg[$i]["mdoc_id"]);
					$my_queu->write_queu();	
					unset($my_queu);
				}	
			}
			else
			{
				$query="select mdoc_id from mdocs where mdoc_mn_naid='".$n_tab_frm."' order by mdoc_id";
				$n_erg=$sql_world->select($query,0,0);
				includeNaPro('queu');
				for($i=0;$i<count($n_erg);$i++)
				{
					$my_queu = new queu; 
					$my_queu->set_queu("mdocs",$n_tab_act,"mdoc_id=".$n_erg[$i]["mdoc_id"]);
					$my_queu->write_queu();		
					unset($my_queu);
				}
			}
		break;

		default:
			$message='';
		break;
	}
}

if(!empty($update) && !empty($n_status))
{
	$ids 	= implode(',',$n_list);
	$query	= "UPDATE queu SET qu_status='".$n_status."' WHERE qu_id in ( {$ids} )";
	$leer	= '';
	$erg	= $sql_world->exec($query,$leer);
	$message= ( $erg > 0 ? $LOCALE->gettext('data_updated') : $LOCALE->gettext('data_not_updated') );
}

if(!empty($delete) && !empty($n_list))
{
	$ids	= implode(',',$n_list);
	$query	= "DELETE FROM queu WHERE qu_id IN ($ids)";
	$leer	= '';
	$erg	= $sql_world->exec($query,$leer);
	$message= ( $erg>=1 ? $LOCALE->gettext('data_deleted') : $LOCALE->gettext('data_not_deleted') );
}

include ('queum.msk');


?>
Return current item: Netautor Professional