Changeset 908
- Timestamp:
- 02/25/07 16:52:15 (2 years ago)
- Files:
-
- branches/punbb-1.3-dev/extras/db_update.php (modified) (1 diff)
- branches/punbb-1.3-dev/upload/post.php (modified) (2 diffs)
- branches/punbb-1.3-dev/upload/profile.php (modified) (3 diffs)
- branches/punbb-1.3-dev/upload/viewtopic.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/punbb-1.3-dev/extras/db_update.php
r897 r908 514 514 } 515 515 516 // Add the auto notify/subscription option to the users table 517 if (!$db->field_exists($db->prefix.'users', 'auto_notify')) 518 { 519 switch ($db_type) 520 { 521 case 'mysql': 522 case 'mysqli': 523 $db->query('ALTER TABLE '.$db->prefix.'users ADD auto_notify TINYINT(1) NOT NULL DEFAULT 0 AFTER notify_with_post') or error('Unable to alter DB structure.', __FILE__, __LINE__, $db->error()); 524 break; 525 526 case 'pgsql': 527 $db->query('ALTER TABLE '.$db->prefix.'users ADD auto_notify SMALLINT') or error('Unable to alter DB structure.', __FILE__, __LINE__, $db->error()); 528 $db->query('ALTER TABLE '.$db->prefix.'users ALTER auto_notify SET DEFAULT 0') or error('Unable to alter DB structure.', __FILE__, __LINE__, $db->error()); 529 $db->query('UPDATE '.$db->prefix.'users SET auto_notify=0') or error('Unable to alter DB structure.', __FILE__, __LINE__, $db->error()); 530 break; 531 532 case 'sqlite': 533 $db->query('ALTER TABLE '.$db->prefix.'users ADD auto_notify INTEGER NOT NULL DEFAULT 0') or error('Unable to alter DB structure.', __FILE__, __LINE__, $db->error()); 534 break; 535 } 536 } 537 516 538 // Finally, we update the version number 517 539 $db->query('UPDATE '.$db->prefix.'config SET conf_value=\''.$update_to.'\' WHERE conf_name=\'o_cur_version\'') or error('Unable to update version.', __FILE__, __LINE__, $db->error()); branches/punbb-1.3-dev/upload/post.php
r907 r908 195 195 if (!$db->num_rows($result)) 196 196 $db->query('INSERT INTO '.$db->prefix.'subscriptions (user_id, topic_id) VALUES('.$pun_user['id'].' ,'.$tid.')') or error('Unable to add subscription', __FILE__, __LINE__, $db->error()); 197 } 198 199 // Check if we're already subscribed, in that case unsubscribe 200 elseif ($pun_config['o_subscriptions'] == '1' && !$subscribe) 201 { 202 $query = array( 'SELECT' => '1', 203 'FROM' => 'subscriptions', 204 'WHERE' => '(topic_id='.$tid.' AND user_id='.$pun_user['id'].')'); 205 206 $result = $db->query_build($query) or error('Unable to fetch subscribtion info', __FILE__, __LINE__, $db->error()); 207 if ($db->num_rows($result)) 208 { 209 $query = array( 'DELETE' => 'subscriptions', 210 'WHERE' => '(topic_id='.$tid.' AND user_id='.$pun_user['id'].')'); 211 212 $result = $db->query_build($query) or error('Unable to remove subscription', __FILE__, __LINE__, $db->error()); 213 } 197 214 } 198 215 } … … 542 559 $checkboxes[] = '<span class="input"><input type="checkbox" id="fld'.(++$fld_count).'" name="hide_smilies" value="1"'.(isset($_POST['hide_smilies']) ? ' checked="checked"' : '').' /> <label for="fld'.$fld_count.'">'.$lang_post['Hide smilies'].'</label></span><br />'; 543 560 561 // Check/uncheck the checkbox for subscriptions depending on scenario 544 562 if (!$pun_user['is_guest'] && $pun_config['o_subscriptions'] == '1') 545 $checkboxes[] = '<span class="input"><input type="checkbox" id="fld'.(++$fld_count).'" name="subscribe" value="1"'.(isset($_POST['subscribe']) ? ' checked="checked"' : '').' /> <label for="flf'.$fld_count.'">'.$lang_post['Subscribe'].'</label></span><br />'; 563 { 564 $checked = false; 565 566 // If it's a preview 567 if (isset($_POST['preview'])) 568 $checked = isset($_POST['subscribe']) ? true : false; 569 570 // If not preview, and we're auto subscribed 571 elseif ($pun_user['auto_notify']) 572 $checked = true; 573 574 // If not auto subscribed, but perhaps already subscribed to the topic (must be a reply) 575 elseif ($tid) 576 { 577 $query = array( 'SELECT' => '1', 578 'FROM' => 'subscriptions', 579 'WHERE' => '(topic_id='.$tid.' AND user_id='.$pun_user['id'].')'); 580 581 $result = $db->query_build($query) or error('Unable to fetch subscribtion info', __FILE__, __LINE__, $db->error()); 582 if ($db->num_rows($result)) 583 $checked = true; 584 } 585 586 $checkboxes[] = '<span class="input"><input type="checkbox" id="fld'.(++$fld_count).'" name="subscribe" value="1"'.($checked ? ' checked="checked"' : '').' /> <label for="flf'.$fld_count.'">'.$lang_post['Subscribe'].'</label></span><br />'; 587 } 546 588 547 589 if (!empty($checkboxes)) branches/punbb-1.3-dev/upload/profile.php
r904 r908 661 661 case 'preferences': 662 662 { 663 $form = extract_elements(array('dst', 'timezone', 'language', 'email_setting', 'save_pass', 'notify_with_post', ' time_format', 'date_format'));663 $form = extract_elements(array('dst', 'timezone', 'language', 'email_setting', 'save_pass', 'notify_with_post', 'auto_notify', 'time_format', 'date_format')); 664 664 665 665 $form['dst'] = (isset($form['dst'])) ? 1 : 0; … … 672 672 if (!isset($form['save_pass']) || $form['save_pass'] != '1') $form['save_pass'] = '0'; 673 673 if (!isset($form['notify_with_post']) || $form['notify_with_post'] != '1') $form['notify_with_post'] = '0'; 674 if (!isset($form['auto_notify']) || $form['auto_notify'] != '1') $form['auto_notify'] = '0'; 674 675 675 676 // If the save_pass setting has changed, we need to set a new cookie with the appropriate expire date … … 1304 1305 <p class="field"> 1305 1306 <span class="input"><input type="checkbox" id="fld<?php echo ++$fld_count ?>" name="form[notify_with_post]" value="1"<?php if ($user['notify_with_post'] == '1') echo ' checked="checked"' ?> /> <label for="fld<?php echo $fld_count ?>"><?php echo $lang_profile['Notify full'] ?></label></span><br /> 1306 <span class="input"><input type="checkbox" id="fld<?php echo ++$fld_count ?>" name="form[ notify_with_post]" value="1"<?php if ($user['notify_with_post'] == '1') echo ' checked="checked"' ?> /> <label for="fld<?php echo $fld_count ?>"><?php echo $lang_profile['Subscribe by default'] ?></label></span><br />1307 <span class="input"><input type="checkbox" id="fld<?php echo ++$fld_count ?>" name="form[auto_notify]" value="1"<?php if ($user['auto_notify'] == '1') echo ' checked="checked"' ?> /> <label for="fld<?php echo $fld_count ?>"><?php echo $lang_profile['Subscribe by default'] ?></label></span><br /> 1307 1308 </p> 1308 1309 </fieldset> branches/punbb-1.3-dev/upload/viewtopic.php
r904 r908 480 480 if ($pun_user['is_admmod']) 481 481 echo "\t\t\t\t".'<input type="hidden" name="csrf_token" value="'.$pun_user['csrf_token'].'" />'."\n"; 482 if (!$pun_user['is_guest'] && $pun_config['o_subscriptions'] == '1' && ($pun_user['auto_notify'] == '1' || $cur_topic['is_subscribed'])) 483 echo "\t\t\t\t".'<input type="hidden" name="subscribe" value="1" />'."\n"; 482 484 483 485 $post_help = array();
