Add ability to control the display of the "Check Spelling" button. Allows administrat...
[squirrelmail.git] / plugins / change_password / backend / poppassd.php
index 753750c86fdaa31aa1b561950fafb3f9fc813580..91e75b99d198b962a8fa246c652027ac6bcd067f 100644 (file)
@@ -3,7 +3,9 @@
 /**
  * Poppassd change password backend
  *
- * @author Seth Randall <sethr@missoulafcu.org>
+ * @author Seth Randall <sethr at missoulafcu.org>
+ * @copyright 2004-2017 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package plugins
  * @subpackage change_password
@@ -21,21 +23,14 @@ global $poppassd_server;
 
 $poppassd_server = '';
 
+/* get overrides from config.php */
+if (isset($cpw_poppassd['server'])) $poppassd_server=$cpw_poppassd['server'];
+
 /**
  * Define here the name of your password changing function.
  */
 global $squirrelmail_plugin_hooks;
 $squirrelmail_plugin_hooks['change_password_dochange']['poppassd'] = 'cpw_poppassd_dochange';
-$squirrelmail_plugin_hooks['change_password_init']['template'] = 'cpw_poppassd_init';
-
-
-/**
- * Use this function to do any backend-specific initialization,
- * e.g. checking requirements, before the password change form
- * is displayed to the user.
- */
-function cpw_poppassd_init() {
-}
 
 /**
  * This is the function that is specific to your backend. It takes
@@ -47,7 +42,7 @@ function cpw_poppassd_init() {
  * CPW_CURRENT_NOMATCH -> "Your current password is not correct."
  * CPW_INVALID_PW -> "Your new password contains invalid characters."
  *
- * @param array data The username/currentpw/newpw data. 
+ * @param array data The username/currentpw/newpw data.
  * @return array Array of error messages.
  */
 function cpw_poppassd_dochange($data) {
@@ -91,8 +86,13 @@ function cpw_poppassd_go($username, $old_pw, $new_pw, $debug = 0) {
     global $poppassd_server;
     global $imapServerAddress;
 
+    /** sqimap_get_user_server() function */
+    include_once(SM_PATH . 'functions/imap_general.php');
+
     if($poppassd_server == '') {
-        $poppassd_server = $imapServerAddress;
+        // if poppassd address is not set, use imap server's address
+        // make sure that setting contains address and not mapping
+        $poppassd_server = sqimap_get_user_server($imapServerAddress,$username);
     }
 
     $messages = array();
@@ -135,5 +135,3 @@ function cpw_poppassd_go($username, $old_pw, $new_pw, $debug = 0) {
 
     return $messages;
 }
-
-?>