Plugin Directory

Changeset 3422520


Ignore:
Timestamp:
12/18/2025 05:58:44 AM (4 months ago)
Author:
dmkun920
Message:

1.1.9 tosshite shuusei simasita

Location:
doc-mitayo/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • doc-mitayo/trunk/doc-mitayo.php

    r3416962 r3422520  
    99 * Text Domain:     doc-mitayo
    1010 * Domain Path:     /languages
    11  * Version:         1.1.8
     11 * Version:         1.1.9
    1212 *
    1313 * @package         Doc_Mitayo
     
    4242define('MITA_PLUGIN_URL', plugins_url('/', __FILE__));
    4343define('MITA_BASENAME', plugin_basename(__FILE__));
    44 load_plugin_textdomain('doc-mitayo', false, plugin_basename(dirname(__FILE__)) . '/languages');
    4544add_action('wp_enqueue_scripts', function () {
    4645    wp_enqueue_style('doc_mitayo_style', MITA_PLUGIN_URL . 'assets/docmitayo.css', '', '');
     
    105104    mita_create_viewers();
    106105    mita_create_results();
     106    mita_create_locks();
     107    mita_ifAllDoneLock(); 
    107108}
    108109register_activation_hook(__FILE__, 'mita_if_plugin_activate');
  • doc-mitayo/trunk/mita-purge.php

    r3191857 r3422520  
    11<?php
    2 global $mita_expirated_action;
    32if (!defined('ABSPATH'))
    43    exit;
    5 require_once(ABSPATH . 'wp-admin/includes/file.php');
    6 WP_Filesystem();
    7 function mita_viewersLen($arg_group_id): int
    8 {
    9     $group_id_safe = sanitize_key($arg_group_id);
     4global $mita_expirated_action;
     5function mita_viewersLen($group_id_safe): int
     6{
    107    global $wpdb;
    118    $strSQL = "SELECT * FROM " . $wpdb->prefix . "ftmm_viewers WHERE ((group_id = %s) AND ((ctl_date Is Null)";
     
    1512    return $wpdb->num_rows;
    1613}
    17 function mita_resultLen($arg_group_id, $arg_post_id): int
    18 {
    19     $group_id_safe = sanitize_key($arg_group_id);
    20     $post_id_safe = sanitize_key($arg_post_id);
     14function mita_resultLen($group_id_safe, $post_id_safe): int
     15{
    2116    global $wpdb;
    2217    $strSQL = "SELECT VIEWERS.viewers_id FROM ( SELECT * FROM " . $wpdb->prefix . "ftmm_viewers WHERE ((group_id = %s) AND ((ctl_date Is Null) OR (ctl_date >= Now())";
     
    6257    return $strSQL_safe;
    6358}
     59function mita_allDoneDocNoList_safe($arg_group_id): string
     60{
     61    $group_id_safe = sanitize_key($arg_group_id);
     62    global $wpdb;
     63    $strSQL = "SELECT r.doc_no, v.group_id FROM wp_ftmm_results r JOIN wp_ftmm_viewers v ON r.viewers_id = v.viewers_id ";
     64    $strSQL .= "GROUP BY r.doc_no, v.group_id HAVING COUNT(DISTINCT r.viewers_id) = (SELECT COUNT(*) FROM (SELECT v2.viewers_id ";
     65    $strSQL .= "FROM wp_ftmm_viewers v2 WHERE v2.group_id = v.group_id ORDER BY v2.viewers_id LIMIT %d ) AS limited_viewers);";
     66    $strSQL_safe = $wpdb->prepare($strSQL, mita_add_master($group_id_safe));
     67    return $strSQL_safe;
     68}
    6469function mita_create_viewers()
    6570{
     
    6974        return;
    7075    $strSQL = "CREATE TABLE " . $wpdb->prefix . "ftmm_viewers(
    71     viewers_id varchar(10) NOT NULL,
    72             group_id varchar(50) NOT NULL,
    73             disp_order int(10) NOT NULL,
    74             viewers_name varchar(100) default NULL,
    75             ctl_date datetime default NULL,
    76             del_add tinyint(4) default NULL,
    77             INDEX(disp_order),
    78             INDEX(group_id),
    79             PRIMARY KEY(viewers_id)
     76        viewers_id varchar(10) NOT NULL,
     77        group_id varchar(50) NOT NULL,
     78        disp_order int(10) NOT NULL,
     79        viewers_name varchar(100) default NULL,
     80        ctl_date datetime default NULL,
     81        del_add tinyint(4) default NULL,
     82        INDEX(disp_order),
     83        INDEX(group_id),
     84        PRIMARY KEY(viewers_id)
    8085        ) CHARACTER SET 'utf8';";
    8186    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
     
    108113        return;
    109114    $strSQL = "CREATE TABLE " . $wpdb->prefix . "ftmm_results(
    110     id mediumint(9) NOT NULL  AUTO_INCREMENT,
    111             viewers_id varchar(10) NOT NULL,
    112             chk_time datetime NOT NULL,
    113             doc_no int(11) NOT NULL,
    114             INDEX(viewers_id),
    115             INDEX(doc_no),
    116             PRIMARY KEY(id)
    117             ) CHARACTER SET 'utf8';";
     115        id mediumint(9) NOT NULL AUTO_INCREMENT,
     116        viewers_id varchar(10) NOT NULL,
     117        chk_time datetime NOT NULL,
     118        doc_no int(11) NOT NULL,
     119        INDEX(viewers_id),
     120        INDEX(doc_no),
     121        PRIMARY KEY(id)
     122        ) CHARACTER SET 'utf8';";
     123    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
     124    dbDelta($strSQL);
     125}
     126function mita_create_locks()
     127{
     128    global $wpdb;
     129    $wpdb->get_var("SHOW TABLES LIKE '" . $wpdb->prefix . "ftmm_locks'");
     130    if (($wpdb->num_rows) > 0)
     131        return;
     132    $strSQL = "CREATE TABLE " . $wpdb->prefix . "ftmm_locks(
     133        group_id varchar(50) NOT NULL,
     134        doc_no int(11) NOT NULL,
     135        PRIMARY KEY(group_id, doc_no)
     136        ) CHARACTER SET 'utf8';";
    118137    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    119138    dbDelta($strSQL);
     
    126145}
    127146add_action('transition_post_status', $mita_expirated_action, 10, 3);
    128 function mita_equally()
     147function mita_equally(): int
    129148{
    130149    global $wpdb;
     
    169188            $user_name_safe . "\n" . "<" . $url_safe . ">";
    170189        if ($viewers_count == $results_count) {
    171             if (mita_is1stAllMitayo($group_id_safe, $post_id_safe) === false)
     190            if (mita_if1stAllMitayo($group_id_safe, $post_id_safe) === false) {
    172191                continue;
     192            }
    173193            if ($isPutBads === false) {
    174194                $slack_title = sanitize_text_field(__('All have been viewed!!', 'doc-mitayo')) . $groupsGuide;
     
    213233    }
    214234}
    215 function mita_is1stAllMitayo($arg_group_id, $arg_post_id): bool
    216 {
    217     global $wp_filesystem;
    218     $group_id_safe = sanitize_key($arg_group_id);
    219     $post_id_safe = sanitize_key($arg_post_id);
    220     $lockfilesDir = MITA_PLUGIN_PATH . 'locks';
    221     $thisLockfile = $lockfilesDir . '/kairanLock_' . $post_id_safe . '_' . $group_id_safe;
    222     if ($wp_filesystem->exists($thisLockfile))
     235function mita_if1stAllMitayo($group_id_safe, $post_id_safe): bool
     236{
     237    if (mita_isLockedId($group_id_safe, $post_id_safe)) {
    223238        return false;
    224     if (!$wp_filesystem->exists($lockfilesDir)) {
    225         $wp_filesystem->mkdir($lockfilesDir, 0744);
    226     }
    227     $wp_filesystem->touch($thisLockfile);
    228     return true;
     239    } else {
     240        $aRecord_safe = array(
     241            'group_id' => $group_id_safe,
     242            'doc_no' => $post_id_safe,
     243        );
     244        global $wpdb;
     245        $aTable = $wpdb->prefix . "ftmm_locks";
     246        $aFormat = array('%s', '%d');
     247        $wpdb->insert($aTable, $aRecord_safe, $aFormat);
     248        return true;
     249    }
     250}
     251function mita_isLockedId($group_id_safe, $post_id_safe): bool
     252{
     253    global $wpdb;
     254    $strSQL = "SELECT doc_no FROM " . $wpdb->prefix . "ftmm_locks WHERE (group_id = %s) AND (doc_no = %d)";
     255    $strSQL_safe = $wpdb->prepare($strSQL, $group_id_safe, $post_id_safe);
     256    $wpdb->get_results($strSQL_safe);
     257    return ($wpdb->num_rows > 0); 
    229258}
    230259function mita_add_master($arg_group_id): int
     
    236265        $add_masters = intdiv(strlen($mita_expirated_action), mita_equally());
    237266    return $add_masters;
     267}
     268function mita_ifAllDoneLock()
     269{
     270    global $wpdb;
     271    $allDoneDocNoList_safe = mita_allDoneDocNoList_safe("first");
     272    $rows = $wpdb->get_results($allDoneDocNoList_safe);
     273    if (empty($rows)) return;
     274    foreach ($rows as $aRecord) {
     275        $group_id_safe = sanitize_key($aRecord->group_id);
     276        $post_id_safe = sanitize_key($aRecord->doc_no);
     277        mita_if1stAllMitayo($group_id_safe, $post_id_safe);     
     278    }
    238279}
    239280function mita_purge_old_kairan(): string
     
    248289        }
    249290    }
    250     $lockfilesDir = MITA_PLUGIN_PATH . 'locks';
    251291    foreach ($purge_set as $aPurgeDocNo) {
    252292        $strSQL = "DELETE FROM " . $wpdb->prefix . "ftmm_results WHERE doc_no = %s";
    253293        $strSQL_safe = $wpdb->prepare($strSQL, $aPurgeDocNo);
    254294        $wpdb->get_results($strSQL_safe);
    255         $thisLockfiles = $lockfilesDir . '/kairanLock_' . $aPurgeDocNo . '*';
    256         foreach (glob($thisLockfiles) as $afile) {
    257             wp_delete_file($afile);
    258         }
     295        $strSQL = "DELETE FROM " . $wpdb->prefix . "ftmm_locks WHERE doc_no = %s";
     296        $strSQL_safe = $wpdb->prepare($strSQL, $aPurgeDocNo);
     297        $wpdb->get_results($strSQL_safe);
    259298    }
    260299    return wp_kses(sanitize_text_field(__('Done(purge)...', 'doc-mitayo'))
  • doc-mitayo/trunk/readme.txt

    r3416962 r3422520  
    66Tested up to: 6.9
    77Requires PHP: 5.6
    8 Stable tag: 1.1.8
     8Stable tag: 1.1.9
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    9898(2025-12-11) : Check that it works with WordPress 6.9.
    9999
     100= 1.1.9 =
     101(2025-12-17) : Compliance with regulations.
     102
    100103== Upgrade Notice ==
    101104
  • doc-mitayo/trunk/readme_ja.txt

    r3416962 r3422520  
    66Tested up to: 6.9
    77Requires PHP: 5.6
    8 Stable tag: 1.1.8
     8Stable tag: 1.1.9
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    100100(2025-12-11) : Check that it works with WordPress 6.9.
    101101
     102= 1.1.9 =
     103(2025-12-17) : Compliance with regulations.
     104
     105
    102106== Upgrade Notice ==
    103107
  • doc-mitayo/trunk/survey-view.php

    r3191862 r3422520  
    2323    $putString .= '<select name="member" class="mita_select">';
    2424    $putString .= '<option hidden>' . sanitize_text_field(__('Please Select.', 'doc-mitayo')) . '</option>';
    25     $prev_viewers_id_safe = sanitize_key($_COOKIE['mitayo_prev_viewers_id' . $group_id_safe]);
     25    if (empty($_COOKIE['mitayo_prev_viewers_id' . $group_id_safe])) {
     26        $prev_viewers_id_safe = "";
     27    } else {
     28        $prev_viewers_id_safe = sanitize_key($_COOKIE['mitayo_prev_viewers_id' . $group_id_safe]);
     29    }
    2630    foreach ($viewers as $aViewer) {
    2731        $current_viewers_id_safe = sanitize_key($aViewer->viewers_id);
  • doc-mitayo/trunk/viewers-update.php

    r3191863 r3422520  
    88    $updateList = explode("\n", $orgUpdateList);
    99    global $wpdb;
    10     $wpdb->query('DELETE FROM ' . $wpdb->prefix . "ftmm_viewers");
     10    $wpdb->query('TRUNCATE TABLE ' . $wpdb->prefix . "ftmm_viewers");
    1111    $listsCnt = 0;
    1212    $resultCnt = 0;
Note: See TracChangeset for help on using the changeset viewer.