Only in cpanel/: .svn
diff -up cpanel47/README.txt cpanel/README.txt
--- cpanel47/README.txt	2006-05-20 20:10:37.000000000 -0500
+++ cpanel/README.txt	2008-09-26 10:05:37.000000000 -0500
@@ -16,14 +16,14 @@ accounts for every Drupal user using cPa
 
 Requirements
 ------------
-* Drupal 4.7.x
+* Drupal 5.x
 * Administrative access to your cPanel account (Username & password)
 * Unlimited Email and/or FTP accounts
 
 Install
 -------
 
-1. Upload cpanel.module to the Drupal modules/ directory.
+1. Upload cpanel.module to the Drupal /sites/all/modules/ directory.
 
 2. Activate the module via the Drupal module configuration menu
    (administer >> settings >> modules)
@@ -79,7 +79,8 @@ FTP accounts settings:
 
 Author
 -------
-Eduin Carrillo   [http://drupal.org/user/16997]
+Original author Eduin Carrillo   [http://drupal.org/user/16997]
+Current author Kai Curry
 
 License
 -------
Only in cpanel/: cpanel.info
diff -up cpanel47/cpanel.module cpanel/cpanel.module
--- cpanel47/cpanel.module	2006-05-26 08:29:10.000000000 -0500
+++ cpanel/cpanel.module	2008-11-24 16:31:47.000000000 -0600
@@ -1,5 +1,5 @@
 <?php
-// $Id: cpanel.module,v 1.1.2.4 2006/05/26 13:29:10 yecarrillo Exp $
+// $Id:$
 
 /**
  * @file
@@ -10,9 +10,19 @@
  * Implementation of hook_menu().
  */
 function cpanel_menu($may_cache) {
+global $user;
   $items = array();
 
   if ($may_cache) {
+  $items[] = array(
+    'path' => 'admin/settings/cpanel',
+    'title' => t('cpanel'),
+    'description' => t('Set your cPanel server settings.'),
+    'callback' => 'drupal_get_form',
+    'callback arguments' => array('cpanel_admin_settings'),
+    'access' => user_access('administer site configuration'),
+    'type' => MENU_NORMAL_ITEM, // optional
+   );
     $items[] = array('path' => 'admin/cpanel', 'title' => t('cpanel'),
       'callback' => 'cpanel_admin');
 
@@ -33,10 +43,7 @@ function cpanel_menu($may_cache) {
  */
 function cpanel_help($section) {
   switch ($section) {
-    case 'admin/modules#description':
-      $output =  t('Syncronize users with cPanel email and FTP accounts.');
-      break;
-    case 'admin/settings/cpanel':
+      case 'admin/settings/cpanel':
       $output = '<p>' . t('Integration with cPanel (<a href="%cpanel_url">%cpanel_url</a>)', array('%cpanel_url' => 'http://www.cpanel.net/')) . '</p>';
       $output .= '<p>' . t('cPanel is a next generation web hosting control panel system. cPanel is extremely feature rich as well as include an easy to use web based interface (GUI).') . '</p>';
       $output .= '<p>' . t('cPanel is designed for the end users of your system and allows them to control everything from adding / removing email accounts to administering MySQL databases.') . '</p>';
@@ -54,9 +61,9 @@ function cpanel_perm() {
 }
 
 /**
- * Implementation of hook_settings
+ * cpanel admin settings which are called by the _menu function here above ('callback arguments' => array('cpanel_admin_settings'),
  */
-function cpanel_settings() {
+function cpanel_admin_settings() {
 
   $form['server'] = array(
     '#type' => 'fieldset',
@@ -165,7 +172,7 @@ function cpanel_settings() {
     '#description' => t('Global domain of your website.'),
   );
   
-  return $form;
+   return system_settings_form($form);
 }
 
 /**
@@ -176,52 +183,52 @@ function cpanel_user($type, &$edit, &$us
   $cpanel_mail_domain = variable_get('cpanel_mail_domain', '');
   $cpanel_ftp_domain = variable_get('cpanel_ftp_domain', '');
   $cpanel_username = cpanel_formatname($user->name);
-
-  $form['cpanel'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('eMail & FTP accounts'),
-    '#collapsible' => TRUE,
-    '#collapsed' => FALSE,
-    '#weight' => 10,
-  );
-  
-  if ($cpanel_mail_domain != '' && variable_get('cpanel_mail_enabled', 0) && user_access('have email account', $user)) {
-    $form['cpanel']['cpanel_email'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Create an email account with my username'),
-      '#return_value' => 1,
-      '#default_value' => $edit['cpanel_email'],
-      '#description' => t('Check to create an email account with your username. You can connect to <i>%server</i> with your <a href="http://en.wikipedia.org/wiki/Internet_Message_Access_Protocol" target="_blank">IMAP</a>/<a href="http://en.wikipedia.org/wiki/Post_Office_Protocol" target="_blank">POP3</a> client.', array('%server' => 'mail.' . $cpanel_ftp_domain)),
-    );
-    $form['cpanel']['cpanel_email_info'] = array(
-      '#value' => '<div align="center"><strong>' . $cpanel_username . '@' . $cpanel_mail_domain . '</strong></div>',
+  if ($type == 'form' && $category == 'account') {
+    $form['cpanel'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('eMail & FTP accounts'),
+      '#collapsible' => TRUE,
+      '#collapsed' => FALSE,
+      '#weight' => 9,
     );
-  } 
-  if ($cpanel_ftp_domain != '' && variable_get('cpanel_ftp_enabled', 0) && user_access('have FTP account', $user)) {
-    $form['cpanel']['cpanel_ftp'] = array(
+    
+    if ($cpanel_mail_domain != '' && variable_get('cpanel_mail_enabled', 0) && user_access('have email account', $user)) {
+      $form['cpanel']['cpanel_email'] = array(
       '#type' => 'checkbox',
-      '#title' => t('Create a FTP account with my username'),
+      '#title' => t('Yes, I want an email account'),
       '#return_value' => 1,
-      '#default_value' => $edit['cpanel_ftp'],
-      '#description' => t('Check to create a FTP account with your username. You can connect to <i>%server</i> with your <a href="http://en.wikipedia.org/wiki/File_Transfer_Protocol" target="_blank">FTP</a> client.', array('%server' => 'ftp.' . $cpanel_ftp_domain)),
-    );
-    $form['cpanel']['cpanel_ftp_info'] = array(
-      '#value' => '<div align="center"><strong>' . $cpanel_username . '@' . $cpanel_ftp_domain . '</strong> (<a href="' . variable_get('cpanel_ftp_subroot', '/') . $cpanel_username . '" target="blank">' . variable_get('cpanel_ftp_subroot', '/') . $cpanel_username . '</a>) </div>',
-    );
-  }
-
-  if ($type == 'form' && $category == 'account' && count($form, COUNT_RECURSIVE) > 5) {
-    // when user tries to edit his own data
+      '#default_value' => $edit['cpanel_email'],
+        '#description' => t('Check to create or delete an email account with your username. You can connect to <i>%server</i> with your <a href="http://en.wikipedia.org/wiki/Internet_Message_Access_Protocol" target="_blank">IMAP</a>/<a href="http://en.wikipedia.org/wiki/Post_Office_Protocol" target="_blank">POP3</a> client.', array('%server' => 'mail.' . $cpanel_ftp_domain)),
+      );
+      $form['cpanel']['cpanel_email_info'] = array(
+        '#type' => 'item',
+        '#value' => '<div align="center"><strong>' . $cpanel_username . '@' . $cpanel_mail_domain . '</strong></div>',
+      );
+    } 
+    if ($cpanel_ftp_domain != '' && variable_get('cpanel_ftp_enabled', 0) && user_access('have FTP account', $user)) {
+      $form['cpanel']['cpanel_ftp'] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Yes, I want an FTP account.'),
+        '#return_value' => 1,
+        '#default_value' => $edit['cpanel_ftp'],
+        '#description' => t('Check to create a FTP account with your username. You can connect to <i>%server</i> with your <a href="http://en.wikipedia.org/wiki/File_Transfer_Protocol" target="_blank">FTP</a> client.', array('%server' => 'ftp.' . $cpanel_ftp_domain)),
+      );
+      $form['cpanel']['cpanel_ftp_info'] = array(
+        '#type' => 'item',
+        '#value' => '<div align="center"><strong>' . $cpanel_username . '@' . $cpanel_ftp_domain . '</strong> (<a href="' . variable_get('cpanel_ftp_subroot', '/') . $cpanel_username . '" target="blank">' . variable_get('cpanel_ftp_subroot', '/') . $cpanel_username . '</a>) </div>',
+      );
+    }
+    // when user tries to edit her own data
     return $form;
   }
-  if ($type == 'validate') {
+  if ($type == 'validate' && $category == 'account') {
     // validate user data editing
     return array('cpanel_email' => $edit['cpanel_email'], 'cpanel_ftp' => $edit['cpanel_ftp']);
   }
-  if ($type == 'insert') {
+  if ($type == 'insert' && $category == 'account') {
     //Create an account when a new user is inserted
     if ($cpanel_mail_domain != '' && variable_get('cpanel_mail_enabled', 0) && user_access('have email account', $user)) {
-      $ret = _cpanel_handle_request('/frontend/x/mail/doaddpop.html', array('email' => $cpanel_username, 'password' => $edit['pass'], 'domain' => $cpanel_mail_domain, 'quota' => variable_get('cpanel_mail_quota', 2)));
+      $ret = _cpanel_handle_request('/frontend/x3/mail/doaddpop.html', array('email' => $cpanel_username, 'password' => $edit['pass'], 'domain' => $cpanel_mail_domain, 'quota' => variable_get('cpanel_mail_quota', 2)));
       
       if (!$ret) {
         watchdog('user', t('Error creating cPanel email account <em>%username@%domain</em>', array('%username' => $cpanel_username,'%domain' => $cpanel_mail_domain)), WATCHDOG_ERROR);
@@ -230,7 +237,7 @@ function cpanel_user($type, &$edit, &$us
       }
     }
     if ($cpanel_ftp_domain != '' && variable_get('cpanel_ftp_enabled', 0) && user_access('have FTP account', $user)) {
-      $ret = _cpanel_handle_request('/frontend/x/ftp/doaddftp.html', array('login' => $cpanel_username, 'password' => $edit['pass'], 'homedir' => variable_get('cpanel_ftp_subroot', '/') . $cpanel_username, 'quota' => variable_get('cpanel_ftp_quota', 2)));
+      $ret = _cpanel_handle_request('/frontend/x3/ftp/doaddftp.html', array('login' => $cpanel_username, 'password' => $edit['pass'], 'homedir' => variable_get('cpanel_ftp_subroot', '/') . $cpanel_username, 'quota' => variable_get('cpanel_ftp_quota', 2)));
       
       if (!$ret) {
         watchdog('user', t('Error creating cPanel FTP account <em>%username@%domain</em>', array('%username' => $cpanel_username,'%domain' => $cpanel_ftp_domain)), WATCHDOG_ERROR);
@@ -239,27 +246,28 @@ function cpanel_user($type, &$edit, &$us
       }
     }
   }
-  if ($type == 'update' && $account = user_load(array('uid' => $user->uid, 'status' => 1))) {  
+  if ($type == 'update' && $category == 'account' && $account = user_load(array('uid' => $user->uid, 'status' => 1))) {  
     if ($cpanel_mail_domain != '' && variable_get('cpanel_mail_enabled', 0) && user_access('have email account', $user)) {
         if (isset($account->cpanel_email) && $account->cpanel_email) {
           if ($edit['cpanel_email'] && $edit['pass'] != '') {
-            $ret = _cpanel_handle_request('/frontend/x/mail/dopasswdpop.html', array('email' => $cpanel_username, 'password' => $edit['pass'], 'domain' => $cpanel_mail_domain, 'quota' => variable_get('cpanel_mail_quota', 2)));
+            $ret = _cpanel_handle_request('/frontend/x3/mail/dopasswdpop.html', array('email' => $cpanel_username, 'password' => $edit['pass'], 'domain' => $cpanel_mail_domain, 'quota' => variable_get('cpanel_mail_quota', 2)));
             if (!$ret) {
               watchdog('user', t('Error updating password fo cPanel email account <em>%username@%domain</em>', array('%username' => $cpanel_username, '%domain' => $cpanel_mail_domain)), WATCHDOG_ERROR);
             } else {
               watchdog('user', t('Password updated for cPanel email account <em>%username@%domain</em> with password : %pass at %date' , array('%username' => $cpanel_username, '%domain' => $cpanel_mail_domain, '%pass' => $edit['pass'],'%date' => date("H:i:s"))), WATCHDOG_NOTICE);
             }
           } elseif (!$edit['cpanel_email']) {
-            $ret = _cpanel_handle_request('/frontend/x/mail/realdelpop.html', array('email' => $cpanel_username, 'domain' => $cpanel_mail_domain));
+            $ret = _cpanel_handle_request('/frontend/x3/mail/realdelpop.html', array('email' => $cpanel_username, 'domain' => $cpanel_mail_domain));
             if (!$ret) {
               watchdog('user', t('Error deleting cPanel email account <em>%username@%domain</em>', array('%username' => $cpanel_username, '%domain' => $cpanel_mail_domain)), WATCHDOG_ERROR);
             } else {
+              drupal_set_message(t('Deleted cPanel email account <em>%username@%domain</em>' , array('%username' => $cpanel_username, '%domain' => $cpanel_mail_domain)));
               watchdog('user', t('Deleted cPanel email account <em>%username@%domain</em>' , array('%username' => $cpanel_username, '%domain' => $cpanel_mail_domain)), WATCHDOG_NOTICE);            	
             }
           }
         } else {
           if ($edit['cpanel_email']) {
-            $ret = _cpanel_handle_request('/frontend/x/mail/doaddpop.html', array('email' => $cpanel_username, 'password' => $edit['pass'] == '' ? $user->name : $edit['pass'], 'domain' => $cpanel_mail_domain, 'quota' => variable_get('cpanel_mail_quota', 2)));
+            $ret = _cpanel_handle_request('/frontend/x3/mail/doaddpop.html', array('email' => $cpanel_username, 'password' => $edit['pass'] == '' ? $user->name : $edit['pass'], 'domain' => $cpanel_mail_domain, 'quota' => variable_get('cpanel_mail_quota', 2)));
             if (!$ret) {
               watchdog('user', t('Error creating cPanel email account <em>%username@%domain</em>', array('%username' => $cpanel_username, '%domain' => $cpanel_mail_domain)), WATCHDOG_ERROR);
             } else {
@@ -271,14 +279,14 @@ function cpanel_user($type, &$edit, &$us
     if ($cpanel_ftp_domain != '' && variable_get('cpanel_ftp_enabled', 0) && user_access('have FTP account', $user)) {
         if (isset($account->cpanel_ftp) && $account->cpanel_ftp) {
           if ($edit['cpanel_ftp'] && $edit['pass'] != '') {
-            $ret = _cpanel_handle_request('/frontend/x/ftp/dopasswdftp.html', array('acct' => $cpanel_username, 'password' => $edit['pass']));
+            $ret = _cpanel_handle_request('/frontend/x3/ftp/dopasswdftp.html', array('acct' => $cpanel_username, 'password' => $edit['pass']));
             if (!$ret) {
               watchdog('user', t('Error updating password fo cPanel FTP account <em>%username@%domain</em>', array('%username' => $cpanel_username, '%domain' => $cpanel_ftp_domain)), WATCHDOG_ERROR);
             } else {
               watchdog('user', t('Password updated for cPanel FTP account <em>%username@%domain</em> with password : %pass at %date' , array('%username' => $cpanel_username, '%domain' => $cpanel_ftp_domain, '%pass' => $edit['pass'],'%date' => date("H:i:s"))), WATCHDOG_NOTICE);
             }
           } elseif (!$edit['cpanel_ftp']) {
-            $ret = _cpanel_handle_request('/frontend/x/ftp/realdodelftp.html', array('login' => $cpanel_username));
+            $ret = _cpanel_handle_request('/frontend/x3/ftp/realdodelftp.html', array('login' => $cpanel_username));
             if (!$ret) {
               watchdog('user', t('Error deleting cPanel FTP account <em>%username@%domain</em>', array('%username' => $cpanel_username, '%domain' => $cpanel_ftp_domain)), WATCHDOG_ERROR);
             } else {
@@ -287,7 +295,7 @@ function cpanel_user($type, &$edit, &$us
           }
         } else {
           if ($edit['cpanel_ftp']) {
-            $ret = _cpanel_handle_request('/frontend/x/ftp/doaddftp.html', array('login' => $cpanel_username, 'password' => $edit['pass'] == '' ? $user->name : $edit['pass'], 'homedir' => variable_get('cpanel_ftp_subroot', '/') . $cpanel_username, 'quota' => variable_get('cpanel_ftp_quota', 2)));
+            $ret = _cpanel_handle_request('/frontend/x3/ftp/doaddftp.html', array('login' => $cpanel_username, 'password' => $edit['pass'] == '' ? $user->name : $edit['pass'], 'homedir' => variable_get('cpanel_ftp_subroot', '/') . $cpanel_username, 'quota' => variable_get('cpanel_ftp_quota', 2)));
             if (!$ret) {
               watchdog('user', t('Error creating cPanel FTP account <em>%username@%domain</em>', array('%username' => $cpanel_username, '%domain' => $cpanel_ftp_domain)), WATCHDOG_ERROR);
             } else {
@@ -300,7 +308,7 @@ function cpanel_user($type, &$edit, &$us
   if ($type == 'delete' && $account = user_load(array('uid' => $user->uid, 'status' => 1))) {
     if ($cpanel_mail_domain != '' && variable_get('cpanel_mail_enabled', 0) && user_access('have email account', $user)) {
       if (isset($account->cpanel_email) && $account->cpanel_email) {
-        $ret = _cpanel_handle_request('/frontend/x/mail/realdelpop.html', array('email' => $cpanel_username, 'domain' => $cpanel_mail_domain));
+        $ret = _cpanel_handle_request('/frontend/x3/mail/realdelpop.html', array('email' => $cpanel_username, 'domain' => $cpanel_mail_domain));
         if (!$ret) {
           watchdog('user', t('Error deleting cPanel email account <em>%username@%domain</em>', array('%username' => $cpanel_username, '%domain' => $cpanel_mail_domain)), WATCHDOG_ERROR);
         } else {
@@ -310,7 +318,7 @@ function cpanel_user($type, &$edit, &$us
     }
     if ($cpanel_ftp_domain != '' && variable_get('cpanel_ftp_enabled', 0) && user_access('have FTP account', $user)) {
       if (isset($account->cpanel_ftp) && $account->cpanel_ftp) {
-        $ret = _cpanel_handle_request('/frontend/x/ftp/realdodelftp.html', array('login' => $cpanel_username));
+        $ret = _cpanel_handle_request('/frontend/x3/ftp/realdodelftp.html', array('login' => $cpanel_username));
         if (!$ret) {
           watchdog('user', t('Error deleting cPanel FTP account <em>%username@%domain</em>', array('%username' => $cpanel_username, '%domain' => $cpanel_ftp_domain)), WATCHDOG_ERROR);
         } else {
@@ -348,7 +356,8 @@ function cpanel_admin() {
       break;
 
     default:
-      $output = cpanel_form_site($op);  
+      $output = cpanel_form_site($op);
+$output = drupal_get_form('cpanel_form_site', $op);	  
   }
   
   return $output;
@@ -446,8 +455,7 @@ function cpanel_form_site($op) {
       );
 
   }
-  $output = drupal_get_form('cpanel_page', $form);
-  return $output;  
+    return $form;  
 }
 
 /**
Only in cpanel/: cpanelbackup
