summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c1e278e)
raw | patch | inline | side by side (parent: c1e278e)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 1 Sep 2005 07:52:01 +0000 (07:52 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 1 Sep 2005 07:52:01 +0000 (07:52 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1279 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/gofon/phoneaccount/class_phoneAccount.inc | patch | blob | history | |
plugins/gofon/phoneaccount/generic.tpl | patch | blob | history |
diff --git a/plugins/gofon/phoneaccount/class_phoneAccount.inc b/plugins/gofon/phoneaccount/class_phoneAccount.inc
index 534de790f8e9c42588426b5209bd56a30987affc..f274977a10cb72dc97de2496d18acd8972b4e062 100644 (file)
var $goFonHardware = "";
var $goFonFormat = "";
var $goFonPIN = "";
+ var $goFonVoicePIN = "";
var $goFonDeliveryMode = "";
var $phoneNumbers = array();
var $mail = "";
/* attribute list for save action */
var $attributes = array("goFonDeliveryMode", "goFonFormat","uid","cn","mail",
- "goFonHardware", "goFonPIN", "telephoneNumber", "goFonMacro","macro");
+ "goFonHardware","goFonPIN", "telephoneNumber", "goFonMacro","macro");
var $objectclasses= array("goFonAccount");
function phoneAccount ($config, $dn= NULL)
if($this->is_account){
$this->is_modified = true;
}
+
+ /* Set PINs to false,
+ * to avoid setting them before we explicitly
+ * pressed set voicemail PIN or Phone PIN
+ */
+
+ if(count(split("\|",$this->goFonPIN))==2){
+ $tmp = split("\|",$this->goFonPIN);
+ $this->goFonPIN = $tmp[0];
+ $this->goFonVoicePIN = $tmp[1];
+ }else{
+ $this->goFonVoicePIN = $this->goFonPIN;
+ }
+
+ // Unset goFonPIN, to avoid save_object for this attribute
+ foreach($this->attributes as $key=>$val){
+ if($val == "goFonPIN"){
+ unset($this->attributes[$key]);
+ }
+ }
+
}
return false;
}
+ $existence = mysql_fetch_row(mysql_query( "SELECT * FROM ".$a_SETUP['SIP_TABLE']." WHERE name='".$this->uid."';"));
+
+ if(!$existence&&((empty($this->goFonPIN))||(empty($this->goFonVoicePIN)))){
+ $this->generate_error = _("You are currently creating a new phone account, please specify a value for phone PIN and voice PIN.");
+ return(false);
+ }
+
+ if((empty($this->goFonPIN))&&(empty($existence[27]))){
+ $this->generate_error = _("The PIN attribute is missing in database entry. Please assign a valid phone PIN.");
+ return(false);
+ }
+
+ if(isset($existence[15])){
+ $voice = mysql_fetch_row(mysql_query("SELECT password FROM ".$a_SETUP['VOICE_TABLE']." where customer_id='".$existence[15]."'"));
+ if((empty($this->goFonVoicePIN))&&(empty($voice[0]))){
+ $this->generate_error = _("The voice PIN attribute is missing in database entry. Please assign a valid voice PIN.");
+ return(false);
+ }
+ }
+
/* If Save == true, we should save something.
* Generate SQL, for drop of old entries
* Generate SQL, for insert new entries
*/
if($save == true){
+
+ /* Get old voice passwword if no new isset */
+ if($this->goFonPIN==false){
+ $pin = mysql_fetch_row(mysql_query("SELECT secret FROM ".$a_SETUP['SIP_TABLE']." where name='".$this->uid."'"));
+ $this->goFonPIN = $pin[0];
+ }
+
// Attribute GoFonDefaultIP set ?
if(((isset($a_ldap_attrs['goFonDefaultIP'][0]))&&($a_ldap_attrs['goFonDefaultIP'][0] != "dynamic"))){
$s_ip = $a_ldap_attrs['goFonDefaultIP'][0];
$s_mail = "";
}
+
+ /* Get old voice passwword if no new isset */
+ if($this->goFonVoicePIN==false){
+ $voice = mysql_fetch_row(mysql_query("SELECT password FROM ".$a_SETUP['VOICE_TABLE']." where customer_id=".$this->phoneNumbers[$i_new_key].""));
+ $this->goFonVoicePIN = $voice[0];
+ }
+
+ /* Get old voice passwword if no new isset */
+ if($this->goFonPIN==false){
+ $pin = mysql_fetch_row(mysql_query("SELECT secret FROM ".$a_SETUP['SIP_TABLE']." where name='".$this->uid."'"));
+ $this->goFonPIN = $pin[0];
+ }
+
// $SQL contains all queries
$SQL = array();
$SQL[] = "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$this->uid."';\n";
$CNname= $this->cn;
}
- $SQL[]= "INSERT INTO ".$a_SETUP['VOICE_TABLE']."
- (`customer_id`,`context`,`mailbox`,`password`,`fullname`,`email`,`pager`)
- VALUES
- ('".$this->phoneNumbers[$i_new_key]."','default','".$this->phoneNumbers[$i_new_key]."','".$this->goFonPINVoice."','".$CNname."','".$s_mail."','');";
-
+ $SQL[]= "INSERT INTO ".$a_SETUP['VOICE_TABLE']." (`customer_id`,`context`,`mailbox`,`password`,`fullname`,`email`,`pager`)
+ VALUES ('".$this->phoneNumbers[$i_new_key]."',
+ 'default',
+ '".$this->phoneNumbers[$i_new_key]."',
+ '".$this->goFonVoicePIN."',
+ '".$CNname."',
+ '".$s_mail."',
+ '');";
$i_is_accounted=false;
$i = 0;
$this->macro ="none";
}
- /* Set new Voicemail password */
- if(isset($_POST['goFonPINVoiceSet'])){
- $this->goFonPINVoice = $_POST['goFonPIN'];
+ if(isset($_POST['goFonVoicePINSet'])){
+ if((strlen($_POST['goFonVoicePIN'])==0)||(strlen($_POST['goFonVoicePIN'])>4)){
+ print_red(_("Voicemail PIN must be between 1-4 characters."));
+ }else{
+ if(preg_match("/[^0-9]/",$_POST['goFonVoicePIN'])){
+ print_red(_("The specified oicemail PIN contains invalid characters, only numeric values are allowed here."));
+ }else{
+ $this->goFonVoicePIN=$_POST['goFonVoicePIN'];
+ }
+ }
+ }
+
+ if(isset($_POST['goFonPINSet'])){
+ if((strlen($_POST['goFonPIN'])!=4)){
+ print_red(_("Phone PIN must be 4 characters long."));
+ }else{
+ if(preg_match("/[^0-9]/",$_POST['goFonVoicePIN'])){
+ print_red(_("The specified phone PIN contains invalid characters, only numeric values are allowed here."));
+ }else{
+ $this->goFonPIN=$_POST['goFonPIN'];
+ }
+ }
}
/* tell user that the pluging selected is no longer available*/
$smarty->assign ("hardware_list", $hl);
/* Show main page */
+
+ foreach(array("goFonVoicePIN","goFonPIN") as $attrs ){
+ $smarty->assign($attrs,$this->$attrs);
+ $smarty->assign($attrs."ACL",chkacl($this->acl,$attrs));
+ }
+
+
$display.= $smarty->fetch(get_template_path('generic.tpl', TRUE, dirname(__FILE__)));
return($display);
}
$message[]= sprintf(_("You need to specify at least one phone number!"));
}
- if(($this->goFonPIN)==""){
- $message[]= sprintf(_("You need to specify a Phone PIN."));
- }else{
- if(!is_id($this->goFonPIN)){
- $message[] = sprintf(_("The given PIN is not valid, only numbers are allowed for this type."));
- }elseif(strlen($this->goFonPIN) < 4){
- $message[] = sprintf(_("The given PIN is too short"));
- }
-
- }
-
/* check for ! in any parameter setting*/
if(isset($this->macroarray[$this->macro])){
foreach($this->macroarray[$this->macro] as $val){
$this->attrs['goFonMacro']=array();
}
+ /* Cahnged behavior for goFonPIN */
+ $this->attrs['goFonPIN'] = $this->goFonPIN."|".$this->goFonVoicePIN;
+
unset($this->attrs['cn']);
/* Write back to ldap */
index 26035b4be4a62b929e92203c6143122850e7f549..40de9a79bf8bb632c56bf935a4be4ac23d5a1725 100644 (file)
<td>{t}Telephone{/t}</td>
<td>{$hardware_list}</td>
</tr>
+ <tr>
+ <td>
+ <LABEL for="goFonPIN">{t}Voicemail PIN{/t}{$must}</LABEL>
+ </td>
+ <td>
+ <input type="password" id="goFonVoicePIN" name="goFonVoicePIN" value="{$goFonVoicePIN}" {$goFonPINACL}>
+ <input type="submit" name="goFonVoicePINSet" value="{t}Set phone password{/t}" {$goFonPINACL}>
+ </td>
+ </tr>
<tr>
<td>
<LABEL for="goFonPIN">{t}Phone PIN{/t}{$must}</LABEL>
</td>
<td>
<input type="password" id="goFonPIN" name="goFonPIN" value="{$goFonPIN}" {$goFonPINACL}>
- <input type="submit" name="goFonPINVoiceSet" value="{t}Set voicemail password{/t}" {$goFonPINACL}>
+ <input type="submit" name="goFonPINSet" value="{t}Set voicemail password{/t}" {$goFonPINACL}>
</td>
</tr>
</table>