From 21e4fbd9736dd6ee0eb343ae0e3dd9eebc05c0fd Mon Sep 17 00:00:00 2001 From: Steven Mondji-Lerider Date: Fri, 31 Aug 2012 10:05:39 +0000 Subject: [PATCH] finishing up default domain types admin --- .gitattributes | 1 + bureau/admin/adm_doms_def_type.php | 23 +++++++++++++++++------ bureau/admin/dom_defdel.php | 15 +++++++++++++++ bureau/class/m_dom.php | 24 +++++++++++++++++++++--- 4 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 bureau/admin/dom_defdel.php diff --git a/.gitattributes b/.gitattributes index 642107a6..0fe1dc3d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -133,6 +133,7 @@ bureau/admin/bro_view.php -text bureau/admin/browseforfolder.php -text bureau/admin/cron.php -text bureau/admin/dom_add.php -text +bureau/admin/dom_defdel.php -text bureau/admin/dom_doadd.php -text bureau/admin/dom_dodel.php -text bureau/admin/dom_edit.inc.php -text diff --git a/bureau/admin/adm_doms_def_type.php b/bureau/admin/adm_doms_def_type.php index 17bd4486..5e62b56c 100644 --- a/bureau/admin/adm_doms_def_type.php +++ b/bureau/admin/adm_doms_def_type.php @@ -12,6 +12,14 @@ if (!$admin->enabled) {


+

+

+
lst_default_subdomains(); ?> -
+ - - + + + - + @@ -74,8 +85,8 @@ for($i=0;$i +
 
+ + - ' >' > ' >

" />

-

" />

diff --git a/bureau/admin/dom_defdel.php b/bureau/admin/dom_defdel.php new file mode 100644 index 00000000..7dbe661a --- /dev/null +++ b/bureau/admin/dom_defdel.php @@ -0,0 +1,15 @@ + array ("request", "integer", ""), + ); +getFields($fields); + +//checker admin rights + +$dom->del_default_type($id); +include_once("adm_doms_def_type.php"); + + diff --git a/bureau/class/m_dom.php b/bureau/class/m_dom.php index 6ede7489..b6e5afe2 100644 --- a/bureau/class/m_dom.php +++ b/bureau/class/m_dom.php @@ -391,6 +391,7 @@ class m_dom { function create_default_subdomains($domain,$target_domain=""){ global $db; + $err->log("dom","create_default_subdomains",$domain); $query="SELECT sub, domain_type, domain_type_parameter FROM default_subdomains WHERE concerned = 'SLAVE' or concerned = 'BOTH' and enabled=1;"; if(empty($target_domain)) { $query="SELECT sub, domain_type, domain_type_parameter FROM default_subdomains WHERE concerned = 'MAIN' or concerned = 'BOTH' and enabled=1;"; @@ -419,6 +420,7 @@ class m_dom { function lst_default_subdomains(){ global $db,$err; + $err->log("dom","lst_default_subdomains"); $c=array(); $db->query("select * from default_subdomains;"); @@ -437,13 +439,14 @@ class m_dom { function update_default_subdomains($arr) { + global $err; + $err->log("dom","update_default_subdomains"); $ok=true; foreach ($arr as $a) { if (! isset($a['id'])) $a['id']=null; if(!empty($a['sub']) || !empty($a['domain_type_parameter'])){ if (! isset($a['enabled'])) $a['enabled']=0; - printvar($a); if (! $this->update_one_default($a['domain_type'],$a['sub'], $a['domain_type_parameter'], $a['concerned'], $a['enabled'],$a['id']) ) { $ok=false; } @@ -454,15 +457,30 @@ class m_dom { function update_one_default($domain_type,$sub,$domain_type_parameter,$concerned,$enabled,$id=null){ global $db,$err; + $err->log("dom","update_one_default"); if($id==null) - $db->query("INSERT INTO default_subdomains values ('','".$sub."','".$domain_type."','".$domain_type_parameter."','".$concerned."','".$enabled."');"); + $db->query("INSERT INTO default_subdomains values ('','".addslashes($sub)."','".addslashes($domain_type)."','".addslashes($domain_type_parameter)."','".addslashes($concerned)."','".addslashes($enabled)."');"); else - $db->query("UPDATE default_subdomains set sub='".$sub."', domain_type='".$domain_type."',domain_type_parameter='".$domain_type_parameter."',concerned='".$concerned."',enabled='".$enabled."' where id=".$id.";"); + $db->query("UPDATE default_subdomains set sub='".addslashes($sub)."', domain_type='".addslashes($domain_type)."',domain_type_parameter='".addslashes($domain_type_parameter)."',concerned='".addslashes($concerned)."',enabled='".addslashes($enabled)."' where id=".addslashes($id).";"); return true; //update + } + + function del_default_type($id){ + global $err,$db; + $err->log("dom","del_default_type"); + + if(!$db->query("delete from default_subdomains where id=$id;")){ + $err->raise("dom",_("Could not delete default type")); + return false; + } + + return true; + + } /* ----------------------------------------------------------------- */