Skip to content

Commit

Permalink
updated ictcore php 7.4.33 -v
Browse files Browse the repository at this point in the history
  • Loading branch information
ICTKashif committed Sep 6, 2023
1 parent 0e4e6ff commit b99df96
Show file tree
Hide file tree
Showing 98 changed files with 220 additions and 217 deletions.
142 changes: 72 additions & 70 deletions core/Account.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ public function __construct($account_id = NULL)
$this->_load();
}
}

public function set($data)
{
foreach ($data as $field => $value) {
if (property_exists($this, $field)) {
$this->$field = $value;
//
public function set($data) {
foreach ($data as $field => $value) {
// Only set the property if it exists in the Contact object
if (property_exists($this, $field)) {
$this->$field = $value;
}
}
}
}
public static function search($aFilter = array())
{
Expand Down Expand Up @@ -204,73 +204,75 @@ public static function search($aFilter = array())

return $aAccount;
}
public static function getClass(&$account_id, $namespace = 'ICT\\Core\\Account')
{
$account_type = ''; // Initialize the variable here
if (ctype_digit(trim($account_id))) {
$query = "SELECT type FROM " . self::$table . " WHERE account_id='%account_id%' ";
$result = DB::query(self::$table, $query, array('account_id' => $account_id));
if (is_resource($result)) {
$account_type = mysqli_result($result, 0);
}
} else {
$account_type = $account_id;
$account_id = null;
}
// The rest of the code remains unchanged
$class_name = ucfirst(strtolower(trim($account_type)));
if (!empty($namespace)) {
$class_name = $namespace . '\\' . $class_name;
}
if (class_exists($class_name, true)) {
return $class_name;
} else {
return false;
}
}

public static function load($account_id)
{
if ($account_id < 0) {
return new self($account_id);
}
$class_name = self::getClass($account_id);
if ($class_name) {
Corelog::log("Creating instance of : $class_name for account: $account_id", Corelog::CRUD);
return new $class_name($account_id);
} else {
Corelog::log("$class_name class not found, Creating instance of : Account", Corelog::CRUD);
return new self($account_id);
}
}
public static function getClass(&$account_id, $namespace = 'ICT\\Core\\Account')
{
$account_type = ''; // Initialize the variable here
if (ctype_digit(trim($account_id))) {
$query = "SELECT type FROM " . self::$table . " WHERE account_id='%account_id%' ";
$result = DB::query(self::$table, $query, array('account_id' => $account_id));
if (is_resource($result)) {
$account_type = mysqli_result($result, 0);
}
} else {
$account_type = $account_id;
$account_id = null;
}
// The rest of the code remains unchanged
$class_name = ucfirst(strtolower(trim($account_type)));
if (!empty($namespace)) {
$class_name = $namespace . '\\' . $class_name;
}
if (class_exists($class_name, true)) {
return $class_name;
} else {
return false;
}
}

public static function load($account_id)
{
if ($account_id < 0) {
return new self($account_id);
}
$class_name = self::getClass($account_id);
if ($class_name) {
Corelog::log("Creating instance of : $class_name for account: $account_id", Corelog::CRUD);
return new $class_name($account_id);
} else {
Corelog::log("$class_name class not found, Creating instance of : Account", Corelog::CRUD);
return new self($account_id);
}
}

protected function _load()
{
Corelog::log("Loading account: $this->account_id", Corelog::CRUD);
$query = "SELECT * FROM " . self::$table . " WHERE account_id='%account_id%' ";
$result = DB::query(self::$table, $query, array('account_id' => $this->account_id));
$data = mysqli_fetch_assoc($result);
if ($data) {
$this->account_id = $data['account_id'];
$this->type = $data['type'];
$this->username = $data['username'];
$this->passwd = $data['passwd'];
$this->passwd_pin = $data['passwd_pin'];
$this->first_name = $data['first_name'];
$this->last_name = $data['last_name'];
$this->phone = $data['phone'];
$this->email = $data['email'];
$this->address = $data['address'];
$this->settings = json_decode($data['settings'], true);
$this->active = $data['active'];
$this->user_id = $data['created_by'];
if (!is_array($this->settings)) {
$this->settings = array();
protected function _load()
{
Corelog::log("Loading account: $this->account_id", Corelog::CRUD);
$query = "SELECT * FROM " . self::$table . " WHERE account_id='%account_id%' ";
$result = DB::query(self::$table, $query, array('account_id' => $this->account_id));
$data = mysqli_fetch_assoc($result);
if ($data) {
$this->account_id = $data['account_id'];
$this->type = $data['type'];
$this->username = $data['username'];
$this->passwd = $data['passwd'];
$this->passwd_pin = $data['passwd_pin'];
$this->first_name = $data['first_name'];
$this->last_name = $data['last_name'];
$this->phone = $data['phone'];
$this->email = $data['email'];
$this->address = $data['address'];
$this->settings = json_decode($data['settings'], true);
$this->active = $data['active'];
$this->user_id = $data['created_by'];

if (!is_array($this->settings)) {
$this->settings = array();
}
} else {
throw new CoreException('404', 'Account not found');
}
} else {
throw new CoreException('404', 'Account not found');
}
}

public function delete()
{
Expand Down
Empty file modified core/Account/Did.php
100644 → 100755
Empty file.
Empty file modified core/Account/Extension.php
100644 → 100755
Empty file.
Empty file modified core/Account/eaddress.php
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions core/Action.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static function search($application_id)
$aAction = array();
$query = "SELECT action_id FROM " . self::$table . " WHERE application_id='%application_id%' ";
$result = DB::query(self::$table, $query, array('application_id' => $application_id));
while ($data = mysqli_fetch_assoc($result)) {
while ($data = mysqli_fetch_assoc($result)) {
$aAction[] = $data;
}
Corelog::log("Search actions for application: $application_id", Corelog::DEBUG, $aAction);
Expand All @@ -95,7 +95,7 @@ protected function _load()
Corelog::log("Loading action: $this->action_id", Corelog::DEBUG);
$query = "SELECT * FROM " . self::$table . " WHERE action_id='%action_id%' ";
$result = DB::query(self::$table, $query, array('action_id' => $this->action_id));
$data = mysqli_fetch_assoc($result);
$data = mysqli_fetch_assoc($result);
$this->action_id = $data['action_id'];
$this->type = $data['type'];
$this->action = $data['action'];
Expand Down
18 changes: 10 additions & 8 deletions core/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function authenticate($credentials, $auth_type)
{
try {
$oUser = User::authenticate($credentials, $auth_type);

if ($oUser instanceof User) {
do_login($oUser);
return true;
Expand All @@ -46,16 +47,17 @@ protected function _authorize($permission)
return true;
}

protected function set($oEntity, $data)
{
foreach ($data as $key => $value) {
try {
$oEntity->$key = $value;
} catch (CoreException $ex) {
throw new CoreException(412, 'Data validation failed, for ' . $key, $ex);
protected function set($oEntity, $data)
{
exit;
foreach ($data as $key => $value) {
try {
$oEntity->$key = $value;
} catch (CoreException $ex) {
throw new CoreException(412, 'Data validation failed, for ' . $key, $ex);
}
}
}
}
public function create_interface($interface_type = null, $root_path = null)
{
global $path_cache;
Expand Down
10 changes: 5 additions & 5 deletions core/Api/Account/DidApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ class DidApi extends AccountApi
* @url POST /dids
*/
public function create($data = array(), $account_id = null)
{
$data['type'] = 'did';
return parent::create($data);
}

{
$data['type'] = 'did';
return parent::create($data);
}
/**
* List all available accounts
*
Expand Down
12 changes: 6 additions & 6 deletions core/Api/Account/ExtensionApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ class ExtensionApi extends AccountApi
*
* @url POST /extensions
*/
public function create($data = array(), $account_id = null)
{
$data['type'] = 'extension';
return parent::create($data);
}

public function create($data = array(), $account_id = null)
{
$data['type'] = 'extension';
return parent::create($data);
}
/**
* List all available accounts
*
Expand Down
72 changes: 36 additions & 36 deletions core/Api/AccountApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,27 @@ class AccountApi extends Api
*
* @url POST /accounts
*/
public function create($data = array(), $account_id = null)
{
$this->_authorize('account_create');

if (isset($data['type']) && !empty($data['type'])) {
$oAccount = Account::load($data['type']);
} else {
$oAccount = new Account();
}
$aSetting = $oAccount->settings;
$oAccount = new Account();
$oAccount->account_id = $account_id;
$oAccount->set($data);
if (isset($data['settings']) && !empty($data['settings'])) {
$oAccount->settings = array_merge($aSetting, $oAccount->settings);
}
if ($oAccount->save()) {
return $oAccount->account_id;
} else {
throw new CoreException(417, 'Account creation failed');
}
public function create($data = array(), $account_id = null)
{
$this->_authorize('account_create');
if (isset($data['type']) && !empty($data['type'])) {
$oAccount = Account::load($data['type']);
} else {
$oAccount = new Account();
}
$aSetting = $oAccount->settings;
$oAccount = new Account();
$oAccount->account_id = $account_id;
$oAccount->set($data);
if (isset($data['settings']) && !empty($data['settings'])) {
$oAccount->settings = array_merge($aSetting, $oAccount->settings);
}
if ($oAccount->save()) {
return $oAccount->account_id;
} else {
throw new CoreException(417, 'Account creation failed');
}
}

/**
Expand Down Expand Up @@ -108,23 +108,23 @@ public function provisioning($account_id)
*
* @url PUT /accounts/$account_id
*/
public function update($account_id, $data = array())
{
$this->_authorize('account_update');
public function update($account_id, $data = array())
{
$this->_authorize('account_update');

$oAccount = Account::load($account_id);
$aSetting = $oAccount->settings;
$oAccount->account_id = $account_id;
$oAccount->set($data);
if (isset($data['settings']) && !empty($data['settings'])) {
$oAccount->settings = array_merge($aSetting, $oAccount->settings);
}
if ($oAccount->save()) {
return $oAccount;
} else {
throw new CoreException(417, 'Account update failed');
$oAccount = Account::load($account_id);
$aSetting = $oAccount->settings;
$oAccount->account_id = $account_id;
$oAccount->set($data);
if (isset($data['settings']) && !empty($data['settings'])) {
$oAccount->settings = array_merge($aSetting, $oAccount->settings);
}
if ($oAccount->save()) {
return $oAccount;
} else {
throw new CoreException(417, 'Account update failed');
}
}
}

/**
* Delete a account
Expand Down
Empty file modified core/Api/Authenticate.php
100644 → 100755
Empty file.
Empty file modified core/Api/CampaignApi.php
100644 → 100755
Empty file.
Empty file modified core/Api/CoreApi.php
100644 → 100755
Empty file.
Empty file modified core/Api/GroupApi.php
100644 → 100755
Empty file.
42 changes: 20 additions & 22 deletions core/Api/ProgramApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,27 @@ class ProgramApi extends Api
* @url POST /programs
* @url POST /programs/$program_name
*/
public function create($program_name = null, $data = array())
{
$this->_authorize('program_create');
$oProgram = Program::load($program_name);
$oProgram->program_id = $program_name;
if (isset($data['name'])) {
$oProgram->name = $data['name'];
}
if (isset($data['type'])) {
$oProgram->type = $data['type'];
}
$oProgram->set($data); // This line is causing the error
$this->set($oProgram, $data);
if ($oProgram->save()) {
$oProgram->deploy();
return $oProgram->program_id;
} else {
throw new CoreException(417, 'Program creation failed');
}
}

public function create($program_name = null, $data = array())
{
$this->_authorize('program_create');
$oProgram = Program::load($program_name);
$oProgram->program_id = $program_name;
if (isset($data['name'])) {
$oProgram->name = $data['name'];
}
if (isset($data['type'])) {
$oProgram->type = $data['type'];
}
$oProgram->set($data); // This line is causing the error
$this->set($oProgram, $data);
if ($oProgram->save()) {
$oProgram->deploy();
return $oProgram->program_id;
} else {
throw new CoreException(417, 'Program creation failed');
}
}
/**
* Initiate a new transmission for given program
*
Expand Down Expand Up @@ -127,7 +127,6 @@ public function update($program_id, $data = array())
throw new CoreException(417, 'Program update failed');
}
}

/**
* Remove a program
*
Expand All @@ -144,5 +143,4 @@ public function remove($program_id)
throw new CoreException(417, 'Program delete failed');
}
}

}
Loading

0 comments on commit b99df96

Please sign in to comment.