717 if($db->numrows() < 1) echo '<h3>Error adding buddy</h3><p>The username you entered is not in use by any registered user.</p>'; |
717 if($db->numrows() < 1) echo '<h3>Error adding buddy</h3><p>The username you entered is not in use by any registered user.</p>'; |
718 { |
718 { |
719 $r = $db->fetchrow(); |
719 $r = $db->fetchrow(); |
720 $db->free_result(); |
720 $db->free_result(); |
721 $q = $db->sql_query('INSERT INTO '.table_prefix.'buddies(user_id,buddy_user_id,is_friend) VALUES('.$session->user_id.', '.$r['user_id'].', 1);'); |
721 $q = $db->sql_query('INSERT INTO '.table_prefix.'buddies(user_id,buddy_user_id,is_friend) VALUES('.$session->user_id.', '.$r['user_id'].', 1);'); |
722 if(!$q) echo '<h3>Warning:</h3><p>Buddy could not be added: '.mysql_error().'</p>'; |
722 if(!$q) echo '<h3>Warning:</h3><p>Buddy could not be added: '.$db->get_error().'</p>'; |
723 $db->free_result(); |
723 $db->free_result(); |
724 } |
724 } |
725 } elseif($argv[1] == 'Remove' && preg_match('#^([0-9]+)$#', $argv[2])) { |
725 } elseif($argv[1] == 'Remove' && preg_match('#^([0-9]+)$#', $argv[2])) { |
726 // Using WHERE user_id prevents users from deleting others' buddies |
726 // Using WHERE user_id prevents users from deleting others' buddies |
727 $q = $db->sql_query('DELETE FROM '.table_prefix.'buddies WHERE user_id='.$session->user_id.' AND buddy_id='.$argv[2].';'); |
727 $q = $db->sql_query('DELETE FROM '.table_prefix.'buddies WHERE user_id='.$session->user_id.' AND buddy_id='.$argv[2].';'); |
728 $db->free_result(); |
728 $db->free_result(); |
729 if(!$q) echo '<h3>Warning:</h3><p>Buddy could not be deleted: '.mysql_error().'</p>'; |
729 if(!$q) echo '<h3>Warning:</h3><p>Buddy could not be deleted: '.$db->get_error().'</p>'; |
730 if(mysql_affected_rows() < 1) echo '<h3>Warning:</h3><p>No rows were affected. Either the selected buddy ID does not exist or you tried to delete someone else\'s buddy.</p>'; |
730 if(mysql_affected_rows() < 1) echo '<h3>Warning:</h3><p>No rows were affected. Either the selected buddy ID does not exist or you tried to delete someone else\'s buddy.</p>'; |
731 } |
731 } |
732 $template->header(); |
732 $template->header(); |
733 userprefs_show_menu(); |
733 userprefs_show_menu(); |
734 ?> |
734 ?> |
735 <table border="0" width="100%" cellspacing="10" cellpadding="0"> |
735 <table border="0" width="100%" cellspacing="10" cellpadding="0"> |
736 <tr> |
736 <tr> |
737 <td style="padding: 0px; width: 120px;" valign="top" > |
737 <td style="padding: 0px; width: 120px;" valign="top" > |
738 <div class="tblholder" style="width: 120px;"><table border="0" width="120" cellspacing="1" cellpadding="4"> |
738 <div class="tblholder" style="width: 120px;"><table border="0" width="120" cellspacing="1" cellpadding="4"> |
739 <tr><th><small>Private messages</small></th></tr> |
739 <tr><th><small><?php echo $lang->get('privmsgs_sidebar_th_privmsgs'); ?></small></th></tr> |
740 <tr><td class="row1"><small><a href="<?php echo $session->append_sid('Inbox'); ?>">Inbox</a> </small></td></tr> |
740 <tr><td class="row1"><small><a href="<?php echo makeUrlNS('Special', 'PrivateMessages/Folder/Inbox'); ?>"><?php echo $lang->get('privmsgs_folder_inbox'); ?></a></small></td></tr> |
741 <tr><td class="row2"><small><a href="<?php echo $session->append_sid('Outbox'); ?>">Outbox</a> </small></td></tr> |
741 <tr><td class="row2"><small><a href="<?php echo makeUrlNS('Special', 'PrivateMessages/Folder/Outbox'); ?>"><?php echo $lang->get('privmsgs_folder_outbox'); ?></a></small></td></tr> |
742 <tr><td class="row1"><small><a href="<?php echo $session->append_sid('Sent'); ?>">Sent Items</a></small></td></tr> |
742 <tr><td class="row1"><small><a href="<?php echo makeUrlNS('Special', 'PrivateMessages/Folder/Sent'); ?>"><?php echo $lang->get('privmsgs_folder_sent'); ?></a></small></td></tr> |
743 <tr><td class="row2"><small><a href="<?php echo $session->append_sid('Drafts'); ?>">Drafts</a> </small></td></tr> |
743 <tr><td class="row2"><small><a href="<?php echo makeUrlNS('Special', 'PrivateMessages/Folder/Drafts'); ?>"><?php echo $lang->get('privmsgs_folder_drafts'); ?></a></small></td></tr> |
744 <tr><td class="row1"><small><a href="<?php echo $session->append_sid('Archive'); ?>">Archive</a></small></td></tr> |
744 <tr><td class="row1"><small><a href="<?php echo makeUrlNS('Special', 'PrivateMessages/Folder/Archive'); ?>"><?php echo $lang->get('privmsgs_folder_archive'); ?></a></small></td></tr> |
745 <tr><th><small>Buddies</small></th></tr> |
745 <tr><th><small><?php echo $lang->get('privmsgs_sidebar_th_buddies'); ?></small></th></tr> |
746 <tr><td class="row2"><small><a href="<?php echo makeUrlNS('Special', 'PrivateMessages/FriendList'); ?>">Friend list</a></small></td></tr> |
746 <tr><td class="row2"><small><a href="<?php echo makeUrlNS('Special', 'PrivateMessages/FriendList'); ?>"><?php echo $lang->get('privmsgs_sidebar_friend_list'); ?></a></small></td></tr> |
747 <tr><td class="row1"><small><a href="<?php echo makeUrlNS('Special', 'PrivateMessages/FoeList'); ?>">Foe list</a></small></td></tr> |
747 <tr><td class="row1"><small><a href="<?php echo makeUrlNS('Special', 'PrivateMessages/FoeList'); ?>"><?php echo $lang->get('privmsgs_sidebar_foe_list'); ?></a></small></td></tr> |
748 </table></div> |
748 </table></div> |
749 </td> |
749 </td> |
750 <td valign="top"> |
750 <td valign="top"> |
751 <?php |
751 <?php |
752 $q = $db->sql_query('SELECT u.username,b.buddy_id FROM '.table_prefix.'buddies AS b LEFT JOIN '.table_prefix.'users AS u ON ( u.user_id=b.buddy_user_id ) WHERE b.user_id='.$session->user_id.' AND is_friend=1;'); |
752 $q = $db->sql_query('SELECT u.username,b.buddy_id FROM '.table_prefix.'buddies AS b LEFT JOIN '.table_prefix.'users AS u ON ( u.user_id=b.buddy_user_id ) WHERE b.user_id='.$session->user_id.' AND is_friend=1;'); |
753 if(!$q) $db->_die('The buddy list could not be selected.'); |
753 if(!$q) $db->_die('The buddy list could not be selected.'); |
754 else |
754 else |
755 { |
755 { |
756 $allbuds = ''; |
756 $allbuds = ''; |
757 echo '<br /><div class="tblholder"><table border="0" width="100%" cellspacing="1" cellpadding="4"><tr><th colspan="3">Buddy list for '.$session->username.'</th></tr>'; |
757 echo '<br /><div class="tblholder"><table border="0" width="100%" cellspacing="1" cellpadding="4"><tr><th colspan="3">' . $lang->get('privmsgs_th_buddy_list', array('username' => htmlspecialchars($session->username))) . '</th></tr>'; |
758 if($db->numrows() < 1) echo '<tr><td class="row3">No buddies in your list.</td></tr>'; |
758 if($db->numrows() < 1) echo '<tr><td class="row3">' . $lang->get('privmsgs_msg_no_buddies') . '</td></tr>'; |
759 $cls = 'row2'; |
759 $cls = 'row2'; |
760 while ( $row = $db->fetchrow() ) |
760 while ( $row = $db->fetchrow() ) |
761 { |
761 { |
762 if($cls=='row2') $cls = 'row1'; |
762 if($cls=='row2') $cls = 'row1'; |
763 else $cls = 'row2'; |
763 else $cls = 'row2'; |
764 echo '<tr><td class="'.$cls.'"><a href="'.makeUrlNS('User', str_replace(' ', '_', $row['username'])).'" '. ( isPage($paths->nslist['User'].str_replace(' ', '_', $row['username'])) ? '' : 'class="wikilink-nonexistent" ' ) .'>'.$row['username'].'</a></td><td class="'.$cls.'"><a href="'.makeUrlNS('Special', 'PrivateMessages/Compose/to/'.str_replace(' ', '_', $row['username'])).'">Send private message</a></td><td class="'.$cls.'"><a onclick="return confirm(\'Are you sure you want to delete this user from your buddy list?\')" href="'.makeUrlNS('Special', 'PrivateMessages/FriendList/Remove/'.$row['buddy_id']).'">Remove</a></td></tr>'; |
764 echo '<tr><td class="'.$cls.'"><a href="'.makeUrlNS('User', str_replace(' ', '_', $row['username'])).'" '. ( isPage($paths->nslist['User'].str_replace(' ', '_', $row['username'])) ? '' : 'class="wikilink-nonexistent" ' ) .'>'.$row['username'].'</a></td><td class="'.$cls.'"><a href="'.makeUrlNS('Special', 'PrivateMessages/Compose/to/'.str_replace(' ', '_', $row['username'])).'">' . $lang->get('privmsgs_btn_buddy_send_pm') . '</a></td><td class="'.$cls.'"><a href="'.makeUrlNS('Special', 'PrivateMessages/FriendList/Remove/'.$row['buddy_id']).'">' . $lang->get('privmsgs_btn_buddy_remove') . '</a></td></tr>'; |
765 $allbuds .= str_replace(' ', '_', $row['username']).','; |
765 $allbuds .= str_replace(' ', '_', $row['username']).','; |
766 } |
766 } |
767 $db->free_result(); |
767 $db->free_result(); |
768 $allbuds = substr($allbuds, 0, strlen($allbuds)-1); |
768 $allbuds = substr($allbuds, 0, strlen($allbuds)-1); |
769 if($cls=='row2') $cls = 'row1'; |
769 if($cls=='row2') $cls = 'row1'; |
770 else $cls = 'row2'; |
770 else $cls = 'row2'; |
771 echo '<tr><td colspan="3" class="'.$cls.'" style="text-align: center;"><a href="'.makeUrlNS('Special', 'PrivateMessages/Compose/to/'.$allbuds).'">Send a PM to all buddies</a></td></tr>'; |
771 echo '<tr><td colspan="3" class="'.$cls.'" style="text-align: center;"><a href="'.makeUrlNS('Special', 'PrivateMessages/Compose/to/'.$allbuds).'">' . $lang->get('privmsgs_btn_pm_all_buddies') . '</a></td></tr>'; |
772 echo '</table></div>'; |
772 echo '</table></div>'; |
773 } |
773 } |
774 echo '<form action="'.makeUrlNS('Special', 'PrivateMessages/FriendList/Add').'" method="post" onsubmit="if(!submitAuthorized) return false;"> |
774 echo '<form action="'.makeUrlNS('Special', 'PrivateMessages/FriendList/Add').'" method="post" onsubmit="if(!submitAuthorized) return false;"> |
775 <h3>Add a new friend</h3>'; |
775 <h3>' . $lang->get('privmsgs_heading_add_buddy') . '</h3>'; |
776 echo '<p>Username: '.$template->username_field('buddyname').' <input type="submit" name="_go" value="Add" /></p>'; |
776 echo '<p>' . $lang->get('privmsgs_lbl_username') . ' '.$template->username_field('buddyname').' <input type="submit" name="_go" value="' . $lang->get('privmsgs_btn_add') . '" /></p>'; |
777 echo '</form>'; |
777 echo '</form>'; |
778 ?> |
778 ?> |
779 </td> |
779 </td> |
780 </tr> |
780 </tr> |
781 </table> |
781 </table> |
789 if(!$q) $db->_die('The buddy\'s user ID could not be selected.'); |
789 if(!$q) $db->_die('The buddy\'s user ID could not be selected.'); |
790 if($db->numrows() < 1) echo '<h3>Error adding buddy</h3><p>The username you entered is not in use by any registered user.</p>'; |
790 if($db->numrows() < 1) echo '<h3>Error adding buddy</h3><p>The username you entered is not in use by any registered user.</p>'; |
791 { |
791 { |
792 $r = $db->fetchrow(); |
792 $r = $db->fetchrow(); |
793 $q = $db->sql_query('INSERT INTO '.table_prefix.'buddies(user_id,buddy_user_id,is_friend) VALUES('.$session->user_id.', '.$r['user_id'].', 0);'); |
793 $q = $db->sql_query('INSERT INTO '.table_prefix.'buddies(user_id,buddy_user_id,is_friend) VALUES('.$session->user_id.', '.$r['user_id'].', 0);'); |
794 if(!$q) echo '<h3>Warning:</h3><p>Buddy could not be added: '.mysql_error().'</p>'; |
794 if(!$q) echo '<h3>Warning:</h3><p>Buddy could not be added: '.$db->get_error().'</p>'; |
795 } |
795 } |
796 $db->free_result(); |
796 $db->free_result(); |
797 } elseif($argv[1] == 'Remove' && preg_match('#^([0-9]+)$#', $argv[2])) { |
797 } elseif($argv[1] == 'Remove' && preg_match('#^([0-9]+)$#', $argv[2])) { |
798 // Using WHERE user_id prevents users from deleting others' buddies |
798 // Using WHERE user_id prevents users from deleting others' buddies |
799 $q = $db->sql_query('DELETE FROM '.table_prefix.'buddies WHERE user_id='.$session->user_id.' AND buddy_id='.$argv[2].';'); |
799 $q = $db->sql_query('DELETE FROM '.table_prefix.'buddies WHERE user_id='.$session->user_id.' AND buddy_id='.$argv[2].';'); |
800 $db->free_result(); |
800 $db->free_result(); |
801 if(!$q) echo '<h3>Warning:</h3><p>Buddy could not be deleted: '.mysql_error().'</p>'; |
801 if(!$q) echo '<h3>Warning:</h3><p>Buddy could not be deleted: '.$db->get_error().'</p>'; |
802 if(mysql_affected_rows() < 1) echo '<h3>Warning:</h3><p>No rows were affected. Either the selected buddy ID does not exist or you tried to delete someone else\'s buddy.</p>'; |
802 if(mysql_affected_rows() < 1) echo '<h3>Warning:</h3><p>No rows were affected. Either the selected buddy ID does not exist or you tried to delete someone else\'s buddy.</p>'; |
803 } |
803 } |
804 $template->header(); |
804 $template->header(); |
805 userprefs_show_menu(); |
805 userprefs_show_menu(); |
806 ?> |
806 ?> |
807 <table border="0" width="100%" cellspacing="10" cellpadding="0"> |
807 <table border="0" width="100%" cellspacing="10" cellpadding="0"> |
808 <tr> |
808 <tr> |
809 <td style="padding: 0px; width: 120px;" valign="top" > |
809 <td style="padding: 0px; width: 120px;" valign="top" > |
810 <div class="tblholder" style="width: 120px;"><table border="0" width="120" cellspacing="1" cellpadding="4"> |
810 <div class="tblholder" style="width: 120px;"><table border="0" width="120" cellspacing="1" cellpadding="4"> |
811 <tr><th><small>Private messages</small></th></tr> |
811 <tr><th><small><?php echo $lang->get('privmsgs_sidebar_th_privmsgs'); ?></small></th></tr> |
812 <tr><td class="row1"><small><a href="<?php echo $session->append_sid('Inbox'); ?>">Inbox</a> </small></td></tr> |
812 <tr><td class="row1"><small><a href="<?php echo makeUrlNS('Special', 'PrivateMessages/Folder/Inbox'); ?>"><?php echo $lang->get('privmsgs_folder_inbox'); ?></a></small></td></tr> |
813 <tr><td class="row2"><small><a href="<?php echo $session->append_sid('Outbox'); ?>">Outbox</a> </small></td></tr> |
813 <tr><td class="row2"><small><a href="<?php echo makeUrlNS('Special', 'PrivateMessages/Folder/Outbox'); ?>"><?php echo $lang->get('privmsgs_folder_outbox'); ?></a></small></td></tr> |
814 <tr><td class="row1"><small><a href="<?php echo $session->append_sid('Sent'); ?>">Sent Items</a></small></td></tr> |
814 <tr><td class="row1"><small><a href="<?php echo makeUrlNS('Special', 'PrivateMessages/Folder/Sent'); ?>"><?php echo $lang->get('privmsgs_folder_sent'); ?></a></small></td></tr> |
815 <tr><td class="row2"><small><a href="<?php echo $session->append_sid('Drafts'); ?>">Drafts</a> </small></td></tr> |
815 <tr><td class="row2"><small><a href="<?php echo makeUrlNS('Special', 'PrivateMessages/Folder/Drafts'); ?>"><?php echo $lang->get('privmsgs_folder_drafts'); ?></a></small></td></tr> |
816 <tr><td class="row1"><small><a href="<?php echo $session->append_sid('Archive'); ?>">Archive</a></small></td></tr> |
816 <tr><td class="row1"><small><a href="<?php echo makeUrlNS('Special', 'PrivateMessages/Folder/Archive'); ?>"><?php echo $lang->get('privmsgs_folder_archive'); ?></a></small></td></tr> |
817 <tr><th><small>Buddies</small></th></tr> |
817 <tr><th><small><?php echo $lang->get('privmsgs_sidebar_th_buddies'); ?></small></th></tr> |
818 <tr><td class="row2"><small><a href="<?php echo makeUrlNS('Special', 'PrivateMessages/FriendList'); ?>">Friend list</a></small></td></tr> |
818 <tr><td class="row2"><small><a href="<?php echo makeUrlNS('Special', 'PrivateMessages/FriendList'); ?>"><?php echo $lang->get('privmsgs_sidebar_friend_list'); ?></a></small></td></tr> |
819 <tr><td class="row1"><small><a href="<?php echo makeUrlNS('Special', 'PrivateMessages/FoeList'); ?>">Foe list</a></small></td></tr> |
819 <tr><td class="row1"><small><a href="<?php echo makeUrlNS('Special', 'PrivateMessages/FoeList'); ?>"><?php echo $lang->get('privmsgs_sidebar_foe_list'); ?></a></small></td></tr> |
820 </table></div> |
820 </table></div> |
821 </td> |
821 </td> |
822 <td valign="top"> |
822 <td valign="top"> |
823 <?php |
823 <?php |
824 $q = $db->sql_query('SELECT u.username,b.buddy_id FROM '.table_prefix.'buddies AS b LEFT JOIN '.table_prefix.'users AS u ON ( u.user_id=b.buddy_user_id ) WHERE b.user_id='.$session->user_id.' AND is_friend=0;'); |
824 $q = $db->sql_query('SELECT u.username,b.buddy_id FROM '.table_prefix.'buddies AS b LEFT JOIN '.table_prefix.'users AS u ON ( u.user_id=b.buddy_user_id ) WHERE b.user_id='.$session->user_id.' AND is_friend=0;'); |
825 if(!$q) $db->_die('The buddy list could not be selected.'); |
825 if(!$q) $db->_die('The buddy list could not be selected.'); |
826 else |
826 else |
827 { |
827 { |
828 $allbuds = ''; |
828 $allbuds = ''; |
829 echo '<br /><div class="tblholder"><table border="0" width="100%" cellspacing="1" cellpadding="4"><tr><th colspan="3">Foe list for '.$session->username.'</th></tr>'; |
829 echo '<br /><div class="tblholder"><table border="0" width="100%" cellspacing="1" cellpadding="4"><tr><th colspan="3">' . $lang->get('privmsgs_th_foe_list', array('username' => htmlspecialchars($session->username))) . '</th></tr>'; |
830 if($db->numrows() < 1) echo '<tr><td class="row2">No foes in your list.</td></tr>'; |
830 if($db->numrows() < 1) echo '<tr><td class="row3">' . $lang->get('privmsgs_msg_no_foes') . '</td></tr>'; |
831 $cls = 'row2'; |
831 $cls = 'row2'; |
832 while ( $row = $db->fetchrow() ) |
832 while ( $row = $db->fetchrow() ) |
833 { |
833 { |
834 if($cls=='row2') $cls = 'row1'; |
834 if($cls=='row2') $cls = 'row1'; |
835 else $cls = 'row2'; |
835 else $cls = 'row2'; |
836 echo '<tr><td class="'.$cls.'"><a href="'.makeUrlNS('User', str_replace(' ', '_', $row['username'])).'" '. ( isPage($paths->nslist['User'].str_replace(' ', '_', $row['username'])) ? '' : 'class="wikilink-nonexistent" ' ) .'>'.$row['username'].'</a></td><td class="'.$cls.'"><a href="'.makeUrlNS('Special', 'PrivateMessages/Compose/to/'.str_replace(' ', '_', $row['username'])).'">Send private message</a></td><td class="'.$cls.'"><a onclick="return confirm(\'Are you sure you want to delete this user from your buddy list?\')" href="'.makeUrlNS('Special', 'PrivateMessages/FriendList/Remove/'.$row['buddy_id']).'">Remove</a></td></tr>'; |
836 echo '<tr><td class="'.$cls.'"><a href="'.makeUrlNS('User', str_replace(' ', '_', $row['username'])).'" '. ( isPage($paths->nslist['User'].str_replace(' ', '_', $row['username'])) ? '' : 'class="wikilink-nonexistent" ' ) .'>'.$row['username'].'</a></td><td class="'.$cls.'"><a href="'.makeUrlNS('Special', 'PrivateMessages/Compose/to/'.str_replace(' ', '_', $row['username'])).'">' . $lang->get('privmsgs_btn_buddy_send_pm') . '</a></td><td class="'.$cls.'"><a href="'.makeUrlNS('Special', 'PrivateMessages/FoeList/Remove/'.$row['buddy_id']).'">' . $lang->get('privmsgs_btn_buddy_remove') . '</a></td></tr>'; |
837 $allbuds .= str_replace(' ', '_', $row['username']).','; |
837 $allbuds .= str_replace(' ', '_', $row['username']).','; |
838 } |
838 } |
|
839 $db->free_result(); |
839 $allbuds = substr($allbuds, 0, strlen($allbuds)-1); |
840 $allbuds = substr($allbuds, 0, strlen($allbuds)-1); |
840 if($cls=='row2') $cls = 'row1'; |
841 if($cls=='row2') $cls = 'row1'; |
841 else $cls = 'row2'; |
842 else $cls = 'row2'; |
842 //echo '<tr><td colspan="3" class="'.$cls.'" style="text-align: center;"><a href="'.makeUrlNS('Special', 'PrivateMessages/Compose/to/'.$allbuds).'">Send a PM to all buddies</a></td></tr>'; |
|
843 echo '</table></div>'; |
843 echo '</table></div>'; |
844 } |
844 } |
845 $db->free_result(); |
|
846 echo '<form action="'.makeUrlNS('Special', 'PrivateMessages/FoeList/Add').'" method="post" onsubmit="if(!submitAuthorized) return false;"> |
845 echo '<form action="'.makeUrlNS('Special', 'PrivateMessages/FoeList/Add').'" method="post" onsubmit="if(!submitAuthorized) return false;"> |
847 <h3>Add a new foe</h3>'; |
846 <h3>' . $lang->get('privmsgs_heading_add_foe') . '</h3>'; |
848 echo '<p>Username: '.$template->username_field('buddyname').' <input type="submit" name="_go" value="Add" /></p>'; |
847 echo '<p>' . $lang->get('privmsgs_lbl_username') . ' '.$template->username_field('buddyname').' <input type="submit" name="_go" value="' . $lang->get('privmsgs_btn_add') . '" /></p>'; |
849 echo '</form>'; |
848 echo '</form>'; |
850 ?> |
849 ?> |
851 </td> |
850 </td> |
852 </tr> |
851 </tr> |
853 </table> |
852 </table> |