summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 613ac49)
raw | patch | inline | side by side (parent: 613ac49)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 3 May 2010 08:48:57 +0000 (08:48 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 3 May 2010 08:48:57 +0000 (08:48 +0000) |
-Removed sorting mechanisms, makes no sense, we manually specify the priority.
-Fixed storage, enforce numeric value followed by a string [0-9] [...].
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6@18020 594d385d-05f5-0310-b6e9-bd551577e9d8
-Fixed storage, enforce numeric value followed by a string [0-9] [...].
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6@18020 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/dns/admin/systems/services/dns/class_servDNSeditZone.inc | patch | blob | history |
diff --git a/gosa-plugins/dns/admin/systems/services/dns/class_servDNSeditZone.inc b/gosa-plugins/dns/admin/systems/services/dns/class_servDNSeditZone.inc
index 75024f308470711ff2e38e792bd4ffcd5c8c8e8c..1fc8b02b99520dc28209fa8e449860ef166640f5 100644 (file)
foreach($this->Records as $key => $rec){
if($rec['type'] == "mXRecord"){
$tmp = explode(" ",$rec['value']);
- $rec['value'] = $tmp[1];
$tmp2[$tmp[0]] = $rec;
unset($this->Records[$key]);
}
}
}
- /* TRansports the geiven Arraykey one position up*/
- function ArrayUp($atr,$attrs)
- {
- $ret = $attrs;
- $pos = $atr ;
- $cn = count($attrs);
- if(!(($pos == -1)||($pos == 1)||($pos >$cn))){
- $before = array_slice($attrs,0,($pos-2));
- $mitte = array_reverse(array_slice($attrs,($pos-2),2));
- $unten = array_slice($attrs,$pos);
- $ret = array();
- $ret = $this->combineArrays($before,$mitte,$unten);
- }
- return($ret);
- }
-
-
- /* TRansports the geiven Arraykey one position up*/
- function ArrayDown($atr,$attrs)
- {
- $ret = $attrs;
- $pos = $atr ;
- $cn = count($attrs);
- if(!(($pos == -1)||($pos == $cn))){
- $before = array_slice($attrs,0,($pos-1));
- $mitte = array_reverse(array_slice($attrs,($pos-1),2));
- $unten = array_slice($attrs,($pos+1));
- $ret = array();
- $ret = $this->combineArrays($before,$mitte,$unten);
- }
- return($ret);
- }
-
- /* Combine new array */
- function combineArrays($ar0,$ar1,$ar2)
- {
- $ret = array();
- if(is_array($ar0))
- foreach($ar0 as $ar => $a){
- $ret[]=$a;
- }
- if(is_array($ar1))
- foreach($ar1 as $ar => $a){
- $ret[]=$a;
- }
- if(is_array($ar2))
- foreach($ar2 as $ar => $a){
- $ret[]=$a;
- }
- return($ret);
- }
-
- function getpos($atr,$attrs)
- {
- $i = 0;
- foreach($attrs as $attr => $name) {
- $i++;
- if($attr == $atr){
- return($i);
- }
- }
- return(-1);
- }
-
function execute()
{
$once =true;
foreach($_POST as $name => $value){
- if((preg_match("/^MXup_/",$name)) && ($once)){
- $once = false;
-
- $id = preg_replace("/^MXup_/","",$name);
- $id = preg_replace("/_.*$/","",$id);
- $id = base64_decode($id);
-
- $this->mXRecords = $this->ArrayUp(($id+1),$this->mXRecords);
- }
- if((preg_match("/^MXdown_/",$name)) && ($once)){
- $once = false;
-
- $id = preg_replace("/^MXdown_/","",$name);
- $id = preg_replace("/_.*$/","",$id);
- $id = base64_decode($id);
-
- $this->mXRecords = $this->ArrayDown(($id+1),$this->mXRecords);
- }
if((preg_match("/^MXdel_/",$name)) && ($once)){
$once = false;
if($this->parent->acl_is_writeable("mXRecord")){
if((isset($_POST['AddMXRecord'])) && (!empty($_POST['StrMXRecord']))){
- $this->mXRecords[] = array("type"=>"mXRecord","value"=>trim($_POST['StrMXRecord']));
+ $rec = get_post('StrMXRecord');
+ if(preg_match("/^[0-9]* /", $rec) && count(preg_split("/ /", $rec)) == 2){
+ list($prio,$value) = preg_split("/ /", $rec);
+ $this->mXRecords[$prio] = array("type"=>"mXRecord","value"=>trim($rec));
+ }else{
+ msg_dialog::display(_("Warning"), msgPool::invalid(_("MxRecord"), "","", "20 mx.record.entry"), WARNING_DIALOG);
+ }
}
/* Handle Post events */
$div = new divSelectBox("MxRecords");
$div->setHeight(120);
$recs = $this->mXRecords;
-
- $oneup = "<input name='MXup_%s' type='image' src='images/lists/sort-up.png' title='"._("Up")."' class='center'> ";
- $onedown = "<input name='MXdown_%s' type='image' src='images/lists/sort-down.png' title='"._("Down")."' class='center'> ";
- $onedel = "<img src='images/empty.png' width='20' class='center'>
- <input name='MXdel_%s' type='image' src='images/lists/trash.png' title='"._("Delete")."' class='center'>";
-
+ ksort($recs);
+ $onedel = "<input name='MXdel_%s' type='image' src='images/lists/trash.png' title='"._("Delete")."' class='center'>";
foreach($recs as $key => $rec){
+ list($prio,$value) = preg_split("/ /", $rec['value']);
$div ->AddEntry(array(
- array("string"=>$rec['value']),
-/* array("string"=>$key,
- "attach"=>"style='width:20px;'"),*/
- array("string"=>str_replace("%s",base64_encode($key),$oneup.$onedown.$onedel),
- "attach"=>"style='width:70px;border-right:0px;'")
+ array("string"=> $prio, "attach"=>"style='width:20px;'"),
+ array("string"=> $value),
+ array("string"=>str_replace("%s",base64_encode($key),$onedel),
+ "attach"=>"style='width:20px;border-right:0px;'")
));
}
/* Create mx records
*/
foreach($this->mXRecords as $key => $rec){
- $rec['value']= $key." ".$rec['value'];
- $this->Records [] = $rec;
+ $this->Records[] = $rec;
}
-
$ret['RECORDS'] = $this->Records;