|
|
@@ -69,8 +69,6 @@ function seafile_ConfigOptions() {
|
|
|
*/
|
|
|
function seafile_TestConnection($params) {
|
|
|
$seafileURL = $params['serverhttpprefix'] . '://' . $params['serverhostname'] . ':' . $params['serverport'];
|
|
|
- error_log("Seafile:TestConnection: " . $seafileURL);
|
|
|
- //error_log(" -> " . $params['serverusername'] . " " . $params['serverpassword']);
|
|
|
$seafileAPI = new Sf_Admin($seafileURL,$params['serverusername'],$params['serverpassword']);
|
|
|
$response = $seafileAPI->login();
|
|
|
if (isset($response['error_msg'])) {
|
|
|
@@ -123,7 +121,6 @@ function seafile_UsageUpdate($params) {
|
|
|
foreach((array)$servicesObj as $serviceObj) {
|
|
|
$service = get_object_vars($serviceObj[0]);
|
|
|
$accountInfo = $seafileAPI->getAccount($service['username']);
|
|
|
- error_log("Seafile Module: Updating Disk Usage for: " . $accountInfo . " : " . round($accountInfo['quota_usage'] / 1000000,2) . "/" . round($accountInfo['quota_total'] / 1000000,2));
|
|
|
if(!isset($accountInfo['error_msg'])) {
|
|
|
try {
|
|
|
Capsule::table('tblhosting')
|
|
|
@@ -131,7 +128,7 @@ function seafile_UsageUpdate($params) {
|
|
|
->update(
|
|
|
array(
|
|
|
'diskusage' => round($accountInfo['quota_usage'] / 1000000,2),
|
|
|
- 'disklimit' => round($accountInfo['quota_total'] / 1000000,2),
|
|
|
+ 'disklimit' => round($accountInfo['quota_total'],2),
|
|
|
'lastupdate' => Capsule::raw('now()')
|
|
|
)
|
|
|
);
|
|
|
@@ -188,26 +185,41 @@ function seafile_ClientArea($params) {
|
|
|
$seafileURL = $params['serverhttpprefix'] . '://' . $params['serverhostname'] . ':' . $params['serverport'];
|
|
|
break;
|
|
|
};
|
|
|
- $clientInfo['basequota'] = $params['configoption1'] ? $params['configoption1'] : 1;
|
|
|
- $clientInfo['addonquota'] = $params['configoptions']['addonQuota'] ? $params['configoptions']['addonQuota'] : 0;
|
|
|
- $clientInfo['userquota'] = $clientInfo['basequota'] + $clientInfo['addonquota'];
|
|
|
- $clientInfo['mailaddress'] = $params['username'];
|
|
|
- $clientInfo['webmailurl'] = $seafileURL;
|
|
|
- $clientInfo['zimbraserver'] = parse_url($clientInfo['webmailurl'], PHP_URL_HOST);
|
|
|
- $clientinfo['url'] = $seafileURL;
|
|
|
- $clientinfo['user'] = $user;
|
|
|
- $clientinfo['mobile1'] = $app;
|
|
|
- $clientinfo['mobile2'] = $google;
|
|
|
- $clientinfo['winclient'] = $winClient;
|
|
|
- $clientinfo['macclient'] = $macClient;
|
|
|
- $clientinfo['linClient'] = $linClient;
|
|
|
- $clientinfo['stitle'] = $params['model']['product']['name'];
|
|
|
+ $user = $params['username'];
|
|
|
|
|
|
+ $app = 'https://itunes.apple.com/cn/app/seafile-pro/id639202512?l=en&mt=8';
|
|
|
+ $google = 'https://play.google.com/store/apps/details?id=com.seafile.seadroid2';
|
|
|
+ $driveWin = 'https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seadrive-2.0.5-en.msi';
|
|
|
+ $winClient = 'https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-7.0.9-en.msi';
|
|
|
+ $macClient = 'https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-client-7.0.9.dmg';
|
|
|
+ $driveMac = 'https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seadrive-2.0.5.dmg';
|
|
|
+ $linClient = 'https://download.seafile.com/published/seafile-user-manual/syncing_client/install_linux_client.md';
|
|
|
|
|
|
- return array(
|
|
|
- 'tabOverviewReplacementTemplate' => 'clientarea',
|
|
|
- 'vars' => $clientInfo,
|
|
|
- );
|
|
|
+ $langObj = Capsule::table('tblconfiguration')
|
|
|
+ ->select('value')
|
|
|
+ ->where('setting', '=', 'Language')
|
|
|
+ ->get();
|
|
|
+ $lla = $_SESSION['Language'] ? trim($_SESSION['Language']) : strtolower($langObj[0]->value);
|
|
|
+ $slang = array();
|
|
|
+ include_once dirname(__FILE__).'/lang/'.$lla.'.php';
|
|
|
+ return array(
|
|
|
+ 'templatefile' => 'clientside',
|
|
|
+ 'vars' => array_merge(
|
|
|
+ array(
|
|
|
+ 'url' => $seafileURL,
|
|
|
+ 'user' => $user,
|
|
|
+ 'mobile1' => $app,
|
|
|
+ 'mobile2' => $google,
|
|
|
+ 'drivewin' => $driveWin,
|
|
|
+ 'winclient' => $winClient,
|
|
|
+ 'macclient' => $macClient,
|
|
|
+ 'drivemac' => $driveMac,
|
|
|
+ 'linClient' => $linClient,
|
|
|
+ ),
|
|
|
+ $slang,
|
|
|
+ $params
|
|
|
+ ),
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -286,10 +298,9 @@ function seafile_ChangePassword($params) {
|
|
|
* @return string 'success' or an error message
|
|
|
*/
|
|
|
function seafile_ChangePackage($params) {
|
|
|
- $quota = $params['configoption1'] ? $params['configoption1'] : 1;
|
|
|
- $addonQuota = $params['configoptions']['addonQuota'] ? $params['configoptions']['addonQuota'] : 0;
|
|
|
- $newAddQuota = $params['configoptions']['newAddQuota'] ? $params['configoptions']['newAddQuota'] : 0;
|
|
|
- $accountQuota = ($quota + $addonQuota + $newAddQuota);
|
|
|
+ $addonQuota = $params['configoptions']['addonQuota'];
|
|
|
+ $quota = $params['configoption1'] ? $params['configoption1'] : 1;
|
|
|
+ $accountQuota = ($quota + $addonQuota) * 1000;
|
|
|
$seafileURL = $params['serverhttpprefix'] . '://' . $params['serverhostname'] . ':' . $params['serverport'];
|
|
|
$seafileAPI = new Sf_Admin($seafileURL,$params['serverusername'],$params['serverpassword']);
|
|
|
$response = $seafileAPI->login();
|
|
|
@@ -314,7 +325,7 @@ function seafile_ChangePackage($params) {
|
|
|
);
|
|
|
return 'Error: could not find account ' . $params['username'];
|
|
|
}
|
|
|
- $result = $seafileAPI->modifyAccount(array('email' => $userAccount['email'], 'quota_total' => $accountQuota * 1024));
|
|
|
+ $result = $seafileAPI->modifyAccount(array('email' => $userAccount['email'], 'quota_total' => $accountQuota));
|
|
|
if(isset($result['error_msg'])) {
|
|
|
logModuleCall(
|
|
|
'seafile',
|
|
|
@@ -324,7 +335,7 @@ function seafile_ChangePackage($params) {
|
|
|
$result
|
|
|
);
|
|
|
return 'Error: could not update quota for ' . $userAccount['email'];
|
|
|
- } elseif ($result['quota_total'] != ($accountQuota * 1048576)) {
|
|
|
+ } elseif ($result['quota_total'] != ($accountQuota * 1000000)) {
|
|
|
logModuleCall(
|
|
|
'seafile',
|
|
|
__FUNCTION__,
|
|
|
@@ -339,7 +350,7 @@ function seafile_ChangePackage($params) {
|
|
|
->where('id', '=', $params['serviceid'])
|
|
|
->update(
|
|
|
array(
|
|
|
- 'disklimit' => $userAccount['quota_total'] / 1024,
|
|
|
+ 'disklimit' => $userAccount['quota_total'],
|
|
|
)
|
|
|
);
|
|
|
} catch (Exception $e) {
|
|
|
@@ -352,10 +363,7 @@ function seafile_ChangePackage($params) {
|
|
|
);
|
|
|
return 'Error: could not update quota in database';
|
|
|
}
|
|
|
- if(seafileUpdateQuota($params) != 'success') {
|
|
|
- return 'Error: could not update addonQuota in database';
|
|
|
- };
|
|
|
- return 'success';
|
|
|
+ return 'success';
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -378,13 +386,9 @@ function seafile_CreateAccount($params) {
|
|
|
$firstName = $params['customfields']['firstname'];
|
|
|
$lastName = $params['customfields']['lastname'];
|
|
|
$loginEMail = $params['customfields']['login'];
|
|
|
- $loginPassword = $params['customfields']['password'];
|
|
|
- $baseQuota = $params['configoption1'];
|
|
|
- $addonQuota = $params['configoptions']['addonQuota'] ? $params['configoptions']['addonQuota'] : 0;
|
|
|
- $newAddQuota = $params['configoptions']['newAddQuota'] ? $params['configoptions']['newAddQuota'] : 0;
|
|
|
-
|
|
|
- //error_log( print_r($params,true) );
|
|
|
-
|
|
|
+ $loginPassword = $params['customfields']['password'];
|
|
|
+ $addonQuota = $params['configoptions']['addonQuota'];
|
|
|
+ $quota = $params['configoption1'] ? $params['configoption1'] : 1;
|
|
|
$seafileURL = $params['serverhttpprefix'] . '://' . $params['serverhostname'] . ':' . $params['serverport'];
|
|
|
$seafileAPI = new Sf_Admin($seafileURL,$params['serverusername'],$params['serverpassword']);
|
|
|
$response = $seafileAPI->login();
|
|
|
@@ -402,7 +406,7 @@ function seafile_CreateAccount($params) {
|
|
|
if(!isset($existingAccount['error_msg'])) {
|
|
|
return 'Error: account already exists ' . $loginEMail;
|
|
|
}
|
|
|
- $accountQuota = ($baseQuota + $addonQuota + $newAddQuota) * 1024;
|
|
|
+ $accountQuota = ($quota + $addonQuota) * 1000;
|
|
|
$newAccount = array();
|
|
|
$newAccount['email'] = $loginEMail;
|
|
|
$newAccount['name'] = $firstName . ' ' . $lastName;
|
|
|
@@ -411,7 +415,6 @@ function seafile_CreateAccount($params) {
|
|
|
$newAccount['password'] = $loginPassword;
|
|
|
$newAccount['note'] = 'Account created from WHCMS for client ' . $params['userid'];
|
|
|
$newAccount['quota_total'] = $accountQuota;
|
|
|
- error_log("Seafile:Create Account for " . $loginEMail . " with " . $accountQuota . "MB");
|
|
|
$result = $seafileAPI->createAccount($newAccount);
|
|
|
if(isset($result['error_msg'])) {
|
|
|
logModuleCall(
|
|
|
@@ -423,31 +426,25 @@ function seafile_CreateAccount($params) {
|
|
|
);
|
|
|
return 'Error: could not create account ' . $loginEMail;
|
|
|
}
|
|
|
- try {
|
|
|
- Capsule::table('tblhosting')
|
|
|
- ->where('id', '=', $params['serviceid'])
|
|
|
- ->update(
|
|
|
- array(
|
|
|
- 'username' => $loginEMail,
|
|
|
- 'password' => $params['customfields']['password'],
|
|
|
- 'disklimit' => $accountQuota,
|
|
|
- 'diskusage' => 0,
|
|
|
- 'domain' => $loginEMail,
|
|
|
- )
|
|
|
- );
|
|
|
- } catch (\Exception $e) {
|
|
|
- logModuleCall(
|
|
|
- 'seafile',
|
|
|
- __FUNCTION__,
|
|
|
- $params,
|
|
|
- 'Error: could save username & password in database',
|
|
|
- $e->getMessage()
|
|
|
- );
|
|
|
- return 'Error: could save username & password in database';
|
|
|
- }
|
|
|
- if(seafileUpdateQuota($params) != 'success') {
|
|
|
- return 'Error: could not update addonQuota in database';
|
|
|
- };
|
|
|
+ try {
|
|
|
+ Capsule::table('tblhosting')
|
|
|
+ ->where('id', '=', $params['serviceid'])
|
|
|
+ ->update(
|
|
|
+ array(
|
|
|
+ 'username' => $loginEMail,
|
|
|
+ 'password' => $params['customfields']['password'],
|
|
|
+ )
|
|
|
+ );
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ logModuleCall(
|
|
|
+ 'seafile',
|
|
|
+ __FUNCTION__,
|
|
|
+ $params,
|
|
|
+ 'Error: could save username & password in database',
|
|
|
+ $e->getMessage()
|
|
|
+ );
|
|
|
+ return 'Error: could save username & password in database';
|
|
|
+ }
|
|
|
return 'success';
|
|
|
}
|
|
|
|
|
|
@@ -611,9 +608,9 @@ function seafile_TerminateAccount($params) {
|
|
|
);
|
|
|
return 'Error: could not find account ' . $params['username'];
|
|
|
}
|
|
|
- //if ($existingAccount['is_active'] == 1) {
|
|
|
- // return 'Account '. $params['username'] . ' is active, suspend account first!';
|
|
|
- //}
|
|
|
+ if ($existingAccount['is_active'] == 1) {
|
|
|
+ return 'Account '. $params['username'] . ' is active, suspend account first!';
|
|
|
+ }
|
|
|
$result = $seafileAPI->deleteAccount($params['username']);
|
|
|
if($result != true) {
|
|
|
logModuleCall(
|
|
|
@@ -660,80 +657,4 @@ function seafileCheckPassword($pwd) {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
-/**
|
|
|
- * Perform an update of customfields to prevent downgrades.
|
|
|
- *
|
|
|
- * Called in changePackage or createAccount functions.
|
|
|
- *
|
|
|
- * @param array $params common module parameters
|
|
|
- *
|
|
|
- * @return *success* or an error
|
|
|
- */
|
|
|
-function seafileUpdateQuota($params) {
|
|
|
- if(isset($params['configoptions']['addonQuota'])) {
|
|
|
- $addonQuota = $params['configoptions']['addonQuota'] ? $params['configoptions']['addonQuota'] : 0 ;
|
|
|
- $newAddQuota = $params['configoptions']['newAddQuota'] ? $params['configoptions']['newAddQuota'] : 0;
|
|
|
- $addonQuota = $addonQuota + $newAddQuota;
|
|
|
- $addonQuotaFieldIDObj = Capsule::table('tblproductconfigoptions')
|
|
|
- ->join('tblhostingconfigoptions', 'tblproductconfigoptions.id', '=', 'tblhostingconfigoptions.configid')
|
|
|
- ->where('tblhostingconfigoptions.relid', '=', $params['serviceid'])
|
|
|
- ->where('tblproductconfigoptions.optionname', 'like', 'addonQuota%')
|
|
|
- ->select('tblhostingconfigoptions.id', 'tblproductconfigoptions.qtymaximum')
|
|
|
- ->get();
|
|
|
- if($addonQuota > $addonQuotaFieldIDObj[0]->qtymaximum) {
|
|
|
- logModuleCall(
|
|
|
- 'seafile',
|
|
|
- __FUNCTION__,
|
|
|
- $params,
|
|
|
- 'Info: someone is trying to exceed the maximum size',
|
|
|
- ''
|
|
|
- );
|
|
|
- $addonQuota = $addonQuotaFieldIDObj[0]->qtymaximum;
|
|
|
- }
|
|
|
- try {
|
|
|
- $updateAddonQuota = Capsule::table('tblhostingconfigoptions')
|
|
|
- ->where('id', $addonQuotaFieldIDObj[0]->id)
|
|
|
- ->update(
|
|
|
- [
|
|
|
- 'qty' => $addonQuota,
|
|
|
- ]
|
|
|
- );
|
|
|
- } catch (\Exception $e) {
|
|
|
- logModuleCall(
|
|
|
- 'seafile',
|
|
|
- __FUNCTION__,
|
|
|
- $updateAddonQuota,
|
|
|
- 'Error: could not save addonOuota in database.',
|
|
|
- $e->getMessage()
|
|
|
- );
|
|
|
- return 'Error: could not save addonOuota in database.';
|
|
|
- }
|
|
|
- $newAddQuotaFieldIDObj = Capsule::table('tblproductconfigoptions')
|
|
|
- ->join('tblhostingconfigoptions', 'tblproductconfigoptions.id', '=', 'tblhostingconfigoptions.configid')
|
|
|
- ->where('tblhostingconfigoptions.relid', '=', $params['serviceid'])
|
|
|
- ->where('tblproductconfigoptions.optionname', 'like', 'newAddQuota%')
|
|
|
- ->select('tblhostingconfigoptions.id')
|
|
|
- ->get();
|
|
|
- try {
|
|
|
- $updateNewAddQuota = Capsule::table('tblhostingconfigoptions')
|
|
|
- ->where('id', $newAddQuotaFieldIDObj[0]->id)
|
|
|
- ->update(
|
|
|
- [
|
|
|
- 'qty' => '0',
|
|
|
- ]
|
|
|
- );
|
|
|
- } catch (\Exception $e) {
|
|
|
- logModuleCall(
|
|
|
- 'seafile',
|
|
|
- __FUNCTION__,
|
|
|
- $updateNewAddQuota,
|
|
|
- 'Error: could not reset newAddOuota in database.',
|
|
|
- $e->getMessage()
|
|
|
- );
|
|
|
- return 'Error: could not reset newAddOuota in database.';
|
|
|
- }
|
|
|
- }
|
|
|
- return 'success';
|
|
|
-}
|
|
|
?>
|