Skip to content

Commit b8b56ce

Browse files
authored
Merge pull request #39 from eruzavin/WHMCS8-support
FEATURE SVM-3051 WHMCS8 support
2 parents fc49808 + a06cbbc commit b8b56ce

3 files changed

Lines changed: 26 additions & 7 deletions

File tree

modules/servers/solusvmpro/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.1.1
1+
4.1.2

modules/servers/solusvmpro/lib/SolusVM.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
use SolusVM\Curl;
66
use Illuminate\Database\Capsule\Manager as Capsule;
7-
7+
use Illuminate\Support\Collection as Collection;
8+
use Exception;
89

910
class SolusVM {
1011
protected $url;
@@ -975,7 +976,7 @@ public static function getParamsFromServiceID( $servid, $uid = null ) {
975976

976977
public static function getParamsFromVserviceID( $vserverid, $uid ) {
977978
/** @var stdClass $hosting */
978-
foreach ( Capsule::table( 'tblhosting' )->where( 'userid', $uid )->get() as $hosting ) {
979+
foreach ( SolusVM::collectionToArray(Capsule::table( 'tblhosting' )->where( 'userid', $uid )->get()) as $hosting ) {
979980

980981
$vserverFieldRow = Capsule::table( 'tblcustomfields' )->where( 'relid', $hosting->packageid )->where( 'fieldname', 'vserverid' )->first();
981982
if ( ! $vserverFieldRow ) {
@@ -1091,5 +1092,22 @@ public function isSuccessResponse( $result ) {
10911092
$this->debugLog( 'solusvmpro', 'isSuccessResponse', '', $result, '', array() );
10921093
return false;
10931094
}
1095+
1096+
/**
1097+
* Converts Collection to array if required
1098+
*
1099+
* @param array|Collection|any $object arbitrary object.
1100+
*
1101+
* @return array
1102+
*/
1103+
public function collectionToArray($object) {
1104+
if (is_array($object)) {
1105+
return $object;
1106+
}
1107+
if ($object instanceof Collection) {
1108+
return $object->toArray();
1109+
}
1110+
throw new Exception('Object is not an array or Illuminate\Support\Collection');
1111+
}
10941112
}
10951113

modules/servers/solusvmpro/solusvmpro.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
function initConfigOption()
2626
{
2727
if(!isset($_POST['id'])){
28-
$data = Capsule::table('tblproducts')->where('servertype', 'solusvmpro')->where('id', $_GET['id'])->get();
28+
$data = SolusVM::collectionToArray(Capsule::table('tblproducts')->where('servertype', 'solusvmpro')->where('id', $_GET['id'])->get());
2929
}else{
30-
$data = Capsule::table('tblproducts')->where('servertype', 'solusvmpro')->where('id', $_POST['id'])->get();
30+
$data = SolusVM::collectionToArray(Capsule::table('tblproducts')->where('servertype', 'solusvmpro')->where('id', $_POST['id'])->get());
3131
}
32+
3233
$packageconfigoption = [];
3334
if(is_array($data) && count($data) > 0) {
3435
$packageconfigoption[1] = $data[0]->configoption1;
@@ -47,7 +48,7 @@ function solusvmpro_ConfigOptions() {
4748

4849
$master_array = array();
4950
/** @var stdClass $row */
50-
foreach ( Capsule::table( 'tblservers' )->where( 'type', 'solusvmpro' )->get() as $row ) {
51+
foreach ( SolusVM::collectionToArray(Capsule::table( 'tblservers' )->where( 'type', 'solusvmpro' )->get()) as $row ) {
5152
$master_array[] = $row->id . " - " . $row->name;
5253
}
5354

@@ -724,7 +725,7 @@ function solusvmpro_ChangePackage( $params ) {
724725

725726
if ( $cextraip > 0 ){
726727
//first() function doesn't work
727-
$ipaddresses = Capsule::table('tblhosting')->select('assignedips')->where( 'id', $params['serviceid'] )->get();
728+
$ipaddresses = SolusVM::collectionToArray(Capsule::table('tblhosting')->select('assignedips')->where( 'id', $params['serviceid'] )->get());
728729
$ips = $ipaddresses[0]->assignedips;
729730

730731
$lines_arr = explode(PHP_EOL, $ips);

0 commit comments

Comments
 (0)