<?php
+
/**
* Dependency injection configuration
*
// Flash messages
$container['flash'] = function ($c) {
- return new \Slim\Flash\Messages;
+ return new \Slim\Flash\Messages();
};
$container['plugins'] = function ($c) use ($app) {
die();
}
-if (file_exists(GALETTE_CONFIG_PATH . 'behavior.inc.php')
+if (
+ file_exists(GALETTE_CONFIG_PATH . 'behavior.inc.php')
&& !defined('GALETTE_TESTS') && !$cron
) {
include_once GALETTE_CONFIG_PATH . 'behavior.inc.php';
require GALETTE_ROOT . '/vendor/autoload.php';
//start profiling
-if (defined('GALETTE_XHPROF_PATH')
+if (
+ defined('GALETTE_XHPROF_PATH')
&& function_exists('xhprof_enable')
) {
include_once __DIR__ . '/../lib/Galette/Common/XHProf.php';
* @since 0.8.2dev 2014-11-10
*/
-use \Slim\Slim;
-use \Slim\Route;
+use Slim\Slim;
+use Slim\Route;
use Galette\Core\Login;
-use \Analog\Analog;
+use Analog\Analog;
$time_start = microtime(true);
<?php
+
/**
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
public static function getClassLoader($className)
{
foreach (spl_autoload_functions() as $loader) {
- if (is_array($loader)
+ if (
+ is_array($loader)
&& $loader[0] instanceof ClassLoader
&& $loader[0]->canLoadClass($className)
) {
<?php
+
/**
* XHProf Profiling for Galette
*
*/
public function start($msg = '')
{
- if (!self::$run
+ if (
+ !self::$run
&& function_exists('xhprof_enable')
) {
xhprof_enable(
->withStatus(301)
->withHeader('Location', $urlRedirect);
} else {
- if ($this->login->isSuperAdmin()
+ if (
+ $this->login->isSuperAdmin()
|| $this->login->isAdmin()
|| $this->login->isStaff()
) {
- if (!isset($_COOKIE['show_galette_dashboard'])
+ if (
+ !isset($_COOKIE['show_galette_dashboard'])
|| $_COOKIE['show_galette_dashboard'] == 1
) {
return $response
*
* @return Response
*/
- public function adminTools(Request $request, Response $response) :Response
+ public function adminTools(Request $request, Response $response): Response
{
$params = [
'page_title' => _T('Administration tools')
*
* @return Response
*/
- public function process(Request $request, Response $response) :Response
+ public function process(Request $request, Response $response): Response
{
$post = $request->getParsedBody();
public function login(Request $request, Response $response, array $args = [])
{
//store redirect path if any
- if (isset($args['r'])
+ if (
+ isset($args['r'])
&& $args['r'] != '/logout'
&& $args['r'] != '/login'
) {
*
* @return Response
*/
- public function lostPassword(Request $request, Response $response) :Response
+ public function lostPassword(Request $request, Response $response): Response
{
if ($this->preferences->pref_mail_method === GaletteMail::METHOD_DISABLED) {
throw new \RuntimeException('Mailing disabled.');
*
* @return Response
*/
- public function retrievePassword(Request $request, Response $response, array $args) :Response
+ public function retrievePassword(Request $request, Response $response, array $args): Response
{
$from_admin = false;
$redirect_url = $this->router->pathFor('slash');
$redirect_url = $this->router->pathFor('member', ['id' => $args[Adherent::PK]]);
}
- if (($this->login->isLogged()
+ if (
+ ($this->login->isLogged()
|| $this->preferences->pref_mail_method == GaletteMail::METHOD_DISABLED)
&& !$from_admin
) {
*
* @return Response
*/
- public function recoverPassword(Request $request, Response $response, array $args) :Response
+ public function recoverPassword(Request $request, Response $response, array $args): Response
{
$password = new Password($this->zdb);
if (!$id_adh = $password->isHashValid(base64_decode($args['hash']))) {
*
* @return Response
*/
- public function doRecoverPassword(Request $request, Response $response) :Response
+ public function doRecoverPassword(Request $request, Response $response): Response
{
$post = $request->getParsedBody();
$password = new Password($this->zdb);
namespace Galette\Controllers\Crud;
use Galette\Controllers\CrudController;
-
use Slim\Http\Request;
use Slim\Http\Response;
use Galette\Entity\Adherent;
use Galette\Entity\Contribution;
use Galette\Entity\Transaction;
-
-
-
use Galette\Repository\Contributions;
use Galette\Repository\Transactions;
use Galette\Repository\Members;
use Galette\IO\PdfMembersCards;
use Galette\Repository\PaymentTypes;
use Galette\Core\Links;
-
-
-
use Analog\Analog;
/**
Response $response,
array $args,
Contribution $contrib
- ) :Response {
+ ): Response {
$get = $request->getQueryParams();
// contribution types
*
* @return Response
*/
- public function add(Request $request, Response $response, array $args = []) :Response
+ public function add(Request $request, Response $response, array $args = []): Response
{
if ($this->session->contribution !== null) {
$contrib = $this->session->contribution;
*
* @return Response
*/
- public function doAdd(Request $request, Response $response, array $args = []) :Response
+ public function doAdd(Request $request, Response $response, array $args = []): Response
{
$args['action'] = 'add';
return $this->store($request, $response, $args);
*
* @return Response
*/
- public function list(Request $request, Response $response, array $args = []) :Response
+ public function list(Request $request, Response $response, array $args = []): Response
{
$ajax = false;
- if ($request->isXhr()
+ if (
+ $request->isXhr()
|| isset($request->getQueryParams()['ajax'])
&& $request->getQueryParams()['ajax'] == 'true'
) {
$filters->orderby = $value;
break;
case 'member':
- if (($this->login->isAdmin()
+ if (
+ ($this->login->isAdmin()
|| $this->login->isStaff())
) {
if ($value == 'all') {
*
* @return Response
*/
- public function filter(Request $request, Response $response, array $args = []) :Response
+ public function filter(Request $request, Response $response, array $args = []): Response
{
$raw_type = null;
switch ($args['type']) {
$filters->max_amount = null;
}
- if ((isset($post['nbshow']) && is_numeric($post['nbshow']))
+ if (
+ (isset($post['nbshow']) && is_numeric($post['nbshow']))
) {
$filters->show = $post['nbshow'];
}
*
* @return Response
*/
- public function edit(Request $request, Response $response, array $args = []) :Response
+ public function edit(Request $request, Response $response, array $args = []): Response
{
if ($this->session->contribution !== null) {
$contrib = $this->session->contribution;
*
* @return Response
*/
- public function doEdit(Request $request, Response $response, array $args = []) :Response
+ public function doEdit(Request $request, Response $response, array $args = []): Response
{
$args['action'] = 'edit';
return $this->store($request, $response, $args);
*
* @return Response
*/
- public function store(Request $request, Response $response, array $args = []) :Response
+ public function store(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
$action = $args['action'];
'contrib_type' => custom_html_entity_decode($contrib->type->libelle)
)
);
- if ($new && isset($_POST['mail_confirm'])
+ if (
+ $new && isset($_POST['mail_confirm'])
&& $_POST['mail_confirm'] == '1'
) {
if (GaletteMail::isValidEmail($adh->getEmail())) {
namespace Galette\Controllers\Crud;
use Galette\Controllers\CrudController;
-
use Slim\Http\Request;
use Slim\Http\Response;
use Galette\DynamicFields\DynamicField;
*
* @return Response
*/
- public function add(Request $request, Response $response, array $args = []) :Response
+ public function add(Request $request, Response $response, array $args = []): Response
{
$form_name = $args['form'];
*
* @return Response
*/
- public function doAdd(Request $request, Response $response, array $args = []) :Response
+ public function doAdd(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
*
* @return Response
*/
- public function list(Request $request, Response $response, array $args = []) :Response
+ public function list(Request $request, Response $response, array $args = []): Response
{
$form_name = $args['form'] ?? 'adh';
if (isset($_POST['form']) && trim($_POST['form']) != '') {
$tpl = 'configurer_fiches.tpl';
//Render directly template if we called from ajax,
//render in a full page otherwise
- if ($request->isXhr()
+ if (
+ $request->isXhr()
|| isset($request->getQueryParams()['ajax'])
&& $request->getQueryParams()['ajax'] == 'true'
) {
*
* @return Response
*/
- public function filter(Request $request, Response $response) :Response
+ public function filter(Request $request, Response $response): Response
{
//no filtering
}
*
* @return Response
*/
- public function edit(Request $request, Response $response, array $args = []) :Response
+ public function edit(Request $request, Response $response, array $args = []): Response
{
$id_dynf = (int)$args['id'];
$form_name = $args['form'];
*
* @return Response
*/
- public function doEdit(Request $request, Response $response, array $args = []) :Response
+ public function doEdit(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
*
* @return Response
*/
- public function move(Request $request, Response $response, array $args = []) :Response
+ public function move(Request $request, Response $response, array $args = []): Response
{
$field_id = (int)$args['id'];
$form_name = $args['form'];
namespace Galette\Controllers\Crud;
use Galette\Controllers\CrudController;
-
use Slim\Http\Request;
use Slim\Http\Response;
-
use Galette\Entity\ContributionsTypes;
use Galette\Entity\Status;
use Galette\Repository\Members;
-
use Analog\Analog;
/**
*
* @return Response
*/
- public function add(Request $request, Response $response, array $args = []) :Response
+ public function add(Request $request, Response $response, array $args = []): Response
{
//no new page (included on list), just to satisfy inheritance
}
*
* @return Response
*/
- public function doAdd(Request $request, Response $response, array $args = []) :Response
+ public function doAdd(Request $request, Response $response, array $args = []): Response
{
$args['id'] = null;
return $this->store($request, $response, $args);
*
* @return Response
*/
- public function list(Request $request, Response $response, array $args = []) :Response
+ public function list(Request $request, Response $response, array $args = []): Response
{
$className = null;
$class = null;
*
* @return Response
*/
- public function filter(Request $request, Response $response) :Response
+ public function filter(Request $request, Response $response): Response
{
//no filters
}
*
* @return Response
*/
- public function edit(Request $request, Response $response, array $args = []) :Response
+ public function edit(Request $request, Response $response, array $args = []): Response
{
$className = null;
$class = null;
*
* @return Response
*/
- public function doEdit(Request $request, Response $response, array $args = []) :Response
+ public function doEdit(Request $request, Response $response, array $args = []): Response
{
return $this->store($request, $response, $args);
}
*
* @return Response
*/
- public function store(Request $request, Response $response, array $args = []) :Response
+ public function store(Request $request, Response $response, array $args = []): Response
{
$id = (isset($args['id']) ? (int)$args['id'] : null);
namespace Galette\Controllers\Crud;
use Galette\Controllers\CrudController;
-
use Slim\Http\Request;
use Slim\Http\Response;
use Galette\Entity\Adherent;
*
* @return Response
*/
- public function add(Request $request, Response $response, array $args = []) :Response
+ public function add(Request $request, Response $response, array $args = []): Response
{
//no new page (included on list), just to satisfy inheritance
}
*
* @return Response
*/
- public function doAdd(Request $request, Response $response, array $args = []) :Response
+ public function doAdd(Request $request, Response $response, array $args = []): Response
{
$group = new Group();
$group->setLogin($this->login);
*
* @return Response
*/
- public function checkUniqueness(Request $request, Response $response, array $args = []) :Response
+ public function checkUniqueness(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
if (!isset($post['gname']) || $post['gname'] == '') {
*
* @return Response
*/
- public function list(Request $request, Response $response, array $args = []) :Response
+ public function list(Request $request, Response $response, array $args = []): Response
{
$groups = new Groups($this->zdb, $this->login);
$group = new Group();
*
* @return Response
*/
- public function getGroup(Request $request, Response $response, array $args = []) :Response
+ public function getGroup(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
$id = $post['id_group'];
*
* @return Response
*/
- public function simpleList(Request $request, Response $response, array $args = []) :Response
+ public function simpleList(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
*
* @return Response
*/
- public function ajaxMembers(Request $request, Response $response, array $args = []) :Response
+ public function ajaxMembers(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
die();
}
- $m = new Members;
+ $m = new Members();
$persons = $m->getArrayList($ids);
// display page
*
* @return Response
*/
- public function filter(Request $request, Response $response) :Response
+ public function filter(Request $request, Response $response): Response
{
//no filters
}
*
* @return Response
*/
- public function edit(Request $request, Response $response, array $args = []) :Response
+ public function edit(Request $request, Response $response, array $args = []): Response
{
//no edit page (included on list), just to satisfy inheritance
}
*
* @return Response
*/
- public function doEdit(Request $request, Response $response, array $args = []) :Response
+ public function doEdit(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
$group = new Group((int)$args['id']);
*
* @return Response
*/
- public function reorder(Request $request, Response $response, array $args = []) :Response
+ public function reorder(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
if (!isset($post['to']) || !isset($post['id_group']) || $post['id_group'] == '') {
namespace Galette\Controllers\Crud;
use Galette\Controllers\CrudController;
-
use Slim\Http\Request;
use Slim\Http\Response;
use Galette\Core\GaletteMail;
*
* @return Response
*/
- public function add(Request $request, Response $response, array $args = []) :Response
+ public function add(Request $request, Response $response, array $args = []): Response
{
$get = $request->getQueryParams();
//We're done :-)
- if (isset($get['mailing_new'])
+ if (
+ isset($get['mailing_new'])
|| isset($get['reminder'])
) {
if ($this->session->mailing !== null) {
$params = array();
- if ($this->preferences->pref_mail_method == Mailing::METHOD_DISABLED
+ if (
+ $this->preferences->pref_mail_method == Mailing::METHOD_DISABLED
&& !GALETTE_MODE === 'DEMO'
) {
$this->history->add(
$filters = new MembersList();
}
- if ($this->session->mailing !== null
+ if (
+ $this->session->mailing !== null
&& !isset($get['from'])
&& !isset($get['reset'])
) {
$members = $m->getList(true);
$mailing = new Mailing($this->preferences, ($members !== false) ? $members : null);
} else {
- if (count($filters->selected) == 0
+ if (
+ count($filters->selected) == 0
&& !isset($get['mailing_new'])
&& !isset($get['reminder'])
) {
'mailing' => $mailing,
'attachments' => $mailing->attachments,
'html_editor' => true,
- 'html_editor_active'=> $this->preferences->pref_editor_enabled
+ 'html_editor_active' => $this->preferences->pref_editor_enabled
)
);
}
*
* @return Response
*/
- public function doAdd(Request $request, Response $response, array $args = []) :Response
+ public function doAdd(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
$error_detected = [];
$this->session->redirect_mailing : $this->router->pathFor('members');
//We're done :-)
- if (isset($post['mailing_done'])
+ if (
+ isset($post['mailing_done'])
|| isset($post['mailing_cancel'])
) {
if ($this->session->mailing !== null) {
$params = array();
- if ($this->preferences->pref_mail_method == Mailing::METHOD_DISABLED
+ if (
+ $this->preferences->pref_mail_method == Mailing::METHOD_DISABLED
&& !GALETTE_MODE === 'DEMO'
) {
$this->history->add(
$filters = new MembersList();
}
- if ($this->session->mailing !== null
+ if (
+ $this->session->mailing !== null
&& !isset($post['mailing_cancel'])
) {
$mailing = $this->session->mailing;
$mailing = new Mailing($this->preferences, ($members !== false) ? $members : null);
}
- if (isset($post['mailing_go'])
+ if (
+ isset($post['mailing_go'])
|| isset($post['mailing_reset'])
|| isset($post['mailing_confirm'])
|| isset($post['mailing_save'])
}
}
- if (count($error_detected) == 0
+ if (
+ count($error_detected) == 0
&& !isset($post['mailing_reset'])
&& !isset($post['mailing_save'])
) {
/** TODO: replace that... */
$this->session->labels = $mailing->unreachables;
- if (!isset($post['html_editor_active'])
+ if (
+ !isset($post['html_editor_active'])
|| trim($post['html_editor_active']) == ''
) {
$post['html_editor_active'] = $this->preferences->pref_editor_enabled;
*
* @return Response
*/
- public function list(Request $request, Response $response, array $args = []) :Response
+ public function list(Request $request, Response $response, array $args = []): Response
{
$option = null;
if (isset($args['option'])) {
*
* @return Response
*/
- public function filter(Request $request, Response $response) :Response
+ public function filter(Request $request, Response $response): Response
{
$post = $request->getParsedBody();
$error_detected = [];
if (isset($post['clear_filter'])) {
$filters->reinit();
} else {
- if ((isset($post['nbshow']) && is_numeric($post['nbshow']))
+ if (
+ (isset($post['nbshow']) && is_numeric($post['nbshow']))
) {
$filters->show = $post['nbshow'];
}
*
* @return Response
*/
- public function edit(Request $request, Response $response, array $args = []) :Response
+ public function edit(Request $request, Response $response, array $args = []): Response
{
//TODO
}
*
* @return Response
*/
- public function doEdit(Request $request, Response $response, array $args = []) :Response
+ public function doEdit(Request $request, Response $response, array $args = []): Response
{
//TODO
}
*
* @return Response
*/
- public function preview(Request $request, Response $response, array $args = []) :Response
+ public function preview(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
// check for ajax mode
$ajax = false;
- if ($request->isXhr()
+ if (
+ $request->isXhr()
|| isset($post['ajax'])
&& $post['ajax'] == 'true'
) {
*
* @return Response
*/
- public function previewAttachment(Request $request, Response $response, array $args = []) :Response
+ public function previewAttachment(Request $request, Response $response, array $args = []): Response
{
$mailing = new Mailing($this->preferences, null);
MailingHistory::loadFrom($this->zdb, (int)$args['id'], $mailing, false);
*
* @return Response
*/
- public function setRecipients(Request $request, Response $response, array $args = []) :Response
+ public function setRecipients(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
$mailing = $this->session->mailing;
namespace Galette\Controllers\Crud;
use Galette\Controllers\CrudController;
-
use Slim\Http\Request;
use Slim\Http\Response;
use Galette\Core\Authentication;
*
* @return Response
*/
- public function add(Request $request, Response $response, array $args = []) :Response
+ public function add(Request $request, Response $response, array $args = []): Response
{
return $this->edit($request, $response, $args);
}
*
* @return Response
*/
- public function selfSubscribe(Request $request, Response $response, array $args = []) :Response
+ public function selfSubscribe(Request $request, Response $response, array $args = []): Response
{
if (!$this->preferences->pref_bool_selfsubscribe || $this->login->isLogged()) {
return $response
*
* @return Response
*/
- public function doAdd(Request $request, Response $response, array $args = []) :Response
+ public function doAdd(Request $request, Response $response, array $args = []): Response
{
return $this->store($request, $response, $args);
}
*
* @return Response
*/
- public function duplicate(Request $request, Response $response, array $args = []) :Response
+ public function duplicate(Request $request, Response $response, array $args = []): Response
{
$id_adh = (int)$args[Adherent::PK];
$adh = new Adherent($this->zdb, $id_adh, ['dynamics' => true, 'parent' => true]);
*
* @return Response
*/
- public function show(Request $request, Response $response, array $args) :Response
+ public function show(Request $request, Response $response, array $args): Response
{
$id = (int)$args['id'];
*
* @return Response
*/
- public function showMe(Request $request, Response $response, array $args = []) :Response
+ public function showMe(Request $request, Response $response, array $args = []): Response
{
if ($this->login->isSuperAdmin()) {
return $response
*
* @return Response
*/
- public function publicList(Request $request, Response $response, array $args = []) :Response
+ public function publicList(Request $request, Response $response, array $args = []): Response
{
$option = null;
$type = $args['type'];
*
* @return Response
*/
- public function filterPublicList(Request $request, Response $response, array $args = []) :Response
+ public function filterPublicList(Request $request, Response $response, array $args = []): Response
{
$type = $args['type'];
$post = $request->getParsedBody();
*
* @return Response
*/
- public function getDynamicFile(Request $request, Response $response, array $args) :Response
+ public function getDynamicFile(Request $request, Response $response, array $args): Response
{
$id = (int)$args['id'];
$deps = array(
*
* @return Response
*/
- public function list(Request $request, Response $response, array $args = []) :Response
+ public function list(Request $request, Response $response, array $args = []): Response
{
$option = $args['option'] ?? null;
$value = $args['value'] ?? null;
*
* @return Response
*/
- public function filter(Request $request, Response $response) :Response
+ public function filter(Request $request, Response $response): Response
{
$post = $request->getParsedBody();
if (isset($this->session->filter_members)) {
$filters->email_filter = (int)$post['email_filter'];
}
//group filter
- if (isset($post['group_filter'])
+ if (
+ isset($post['group_filter'])
&& $post['group_filter'] > 0
) {
$filters->group_filter = (int)$post['group_filter'];
if (!$freed) {
$i = 0;
foreach ($post['free_field'] as $f) {
- if (trim($f) !== ''
+ if (
+ trim($f) !== ''
&& trim($post['free_text'][$i]) !== ''
) {
$fs_search = $post['free_text'][$i];
*
* @return Response
*/
- public function advancedSearch(Request $request, Response $response) :Response
+ public function advancedSearch(Request $request, Response $response): Response
{
if (isset($this->session->filter_members)) {
$filters = $this->session->filter_members;
unset($fields['mdp_adh']);
foreach ($fields as $k => $f) {
- if ($visibles[$k] == FieldsConfig::NOBODY ||
+ if (
+ $visibles[$k] == FieldsConfig::NOBODY ||
($visibles[$k] == FieldsConfig::ADMIN &&
$access_level < Authentication::ACCESS_ADMIN) ||
($visibles[$k] == FieldsConfig::STAFF &&
*
* @return Response
*/
- public function ajaxList(Request $request, Response $response, array $args = []) :Response
+ public function ajaxList(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
*
* @return Response
*/
- public function handleBatch(Request $request, Response $response) :Response
+ public function handleBatch(Request $request, Response $response): Response
{
$post = $request->getParsedBody();
*
* @return Response
*/
- public function edit(Request $request, Response $response, array $args = []) :Response
+ public function edit(Request $request, Response $response, array $args = []): Response
{
$action = $args['action'];
$id = null;
*
* @return Response
*/
- public function doEdit(Request $request, Response $response, array $args = []) :Response
+ public function doEdit(Request $request, Response $response, array $args = []): Response
{
return $this->store($request, $response, $args);
}
*
* @return Response
*/
- public function massChange(Request $request, Response $response, array $args = []) :Response
+ public function massChange(Request $request, Response $response, array $args = []): Response
{
$filters = $this->session->filter_members;
*
* @return Response
*/
- public function validateMassChange(Request $request, Response $response, array $args = []) :Response
+ public function validateMassChange(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
*
* @return Response
*/
- public function doMassChange(Request $request, Response $response, array $args = []) :Response
+ public function doMassChange(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
$redirect_url = $post['redirect_uri'];
*
* @return Response
*/
- public function store(Request $request, Response $response, array $args = []) :Response
+ public function store(Request $request, Response $response, array $args = []): Response
{
if (!$this->preferences->pref_bool_selfsubscribe && !$this->login->isLogged()) {
return $response
$fc->setNotRequired('mdp_adh');
}
- if ($member->hasParent() && !isset($post['detach_parent'])
+ if (
+ $member->hasParent() && !isset($post['detach_parent'])
|| isset($post['parent_id']) && !empty($post['parent_id'])
) {
$parent_fields = $member->getParentFields();
if ($new) {
if (isset($args['self'])) {
$success_detected[] = _T("Your account has been created!");
- if ($this->preferences->pref_mail_method > GaletteMail::METHOD_DISABLED
+ if (
+ $this->preferences->pref_mail_method > GaletteMail::METHOD_DISABLED
&& $member->getEmail() != ''
) {
$success_detected[] = _T("An email has been sent to you, check your inbox.");
$success_detected[] = _T("New member has been successfully added.");
}
//Send email to admin if preference checked
- if ($this->preferences->pref_mail_method > GaletteMail::METHOD_DISABLED
+ if (
+ $this->preferences->pref_mail_method > GaletteMail::METHOD_DISABLED
&& $this->preferences->pref_bool_mailadh
) {
$texts = new Texts(
}
// send email to admin
- if ($this->preferences->pref_mail_method > GaletteMail::METHOD_DISABLED
+ if (
+ $this->preferences->pref_mail_method > GaletteMail::METHOD_DISABLED
&& $this->preferences->pref_bool_mailadh
&& !$new
&& $member->id == $this->login->id
if (count($error_detected) == 0) {
if (isset($args['self'])) {
$redirect_url = $this->router->pathFor('login');
- } elseif (isset($post['redirect_on_create'])
+ } elseif (
+ isset($post['redirect_on_create'])
&& $post['redirect_on_create'] > Adherent::AFTER_ADD_DEFAULT
) {
switch ($post['redirect_on_create']) {
namespace Galette\Controllers\Crud;
use Galette\Controllers\CrudController;
-
use Slim\Http\Request;
use Slim\Http\Response;
use Galette\Repository\PaymentTypes;
*
* @return Response
*/
- public function add(Request $request, Response $response, array $args = []) :Response
+ public function add(Request $request, Response $response, array $args = []): Response
{
//no new page (included on list), just to satisfy inheritance
}
*
* @return Response
*/
- public function doAdd(Request $request, Response $response, array $args = []) :Response
+ public function doAdd(Request $request, Response $response, array $args = []): Response
{
$args['id'] = null;
return $this->store($request, $response, $args);
*
* @return Response
*/
- public function list(Request $request, Response $response, array $args = []) :Response
+ public function list(Request $request, Response $response, array $args = []): Response
{
$ptypes = new PaymentTypes(
$this->zdb,
*
* @return Response
*/
- public function filter(Request $request, Response $response) :Response
+ public function filter(Request $request, Response $response): Response
{
//no filters
}
*
* @return Response
*/
- public function edit(Request $request, Response $response, array $args = []) :Response
+ public function edit(Request $request, Response $response, array $args = []): Response
{
$id = (int)$args['id'];
$ptype = new PaymentType($this->zdb, $id);
*
* @return Response
*/
- public function doEdit(Request $request, Response $response, array $args = []) :Response
+ public function doEdit(Request $request, Response $response, array $args = []): Response
{
return $this->store($request, $response, $args);
}
*
* @return Response
*/
- public function store(Request $request, Response $response, array $args = []) :Response
+ public function store(Request $request, Response $response, array $args = []): Response
{
$id = (isset($args['id']) ? (int)$args['id'] : null);
$post = $request->getParsedBody();
namespace Galette\Controllers\Crud;
use Galette\Controllers\CrudController;
-
use Slim\Http\Request;
use Slim\Http\Response;
use Galette\Entity\SavedSearch;
*
* @return Response
*/
- public function add(Request $request, Response $response, array $args = []) :Response
+ public function add(Request $request, Response $response, array $args = []): Response
{
//no new page (included on list), just to satisfy inheritance
}
*
* @return Response
*/
- public function doAdd(Request $request, Response $response, array $args = []) :Response
+ public function doAdd(Request $request, Response $response, array $args = []): Response
{
if ($request->isPost()) {
$post = $request->getParsedBody();
*
* @return Response
*/
- public function list(Request $request, Response $response, array $args = []) :Response
+ public function list(Request $request, Response $response, array $args = []): Response
{
$option = null;
if (isset($args['option'])) {
*
* @return Response
*/
- public function filter(Request $request, Response $response) :Response
+ public function filter(Request $request, Response $response): Response
{
//no filters
}
*
* @return Response
*/
- public function edit(Request $request, Response $response, array $args = []) :Response
+ public function edit(Request $request, Response $response, array $args = []): Response
{
//no edition
}
*
* @return Response
*/
- public function doEdit(Request $request, Response $response, array $args = []) :Response
+ public function doEdit(Request $request, Response $response, array $args = []): Response
{
//no edition
}
*
* @return Response
*/
- public function load(Request $request, Response $response, array $args = []) :Response
+ public function load(Request $request, Response $response, array $args = []): Response
{
try {
$sco = new SavedSearch($this->zdb, $this->login, (int)$args['id']);
namespace Galette\Controllers\Crud;
use Galette\Controllers\CrudController;
-
use Slim\Http\Request;
use Slim\Http\Response;
use Galette\Repository\Titles;
*
* @return Response
*/
- public function add(Request $request, Response $response, array $args = []) :Response
+ public function add(Request $request, Response $response, array $args = []): Response
{
//no new page (included on list), just to satisfy inheritance
}
*
* @return Response
*/
- public function doAdd(Request $request, Response $response, array $args = []) :Response
+ public function doAdd(Request $request, Response $response, array $args = []): Response
{
$args['id'] = null;
return $this->store($request, $response, $args);
*
* @return Response
*/
- public function list(Request $request, Response $response, array $args = []) :Response
+ public function list(Request $request, Response $response, array $args = []): Response
{
$titles = Titles::getList($this->zdb);
*
* @return Response
*/
- public function filter(Request $request, Response $response) :Response
+ public function filter(Request $request, Response $response): Response
{
//no filtering
}
*
* @return Response
*/
- public function edit(Request $request, Response $response, array $args = []) :Response
+ public function edit(Request $request, Response $response, array $args = []): Response
{
$id = (int)$args['id'];
$title = new Title($id);
*
* @return Response
*/
- public function doEdit(Request $request, Response $response, array $args = []) :Response
+ public function doEdit(Request $request, Response $response, array $args = []): Response
{
return $this->store($request, $response, $args);
}
*
* @return Response
*/
- public function store(Request $request, Response $response, array $args = []) :Response
+ public function store(Request $request, Response $response, array $args = []): Response
{
$id = $args['id'] ?? null;
$post = $request->getParsedBody();
namespace Galette\Controllers\Crud;
use Galette\Controllers\CrudController;
-
use Slim\Http\Request;
use Slim\Http\Response;
use Galette\Entity\Adherent;
*
* @return Response
*/
- public function add(Request $request, Response $response, array $args = []) :Response
+ public function add(Request $request, Response $response, array $args = []): Response
{
return $this->edit($request, $response, $args);
}
*
* @return Response
*/
- public function doAdd(Request $request, Response $response, array $args = []) :Response
+ public function doAdd(Request $request, Response $response, array $args = []): Response
{
return $this->doEdit($request, $response, $args);
}
*
* @return Response
*/
- public function edit(Request $request, Response $response, array $args = []) :Response
+ public function edit(Request $request, Response $response, array $args = []): Response
{
$trans = null;
*
* @return Response
*/
- public function doEdit(Request $request, Response $response, array $args = []) :Response
+ public function doEdit(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
$trans = new Transaction($this->zdb, $this->login);
*
* @return Response
*/
- public function attach(Request $request, Response $response, array $args = []) :Response
+ public function attach(Request $request, Response $response, array $args = []): Response
{
if (!Contribution::setTransactionPart($this->zdb, $args['id'], $args['cid'])) {
$this->flash->addMessage(
*
* @return Response
*/
- public function detach(Request $request, Response $response, array $args = []) :Response
+ public function detach(Request $request, Response $response, array $args = []): Response
{
if (!Contribution::unsetTransactionPart($this->zdb, $this->login, $args['id'], $args['cid'])) {
$this->flash->addMessage(
*
* @return Response
*/
- abstract public function add(Request $request, Response $response, array $args = []) :Response;
+ abstract public function add(Request $request, Response $response, array $args = []): Response;
/**
* Add action
*
* @return Response
*/
- abstract public function doAdd(Request $request, Response $response, array $args = []) :Response;
+ abstract public function doAdd(Request $request, Response $response, array $args = []): Response;
// /CRUD - Create
// CRUD - Read
*
* @return Response
*/
- abstract public function list(Request $request, Response $response, array $args = []) :Response;
+ abstract public function list(Request $request, Response $response, array $args = []): Response;
/**
* List filtering
*
* @return Response
*/
- abstract public function filter(Request $request, Response $response) :Response;
+ abstract public function filter(Request $request, Response $response): Response;
// /CRUD - Read
// CRUD - Update
*
* @return Response
*/
- abstract public function edit(Request $request, Response $response, array $args = []) :Response;
+ abstract public function edit(Request $request, Response $response, array $args = []): Response;
/**
* Edit action
*
* @return Response
*/
- abstract public function doEdit(Request $request, Response $response, array $args = []) :Response;
+ abstract public function doEdit(Request $request, Response $response, array $args = []): Response;
// /CRUD - Update
// CRUD - Delete
*
* @return Response
*/
- public function confirmDelete(Request $request, Response $response, array $args = []) :Response
+ public function confirmDelete(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
$data = [
*
* @return Response
*/
- public function delete(Request $request, Response $response, array $args = []) :Response
+ public function delete(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
$ajax = isset($post['ajax']) && $post['ajax'] === 'true';
*
* @return Response
*/
- protected function sendResponse(Response $response, $filepath, $filename) :Response
+ protected function sendResponse(Response $response, $filepath, $filename): Response
{
if (file_exists($filepath)) {
$response = $response->withHeader('Content-Description', 'File Transfer')
*
* @return Response
*/
- public function export(Request $request, Response $response) :Response
+ public function export(Request $request, Response $response): Response
{
$csv = new CsvOut();
*
* @return Response
*/
- public function doExport(Request $request, Response $response) :Response
+ public function doExport(Request $request, Response $response): Response
{
$post = $request->getParsedBody();
$csv = new CsvOut();
*
* @return Response
*/
- public function import(Request $request, Response $response) :Response
+ public function import(Request $request, Response $response): Response
{
$csv = new CsvIn($this->zdb);
$existing = $csv->getExisting();
*
* @return Response
*/
- public function doImports(Request $request, Response $response) :Response
+ public function doImports(Request $request, Response $response): Response
{
$csv = new CsvIn($this->zdb);
$post = $request->getParsedBody();
*
* @return Response
*/
- public function uploadImportFile(Request $request, Response $response) :Response
+ public function uploadImportFile(Request $request, Response $response): Response
{
$csv = new CsvIn($this->zdb);
if (isset($_FILES['new_file'])) {
*
* @return Response
*/
- public function getFile(Request $request, Response $response, array $args = []) :Response
+ public function getFile(Request $request, Response $response, array $args = []): Response
{
$filename = $args['file'];
*
* @return Response
*/
- public function confirmRemoveFile(Request $request, Response $response, array $args = []) :Response
+ public function confirmRemoveFile(Request $request, Response $response, array $args = []): Response
{
$data = [
'id' => $args['id'],
*
* @return Response
*/
- public function removeFile(Request $request, Response $response, array $args = []) :Response
+ public function removeFile(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
$ajax = isset($post['ajax']) && $post['ajax'] === 'true';
*
* @return Response
*/
- public function importModel(Request $request, Response $response, array $args = []) :Response
+ public function importModel(Request $request, Response $response, array $args = []): Response
{
$model = new ImportModel();
$model->load();
*
* @return Response
*/
- public function getImportModel(Request $request, Response $response, array $args = []) :Response
+ public function getImportModel(Request $request, Response $response, array $args = []): Response
{
$model = new ImportModel();
$model->load();
*
* @return Response
*/
- public function storeModel(Request $request, Response $response, array $args = []) :Response
+ public function storeModel(Request $request, Response $response, array $args = []): Response
{
$model = new ImportModel();
$model->load();
*
* @return Response
*/
- public function membersExport(Request $request, Response $response, array $args = []) :Response
+ public function membersExport(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
$get = $request->getQueryParams();
*
* @return Response
*/
- public function dynamicTranslations(Request $request, Response $response, array $args = []) :Response
+ public function dynamicTranslations(Request $request, Response $response, array $args = []): Response
{
$text_orig = '';
if (isset($args['text_orig'])) {
*
* @return Response
*/
- public function doDynamicTranslations(Request $request, Response $response) :Response
+ public function doDynamicTranslations(Request $request, Response $response): Response
{
$post = $request->getParsedBody();
$error_detected = false;
*
* @return Response
*/
- public function slash(Request $request, Response $response, array $args = []) :Response
+ public function slash(Request $request, Response $response, array $args = []): Response
{
return $this->galetteRedirect($request, $response, $args);
}
*
* @return Response
*/
- public function systemInformation(Request $request, Response $response) :Response
+ public function systemInformation(Request $request, Response $response): Response
{
$sysinfos = new SysInfos();
$raw_infos = $sysinfos->getRawData(
*
* @return Response
*/
- public function dashboard(Request $request, Response $response) :Response
+ public function dashboard(Request $request, Response $response): Response
{
$news = new News($this->preferences->pref_rss_url);
*
* @return Response
*/
- public function preferences(Request $request, Response $response) :Response
+ public function preferences(Request $request, Response $response): Response
{
// flagging required fields
$required = array(
$d = dir(GALETTE_THEMES_PATH);
while (($entry = $d->read()) !== false) {
$full_entry = GALETTE_THEMES_PATH . $entry;
- if ($entry != '.'
+ if (
+ $entry != '.'
&& $entry != '..'
&& is_dir($full_entry)
- && file_exists($full_entry.'/page.tpl')
+ && file_exists($full_entry . '/page.tpl')
) {
$themes[] = $entry;
}
*
* @return Response
*/
- public function storePreferences(Request $request, Response $response) :Response
+ public function storePreferences(Request $request, Response $response): Response
{
$post = $request->getParsedBody();
$error_detected = [];
// picture upload
if (GALETTE_MODE !== 'DEMO' && isset($_FILES['logo'])) {
if ($_FILES['logo']['error'] === UPLOAD_ERR_OK) {
- if ($_FILES['logo']['tmp_name'] !='') {
+ if ($_FILES['logo']['tmp_name'] != '') {
if (is_uploaded_file($_FILES['logo']['tmp_name'])) {
$res = $this->logo->store($_FILES['logo']);
if ($res < 0) {
// Card logo upload
if (GALETTE_MODE !== 'DEMO' && isset($_FILES['card_logo'])) {
if ($_FILES['card_logo']['error'] === UPLOAD_ERR_OK) {
- if ($_FILES['card_logo']['tmp_name'] !='') {
+ if ($_FILES['card_logo']['tmp_name'] != '') {
if (is_uploaded_file($_FILES['card_logo']['tmp_name'])) {
$res = $this->print_logo->store($_FILES['card_logo']);
if ($res < 0) {
*
* @return Response
*/
- public function testEmail(Request $request, Response $response) :Response
+ public function testEmail(Request $request, Response $response): Response
{
$sent = false;
if (!$this->preferences->pref_mail_method > GaletteMail::METHOD_DISABLED) {
*
* @return Response
*/
- public function charts(Request $request, Response $response) :Response
+ public function charts(Request $request, Response $response): Response
{
$charts = new Charts(
array(
*
* @return Response
*/
- public function configureCoreFields(Request $request, Response $response) :Response
+ public function configureCoreFields(Request $request, Response $response): Response
{
$fc = $this->fields_config;
*
* @return Response
*/
- public function storeCoreFieldsConfig(Request $request, Response $response) :Response
+ public function storeCoreFieldsConfig(Request $request, Response $response): Response
{
$post = $request->getParsedBody();
$fc = $this->fields_config;
*
* @return Response
*/
- public function configureListFields(Request $request, Response $response, array $args = []) :Response
+ public function configureListFields(Request $request, Response $response, array $args = []): Response
{
$table = $args['table'];
//TODO: check if type table exists
*
* @return Response
*/
- public function storeListFields(Request $request, Response $response, array $args = []) :Response
+ public function storeListFields(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
*
* @return Response
*/
- public function fakeData(Request $request, Response $response) :Response
+ public function fakeData(Request $request, Response $response): Response
{
$params = [
'page_title' => _T('Generate fake data'),
*
* @return Response
*/
- public function doFakeData(Request $request, Response $response) :Response
+ public function doFakeData(Request $request, Response $response): Response
{
$post = $request->getParsedBody();
*
* @return Response
*/
- public function reminders(Request $request, Response $response) :Response
+ public function reminders(Request $request, Response $response): Response
{
$texts = new Texts($this->preferences, $this->router);
*
* @return Response
*/
- public function doReminders(Request $request, Response $response) :Response
+ public function doReminders(Request $request, Response $response): Response
{
$error_detected = [];
$warning_detected = [];
*
* @return Response
*/
- public function filterReminders(Request $request, Response $response, array $args = []) :Response
+ public function filterReminders(Request $request, Response $response, array $args = []): Response
{
//always reset filters
$filters = new MembersList();
*
* @return Response
*/
- public function documentLink(Request $request, Response $response, array $args = []) :Response
+ public function documentLink(Request $request, Response $response, array $args = []): Response
{
// display page
$this->view->render(
*
* @return Response
*/
- public function history(Request $request, Response $response, array $args = []) :Response
+ public function history(Request $request, Response $response, array $args = []): Response
{
$option = null;
if (isset($args['option'])) {
*
* @return Response
*/
- public function historyFilter(Request $request, Response $response) :Response
+ public function historyFilter(Request $request, Response $response): Response
{
$post = $request->getParsedBody();
$error_detected = [];
if (isset($post['clear_filter'])) {
$filters->reinit();
} else {
- if ((isset($post['nbshow']) && is_numeric($post['nbshow']))
+ if (
+ (isset($post['nbshow']) && is_numeric($post['nbshow']))
) {
$filters->show = $post['nbshow'];
}
*
* @return Response
*/
- public function flushHistory(Request $request, Response $response) :Response
+ public function flushHistory(Request $request, Response $response): Response
{
$post = $request->getParsedBody();
$ajax = isset($post['ajax']) && $post['ajax'] === 'true';
*
* @return Response
*/
- public function confirmHistoryFlush(Request $request, Response $response) :Response
+ public function confirmHistoryFlush(Request $request, Response $response): Response
{
$data = [
'redirect_uri' => $this->router->pathFor('history')
*
* @return Response
*/
- protected function sendResponse(Response $response, Picture $picture) :Response
+ protected function sendResponse(Response $response, Picture $picture): Response
{
$response = $response->withHeader('Content-Type', $picture->getMime())
->withHeader('Content-Transfer-Encoding', 'binary')
*
* @return Response
*/
- public function logo(Request $request, Response $response) :Response
+ public function logo(Request $request, Response $response): Response
{
return $this->sendResponse($response, $this->logo);
}
*
* @return Response
*/
- public function printLogo(Request $request, Response $response) :Response
+ public function printLogo(Request $request, Response $response): Response
{
return $this->sendResponse($response, $this->print_logo);
}
*
* @return Response
*/
- public function photo(Request $request, Response $response, array $args) :Response
+ public function photo(Request $request, Response $response, array $args): Response
{
$id = (int)$args['id'];
$adh = new Adherent($this->zdb, (int)$id, $deps);
$picture = null;
- if ($adh->canEdit($this->login)
+ if (
+ $adh->canEdit($this->login)
|| $this->preferences->showPublicPages($this->login)
&& $adh->appearsInMembersList()
) {
*
* @return Response
*/
- protected function sendResponse(Response $response, Pdf $pdf) :Response
+ protected function sendResponse(Response $response, Pdf $pdf): Response
{
return $response
->withHeader('Content-type', 'application/pdf')
*
* @return Response
*/
- public function membersCards(Request $request, Response $response, array $args = []) :Response
+ public function membersCards(Request $request, Response $response, array $args = []): Response
{
if ($this->session->filter_members) {
$filters = $this->session->filter_members;
$filters = new MembersList();
}
- if (isset($args[Adherent::PK])
+ if (
+ isset($args[Adherent::PK])
&& $args[Adherent::PK] > 0
) {
$id_adh = $args[Adherent::PK];
*
* @return Response
*/
- public function membersLabels(Request $request, Response $response) :Response
+ public function membersLabels(Request $request, Response $response): Response
{
$post = $request->getParsedBody();
$get = $request->getQueryParams();
}
$members = null;
- if (isset($get['from'])
+ if (
+ isset($get['from'])
&& $get['from'] === 'mailing'
) {
//if we're from mailing, we have to retrieve
*
* @return Response
*/
- public function adhesionForm(Request $request, Response $response, array $args = []) :Response
+ public function adhesionForm(Request $request, Response $response, array $args = []): Response
{
$id_adh = isset($args[Adherent::PK]) ? (int)$args[Adherent::PK] : null;
$adh = new Adherent($this->zdb, $id_adh, ['dynamics' => true]);
*
* @return Response
*/
- public function attendanceSheetConfig(Request $request, Response $response, array $args = []) :Response
+ public function attendanceSheetConfig(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
// check for ajax mode
$ajax = false;
- if ($request->isXhr()
+ if (
+ $request->isXhr()
|| isset($post['ajax'])
&& $post['ajax'] == 'true'
) {
*
* @return Response
*/
- public function attendanceSheet(Request $request, Response $response) :Response
+ public function attendanceSheet(Request $request, Response $response): Response
{
$post = $request->getParsedBody();
'doc_title' => $doc_title,
'title' => $post['sheet_title'] ?? null,
'subtitle' => $post['sheet_sub_title'] ?? null,
- 'sheet_date'=> $post['sheet_date'] ?? null
+ 'sheet_date' => $post['sheet_date'] ?? null
];
$pdf = new PdfAttendanceSheet($this->zdb, $this->preferences, $data);
//with or without images?
*
* @return Response
*/
- public function contribution(Request $request, Response $response, array $args = []) :Response
+ public function contribution(Request $request, Response $response, array $args = []): Response
{
$contribution = new Contribution($this->zdb, $this->login, (int)$args['id']);
if ($contribution->id == '') {
*
* @return Response
*/
- public function group(Request $request, Response $response, array $args = []) :Response
+ public function group(Request $request, Response $response, array $args = []): Response
{
$groups = new Groups($this->zdb, $this->login);
*
* @return Response
*/
- public function models(Request $request, Response $response, array $args = []) :Response
+ public function models(Request $request, Response $response, array $args = []): Response
{
$id = 1;
if (isset($_POST[PdfModel::PK])) {
//Render directly template if we called from ajax,
//render in a full page otherwise
- if ($request->isXhr()
+ if (
+ $request->isXhr()
|| isset($request->getQueryParams()['ajax'])
&& $request->getQueryParams()['ajax'] == 'true'
) {
*
* @return Response
*/
- public function storeModels(Request $request, Response $response, array $args = []) :Response
+ public function storeModels(Request $request, Response $response, array $args = []): Response
{
$post = $request->getParsedBody();
$type = null;
*
* @return Response
*/
- public function directlinkDocument(Request $request, Response $response, array $args = []) :Response
+ public function directlinkDocument(Request $request, Response $response, array $args = []): Response
{
$hash = $args['hash'];
$post = $request->getParsedBody();
*
* @return Response
*/
- public function showPlugins(Request $request, Response $response) :Response
+ public function showPlugins(Request $request, Response $response): Response
{
$plugins = $this->plugins;
*
* @return Response
*/
- public function togglePlugin(Request $request, Response $response, array $args = []) :Response
+ public function togglePlugin(Request $request, Response $response, array $args = []): Response
{
if (GALETTE_MODE !== 'DEMO') {
$plugins = $this->plugins;
*
* @return Response
*/
- public function initPluginDb(Request $request, Response $response, array $args = []) :Response
+ public function initPluginDb(Request $request, Response $response, array $args = []): Response
{
if (GALETTE_MODE === 'DEMO') {
Analog::log(
$install = null;
$mdplugin = md5($plugin['root']);
- if (isset($this->session->$mdplugin)
+ if (
+ isset($this->session->$mdplugin)
&& !isset($_GET['raz'])
) {
$install = $this->session->$mdplugin;
' | Query was: ' . $query,
Analog::WARNING
);
- if ((strcasecmp(trim($w1), 'drop') != 0)
+ if (
+ (strcasecmp(trim($w1), 'drop') != 0)
&& (strcasecmp(trim($w1), 'rename') != 0)
) {
$error_detected[] = $w1 . ' ' . $w2 . ' ' . $w3 . ' ' . $extra;
*/
public function makeRandomPassword($size = null)
{
- if ($size === null
+ if (
+ $size === null
|| trim($size) == ''
|| !is_int($size)
) {
$pass = '';
$i = 0;
while ($i <= $size - 1) {
- $num = mt_rand(0, 32)%33;
+ $num = mt_rand(0, 32) % 33;
$pass .= substr($this->chars, $num, 1);
$i++;
}
if ($translated) {
$mstring = _T("either 'mysql' or 'pgsql' PDO driver");
}
- if (!extension_loaded('pdo_mysql')
+ if (
+ !extension_loaded('pdo_mysql')
&& !extension_loaded('pdo_pgsql')
) {
$this->missing[] = $mstring;
<?php
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
} elseif ($type === self::PGSQL) {
$_type = 'Pdo_Pgsql';
} else {
- throw new \Exception;
+ throw new \Exception();
}
$_options = array(
$sql = 'SELECT pg_database_size(\'' . NAME_DB . '\')';
$result = $this->db->query($sql, Adapter::QUERY_MODE_EXECUTE)
->current();
- $infos['size'] = (string)round($result['pg_database_size']/1024/1024);
+ $infos['size'] = (string)round($result['pg_database_size'] / 1024 / 1024);
} else {
$sql = 'SELECT @@sql_mode as mode, @@version AS version, @@version_comment AS version_comment';
$result = $this->db->query($sql, Adapter::QUERY_MODE_EXECUTE)
);
}
- if ($this->preferences->pref_mail_smtp_port
+ if (
+ $this->preferences->pref_mail_smtp_port
&& $this->preferences->pref_mail_smtp_port != ''
) {
// set the SMTP port for the SMTP server
*/
public static function findUserIPAddress()
{
- if (defined('GALETTE_X_FORWARDED_FOR_INDEX')
+ if (
+ defined('GALETTE_X_FORWARDED_FOR_INDEX')
&& isset($_SERVER['HTTP_X_FORWARDED_FOR'])
) {
$split_xff = preg_split('/,\s*/', $_SERVER['HTTP_X_FORWARDED_FOR']);
{
setlocale(LC_ALL, $this->getLongID());
- if (putenv("LANG=" . $this->getLongID())
+ if (
+ putenv("LANG=" . $this->getLongID())
or putenv("LANGUAGE=" . $this->getLongID())
or putenv("LC_ALL=" . $this->getLongID())
) {
namespace Galette\Core;
-use \Analog\Analog;
+use Analog\Analog;
use Laminas\Db\Adapter\Adapter;
/**
public function atPreviousStep()
{
if ($this->_step > 0) {
- if ($this->_step - 1 !== self::STEP_DB_INSTALL
+ if (
+ $this->_step - 1 !== self::STEP_DB_INSTALL
&& $this->_step !== self::STEP_END
) {
if ($this->_step === self::STEP_DB_INSTALL) {
}
}
}
- if (preg_match(
- "/upgrade-to-(.*)-" . $db_type . ".sql/",
- $file,
- $ver
- )) {
+ if (
+ preg_match(
+ "/upgrade-to-(.*)-" . $db_type . ".sql/",
+ $file,
+ $ver
+ )
+ ) {
if ($version === null) {
$sql_update_scripts[$ver[1]] = $ver[1];
} else {
$log_lvl = Analog::WARNING;
//if error are on drop, DROP, rename or RENAME we can continue
$parts = explode(' ', $query, 1);
- if ((strcasecmp(trim($parts[0]), 'drop') != 0)
+ if (
+ (strcasecmp(trim($parts[0]), 'drop') != 0)
&& (strcasecmp(trim($parts[0]), 'rename') != 0)
) {
$log_lvl = Analog::ERROR;
$this->setDbType($existing['db_type'], $error_detected);
}
- if ($existing['db_host'] !== null
+ if (
+ $existing['db_host'] !== null
|| $existing['db_user'] !== null
|| $existing['db_name'] !== null
) {
//if config file is already up-to-date, nothing to write
$existing = $this->loadExistingConfigFile(array(), true);
- if (isset($existing['db_type'])
+ if (
+ isset($existing['db_type'])
&& $existing['db_type'] == $this->_db_type
&& isset($existing['db_host'])
&& $existing['db_host'] == $this->_db_host
}
$conffile = GALETTE_CONFIG_PATH . 'config.inc.php';
- if (is_writable(GALETTE_CONFIG_PATH)
+ if (
+ is_writable(GALETTE_CONFIG_PATH)
&& (!file_exists($conffile) || file_exists($conffile) && is_writable($conffile))
&& $fd = @fopen($conffile, 'w')
) {
$active = $row->activite_adh;
if (!$row->activite_adh == true) {
Analog::log(
- 'Member `' . $user .' is inactive!`' . $log_suffix,
+ 'Member `' . $user . ' is inactive!`' . $log_suffix,
Analog::WARNING
);
return false;
}
//staff members and admins are de facto groups managers. For all
//others, get managed groups
- if (!$this->isSuperAdmin()
+ if (
+ !$this->isSuperAdmin()
&& !$this->isAdmin()
&& !$this->isStaff()
) {
private function loadAttachments()
{
$dir = '';
- if (isset($this->tmp_path)
+ if (
+ isset($this->tmp_path)
&& trim($this->tmp_path) !== ''
) {
$dir = $this->tmp_path;
*/
public function moveAttachments($id)
{
- if (isset($this->tmp_path)
+ if (
+ isset($this->tmp_path)
&& trim($this->tmp_path) !== ''
&& count($this->attachments) > 0
) {
public function removeAttachment($name)
{
$to_remove = null;
- if (isset($this->tmp_path)
+ if (
+ isset($this->tmp_path)
&& trim($this->tmp_path) !== ''
&& file_exists($this->tmp_path)
) {
public function removeAttachments($temp = false)
{
$to_remove = null;
- if (isset($this->tmp_path)
+ if (
+ isset($this->tmp_path)
&& trim($this->tmp_path) !== ''
&& file_exists($this->tmp_path)
) {
}
break;
case 'current_step':
- if (is_int($value)
+ if (
+ is_int($value)
&& ($value == self::STEP_START
|| $value == self::STEP_PREVIEW
|| $value == self::STEP_SEND
if ($this->show !== 0) {
$select->limit($this->show);
$select->offset(
- ($this->current_page - 1)*$this->show
+ ($this->current_page - 1) * $this->show
);
}
}
protected function countPages()
{
if ($this->show !== 0) {
- if ($this->counter%$this->show == 0) {
- $this->pages = intval($this->counter/$this->show);
+ if ($this->counter % $this->show == 0) {
+ $this->pages = intval($this->counter / $this->show);
} else {
- $this->pages = intval($this->counter/$this->show) + 1;
+ $this->pages = intval($this->counter / $this->show) + 1;
}
} else {
$this->pages = 0;
}
break;
case 'show':
- if ($value == 'all'
+ if (
+ $value == 'all'
|| preg_match('/[[:digit:]]/', $value)
&& $value >= 0
) {
{
$dh = @opendir(GALETTE_TEMPIMAGES_PATH);
while ($file = readdir($dh)) {
- if (substr($file, 0, 3) == 'pw_'
+ if (
+ substr($file, 0, 3) == 'pw_'
&& time() - filemtime(GALETTE_TEMPIMAGES_PATH . '/' . $file) > 60
) {
unlink(GALETTE_TEMPIMAGES_PATH . '/' . $file);
$this->generateNewPassword();
$pass = $this->getNewPassword();
- $png = imagecreate(10 + 7.5*strlen($pass), 18);
+ $png = imagecreate(10 + 7.5 * strlen($pass), 18);
$bg = imagecolorallocate($png, 160, 160, 160);
imagestring($png, 3, 5, 2, $pass, imagecolorallocate($png, 0, 0, 0));
$file = GALETTE_TEMPIMAGES_PATH . '/' . $this->getImageName();
if ($this->height > $this->width) {
if ($this->height > $this->max_height) {
- $ratio = $this->max_height/$this->height;
+ $ratio = $this->max_height / $this->height;
$this->optimal_height = $this->max_height;
- $this->optimal_width = $this->width*$ratio;
+ $this->optimal_width = $this->width * $ratio;
}
} else {
if ($this->width > $this->max_width) {
- $ratio = $this->max_width/$this->width;
+ $ratio = $this->max_width / $this->width;
$this->optimal_width = $this->max_width;
- $this->optimal_height = $this->height*$ratio;
+ $this->optimal_height = $this->height * $ratio;
}
}
}
}
//Second, let's check file size
- if ($file['size'] > ($this->maxlenght*1024)) {
+ if ($file['size'] > ($this->maxlenght * 1024)) {
Analog::log(
- '[' . $class . '] File is too big (' . ($file['size']*1024) .
- 'Ko for maximum authorized ' . ($this->maxlenght*1024) .
+ '[' . $class . '] File is too big (' . ($file['size'] * 1024) .
+ 'Ko for maximum authorized ' . ($this->maxlenght * 1024) .
'Ko',
Analog::ERROR
);
list($cur_width, $cur_height, $cur_type, $curattr)
= getimagesize($source);
- $ratio = $cur_width/$cur_height;
+ $ratio = $cur_width / $cur_height;
// calculate image size according to ratio
if ($cur_width > $cur_height) {
- $h = $w/$ratio;
+ $h = $w / $ratio;
} else {
- $w = $h*$ratio;
+ $w = $h * $ratio;
}
$thumb = imagecreatetruecolor($w, $h);
namespace Galette\Core;
-use \Analog\Analog;
+use Analog\Analog;
use Laminas\Db\Adapter\Adapter;
/**
public function atPreviousStep()
{
if ($this->_step > 0) {
- if ($this->_step - 1 !== self::STEP_DB_INSTALL
+ if (
+ $this->_step - 1 !== self::STEP_DB_INSTALL
&& $this->_step !== self::STEP_END
) {
if ($this->_step === self::STEP_DB_INSTALL) {
if ($entry != '.' && $entry != '..' && is_dir($full_entry)) {
$this->id = $entry;
$this->mroot = $full_entry;
- if (!file_exists($full_entry . '/_define.php')
+ if (
+ !file_exists($full_entry . '/_define.php')
|| !file_exists($full_entry . '/_routes.php')
) {
//plugin is not compatible with that version of galette.
'acls' => $acls,
'date' => $release_date,
'priority' => $priority === null ?
- 1000 : (integer)$priority,
+ 1000 : (int)$priority,
'root_writable' => is_writable($this->mroot),
'route' => $route
);
global $emitter;
$providerClassName = '\\' . $this->getNamespace($id) . '\\' . 'PluginEventProvider';
- if (class_exists($providerClassName)
+ if (
+ class_exists($providerClassName)
&& method_exists($providerClassName, 'provideListeners')
) {
$emitter->useListenerProvider(new $providerClassName());
}
// missing relations
- if (GALETTE_MODE !== 'DEMO'
+ if (
+ GALETTE_MODE !== 'DEMO'
&& isset($insert_values['pref_mail_method'])
) {
if ($insert_values['pref_mail_method'] > GaletteMail::METHOD_DISABLED) {
- if (!isset($insert_values['pref_email_nom'])
+ if (
+ !isset($insert_values['pref_email_nom'])
|| $insert_values['pref_email_nom'] == ''
) {
$this->errors[] = _T("- You must indicate a sender name for emails!");
}
- if (!isset($insert_values['pref_email'])
+ if (
+ !isset($insert_values['pref_email'])
|| $insert_values['pref_email'] == ''
) {
$this->errors[] = _T("- You must indicate an email address Galette should use to send emails!");
}
if ($insert_values['pref_mail_method'] == GaletteMail::METHOD_SMTP) {
- if (!isset($insert_values['pref_mail_smtp_host'])
+ if (
+ !isset($insert_values['pref_mail_smtp_host'])
|| $insert_values['pref_mail_smtp_host'] == ''
) {
$this->errors[] = _T("- You must indicate the SMTP server you want to use!");
}
}
- if ($insert_values['pref_mail_method'] == GaletteMail::METHOD_GMAIL
+ if (
+ $insert_values['pref_mail_method'] == GaletteMail::METHOD_GMAIL
|| ($insert_values['pref_mail_method'] == GaletteMail::METHOD_SMTP
&& $insert_values['pref_mail_smtp_auth'])
) {
- if (!isset($insert_values['pref_mail_smtp_user'])
+ if (
+ !isset($insert_values['pref_mail_smtp_user'])
|| trim($insert_values['pref_mail_smtp_user']) == ''
) {
$this->errors[] = _T("- You must provide a login for SMTP authentication.");
}
- if (!isset($insert_values['pref_mail_smtp_password'])
+ if (
+ !isset($insert_values['pref_mail_smtp_password'])
|| ($insert_values['pref_mail_smtp_password']) == ''
) {
$this->errors[] = _T("- You must provide a password for SMTP authentication.");
}
}
- if (isset($insert_values['pref_beg_membership'])
+ if (
+ isset($insert_values['pref_beg_membership'])
&& $insert_values['pref_beg_membership'] != ''
&& isset($insert_values['pref_membership_ext'])
&& $insert_values['pref_membership_ext'] != ''
$this->errors[] = _T("- Default membership extention and beginning of membership are mutually exclusive.");
}
- if (isset($insert_values['pref_membership_offermonths'])
+ if (
+ isset($insert_values['pref_membership_offermonths'])
&& (int)$insert_values['pref_membership_offermonths'] > 0
&& isset($insert_values['pref_membership_ext'])
&& $insert_values['pref_membership_ext'] != ''
// update preferences
foreach ($insert_values as $champ => $valeur) {
- if ($login->isSuperAdmin()
+ if (
+ $login->isSuperAdmin()
|| (!$login->isSuperAdmin()
&& ($champ != 'pref_admin_pass' && $champ != 'pref_admin_login'))
) {
- if (($champ == "pref_admin_pass" && $_POST['pref_admin_pass'] != '')
+ if (
+ ($champ == "pref_admin_pass" && $_POST['pref_admin_pass'] != '')
|| ($champ != "pref_admin_pass")
) {
$this->$champ = $valeur;
$stmt = $this->zdb->sql->prepareStatementForSqlObject($update);
foreach (self::$defaults as $k => $v) {
- if (GALETTE_MODE == 'DEMO'
+ if (
+ GALETTE_MODE == 'DEMO'
&& in_array($k, ['pref_admin_pass', 'pref_admin_login', 'pref_mail_method'])
) {
continue;
break;
case self::PUBLIC_PAGES_VISIBILITY_RESTRICTED:
//pages should be displayed only for up to date members
- if ($login->isUp2Date()
+ if (
+ $login->isUp2Date()
|| $login->isAdmin()
|| $login->isStaff()
) {
$virtuals = array('vpref_email_newadh');
if (!in_array($name, $forbidden) && isset($this->prefs[$name])) {
- if (GALETTE_MODE === 'DEMO'
+ if (
+ GALETTE_MODE === 'DEMO'
&& $name == 'pref_mail_method'
) {
return GaletteMail::METHOD_DISABLED;
return false;
}
- if ($name == 'pref_email'
+ if (
+ $name == 'pref_email'
|| $name == 'pref_email_newadh'
|| $name == 'pref_email_reply_to'
) {
//check page width
$max = 210;
//margins
- $size = $this->pref_card_marges_h*2;
+ $size = $this->pref_card_marges_h * 2;
//cards
- $size += PdfMembersCards::getWidth()*PdfMembersCards::getCols();
+ $size += PdfMembersCards::getWidth() * PdfMembersCards::getCols();
//spacing
- $size += $this->pref_card_hspace*(PdfMembersCards::getCols() - 1);
+ $size += $this->pref_card_hspace * (PdfMembersCards::getCols() - 1);
if ($size > $max) {
$warning_detected[] = _T('Current cards configuration may exceed page width!');
}
$max = 297;
//margins
- $size = $this->pref_card_marges_v*2;
+ $size = $this->pref_card_marges_v * 2;
//cards
- $size += PdfMembersCards::getHeight()*PdfMembersCards::getRows();
+ $size += PdfMembersCards::getHeight() * PdfMembersCards::getRows();
//spacing
- $size += $this->pref_card_vspace*(PdfMembersCards::getRows() - 1);
+ $size += $this->pref_card_vspace * (PdfMembersCards::getRows() - 1);
if ($size > $max) {
$warning_detected[] = _T('Current cards configuration may exceed page height!');
}
$str .= "\n" . 'PHP loaded modules:';
$i = 0;
foreach (get_loaded_extensions() as $e) {
- if ($i%10 === 0) {
+ if ($i % 10 === 0) {
$str .= "\n ";
}
$str .= $e . ", ";
$this->errors = [];
$this->warnings = [];
- if ((!isset($values['field_name']) || $values['field_name'] == '')
+ if (
+ (!isset($values['field_name']) || $values['field_name'] == '')
&& get_class($this) != '\Galette\DynamicField\Separator'
) {
$this->errors[] = _T('Missing required field name!');
//Galette relative information
$this->_appears_in_list = ($r->bool_display_info == 1) ? true : false;
$this->_admin = ($r->bool_admin_adh == 1) ? true : false;
- if (isset($r->priorite_statut)
+ if (
+ isset($r->priorite_statut)
&& $r->priorite_statut < Members::NON_STAFF_MEMBERS
) {
$this->_staff = true;
$date_end = new \DateTime($this->_due_date);
$date_diff = $date_now->diff($date_end);
$this->_days_remaining = ($date_diff->invert == 1)
- ? $date_diff->days*-1
+ ? $date_diff->days * -1
: $date_diff->days;
if ($this->_days_remaining == 0) {
$patterns = array('/%days/', '/%date/');
$ddate = new \DateTime($this->_due_date);
$replace = array(
- $this->_days_remaining*-1,
+ $this->_days_remaining * -1,
$ddate->format(__("Y-m-d"))
);
if ($this->_active) {
}
//no parent if checkbox was unchecked
- if (!isset($values['attach'])
+ if (
+ !isset($values['attach'])
&& empty($this->_id)
&& isset($values['parent_id'])
) {
// now, check validity
if ($value !== null && $value != '') {
$this->validate($key, $value, $values);
- } elseif (($key == 'login_adh' && !isset($required['login_adh']))
+ } elseif (
+ ($key == 'login_adh' && !isset($required['login_adh']))
|| ($key == 'mdp_adh' && !isset($required['mdp_adh']))
&& !isset($this->_id)
) {
$d->setTime(0, 0, 0);
$diff = $now->diff($d);
- $days = (integer)$diff->format('%R%a');
+ $days = (int)$diff->format('%R%a');
if ($days >= 0) {
$this->errors[] = _T('- Birthdate must be set in the past!');
}
- $years = (integer)$diff->format('%R%Y');
+ $years = (int)$diff->format('%R%Y');
if ($years <= -200) {
$this->errors[] = str_replace(
'%years',
- $years*-1,
+ $years * -1,
_T('- Members must be less than 200 years old (currently %years)!')
);
}
}
$results = $this->zdb->execute($select);
- if ($results->count() !== 0
+ if (
+ $results->count() !== 0
|| $value == $preferences->pref_admin_login
) {
$this->errors[] = _T("- This username is already in use, please choose another one!");
}
break;
case 'mdp_adh':
- if ($this->_self_adh !== true
+ if (
+ $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
+ } elseif (
+ $this->_self_adh === true
&& !crypt($value, $values['mdp_crypt']) == $values['mdp_crypt']
) {
$this->errors[] = _T("Password misrepeated: ");
$fields = self::getDbFields($this->zdb);
foreach ($fields as $field) {
- if ($field !== 'date_modif_adh'
+ if (
+ $field !== 'date_modif_adh'
|| !isset($this->_id)
|| $this->_id == ''
) {
$prop = '_' . $this->fields[$field]['propname'];
- if (($field === 'bool_admin_adh'
+ if (
+ ($field === 'bool_admin_adh'
|| $field === 'bool_exempt_adh'
|| $field === 'bool_display_info'
|| $field === 'activite_adh')
//do not work with knows bad dates...
//the one with BC comes from 0.63/pgsl demo... Why the hell a so
//strange date? dont know :(
- if ($enddate !== '0000-00-00'
+ if (
+ $enddate !== '0000-00-00'
&& $enddate !== '1901-01-01'
&& $enddate !== '0001-01-01 BC'
) {
foreach ($required as $key => $val) {
if ($val === 1) {
$prop = '_' . $this->_fields[$key]['propname'];
- if (!isset($disabled[$key])
+ if (
+ !isset($disabled[$key])
&& (!isset($this->$prop)
|| (!is_object($this->$prop) && trim($this->$prop) == '')
|| (is_object($this->$prop) && trim($this->$prop->id) == ''))
default:
throw new \RuntimeException("Call to __get for '$name' is forbidden!");
}
- } elseif (property_exists($this, $rname)
+ } elseif (
+ property_exists($this, $rname)
|| in_array($name, $virtuals)
) {
switch ($name) {
$date_end = new \DateTime($this->_end_date);
$date_start = new \DateTime($this->_begin_date);
$diff = $date_end->diff($date_start);
- return $diff->format('%y')*12 + $diff->format('%m');
+ return $diff->format('%y') * 12 + $diff->format('%m');
} else {
return '';
}
$this->delete_stmt->execute($entry);
//update val index
$field_id = $entry['where3'];
- if (isset($this->current_values[$field_id])
+ if (
+ isset($this->current_values[$field_id])
&& count($this->current_values[$field_id])
) {
$val_index = (int)$entry['where4'];
foreach ($this->dynamic_fields as $field) {
$perm = $field->getPerm();
- if (($perm == DynamicField::PERM_MANAGER &&
+ if (
+ ($perm == DynamicField::PERM_MANAGER &&
$access_level < Authentication::ACCESS_MANAGER) ||
($perm == DynamicField::PERM_STAFF &&
$access_level < Authentication::ACCESS_STAFF) ||
if (!isset($disabled[$key])) {
if (substr($key, 0, 11) == 'info_field_') {
list($field_id, $val_index) = explode('_', substr($key, 11));
- if (is_numeric($field_id)
+ if (
+ is_numeric($field_id)
&& is_numeric($val_index)
) {
if ($fields[$field_id]->isRequired() && (trim($value) === '' || $value == null)) {
continue;
}
- if ($file['error'] == UPLOAD_ERR_NO_FILE
+ if (
+ $file['error'] == UPLOAD_ERR_NO_FILE
&& $file['name'] == ''
- && $file['tmp_name'] == '') {
+ && $file['tmp_name'] == ''
+ ) {
//not upload atempt.
continue;
} elseif ($file['error'] !== UPLOAD_ERR_OK) {
$max_size =
$fields[$field_id]->getSize() ?
- $fields[$field_id]->getSize()*1024 : File::DEFAULT_MAX_FILE_SIZE*1024;
+ $fields[$field_id]->getSize() * 1024 : File::DEFAULT_MAX_FILE_SIZE * 1024;
if ($file['size'] > $max_size) {
Analog::log(
"file too large: " . $file['size'] . " Ko, vs $max_size Ko allowed",
try {
$select = $this->zdb->select($this->table);
$fields = array($this->fpk, $this->flabel);
- if ($this->order_field !== false
+ if (
+ $this->order_field !== false
&& $this->order_field !== $this->fpk
&& $this->order_field !== $this->flabel
) {
{
$forbidden = array();
$virtuals = array('extension', 'libelle');
- if (in_array($name, $virtuals)
+ if (
+ in_array($name, $virtuals)
|| !in_array($name, $forbidden)
&& isset($this->$name)
) {
*
* @return array
*/
- public function getErrors() :array
+ public function getErrors(): array
{
return $this->errors;
}
*
* @return ArrayObject
*/
- protected function prepareField(ArrayObject $rset) :ArrayObject
+ protected function prepareField(ArrayObject $rset): ArrayObject
{
if ($rset->field_id === 'parent_id') {
$rset->readonly = true;
*
* @return array
*/
- protected function buildField(ArrayObject $rset) :array
+ protected function buildField(ArrayObject $rset): array
{
$rset = $this->prepareField($rset);
$f = array(
'label' => $this->defaults[$rset->field_id]['label'],
'category' => (int)$rset->id_field_category,
'visible' => (int)$rset->visible,
- 'required' => (boolean)$rset->required,
+ 'required' => (bool)$rset->required,
'propname' => $this->defaults[$rset->field_id]['propname'],
- 'position' =>(int)$rset->position,
+ 'position' => (int)$rset->position,
'disabled' => false
);
return $f;
$hidden_elements[] = $o;
} else {
// skip fields blacklisted for edition
- if (in_array($o->field_id, $this->non_form_elements)
+ if (
+ in_array($o->field_id, $this->non_form_elements)
|| $selfs && $this->isSelfExcluded($o->field_id)
) {
continue;
}
// skip fields according to access control
- if ($o->visible == self::NOBODY ||
+ if (
+ $o->visible == self::NOBODY ||
($o->visible == self::ADMIN &&
$access_level < Authentication::ACCESS_ADMIN) ||
($o->visible == self::STAFF &&
$o->type = self::TYPE_DATE;
} elseif (preg_match('/bool/', $o->field_id)) {
$o->type = self::TYPE_BOOL;
- } elseif ($o->field_id == 'titre_adh'
+ } elseif (
+ $o->field_id == 'titre_adh'
|| $o->field_id == 'pref_lang'
|| $o->field_id == 'id_statut'
) {
}
// disabled field according to access control
- if ($o->visible == self::USER_READ &&
- $access_level == Authentication::ACCESS_USER) {
+ if (
+ $o->visible == self::USER_READ &&
+ $access_level == Authentication::ACCESS_USER
+ ) {
$o->disabled = true;
} else {
$o->disabled = false;
}
// skip fields according to access control
- if ($o->visible == self::NOBODY ||
+ if (
+ $o->visible == self::NOBODY ||
($o->visible == self::ADMIN &&
$access_level < Authentication::ACCESS_ADMIN) ||
($o->visible == self::STAFF &&
unset($fields['mdp_adh']);
foreach ($fields as $k => $f) {
- if ($visibles[$k] == FieldsConfig::NOBODY ||
+ if (
+ $visibles[$k] == FieldsConfig::NOBODY ||
($visibles[$k] == FieldsConfig::ADMIN &&
$access_level < Authentication::ACCESS_ADMIN) ||
($visibles[$k] == FieldsConfig::STAFF &&
*
* @return array
*/
- public function getField($name) :array
+ public function getField($name): array
{
if (!isset($this->core_db_fields[$name])) {
throw new \UnexpectedValueException("$name fied does not exists");
public function getLevel()
{
if ($this->parent_group) {
- return $this->parent_group->getLevel()+1;
+ return $this->parent_group->getLevel() + 1;
}
return 0;
}
public function getFullName()
{
if ($this->parent_group) {
- return $this->parent_group->getFullName().' / '.$this->group_name;
+ return $this->parent_group->getFullName() . ' / ' . $this->group_name;
}
return $this->group_name;
}
public function getIndentName()
{
if (($level = $this->getLevel())) {
- return str_repeat(" ", 3*$level).'» '.$this->group_name;
+ return str_repeat(" ", 3 * $level) . '» ' . $this->group_name;
}
return $this->group_name;
}
*
* @return array
*/
- protected function buildField(ArrayObject $rset) :array
+ protected function buildField(ArrayObject $rset): array
{
$f = parent::buildField($rset);
- $f['list_position'] = (integer)$rset->list_position;
+ $f['list_position'] = (int)$rset->list_position;
$f['list_visible'] = ($f['list_position'] >= 0);
return $f;
}
}
// skip fields according to access control
- if ($o->visible == self::NOBODY ||
+ if (
+ $o->visible == self::NOBODY ||
($o->visible == self::ADMIN &&
$access_level < Authentication::ACCESS_ADMIN) ||
($o->visible == self::STAFF &&
*
* @return array
*/
- public function getListedFields() :array
+ public function getListedFields(): array
{
return $this->listed_fields;
}
*
* @return array
*/
- public function getRemainingFields() :array
+ public function getRemainingFields(): array
{
$db_fields = $this->core_db_fields;
*
* @return array
*/
- public function getAclMapping() :array
+ public function getAclMapping(): array
{
return $this->acl_mapping;
}
break;
default:
Analog::log(
- 'Unable to set property ' .$name,
+ 'Unable to set property ' . $name,
Analog::WARNING
);
break;
$value = null;
//get header and footer from parent if not defined in current model
- if ($this->id > self::MAIN_MODEL
+ if (
+ $this->id > self::MAIN_MODEL
&& $this->parent !== null
) {
$value = $this->parent->styles;
$prop_value = $this->$pname;
//get header and footer from parent if not defined in current model
- if ($this->id > self::MAIN_MODEL
+ if (
+ $this->id > self::MAIN_MODEL
&& trim($prop_value) === ''
&& $this->parent !== null
&& ($pname === 'footer'
{
switch ($name) {
case 'type':
- if ($value === self::MAIN_MODEL
+ if (
+ $value === self::MAIN_MODEL
|| $value === self::INVOICE_MODEL
|| $value === self::RECEIPT_MODEL
|| $value === self::ADHESION_FORM_MODEL
break;
default:
Analog::log(
- 'Unable to set PdfModel property ' .$name,
+ 'Unable to set PdfModel property ' . $name,
Analog::WARNING
);
break;
{
switch ($name) {
case 'type':
- if ($value === self::IMPENDING
+ if (
+ $value === self::IMPENDING
|| $value === self::LATE
) {
$this->type = $value;
$this->nomail = false;
}
if ($this->type === self::LATE) {
- $this->replaces['days_expired'] = $value->days_remaining*-1;
+ $this->replaces['days_expired'] = $value->days_remaining * -1;
}
if ($this->type === self::IMPENDING) {
$this->replaces['days_remaining'] = $value->days_remaining;
{
$forbidden = [];
$virtuals = ['sparameters'];
- if (in_array($name, $virtuals)
+ if (
+ in_array($name, $virtuals)
|| !in_array($name, $forbidden)
&& isset($this->$name)
) {
foreach ($this->defaults as $default) {
$exists = false;
foreach ($list as $text) {
- if ($text->tref == $default['tref']
+ if (
+ $text->tref == $default['tref']
&& $text->tlang == $default['tlang']
) {
$exists = true;
break;
case 'short':
case 'long':
- if ($name === 'long'
+ if (
+ $name === 'long'
&& ($this->long == null || trim($this->long) === '')
) {
$name = 'short';
$this->loadFromRS($result);
return true;
} else {
- throw new \Exception;
+ throw new \Exception();
}
} catch (\Exception $e) {
Analog::log(
*/
public function withinContributions()
{
- if ($this->_contrib_creation_date_begin != null
+ 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
Analog::DEBUG
);
- if (in_array($name, $this->pagination_fields)
+ if (
+ in_array($name, $this->pagination_fields)
|| in_array($name, $this->memberslist_fields)
) {
return parent::__get($name);
} else {
- if (in_array($name, $this->advancedmemberslist_fields)
+ if (
+ in_array($name, $this->advancedmemberslist_fields)
|| in_array($name, $this->virtuals_advancedmemberslist_fields)
) {
$rname = '_' . $name;
{
global $zdb, $preferences, $login;
- if (in_array($name, $this->pagination_fields)
+ if (
+ in_array($name, $this->pagination_fields)
|| in_array($name, $this->memberslist_fields)
) {
parent::__set($name, $value);
} else {
Analog::log(
'[AdvancedMembersList] Value for status filter should be an '
- .'integer (' . gettype($v) . ' given',
+ . 'integer (' . gettype($v) . ' given',
Analog::WARNING
);
}
} else {
Analog::log(
'[AdvancedMembersList] Value for payment type filter should be an '
- .'integer (' . gettype($v) . ' given',
+ . 'integer (' . gettype($v) . ' given',
Analog::WARNING
);
}
} else {
Analog::log(
'[AdvancedMembersList] Value for dynamic contribution fields filter should be an '
- .'array (' . gettype($value) . ' given',
+ . 'array (' . gettype($value) . ' given',
Analog::WARNING
);
}
unset($this->_groups_search['empty']);
}
if (is_array($value)) {
- if (isset($value['group'])
- && isset($value['idx'])
+ if (
+ isset($value['group'])
+ && isset($value['idx'])
) {
$id = $value['idx'];
unset($value['idx']);
} else {
Analog::log(
'[AdvancedMembersList] Value for group filter should be an '
- .'array (' . gettype($value) . ' given',
+ . 'array (' . gettype($value) . ' given',
Analog::WARNING
);
}
} else {
Analog::log(
'[AdvancedMembersList] Value for group filter logical operator should be '
- .' in [0,1] (' . gettype($value) . '-> ' . $value . ' given )',
+ . ' in [0,1] (' . gettype($value) . '-> ' . $value . ' given )',
Analog::WARNING
);
}
break;
default:
- if (substr($name, 0, 4) === 'cds_'
+ if (
+ substr($name, 0, 4) === 'cds_'
|| substr($name, 0, 5) === 'cdsc_'
) {
if (is_array($value) || trim($value) !== '') {
if (!is_array($data)) {
Analog::log(
'[AdvancedMembersList] Value for free filter should be an '
- .'array (' . gettype($data) . ' given',
+ . 'array (' . gettype($data) . ' given',
Analog::WARNING
);
return false;
} elseif ($value !== null && $value !== '0') {
Analog::log(
'[MembersList] Value for group filter should be an '
- .'integer (' . gettype($value) . ' given)',
+ . 'integer (' . gettype($value) . ' given)',
Analog::WARNING
);
}
$raw_size = filesize($file);
$size = 0;
- if ($raw_size >= 1024*1024*1024) { // Go
- $size = round(($raw_size/1024)/1024/1024, 2) . ' Go';
- } elseif ($raw_size >= 1024*1024) { // Mo
- $size = round(($raw_size/1024)/1024, 2) . ' Mo';
+ if ($raw_size >= 1024 * 1024 * 1024) { // Go
+ $size = round(($raw_size / 1024) / 1024 / 1024, 2) . ' Go';
+ } elseif ($raw_size >= 1024 * 1024) { // Mo
+ $size = round(($raw_size / 1024) / 1024, 2) . ' Mo';
} elseif ($raw_size >= 1024) { // ko
- $size = round(($raw_size/1024), 2) . ' Ko';
+ $size = round(($raw_size / 1024), 2) . ' Ko';
} else { // octets
$size = $raw_size . ' octets';
}
array $members_fields_cats,
$dryrun
) {
- if (!file_exists(self::DEFAULT_DIRECTORY . '/' . $filename)
+ if (
+ !file_exists(self::DEFAULT_DIRECTORY . '/' . $filename)
|| !is_readable(self::DEFAULT_DIRECTORY . '/' . $filename)
) {
Analog::log(
);
$row = 0;
- while (($data = fgetcsv(
- $handle,
- 1000,
- self::DEFAULT_SEPARATOR,
- self::DEFAULT_QUOTE
- )) !== false) {
+ while (
+ ($data = fgetcsv(
+ $handle,
+ 1000,
+ self::DEFAULT_SEPARATOR,
+ self::DEFAULT_QUOTE
+ )) !== false
+ ) {
//check fields count
$count = count($data);
if ($count != $cnt_fields) {
$column = trim($column);
//check required fields
- if (in_array($this->_fields[$col], $this->_required)
+ if (
+ in_array($this->_fields[$col], $this->_required)
&& empty($column)
) {
$this->addError(
try {
$this->zdb->connection->beginTransaction();
- while (($data = fgetcsv(
- $handle,
- 1000,
- self::DEFAULT_SEPARATOR,
- self::DEFAULT_QUOTE
- )) !== false) {
+ while (
+ ($data = fgetcsv(
+ $handle,
+ 1000,
+ self::DEFAULT_SEPARATOR,
+ self::DEFAULT_QUOTE
+ )) !== false
+ ) {
if ($row > 0) {
$col = 0;
$values = array();
$values['is_company'] = true;
}
//check for booleans
- if (($this->_fields[$col] == 'bool_admin_adh'
+ if (
+ ($this->_fields[$col] == 'bool_admin_adh'
|| $this->_fields[$col] == 'bool_exempt_adh'
|| $this->_fields[$col] == 'bool_display_info'
|| $this->_fields[$col] == 'activite_adh')
*/
private function write($last = false)
{
- if ($last && $this->file
+ if (
+ $last && $this->file
|| !$last && $this->file
- && ($this->current_line%self::BUFLINES) == 0
+ && ($this->current_line % self::BUFLINES) == 0
) {
if ($this->file === true) {
echo $this->result;
'xslt' => 'application/xslt+xml',
'xsl' => 'application/xml',
'dtd' => 'application/xml-dtd',
- 'atom' =>'application/atom+xml',
- 'mathml' =>'application/mathml+xml',
- 'rdf' =>'application/rdf+xml',
- 'smi' =>'application/smil',
- 'smil' =>'application/smil',
- 'vxml' =>'application/voicexml+xml',
- 'latex' =>'application/x-latex',
- 'tcl' =>'application/x-tcl',
- 'tex' =>'application/x-tex',
- 'texinfo' =>'application/x-texinfo',
- 'wrl' =>'model/vrml',
- 'wrml' =>'model/vrml',
- 'ics' =>'text/calendar',
- 'ifb' =>'text/calendar',
- 'sgml' =>'text/sgml',
- 'htc' =>'text/x-component',
+ 'atom' => 'application/atom+xml',
+ 'mathml' => 'application/mathml+xml',
+ 'rdf' => 'application/rdf+xml',
+ 'smi' => 'application/smil',
+ 'smil' => 'application/smil',
+ 'vxml' => 'application/voicexml+xml',
+ 'latex' => 'application/x-latex',
+ 'tcl' => 'application/x-tcl',
+ 'tex' => 'application/x-tex',
+ 'texinfo' => 'application/x-texinfo',
+ 'wrl' => 'model/vrml',
+ 'wrml' => 'model/vrml',
+ 'ics' => 'text/calendar',
+ 'ifb' => 'text/calendar',
+ 'sgml' => 'text/sgml',
+ 'htc' => 'text/x-component',
'pgp' => 'application/pgp-signature',
'rtf' => 'application/rtf',
// images
}
//Second, let's check file size
- if ($file['size'] > ($this->maxlenght*1024)) {
+ if ($file['size'] > ($this->maxlenght * 1024)) {
Analog::log(
- '[' . $class . '] File is too big (' . ($file['size']*1024) .
- 'Ko for maximum authorized ' . ($this->maxlenght*1024) .
+ '[' . $class . '] File is too big (' . ($file['size'] * 1024) .
+ 'Ko for maximum authorized ' . ($this->maxlenght * 1024) .
'Ko',
Analog::ERROR
);
$mime = $this->getMimeType($tmpfile);
- if (count($this->allowed_mimes) > 0
+ if (
+ count($this->allowed_mimes) > 0
&& !in_array($mime, $this->allowed_mimes)
) {
Analog::log(
namespace Galette\IO;
-use \DateTime;
+use DateTime;
use Analog\Analog;
use Galette\Core\Db;
use Galette\Core\Login;
$labels = array();
foreach ($this->members_fields as $k => $f) {
// skip fields blacklisted for export
- if ($k === 'mdp_adh' ||
+ if (
+ $k === 'mdp_adh' ||
($export_fields !== null &&
(is_array($export_fields) && !in_array($k, $export_fields)))
) {
}
// skip fields according to access control
- if ($visibles[$k] == FieldsConfig::NOBODY ||
+ if (
+ $visibles[$k] == FieldsConfig::NOBODY ||
($visibles[$k] == FieldsConfig::ADMIN &&
$access_level < Authentication::ACCESS_ADMIN) ||
($visibles[$k] == FieldsConfig::STAFF &&
//handle dates
if (isset($member->date_crea_adh)) {
- if ($member->date_crea_adh != ''
+ if (
+ $member->date_crea_adh != ''
&& $member->date_crea_adh != '1901-01-01'
) {
$dcrea = new DateTime($member->date_crea_adh);
}
if (isset($member->date_modif_adh)) {
- if ($member->date_modif_adh != ''
+ if (
+ $member->date_modif_adh != ''
&& $member->date_modif_adh != '1901-01-01'
) {
$dmodif = new DateTime($member->date_modif_adh);
}
if (isset($member->date_echeance)) {
- if ($member->date_echeance != ''
+ if (
+ $member->date_echeance != ''
&& $member->date_echeance != '1901-01-01'
) {
$dech = new DateTime($member->date_echeance);
}
if (isset($member->ddn_adh)) {
- if ($member->ddn_adh != ''
+ if (
+ $member->ddn_adh != ''
&& $member->ddn_adh != '1901-01-01'
) {
$ddn = new DateTime($member->ddn_adh);
'</div>';
$this->writeHtml($hsubtitle);
}
- if (trim($this->model->title) !== ''
+ if (
+ trim($this->model->title) !== ''
|| trim($this->model->subtitle) !== ''
) {
$this->Ln(5);
$logofile = $print_logo->getPath();
// Set logo size to max width 30 mm or max height 25 mm
- $ratio = $print_logo->getWidth()/$print_logo->getHeight();
+ $ratio = $print_logo->getWidth() / $print_logo->getHeight();
if ($ratio < 1) {
if ($print_logo->getHeight() > 16) {
$hlogo = 25;
} else {
$hlogo = $print_logo->getHeight();
}
- $wlogo = round($hlogo*$ratio);
+ $wlogo = round($hlogo * $ratio);
} else {
if ($print_logo->getWidth() > 16) {
$wlogo = 30;
} else {
$wlogo = $print_logo->getWidth();
}
- $hlogo = round($wlogo/$ratio);
+ $hlogo = round($wlogo / $ratio);
}
$this->SetFont(self::FONT, 'B', self::FONT_SIZE + 4);
$p = $m->picture->getPath();
// Set logo size to max width 30 mm or max height 25 mm
- $ratio = $m->picture->getWidth()/$m->picture->getHeight();
+ $ratio = $m->picture->getWidth() / $m->picture->getHeight();
if ($ratio < 1) {
if ($m->picture->getHeight() > 14) {
$hlogo = 14;
} else {
$hlogo = $m->picture->getHeight();
}
- $wlogo = round($hlogo*$ratio);
+ $wlogo = round($hlogo * $ratio);
} else {
if ($m->picture->getWidth() > 14) {
$wlogo = 14;
} else {
$wlogo = $m->picture->getWidth();
}
- $hlogo = round($wlogo/$ratio);
+ $hlogo = round($wlogo / $ratio);
}
$y = $this->getY() + 1;
class PdfGroups extends Pdf
{
- const SHEET_FONT = self::FONT_SIZE-2;
+ const SHEET_FONT = self::FONT_SIZE - 2;
private $doc_title;
$this->logofile = $print_logo->getPath();
// Set logo size to max width 30 mm or max height 25 mm
- $ratio = $print_logo->getWidth()/$print_logo->getHeight();
+ $ratio = $print_logo->getWidth() / $print_logo->getHeight();
if ($ratio < 1) {
if ($print_logo->getHeight() > 16) {
$this->hlogo = 20;
} else {
$this->hlogo = $print_logo->getHeight();
}
- $this->wlogo = round($this->hlogo*$ratio);
+ $this->wlogo = round($this->hlogo * $ratio);
} else {
if ($print_logo->getWidth() > 16) {
$this->wlogo = 30;
} else {
$this->wlogo = $print_logo->getWidth();
}
- $this->hlogo = round($this->wlogo/$ratio);
+ $this->hlogo = round($this->wlogo / $ratio);
}
}
$nb_card = 0;
foreach ($members as $member) {
// Detect page breaks
- if ($nb_card%($this->nbcol*$this->nbrow) == 0) {
+ if ($nb_card % ($this->nbcol * $this->nbrow) == 0) {
$this->AddPage();
}
// Compute card position on page
- $col = $nb_card%$this->nbcol;
- $row = ($nb_card/$this->nbcol)%$this->nbrow;
+ $col = $nb_card % $this->nbcol;
+ $row = ($nb_card / $this->nbcol) % $this->nbrow;
// Set origin
- $x0 = $this->xorigin + $col*(round($this->wi) + round($this->hspacing));
- $y0 = $this->yorigin + $row*(round($this->he) + round($this->vspacing));
+ $x0 = $this->xorigin + $col * (round($this->wi) + round($this->hspacing));
+ $y0 = $this->yorigin + $row * (round($this->he) + round($this->vspacing));
// Logo X position
$xl = round($x0 + $this->wi - $this->wlogo);
// Get data
// Label heigth
$this->lh = round($this->preferences->pref_etiq_vsize);
// Line heigth
- $this->line_h = round($this->lh/5);
+ $this->line_h = round($this->lh / 5);
}
/**
// Detect page breaks
$colsrows = $this->preferences->pref_etiq_cols
* $this->preferences->pref_etiq_rows;
- if ($nb_etiq%$colsrows == 0) {
+ if ($nb_etiq % $colsrows == 0) {
$this->AddPage();
}
// Set font
$this->SetFont(self::FONT, 'B', $this->preferences->pref_etiq_corps);
// Compute label position
- $col = $nb_etiq%$this->preferences->pref_etiq_cols;
- $row = ($nb_etiq/$this->preferences->pref_etiq_cols)
+ $col = $nb_etiq % $this->preferences->pref_etiq_cols;
+ $row = ($nb_etiq / $this->preferences->pref_etiq_cols)
% $this->preferences->pref_etiq_rows;
// Set label origin
- $x = $this->xorigin + $col*(
+ $x = $this->xorigin + $col * (
round($this->preferences->pref_etiq_hsize) +
round($this->preferences->pref_etiq_hspace)
);
- $y = $this->yorigin + $row*(
+ $y = $this->yorigin + $row * (
round($this->preferences->pref_etiq_vsize) +
round($this->preferences->pref_etiq_vspace)
);
$this->Cell($this->lw, $this->line_h, $member->address, 0, 0, 'L', 0);
// Print second line of address
- $this->SetXY($x, $y + $this->line_h*2);
+ $this->SetXY($x, $y + $this->line_h * 2);
$this->Cell(
$this->lw,
$this->line_h,
'B'
);
- $this->SetXY($x, $y + $this->line_h*3);
+ $this->SetXY($x, $y + $this->line_h * 3);
$this->Cell(
$this->lw,
$this->line_h,
);
// Print country
$this->SetFont(self::FONT, 'I', $this->preferences->pref_etiq_corps);
- $this->SetXY($x, $y + $this->line_h*4);
+ $this->SetXY($x, $y + $this->line_h * 4);
$this->Cell($this->lw, $this->line_h, $member->country, 0, 0, 'R', 0);
$nb_etiq++;
}
*
* @return \Psr\Http\Message\ResponseInterface
*/
- public function __invoke(Request $request, Response $response, $next) :Response
+ public function __invoke(Request $request, Response $response, $next): Response
{
if (!$this->login || !$this->login->isLogged()) {
if ($request->isGet()) {
}
break;
case 'admin':
- if ($this->login->isSuperAdmin()
+ if (
+ $this->login->isSuperAdmin()
|| $this->login->isAdmin()
) {
$go = true;
}
break;
case 'staff':
- if ($this->login->isSuperAdmin()
+ if (
+ $this->login->isSuperAdmin()
|| $this->login->isAdmin()
|| $this->login->isStaff()
) {
}
break;
case 'groupmanager':
- if ($this->login->isSuperAdmin()
+ if (
+ $this->login->isSuperAdmin()
|| $this->login->isAdmin()
|| $this->login->isStaff()
|| $this->login->isGroupManager()
*
* @return \Psr\Http\Message\ResponseInterface
*/
- public function __invoke(Request $request, Response $response, $next) :Response
+ public function __invoke(Request $request, Response $response, $next): Response
{
$route = $request->getAttribute('route');
$route_info = $request->getAttribute('routeInfo');
$middlewares = $route->getMiddleware();
if (count($middlewares) > 0) {
foreach ($middlewares as $middleware) {
- if (!in_array($name, $excluded_names)
+ if (
+ !in_array($name, $excluded_names)
&& !in_array($name, $missing_acls)
) {
try {
*
* @return \Psr\Http\Message\ResponseInterface
*/
- public function __invoke(Request $request, Response $response, $next) :Response
+ public function __invoke(Request $request, Response $response, $next): Response
{
$get = $request->getQueryParams();
*
* @return \Psr\Http\Message\ResponseInterface
*/
- public function __invoke(Request $request, Response $response, $next) :Response
+ public function __invoke(Request $request, Response $response, $next): Response
{
$navigate = array();
$route = $request->getAttribute('route');
$filters = new MembersList();
}
- if ($this->login->isAdmin()
+ if (
+ $this->login->isAdmin()
|| $this->login->isStaff()
|| $this->login->isGroupManager()
) {
*
* @return \Psr\Http\Message\ResponseInterface
*/
- public function __invoke(Request $request, Response $response, $next) :Response
+ public function __invoke(Request $request, Response $response, $next): Response
{
$telemetry = new \Galette\Util\Telemetry(
$this->zdb,
*
* @return \Psr\Http\Message\ResponseInterface
*/
- public function __invoke(Request $request, Response $response, $next) :Response
+ public function __invoke(Request $request, Response $response, $next): Response
{
$uri = $request->getUri();
$path = $uri->getPath();
namespace Galette\Middleware;
use Galette\Core\I18n;
-
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
*
* @return \Psr\Http\Message\ResponseInterface
*/
- public function __invoke(Request $request, Response $response, $next) :Response
+ public function __invoke(Request $request, Response $response, $next): Response
{
$response
->withStatus(503)
);
//add ending / if missing
- if ($path === ''
+ if (
+ $path === ''
|| $path !== '/'
&& substr($path, -1) !== '/'
) {
$c = new Contribution($this->zdb, $this->login, $contribution);
$res = $c->remove(false);
if ($res === false) {
- throw new \Exception;
+ throw new \Exception();
}
}
if ($transaction) {
if ($results) {
foreach ($results as $r) {
$perm = $r['field_perm'];
- if (($perm == DynamicField::PERM_MANAGER &&
+ if (
+ ($perm == DynamicField::PERM_MANAGER &&
$access_level < Authentication::ACCESS_MANAGER) ||
($perm == DynamicField::PERM_STAFF &&
$access_level < Authentication::ACCESS_STAFF) ||
use Galette\DynamicFields\DynamicField;
use Galette\Entity\DynamicFieldsHandle;
-
use Analog\Analog;
use Laminas\Db\Adapter\Adapter;
use Laminas\Db\Sql\Expression;
return true;
} catch (\Exception $e) {
$zdb->connection->rollBack();
- if ($e instanceof \Zend_Db_Statement_Exception
+ if (
+ $e instanceof \Zend_Db_Statement_Exception
&& $e->getCode() == 23000
) {
Analog::log(
*
* @return Select SELECT statement
*/
- private function buildSelect($mode, $fields, $photos, $count = false) :Select
+ private function buildSelect($mode, $fields, $photos, $count = false): Select
{
global $zdb, $login;
}
//check for contributions filtering
- if ($this->filters instanceof AdvancedMembersList
+ if (
+ $this->filters instanceof AdvancedMembersList
&& $this->filters->withinContributions()
) {
$select->join(
$hasDf = false;
$dfs = array();
- if ($this->filters instanceof AdvancedMembersList
+ if (
+ $this->filters instanceof AdvancedMembersList
&& $this->filters->free_search
&& count($this->filters->free_search) > 0
&& !isset($this->filters->free_search['empty'])
$hasCdfc = false;
$cdfcs = array();
- if ($this->filters instanceof AdvancedMembersList
+ if (
+ $this->filters instanceof AdvancedMembersList
&& $this->filters->withinContributions()
) {
- if ($this->filters->contrib_dynamic
+ if (
+ $this->filters->contrib_dynamic
&& count($this->filters->contrib_dynamic) > 0
&& !isset($this->filters->contrib_dynamic['empty'])
) {
*
* @return Select
*/
- private function buildOrderClause(Select $select, $fields = null) :Select
+ private function buildOrderClause(Select $select, $fields = null): Select
{
$order = array();
// we will use in the final query.
// The OR case is quite simple, AND is a bit more complex; since we must
// check each member do belongs to all listed groups.
- if (count($this->filters->groups_search) > 0
+ if (
+ count($this->filters->groups_search) > 0
&& !isset($this->filters->groups_search['empty'])
) {
$groups_adh = [];
}
}
- if ($this->filters->rbirth_date_begin
+ if (
+ $this->filters->rbirth_date_begin
|| $this->filters->rbirth_date_end
) {
if ($this->filters->rbirth_date_begin) {
}
}
- if ($this->filters->rcreation_date_begin
+ if (
+ $this->filters->rcreation_date_begin
|| $this->filters->rcreation_date_end
) {
if ($this->filters->rcreation_date_begin) {
}
}
- if ($this->filters->rmodif_date_begin
+ if (
+ $this->filters->rmodif_date_begin
|| $this->filters->rmodif_date_end
) {
if ($this->filters->rmodif_date_begin) {
}
}
- if ($this->filters->rdue_date_begin
+ if (
+ $this->filters->rdue_date_begin
|| $this->filters->rdue_date_end
) {
if ($this->filters->rdue_date_begin) {
);
}
- if ($this->filters->rcontrib_creation_date_begin
+ if (
+ $this->filters->rcontrib_creation_date_begin
|| $this->filters->rcontrib_creation_date_end
) {
if ($this->filters->rcontrib_creation_date_begin) {
}
}
- if ($this->filters->rcontrib_begin_date_begin
+ if (
+ $this->filters->rcontrib_begin_date_begin
|| $this->filters->rcontrib_begin_date_end
) {
if ($this->filters->rcontrib_begin_date_begin) {
}
}
- if ($this->filters->rcontrib_end_date_begin
+ if (
+ $this->filters->rcontrib_end_date_begin
|| $this->filters->rcontrib_end_date_end
) {
if ($this->filters->rcontrib_end_date_begin) {
}
}
- if ($this->filters->contrib_min_amount
+ if (
+ $this->filters->contrib_min_amount
|| $this->filters->contrib_max_amount
) {
if ($this->filters->contrib_min_amount) {
);
}
- if (count($this->filters->contrib_dynamic) > 0
+ if (
+ count($this->filters->contrib_dynamic) > 0
&& !isset($this->filters->contrib_dynamic['empty'])
) {
foreach ($this->filters->contrib_dynamic as $k => $cd) {
}
}
- if (count($this->filters->free_search) > 0
+ if (
+ count($this->filters->free_search) > 0
&& !isset($this->filters->free_search['empty'])
) {
foreach ($this->filters->free_search as $fs) {
} elseif (!strncmp($fs['field'], 'bool_', strlen('bool_'))) {
$qry .= $prefix . $fs['field'] . $qop . ' ' .
$fs['search'];
- } elseif ($fs['qry_op'] === AdvancedMembersList::OP_BEFORE
+ } elseif (
+ $fs['qry_op'] === AdvancedMembersList::OP_BEFORE
|| $fs['qry_op'] === AdvancedMembersList::OP_AFTER
) {
if ($prefix === 'a.') {
foreach ($results as $m) {
$dirty = false;
- if ($m->login_adh == ''
+ if (
+ $m->login_adh == ''
|| !isset($m->login_adh)
|| $m->login_adh == 'NULL'
) {
$dirty = true;
}
- if ($m->mdp_adh == ''
+ if (
+ $m->mdp_adh == ''
|| !isset($m->mdp_adh)
|| $m->mdp_adh == 'NULL'
) {
}
}
- if (count($missing) >0) {
+ if (count($missing) > 0) {
$this->zdb->connection->beginTransaction();
$this->insert($ent::TABLE, $missing);
Analog::log(
$entity = $ent;
} else {
throw new \RuntimeException(
- 'Unable to find entity name from repository one. Please '.
+ 'Unable to find entity name from repository one. Please ' .
'provide entity name in repository constructor'
);
}
$s = new SavedSearch($this->zdb, $this->login, $search);
$res = $s->remove(false);
if ($res === false) {
- throw new \Exception;
+ throw new \Exception();
}
}
if ($transaction) {
$c = new Transaction($this->zdb, $this->login, $transaction);
$res = $c->remove($hist, false);
if ($res === false) {
- throw new \Exception;
+ throw new \Exception();
}
}
$this->zdb->connection->commit();
namespace Galette\Updater;
-use \Analog\Analog;
+use Analog\Analog;
use Galette\Core\Db;
/**
protected function setSqlScripts($version)
{
$scripts = $this->getSqlScripts($version);
- if (is_array($scripts)
+ if (
+ is_array($scripts)
&& count($scripts) === count($this->engines)
&& count(array_diff(array_keys($scripts), $this->engines)) == 0
) {
<?xml version="1.0"?>
<ruleset name="Galette">
- <description>Coding standard based on PSR2 with comments from Zend for Galette</description>
+ <description>Coding standard based on PSR12 with comments from PEAR for Galette</description>
- <!-- Include the whole PSR2 standard -->
- <rule ref="PSR2"/>
+ <!-- Include the whole PSR12 standard -->
+ <rule ref="PSR12"/>
<!-- Comments rules from PEAR standard -->
<rule ref="PEAR.Commenting.ClassComment"/>
namespace Galette\Core\test\units;
-use \atoum;
+use atoum;
/**
* CheckModules tests class
namespace Galette\Core\test\units;
-use \atoum;
+use atoum;
/**
* Database tests class
namespace Galette\Core\test\units;
-use \atoum;
+use atoum;
/**
* History tests class
namespace Galette\Core\test\units;
-use \atoum;
+use atoum;
/**
* I18n tests class
namespace Galette\Core\test\units;
-use \atoum;
+use atoum;
/**
* Install tests class
namespace Galette\Core\test\units;
-use \atoum;
+use atoum;
/**
* Password tests class
namespace Galette\Core\test\units;
-use \atoum;
+use atoum;
/**
* Login tests class
namespace Galette\Core\test\units;
-use \atoum;
+use atoum;
/**
* Picture tests class
namespace Galette\Core\test\units;
-use \atoum;
+use atoum;
/**
* Password tests class
namespace Galette\Core\test\units;
-use \atoum;
+use atoum;
/**
* PasswordImage tests class
namespace Galette\Core\test\units;
-use \atoum;
+use atoum;
/**
* Picture tests class
namespace Galette\Core\test\units;
-use \atoum;
+use atoum;
/**
* Plugins tests class
namespace Galette\Core\test\units;
-use \atoum;
+use atoum;
/**
* Preferences tests class
namespace Galette\Core\test\units;
-use \atoum;
+use atoum;
/**
* Picture tests class
namespace Galette\DynamicFields\test\units;
-use \atoum;
+use atoum;
/**
* Dynamic booleans test
namespace Galette\DynamicFields\test\units;
-use \atoum;
+use atoum;
/**
* Dynamic separator test
namespace Galette\Entity\test\units;
-use \atoum;
+use atoum;
/**
* Adherent tests class
namespace Galette\Entity\test\units;
-use \atoum;
+use atoum;
/**
* Contribution tests class
namespace Galette\Entity\test\units;
-use \atoum;
+use atoum;
/**
* Preferences tests class
namespace Galette\Entity\test\units;
-use \atoum;
+use atoum;
/**
* ListsConfig tests class
$last_ok = -1;
foreach ($expecteds as $k => $expected) {
$this->string($new_list[$k]['field_id'])->isIdenticalTo($expected);
- if ($new_list[$k]['list_position'] != $k-1) {
+ if ($new_list[$k]['list_position'] != $k - 1) {
$this->integer($new_list[$k]['list_position'])->isGreaterThan($last_ok);
$last_ok = $new_list[$k]['list_position'];
} else {
$last_ok = -1;
foreach ($expecteds as $k => $expected) {
$this->string($new_list[$k]['field_id'])->isIdenticalTo($expected);
- if ($new_list[$k]['list_position'] != $k-1) {
+ if ($new_list[$k]['list_position'] != $k - 1) {
$this->integer($new_list[$k]['list_position'])->isGreaterThan($last_ok);
$last_ok = $new_list[$k]['list_position'];
} else {
namespace Galette\Entity\test\units;
-use \atoum;
+use atoum;
/**
* Payment type tests
namespace Galette\Entity\test\units;
-use \atoum;
+use atoum;
use Zend\Db\Adapter\Adapter;
/**
namespace Galette\Entity\test\units;
-use \atoum;
+use atoum;
use Zend\Db\Adapter\Adapter;
/**
namespace Galette\Entity\test\units;
-use \atoum;
+use atoum;
use Zend\Db\Adapter\Adapter;
/**
namespace Galette\Entity\test\units;
-use \atoum;
+use atoum;
use Zend\Db\Adapter\Adapter;
/**
namespace Galette\IO\test\units;
-use \atoum;
-
-use \Galette\Entity\Adherent;
-use \Galette\DynamicFields\DynamicField;
+use atoum;
+use Galette\Entity\Adherent;
+use Galette\DynamicFields\DynamicField;
/**
* CsvIn tests class
$csvfile_model = $response->getBody()->__toString();
$this->string($csvfile_model)
- ->isIdenticalTo("\"".implode("\";\"", $fields)."\"\r\n");
+ ->isIdenticalTo("\"" . implode("\";\"", $fields) . "\"\r\n");
$fakedata = new \Galette\Util\FakeData($this->zdb, $this->i18n);
$contents = $csvfile_model;
foreach ($fields as $field) {
$amember[$field] = $member[$field];
}
- $contents .= "\"".implode("\";\"", $amember)."\"\r\n";
+ $contents .= "\"" . implode("\";\"", $amember) . "\"\r\n";
}
$path = GALETTE_CACHE_DIR . $file_name;
for ($i = 0; $i < 10; ++$i) {
$data = $fakedata->fakeMember();
//two lines without name.
- $data['nom_adh'] = (($i == 2 || $i ==5) ? '' : str_replace('"', '""', $data['nom_adh']));
+ $data['nom_adh'] = (($i == 2 || $i == 5) ? '' : str_replace('"', '""', $data['nom_adh']));
$data['ville_adh'] = str_replace('"', '""', $data['ville_adh']);
$data['fingerprint'] = 'FAKER_' . $i;
$members_list[$data['fingerprint']] = $data;
*
* @return \Galette\Entity\ImportModel
*/
- protected function getModel($fields) :\Galette\Entity\ImportModel
+ protected function getModel($fields): \Galette\Entity\ImportModel
{
$model = new \Galette\Entity\ImportModel();
$this->boolean($model->remove($this->zdb))->isTrue();
for ($i = 0; $i < 10; ++$i) {
$data = $fakedata->fakeMember();
//two lines without name.
- $data['nom_adh'] = (($i == 2 || $i ==5) ? '' : str_replace('"', '""', $data['nom_adh']));
+ $data['nom_adh'] = (($i == 2 || $i == 5) ? '' : str_replace('"', '""', $data['nom_adh']));
$data['ville_adh'] = str_replace('"', '""', $data['ville_adh']);
$data['fingerprint'] = 'FAKER_' . $i;
$data['dynfield_' . $df->getId()] = 'Dynamic field value for ' . $data['fingerprint'];
$data['ville_adh'] = str_replace('"', '""', $data['ville_adh']);
$data['fingerprint'] = 'FAKER_' . $i;
//two lines without required dynamic field.
- $data['dynfield_' . $df->getId()] = (($i == 2 || $i ==5) ? '' :
+ $data['dynfield_' . $df->getId()] = (($i == 2 || $i == 5) ? '' :
'Dynamic field value for ' . $data['fingerprint']);
$members_list[$data['fingerprint']] = $data;
}
$data['nom_adh'] = str_replace('"', '""', $data['nom_adh']);
$data['ville_adh'] = str_replace('"', '""', $data['ville_adh']);
$data['fingerprint'] = 'FAKER_' . $i;
- $data['dynfield_' . $cdf->getId()] =(($i == 2 || $i ==5) ? '20200513' : $data['date_crea_adh']);
+ $data['dynfield_' . $cdf->getId()] = (($i == 2 || $i == 5) ? '20200513' : $data['date_crea_adh']);
$members_list[$data['fingerprint']] = $data;
}
$count_before = 10;
namespace Galette\IO\test\units;
-use \atoum;
+use atoum;
/**
* News tests class
namespace Galette\Middleware\test\units;
-use \atoum;
+use atoum;
/**
* CheckAcls tests class
namespace Galette\Repository\test\units;
-use \atoum;
+use atoum;
/**
* Members repository tests
//Filter on active accounts
- $filters = new \Galette\Filters\MembersList;
+ $filters = new \Galette\Filters\MembersList();
$filters->filter_account = \Galette\Repository\Members::ACTIVE_ACCOUNT;
$members = new \Galette\Repository\Members($filters);
$list = $members->getList();
$this->integer($list->count())->isIdenticalTo(9);
//Filter on inactive accounts
- $filters = new \Galette\Filters\MembersList;
+ $filters = new \Galette\Filters\MembersList();
$filters->filter_account = \Galette\Repository\Members::INACTIVE_ACCOUNT;
$members = new \Galette\Repository\Members($filters);
$list = $members->getList();
$this->integer($list->count())->isIdenticalTo(1);
//Search on address
- $filters = new \Galette\Filters\MembersList;
+ $filters = new \Galette\Filters\MembersList();
$filters->filter_str = 'avenue';
$filters->field_filter = \Galette\Repository\Members::FILTER_ADDRESS;
$members = new \Galette\Repository\Members($filters);
$this->integer(count($group->getMembers()))->isIdenticalTo(6);
//all groups/members are setup. try to find them now.
- $filters = new \Galette\Filters\AdvancedMembersList;
+ $filters = new \Galette\Filters\AdvancedMembersList();
$filters->groups_search_log_op = \Galette\Filters\AdvancedMembersList::OP_OR;
$filters->groups_search = ['idx' => 1, 'group' => $europe];
$members = new \Galette\Repository\Members($filters);
$this->integer($list->count())->isIdenticalTo(2);
//another try
- $filters = new \Galette\Filters\AdvancedMembersList;
+ $filters = new \Galette\Filters\AdvancedMembersList();
$filters->groups_search_log_op = \Galette\Filters\AdvancedMembersList::OP_OR;
$filters->groups_search = ['idx' => 1, 'group' => $africa];
$filters->groups_search = ['idx' => 2, 'group' => $pony];
namespace Galette\Repository\test\units;
-use \atoum;
+use atoum;
/**
* Payment types repository tests
namespace Galette\Repository\test\units;
-use \atoum;
+use atoum;
/**
* PDF models repository tests
{
global $container, $zdb;
$zdb = $this->zdb; //globals '(
- $container = new class{
+ $container = new class {
/**
* Get (only router)
*
*/
public function get($name)
{
- $router = new class{
+ $router = new class {
/**
* Get path ('')
*
namespace Galette\Util\test\units;
-use \atoum;
+use atoum;
use Galette\Core\Preferences;
/**
}
if ($level < Preferences::PWD_VERY_STRONG) {
- $this->preferences->pref_password_strength = $level +1;
+ $this->preferences->pref_password_strength = $level + 1;
$password = new \Galette\Util\Password($this->preferences);
$this->boolean($password->isValid($pass))->isFalse();
$this->array($password->getErrors())->isEqualTo($errors);
namespace Galette\Util\test\units;
-use \atoum;
+use atoum;
/**
* Telemetry tests class
<?php
+
/**
* Test bootstrap
*
<?php
+
/**
* MySQL configuration file for tests
*
* @link http://galette.tuxfamily.org
* @since Available since 0.7.3dev 2012-12-12
*/
+
define("TYPE_DB", "mysql");
if (file_exists(__DIR__ . '/local_config.inc.php')) {
include_once __DIR__ . '/local_config.inc.php';
<?php
+
/**
* PostgreSQL configuration file for tests
*
* @link http://galette.tuxfamily.org
* @since Available since 0.7.3dev 2012-12-12
*/
+
define("TYPE_DB", "pgsql");
if (file_exists(__DIR__ . '/local_config.inc.php')) {
<?php
-
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* @since 2013-01-13
*/
-use \mageekguy\atoum;
+use mageekguy\atoum;
$coverageField = new atoum\report\fields\runner\coverage\html(
'Galette',