Location: PHPKode > projects > Simple Way to Usenet > swun/libs/swun/rpc/rpconf_db.class.php
<?php
/**
 *  
 * @author  Benjamin Gillissen <hide@address.com>
 * 
 *	**************************************************************

	Copyright (C) 2009  Benjamin Gillissen
	
	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details at:
	http://www.gnu.org/copyleft/gpl.html

 *	**************************************************************
 */
class rpconf_db extends dbobject {
	
	
	public function __construct(){ 
		parent::__construct(configs::get('hellarpc', 'CNF')); 
	}
	
	public function isrpc($rid){
		$arg=Array('id' => $rid);
		return $this->dbquery($arg, __FUNCTION__);
	}
	
	public function get_staTO($rid){		return $this->getconfarg($rid, 'staTO'); }
	
	public function gethost($rid){ 			return $this->getconfarg($rid, 'host'); }
			
	public function isactif($rid){ 			return $this->getconfarg($rid, 'actif'); }
	
	public function getname($rid){ 			return $this->getconfarg($rid, 'name'); }
	
	public function get_destrepo($rid){ 	return $this->getconfarg($rid, 'repo'); }
		
	public function get_repobaseurl($rid){ 	return $this->getconfarg($rid, 'baseurl'); }
	
	public function getpolicy($rid){ 		return $this->getconfarg($rid, 'cachepol'); }
	
	public function getconninfo($rid){
		$conninfo = Array('host', 'port', 'user', 'pass', "conTO");
		foreach($conninfo as $k => &$info){ $o[$info] = $this->getconfarg($rid, $info); }
		return $o;
	}
	
	private function getconfarg($rid, $info){
		$arg=Array('id'=>$rid, 'info'=>$info);
		return $this->dbquery($arg, __FUNCTION__, $info);
	}
	
	public function getfirst(){
		$arg=Array();
		return $this->dbquery($arg, __FUNCTION__, 'rid');
	}
	
	public function listall($start=NULL, $end=NULL){
		if ( $start === NULL OR $end === NULL ){
			$start=0;
			$end=$this->countall();
		}
		$arg=Array('start'=>$start, 'end'=>$end);
		while ( FALSE !== ($rid = $this->dbquery($arg, __FUNCTION__, 'rid') )){ $o[] = $rid; }
		if ( isset($o) ){ return $o; }
		return FALSE;
	}
	
	public function countall(){
		$arg=Array();
		return $this->dbquery($arg, __FUNCTION__);
	}
	
	
	
	
	//FOR webadmin, later
	public function add($name, $ip, $port, $user, $pass, $cpol, $conTO, $staTO, $repo, $baseurl, $actif){
		$conf = serialize(Array('ip' => $ip, 'port' => $port, 'user' => $user, 'pass' => $pass, 'cpol'=>$cpol));
		$arg=Array('conf'=>$conf, 'qid'=>$qid);
		return $this->dbquery($arg, __FUNCTION__);
	}
	
	public function edit($rid, $name, $ip, $port, $user, $pass, $cpol, $qid){
		$conf = serialize(Array('ip' => $ip, 'port' => $port, 'user' => $user, 'pass' => $pass, 'cpol'=>$cpol));
		$arg=Array('id'=>$rid, 'conf'=>$conf, 'qid'=>$qid);
		return $this->dbquery($arg, __FUNCTION__);
	}
	
	public function del($rid){
		$arg=Array('id'=>$rid);
		return $this->dbquery($arg, __FUNCTION__);
	}
}
Return current item: Simple Way to Usenet