Add ability to control the display of the "Check Spelling" button. Allows administrat...
[squirrelmail.git] / plugins / change_password / backend / merak.php
index 5bcd69eb07eab89e4ae203964d1e1b2e3fe4a624..1c332795a7f736b8619a0e70388e6925228c9785 100644 (file)
@@ -1,8 +1,11 @@
 <?php
+
 /**
  * Merakchange password backend
  *
- * @author Edwin van Elk <Edwin@eve-software.com>
+ * @author Edwin van Elk <edwin at eve-software.com>
+ * @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
@@ -20,11 +23,34 @@ $merak_url = "http://localhost:32000/";
 $merak_selfpage = "self.html";
 $merak_action = "self_edit";
 
-// NO NEED TO CHANGE ANYTHING BELOW THIS LINE
+// get overrides from config.
+if ( isset($cpw_merak) && is_array($cpw_merak) && !empty($cpw_merak) ) {
+  foreach ( $cpw_merak as $key => $value ) {
+    if ( isset(${'merak_'.$key}) )
+      ${'merak_'.$key} = $value;
+  }
+}
 
 global $squirrelmail_plugin_hooks;
-$squirrelmail_plugin_hooks['change_password_dochange']['merak'] = 
+$squirrelmail_plugin_hooks['change_password_dochange']['merak'] =
    'cpw_merak_dochange';
+$squirrelmail_plugin_hooks['change_password_init']['merak'] =
+   'cpw_merak_init';
+
+/**
+ * Check if php install has all required extensions.
+ */
+function cpw_merak_init() {
+    global $oTemplate;
+
+    if (!function_exists('curl_init')) {
+        // user_error('Curl module NOT available!', E_USER_ERROR);
+        error_box(_("PHP Curl extension is NOT available! Unable to change password!"));
+        // close html and stop script execution
+        $oTemplate->display('footer.tpl');
+        exit();
+    }
+}
 
 /**
  * This is the function that is specific to your backend. It takes
@@ -36,7 +62,7 @@ $squirrelmail_plugin_hooks['change_password_dochange']['merak'] =
  * 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_merak_dochange($data)
@@ -51,13 +77,6 @@ function cpw_merak_dochange($data)
 
    global $merak_url, $merak_selfpage, $merak_action;
 
-   if (!function_exists('curl_init')) {
-
-      // user_error('Curl module NOT available!', E_USER_ERROR);
-      array_push($msgs, _("Curl module NOT available! Unable to change password!"));
-      return $msgs;
-   }
-
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, $merak_url . $merak_selfpage);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);