芝麻web文件管理V1.00
编辑当前文件:/home/p/r/i/prismawe/clients/canaldegap.fr_old/modules/parcelle/action.editcomm.php
variables["admintheme"]; if(isset($params["cancel"]) || ($this->GetPreference("restrict_permissions",false) && !$this->CheckPermission("parcelle_advanced") && !$this->CheckPermission("parcelle_manage_commune")) ){ $newparams = array("active_tab" => "commune"); if(!isset($params["cancel"])) $newparams["module_message"] = $this->Lang("error_denied"); $this->Redirect($id, "defaultadmin", $returnid, $newparams); } $db =& $this->GetDb(); if(isset($params["commid"])) { // if we are working on an item that exists, we load it. We must do this even when the form is submitted, otherwise we won't have the file fields $items = $this->get_level_commune(array("id"=>$params["commid"])); $item = $items[0]; } // CHECK IF THE FORM IS BEING SUBMITTED : // (we must detect all kinds of submit buttons, including files, since information must be saved before we go to file submission) if (isset($params["submit"]) || isset($params["apply"]) || isset($params["add_plan"]) || isset($params["remove_plan"]) ) { debug_buffer("Edit Form has been submitted".__LINE__); // RETRIEVING THE FORM VALUES (and escaping it, if needed) if(!isset($item)) $item = new stdClass(); if(isset($params["commitem_order"])) $item->item_order = $params["commitem_order"]; $item->code = $params["commcode"]; $item->dpt = $params["commdpt"]; $item->insee = $params["comminsee"]; $item->cp = $params["commcp"]; $item->name = $params["commname"]; if($this->GetPreference("editable_aliases",false)){ if(isset($params["commalias"])){ $tmpalias = $this->plcreatealias(trim($params["commalias"])); $item->alias = $tmpalias == ""?$this->plcreatealias($item->name):$tmpalias; }else{ $item->alias = $this->plcreatealias($item->name); } }else{ $item->alias = $this->plcreatealias($item->name); } $autoincrementalias = $this->GetPreference("autoincrement_alias",false); // CHECK IF THE NEEDED VALUES ARE THERE if( !isset($params["commname"]) || $params["commname"] == "" ) { echo $this->ShowErrors($this->Lang("error_missginvalue")); }elseif(!$autoincrementalias && false == $this->checkalias("module_parcelle_commune", $item->alias, isset($params["commid"])?$params["commid"]:false)){ echo $this->ShowErrors($this->Lang("error_alreadyexists")); }else{ ############ DOING THE UPDATE if($autoincrementalias){ $basealias = $item->alias; $tmpalias = $item->alias; $i = 1; while(!$this->checkalias("module_parcelle_commune", $tmpalias, isset($params["commid"])?$params["commid"]:false)){ $tmpalias = $basealias."_".$i; $i++; } $item->alias = $tmpalias; } // FIELDS TO UPDATE $query = (isset($item->id)?"UPDATE ":"INSERT INTO ").cms_db_prefix()."module_parcelle_commune SET code=?, dpt=?, insee=?, cp=?, name=?, alias=?, date_modified=?, active=".(isset($item->active)?$item->active:1).", isdefault=".(isset($item->isdefault)?$item->isdefault:0).""; // VALUES $values = array($item->code, addslashes($item->dpt), addslashes($item->insee), addslashes($item->cp), addslashes($item->name),$item->alias,str_replace("'","",$db->DBTimeStamp(time()))); if(isset($item->id)){ $event = "parcelle_modified"; $query .= " WHERE id=?;"; array_push($values,$item->id); }else{ // NEW ITEM $query .= ", date_created=?"; $values[] = str_replace("'","",$db->DBTimeStamp(time())); $event = "parcelle_added"; // get a new id from the sequence table $item->id = $db->GenID(cms_db_prefix()."module_parcelle_commune_seq"); if($this->GetPreference("newitemsfirst_commune",false)){ // new items get to the top - so we must put all other items down from one step, and then set this item's order to 1 $query2 = "UPDATE ".cms_db_prefix()."module_parcelle_commune SET item_order=(item_order+1)"; $db->Execute($query2); $query .= ",item_order=1, id=".$item->id; }else{ // new items get to the bottom - so we must set the item_order to the number of items + 1 $item_order = $this->countsomething("commune") + 1; $query .= ",item_order=".$item_order.", id=".$item->id; } } $db->Execute($query, $values); $redirect = true; //if(mysql_affected_rows()){ // mysql-only if($db->Affected_Rows()){ if($this->GetPreference("searchmodule_index_commune",false)){ // IF ANYTHING WAS MODIFIED, WE MUST UPDATE THE SEARCH INDEX AND SEND AN EVENT... if(isset($event)) $this->SendEvent($event, array("what"=>"commune", "itemid" => $item->id, "alias"=>$item->alias)); debug_buffer("SEARHC INDEX WAS UPDATED ".__LINE__); $module =& $this->GetModuleInstance("Search"); if($module) { $text = "$item->name"; $module->AddWords($this->GetName(), $item->id, "commune", $text, NULL); } } }elseif(mysql_error()){ // do not redirect : $redirect = false; echo $this->ShowErrors(mysql_error()); } // REDIRECTING... if(isset($params["add_plan"])){ $params = array("commid"=>$item->id,"field"=>"plan","tablename"=>"parcelle_commune","prefix"=>"comm", "startdir"=>"parcelles/communes/", "extensions"=>"pdf,jpg,jpeg,gif,png", "mode"=>"file"); $this->Redirect($id, "browsefiles", $returnid, $params); }elseif(isset($params["remove_plan"])){ $params = array("commid"=>$item->id,"field"=>"plan","level"=>"commune","tablename"=>"parcelle_commune","prefix"=>"comm"); $this->Redirect($id, "assignfile", $returnid, $params); }elseif($redirect == false){ }elseif(isset($params["apply"])){ echo $this->ShowMessage($this->Lang("message_modified")); }else{ $params = array("module_message" => $this->Lang("message_modified"), "active_tab"=>"commune"); $this->Redirect($id, "defaultadmin", $returnid, $params); } } // END OF FORM SUBMISSION } /* ## PREPARING SMARTY ELEMENTS CreateInputText : (id,name,value,size,maxlength) CreateTextArea : (wysiwyg,id,text,name) CreateInputSelectList : (id,name,items,selecteditems,size) CreateInputDropdown : (id,name,items,sindex,svalue) */ $this->smarty->assign("code_label", $this->Lang("commune_code")); $this->smarty->assign("code_input", $this->CreateInputText($id,"commcode",isset($item)?$item->code:"",30,10)); $this->smarty->assign("dpt_label", $this->Lang("commune_dpt")); $this->smarty->assign("dpt_input", $this->CreateInputText($id,"commdpt",isset($item)?$item->dpt:"",30,10)); $this->smarty->assign("insee_label", $this->Lang("commune_insee")); $this->smarty->assign("insee_input", $this->CreateInputText($id,"comminsee",isset($item)?$item->insee:"",30,10)); $this->smarty->assign("cp_label", $this->Lang("commune_cp")); $this->smarty->assign("cp_input", $this->CreateInputText($id,"commcp",isset($item)?$item->cp:"",30,10)); $this->smarty->assign("plan_label", $this->Lang("commune_plan")); $this->smarty->assign("plan_input", ((isset($item->plan) && $item->plan)?$item->plan->pic.'
'.$item->plan->filepath."
(".$item->plan->size_wformat.")
".$this->CreateInputSubmit($id,"remove_plan",$this->Lang("Remove"))." ":"").$this->CreateInputSubmit($id,"add_plan",$this->Lang("commune_select_plan"))); $this->smarty->assign("name_label", $this->Lang("name")); $this->smarty->assign("name_input", $this->CreateInputText($id,"commname",isset($item)?$item->name:"",50,64)); if($this->GetPreference("editable_aliases",false)){ $this->smarty->assign("alias_label", $this->Lang("alias")); $this->smarty->assign("alias_input", $this->CreateInputText($id,"commalias",isset($item)?$item->alias:"",50,64)); $this->smarty->assign("itemalias",false); }else{ $this->smarty->assign("itemalias",isset($item->alias)?"(alias : ".$item->alias.")":false); $this->smarty->assign("alias_input", false); } $this->smarty->assign("edittitle", $this->Lang("edit_commune")); $this->smarty->assign("submit", $this->CreateInputSubmit($id, "submit", lang("submit"))); $this->smarty->assign("apply", (isset($item) && isset($item->id))?$this->CreateInputSubmit($id, "apply", lang("apply")):""); $this->smarty->assign("cancel", $this->CreateInputSubmit($id, "cancel", lang("cancel"))); // DISPLAYING if(isset($item) && isset($item->id)){ echo $this->CreateFormStart($id, "editcomm", $returnid); echo $this->ProcessTemplate("editcomm.tpl"); echo $this->CreateInputHidden($id, "commid", $item->id); if(isset($item) && isset($item->parent)) echo $this->CreateInputHidden($id, "oldparent", $item->parent); echo $this->CreateInputHidden($id, "commitem_order", $item->item_order); echo $this->CreateFormEnd(); }else{ echo $this->CreateFormStart($id, "editcomm", $returnid); echo $this->ProcessTemplate("editcomm.tpl"); echo $this->CreateFormEnd(); } ?>