summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8badf9a)
raw | patch | inline | side by side (parent: 8badf9a)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 9 Apr 2010 15:19:12 +0000 (15:19 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 9 Apr 2010 15:19:12 +0000 (15:19 +0000) |
-Do not allow to write duplicate entries into the database.
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17570 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17570 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/gofon/gofon/macro/class_gofonMacro.inc | patch | blob | history |
diff --git a/gosa-plugins/gofon/gofon/macro/class_gofonMacro.inc b/gosa-plugins/gofon/gofon/macro/class_gofonMacro.inc
index 725df304a553e49057f863af206e1bd0a998fa13..d5571e073c2eba931992bc81b94ce8221331ccf2 100644 (file)
" VALUES ";
$a_contentLines = preg_split("/\n/",$this->goFonMacroContent);
+
+ // Keep all macro priorities to avoid duplicates!
+ $priorities = array();
foreach($a_contentLines as $i_linenum => $s_linestr){
/* Remove the 'exten => ' string in front of the macro content line
*/
$tmp = explode(",", $s_linestr,3);
- // No priority given ... somehow
- if(count($tmp) == 2){
- $tmp = array($tmp[0],"1",$tmp[1]);
- }
-
/* Check if there is an application given */
- if($tmp[2] == ""){
+ if(!isset($tmp[2]) || $tmp[2] == ""){
return(sprintf(_("Application missing in line %s!"),$i_linenum));
}
- if($tmp[1] == ""){
+ if(!isset($tmp[1]) || $tmp[1] == ""){
return(sprintf(_("Priority missing in line %s!"),$i_linenum));
}
/* Check if there is an extension given */
- if($tmp[0] == ""){
+ if(!isset($tmp[0]) || $tmp[0] == ""){
return(sprintf(_("Extension missing in line %s!"),$i_linenum));
}
+ // Table 'extensions' has a primary key over the following fields
+ // 'context', 'exten' and 'priority' -
+ // Ensure that we do not write duplicates here.
+ $du = $context.$tmp[0].$tmp[1];
+ if(!isset($priorities[$du])){
+ $priorities[$du] = 1;
+ }else{
+ return(sprintf(_("Duplicate combination of 'extension' and 'priority' in line %s!"),$i_linenum));
+ }
+
/* Create extension entry for current line
* and add this line to an array that will be inserted
* to each database.