'0.704' => '0.76'
);
- protected int $_step;
- private ?string $_mode;
- private ?string $_installed_version = null;
-
- private string $_db_type;
- private string $_db_host;
- private string $_db_port;
- private string $_db_name;
- private string $_db_user;
- private ?string $_db_pass;
- private ?string $_db_prefix = null;
-
- private bool $_db_connected;
+ protected int $step;
+ private ?string $mode;
+ private ?string $installed_version = null;
+
+ private string $db_type;
+ private string $db_host;
+ private string $db_port;
+ private string $db_name;
+ private string $db_user;
+ private ?string $db_pass;
+ private ?string $db_prefix = null;
+
+ private bool $db_connected;
/** @var array<string, string> */
- private array $_report;
+ private array $report;
- private string $_admin_login;
- private string $_admin_pass;
+ private string $admin_login;
+ private string $admin_pass;
- private bool $_error;
+ private bool $error;
/**
* Main constructor
*/
public function __construct()
{
- $this->_step = self::STEP_CHECK;
- $this->_mode = null;
- $this->_db_connected = false;
- $this->_db_prefix = null;
+ $this->step = self::STEP_CHECK;
+ $this->mode = null;
+ $this->db_connected = false;
+ $this->db_prefix = null;
}
/**
public function getStepTitle(): string
{
$step_title = null;
- switch ($this->_step) {
+ switch ($this->step) {
case self::STEP_CHECK:
$step_title = _T("Checks");
break;
/**
* Get current mode
*
- * @return string
+ * @return ?string
*/
public function getMode(): ?string
{
- return $this->_mode;
+ return $this->mode;
}
/**
*/
public function isInstall(): bool
{
- return $this->_mode === self::INSTALL;
+ return $this->mode === self::INSTALL;
}
/**
*/
public function isUpgrade(): bool
{
- return $this->_mode === self::UPDATE;
+ return $this->mode === self::UPDATE;
}
/**
public function setMode(string $mode): self
{
if ($mode === self::INSTALL || $mode === self::UPDATE) {
- $this->_mode = $mode;
+ $this->mode = $mode;
} else {
throw new \UnexpectedValueException('Unknown mode "' . $mode . '"');
}
*/
public function atPreviousStep(): void
{
- if ($this->_step > 0) {
+ if ($this->step > 0) {
if (
- $this->_step - 1 !== self::STEP_DB_INSTALL
- && $this->_step !== self::STEP_END
+ $this->step - 1 !== self::STEP_DB_INSTALL
+ && $this->step !== self::STEP_END
) {
- if ($this->_step === self::STEP_DB_INSTALL) {
- $this->_step = self::STEP_DB_CHECKS;
+ if ($this->step === self::STEP_DB_INSTALL) {
+ $this->step = self::STEP_DB_CHECKS;
} else {
- if ($this->_step === self::STEP_DB_UPGRADE) {
+ if ($this->step === self::STEP_DB_UPGRADE) {
$this->setInstalledVersion(null);
}
- $this->_step = $this->_step - 1;
+ $this->step = $this->step - 1;
}
} else {
$msg = null;
- if ($this->_step === self::STEP_END) {
+ if ($this->step === self::STEP_END) {
$msg = 'Ok man, install is finished already!';
} else {
$msg = 'It is forbidden to rerun database install!';
*/
public function isCheckStep(): bool
{
- return $this->_step === self::STEP_CHECK;
+ return $this->step === self::STEP_CHECK;
}
/**
*/
public function atTypeStep(): void
{
- $this->_step = self::STEP_TYPE;
+ $this->step = self::STEP_TYPE;
}
/**
*/
public function isTypeStep(): bool
{
- return $this->_step === self::STEP_TYPE;
+ return $this->step === self::STEP_TYPE;
}
/**
*/
public function atDbStep(): void
{
- $this->_step = self::STEP_DB;
+ $this->step = self::STEP_DB;
}
/**
*/
public function isDbStep(): bool
{
- return $this->_step === self::STEP_DB;
+ return $this->step === self::STEP_DB;
}
/**
*/
public function postCheckDb(): bool
{
- return $this->_step >= self::STEP_DB_CHECKS;
+ return $this->step >= self::STEP_DB_CHECKS;
}
/**
switch ($type) {
case Db::MYSQL:
case Db::PGSQL:
- $this->_db_type = $type;
+ $this->db_type = $type;
break;
default:
$errs[] = _T("Database type unknown");
*/
public function getDbType(): ?string
{
- return $this->_db_type ?? null;
+ return $this->db_type ?? null;
}
/**
*/
public function setDsn(string $host, string $port, string $name, string $user, ?string $pass): void
{
- $this->_db_host = $host;
- $this->_db_port = $port;
- $this->_db_name = $name;
- $this->_db_user = $user;
- $this->_db_pass = $pass;
+ $this->db_host = $host;
+ $this->db_port = $port;
+ $this->db_name = $name;
+ $this->db_user = $user;
+ $this->db_pass = $pass;
}
/**
*/
public function setTablesPrefix(string $prefix): self
{
- $this->_db_prefix = $prefix;
+ $this->db_prefix = $prefix;
return $this;
}
*/
public function getDbHost(): ?string
{
- return $this->_db_host ?? null;
+ return $this->db_host ?? null;
}
/**
*/
public function getDbPort(): ?string
{
- return $this->_db_port ?? null;
+ return $this->db_port ?? null;
}
/**
*/
public function getDbName(): ?string
{
- return $this->_db_name ?? null;
+ return $this->db_name ?? null;
}
/**
*/
public function getDbUser(): ?string
{
- return $this->_db_user ?? null;
+ return $this->db_user ?? null;
}
/**
*/
public function getDbPass(): string
{
- return $this->_db_pass;
+ return $this->db_pass;
}
/**
*/
public function getTablesPrefix(): ?string
{
- return $this->_db_prefix;
+ return $this->db_prefix;
}
/**
*/
public function atDbCheckStep(): void
{
- $this->_step = self::STEP_DB_CHECKS;
+ $this->step = self::STEP_DB_CHECKS;
}
/**
*/
public function isDbCheckStep(): bool
{
- return $this->_step === self::STEP_DB_CHECKS;
+ return $this->step === self::STEP_DB_CHECKS;
}
/**
public function testDbConnexion(): bool
{
return Db::testConnectivity(
- $this->_db_type,
- $this->_db_user,
- $this->_db_pass,
- $this->_db_host,
- $this->_db_port,
- $this->_db_name
+ $this->db_type,
+ $this->db_user,
+ $this->db_pass,
+ $this->db_host,
+ $this->db_port,
+ $this->db_name
);
}
*/
public function isDbConnected(): bool
{
- return $this->_db_connected;
+ return $this->db_connected;
}
/**
*/
public function atVersionSelection(): void
{
- $this->_step = self::STEP_VERSION;
+ $this->step = self::STEP_VERSION;
}
/**
*/
public function isVersionSelectionStep(): bool
{
- return $this->_step === self::STEP_VERSION;
+ return $this->step === self::STEP_VERSION;
}
/**
*/
public function atDbInstallStep(): void
{
- $this->_step = self::STEP_DB_INSTALL;
+ $this->step = self::STEP_DB_INSTALL;
}
/**
*/
public function isDbinstallStep(): bool
{
- return $this->_step === self::STEP_DB_INSTALL;
+ return $this->step === self::STEP_DB_INSTALL;
}
/**
*/
public function atDbUpgradeStep(): void
{
- $this->_step = self::STEP_DB_UPGRADE;
+ $this->step = self::STEP_DB_UPGRADE;
}
/**
*/
public function isDbUpgradeStep(): bool
{
- return $this->_step === self::STEP_DB_UPGRADE;
+ return $this->step === self::STEP_DB_UPGRADE;
}
if ($this->isUpgrade()) {
$update_scripts = self::getUpdateScripts(
$path,
- $this->_db_type,
- $this->_installed_version
+ $this->db_type,
+ $this->installed_version
);
} else {
- $update_scripts['current'] = $this->_db_type . '.sql';
+ $update_scripts['current'] = $this->db_type . '.sql';
}
return $update_scripts;
{
$fatal_error = false;
$update_scripts = $this->getScripts($spath);
- $this->_report = array();
+ $this->report = array();
$scripts_path = ($spath ?? GALETTE_ROOT . '/install') . '/scripts/';
foreach ($update_scripts as $key => $val) {
if ($updater instanceof \Galette\Updater\AbstractUpdater) {
$updater->run($zdb, $this);
$ret = $updater->getReport();
- $this->_report = array_merge($this->_report, $ret);
+ $this->report = array_merge($this->report, $ret);
} else {
$fatal_error = true;
Analog::log(
_T("%version script has been successfully executed :)")
);
$ret['res'] = true;
- $this->_report[] = $ret;
+ $this->report[] = $ret;
} catch (\RuntimeException $e) {
Analog::log(
$e->getMessage(),
_T("Unable to run %version update script :(")
);
$fatal_error = true;
- $this->_report[] = $ret;
+ $this->report[] = $ret;
}
}
// load in the sql parser
include_once GALETTE_ROOT . 'includes/sql_parse.php';
- $sql_query = preg_replace('/galette_/', $this->_db_prefix, $sql_query);
+ $sql_query = preg_replace('/galette_/', $this->db_prefix, $sql_query);
$sql_query = remove_remarks($sql_query);
$sql_query = split_sql_file($sql_query, ';');
}
}
- $this->_report = array_merge($this->_report, $queries_results);
+ $this->report = array_merge($this->report, $queries_results);
return !$fatal_error;
}
*/
public function getDbInstallReport(): array
{
- return $this->_report;
+ return $this->report;
}
/**
*/
public function reinitReport(): void
{
- $this->_report = array();
+ $this->report = array();
}
/**
*/
public function atAdminStep(): void
{
- $this->_step = self::STEP_ADMIN;
+ $this->step = self::STEP_ADMIN;
}
/**
*/
public function isAdminStep(): bool
{
- return $this->_step === self::STEP_ADMIN;
+ return $this->step === self::STEP_ADMIN;
}
/**
*/
public function setAdminInfos(string $login, string $pass): void
{
- $this->_admin_login = $login;
- $this->_admin_pass = password_hash($pass, PASSWORD_BCRYPT);
+ $this->admin_login = $login;
+ $this->admin_pass = password_hash($pass, PASSWORD_BCRYPT);
}
/**
*/
public function getAdminLogin(): string
{
- return $this->_admin_login;
+ return $this->admin_login;
}
/**
*/
public function getAdminPass(): string
{
- return $this->_admin_pass;
+ return $this->admin_pass;
}
/**
*/
public function atTelemetryStep(): void
{
- $this->_step = self::STEP_TELEMETRY;
+ $this->step = self::STEP_TELEMETRY;
}
/**
*/
public function isTelemetryStep(): bool
{
- return $this->_step === self::STEP_TELEMETRY;
+ return $this->step === self::STEP_TELEMETRY;
}
/**
*/
public function atGaletteInitStep(): void
{
- $this->_step = self::STEP_GALETTE_INIT;
+ $this->step = self::STEP_GALETTE_INIT;
}
/**
*/
public function isGaletteInitStep(): bool
{
- return $this->_step === self::STEP_GALETTE_INIT;
+ return $this->step === self::STEP_GALETTE_INIT;
}
/**
if (
isset($existing['db_type'])
- && $existing['db_type'] == $this->_db_type
+ && $existing['db_type'] == $this->db_type
&& isset($existing['db_host'])
- && $existing['db_host'] == $this->_db_host
+ && $existing['db_host'] == $this->db_host
&& isset($existing['db_port'])
- && $existing['db_port'] == $this->_db_port
+ && $existing['db_port'] == $this->db_port
&& isset($existing['db_user'])
- && $existing['db_user'] == $this->_db_user
+ && $existing['db_user'] == $this->db_user
&& isset($existing['pwd_db'])
- && $existing['pwd_db'] == $this->_db_pass
+ && $existing['pwd_db'] == $this->db_pass
&& isset($existing['db_name'])
- && $existing['db_name'] == $this->_db_name
+ && $existing['db_name'] == $this->db_name
&& isset($existing['prefix'])
- && $existing['prefix'] == $this->_db_prefix
+ && $existing['prefix'] == $this->db_prefix
) {
Analog::log(
'Config file is already up-to-date, nothing to do.',
Analog::INFO
);
- $this->_report[] = array(
+ $this->report[] = array(
'message' => _T("Config file already exists and is up to date"),
'res' => true
);
&& $fd = @fopen($conffile, 'w')
) {
$data = "<?php
-define('TYPE_DB', '" . $this->_db_type . "');
-define('HOST_DB', '" . $this->_db_host . "');
-define('PORT_DB', '" . $this->_db_port . "');
-define('USER_DB', '" . $this->_db_user . "');
-define('PWD_DB', '" . $this->_db_pass . "');
-define('NAME_DB', '" . $this->_db_name . "');
-define('PREFIX_DB', '" . $this->_db_prefix . "');
+define('TYPE_DB', '" . $this->db_type . "');
+define('HOST_DB', '" . $this->db_host . "');
+define('PORT_DB', '" . $this->db_port . "');
+define('USER_DB', '" . $this->db_user . "');
+define('PWD_DB', '" . $this->db_pass . "');
+define('NAME_DB', '" . $this->db_name . "');
+define('PREFIX_DB', '" . $this->db_prefix . "');
";
fwrite($fd, $data);
fclose($fd);
$ret['error'] = $str;
$error = true;
}
- $this->_report[] = $ret;
+ $this->report[] = $ret;
return !$error;
}
$models = new \Galette\Repository\PdfModels($zdb, $preferences, $login);
- $this->_error = false;
+ $this->error = false;
//Install preferences
$res = $preferences->installInit(
$res = $models->installInit(false);
$this->proceedReport(_T("PDF models"), $res);
- return !$this->_error;
+ return !$this->error;
} elseif ($this->isUpgrade()) {
$preferences = new Preferences($zdb);
$preferences->store();
if ($res instanceof \Exception) {
$ret['debug'] = $res->getMessage();
- $this->_error = true;
+ $this->error = true;
} else {
$ret['res'] = true;
}
- $this->_report[] = $ret;
+ $this->report[] = $ret;
}
/**
* Retrieve galette initialization report
*/
public function getInitializationReport(): array
{
- return $this->_report;
+ return $this->report;
}
/**
*/
public function atEndStep(): void
{
- $this->_step = self::STEP_END;
+ $this->step = self::STEP_END;
}
/**
*/
public function isEndStep(): bool
{
- return $this->_step === self::STEP_END;
+ return $this->step === self::STEP_END;
}
/**
*/
public function setInstalledVersion(?string $version): void
{
- $this->_installed_version = $version;
+ $this->installed_version = $version;
}
/**
*/
public function isStepPassed($step): bool
{
- return $this->_step > $step;
+ return $this->step > $step;
}
}
* @property-read string $alt_message
* @property-read string $wrapped_message
* @property-read PHPMailer\PHPMailer\PHPMailer $mail
- * @property-read PHPMailer\PHPMailer\PHPMailer $_mail
* @property-read array $errors
* @property-read array $recipients
* @property-read array $unreachables
case 'html':
return $this->isHTML();
case 'mail':
- case '_mail':
return $this->getPhpMailer();
case 'errors':
return $this->getErrors();
case 'wrapped_message':
case 'html':
case 'mail':
- case '_mail':
case 'errors':
case 'recipients':
case 'tmp_path':
} else {
Analog::log(
'[' . get_class($this) .
- '|Pagination] Unable to get proprety `' . $name . '`',
+ '|Pagination] Unable to get property `' . $name . '`',
Analog::WARNING
);
}
default:
Analog::log(
'[' . get_class($this) .
- '|Pagination] Unable to set proprety `' . $name . '`',
+ '|Pagination] Unable to set property `' . $name . '`',
Analog::WARNING
);
break;
*/
public function atPreviousStep(): void
{
- if ($this->_step > 0) {
+ if ($this->step > 0) {
if (
- $this->_step - 1 !== self::STEP_DB_INSTALL
- && $this->_step !== self::STEP_END
+ $this->step - 1 !== self::STEP_DB_INSTALL
+ && $this->step !== self::STEP_END
) {
- if ($this->_step === self::STEP_DB_INSTALL) {
- $this->_step = self::STEP_DB_CHECKS;
+ if ($this->step === self::STEP_DB_INSTALL) {
+ $this->step = self::STEP_DB_CHECKS;
} else {
- if ($this->_step === self::STEP_DB_UPGRADE) {
+ if ($this->step === self::STEP_DB_UPGRADE) {
$this->setInstalledVersion(null);
}
- $this->_step = $this->_step - 1;
+ $this->step = $this->step - 1;
}
} else {
$msg = null;
- if ($this->_step === self::STEP_END) {
+ if ($this->step === self::STEP_END) {
$msg = 'Ok man, install is finished already!';
} else {
$msg = 'It is forbidden to rerun database install!';
*
* @author Johan Cwiklinski <johan@x-tnd.be>
*
- * @property integer $id
- * @property integer|Title $title Either a title id or an instance of Title
+ * @property ?integer $id
+ * @property integer|Title|null $title Either a title id or an instance of Title
* @property string $stitle Title label
* @property string $company_name
* @property string $name
* @property ?string $surname
* @property string $nickname
- * @property string $birthdate Localized birthdate
- * @property string $rbirthdate Raw birthdate
+ * @property ?string $birthdate Localized birthdate
+ * @property ?string $rbirthdate Raw birthdate
* @property string $birth_place
* @property integer $gender
* @property string $sgender Gender label
* @property string $language
* @property integer $status
* @property string $sstatus Status label
- * @property string $address
- * @property string $zipcode
- * @property string $town
+ * @property ?string $address
+ * @property ?string $zipcode
+ * @property ?string $town
* @property ?string $country
* @property string $phone
* @property string $gsm
- * @property string $email
+ * @property ?string $email
* @property string $gnupgid
* @property string $fingerprint
- * @property string $login
+ * @property ?string $login
* @property string $creation_date Localized creation date
* @property string $modification_date Localized modification date
* @property string $due_date Localized due date
* @property Picture $picture
* @property array $groups
* @property array $managed_groups
- * @property integer|Adherent $parent Parent id if parent dep is not loaded, Adherent instance otherwise
+ * @property integer|Adherent|null $parent Parent id if parent dep is not loaded, Adherent instance otherwise
* @property array $children
* @property boolean $admin better to rely on isAdmin()
* @property boolean $staff better to rely on isStaff()
* @property Social $social Social networks/Contact
* @property string $number Member number
* @property-read bool $self_adh
- * @property string $region
+ * @property ?string $region
*/
class Adherent
{
public const AFTER_ADD_LIST = 4;
public const AFTER_ADD_HOME = 5;
- private ?int $_id;
+ private ?int $id;
//Identity
- private Title|string|null $_title = null;
- private ?string $_company_name;
- private ?string $_name;
- private ?string $_surname;
- private ?string $_nickname;
- private ?string $_birthdate;
- private ?string $_birth_place;
- private int $_gender;
- private string $_job;
- private string $_language;
- private bool $_active;
- private int $_status;
+ private Title|string|null $title = null;
+ private ?string $company_name;
+ private ?string $name;
+ private ?string $surname;
+ private ?string $nickname;
+ private ?string $birthdate;
+ private ?string $birth_place;
+ private int $gender;
+ private string $job;
+ private string $language;
+ private bool $active;
+ private int $status;
//Contact information
- private ?string $_address = null;
- private ?string $_zipcode = null;
- private ?string $_town = null;
- private ?string $_country = null;
- private ?string $_phone;
- private ?string $_gsm;
- private ?string $_email;
- private ?string $_gnupgid;
- private ?string $_fingerprint;
+ private ?string $address = null;
+ private ?string $zipcode = null;
+ private ?string $town = null;
+ private ?string $country = null;
+ private ?string $phone;
+ private ?string $gsm;
+ private ?string $email;
+ private ?string $gnupgid;
+ private ?string $fingerprint;
//Galette relative information
- private bool $_appears_in_list;
- private bool $_admin;
- private bool $_staff = false;
- private bool $_due_free;
- private ?string $_login;
- private ?string $_password;
- private string $_creation_date;
- private string $_modification_date;
- private ?string $_due_date;
- private string $_others_infos;
- private ?string $_others_infos_admin;
- private ?Picture $_picture = null;
- private int $_oldness;
- private ?int $_days_remaining = null;
+ private bool $appears_in_list;
+ private bool $admin;
+ private bool $staff = false;
+ private bool $due_free;
+ private ?string $login;
+ private ?string $password;
+ private string $creation_date;
+ private string $modification_date;
+ private ?string $due_date;
+ private string $others_infos;
+ private ?string $others_infos_admin;
+ private ?Picture $picture = null;
+ private int $oldness;
+ private ?int $days_remaining = null;
/** @var array<int, Group> */
- private array $_groups = [];
+ private array $groups = [];
/** @var array<int, Group> */
- private array $_managed_groups = [];
- private int|Adherent|null $_parent;
+ private array $managed_groups = [];
+ private int|Adherent|null $parent;
/** @var array<int, Adherent>|null */
- private ?array $_children = [];
- private bool $_duplicate = false;
+ private ?array $children = [];
+ private bool $duplicate = false;
/** @var array<int,Social> */
- private array $_socials;
- private ?string $_number = null;
- private ?string $_region = null;
+ private array $socials;
+ private ?string $number = null;
+ private ?string $region = null;
- private string $_row_classes;
+ private string $row_classes;
- private bool $_self_adh = false;
+ private bool $self_adh = false;
private Db $zdb;
private Preferences $preferences;
/** @var array<string, mixed> */
private array $fields;
private History $history;
- private int $_due_status = Contribution::STATUS_UNKNOWN;
+ private int $due_status = Contribution::STATUS_UNKNOWN;
/** @var array<string> */
private array $parent_fields = [
if (is_int($args) && $args > 0) {
$this->load($args);
} else {
- $this->_active = true;
- $this->_language = $i18n->getID();
- $this->_creation_date = date("Y-m-d");
- $this->_status = $this->getDefaultStatus();
- $this->_title = null;
- $this->_gender = self::NC;
+ $this->active = true;
+ $this->language = $i18n->getID();
+ $this->creation_date = date("Y-m-d");
+ $this->status = $this->getDefaultStatus();
+ $this->title = null;
+ $this->gender = self::NC;
$gp = new Password($this->zdb);
- $this->_password = $gp->makeRandomPassword();
- $this->_picture = new Picture();
- $this->_admin = false;
- $this->_staff = false;
- $this->_due_free = false;
- $this->_appears_in_list = false;
- $this->_parent = null;
-
- if ($this->_deps['dynamics'] === true) {
+ $this->password = $gp->makeRandomPassword();
+ $this->picture = new Picture();
+ $this->admin = false;
+ $this->staff = false;
+ $this->due_free = false;
+ $this->appears_in_list = false;
+ $this->parent = null;
+
+ if ($this->deps['dynamics'] === true) {
$this->loadDynamicFields();
}
}
*/
private function loadFromRS(ArrayObject $r): void
{
- $this->_self_adh = false;
- $this->_id = $r->id_adh;
+ $this->self_adh = false;
+ $this->id = $r->id_adh;
//Identity
if ($r->titre_adh !== null) {
- $this->_title = new Title((int)$r->titre_adh);
+ $this->title = new Title((int)$r->titre_adh);
}
- $this->_company_name = $r->societe_adh;
- $this->_name = $r->nom_adh;
- $this->_surname = $r->prenom_adh;
- $this->_nickname = $r->pseudo_adh;
+ $this->company_name = $r->societe_adh;
+ $this->name = $r->nom_adh;
+ $this->surname = $r->prenom_adh;
+ $this->nickname = $r->pseudo_adh;
if ($r->ddn_adh != '1901-01-01') {
- $this->_birthdate = $r->ddn_adh;
- }
- $this->_birth_place = $r->lieu_naissance;
- $this->_gender = (int)$r->sexe_adh;
- $this->_job = $r->prof_adh;
- $this->_language = $r->pref_lang;
- $this->_active = $r->activite_adh == 1;
- $this->_status = (int)$r->id_statut;
+ $this->birthdate = $r->ddn_adh;
+ }
+ $this->birth_place = $r->lieu_naissance;
+ $this->gender = (int)$r->sexe_adh;
+ $this->job = $r->prof_adh;
+ $this->language = $r->pref_lang;
+ $this->active = $r->activite_adh == 1;
+ $this->status = (int)$r->id_statut;
//Contact information
- $this->_address = $r->adresse_adh;
- $this->_zipcode = $r->cp_adh;
- $this->_town = $r->ville_adh;
- $this->_region = $r->region_adh;
- $this->_country = $r->pays_adh;
- $this->_phone = $r->tel_adh;
- $this->_gsm = $r->gsm_adh;
- $this->_email = $r->email_adh;
- $this->_gnupgid = $r->gpgid;
- $this->_fingerprint = $r->fingerprint;
+ $this->address = $r->adresse_adh;
+ $this->zipcode = $r->cp_adh;
+ $this->town = $r->ville_adh;
+ $this->region = $r->region_adh;
+ $this->country = $r->pays_adh;
+ $this->phone = $r->tel_adh;
+ $this->gsm = $r->gsm_adh;
+ $this->email = $r->email_adh;
+ $this->gnupgid = $r->gpgid;
+ $this->fingerprint = $r->fingerprint;
//Galette relative information
- $this->_appears_in_list = $r->bool_display_info == 1;
- $this->_admin = $r->bool_admin_adh == 1;
+ $this->appears_in_list = $r->bool_display_info == 1;
+ $this->admin = $r->bool_admin_adh == 1;
if (
isset($r->priorite_statut)
&& $r->priorite_statut < Members::NON_STAFF_MEMBERS
) {
- $this->_staff = true;
+ $this->staff = true;
}
- $this->_due_free = $r->bool_exempt_adh == 1;
- $this->_login = $r->login_adh;
- $this->_password = $r->mdp_adh;
- $this->_creation_date = $r->date_crea_adh;
+ $this->due_free = $r->bool_exempt_adh == 1;
+ $this->login = $r->login_adh;
+ $this->password = $r->mdp_adh;
+ $this->creation_date = $r->date_crea_adh;
if ($r->date_modif_adh != '1901-01-01') {
- $this->_modification_date = $r->date_modif_adh;
+ $this->modification_date = $r->date_modif_adh;
} else {
- $this->_modification_date = $this->_creation_date;
+ $this->modification_date = $this->creation_date;
}
- $this->_due_date = $r->date_echeance;
- $this->_others_infos = $r->info_public_adh;
- $this->_others_infos_admin = $r->info_adh;
- $this->_number = $r->num_adh;
+ $this->due_date = $r->date_echeance;
+ $this->others_infos = $r->info_public_adh;
+ $this->others_infos_admin = $r->info_adh;
+ $this->number = $r->num_adh;
if ($r->parent_id !== null) {
- $this->_parent = (int)$r->parent_id;
- if ($this->_deps['parent'] === true) {
+ $this->parent = (int)$r->parent_id;
+ if ($this->deps['parent'] === true) {
$this->loadParent();
}
}
- if ($this->_deps['children'] === true) {
+ if ($this->deps['children'] === true) {
$this->loadChildren();
}
- if ($this->_deps['picture'] === true) {
- $this->_picture = new Picture($this->_id);
+ if ($this->deps['picture'] === true) {
+ $this->picture = new Picture($this->id);
}
- if ($this->_deps['groups'] === true) {
+ if ($this->deps['groups'] === true) {
$this->loadGroups();
}
- if ($this->_deps['dues'] === true) {
+ if ($this->deps['dues'] === true) {
$this->checkDues();
}
- if ($this->_deps['dynamics'] === true) {
+ if ($this->deps['dynamics'] === true) {
$this->loadDynamicFields();
}
- if ($this->_deps['socials'] === true) {
+ if ($this->deps['socials'] === true) {
$this->loadSocials();
}
}
*/
private function loadParent(): void
{
- if (isset($this->_parent) && !$this->_parent instanceof Adherent) {
- $deps = array_fill_keys(array_keys($this->_deps), false);
- $this->_parent = new Adherent($this->zdb, (int)$this->_parent, $deps);
+ if (isset($this->parent) && !$this->parent instanceof Adherent) {
+ $deps = array_fill_keys(array_keys($this->deps), false);
+ $this->parent = new Adherent($this->zdb, (int)$this->parent, $deps);
}
}
*/
private function loadChildren(): void
{
- $this->_children = array();
+ $this->children = array();
try {
$id = self::PK;
$select = $this->zdb->select(self::TABLE);
$select->columns(
array($id)
- )->where(['parent_id' => $this->_id]);
+ )->where(['parent_id' => $this->id]);
$results = $this->zdb->execute($select);
if ($results->count() > 0) {
foreach ($results as $row) {
- $deps = $this->_deps;
+ $deps = $this->deps;
$deps['children'] = false;
$deps['parent'] = false;
- $this->_children[] = new Adherent($this->zdb, (int)$row->$id, $deps);
+ $this->children[] = new Adherent($this->zdb, (int)$row->$id, $deps);
}
}
} catch (Throwable $e) {
Analog::log(
- 'Cannot load children for member #' . $this->_id . ' | ' .
+ 'Cannot load children for member #' . $this->id . ' | ' .
$e->getMessage(),
Analog::WARNING
);
*/
public function loadGroups(): void
{
- $this->_groups = Groups::loadGroups($this->_id);
- $this->_managed_groups = Groups::loadManagedGroups($this->_id);
+ $this->groups = Groups::loadGroups($this->id);
+ $this->managed_groups = Groups::loadManagedGroups($this->id);
}
/**
*/
public function loadSocials(): void
{
- $this->_socials = Social::getListForMember($this->_id);
+ $this->socials = Social::getListForMember($this->id);
}
/**
{
//how many days since our beloved member has been created
$now = new DateTime();
- $this->_oldness = $now->diff(
- new DateTime($this->_creation_date)
+ $this->oldness = $now->diff(
+ new DateTime($this->creation_date)
)->days;
- $this->_row_classes = '';
+ $this->row_classes = '';
if ($this->isDueFree()) {
//no fee required, we don't care about dates
- $this->_row_classes .= ' cotis-exempt';
- $this->_due_status = Contribution::STATUS_DUEFREE;
+ $this->row_classes .= ' cotis-exempt';
+ $this->due_status = Contribution::STATUS_DUEFREE;
} else {
//ok, fee is required. Let's check the dates
- if ($this->_due_date == '') {
- $this->_row_classes .= ' cotis-never';
- $this->_due_status = Contribution::STATUS_NEVER;
+ if ($this->due_date == '') {
+ $this->row_classes .= ' cotis-never';
+ $this->due_status = Contribution::STATUS_NEVER;
} else {
// To count the days remaining, the next begin date is required.
- $due_date = new DateTime($this->_due_date);
+ $due_date = new DateTime($this->due_date);
$next_begin_date = clone $due_date;
$next_begin_date->add(new \DateInterval('P1D'));
$date_diff = $now->diff($next_begin_date);
- $this->_days_remaining = $date_diff->days;
+ $this->days_remaining = $date_diff->days;
// Active
if ($date_diff->invert == 0 && $date_diff->days >= 0) {
- $this->_days_remaining = $date_diff->days;
- if ($this->_days_remaining <= 30) {
+ $this->days_remaining = $date_diff->days;
+ if ($this->days_remaining <= 30) {
if ($date_diff->days == 0) {
- $this->_row_classes .= ' cotis-lastday';
+ $this->row_classes .= ' cotis-lastday';
}
- $this->_row_classes .= ' cotis-soon';
- $this->_due_status = Contribution::STATUS_IMPENDING;
+ $this->row_classes .= ' cotis-soon';
+ $this->due_status = Contribution::STATUS_IMPENDING;
} else {
- $this->_row_classes .= ' cotis-ok';
- $this->_due_status = Contribution::STATUS_UPTODATE;
+ $this->row_classes .= ' cotis-ok';
+ $this->due_status = Contribution::STATUS_UPTODATE;
}
// Expired
} elseif ($date_diff->invert == 1 && $date_diff->days >= 0) {
- $this->_days_remaining = $date_diff->days;
+ $this->days_remaining = $date_diff->days;
//check if member is still active
if ($this->isActive()) {
- $this->_row_classes .= ' cotis-late';
- $this->_due_status = Contribution::STATUS_LATE;
+ $this->row_classes .= ' cotis-late';
+ $this->due_status = Contribution::STATUS_LATE;
} else {
- $this->_row_classes .= ' cotis-old';
- $this->_due_status = Contribution::STATUS_OLD;
+ $this->row_classes .= ' cotis-old';
+ $this->due_status = Contribution::STATUS_OLD;
}
}
}
if (!$this->isActive()) {
//anyway, if a member is no longer active, its due status is old.
- $this->_due_status = Contribution::STATUS_OLD;
+ $this->due_status = Contribution::STATUS_OLD;
}
- if ($this->_due_status === Contribution::STATUS_UNKNOWN) {
+ if ($this->due_status === Contribution::STATUS_UNKNOWN) {
throw new \RuntimeException(
- 'Unable to determine due status for member #' . $this->_id
+ 'Unable to determine due status for member #' . $this->id
);
}
}
*/
public function isAdmin(): bool
{
- return $this->_admin;
+ return $this->admin;
}
/**
*/
public function isStaff(): bool
{
- return $this->_staff;
+ return $this->staff;
}
/**
*/
public function isDueFree(): bool
{
- return $this->_due_free;
+ return $this->due_free;
}
/**
$this->loadGroups();
}
- foreach ($this->_groups as $g) {
+ foreach ($this->groups as $g) {
if ($g->getName() == $group_name) {
return true;
}
}
if ($group_name !== null) {
- foreach ($this->_managed_groups as $mg) {
+ foreach ($this->managed_groups as $mg) {
if ($mg->getName() == $group_name) {
return true;
}
*/
public function isCompany(): bool
{
- return trim($this->_company_name ?? '') != '';
+ return trim($this->company_name ?? '') != '';
}
/**
*/
public function isMan(): bool
{
- return $this->_gender === self::MAN;
+ return $this->gender === self::MAN;
}
/**
*/
public function isWoman(): bool
{
- return $this->_gender === self::WOMAN;
+ return $this->gender === self::WOMAN;
}
*/
public function appearsInMembersList(): bool
{
- return $this->_appears_in_list;
+ return $this->appears_in_list;
}
/**
*/
public function isActive(): bool
{
- return $this->_active;
+ return $this->active;
}
/**
*/
public function hasPicture(): bool
{
- return $this->_picture->hasPicture();
+ return $this->picture->hasPicture();
}
/**
*/
public function hasParent(): bool
{
- return !empty($this->_parent);
+ return !empty($this->parent);
}
/**
*/
public function hasChildren(): bool
{
- if (!isset($this->children) || $this->_children === null) {
+ if (!isset($this->children) || $this->children === null) {
if ($this->id) {
Analog::log(
'Children has not been loaded!',
}
return false;
} else {
- return count($this->_children) > 0;
+ return count($this->children) > 0;
}
}
{
$strclass = ($this->isActive()) ? 'active-account' : 'inactive-account';
if ($public === false) {
- $strclass .= $this->_row_classes ?? '';
+ $strclass .= $this->row_classes ?? '';
}
return $strclass;
}
$never_contributed = false;
$now = new DateTime();
// To count the days remaining, the next begin date is required.
- if (!isset($this->_due_date)) {
- $this->_due_date = $now->format('Y-m-d');
+ if (!isset($this->due_date)) {
+ $this->due_date = $now->format('Y-m-d');
$never_contributed = true;
}
- $due_date = new DateTime($this->_due_date);
+ $due_date = new DateTime($this->due_date);
$next_begin_date = clone $due_date;
$next_begin_date->add(new \DateInterval('P1D'));
$date_diff = $now->diff($next_begin_date);
if ($this->isDueFree()) {
$ret = _T("Freed of dues");
} elseif ($never_contributed === true) {
- if ($this->_active) {
+ if ($this->active) {
$patterns = array('/%days/', '/%date/');
- $cdate = new DateTime($this->_creation_date);
- if (!isset($this->_oldness)) {
+ $cdate = new DateTime($this->creation_date);
+ if (!isset($this->oldness)) {
$this->checkDues();
}
$replace = array(
- $this->_oldness,
+ $this->oldness,
$cdate->format(__("Y-m-d"))
);
$ret = _T("Never contributed");
}
// Last active or first expired day
- } elseif ($this->_days_remaining === 0) {
+ } elseif ($this->days_remaining === 0) {
if ($date_diff->invert == 0) {
$ret = _T("Last day!");
} else {
$ret = _T("Late since today!");
}
// Active
- } elseif ($date_diff->invert == 0 && $this->_days_remaining > 0) {
+ } elseif ($date_diff->invert == 0 && $this->days_remaining > 0) {
$patterns = array('/%days/', '/%date/');
$replace = array(
- $this->_days_remaining,
+ $this->days_remaining,
$due_date->format(__("Y-m-d"))
);
$ret = preg_replace(
_T("%days days remaining (ending on %date)")
);
// Expired
- } elseif ($date_diff->invert == 1 && $this->_days_remaining > 0) {
+ } elseif ($date_diff->invert == 1 && $this->days_remaining > 0) {
$patterns = array('/%days/', '/%date/');
$replace = array(
// We need the number of days expired, not the number of days remaining.
- $this->_days_remaining + 1,
+ $this->days_remaining + 1,
$due_date->format(__("Y-m-d"))
);
- if ($this->_active) {
+ if ($this->active) {
$ret = preg_replace(
$patterns,
$replace,
*/
public function setSelfMembership(): void
{
- $this->_self_adh = true;
+ $this->self_adh = true;
}
/**
return true;
} else {
//let's check from due date, if present
- if (!isset($this->_due_date)) {
+ if (!isset($this->due_date)) {
return false;
} else {
- $due_date = new DateTime($this->_due_date);
+ $due_date = new DateTime($this->due_date);
$now = new DateTime();
$now->setTime(0, 0, 0);
return $due_date >= $now;
//no parent if checkbox was unchecked
if (
!isset($values['attach'])
- && !empty($this->_id)
+ && !empty($this->id)
&& isset($values['parent_id'])
) {
unset($values['parent_id']);
if (isset($values['duplicate'])) {
//if we're duplicating, keep a trace (if an error occurs)
- $this->_duplicate = true;
+ $this->duplicate = true;
}
foreach ($fields as $key) {
//first, let's sanitize values
$key = strtolower($key);
- $prop = '_' . $this->fields[$key]['propname'];
+ $prop = $this->fields[$key]['propname'];
if (isset($values[$key])) {
$value = $values[$key];
//@phpstan-ignore-next-line
$value = trim($value ?? '');
}
- } elseif (empty($this->_id)) {
+ } elseif (empty($this->id)) {
switch ($key) {
case 'bool_admin_adh':
case 'bool_exempt_adh':
}
} else {
//keep stored value on update
- if ($prop != '_password' || isset($values['mdp_adh']) && isset($values['mdp_adh2'])) {
+ if ($prop != 'password' || isset($values['mdp_adh']) && isset($values['mdp_adh2'])) {
$value = $this->$prop;
} else {
$value = null;
if ($key !== 'mdp_adh') {
$this->validate($key, $value, $values);
}
- } elseif (empty($this->_id)) {
+ } elseif (empty($this->id)) {
//ensure login and password are not empty
if (($key == 'login_adh' || $key == 'mdp_adh') && !isset($required[$key])) {
$p = new Password($this->zdb);
// missing required fields?
foreach ($required as $key => $val) {
- $prop = '_' . $this->fields[$key]['propname'];
+ $prop = $this->fields[$key]['propname'];
if (!isset($disabled[$key])) {
$mandatory_missing = false;
//attach to/detach from parent
if (isset($values['detach_parent'])) {
- $this->_parent = null;
+ $this->parent = null;
}
if ($login->isGroupManager() && !$login->isAdmin() && !$login->isStaff() && $this->parent_id !== $login->id) {
{
global $preferences;
- $prop = '_' . $this->fields[$field]['propname'];
+ $prop = $this->fields[$field]['propname'];
if ($value === null || (is_string($value) && trim($value) == '')) {
//empty values are OK
$select->columns(
array(self::PK)
)->where(array('email_adh' => $value));
- if (!empty($this->_id)) {
+ if (!empty($this->id)) {
$select->where->notEqualTo(
self::PK,
- $this->_id
+ $this->id
);
}
$select->columns(
array(self::PK)
)->where(array('login_adh' => $value));
- if (!empty($this->_id)) {
+ if (!empty($this->id)) {
$select->where->notEqualTo(
self::PK,
- $this->_id
+ $this->id
);
}
break;
case 'mdp_adh':
if (
- $this->_self_adh !== true
+ $this->self_adh !== true
&& (!isset($values['mdp_adh2'])
|| $values['mdp_adh2'] != $value)
) {
$this->errors[] = _T("- The passwords don't match!");
} elseif (
- $this->_self_adh === true
+ $this->self_adh === true
&& !crypt($value, $values['mdp_crypt']) == $values['mdp_crypt']
) {
$this->errors[] = _T("Password misrepeated: ");
if (!$login->isAdmin() && !$login->isStaff() && !$login->isGroupManager() && $this->id == '') {
if ($this->preferences->pref_bool_create_member) {
- $this->_parent = $login->id;
+ $this->parent = $login->id;
}
}
foreach ($fields as $field) {
if (
$field !== 'date_modif_adh'
- || empty($this->_id)
+ || empty($this->id)
) {
- $prop = '_' . $this->fields[$field]['propname'];
+ $prop = $this->fields[$field]['propname'];
if (
($field === 'bool_admin_adh'
|| $field === 'bool_exempt_adh'
$values[$field] = $this->zdb->isPostgres() ? 'false' : 0;
} elseif ($field === 'parent_id') {
//handle parents
- if (!isset($this->_parent)) {
+ if (!isset($this->parent)) {
$values['parent_id'] = new Expression('NULL');
} elseif ($this->parent instanceof Adherent) {
- $values['parent_id'] = $this->_parent->id;
+ $values['parent_id'] = $this->parent->id;
} else {
- $values['parent_id'] = $this->_parent;
+ $values['parent_id'] = $this->parent;
}
} else {
$values[$field] = $this->$prop;
//an empty value will cause date to be set to 1901-01-01, a null
//will result in 0000-00-00. We want a database NULL value here.
- if (!$this->_birthdate) {
+ if (!$this->birthdate) {
$values['ddn_adh'] = new Expression('NULL');
}
- if (!$this->_due_date) {
+ if (!$this->due_date) {
$values['date_echeance'] = new Expression('NULL');
}
- if ($this->_title instanceof Title) {
- $values['titre_adh'] = $this->_title->id;
+ if ($this->title instanceof Title) {
+ $values['titre_adh'] = $this->title->id;
} else {
$values['titre_adh'] = new Expression('NULL');
}
- if (!$this->_parent) {
+ if (!$this->parent) {
$values['parent_id'] = new Expression('NULL');
}
- if (!$this->_number) {
+ if (!$this->number) {
$values['num_adh'] = new Expression('NULL');
}
//fields that cannot be null
$notnull = [
- '_surname' => 'prenom_adh',
- '_nickname' => 'pseudo_adh',
- '_address' => 'adresse_adh',
- '_zipcode' => 'cp_adh',
- '_town' => 'ville_adh',
- '_region' => 'region_adh'
+ 'surname' => 'prenom_adh',
+ 'nickname' => 'pseudo_adh',
+ 'address' => 'adresse_adh',
+ 'zipcode' => 'cp_adh',
+ 'town' => 'ville_adh',
+ 'region' => 'region_adh'
];
foreach ($notnull as $prop => $field) {
if (!isset($this->$prop) || $this->$prop === null) {
}
}
- if (empty($this->_id)) {
+ if (empty($this->id)) {
//we're inserting a new member
unset($values[self::PK]);
//set modification date
- $this->_modification_date = date('Y-m-d');
- $values['date_modif_adh'] = $this->_modification_date;
+ $this->modification_date = date('Y-m-d');
+ $values['date_modif_adh'] = $this->modification_date;
$insert = $this->zdb->insert(self::TABLE);
$insert->values($values);
$add = $this->zdb->execute($insert);
if ($add->count() > 0) {
- $this->_id = $this->zdb->getLastGeneratedValue($this);
- $this->_picture = new Picture($this->_id);
+ $this->id = $this->zdb->getLastGeneratedValue($this);
+ $this->picture = new Picture($this->id);
// logging
- if ($this->_self_adh) {
+ if ($this->self_adh) {
$hist->add(
_T("Self_subscription as a member: ") .
- $this->getNameWithCase($this->_name, $this->_surname),
+ $this->getNameWithCase($this->name, $this->surname),
$this->sname
);
} else {
//we're editing an existing member
if (!$this->isDueFree()) {
// deadline
- $due_date = Contribution::getDueDate($this->zdb, $this->_id);
+ $due_date = Contribution::getDueDate($this->zdb, $this->id);
if ($due_date) {
$values['date_echeance'] = $due_date;
}
}
- if (!$this->_password) {
+ if (!$this->password) {
unset($values['mdp_adh']);
}
$update = $this->zdb->update(self::TABLE);
$update->set($values);
- $update->where([self::PK => $this->_id]);
+ $update->where([self::PK => $this->id]);
$edit = $this->zdb->execute($update);
$update = $this->zdb->update(self::TABLE);
$update->set(
array('date_modif_adh' => $modif_date)
- )->where([self::PK => $this->_id]);
+ )->where([self::PK => $this->id]);
$this->zdb->execute($update);
- $this->_modification_date = $modif_date;
+ $this->modification_date = $modif_date;
} catch (Throwable $e) {
Analog::log(
'Something went wrong updating modif date :\'( | ' .
}
if (in_array($name, $virtuals)) {
- if (substr($name, 0, 1) !== '_') {
- $real = '_' . substr($name, 1);
- } else {
- $real = $name;
- }
switch ($name) {
case 'sadmin':
return (($this->isAdmin()) ? _T("Yes") : _T("No"));
case 'sappears_in_list':
return (($this->appearsInMembersList()) ? _T("Yes") : _T("No"));
case 'sstaff':
- return (($this->$real) ? _T("Yes") : _T("No"));
+ return (($this->isStaff()) ? _T("Yes") : _T("No"));
case 'sactive':
return (($this->isActive()) ? _T("Active") : _T("Inactive"));
case 'stitle':
- if (isset($this->_title) && $this->_title instanceof Title) {
- return $this->_title->tshort;
+ if (isset($this->title) && $this->title instanceof Title) {
+ return $this->title->tshort;
} else {
return null;
}
case 'sstatus':
$status = new Status($this->zdb);
- return $status->getLabel($this->_status);
+ return $status->getLabel($this->status);
case 'sfullname':
return $this->getNameWithCase(
- $this->_name ?? '',
- $this->_surname ?? '',
- (isset($this->_title) ? $this->title : false)
+ $this->name,
+ $this->surname,
+ ($this->title ?? false)
);
case 'saddress':
- $address = $this->_address;
- return $address;
+ return $this->address;
case 'sname':
- return $this->getNameWithCase($this->_name, $this->_surname);
+ return $this->getNameWithCase($this->name, $this->surname);
case 'rbirthdate':
- return $this->_birthdate;
+ return $this->birthdate;
case 'sgender':
switch ($this->gender) {
case self::MAN:
//for backward compatibility
if (in_array($name, $socials)) {
- $values = Social::getListForMember($this->_id, $name);
+ $values = Social::getListForMember($this->id, $name);
return $values[0] ?? null;
}
- if (substr($name, 0, 1) !== '_') {
- $rname = '_' . $name;
- } else {
- $rname = $name;
- }
-
switch ($name) {
case 'id':
case 'id_statut':
- if (isset($this->$rname) && $this->$rname !== null) {
- return (int)$this->$rname;
+ if (isset($this->$name) && $this->$name !== null) {
+ return (int)$this->$name;
} else {
return null;
}
case 'address':
- return $this->$rname ?? '';
+ return $this->$name ?? '';
case 'birthdate':
case 'creation_date':
case 'modification_date':
case 'due_date':
- if (isset($this->$rname) && $this->$rname != '') {
+ if (isset($this->$name) && $this->$name != '') {
try {
- $d = new DateTime($this->$rname);
+ $d = new DateTime($this->$name);
return $d->format(__("Y-m-d"));
} catch (Throwable $e) {
//oops, we've got a bad date :/
Analog::log(
- 'Bad date (' . $this->$rname . ') | ' .
+ 'Bad date (' . $this->$name . ') | ' .
$e->getMessage(),
Analog::INFO
);
- return $this->$rname;
+ return $this->$name;
}
}
return null;
case 'parent_id':
- return ($this->_parent instanceof Adherent) ? $this->_parent->id : (int)$this->_parent;
+ return ($this->parent instanceof Adherent) ? $this->parent->id : (int)$this->parent;
default:
- if (!property_exists($this, $rname)) {
+ if (!property_exists($this, $name)) {
Analog::log(
- "Unknown property '$rname'",
+ "Unknown property '$name'",
Analog::WARNING
);
return null;
} else {
- if (isset($this->$rname)) {
- return $this->$rname;
+ if (isset($this->$name)) {
+ return $this->$name;
}
return null;
}
return true;
}
- if (substr($name, 0, 1) !== '_') {
- $rname = '_' . $name;
- } else {
- $rname = $name;
- }
-
switch ($name) {
case 'id':
case 'id_statut':
case 'parent_id':
return true;
default:
- return property_exists($this, $rname);
+ return property_exists($this, $name);
}
}
*/
public function getEmail(): string
{
- $email = $this->_email;
+ $email = $this->email;
if (empty($email) && $this->hasParent()) {
$this->loadParent();
$email = $this->parent->email;
*/
public function getAddress(): string
{
- $address = $this->_address;
+ $address = $this->address;
if (empty($address) && $this->hasParent()) {
$this->loadParent();
$address = $this->parent->address;
*/
public function getZipcode(): string
{
- $address = $this->_address;
- $zip = $this->_zipcode;
+ $address = $this->address;
+ $zip = $this->zipcode;
if (empty($address) && $this->hasParent()) {
$this->loadParent();
$zip = $this->parent->zipcode;
*/
public function getTown(): string
{
- $address = $this->_address;
- $town = $this->_town;
+ $address = $this->address;
+ $town = $this->town;
if (empty($address) && $this->hasParent()) {
$this->loadParent();
$town = $this->parent->town;
*/
public function getRegion(): string
{
- $address = $this->_address;
- $region = $this->_region;
+ $address = $this->address;
+ $region = $this->region;
if (empty($address) && $this->hasParent()) {
$this->loadParent();
$region = $this->parent->region;
*/
public function getCountry(): string
{
- $address = $this->_address;
- $country = $this->_country;
+ $address = $this->address;
+ $country = $this->country;
if (empty($address) && $this->hasParent()) {
$this->loadParent();
$country = $this->parent->country;
*/
public function getAge(): string
{
- if (!isset($this->_birthdate) && $this->_birthdate == null) {
+ if (!isset($this->birthdate) && $this->birthdate == null) {
return '';
}
- $d = DateTime::createFromFormat('Y-m-d', $this->_birthdate);
+ $d = DateTime::createFromFormat('Y-m-d', $this->birthdate);
if ($d === false) {
Analog::log(
- 'Invalid birthdate: ' . $this->_birthdate,
+ 'Invalid birthdate: ' . $this->birthdate,
Analog::ERROR
);
return '';
public function setDuplicate(): void
{
//mark as duplicated
- $this->_duplicate = true;
- $infos = $this->_others_infos_admin;
- $this->_others_infos_admin = str_replace(
+ $this->duplicate = true;
+ $infos = $this->others_infos_admin;
+ $this->others_infos_admin = str_replace(
['%name', '%id'],
- [$this->sname, $this->_id],
+ [$this->sname, $this->id],
_T('Duplicated from %name (%id)')
);
if (!empty($infos)) {
- $this->_others_infos_admin .= "\n" . $infos;
+ $this->others_infos_admin .= "\n" . $infos;
}
//drop id_adh
- $this->_id = null;
+ $this->id = null;
//drop email, must be unique
- $this->_email = null;
+ $this->email = null;
//drop creation date
- $this->_creation_date = date("Y-m-d");
+ $this->creation_date = date("Y-m-d");
//drop login
- $this->_login = null;
+ $this->login = null;
//reset picture
- $this->_picture = new Picture();
+ $this->picture = new Picture();
//remove birthdate
- $this->_birthdate = null;
+ $this->birthdate = null;
//remove surname
- $this->_surname = null;
+ $this->surname = null;
//not admin
- $this->_admin = false;
+ $this->admin = false;
//not due free
- $this->_due_free = false;
+ $this->due_free = false;
}
/**
if (!$this->isDepEnabled('groups')) {
$this->loadGroups();
}
- return $this->_groups;
+ return $this->groups;
}
/**
if (!$this->isDepEnabled('groups')) {
$this->loadGroups();
}
- return $this->_managed_groups;
+ return $this->managed_groups;
}
/**
global $preferences;
//admin and staff users can edit, as well as member itself
- if ($this->id && $login->id == $this->id || $login->isAdmin() || $login->isStaff()) {
+ if (isset($this->id) && $login->id == $this->id || $login->isAdmin() || $login->isStaff()) {
return true;
}
*/
public function isDuplicate(): bool
{
- return $this->_duplicate;
+ return $this->duplicate;
}
/**
*/
public function setParent(int $id): self
{
- $this->_parent = $id;
+ $this->parent = $id;
$this->loadParent();
return $this;
}
*/
public function getDueStatus(): int
{
- return $this->_due_status;
+ return $this->due_status;
}
/**
namespace Galette\Entity;
use ArrayObject;
+use DateInterval;
use DateTime;
use Galette\Events\GaletteEvent;
use Galette\Features\HasEvent;
public const STATUS_LATE = 4;
public const STATUS_OLD = 5;
- private int $_id;
- private ?string $_date = null;
- private ?int $_member = null;
- private ?ContributionsTypes $_type = null;
- private ?float $_amount = null;
- private ?int $_payment_type;
- private ?float $_orig_amount = null;
- private ?string $_info = null;
- private ?string $_begin_date = null;
- private ?string $_end_date = null;
- private ?Transaction $_transaction = null;
- private bool $_is_cotis;
- private ?int $_extension = null;
+ private int $id;
+ private ?string $date = null;
+ private ?int $member = null;
+ private ?ContributionsTypes $type = null;
+ private ?float $amount = null;
+ private ?int $payment_type;
+ private ?float $orig_amount = null;
+ private ?string $info = null;
+ private ?string $begin_date = null;
+ private ?string $end_date = null;
+ private ?Transaction $transaction = null;
+ private bool $is_cotis;
+ private ?int $extension = null;
/** @var array<int, PaymentType> */
private array $ptypes_list;
$this->login = $login;
global $preferences;
- $this->_payment_type = $preferences->pref_default_paymenttype;
+ $this->payment_type = $preferences->pref_default_paymenttype;
$this
->setFields()
if (is_int($args)) {
$this->load($args);
} elseif (is_array($args)) {
- $this->_date = date("Y-m-d");
+ $this->date = date("Y-m-d");
if (isset($args['adh']) && $args['adh'] != '') {
- $this->_member = (int)$args['adh'];
+ $this->member = (int)$args['adh'];
}
if (isset($args['trans'])) {
- $this->_transaction = new Transaction($this->zdb, $this->login, (int)$args['trans']);
- if (!isset($this->_member)) {
- $this->_member = $this->_transaction->member;
+ $this->transaction = new Transaction($this->zdb, $this->login, (int)$args['trans']);
+ if (!isset($this->member)) {
+ $this->member = $this->transaction->member;
}
- $this->_amount = $this->_transaction->getMissingAmount();
+ $this->amount = $this->transaction->getMissingAmount();
}
$this->setContributionType((int)$args['type']);
//calculate begin date for membership fee
- $this->_begin_date = $this->_date;
- if ($this->_is_cotis) {
- $due_date = self::getDueDate($this->zdb, $this->_member);
+ $this->begin_date = $this->date;
+ if ($this->is_cotis) {
+ $due_date = self::getDueDate($this->zdb, $this->member);
if ($due_date != '') {
$now = new \DateTime();
$due_date = new \DateTime($due_date);
if ($due_date < $now) {
// Member didn't renew on time
- $this->_begin_date = $now->format('Y-m-d');
+ $this->begin_date = $now->format('Y-m-d');
} else {
// Caution : the next_begin_date is the day after the due_date.
$next_begin_date = clone $due_date;
$next_begin_date->add(new \DateInterval('P1D'));
- $this->_begin_date = $next_begin_date->format('Y-m-d');
+ $this->begin_date = $next_begin_date->format('Y-m-d');
}
}
$this->retrieveEndDate();
}
if (isset($args['payment_type'])) {
- $this->_payment_type = $args['payment_type'];
+ $this->payment_type = $args['payment_type'];
}
} elseif (is_object($args)) {
$this->loadFromRS($args);
global $preferences;
$now = new \DateTime();
- $begin_date = new \DateTime($this->_begin_date);
+ $begin_date = new \DateTime($this->begin_date);
if ($preferences->pref_beg_membership != '') {
//case beginning of membership
list($j, $m) = explode('/', $preferences->pref_beg_membership);
- $next_begin_date = new \DateTime($begin_date->format('Y') . '-' . $m . '-' . $j);
+ $next_begin_date = new DateTime($begin_date->format('Y') . '-' . $m . '-' . $j);
while ($next_begin_date <= $begin_date) {
$next_begin_date->add(new \DateInterval('P1Y'));
}
// Caution : the end_date to retrieve is the day before the next_begin_date.
$end_date = clone $next_begin_date;
$end_date->sub(new \DateInterval('P1D'));
- $this->_end_date = $end_date->format('Y-m-d');
+ $this->end_date = $end_date->format('Y-m-d');
} elseif ($preferences->pref_membership_ext != '') {
//case membership extension
- if ($this->_extension == null) {
- $this->_extension = $preferences->pref_membership_ext;
+ if ($this->extension == null) {
+ $this->extension = $preferences->pref_membership_ext;
}
- $dext = new \DateInterval('P' . $this->_extension . 'M');
+ $dext = new \DateInterval('P' . $this->extension . 'M');
// Caution : the end_date to retrieve is the day before the next_begin_date.
$next_begin_date = $begin_date->add($dext);
$end_date = clone $next_begin_date;
$end_date->sub(new \DateInterval('P1D'));
- $this->_end_date = $end_date->format('Y-m-d');
+ $this->end_date = $end_date->format('Y-m-d');
} else {
throw new \RuntimeException(
'Unable to define end date; none of pref_beg_membership nor pref_membership_ext are defined!'
private function loadFromRS(ArrayObject $r): void
{
$pk = self::PK;
- $this->_id = (int)$r->$pk;
- $this->_date = $r->date_enreg;
- $this->_amount = (double)$r->montant_cotis;
+ $this->id = (int)$r->$pk;
+ $this->date = $r->date_enreg;
+ $this->amount = (double)$r->montant_cotis;
//save original amount, we need it for transactions parts calculations
- $this->_orig_amount = (double)$r->montant_cotis;
- $this->_payment_type = $r->type_paiement_cotis;
- $this->_info = $r->info_cotis;
- $this->_begin_date = $r->date_debut_cotis;
+ $this->orig_amount = (double)$r->montant_cotis;
+ $this->payment_type = $r->type_paiement_cotis;
+ $this->info = $r->info_cotis;
+ $this->begin_date = $r->date_debut_cotis;
$end_date = $r->date_fin_cotis;
//do not work with knows bad dates...
//the one with BC comes from 0.63/pgsql demo... Why the hell a so
&& $end_date !== '1901-01-01'
&& $end_date !== '0001-01-01 BC'
) {
- $this->_end_date = $r->date_fin_cotis;
+ $this->end_date = $r->date_fin_cotis;
}
$adhpk = Adherent::PK;
- $this->_member = (int)$r->$adhpk;
+ $this->member = (int)$r->$adhpk;
$transpk = Transaction::PK;
if ($r->$transpk != '') {
- $this->_transaction = new Transaction($this->zdb, $this->login, (int)$r->$transpk);
+ $this->transaction = new Transaction($this->zdb, $this->login, (int)$r->$transpk);
}
$this->setContributionType((int)$r->id_type_cotis);
foreach ($fields as $key) {
//first, let's sanitize values
$key = strtolower($key);
- $prop = '_' . $this->fields[$key]['propname'];
+ $prop = $this->fields[$key]['propname'];
if (isset($values[$key])) {
$value = trim($values[$key]);
break;
case Adherent::PK:
if ($value != '') {
- $this->_member = (int)$value;
+ $this->member = (int)$value;
}
break;
case ContributionsTypes::PK:
case 'montant_cotis':
$value = strtr($value, ',', '.');
if (!empty($value) || $value === '0') {
- $this->_amount = (double)$value;
+ $this->amount = (double)$value;
}
if (!is_numeric($value) && $value !== '') {
$this->errors[] = _T("- The amount must be an integer!");
break;
case 'type_paiement_cotis':
if ($value != '') {
- $this->_payment_type = (int)$value;
+ $this->payment_type = (int)$value;
}
break;
case 'info_cotis':
- $this->_info = $value;
+ $this->info = $value;
break;
case Transaction::PK:
if ($value != '') {
- $this->_transaction = new Transaction($this->zdb, $this->login, (int)$value);
+ $this->transaction = new Transaction($this->zdb, $this->login, (int)$value);
}
break;
case 'duree_mois_cotis':
// missing required fields?
foreach ($required as $key => $val) {
if ($val === 1) {
- $prop = '_' . $this->fields[$key]['propname'];
+ $prop = $this->fields[$key]['propname'];
if (
!isset($disabled[$key])
&& (!isset($this->$prop)
}
}
- if ($this->_transaction != null && $this->_amount != null) {
- $missing = $this->_transaction->getMissingAmount();
+ if ($this->transaction != null && $this->amount != null) {
+ $missing = $this->transaction->getMissingAmount();
//calculate new missing amount
- $missing = $missing + $this->_orig_amount - $this->_amount;
+ $missing = $missing + $this->orig_amount - $this->amount;
if ($missing < 0) {
$this->errors[] = _T("- Sum of all contributions exceed corresponding transaction amount.");
}
array('ct' => PREFIX_DB . ContributionsTypes::TABLE),
'c.' . ContributionsTypes::PK . '=ct.' . ContributionsTypes::PK,
array()
- )->where([Adherent::PK => $this->_member])
+ )->where([Adherent::PK => $this->member])
->where(array('cotis_extension' => new Expression('true')))
->where->nest->nest
- ->greaterThanOrEqualTo('date_debut_cotis', $this->_begin_date)
- ->lessThanOrEqualTo('date_debut_cotis', $this->_end_date)
+ ->greaterThanOrEqualTo('date_debut_cotis', $this->begin_date)
+ ->lessThanOrEqualTo('date_debut_cotis', $this->end_date)
->unnest
->or->nest
- ->greaterThanOrEqualTo('date_fin_cotis', $this->_begin_date)
- ->lessThanOrEqualTo('date_fin_cotis', $this->_end_date);
+ ->greaterThanOrEqualTo('date_fin_cotis', $this->begin_date)
+ ->lessThanOrEqualTo('date_fin_cotis', $this->end_date);
- if ($this->id != '') {
+ if (isset($this->id)) {
$select->where->notEqualTo(self::PK, $this->id);
}
$d_begin = new \DateTime($result->date_debut_cotis);
$d_end = new \DateTime($result->date_fin_cotis);
- if ($d_begin->format('m-d') == $d_end->format('m-d') && $result->date_fin_cotis == $this->_begin_date) {
+ if ($d_begin->format('m-d') == $d_end->format('m-d') && $result->date_fin_cotis == $this->begin_date) {
//see https://bugs.galette.eu/issues/1762
return true;
}
$values = array();
$fields = self::getDbFields($this->zdb);
foreach ($fields as $field) {
- $prop = '_' . $this->fields[$field]['propname'];
+ $prop = $this->fields[$field]['propname'];
if (!isset($this->$prop)) {
continue;
}
}
//no end date, let's take database defaults
- if (!$this->isFee() && !$this->_end_date) {
+ if (!$this->isFee() && !$this->end_date) {
unset($values['date_fin_cotis']);
}
- if (!isset($this->_id) || $this->_id == '') {
+ if (!isset($this->id) || $this->id == '') {
//we're inserting a new contribution
unset($values[self::PK]);
$add = $this->zdb->execute($insert);
if ($add->count() > 0) {
- $this->_id = $this->zdb->getLastGeneratedValue($this);
+ $this->id = $this->zdb->getLastGeneratedValue($this);
// logging
$hist->add(
_T("Contribution added"),
- Adherent::getSName($this->zdb, $this->_member)
+ Adherent::getSName($this->zdb, $this->member)
);
$event = $this->getAddEventName();
} else {
} else {
//we're editing an existing contribution
$update = $this->zdb->update(self::TABLE);
- $update->set($values)->where([self::PK => $this->_id]);
+ $update->set($values)->where([self::PK => $this->id]);
$edit = $this->zdb->execute($update);
//edit == 0 does not mean there were an error, but that there
if ($edit->count() > 0) {
$hist->add(
_T("Contribution updated"),
- Adherent::getSName($this->zdb, $this->_member)
+ Adherent::getSName($this->zdb, $this->member)
);
}
$this->dynamicsStore(true);
$this->zdb->connection->commit();
- $this->_orig_amount = $this->_amount;
+ $this->orig_amount = $this->amount;
//send event at the end of process, once all has been stored
if ($event !== null && $this->areEventsEnabled()) {
private function updateDeadline(): bool
{
try {
- $due_date = self::getDueDate($this->zdb, $this->_member);
+ $due_date = self::getDueDate($this->zdb, $this->member);
if ($due_date != '') {
$due_date_update = $due_date;
$update->set(
array('date_echeance' => $due_date_update)
)->where(
- [Adherent::PK => $this->_member]
+ [Adherent::PK => $this->member]
);
$this->zdb->execute($update);
return true;
} catch (Throwable $e) {
Analog::log(
- 'An error occurred updating member ' . $this->_member .
+ 'An error occurred updating member ' . $this->member .
'\'s deadline |' .
$e->getMessage(),
Analog::ERROR
}
$delete = $this->zdb->delete(self::TABLE);
- $delete->where([self::PK => $this->_id]);
+ $delete->where([self::PK => $this->id]);
$del = $this->zdb->execute($delete);
if ($del->count() > 0) {
$this->updateDeadline();
}
Analog::log(
'An error occurred trying to remove contribution #' .
- $this->_id . ' | ' . $e->getMessage(),
+ $this->id . ' | ' . $e->getMessage(),
Analog::ERROR
);
throw $e;
*/
public function getFieldLabel(string $field, string $entry = 'label'): string
{
- if ($field == 'date_debut_cotis' && !empty($this->_is_cotis) && $this->isFee()) {
+ if ($field == 'date_debut_cotis' && !empty($this->is_cotis) && $this->isFee()) {
$entry = 'cotlabel';
}
return $this->trait_getFieldLabel($field, $entry);
*/
public function getRowClass(): string
{
- return ($this->_end_date != $this->_begin_date && $this->_is_cotis) ?
+ return ($this->end_date != $this->begin_date && $this->is_cotis) ?
'cotis-normal' : 'cotis-give';
}
*/
public function isFee(): bool
{
- return $this->_is_cotis;
+ return $this->is_cotis;
}
/**
public function isTransactionPartOf(int $id): bool
{
if ($this->isTransactionPart()) {
- return $id == $this->_transaction->id;
+ return $id == $this->transaction->id;
} else {
return false;
}
*/
public function isTransactionPart(): bool
{
- return $this->_transaction != null;
+ return $this->transaction != null;
}
/**
}
$voucher_path = null;
- if (isset($this->_id)) {
+ if (isset($this->id)) {
$voucher = new PdfContribution($this, $this->zdb, $preferences);
$voucher->store(GALETTE_CACHE_DIR . '/pdf_contribs');
$voucher_path = $voucher->getPath();
}
$contrib = array(
- 'id' => $this->_id,
- 'date' => $this->_date,
+ 'id' => $this->id,
+ 'date' => $this->date,
'type' => $this->getRawType(),
'amount' => $this->amount,
'voucher' => $voucher_path,
'payment' => $payment
);
- if ($this->_member !== null) {
- $m = new Adherent($this->zdb, (int)$this->_member);
+ if ($this->member !== null) {
+ $m = new Adherent($this->zdb, (int)$this->member);
$member = array(
- 'id' => (int)$this->_member,
+ 'id' => (int)$this->member,
'name' => $m->sfullname,
'email' => $m->email,
'organization' => ($m->isCompany() ? 1 : 0),
*/
public function getPaymentType(): string
{
- if ($this->_payment_type === null) {
+ if ($this->payment_type === null) {
return '-';
}
*/
public function __get(string $name)
{
- $rname = '_' . $name;
-
if (in_array($name, $this->forbidden_fields)) {
Analog::log(
"Call to __get for '$name' is forbidden!",
throw new \RuntimeException("Call to __get for '$name' is forbidden!");
}
} elseif (
- property_exists($this, $rname)
- || property_exists($this, $name)
+ property_exists($this, $name)
|| in_array($name, $this->virtual_fields)
) {
switch ($name) {
case 'raw_date':
case 'raw_begin_date':
case 'raw_end_date':
- $rname = '_' . substr($name, 4);
- return $this->getDate($rname, false);
+ return $this->getDate(substr($name, 4), false);
case 'date':
case 'begin_date':
case 'end_date':
- return $this->getDate($rname);
+ return $this->getDate($name);
case 'duration':
- if (isset($this->_is_cotis)) {
+ if (isset($this->is_cotis)) {
// Caution : the end_date stored is actually the due date.
// Adding a day to compute the next_begin_date is required
// to return the right number of months.
- $next_begin_date = new \DateTime($this->_end_date ?? $this->_begin_date);
- $next_begin_date->add(new \DateInterval('P1D'));
- $begin_date = new \DateTime($this->_begin_date);
+ $next_begin_date = new DateTime($this->end_date ?? $this->begin_date);
+ $next_begin_date->add(new DateInterval('P1D'));
+ $begin_date = new DateTime($this->begin_date);
$diff = $next_begin_date->diff($begin_date);
return (int)$diff->format('%y') * 12 + (int)$diff->format('%m');
} else {
return '';
}
case 'model':
- if (!isset($this->_is_cotis)) {
+ if (!isset($this->is_cotis)) {
return null;
}
return ($this->isFee()) ?
case 'fields':
return $this->fields;
default:
- if (property_exists($this, $rname)) {
- if (isset($this->$rname)) {
- return $this->$rname;
+ if (property_exists($this, $name)) {
+ if (isset($this->$name)) {
+ return $this->$name;
}
} else {
- throw new \LogicException("Property '" . __CLASS__ . "::$rname' does not exist!");
+ throw new \LogicException("Property '" . __CLASS__ . "::$name' does not exist!");
}
}
} else {
Analog::log(
- "Unknown property '$rname'",
+ "Unknown property '$name'",
Analog::WARNING
);
return null;
}
}
- /**
- * Global isset method
- * Required for twig to access properties via __get
- *
- * @param string $name name of the property we want to retrieve
- *
- * @return bool
- */
- public function __isset(string $name): bool
- {
- return $this->trait___isset('_' . $name) || $this->trait___isset($name);
- }
-
-
/**
* Global setter method
*
$forbidden = array('fields', 'is_cotis', 'end_date');
if (!in_array($name, $forbidden)) {
- $rname = '_' . $name;
switch ($name) {
case 'transaction':
if (is_int($value)) {
- $this->$rname = new Transaction($this->zdb, $this->login, $value);
+ $this->$name = new Transaction($this->zdb, $this->login, $value);
} else {
Analog::log(
'Trying to set a transaction from an id that is not an integer.',
$this->setContributionType($value);
break;
case 'begin_date':
- $this->setDate($rname, $value);
+ $this->setDate($name, $value);
break;
case 'amount':
if (is_numeric($value) && $value > 0) {
- $this->$rname = $value;
+ $this->$name = $value;
} else {
Analog::log(
'Trying to set an amount with a non numeric value, ' .
case 'member':
if (is_int($value)) {
//set type
- $this->$rname = $value;
+ $this->$name = $value;
}
break;
case 'payment_type':
}
//admin and staff users can edit, as well as member itself
- if (!$this->id || $login->id == $this->_member || $login->isAdmin() || $login->isStaff()) {
+ if (!isset($this->id) || $login->id == $this->member || $login->isAdmin() || $login->isStaff()) {
return true;
}
->load($this->login->id);
if ($parent->hasChildren()) {
foreach ($parent->children as $child) {
- if ($child->id === $this->_member) {
+ if ($child->id === $this->member) {
return true;
}
}
public function setContributionType(int $type): self
{
//set type
- $this->_type = new ContributionsTypes($this->zdb, $type);
+ $this->type = new ContributionsTypes($this->zdb, $type);
//set is_cotis according to type
- if ($this->_type->extension == 1) {
- $this->_is_cotis = true;
+ if ($this->type->extension == 1) {
+ $this->is_cotis = true;
} else {
- $this->_is_cotis = false;
+ $this->is_cotis = false;
}
return $this;
$this->ptypes_list = $ptypes->getList();
}
if (isset($this->ptypes_list[$value])) {
- $this->_payment_type = $value;
+ $this->payment_type = $value;
} else {
Analog::log(
'Unknown payment type ' . $value,
*/
public function getFields(): ?array
{
- return $this->fields;
+ return $this->fields ?? null;
}
/**
*
* @property integer $id
* @property string $date
- * @property integer $amount
+ * @property float $amount
* @property ?string $description
* @property ?integer $member
* @property ?integer $payment_type
public const TABLE = 'transactions';
public const PK = 'trans_id';
- private int $_id;
- private string $_date;
- private float $_amount;
- private ?string $_description = null;
- private ?int $_member = null;
- private ?int $_payment_type = null;
+ private int $id;
+ private string $date;
+ private float $amount;
+ private ?string $description = null;
+ private ?int $member = null;
+ private ?int $payment_type = null;
private Db $zdb;
private Login $login;
$this->setFields();
if ($args === null || is_int($args)) {
- $this->_date = date("Y-m-d");
+ $this->date = date("Y-m-d");
if (is_int($args) && $args > 0) {
$this->load($args);
$this->zdb->connection->beginTransaction();
}
- //remove associated contributions if needeed
+ //remove associated contributions if needed
if ($this->getDispatchedAmount() > 0) {
$c = new Contributions($this->zdb, $this->login);
- $clist = $c->getListFromTransaction($this->_id);
+ $clist = $c->getListFromTransaction($this->id);
$cids = array();
foreach ($clist as $cid) {
$cids[] = $cid->id;
//remove transaction itself
$delete = $this->zdb->delete(self::TABLE);
- $delete->where([self::PK => $this->_id]);
+ $delete->where([self::PK => $this->id]);
$del = $this->zdb->execute($delete);
if ($del->count() > 0) {
$this->dynamicsRemove(true);
}
Analog::log(
'An error occurred trying to remove transaction #' .
- $this->_id . ' | ' . $e->getMessage(),
+ $this->id . ' | ' . $e->getMessage(),
Analog::ERROR
);
throw $e;
private function loadFromRS(ArrayObject $r): void
{
$pk = self::PK;
- $this->_id = $r->$pk;
- $this->_date = $r->trans_date;
- $this->_amount = $r->trans_amount;
- $this->_description = $r->trans_desc;
+ $this->id = $r->$pk;
+ $this->date = $r->trans_date;
+ $this->amount = $r->trans_amount;
+ $this->description = $r->trans_desc;
$adhpk = Adherent::PK;
- $this->_member = (int)$r->$adhpk;
- $this->_payment_type = $r->type_paiement_trans;
+ $this->member = (int)$r->$adhpk;
+ $this->payment_type = $r->type_paiement_trans;
$this->loadDynamicFields();
}
foreach ($fields as $key) {
//first, let's sanitize values
$key = strtolower($key);
- $prop = '_' . $this->fields[$key]['propname'];
+ $prop = $this->fields[$key]['propname'];
if (isset($values[$key])) {
$value = trim($values[$key]);
$this->setDate($key, $value);
break;
case Adherent::PK:
- $this->_member = (int)$value;
+ $this->member = (int)$value;
break;
case 'trans_amount':
$value = strtr($value, ',', '.');
- $this->_amount = (double)$value;
+ $this->amount = (double)$value;
if (!is_numeric($value)) {
$this->errors[] = _T("- The amount must be an integer!");
}
break;
case 'trans_desc':
/** TODO: retrieve field length from database and check that */
- $this->_description = strip_tags($value);
+ $this->description = strip_tags($value);
if (mb_strlen($value) > 150) {
$this->errors[] = _T("- Transaction description must be 150 characters long maximum.");
}
);
$ptlist = $ptypes->getList();
if (isset($ptlist[$value])) {
- $this->_payment_type = (int)$value;
+ $this->payment_type = (int)$value;
} else {
$this->errors[] = _T("- Unknown payment type");
}
// missing required fields?
foreach ($required as $key => $val) {
if ($val === 1) {
- $prop = '_' . $this->fields[$key]['propname'];
+ $prop = $this->fields[$key]['propname'];
if (!isset($disabled[$key]) && !isset($this->$prop)) {
$this->errors[] = str_replace(
'%field',
}
}
- if (isset($this->_id)) {
+ if (isset($this->id)) {
$dispatched = $this->getDispatchedAmount();
- if ($dispatched > $this->_amount) {
+ if ($dispatched > $this->amount) {
$this->errors[] = _T("- Sum of all contributions exceed corresponding transaction amount.");
}
}
$fields = $this->getDbFields($this->zdb);
/** FIXME: quote? */
foreach ($fields as $field) {
- $prop = '_' . $this->fields[$field]['propname'];
+ $prop = $this->fields[$field]['propname'];
if (isset($this->$prop)) {
$values[$field] = $this->$prop;
}
}
- if (!isset($this->_id) || $this->_id == '') {
+ if (!isset($this->id) || $this->id == '') {
//we're inserting a new transaction
unset($values[self::PK]);
$insert = $this->zdb->insert(self::TABLE);
$insert->values($values);
$add = $this->zdb->execute($insert);
if ($add->count() > 0) {
- $this->_id = $this->zdb->getLastGeneratedValue($this);
+ $this->id = $this->zdb->getLastGeneratedValue($this);
// logging
$hist->add(
_T("Transaction added"),
- Adherent::getSName($this->zdb, $this->_member)
+ Adherent::getSName($this->zdb, $this->member)
);
$event = 'transaction.add';
} else {
} else {
//we're editing an existing transaction
$update = $this->zdb->update(self::TABLE);
- $update->set($values)->where([self::PK => $this->_id]);
+ $update->set($values)->where([self::PK => $this->id]);
$edit = $this->zdb->execute($update);
//edit == 0 does not mean there were an error, but that there
//were nothing to change
if ($edit->count() > 0) {
$hist->add(
_T("Transaction updated"),
- Adherent::getSName($this->zdb, $this->_member)
+ Adherent::getSName($this->zdb, $this->member)
);
}
$event = 'transaction.edit';
*/
public function getDispatchedAmount(): float
{
- if (empty($this->_id)) {
+ if (empty($this->id)) {
return (double)0;
}
array(
'sum' => new Expression('SUM(montant_cotis)')
)
- )->where([self::PK => $this->_id]);
+ )->where([self::PK => $this->id]);
$results = $this->zdb->execute($select);
$result = $results->current();
*/
public function getMissingAmount(): float
{
- if (empty($this->_id)) {
- return (double)$this->amount;
+ if (empty($this->id)) {
+ return $this->amount ?? 0;
}
try {
array(
'sum' => new Expression('SUM(montant_cotis)')
)
- )->where([self::PK => $this->_id]);
+ )->where([self::PK => $this->id]);
$results = $this->zdb->execute($select);
$result = $results->current();
$dispatched_amount = $result->sum;
- return (double)$this->_amount - (double)$dispatched_amount;
+ return (double)$this->amount - (double)$dispatched_amount;
} catch (Throwable $e) {
Analog::log(
'An error occurred retrieving missing amounts | ' .
*/
public function getPaymentType(): string
{
- if ($this->_payment_type === null) {
+ if ($this->payment_type === null) {
return '-';
}
*/
public function __get(string $name)
{
- $rname = '_' . $name;
- if (!in_array($name, $this->forbidden_fields) && (property_exists($this, $rname) || property_exists($this, $name))) {
+ if (!in_array($name, $this->forbidden_fields) && property_exists($this, $name)) {
switch ($name) {
case 'date':
- return $this->getDate($rname);
+ return $this->getDate($name);
case 'id':
- if (isset($this->$rname) && $this->$rname !== null) {
- return (int)$this->$rname;
+ if (isset($this->$name) && $this->$name !== null) {
+ return (int)$this->$name;
}
return null;
case 'amount':
- if (isset($this->$rname)) {
- return (double)$this->$rname;
+ if (isset($this->$name)) {
+ return (double)$this->$name;
}
return null;
case 'fields':
return $this->fields;
default:
- return $this->$rname;
+ return $this->$name;
}
} else {
Analog::log(
}
//admin and staff users can edit, as well as member itself
- if (!$this->id || $login->id == $this->_member || $login->isAdmin() || $login->isStaff()) {
+ if (!isset($this->id) || $login->id == $this->member || $login->isAdmin() || $login->isStaff()) {
return true;
}
->load($this->login->id);
if ($parent->hasChildren()) {
foreach ($parent->children as $child) {
- if ($child->id === $this->_member) {
+ if ($child->id === $this->member) {
return true;
}
}
trait Dependencies
{
/** @var array<string, bool> */
- protected array $_deps = array(
+ protected array $deps = array(
'picture' => true,
'groups' => true,
'dues' => true,
*/
public function setDeps(array $deps): self
{
- $this->_deps = array_merge(
- $this->_deps,
+ $this->deps = array_merge(
+ $this->deps,
$deps
);
return $this;
*/
public function disableAllDeps(): self
{
- $this->_deps = array_fill_keys(
- array_keys($this->_deps),
+ $this->deps = array_fill_keys(
+ array_keys($this->deps),
false
);
return $this;
*/
public function enableAllDeps(): self
{
- foreach ($this->_deps as &$dep) {
+ foreach ($this->deps as &$dep) {
$dep = true;
}
return $this;
*/
public function enableDep(string $name): self
{
- if (!isset($this->_deps[$name])) {
+ if (!isset($this->deps[$name])) {
Analog::log(
'dependency ' . $name . ' does not exists!',
Analog::WARNING
);
} else {
- $this->_deps[$name] = true;
+ $this->deps[$name] = true;
}
return $this;
*/
public function disableDep(string $name): self
{
- if (!isset($this->_deps[$name])) {
+ if (!isset($this->deps[$name])) {
Analog::log(
'dependency ' . $name . ' does not exists!',
Analog::WARNING
);
} else {
- $this->_deps[$name] = false;
+ $this->deps[$name] = false;
}
return $this;
*/
protected function isDepEnabled(string $name): bool
{
- return $this->_deps[$name];
+ return $this->deps[$name];
}
}
namespace Galette\Features;
+use Galette\Core\Login;
use Galette\Entity\Adherent;
use Galette\Repository\DynamicFieldsSet;
use Throwable;
*/
private function loadDynamicFields(): void
{
- if (!property_exists($this, 'login')) {
- global $login;
- } else {
+ /** @phpstan-ignore-next-line */
+ if (property_exists($this, 'login') && ($this->login ?? null) instanceof Login) {
$login = $this->login;
+ } else {
+ global $login;
}
$this->dynamics = new DynamicFieldsHandle($this->zdb, $login, $this);
}
}
//actual field value
if ($value !== null && trim($value) !== '') {
- $this->dynamics->setValue($this->id, $field_id, $val_index, $value);
+ $this->dynamics->setValue($this->id ?? null, $field_id, $val_index, $value);
} else {
$this->dynamics->unsetValue($field_id, $val_index);
}
*
* @author Johan Cwiklinski <johan@x-tnd.be>
*
- * @property string $creation_date_begin
- * @property string $creation_date_end
- * @property string $modif_date_begin
- * @property string $modif_date_end
- * @property string $due_date_begin
- * @property string $due_date_end
- * @property string $birth_date_begin
- * @property string $birth_date_end
- * @property boolean $show_public_infos
+ * @property ?string $creation_date_begin
+ * @property ?string $creation_date_end
+ * @property ?string $modif_date_begin
+ * @property ?string $modif_date_end
+ * @property ?string $due_date_begin
+ * @property ?string $due_date_end
+ * @property ?string $birth_date_begin
+ * @property ?string $birth_date_end
+ * @property int $show_public_infos
* @property array|integer $status
- * @property string $contrib_creation_date_begin
- * @property string $contrib_creation_date_end
- * @property string $contrib_begin_date_begin
- * @property string $contrib_begin_date_end
- * @property string $contrib_end_date_begin
- * @property string $contrib_end_date_end
+ * @property ?string $contrib_creation_date_begin
+ * @property ?string $contrib_creation_date_end
+ * @property ?string $contrib_begin_date_begin
+ * @property ?string $contrib_begin_date_end
+ * @property ?string $contrib_end_date_begin
+ * @property ?string $contrib_end_date_end
* @property array $contributions_types
* @property array $payments_types
- * @property integer $contrib_min_amount
- * @property integer $contrib_max_amount
+ * @property ?float $contrib_min_amount
+ * @property ?float $contrib_max_amount
* @property array $contrib_dynamic
* @property array $free_search
* @property array $groups_search
* @property integer $groups_search_log_op
*
- * @property-read string $rcreation_date_begin
- * @property-read string $rcreation_date_end
- * @property-read string $rmodif_date_begin
- * @property-read string $rmodif_date_end
- * @property-read string $rdue_date_begin
- * @property-read string $rdue_date_end
- * @property-read string $rbirth_date_begin
- * @property-read string $rbirth_date_end
- * @property-read string $rcontrib_creation_date_begin
- * @property-read string $rcontrib_creation_date_end
- * @property-read string $rcontrib_begin_date_begin
- * @property-read string $rcontrib_begin_date_end
- * @property-read string $rcontrib_end_date_begin
- * @property-read string $rcontrib_end_date_end
+ * @property-read ?string $rcreation_date_begin
+ * @property-read ?string $rcreation_date_end
+ * @property-read ?string $rmodif_date_begin
+ * @property-read ?string $rmodif_date_end
+ * @property-read ?string $rdue_date_begin
+ * @property-read ?string $rdue_date_end
+ * @property-read ?string $rbirth_date_begin
+ * @property-read ?string $rbirth_date_end
+ * @property-read ?string $rcontrib_creation_date_begin
+ * @property-read ?string $rcontrib_creation_date_end
+ * @property-read ?string $rcontrib_begin_date_begin
+ * @property-read ?string $rcontrib_begin_date_end
+ * @property-read ?string $rcontrib_end_date_begin
+ * @property-read ?string $rcontrib_end_date_end
* @property-read array $search_fields
*/
public const OP_BEFORE = 6;
public const OP_AFTER = 7;
- private ?string $_creation_date_begin = null;
- private ?string $_creation_date_end = null;
- private ?string $_modif_date_begin = null;
- private ?string $_modif_date_end = null;
- private ?string $_due_date_begin = null;
- private ?string $_due_date_end = null;
- private ?string $_birth_date_begin = null;
- private ?string $_birth_date_end = null;
- private int $_show_public_infos = Members::FILTER_DC_PUBINFOS;
+ private ?string $creation_date_begin = null;
+ private ?string $creation_date_end = null;
+ private ?string $modif_date_begin = null;
+ private ?string $modif_date_end = null;
+ private ?string $due_date_begin = null;
+ private ?string $due_date_end = null;
+ private ?string $birth_date_begin = null;
+ private ?string $birth_date_end = null;
+ private int $show_public_infos = Members::FILTER_DC_PUBINFOS;
/** @var array<int> */
- private array $_status = array();
- private ?string $_contrib_creation_date_begin = null;
- private ?string $_contrib_creation_date_end = null;
- private ?string $_contrib_begin_date_begin = null;
- private ?string $_contrib_begin_date_end = null;
- private ?string $_contrib_end_date_begin = null;
- private ?string $_contrib_end_date_end = null;
+ private array $status = array();
+ private ?string $contrib_creation_date_begin = null;
+ private ?string $contrib_creation_date_end = null;
+ private ?string $contrib_begin_date_begin = null;
+ private ?string $contrib_begin_date_end = null;
+ private ?string $contrib_end_date_begin = null;
+ private ?string $contrib_end_date_end = null;
/** @var array<int> */
- private array $_contributions_types = array();
+ private array $contributions_types = array();
/** @var array<int> */
- private array $_payments_types = array();
- private ?int $_contrib_min_amount = null;
- private ?int $_contrib_max_amount = null;
+ private array $payments_types = array();
+ private ?float $contrib_min_amount = null;
+ private ?float $contrib_max_amount = null;
/** @var array<string> */
protected array $advancedmemberslist_fields = array(
*
* @var array<string,mixed>
*/
- private array $_free_search = array(
+ private array $free_search = array(
'empty' => array(
'field' => '',
'search' => '',
*
* @var array<string,mixed>
*/
- private array $_groups_search = array(
+ private array $groups_search = array(
'empty' => array(
'group' => '',
)
);
//defaults to 'OR' for group search
- private int $_groups_search_log_op = self::OP_OR;
+ private int $groups_search_log_op = self::OP_OR;
/**
* an empty contributions dynamic field criteria to begin
*
* @var array<string,mixed>
*/
- private array $_contrib_dynamic = array();
+ private array $contrib_dynamic = array();
/**
* Default constructor
public function withinContributions(): bool
{
if (
- $this->_contrib_creation_date_begin != null
- || $this->_contrib_creation_date_end != null
- || $this->_contrib_begin_date_begin != null
- || $this->_contrib_begin_date_end != null
- || $this->_contrib_end_date_begin != null
- || $this->_contrib_end_date_end != null
- || $this->_contrib_min_amount != null
- || $this->_contrib_max_amount != null
- || count($this->_contrib_dynamic) > 0
- || count($this->_contributions_types) > 0
- || count($this->_payments_types) > 0
+ $this->contrib_creation_date_begin != null
+ || $this->contrib_creation_date_end != null
+ || $this->contrib_begin_date_begin != null
+ || $this->contrib_begin_date_end != null
+ || $this->contrib_end_date_begin != null
+ || $this->contrib_end_date_end != null
+ || $this->contrib_min_amount != null
+ || $this->contrib_max_amount != null
+ || count($this->contrib_dynamic) > 0
+ || count($this->contributions_types) > 0
+ || count($this->payments_types) > 0
) {
return true;
} else {
{
parent::reinit();
- $this->_creation_date_begin = null;
- $this->_creation_date_end = null;
- $this->_modif_date_begin = null;
- $this->_modif_date_end = null;
- $this->_due_date_begin = null;
- $this->_due_date_end = null;
- $this->_birth_date_begin = null;
- $this->_birth_date_end = null;
- $this->_show_public_infos = Members::FILTER_DC_PUBINFOS;
- $this->_status = array();
-
- $this->_contrib_creation_date_begin = null;
- $this->_contrib_creation_date_end = null;
- $this->_contrib_begin_date_begin = null;
- $this->_contrib_begin_date_end = null;
- $this->_contrib_end_date_begin = null;
- $this->_contrib_begin_date_end = null;
- $this->_contributions_types = array();
- $this->_payments_types = array();
-
- $this->_free_search = array(
+ $this->creation_date_begin = null;
+ $this->creation_date_end = null;
+ $this->modif_date_begin = null;
+ $this->modif_date_end = null;
+ $this->due_date_begin = null;
+ $this->due_date_end = null;
+ $this->birth_date_begin = null;
+ $this->birth_date_end = null;
+ $this->show_public_infos = Members::FILTER_DC_PUBINFOS;
+ $this->status = array();
+
+ $this->contrib_creation_date_begin = null;
+ $this->contrib_creation_date_end = null;
+ $this->contrib_begin_date_begin = null;
+ $this->contrib_begin_date_end = null;
+ $this->contrib_end_date_begin = null;
+ $this->contrib_begin_date_end = null;
+ $this->contributions_types = array();
+ $this->payments_types = array();
+
+ $this->free_search = array(
'empty' => array(
'field' => '',
'search' => '',
)
);
- $this->_contrib_dynamic = array();
+ $this->contrib_dynamic = array();
- $this->_groups_search = array(
+ $this->groups_search = array(
'empty' => array(
'group' => '',
)
);
- $this->_groups_search_log_op = self::OP_OR;
+ $this->groups_search_log_op = self::OP_OR;
}
/**
in_array($name, $this->advancedmemberslist_fields)
|| in_array($name, $this->virtuals_advancedmemberslist_fields)
) {
- $rname = '_' . $name;
switch ($name) {
case 'creation_date_begin':
case 'creation_date_end':
case 'contrib_end_date_begin':
case 'contrib_end_date_end':
try {
- if ($this->$rname !== null) {
- $d = new \DateTime($this->$rname);
+ if ($this->$name !== null) {
+ $d = new \DateTime($this->$name);
return $d->format(__("Y-m-d"));
}
} catch (Throwable $e) {
//oops, we've got a bad date :/
Analog::log(
- 'Bad date (' . $this->$rname . ') | ' .
+ 'Bad date (' . $this->$name . ') | ' .
$e->getMessage(),
Analog::INFO
);
- return $this->$rname;
+ return $this->$name;
}
break;
case 'rcreation_date_begin':
case 'rcontrib_begin_date_end':
case 'rcontrib_end_date_begin':
case 'rcontrib_end_date_end':
- //same as above, but raw format
- $rname = '_' . substr($name, 1);
+ $rname = substr($name, 1);
return $this->$rname;
case 'search_fields':
$search_fields = array_merge($this->memberslist_fields, $this->advancedmemberslist_fields);
unset($search_fields[$key]);
return $search_fields;
}
- return $this->$rname;
+ return $this->$name;
} else {
Analog::log(
- '[AdvancedMembersList] Unable to get proprety `' . $name . '`',
+ '[AdvancedMembersList] Unable to get property `' . $name . '`',
Analog::WARNING
);
}
Analog::DEBUG
);
- $prop = '_' . $name;
-
switch ($name) {
case 'creation_date_begin':
case 'creation_date_end':
if ($d === false) {
throw new \Exception('Incorrect format');
}
- $this->$prop = $d->format('Y-m-d');
+ $this->$name = $d->format('Y-m-d');
} catch (Throwable $e) {
Analog::log(
'Incorrect date format for ' . $name .
case 'contrib_min_amount':
case 'contrib_max_amount':
if (is_float($value)) {
- $this->$prop = $value;
+ $this->$name = $value;
} else {
if ($value !== null) {
Analog::log(
break;
case 'show_public_infos':
if (is_numeric($value)) {
- $this->$prop = $value;
+ $this->$name = $value;
} else {
Analog::log(
'[AdvancedMembersList] Value for property `' . $name .
if (!is_array($value)) {
$value = array($value);
}
- $this->_status = array();
+ $this->status = array();
foreach ($value as $v) {
if (is_numeric($v)) {
//check status existence
$s = new Status($zdb);
$res = $s->get($v);
if ($res !== false) {
- $this->_status[] = $v;
+ $this->status[] = $v;
} else {
Analog::log(
'Status #' . $v . ' does not exists!',
if (!is_array($value)) {
$value = array($value);
}
- $this->_contributions_types = array();
+ $this->contributions_types = array();
foreach ($value as $v) {
if (is_numeric($v)) {
//check type existence
$s = new ContributionsTypes($zdb);
$res = $s->get($v);
if ($res !== false) {
- $this->_contributions_types[] = $v;
+ $this->contributions_types[] = $v;
} else {
Analog::log(
'Contribution type #' . $v . ' does not exists!',
if (!is_array($value)) {
$value = array($value);
}
- $this->_payments_types = array();
+ $this->payments_types = array();
$ptypes = new PaymentTypes(
$zdb,
$preferences,
foreach ($value as $v) {
if (is_numeric($v)) {
if (isset($ptlist[$v])) {
- $this->_payments_types[] = $v;
+ $this->payments_types[] = $v;
} else {
Analog::log(
'Payment type #' . $v . ' does not exists!',
}
break;
case 'free_search':
- if (isset($this->_free_search['empty']) && !isset($value['empty'])) {
- unset($this->_free_search['empty']);
+ if (isset($this->free_search['empty']) && !isset($value['empty'])) {
+ unset($this->free_search['empty']);
}
if ($this->isValidFreeSearch($value)) {
break;
}
- $this->_free_search[$id] = $value;
+ $this->free_search[$id] = $value;
} else {
Analog::log(
'[AdvancedMembersList] bad construct for free filter',
break;
case 'contrib_dynamic':
if (is_array($value)) {
- $this->_contrib_dynamic = $value;
+ $this->contrib_dynamic = $value;
} else {
Analog::log(
'[AdvancedMembersList] Value for dynamic contribution fields filter should be an '
}
break;
case 'groups_search':
- if (isset($this->_groups_search['empty'])) {
- unset($this->_groups_search['empty']);
+ if (isset($this->groups_search['empty'])) {
+ unset($this->groups_search['empty']);
}
if (is_array($value)) {
if (
) {
$id = $value['idx'];
unset($value['idx']);
- $this->_groups_search[$id] = $value;
+ $this->groups_search[$id] = $value;
} else {
Analog::log(
'[AdvancedMembersList] bad construct for group filter',
break;
case 'groups_search_log_op':
if ($value == self::OP_AND || $value == self::OP_OR) {
- $this->_groups_search_log_op = $value;
+ $this->groups_search_log_op = $value;
} else {
Analog::log(
'[AdvancedMembersList] Value for group filter logical operator should be '
} else {
$id = substr($name, 4, strlen($name));
}
- $this->_contrib_dynamic[$id] = $value;
+ $this->contrib_dynamic[$id] = $value;
}
} else {
Analog::log(
- '[AdvancedMembersList] Unable to set proprety `' .
+ '[AdvancedMembersList] Unable to set property `' .
$name . '`',
Analog::WARNING
);
*
* @author Johan Cwiklinski <johan@x-tnd.be>
*
- * @property string $filter_str
- * @property integer $field_filter
- * @property integer $membership_filter
- * @property integer $filter_account
- * @property integer $email_filter
- * @property integer $group_filter
+ * @property ?string $filter_str
+ * @property ?integer $field_filter
+ * @property ?integer $membership_filter
+ * @property ?integer $filter_account
+ * @property ?integer $email_filter
+ * @property ?integer $group_filter
* @property array $selected
* @property array $unreachable
* @property string $query
class MembersList extends Pagination
{
//filters
- private ?string $_filter_str = null;
- private ?int $_field_filter = null;
- private ?int $_membership_filter = null;
- private ?int $_filter_account = null;
- private ?int $_email_filter = null;
- private ?int $_group_filter = null;
+ private ?string $filter_str = null;
+ private ?int $field_filter = null;
+ private ?int $membership_filter = null;
+ private ?int $filter_account = null;
+ private ?int $email_filter = null;
+ private ?int $group_filter = null;
/** @var array<int> */
- private array $_selected = [];
+ private array $selected = [];
/** @var array<int> */
- private array $_unreachable = [];
+ private array $unreachable = [];
protected string $query = '';
global $preferences;
parent::reinit();
- $this->_filter_str = null;
- $this->_field_filter = null;
- $this->_membership_filter = null;
- $this->_filter_account = $preferences->pref_filter_account;
- $this->_email_filter = Members::FILTER_DC_EMAIL;
- $this->_group_filter = null;
- $this->_selected = array();
+ $this->filter_str = null;
+ $this->field_filter = null;
+ $this->membership_filter = null;
+ $this->filter_account = $preferences->pref_filter_account;
+ $this->email_filter = Members::FILTER_DC_EMAIL;
+ $this->group_filter = null;
+ $this->selected = array();
}
/**
return parent::__get($name);
} else {
if (in_array($name, $this->memberslist_fields)) {
- if ($name === 'query') {
- return $this->$name;
- } else {
- $name = '_' . $name;
- return $this->$name;
- }
+ return $this->$name;
} else {
Analog::log(
'[MembersList] Unable to get property `' . $name . '`',
case 'selected':
case 'unreachable':
if (is_array($value)) {
- $name = '_' . $name;
$this->$name = $value;
} elseif ($value !== null) {
Analog::log(
}
break;
case 'filter_str':
- $name = '_' . $name;
$this->$name = $value;
break;
case 'field_filter':
case 'membership_filter':
case 'filter_account':
if (is_numeric($value)) {
- $name = '_' . $name;
$this->$name = $value;
} elseif ($value !== null) {
Analog::log(
case Members::FILTER_DC_EMAIL:
case Members::FILTER_W_EMAIL:
case Members::FILTER_WO_EMAIL:
- $this->_email_filter = $value;
+ $this->email_filter = $value;
break;
default:
Analog::log(
$g = new Group();
$res = $g->load($value);
if ($res === true) {
- $this->_group_filter = $value;
+ $this->group_filter = $value;
} else {
Analog::log(
'Group #' . $value . ' does not exists!',
protected array $extensions = array('csv', 'txt');
/** @var array<string> */
- private $_fields;
+ private array $fields;
/** @var array<string> */
- private array $_default_fields = array(
+ private array $default_fields = array(
'nom_adh',
'prenom_adh',
'ddn_adh',
'info_adh'
);
- private bool $_dryrun = true;
+ private bool $dryrun = true;
/** @var array<string,mixed> */
- private array $_members_fields;
+ private array $members_fields;
/** @var array<string,mixed> */
- private array $_members_fields_cats;
+ private array $members_fields_cats;
/** @var array<string,bool> */
- private array $_required;
+ private array $required;
/** @var array<int, string> */
private array $statuses;
/** @var Title[] */
/** @var array<string,string> */
private array $langs;
/** @var array<string,int> */
- private $emails;
+ private array $emails;
private Db $zdb;
private Preferences $preferences;
private History $history;
private function loadFields()
{
//at last, we got the defaults
- $this->_fields = $this->_default_fields;
+ $this->fields = $this->default_fields;
$model = new ImportModel();
//we go with default fields if model cannot be loaded
if ($model->load()) {
- $this->_fields = $model->getFields();
+ $this->fields = $model->getFields();
}
}
*/
public function getDefaultFields()
{
- return $this->_default_fields;
+ return $this->default_fields;
}
/**
$this->preferences = $preferences;
$this->history = $history;
if ($dryrun === false) {
- $this->_dryrun = false;
+ $this->dryrun = false;
}
$this->loadFields();
- $this->_members_fields = $members_fields;
- $this->_members_fields_cats = $members_fields_cats;
+ $this->members_fields = $members_fields;
+ $this->members_fields_cats = $members_fields_cats;
if (!$this->check($filename)) {
return self::INVALID_FILE;
return false;
}
- $cnt_fields = count($this->_fields);
+ $cnt_fields = count($this->fields);
//check required fields
$fc = new FieldsConfig(
$this->zdb,
Adherent::TABLE,
- $this->_members_fields,
- $this->_members_fields_cats
+ $this->members_fields,
+ $this->members_fields_cats
);
$config_required = $fc->getRequired();
- $this->_required = array();
+ $this->required = array();
foreach (array_keys($config_required) as $field) {
- if (in_array($field, $this->_fields)) {
- $this->_required[$field] = $field;
+ if (in_array($field, $this->fields)) {
+ $this->required[$field] = $field;
}
}
$dfields = [];
$member->setDependencies(
$this->preferences,
- $this->_members_fields,
+ $this->members_fields,
$this->history
);
//check required fields
if (
- in_array($this->_fields[$col], $this->_required)
+ in_array($this->fields[$col], $this->required)
&& empty($column)
) {
$this->addError(
str_replace(
array('%field', '%row'),
- array($this->_fields[$col], $row),
+ array($this->fields[$col], $row),
_T("Field %field is required, but missing in row %row")
)
);
//check for statuses
//if missing, set default one; if not check it does exists
- if ($this->_fields[$col] == Status::PK) {
+ if ($this->fields[$col] == Status::PK) {
if (empty($column)) {
$column = Status::DEFAULT_STATUS;
} else {
}
//check for title
- if ($this->_fields[$col] == 'titre_adh' && !empty($column)) {
+ if ($this->fields[$col] == 'titre_adh' && !empty($column)) {
if (!isset($this->titles)) {
//load existing titles
$titles = new Titles($this->zdb);
}
//check for email unicity
- if ($this->_fields[$col] == 'email_adh' && !empty($column)) {
- if ($this->emails === null) {
+ if ($this->fields[$col] == 'email_adh' && !empty($column)) {
+ if (!isset($this->emails)) {
//load existing emails
$this->emails = Members::getEmails($this->zdb);
}
}
//check for language
- if ($this->_fields[$col] == 'pref_lang') {
+ if ($this->fields[$col] == 'pref_lang') {
if (!isset($this->langs)) {
//load existing titles
/** @var I18n $i18n */
}
//passwords
- if ($this->_fields[$col] == 'mdp_adh' && !empty($column)) {
- $this->_fields['mdp_adh2'] = $column;
+ if ($this->fields[$col] == 'mdp_adh' && !empty($column)) {
+ $this->fields['mdp_adh2'] = $column;
}
- if (substr($this->_fields[$col], 0, strlen('dynfield_')) === 'dynfield_') {
+ if (substr($this->fields[$col], 0, strlen('dynfield_')) === 'dynfield_') {
//dynamic field, keep to check later
- $dfields[$this->_fields[$col] . '_1'] = $column;
+ $dfields[$this->fields[$col] . '_1'] = $column;
} else {
//standard field
- $member->validate($this->_fields[$col], $column, $this->_fields);
+ $member->validate($this->fields[$col], $column, $this->fields);
}
$errors = $member->getErrors();
if (count($errors)) {
$col = 0;
$values = array();
foreach ($data as $column) {
- if (substr($this->_fields[$col], 0, strlen('dynfield_')) === 'dynfield_') {
+ if (substr($this->fields[$col], 0, strlen('dynfield_')) === 'dynfield_') {
//dynamic field, keep to check later
- $values[str_replace('dynfield_', 'info_field_', $this->_fields[$col] . '_1')] = $column;
+ $values[str_replace('dynfield_', 'info_field_', $this->fields[$col] . '_1')] = $column;
$col++;
continue;
}
- $values[$this->_fields[$col]] = $column;
- if ($this->_fields[$col] === 'societe_adh') {
+ $values[$this->fields[$col]] = $column;
+ if ($this->fields[$col] === 'societe_adh') {
$values['is_company'] = true;
}
//check for booleans
if (
- ($this->_fields[$col] == 'bool_admin_adh'
- || $this->_fields[$col] == 'bool_exempt_adh'
- || $this->_fields[$col] == 'bool_display_info'
- || $this->_fields[$col] == 'activite_adh')
+ ($this->fields[$col] == 'bool_admin_adh'
+ || $this->fields[$col] == 'bool_exempt_adh'
+ || $this->fields[$col] == 'bool_display_info'
+ || $this->fields[$col] == 'activite_adh')
&& ($column == null || trim($column) == '')
) {
- $values[$this->_fields[$col]] = 0; //defaults to 0 as in Adherent
+ $values[$this->fields[$col]] = 0; //defaults to 0 as in Adherent
}
- if ($this->_fields[$col] == Status::PK && empty(trim($column))) {
+ if ($this->fields[$col] == Status::PK && empty(trim($column))) {
$values[Status::PK] = Status::DEFAULT_STATUS;
}
$member = new Adherent($this->zdb);
$member->setDependencies(
$this->preferences,
- $this->_members_fields,
+ $this->members_fields,
$this->history
);
//check for empty creation date
$values['mdp_adh2'] = $values['mdp_adh'];
}
- $valid = $member->check($values, $this->_required, []);
+ $valid = $member->check($values, $this->required, []);
if ($valid === true) {
- if ($this->_dryrun === false) {
+ if ($this->dryrun === false) {
$store = $member->store();
if ($store !== true) {
$this->addError(
$this->assertInstanceOf(\Galette\Entity\Adherent::class, $adh);
$this->assertTrue($adh->appearsInMembersList());
- $this->assertNull($adh->_picture);
+ $this->assertNull($adh->picture);
$list = $members->getPublicList(true);
$this->assertCount(1, $list);