0) { // Include the WebsitePanel ES Class require_once(ROOTDIR . '/modules/servers/websitepanel/websitepanel.class.php'); require_once(ROOTDIR . '/modules/servers/websitepanel/websitepanel.functions.php'); // Retrieve the WebsitePanel Addons module settings $modSettings = websitepanel_sync_GetSettings(); $srvSettings = websitepanel_GetServerSettings(); if (empty($modSettings['serverhost']) || empty($modSettings['serverport']) || empty($srvSettings['username']) || empty($srvSettings['password'])) { // The module is disabled or has not yet been configured - stop return; } // Create the WebsitePanel object instance $wsp = new WebsitePanel($srvSettings['username'], $srvSettings['password'], $modSettings['serverhost'], $modSettings['serverport'], (($modSettings['serversecured']) == 'on' ? TRUE : FALSE)); // Get all WSP users with the old email $items = (array)$wsp->getUsersPagedRecursive(1, 'Email', $params['olddata']['email'], 0, 0, ''); // Load / parse the XML response $xml = simplexml_load_string($items['any']); $rootPath = $xml->NewDataSet; // Total number of elements to update $total = $rootPath->Table->Column1; // Begin updating WebsitePanel accounts for ($i = 0; $i < $total; $i++) { // Set the current root element and get the users details from WebsitePanel // We cannot use the details provided by the get_users_paged_recursive method as it does not return all the required elements to fully update the user $currentRoot = $rootPath->Table1->$i; $userDetails = (array)$wsp->getUserByUsername($currentRoot->Username); // Update the current user $wsp->updateUserDetails($userDetails['RoleId'], (($userDetails['RoleId'] == 2) ? 'Reseller' : 'User'), $userDetails['StatusId'], $userDetails['Status'], $userDetails['LoginStatusId'], $userDetails['LoginStatus'], $userDetails['FailedLogins'], $userDetails['UserId'], $userDetails['OwnerId'], $userDetails['Created'], $userDetails['Changed'], $userDetails['IsDemo'], $userDetails['IsPeer'], $currentRoot->Comments, $userDetails['Username'], $userDetails['Password'], $params['firstname'], $params['lastname'], $params['email'], $params['phonenumber'], $params['postcode'], '', '', '', '', $params['country'], $params['address1'] . (!empty($params['address2']) ? " {$params['address2']}" : ''), $params['city'], $params['state'], TRUE, $params['companyname'], (($userDetails['RoleId'] == 2) ? TRUE : FALSE)); // Add log entry to client log logactivity("WebsitePanel Sync - Account {$currentRoot->Username} contact details updated successfully", $params['userid']); } } } /* Update Client Contact Details - WebsitePanel */ add_hook('ClientEdit', 1, 'websitepanel_sync_ClientEdit'); /** * websitepanel_addons_GetSettings * * @access public * @return array */ function websitepanel_sync_GetSettings() { $settings = array(); // Retrieve the settings from the modules configuration table $results = select_query('tbladdonmodules', 'setting,value', array('module' => 'websitepanel_sync')); while (($row = mysql_fetch_array($results)) != false) { $settings[$row['setting']] = $row['value']; } return $settings; }