$container['history'] = function ($c) {
- return new Galette\Core\History($c->get('zdb'), $c->get('login'));
+ return new Galette\Core\History($c->get('zdb'), $c->get('login'), $c->get('preferences'));
};
$container['acls'] = function ($c) {
) {
$mailing = $this->session->mailing;
} elseif (isset($get['from']) && is_numeric($get['from'])) {
- $mailing = new Mailing($this->preferences, null, $get['from']);
+ $mailing = new Mailing($this->preferences, [], (int)$get['from']);
MailingHistory::loadFrom($this->zdb, (int)$get['from'], $mailing);
} elseif (isset($get['reminder'])) {
//FIXME: use a constant!
$filters->filter_account = Members::ACTIVE_ACCOUNT;
$m = new Members($filters);
$members = $m->getList(true);
- $mailing = new Mailing($this->preferences, ($members !== false) ? $members : null);
+ $mailing = new Mailing($this->preferences, ($members !== false) ? $members : []);
} else {
if (
count($filters->selected) == 0
}
$m = new Members();
$members = $m->getArrayList($filters->selected);
- $mailing = new Mailing($this->preferences, ($members !== false) ? $members : null);
+ $mailing = new Mailing($this->preferences, ($members !== false) ? $members : []);
}
if (isset($get['remove_attachment'])) {
$mailing = null;
if (isset($args['id'])) {
- $mailing = new Mailing($this->preferences, null);
+ $mailing = new Mailing($this->preferences);
MailingHistory::loadFrom($this->zdb, (int)$args['id'], $mailing, false);
$attachments = $mailing->attachments;
} else {
*/
public function previewAttachment(Request $request, Response $response, array $args = []): Response
{
- $mailing = new Mailing($this->preferences, null);
+ $mailing = new Mailing($this->preferences);
MailingHistory::loadFrom($this->zdb, (int)$args['id'], $mailing, false);
$attachments = $mailing->attachments;
$attachment = $attachments[$args['pos']];
try {
$this->history->clean();
//reinitialize object after flush
- $this->history = new History($this->zdb, $this->login);
+ $this->history = new History($this->zdb, $this->login, $this->preferences);
$filters = new HistoryList();
$this->session->filter_history = $filters;
}
/**
- * History flush rconfirmation
+ * History flush confirmation
*
* @param Request $request PSR Request
* @param Response $response PSR Response
protected $count;
protected $zdb;
protected $login;
+ protected $preferences;
protected $filters;
protected $users;
/**
* Default constructor
*
- * @param Db $zdb Database
- * @param Login $login Login
- * @param HistoryList $filters Filtering
+ * @param Db $zdb Database
+ * @param Login $login Login
+ * @param Preferences $preferences Preferences
+ * @param HistoryList $filters Filtering
*/
- public function __construct(Db $zdb, Login $login, $filters = null)
+ public function __construct(Db $zdb, Login $login, Preferences $preferences, $filters = null)
{
$this->zdb = $zdb;
$this->login = $login;
+ $this->preferences = $preferences;
if ($filters === null) {
$this->filters = new HistoryList();
*/
public function add($action, $argument = '', $query = '')
{
- global $preferences;
-
- if ($preferences->pref_log == Preferences::LOG_DISABLED) {
+ if ($this->preferences->pref_log == Preferences::LOG_DISABLED) {
//logs are disabled
return true;
}
* @param array $members An array of members
* @param int $id Identifier, defaults to null
*/
- public function __construct(Preferences $preferences, $members, $id = null)
+ public function __construct(Preferences $preferences, array $members = [], int $id = null)
{
parent::__construct($preferences);
- if ($id !== null) {
- $this->id = $id;
- } else {
- $this->generateNewId();
- }
+ $this->id = $id ?? $this->generateNewId();
+
$this->current_step = self::STEP_START;
$this->mime_type = self::MIME_DEFAULT;
/** TODO: add a preference that propose default mime-type to use,
then init it here */
- if ($members !== null) {
+ if (count($members)) {
//Check which members have a valid email address and which have not
$this->setRecipients($members);
}
/**
* Generate new mailing id and temporary path
*
- * @return void
+ * @return integer
*/
- private function generateNewId()
+ private function generateNewId(): int
{
global $zdb;
$pass = new Password($zdb);
$this->id = $pass->makeRandomPassword(30);
$this->generateTmpPath($this->id);
+ return $this->id;
}
/**
/**
* Default constructor
*
- * @param Db $zdb Database
- * @param Login $login Login
- * @param HistoryList $filters Filtering
- * @param Mailing $mailing Mailing
+ * @param Db $zdb Database
+ * @param Login $login Login
+ * @param Preferences $preferences Preferences
+ * @param MailingsList|null $filters Filtering
+ * @param Mailing|null $mailing Mailing
*/
- public function __construct(Db $zdb, Login $login, $filters = null, $mailing = null)
+ public function __construct(Db $zdb, Login $login, Preferences $preferences, MailingsList $filters = null, Mailing $mailing = null)
{
- parent::__construct($zdb, $login, $filters);
-
- if ($mailing instanceof Mailing) {
- $this->mailing = $mailing;
- } elseif ($mailing !== null) {
- Analog::log(
- '[' . __METHOD__ .
- '] Mailing should be either null or an instance of Mailing',
- Analog::ERROR
- );
- }
+ parent::__construct($zdb, $login, $preferences, $filters);
+ $this->mailing = $mailing;
}
/**
if (is_array($list)) {
try {
foreach ($list as $id) {
- $mailing = new Mailing($preferences, null, $id);
+ $mailing = new Mailing($preferences, [], $id);
$mailing->removeAttachments();
}
private $zdb;
private $i18n;
private $session;
+ private $preferences;
/**
* Set up tests
$this->i18n = new \Galette\Core\I18n();
$this->session = new \RKA\Session();
$this->login = new \Galette\Core\Login($this->zdb, $this->i18n, $this->session);
- $this->history = new \Galette\Core\History($this->zdb, $this->login);
+ $this->preferences = new \Galette\Core\Preferences(
+ $this->zdb
+ );
+ $this->history = new \Galette\Core\History($this->zdb, $this->login, $this->preferences);
}
/**
throw new \LogicException('Error executing query!', 123);
};
- $this->history = new \Galette\Core\History($this->zdb, $this->login);
+ $this->history = new \Galette\Core\History($this->zdb, $this->login, $this->preferences);
$add = $this->history->add('Test');
$this->boolean($add)->isFalse();
}
throw new \LogicException('Error executing query!', 123);
};
- $this->history = new \Galette\Core\History($this->zdb, $this->login);
+ $this->history = new \Galette\Core\History($this->zdb, $this->login, $this->preferences);
$list = $this->history->getHistory();
$this->boolean($list)->isFalse();
}
);
$this->session = new \RKA\Session();
$this->login = new \Galette\Core\Login($this->zdb, $this->i18n, $this->session);
- $this->history = new \Galette\Core\History($this->zdb, $this->login);
+ $this->history = new \Galette\Core\History($this->zdb, $this->login, $this->preferences);
global $zdb, $login, $hist, $i18n; // globals :(
$zdb = $this->zdb;
$this->preferences = new \Galette\Core\Preferences(
$this->zdb
);
- $this->history = new \Galette\Core\History($this->zdb, $this->login);
+ $this->history = new \Galette\Core\History($this->zdb, $this->login, $this->preferences);
include_once GALETTE_ROOT . 'includes/fields_defs/members_fields.php';
$this->members_fields = $members_fields;
);
$this->session = new \RKA\Session();
$this->login = new \Galette\Core\Login($this->zdb, $this->i18n, $this->session);
- $this->history = new \Galette\Core\History($this->zdb, $this->login);
+ $this->history = new \Galette\Core\History($this->zdb, $this->login, $this->preferences);
$this->default_deps = [
'picture' => true,
);
$this->session = new \RKA\Session();
$this->login = new \Galette\Core\Login($this->zdb, $this->i18n, $this->session);
- $this->history = new \Galette\Core\History($this->zdb, $this->login);
+ $this->history = new \Galette\Core\History($this->zdb, $this->login, $this->preferences);
global $zdb, $login, $hist, $i18n; // globals :(
$zdb = $this->zdb;
);
$this->session = new \RKA\Session();
$this->login = new \Galette\Core\Login($this->zdb, $this->i18n, $this->session);
- $this->history = new \Galette\Core\History($this->zdb, $this->login);
+ $this->history = new \Galette\Core\History($this->zdb, $this->login, $this->preferences);
$flash_data = [];
$this->flash_data = &$flash_data;
$this->flash = new \Slim\Flash\Messages($flash_data);
);
$this->session = new \RKA\Session();
$this->login = new \Galette\Core\Login($this->zdb, $this->i18n, $this->session);
- $this->history = new \Galette\Core\History($this->zdb, $this->login);
+ $this->history = new \Galette\Core\History($this->zdb, $this->login, $this->preferences);
include_once GALETTE_ROOT . 'includes/fields_defs/members_fields.php';
$this->members_fields = $members_fields;
);
$this->session = new \RKA\Session();
$this->login = new \Galette\Core\Login($this->zdb, $this->i18n, $this->session);
- $this->history = new \Galette\Core\History($this->zdb, $this->login);
+ $this->history = new \Galette\Core\History($this->zdb, $this->login, $this->preferences);
global $zdb, $login, $hist, $i18n; // globals :(
$zdb = $this->zdb;
\Galette\Core\I18n::DEFAULT_LANG
);
$login = new \Galette\Core\Login($this->zdb, $i18n, $session);
- $history = new \Galette\Core\History($this->zdb, $login);
+ $history = new \Galette\Core\History($this->zdb, $login, $this->preferences);
include_once GALETTE_ROOT . 'includes/fields_defs/members_fields.php';
$members_fields = $members_fields;