Plugin Directory

Changeset 3103274


Ignore:
Timestamp:
06/16/2024 04:45:47 PM (22 months ago)
Author:
tharkun69
Message:

1.4.3

  • Bugfix: Error “An active PHP session was detected”
  • Bugfix: Handle wrong plan identifier in short code
  • Support of checking block conflicts
Location:
occupancy-plan/trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • occupancy-plan/trunk/admin/class-occupancy-plan-admin.php

    r3068888 r3103274  
    532532     * 1.3.8 - Don't send mail for block update
    533533     * 1.3.16 - Replace of [email] tag
    534      * 1.4.1 - Bugfix: User correct blocks controller
     534     * 1.4.1 - Bugfix: Use correct blocks controller
     535     * 1.4.3 - Use 'checkblockconflict' column
    535536     */
    536537    public function add_block()
     
    548549        {
    549550            return $this->handleError(__('No permission.', 'occupancy-plan'));
     551        }
     552
     553        // Check if block is already occupied
     554        if (isset($plan->checkblockconflict) && ($plan->checkblockconflict == 1) && ($this->blocks->check_block() > 0))
     555        {
     556            return $this->handleError(__('Conflict: Selected time slot overlaps with existing booking', 'occupancy-plan'));
    550557        }
    551558
     
    789796     * 1.3.6 - Add 'timeinterval' column, Add 'frontendtooltip' column
    790797     * 1.3.13 - Add 'undefinedname' column
     798     * 1.4.3 - Add 'checkblockconflict' column
    791799     */
    792800    private function generate_csv($planID)
     
    815823                    'allowintervaledit', 'anonymized', 'placeholder',
    816824                    'allowcourtedit','timeinterval', 'frontendtooltip',
    817                     'undefinedname');
     825                    'undefinedname'. 'checkblockconflict');
    818826        fputcsv($file, $csv_header, $delimiter);
    819827
     
    830838                    allowintervaledit,anonymized, placeholder,
    831839                    allowcourtedit, timeinterval, frontendtooltip
    832                     undefinedname
     840                    undefinedname, checkblockconflict
    833841                FROM $table_plan WHERE id = $planID";
    834842        $schedule = $wpdb->get_row($sql, ARRAY_A);
     
    914922     * 1.3.8 - Support of import of block for selected schedule
    915923     * 1.3.17 - Import of field 'authorizedusers'
     924     * 1.4.3 - Add 'checkblockconflict' column
    916925     */
    917926    public function csv_import($planID, $importblocks)
     
    10481057                        'timeinterval' => ($datalen > 43)? intval($csvdata[43]) : 60,
    10491058                        'frontendtooltip' => ($datalen > 44)? sanitize_text_field($csvdata[44]) : '',
    1050                         'undefinedname' => ($datalen > 45)? sanitize_text_field($csvdata[45]) : __('Undefined', 'occupancy-plan')
     1059                        'undefinedname' => ($datalen > 45)? sanitize_text_field($csvdata[45]) : __('Undefined', 'occupancy-plan'),
     1060                        'checkblockconflict' => ($datalen > 46)? intval($csvdata[46]) : 0
    10511061                    );
    10521062                    $format = array('%s','%s','%s','%s','%s','%s',
     
    14131423     * @since     1.4
    14141424     *
     1425     * 1.4.3 - Fix: Error “An active PHP session was detected”
    14151426     */
    14161427    public function start_session()
     
    14181429        if (!session_id())
    14191430        {
    1420             session_start();
     1431            session_start([
     1432            'read_and_close' => true,
     1433            ]);
    14211434        }
    14221435    }
  • occupancy-plan/trunk/admin/controller/class-occupancy-plan-blocks.php

    r3076337 r3103274  
    700700        }
    701701    }
     702
     703    /**
     704     * Check block existence / conflict
     705     *
     706     * @since    1.4.3
     707     *
     708     */
     709    public function check_block()
     710    {
     711        $planid = intval($_POST['planid']);
     712
     713        $interval = isset($_POST['interval'])? intval($_POST['interval']) : 1;
     714        if ($interval != 1)
     715        {
     716            return 0;
     717        }
     718        $singledate = sanitize_text_field($_POST['startdate']);
     719        $date = DateTime::createFromFormat('Y-m-d', $singledate);
     720
     721        $starttime = sanitize_text_field($_POST['starttime']);
     722        $endtime = sanitize_text_field($_POST['endtime']);
     723
     724        $courttext = sanitize_text_field($_POST['court']);
     725        if (strpos($courttext, '|') > 0)
     726        {
     727            $courtids = explode("|", $courttext);
     728            $courtid = intval($courtids[0]);
     729            $childcourtid = intval($courtids[1]);
     730        }
     731        else
     732        {
     733            $courtid = intval($courttext);
     734            if (isset($_POST['childcourt-' . $courtid]))
     735            {
     736                $childcourtid = intval($_POST['childcourt-' . $courtid]);
     737            }
     738            else
     739            {
     740                $childcourtid = isset($_POST['childcourt'])? intval($_POST['childcourt']) : 0;
     741            }
     742        }
     743
     744        $weekday = $date->format("N");
     745        $weekdayinmonth = (int) ceil($date->format("d") / 7);
     746        $calendarweek = 2 - (int) ceil($date->format("W") % 2 );
     747
     748        global $wpdb;
     749        $table_block = "{$wpdb->prefix}occupancy_plan_block";
     750
     751        $sql = "SELECT * FROM $table_block WHERE planid = {$planid}
     752            AND (weekday = {$weekday})
     753            AND ((court = 0) OR (court = {$courtid}))
     754            AND ((childcourt = 0) OR (childcourt = {$childcourtid}))
     755            AND ('{$singledate}' BETWEEN startdate AND enddate)
     756            AND ((('$starttime' >= starttime) AND ('$starttime' < endtime)) OR
     757                 (('$endtime' > starttime) AND ('$endtime' <= endtime)))
     758            AND ((`interval` <> 3) OR (intervalinfo = {$weekdayinmonth}))
     759            AND ((`interval` <> 5) OR (intervalinfo = {$calendarweek}))
     760            LIMIT 1";
     761
     762        $results = $wpdb->get_results($sql, OBJECT);
     763        return sizeof($results);
     764    }
    702765}
  • occupancy-plan/trunk/admin/controller/class-occupancy-plan-plans.php

    r3068435 r3103274  
    2828     * 1.3.6 - Add 'timeinterval' column, Add 'frontendtooltip' column
    2929     * 1.3.13 - Add 'undefinedname' column
     30     * 1.4.3 - Add 'checkblockconflict' column
    3031     */
    3132    public function new_plan()
     
    136137        $plan->frontendtooltip = '';
    137138        $plan->undefinedname =__('Undefined', 'occupancy-plan');
     139        $plan->checkblockconflict = 0;
    138140        return $plan;
    139141    }
     
    268270     * 1.3.6 - Add 'timeinterval' column, Add 'frontendtooltip' column
    269271     * 1.3.13 - Add 'undefinedname' column
     272     * 1.4.3 - Add 'checkblockconflict' column
    270273     */
    271274    public function save_plan()
     
    351354                'placeholder' => sanitize_text_field($_POST['placeholder']),
    352355                'frontendtooltip' => sanitize_text_field($_POST['frontendtooltip']),
    353                 'undefinedname' => sanitize_text_field($_POST['undefinedname'])
     356                'undefinedname' => sanitize_text_field($_POST['undefinedname']),
     357                'checkblockconflict' => isset($_POST['checkblockconflict'])? 1:0
    354358                );
    355359
     
    361365            '%d','%d','%s','%s','%s','%s','%s','%s','%d','%d',
    362366            '%s','%s','%s','%s','%s','%s','%d','%s','%s',
    363             '%d','%s','%s','%s');
     367            '%d','%s','%s','%s','%d');
    364368
    365369        if ((isset($_POST['id'])) && (intval($_POST['id']) > 0))
  • occupancy-plan/trunk/admin/partials/occupancy-plan-plan.php

    r3076337 r3103274  
    419419                            <input class="op-admin-input-90" type="text" name="undefinedname" maxlength="128" value="<?php echo (isset($plan->undefinedname))? esc_attr($plan->undefinedname) : '' ?>" <?php echo (isset($mode))? '':'readonly'?> />
    420420                            <span class="op-help-tip" data-tooltip="<?php echo __('This default text is used for the name in bookings when the user is not logged in', 'occupancy-plan');?>">?</span>
     421                        </div>
     422                        <div class="op-admin-form-col-4">
     423                            <label class="op-admin-label" for="checkblockconflict"><?php echo __('Check Block Conflict', 'occupancy-plan');?></label>
     424                        </div>
     425                        <div class="op-admin-form-col-8">
     426                            <input class="op-admin-input-100" type="checkbox" name="checkblockconflict" value="1" <?php if ($plan->checkblockconflict== 1 ) echo 'checked'; ?> <?php echo (isset($mode))? '':'disabled'?> />
     427                            <span class="op-help-tip" data-tooltip="<?php echo __('If this flag is set, when creating a booking from the frontend, it is checked whether there is a conflict with an existing booking', 'occupancy-plan');?>">?</span>
    421428                        </div>
    422429                    </div>
  • occupancy-plan/trunk/includes/class-occupancy-plan-plugin.php

    r3068435 r3103274  
    1515
    1616global $occupancy_plan_db_version;
    17 $occupancy_plan_db_version = '1.4';
     17$occupancy_plan_db_version = '1.4.3';
    1818
    1919class Occupancy_Plan_Plugin
     
    4848     * 1.3.21 - 'shortname' changed length to 16 characters
    4949     * 1.4 - Add block exceptions
     50     * 1.4.3 - Add 'checkblockconflict' column
    5051     *
    5152     */
     
    157158                frontendtooltip varchar(128) NULL,
    158159                undefinedname varchar(128) NULL,
     160                checkblockconflict bit(1) NULL,
    159161                UNIQUE KEY id (id)
    160162        ) $charset_collate;";
  • occupancy-plan/trunk/occupancy-plan.php

    r3076337 r3103274  
    1616 * Plugin URI:        https://www.software-kunze.de/plugins/occupancy-plan/
    1717 * Description:       Management of Occupancy Plans
    18  * Version:           1.4.2
     18 * Version:           1.4.3
    1919 * Author:            Alexander Kunze Software Consulting
    2020 * Author URI:        https://www.software-kunze.de
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define('Occupancy_Plan', '1.4.2');
     38define('Occupancy_Plan', '1.4.3');
    3939
    4040/**
  • occupancy-plan/trunk/public/class-occupancy-plan-public.php

    r3068435 r3103274  
    228228     * 1.2.6 - Add approval process data to plan object
    229229     * 1.3.6 - Set new columm 'timeinterval' based on the plan configuration
     230     * 1.4.3 - Fix: Check plan existencse
    230231     */
    231232    private function get_plan($planID)
     
    235236        $plan = $wpdb->get_row("SELECT * FROM $table_plan WHERE id = $planID");
    236237
    237         if (!isset($plan->timeinterval))
    238         {
    239             if ((isset($plan->oneandahalf)) && ($plan->oneandahalf == 1))
    240             {
    241                 if ((isset($plan->halfhour)) && ($plan->halfhour == 1))
    242                 {
    243                     $plan->timeinterval = 45;
     238        if (isset($plan))
     239        {
     240            if (!isset($plan->timeinterval))
     241            {
     242                if ((isset($plan->oneandahalf)) && ($plan->oneandahalf == 1))
     243                {
     244                    if ((isset($plan->halfhour)) && ($plan->halfhour == 1))
     245                    {
     246                        $plan->timeinterval = 45;
     247                    }
     248                    else
     249                    {
     250                        $plan->timeinterval = 90;
     251                    }
    244252                }
    245253                else
    246254                {
    247                     $plan->timeinterval = 90;
    248                 }
    249             }
    250             else
    251             {
    252                 if ((isset($plan->halfhour)) && ($plan->halfhour == 1))
    253                 {
    254                     $plan->timeinterval = 30;
    255                 }
    256                 else
    257                 {
    258                     $plan->timeinterval = 60;
    259                 }
    260             }
    261         }
    262         $table_approval_process = "{$wpdb->prefix}occupancy_plan_approval_process";
    263         $approval_process = $wpdb->get_row("SELECT * FROM $table_approval_process WHERE planid = $planID");
    264 
    265         if (isset($approval_process))
    266         {
    267             if (isset($approval_process->informationlink))
    268             {
    269                 $parts = explode("|", $approval_process->informationlink);
    270                 if (sizeof($parts) > 1)
    271                 {
    272                     $plan->informationlinkhref = $parts[0];
    273                     $plan->informationlinkname = $parts[1];
    274                 }
    275             }
    276            
    277             return (object) array_merge((array) $plan, (array) $approval_process);
    278         }
    279         else
    280         {
    281             return $plan;
    282         }
     255                    if ((isset($plan->halfhour)) && ($plan->halfhour == 1))
     256                    {
     257                        $plan->timeinterval = 30;
     258                    }
     259                    else
     260                    {
     261                        $plan->timeinterval = 60;
     262                    }
     263                }
     264            }
     265            $table_approval_process = "{$wpdb->prefix}occupancy_plan_approval_process";
     266            $approval_process = $wpdb->get_row("SELECT * FROM $table_approval_process WHERE planid = $planID");
     267
     268            if (isset($approval_process))
     269            {
     270                if (isset($approval_process->informationlink))
     271                {
     272                    $parts = explode("|", $approval_process->informationlink);
     273                    if (sizeof($parts) > 1)
     274                    {
     275                        $plan->informationlinkhref = $parts[0];
     276                        $plan->informationlinkname = $parts[1];
     277                    }
     278                }
     279
     280                return (object) array_merge((array) $plan, (array) $approval_process);
     281            }
     282        }
     283
     284        return $plan;
    283285    }
    284286
  • occupancy-plan/trunk/public/css/occupancy-plan-public.css

    r3016326 r3103274  
    328328}
    329329
     330.op-booking-conflict {
     331    color: red;
     332}
  • occupancy-plan/trunk/public/js/occupancy-plan-public.js

    r3068435 r3103274  
    163163            $('.wp-color-result-text').text(publicobject.selectcolor);
    164164            $('.wp-picker-clear').val(publicobject.clearcolor);
     165            $($dialogid).find('.op-booking-conflict').hide();
    165166
    166167            for (var $key in $data)
     
    294295                                        },
    295296                                        error: function (err) {
     297                                            $($dialogid).find('.op-booking-conflict').show();
    296298                                            console.error(err.responseText);
    297299                                        }
    298300                                    });
    299                                     $(this).dialog("close");
    300301                                }
    301302                                else {
     
    329330                                                },
    330331                                                success: function(response) {
    331                                                     $($dialogid).dialog('close');
    332332                                                    document.location.reload();
    333333                                                }
  • occupancy-plan/trunk/public/partials/occupancy-plan-booking-dialog.php

    r3068435 r3103274  
    425425            </p>
    426426        <?php } ?>
     427        <p class="op-booking-conflict">
     428            <?php echo __('Conflict: Selected time slot overlaps with existing booking', 'occupancy-plan');?>
     429        </p>
    427430    </form>
    428431</div>
  • occupancy-plan/trunk/public/partials/occupancy-plan-public-display.php

    r3059603 r3103274  
    592592            </p>
    593593        <?php } ?>
     594        <p class="op-booking-conflict">
     595            <?php echo __('Conflict: Selected time slot overlaps with existing booking', 'occupancy-plan');?>
     596        </p>
    594597    </form>
    595598</div>
  • occupancy-plan/trunk/readme.txt

    r3076337 r3103274  
    44Tags: Occupancy Plan, Belegungsplan, Booking, Buchungen, Hallenbelegung, Reservierung
    55Requires at least: 4.9
    6 Tested up to: 6.5.2
    7 Stable tag: 1.4.2
     6Tested up to: 6.5.4
     7Stable tag: 1.4.3
    88Requires PHP: 5.2.4
    99License: GPLv2 or later
     
    5050== Changelog ==
    5151
     52= 1.4.3 =
     53* Bugfix: Error “An active PHP session was detected”
     54* Bugfix: Handle wrong plan identifier in short code
     55* Support of checking block conflicts
     56
    5257= 1.4.2 =
    5358* Bugfix: Use plans controller for CSV export
Note: See TracChangeset for help on using the changeset viewer.