Changeset 3422520
- Timestamp:
- 12/18/2025 05:58:44 AM (4 months ago)
- Location:
- doc-mitayo/trunk
- Files:
-
- 6 edited
-
doc-mitayo.php (modified) (3 diffs)
-
mita-purge.php (modified) (10 diffs)
-
readme.txt (modified) (2 diffs)
-
readme_ja.txt (modified) (2 diffs)
-
survey-view.php (modified) (1 diff)
-
viewers-update.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
doc-mitayo/trunk/doc-mitayo.php
r3416962 r3422520 9 9 * Text Domain: doc-mitayo 10 10 * Domain Path: /languages 11 * Version: 1.1. 811 * Version: 1.1.9 12 12 * 13 13 * @package Doc_Mitayo … … 42 42 define('MITA_PLUGIN_URL', plugins_url('/', __FILE__)); 43 43 define('MITA_BASENAME', plugin_basename(__FILE__)); 44 load_plugin_textdomain('doc-mitayo', false, plugin_basename(dirname(__FILE__)) . '/languages');45 44 add_action('wp_enqueue_scripts', function () { 46 45 wp_enqueue_style('doc_mitayo_style', MITA_PLUGIN_URL . 'assets/docmitayo.css', '', ''); … … 105 104 mita_create_viewers(); 106 105 mita_create_results(); 106 mita_create_locks(); 107 mita_ifAllDoneLock(); 107 108 } 108 109 register_activation_hook(__FILE__, 'mita_if_plugin_activate'); -
doc-mitayo/trunk/mita-purge.php
r3191857 r3422520 1 1 <?php 2 global $mita_expirated_action;3 2 if (!defined('ABSPATH')) 4 3 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); 4 global $mita_expirated_action; 5 function mita_viewersLen($group_id_safe): int 6 { 10 7 global $wpdb; 11 8 $strSQL = "SELECT * FROM " . $wpdb->prefix . "ftmm_viewers WHERE ((group_id = %s) AND ((ctl_date Is Null)"; … … 15 12 return $wpdb->num_rows; 16 13 } 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); 14 function mita_resultLen($group_id_safe, $post_id_safe): int 15 { 21 16 global $wpdb; 22 17 $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())"; … … 62 57 return $strSQL_safe; 63 58 } 59 function 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 } 64 69 function mita_create_viewers() 65 70 { … … 69 74 return; 70 75 $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) 80 85 ) CHARACTER SET 'utf8';"; 81 86 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); … … 108 113 return; 109 114 $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 } 126 function 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';"; 118 137 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 119 138 dbDelta($strSQL); … … 126 145 } 127 146 add_action('transition_post_status', $mita_expirated_action, 10, 3); 128 function mita_equally() 147 function mita_equally(): int 129 148 { 130 149 global $wpdb; … … 169 188 $user_name_safe . "\n" . "<" . $url_safe . ">"; 170 189 if ($viewers_count == $results_count) { 171 if (mita_i s1stAllMitayo($group_id_safe, $post_id_safe) === false)190 if (mita_if1stAllMitayo($group_id_safe, $post_id_safe) === false) { 172 191 continue; 192 } 173 193 if ($isPutBads === false) { 174 194 $slack_title = sanitize_text_field(__('All have been viewed!!', 'doc-mitayo')) . $groupsGuide; … … 213 233 } 214 234 } 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)) 235 function mita_if1stAllMitayo($group_id_safe, $post_id_safe): bool 236 { 237 if (mita_isLockedId($group_id_safe, $post_id_safe)) { 223 238 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 } 251 function 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); 229 258 } 230 259 function mita_add_master($arg_group_id): int … … 236 265 $add_masters = intdiv(strlen($mita_expirated_action), mita_equally()); 237 266 return $add_masters; 267 } 268 function 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 } 238 279 } 239 280 function mita_purge_old_kairan(): string … … 248 289 } 249 290 } 250 $lockfilesDir = MITA_PLUGIN_PATH . 'locks';251 291 foreach ($purge_set as $aPurgeDocNo) { 252 292 $strSQL = "DELETE FROM " . $wpdb->prefix . "ftmm_results WHERE doc_no = %s"; 253 293 $strSQL_safe = $wpdb->prepare($strSQL, $aPurgeDocNo); 254 294 $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); 259 298 } 260 299 return wp_kses(sanitize_text_field(__('Done(purge)...', 'doc-mitayo')) -
doc-mitayo/trunk/readme.txt
r3416962 r3422520 6 6 Tested up to: 6.9 7 7 Requires PHP: 5.6 8 Stable tag: 1.1. 88 Stable tag: 1.1.9 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 98 98 (2025-12-11) : Check that it works with WordPress 6.9. 99 99 100 = 1.1.9 = 101 (2025-12-17) : Compliance with regulations. 102 100 103 == Upgrade Notice == 101 104 -
doc-mitayo/trunk/readme_ja.txt
r3416962 r3422520 6 6 Tested up to: 6.9 7 7 Requires PHP: 5.6 8 Stable tag: 1.1. 88 Stable tag: 1.1.9 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 100 100 (2025-12-11) : Check that it works with WordPress 6.9. 101 101 102 = 1.1.9 = 103 (2025-12-17) : Compliance with regulations. 104 105 102 106 == Upgrade Notice == 103 107 -
doc-mitayo/trunk/survey-view.php
r3191862 r3422520 23 23 $putString .= '<select name="member" class="mita_select">'; 24 24 $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 } 26 30 foreach ($viewers as $aViewer) { 27 31 $current_viewers_id_safe = sanitize_key($aViewer->viewers_id); -
doc-mitayo/trunk/viewers-update.php
r3191863 r3422520 8 8 $updateList = explode("\n", $orgUpdateList); 9 9 global $wpdb; 10 $wpdb->query(' DELETE FROM' . $wpdb->prefix . "ftmm_viewers");10 $wpdb->query('TRUNCATE TABLE ' . $wpdb->prefix . "ftmm_viewers"); 11 11 $listsCnt = 0; 12 12 $resultCnt = 0;
Note: See TracChangeset
for help on using the changeset viewer.