connection.php
2 years ago
fapiMemberLoginPage.php
2 years ago
index.php
2 years ago
levelSelection.php
2 years ago
memberList.php
2 years ago
settingsContentAdd.php
2 years ago
settingsContentRemove.php
2 years ago
settingsContentSelect.php
2 years ago
settingsElements.php
2 years ago
settingsEmails.php
2 years ago
settingsLevelNew.php
2 years ago
settingsPages.php
2 years ago
settingsSectionNew.php
2 years ago
settingsSettings.php
2 years ago
settingsUnlocking.php
2 years ago
test.php
2 years ago
settingsUnlocking.php
183 lines
| 1 | <?php |
| 2 | |
| 3 | use FapiMember\Container\Container; |
| 4 | use FapiMember\Deprecated\FapiMemberTools; |
| 5 | use FapiMember\Model\Enums\Keys\MetaKey; |
| 6 | use FapiMember\Repository\PageRepository; |
| 7 | use FapiMember\Utils\AlertProvider; |
| 8 | |
| 9 | echo FapiMemberTools::heading(); |
| 10 | ?> |
| 11 | |
| 12 | <div class="page both"> |
| 13 | <div class="withSections"> |
| 14 | <div class="a"> |
| 15 | <h3><?php echo __('Členské sekce/úrovně', 'fapi-member'); ?></h3> |
| 16 | <?php echo AlertProvider::showErrors(); ?> |
| 17 | <?php echo FapiMemberTools::levelsSelectionNonJs() ?> |
| 18 | </div> |
| 19 | <div class="b"> |
| 20 | <div> |
| 21 | <?php |
| 22 | $level = (isset($_GET['level'])) ? FapiMemberTools::sanitizeLevelId($_GET['level']) : null; |
| 23 | global $FapiPlugin; |
| 24 | $term = get_term($level); |
| 25 | |
| 26 | if (!is_wp_error($term)) { |
| 27 | $parent_term_id = $term->parent; |
| 28 | } |
| 29 | |
| 30 | if ($level === null) { |
| 31 | $pageRepository = Container::get(PageRepository::class); |
| 32 | $currentTimeLockedPageId = $pageRepository->getTimedUnlockNoAccessPageId();; |
| 33 | ?> |
| 34 | <div class="onePageOther"> |
| 35 | <h3><?php _e('Stránka, která se zobrazí, když obsah ještě nebyl odemčen.', 'fapi-member') ?></h3> |
| 36 | <p><?php _e('Úroveň musí mít povoleno časově omezené odemykání, aby byl uživatel přesměrován na tuto stránku.', 'fapi-member') ?></p> |
| 37 | |
| 38 | <?php echo FapiMemberTools::formStart('set_section_unlocking') ?> |
| 39 | <input type="hidden" name="level_id" value="<?php echo $level ?>"> |
| 40 | <div style="justify-content:start" class="row submitInline noLabel"> |
| 41 | <select type="text" name="time_locked_page_id" id="time_locked_page_id"> |
| 42 | <option value=""><?php echo __('-- nevybrána --', 'fapi-member'); ?></option> |
| 43 | <?php echo FapiMemberTools::allPagesAsOptions($currentTimeLockedPageId) ?> |
| 44 | </select> |
| 45 | <input type="submit" class="primary" value="<?php _e('Uložit', 'fapi-member'); ?>"> |
| 46 | </div> |
| 47 | </form> |
| 48 | </div> |
| 49 | <?php |
| 50 | } elseif ($parent_term_id === 0) { |
| 51 | ?> |
| 52 | <h3><?php _e('Zvolili jste členskou sekci, prosím zvolte úroveň.', 'fapi-member') ?></h3> |
| 53 | <?php |
| 54 | } else { |
| 55 | $daysToUnlockVal = get_term_meta($level, MetaKey::DAYS_TO_UNLOCK, true) ? |
| 56 | get_term_meta($level, MetaKey::DAYS_TO_UNLOCK, true) : |
| 57 | '0'; |
| 58 | |
| 59 | $dateUnlockVal = get_term_meta($level, MetaKey::DATE_UNLOCK, true) ? |
| 60 | get_term_meta($level, MetaKey::DATE_UNLOCK, true) : |
| 61 | null; |
| 62 | |
| 63 | $timeUnlockVal = get_term_meta($level, MetaKey::TIME_UNLOCK, true) ? |
| 64 | get_term_meta($level, MetaKey::TIME_UNLOCK, true) : |
| 65 | false; |
| 66 | |
| 67 | $buttonUnlockVal = get_term_meta($level, MetaKey::BUTTON_UNLOCK, true) ? |
| 68 | get_term_meta($level, MetaKey::BUTTON_UNLOCK, true) : |
| 69 | false; |
| 70 | ?> |
| 71 | <div class="onePageOther"> |
| 72 | <?php echo FapiMemberTools::formStart('set_section_unlocking') ?> |
| 73 | |
| 74 | <h3><?php _e('Odemknutí tlačítkem', 'fapi-member') ?></h3> |
| 75 | <label>Povolit: </label> |
| 76 | <input type="checkbox" name="button_unlock" <?php if ($buttonUnlockVal) echo 'checked'; ?>> |
| 77 | |
| 78 | <div id="button_unlock_settings"> |
| 79 | <p><?php _e('K odemčení úrovně musí uživatel již mít přístup do dané sekce.', 'fapi-member') ?></p> |
| 80 | <label><?php _e('Shrotcode talčítka pro uvolnění obsahu: ', 'fapi-member') ?></label> |
| 81 | <code><?= '[fapi-member-unlock-level level=' . $level . ']' ?></code> |
| 82 | </div> |
| 83 | |
| 84 | <br><br> |
| 85 | |
| 86 | <h3><?php _e('Časově omezené odemykání úrovně', 'fapi-member') ?></h3> |
| 87 | <div> |
| 88 | <input type="radio" name="time_unlock" value="disallow" id="disallow" |
| 89 | <?php if ($timeUnlockVal === 'disallow') echo 'checked'; ?> |
| 90 | > |
| 91 | <label for="disallow">Nepovolovat</label> |
| 92 | </div> |
| 93 | <div> |
| 94 | <input type="radio" name="time_unlock" value="date" id="date" |
| 95 | <?php if ($timeUnlockVal === 'date') echo 'checked'; ?> |
| 96 | > |
| 97 | <label for="date">Od pevného data</label> |
| 98 | </div> |
| 99 | <div> |
| 100 | <input type="radio" name="time_unlock" value="days" id="days" |
| 101 | <?php if ($timeUnlockVal === 'days') echo 'checked'; ?> |
| 102 | > |
| 103 | <label for="days">Počet dní od registrace</label> |
| 104 | </div> |
| 105 | |
| 106 | <div id="date_settings_content"> |
| 107 | <p><?php _e('Datum kdy bude sekce/úroveň odemčena pro všechny uživatele.', 'fapi-member') ?></p> |
| 108 | <input type="hidden" name="level_id" value="<?php echo $level ?>"> |
| 109 | <input type="date" min="0" max="100" name="unlock_date" value="<?php echo $dateUnlockVal ?>""> |
| 110 | </div> |
| 111 | <div id="days_settings_content"> |
| 112 | <p><?php _e('Počet dní od registrace uživatele do členské sekce, po kterých má být vybraná sekce/úroveň zpřístupněna.', 'fapi-member') ?></p> |
| 113 | <input type="hidden" name="level_id" value="<?php echo $level ?>"> |
| 114 | <input type="number" min="0" max="100" name="days_to_unlock" value="<?php echo $daysToUnlockVal ?>" oninput="this.value = Math.abs(this.value)"> |
| 115 | <p><?php _e('0 = Sekce bude přístupná ihned po registraci', 'fapi-member') ?></p> |
| 116 | <p><?php _e('3 = Sekce bude přístupná 3 den po registraci', 'fapi-member') ?></p> |
| 117 | </div> |
| 118 | |
| 119 | <div style="justify-content:start" class="row submitInline noLabel"> |
| 120 | <input type="submit" class="primary" value="<?php _e('Uložit', 'fapi-member'); ?>"> |
| 121 | </div> |
| 122 | </form> |
| 123 | </div> |
| 124 | <?php } ?> |
| 125 | |
| 126 | </div> |
| 127 | </div> |
| 128 | </div> |
| 129 | </div> |
| 130 | </div> |
| 131 | |
| 132 | <script> |
| 133 | var timeLockRadios = document.getElementsByName('time_unlock'); |
| 134 | var selectedRadioValue = document.querySelector('input[name="time_unlock"]:checked')?.value; |
| 135 | |
| 136 | var buttonUnlockCheckbox = document.getElementsByName('button_unlock')[0]; |
| 137 | toggleSettings(buttonUnlockCheckbox.checked, 'button_unlock_settings'); |
| 138 | |
| 139 | timeLockRadios.forEach(function(radio) { |
| 140 | toggleSettings( |
| 141 | radio.value === selectedRadioValue, |
| 142 | radio.value + '_settings_content', |
| 143 | ); |
| 144 | |
| 145 | radio.addEventListener('change', function(e) { |
| 146 | selectedRadioValue = document.querySelector('input[name="time_unlock"]:checked')?.value; |
| 147 | timeLockRadios.forEach(function(radio) { |
| 148 | toggleSettings( |
| 149 | radio.value === selectedRadioValue, |
| 150 | radio.value + '_settings_content', |
| 151 | ); |
| 152 | }); |
| 153 | }); |
| 154 | }); |
| 155 | |
| 156 | buttonUnlockCheckbox.addEventListener('change', function(e) { |
| 157 | toggleSettings(e.target.checked, 'button_unlock_settings'); |
| 158 | }); |
| 159 | |
| 160 | function toggleSettings(show, id) { |
| 161 | console.log(show); |
| 162 | var element = document.getElementById(id); |
| 163 | |
| 164 | if (element == undefined) { |
| 165 | return; |
| 166 | } |
| 167 | |
| 168 | if (show) { |
| 169 | element.style.display = 'block'; |
| 170 | } else { |
| 171 | element.style.display = 'none'; |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | function getSelectedOption(radios) { |
| 176 | for (let i = 0; i < radios.length; i++) { |
| 177 | if (radios[i].checked) { |
| 178 | return radios[i].value; |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | </script> |
| 183 |