fixed get_instance()

This commit is contained in:
2026-01-12 17:30:36 +01:00
parent 079e276231
commit a182417ef7
3 changed files with 21 additions and 31 deletions
+8 -13
View File
@@ -10,10 +10,10 @@ class Down extends BaseCommand
protected $group = 'Housekeeping'; protected $group = 'Housekeeping';
protected $name = 'down'; protected $name = 'down';
protected $description = 'Put the application into maintenance mode.'; protected $description = 'Put the application into maintenance mode.';
protected $usage = 'down [options]'; protected $usage = 'down [--allow IP] [--message "text"]';
protected $options = [ protected $options = [
'--allow' => 'IP address(es) to whitelist (comma-separated or use multiple --allow)', 'allow' => 'IP address(es) to whitelist (comma-separated)',
'--message' => 'Custom message for the maintenance page', 'message' => 'Custom message for the maintenance page',
]; ];
public function run(array $params) public function run(array $params)
@@ -21,19 +21,14 @@ class Down extends BaseCommand
$allowedIps = []; $allowedIps = [];
// Get allowed IPs from command line // Get allowed IPs from command line
if (CLI::getOption('allow')) { $allow = CLI::getOption('allow');
$allow = CLI::getOption('allow'); if ($allow !== null && $allow !== false) {
if (is_array($allow)) { $allowedIps = array_map('trim', explode(',', (string) $allow));
foreach ($allow as $ip) {
$allowedIps = array_merge($allowedIps, array_map('trim', explode(',', $ip)));
}
} else {
$allowedIps = array_map('trim', explode(',', $allow));
}
} }
// Get custom message // Get custom message
$message = CLI::getOption('message') ?: ''; $message = CLI::getOption('message');
$message = ($message !== null && $message !== false) ? (string) $message : '';
// Create maintenance data // Create maintenance data
$data = [ $data = [
+12 -14
View File
@@ -8,7 +8,6 @@
class RequestPassword { class RequestPassword {
private $ci;
private $salt; private $salt;
private $user; private $user;
private $password; private $password;
@@ -18,12 +17,8 @@ class RequestPassword {
public function __construct( $user ) public function __construct( $user )
{ {
$this->ci =& get_instance();
$this->user = $user; $this->user = $user;
$this->ci->load->library( 'email' );
$this->handle(); $this->handle();
} }
@@ -87,18 +82,21 @@ class RequestPassword {
'password' => $this->password 'password' => $this->password
]; ];
$html = $this->ci->load->view( 'emails/requestpassword_email', ['user'=>$data], true ); $html = view('emails/requestpassword_email', ['user' => $data]);
$this->ci->email->from( 'noreply@dbois.nl', 'DBOIS' ); $email = \Config\Services::email();
$this->ci->email->to( $this->user->email ); $email->setFrom('noreply@dbois.nl', 'DBOIS');
$this->ci->email->subject( 'Nieuw wachtwoord DBOIS' ); $email->setTo($this->user->email);
$this->ci->email->message( $html ); $email->setSubject('Nieuw wachtwoord DBOIS');
$this->ci->email->set_mailtype("html"); $email->setMessage($html);
$this->ci->email->set_newline("\r\n"); $email->setMailType('html');
$email->setNewline("\r\n");
$this->sendResult = $this->ci->email->send(); $this->sendResult = $email->send();
if( ! $this->sendResult ) log_message( 'error', json_encode($this->ci->email->print_debugger())); if (! $this->sendResult) {
log_message('error', $email->printDebugger());
}
} }
} }
@@ -17,15 +17,12 @@ class InvoiceSpreadsheet {
private $invoiceSheet; private $invoiceSheet;
private $fullpathname; private $fullpathname;
private $filename; private $filename;
private $ci;
public function __construct( $invoiceReport ) public function __construct( $invoiceReport )
{ {
$this->ci =& get_instance();
$this->invoiceReport = $invoiceReport; $this->invoiceReport = $invoiceReport;
$this->ci->load->helper( 'download' ); helper('download');
$this->handle(); $this->handle();
} }