From 09b916796a6a3d14b78c74492fb5a93fdad9482d Mon Sep 17 00:00:00 2001 From: Guillaume David Date: Fri, 20 Dec 2024 17:10:23 +0100 Subject: [PATCH] Updates --- config.php | 2 +- src/admin/views/race/view-race-edit.php | 8 +++++ src/admin/views/race/view-race-list.php | 5 ++++ src/class/race/Race.php | 30 ++++++++++++++----- src/database/initialize.php | 1 + src/database/update.php | 3 +- .../cass-shortcode-calendar-global.js | 13 ++++++-- .../cass-shortcode-calendar-global.php | 15 +++++++++- src/frontend/cass-shortcode-course-info.js | 10 +++++-- src/frontend/cass-shortcode-course-info.php | 4 ++- .../cass-shortcode-member-register.php | 2 +- 11 files changed, 74 insertions(+), 19 deletions(-) diff --git a/config.php b/config.php index f48c841..345662e 100644 --- a/config.php +++ b/config.php @@ -9,7 +9,7 @@ class CASS_Config public static function execute() { //Configuration of plugin - define("PRODUCTION", true); + define("PRODUCTION", false); define("DB_DROP_IF_UNINSTALL", false); //Recaptcha v2 key diff --git a/src/admin/views/race/view-race-edit.php b/src/admin/views/race/view-race-edit.php index 435d988..95b3ba2 100644 --- a/src/admin/views/race/view-race-edit.php +++ b/src/admin/views/race/view-race-edit.php @@ -162,6 +162,7 @@ class CASS_View_Race_Edit } //Non obligatory fields + $race->setSubscriptionEnable($_POST["subscriptionEnable"] === "on" ? 1 : 0); $race->setPlaceLatitude(doubleval($_POST["placeLatitude"])); $race->setPlaceLongitude(doubleval($_POST["placeLongitude"])); $race->setMeetingPlaceLongitude(doubleval($_POST["meetingPlaceLongitude"])); @@ -420,6 +421,13 @@ class CASS_View_Race_Edit +
+
+ + getSubscriptionEnable() == 1) { + echo "checked"; + } ?>> +

diff --git a/src/admin/views/race/view-race-list.php b/src/admin/views/race/view-race-list.php index 9b63fa6..1fd1f64 100644 --- a/src/admin/views/race/view-race-list.php +++ b/src/admin/views/race/view-race-list.php @@ -127,6 +127,7 @@ class CASS_View_Race_List extends WP_List_Table 'IDWPUser_Deputy' => __('Adjoint', 'cass-race-deputy-content'), 'start' => __('Début', 'cass-race-start-content'), 'end' => __('Fin', 'cass-race-end-content'), + 'subscriptionEnable' => __('Ins. activée','cass-race-subscription-enable-content'), 'subscriptionStart' => __('Ins. début', 'cass-race-start-content'), 'subscriptionEnd' => __('Ins. fin', 'cass-race-end-content'), 'subscriptionCount' => __('Nbre inscrit', 'cass-race-count-subscribed-content'), @@ -338,6 +339,9 @@ class CASS_View_Race_List extends WP_List_Table case 'comment': return ReadGlobal($item[$column_name]); + + case 'subscriptionEnable': + return $item[$column_name] == 1 ? "Oui" : "Non"; default: return $item[$column_name]; } @@ -361,6 +365,7 @@ class CASS_View_Race_List extends WP_List_Table 'state' => array('state', false), 'start' => array('start', false), 'end' => array('end', false), + 'subscriptionEnable' => array('subscriptionEnable', false), 'subscriptionStart' => array('subscriptionStart', false), 'subscriptionEnd' => array('subscriptionEnd', false), 'IDLevel' => array('IDLevel', false), diff --git a/src/class/race/Race.php b/src/class/race/Race.php index 822e0f4..88022e0 100644 --- a/src/class/race/Race.php +++ b/src/class/race/Race.php @@ -14,6 +14,7 @@ class Race private $placeLongitude; private $start; private $end; + private $subscriptionEnable; private $subscriptionStart; private $subscriptionEnd; private $IDLevel; @@ -35,7 +36,7 @@ class Race { global $wpdb; $sql = " - SELECT IDRace, name, dtCreation, dtEdition, state, IDWPUser_RL,IDWPUser_Deputy, placeName, placeLocality, placeLatitude, placeLongitude, start, end, subscriptionStart, subscriptionEnd, IDLevel, meetingPlaceName, meetingPlaceLongitude, meetingPlaceLatitude, participantMin, participantMax, descriptionPublic, descriptionMemberSubscribed, formType, comment, IDType, IDGroup, IDSeason + SELECT IDRace, name, dtCreation, dtEdition, state, IDWPUser_RL,IDWPUser_Deputy, placeName, placeLocality, placeLatitude, placeLongitude, start, end, subscriptionEnable, subscriptionStart, subscriptionEnd, IDLevel, meetingPlaceName, meetingPlaceLongitude, meetingPlaceLatitude, participantMin, participantMax, descriptionPublic, descriptionMemberSubscribed, formType, comment, IDType, IDGroup, IDSeason FROM cass_race WHERE IDRace = %d; "; @@ -55,6 +56,7 @@ class Race $this->setPlaceLongitude($result->placeLongitude); $this->setStart($result->start); $this->setEnd($result->end); + $this->setSubscriptionEnable($result->subscriptionEnable); $this->setSubscriptionStart($result->subscriptionStart); $this->setSubscriptionEnd($result->subscriptionEnd); $this->setIDLevel($result->IDLevel); @@ -83,10 +85,10 @@ class Race $sql = " UPDATE cass_race - SET name = %s, dtCreation = %s, dtEdition = %s, state = %d, IDWPUser_RL = %d, IDWPUser_Deputy = %d, placeName = %s, placeLocality = %s, placeLatitude = %s, placeLongitude = %s, start = %s, end = %s, subscriptionStart = %s, subscriptionEnd = %s, IDLevel = %d, meetingPlaceName = %s, meetingPlaceLongitude = %s, meetingPlaceLatitude = %s, participantMin = %d, participantMax = %d, descriptionPublic = %s, descriptionMemberSubscribed = %s, formType = %d, comment = %s, IDType = %d, IDGroup = %d, IDSeason = %d + SET name = %s, dtCreation = %s, dtEdition = %s, state = %d, IDWPUser_RL = %d, IDWPUser_Deputy = %d, placeName = %s, placeLocality = %s, placeLatitude = %s, placeLongitude = %s, start = %s, end = %s,subscriptionEnable = %d, subscriptionStart = %s, subscriptionEnd = %s, IDLevel = %d, meetingPlaceName = %s, meetingPlaceLongitude = %s, meetingPlaceLatitude = %s, participantMin = %d, participantMax = %d, descriptionPublic = %s, descriptionMemberSubscribed = %s, formType = %d, comment = %s, IDType = %d, IDGroup = %d, IDSeason = %d WHERE IDRace = %d; "; - + $wpdb->query($wpdb->prepare( $sql, $this->getName(), @@ -101,6 +103,7 @@ class Race $this->getPlaceLongitude(), $this->getStart(), $this->getEnd(), + $this->getSubscriptionEnable(), $this->getSubscriptionStart(), $this->getSubscriptionEnd(), $this->getIDLevel(), @@ -139,8 +142,8 @@ class Race global $wpdb; $sql = " - INSERT INTO cass_race (name, dtCreation, dtEdition, state, IDWPUser_RL, IDWPUser_Deputy, placeName, placeLocality, placeLatitude, placeLongitude, start, end, subscriptionStart, subscriptionEnd, IDLevel, meetingPlaceName, meetingPlaceLongitude, meetingPlaceLatitude, participantMin, participantMax, descriptionPublic, descriptionMemberSubscribed, formType, comment, IDType, IDGroup, IDSeason) - VALUES(%s, %s, %s, %d, %d, %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %d, %d, %d, %s, %s, %d, %s, %d, %d, %d); + INSERT INTO cass_race (name, dtCreation, dtEdition, state, IDWPUser_RL, IDWPUser_Deputy, placeName, placeLocality, placeLatitude, placeLongitude, start, end, subscriptionEnable, subscriptionStart, subscriptionEnd, IDLevel, meetingPlaceName, meetingPlaceLongitude, meetingPlaceLatitude, participantMin, participantMax, descriptionPublic, descriptionMemberSubscribed, formType, comment, IDType, IDGroup, IDSeason) + VALUES(%s, %s, %s, %d, %d, %d, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s, %s, %d, %d, %d, %d, %s, %s, %d, %s, %d, %d, %d); "; $wpdb->query($wpdb->prepare( @@ -157,6 +160,7 @@ class Race $this->getPlaceLongitude(), $this->getStart(), $this->getEnd(), + $this->getSubscriptionEnable(), $this->getSubscriptionStart(), $this->getSubscriptionEnd(), $this->getIDLevel(), @@ -179,7 +183,7 @@ class Race global $wpdb; $sql = " - SELECT cass_race.IDRace, wp_users_rl.display_name AS nameRL, wp_users_deputy.display_name AS nameDeputy, GROUP_CONCAT(cass_material.name) AS materials, cass_race.name AS name, state, placeName, placeLocality, placeLatitude, placeLongitude, start, end, subscriptionStart, subscriptionEnd, cass_race.IDLevel, meetingPlaceName, meetingPlaceLatitude, meetingPlaceLongitude, participantMin, participantMax, descriptionPublic, descriptionMemberSubscribed, comment, cass_level.name AS level, cass_type.name AS type, cass_group.name AS 'group', cass_race.IDGroup, cass_season.name AS season FROM cass_race + SELECT cass_race.IDRace, wp_users_rl.display_name AS nameRL, wp_users_deputy.display_name AS nameDeputy, GROUP_CONCAT(cass_material.name) AS materials, cass_race.name AS name, state, placeName, placeLocality, placeLatitude, placeLongitude, start, end, subscriptionEnable, subscriptionStart, subscriptionEnd, cass_race.IDLevel, meetingPlaceName, meetingPlaceLatitude, meetingPlaceLongitude, participantMin, participantMax, descriptionPublic, descriptionMemberSubscribed, comment, cass_level.name AS level, cass_type.name AS type, cass_group.name AS 'group', cass_race.IDGroup, cass_season.name AS season FROM cass_race INNER JOIN cass_level ON cass_level.IDLevel = cass_race.IDLevel INNER JOIN cass_group ON cass_group.IDGroup = cass_race.IDGroup INNER JOIN cass_type ON cass_type.IDType = cass_race.IDType @@ -199,7 +203,7 @@ class Race global $wpdb; $sql = " - SELECT cass_race.IDRace, wp_users_rl.display_name AS nameRL, wp_users_deputy.display_name AS nameDeputy, GROUP_CONCAT(cass_material.name) AS materials, cass_race.name AS name, state, placeName, placeLocality, placeLatitude, placeLongitude, start, end, subscriptionStart, subscriptionEnd, cass_race.IDLevel, meetingPlaceName, meetingPlaceLatitude, meetingPlaceLongitude, participantMin, participantMax, descriptionPublic, descriptionMemberSubscribed, comment, cass_level.name AS level, cass_type.name AS type, cass_group.name AS 'group', cass_race.IDGroup, cass_season.name AS season FROM cass_race + SELECT cass_race.IDRace, wp_users_rl.display_name AS nameRL, wp_users_deputy.display_name AS nameDeputy, GROUP_CONCAT(cass_material.name) AS materials, cass_race.name AS name, state, placeName, placeLocality, placeLatitude, placeLongitude, start, end, subscriptionEnable, subscriptionStart, subscriptionEnd, cass_race.IDLevel, meetingPlaceName, meetingPlaceLatitude, meetingPlaceLongitude, participantMin, participantMax, descriptionPublic, descriptionMemberSubscribed, comment, cass_level.name AS level, cass_type.name AS type, cass_group.name AS 'group', cass_race.IDGroup, cass_season.name AS season FROM cass_race INNER JOIN cass_level ON cass_level.IDLevel = cass_race.IDLevel INNER JOIN cass_group ON cass_group.IDGroup = cass_race.IDGroup INNER JOIN cass_type ON cass_type.IDType = cass_race.IDType @@ -222,7 +226,7 @@ class Race global $wpdb; $sql = " - SELECT IDRace, name, dtCreation, dtEdition, state, IDWPUser_RL, IDWPUser_Deputy, placeName, placeLocality, placeLatitude, placeLongitude, start, end,subscriptionStart,subscriptionEnd, IDLevel, meetingPlaceName, meetingPlaceLongitude, meetingPlaceLatitude, participantMin, participantMax, descriptionPublic, descriptionMemberSubscribed, formType, comment, IDType, IDGroup, IDSeason + SELECT IDRace, name, dtCreation, dtEdition, state, IDWPUser_RL, IDWPUser_Deputy, placeName, placeLocality, placeLatitude, placeLongitude, start, end,subscriptionEnable, subscriptionStart,subscriptionEnd, IDLevel, meetingPlaceName, meetingPlaceLongitude, meetingPlaceLatitude, participantMin, participantMax, descriptionPublic, descriptionMemberSubscribed, formType, comment, IDType, IDGroup, IDSeason FROM cass_race WHERE IDRace = %d; "; @@ -310,6 +314,11 @@ class Race { return $this->end; } + + public function getSubscriptionEnable() + { + return $this->subscriptionEnable; + } public function getSubscriptionStart() { return $this->subscriptionStart; @@ -450,6 +459,11 @@ class Race $this->end = $end; } + public function setSubscriptionEnable($subscriptionEnable) + { + $this->subscriptionEnable = $subscriptionEnable; + } + public function setSubscriptionStart($subscriptionStart) { $this->subscriptionStart = $subscriptionStart; diff --git a/src/database/initialize.php b/src/database/initialize.php index 48f657d..81d75dd 100644 --- a/src/database/initialize.php +++ b/src/database/initialize.php @@ -49,6 +49,7 @@ function cass_database_initialize(){ placeLongitude VARCHAR(45) NULL, start DATETIME NOT NULL, end DATETIME NOT NULL, + subscriptionEnable BOOLEAN, subscriptionStart DATETIME NOT NULL, subscriptionEnd DATETIME NOT NULL, meetingPlaceName VARCHAR(100) NULL, diff --git a/src/database/update.php b/src/database/update.php index 515b0d7..3e94994 100644 --- a/src/database/update.php +++ b/src/database/update.php @@ -8,8 +8,7 @@ function cass_database_update(){ /* - ALTER TABLE cass_race - ADD IDWPUser_Deputy INT NOT NULL; + ALTER TABLE cass_race ADD subscriptionEnable BOOLEAN; */ } \ No newline at end of file diff --git a/src/frontend/cass-shortcode-calendar-global.js b/src/frontend/cass-shortcode-calendar-global.js index 515332f..1343c38 100644 --- a/src/frontend/cass-shortcode-calendar-global.js +++ b/src/frontend/cass-shortcode-calendar-global.js @@ -242,7 +242,16 @@ document.addEventListener('DOMContentLoaded', function () { document.getElementById("raceLeader").innerHTML = "La course est gérée (chef de course) par " + ReadGlobal(race.nameRL, false) + " " + ReadGlobal(deputyText, false) + ""; document.getElementById("raceTypeLevel").innerHTML = "Le type est " + ReadGlobal(race.type, false) + " d'un niveau " + ReadGlobal(race.level, false) + ""; document.getElementById("raceGroup").innerHTML = "Groupe : " + ReadGlobal(race.group, false) + ""; - document.getElementById("raceSubscriptionStartEnd").innerHTML = "Les inscriptions sont ouvertes du " + getDateFormated(race.subscriptionStart) + " au " + getDateFormated(race.subscriptionEnd) + ""; + + + + if(parseInt(race.subscriptionEnable) == 1) { + + document.getElementById("raceSubscriptionStartEnd").innerHTML = "Les inscriptions sont ouvertes du " + getDateFormated(race.subscriptionStart) + " au " + getDateFormated(race.subscriptionEnd) + ""; + } else { + document.getElementById("raceSubscriptionStartEnd").innerHTML = "Les inscriptions sont ouvertes du " + getDateFormated(race.subscriptionStart) + " au " + getDateFormated(race.subscriptionEnd) + " (actuellement fermées)"; + } + document.getElementById("racePlaceLocality").innerHTML = "La course se déroulera à "+ReadGlobal(race.placeName,false)+" ("+race.placeLocality+")"; document.getElementById("raceMeeting").innerHTML = "Le lieu de RDV est " + race.meetingPlaceName + "."; document.getElementById("IDRace").value = race.IDRace; @@ -275,7 +284,7 @@ document.addEventListener('DOMContentLoaded', function () { var subscriptionEnd = race.subscriptionEnd.toLocaleString(); // Contrôle état de la course - if (race.state == 2 || race.state == 3) { + if ((race.state == 2 || race.state == 3) && parseInt(race.subscriptionEnable) == 1) { // Contrôle ouverture des inscriptions var inscriptionElement = document.getElementById('inscription'); diff --git a/src/frontend/cass-shortcode-calendar-global.php b/src/frontend/cass-shortcode-calendar-global.php index 60254d7..45f8e3a 100644 --- a/src/frontend/cass-shortcode-calendar-global.php +++ b/src/frontend/cass-shortcode-calendar-global.php @@ -85,6 +85,7 @@ function cass_shortcode_calendar_global($atts){
+ +
+
Administration
+ + Liste des participants de la course + +
+
+ -
+ + + +
diff --git a/src/frontend/cass-shortcode-course-info.js b/src/frontend/cass-shortcode-course-info.js index 1fbdc89..c44452c 100644 --- a/src/frontend/cass-shortcode-course-info.js +++ b/src/frontend/cass-shortcode-course-info.js @@ -90,9 +90,13 @@ document.addEventListener('DOMContentLoaded', function () { // Contrôle état de la course - raceSubscriptionStartEndMeetingPlaceParticipiant = 'Les inscriptions sont ouvertes du ' + getDateFormated(this.race.subscriptionStart) + ' au ' + getDateFormated(this.race.subscriptionEnd) + '.'; - - + if(parseInt(this.race.subscriptionEnable) == 1) { + raceSubscriptionStartEndMeetingPlaceParticipiant = 'Les inscriptions sont ouvertes du ' + getDateFormated(this.race.subscriptionStart) + ' au ' + getDateFormated(this.race.subscriptionEnd) + '.'; + } else { + raceSubscriptionStartEndMeetingPlaceParticipiant = 'Les inscriptions sont ouvertes du ' + getDateFormated(this.race.subscriptionStart) + ' au ' + getDateFormated(this.race.subscriptionEnd) + ' (actuellement fermées).'; + + } + if (this.race.participantMin !== null && this.race.participantMin !== "" && this.race.participantMin !== 0) { raceSubscriptionStartEndMeetingPlaceParticipiant += "
Le nombre de participant minimum est de " + this.race.participantMin + "."; } diff --git a/src/frontend/cass-shortcode-course-info.php b/src/frontend/cass-shortcode-course-info.php index 3af8306..94a56da 100644 --- a/src/frontend/cass-shortcode-course-info.php +++ b/src/frontend/cass-shortcode-course-info.php @@ -118,7 +118,7 @@ function cass_shortcode_course_info() } else if ($id == 0 || $race_user_state == 3 || $race_user_state == 4) { if($race->getSubscriptionStart() > $today) { $HTML.="

Les inscriptions pour cette course ne sont pas encore ouvertes.

"; - } else if($race->getSubscriptionStart() <= $today && $race->getSubscriptionEnd() > $today){ + } else if($race->getSubscriptionEnable == 1 && ($race->getSubscriptionStart() <= $today && $race->getSubscriptionEnd() > $today)){ $HTML.="

Les inscriptions pour cette course sont ouvertes.

@@ -130,6 +130,8 @@ function cass_shortcode_course_info()
"; } else if($race->getSubscriptionStart() <= $today && $race->getSubscriptionEnd() <= $today){ $HTML.="

Les inscriptions pour cette course sont fermées.

"; + } else { + $HTML.="

Les inscriptions pour cette course ne sont pas encore ouvertes.

"; } } } diff --git a/src/frontend/cass-shortcode-member-register.php b/src/frontend/cass-shortcode-member-register.php index 4e32d21..6657ed3 100644 --- a/src/frontend/cass-shortcode-member-register.php +++ b/src/frontend/cass-shortcode-member-register.php @@ -50,7 +50,7 @@ function cass_shortcode_member_register()
- +