From 46b09517206e7c0c4e0394e93c1f1c04cd62451f Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Fri, 8 Apr 2011 17:09:15 +0200 Subject: [PATCH] LSaddon :: asterisk : Added addon to support asterisk functions --- .../LSaddons/config.LSaddons.asterisk.php | 32 +++++++ .../includes/addons/LSaddons.asterisk.php | 85 +++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 public_html/conf/LSaddons/config.LSaddons.asterisk.php create mode 100644 public_html/includes/addons/LSaddons.asterisk.php diff --git a/public_html/conf/LSaddons/config.LSaddons.asterisk.php b/public_html/conf/LSaddons/config.LSaddons.asterisk.php new file mode 100644 index 00000000..eaf04949 --- /dev/null +++ b/public_html/conf/LSaddons/config.LSaddons.asterisk.php @@ -0,0 +1,32 @@ + diff --git a/public_html/includes/addons/LSaddons.asterisk.php b/public_html/includes/addons/LSaddons.asterisk.php new file mode 100644 index 00000000..f8fdc8e0 --- /dev/null +++ b/public_html/includes/addons/LSaddons.asterisk.php @@ -0,0 +1,85 @@ + + * + * @retval boolean true if Asterisk is totally supported, false in other case + */ + function LSaddon_asterisk_support() { + $retval=true; + + $MUST_DEFINE_CONST= array( + 'LS_ASTERISK_HASH_PWD_FORMAT', + ); + + foreach($MUST_DEFINE_CONST as $const) { + if ( (!defined($const)) || (constant($const) == "")) { + LSerror :: addErrorCode('ASTERISK_SUPPORT_01',$const); + $retval=false; + } + } + + return $retval; + } + + + + /** + * Make asterisk password hash + * + * @author Benjamin Renard + * + * Hash password in MD5 respecting the LSformat LS_ASTERISK_HASH_PWD_FORMAT. + * + * This function can be used as encode_function of LSattr_ldap :: password. + * + * @param[in] $ldapObject LSldapObject The LSldapObject use to build the hashed password + * @param[in] $clearPassword string The password in clear text + * + * @retval string The hashed password + */ + function hashAsteriskPassword($ldapObject,$clearPassword) { + if (!is_a($ldapObject,'LSldapObject')) { + LSerror :: addErrorCode('ASTERISK_01',array('function' => 'hashAsteriskPassword', 'objectName' => 'LSldapObject')); + return; + } + if (!is_string($clearPassword)) { + return; + } + $ldapObject -> registerOtherValue('clearPassword',$clearPassword); + return md5($ldapObject->getFData(LS_ASTERISK_HASH_PWD_FORMAT)); + } + +