Προς το περιεχόμενο

PHP mod problem σε Forum


merez

Προτεινόμενες αναρτήσεις

Δημοσ.

Hello!

 

Τρέχω ένα YaBB Forum (είναι παλιό και ίσως πολλοί δεν το γνωρίζετε καν, αλλά δε γίνεται update για διάφορους λόγους)

 

Πρόσφατα προσπάθησα να του προσθέσω ένα mod το οποίο πετάει ένα απλό alert box όποτε έρχεται νέο προσωπικό μήνυμα. Το πρόβλημα είναι ότι το κουτάκι εμφανίζεται 2 φορές, και όχι μία όπως θα έπρεπε, ενά κατά τα άλλα παίζει κανονικά.

Παρακάτω παραθέτω τα τμήματα κώδικα τα οποία τροποποιοεί το συγκεκριμένο mod.

 

>
<id>
New messages
</id>

<version>
1.0 for YaBB SE 1.4.0
</version>

<mod info>
This mod makes it so that each user can see how many new instant messages they have, instead of only knowing how many you have all together. This version adds an alert box.

Upload "Newmessagesdbalert.php" to your YaBB SE directory and type in http://www.yoursite.com/yabbse/Newmessagesdbalert.php to update your database.
</mod info>

<author>
Chris CromerModified for YaBB SE 1.4.0 by Shaun
</author>

<homepage>
http://www.agigames.comhttp://www.clubcelica.com
</homepage>

<edit file>
Sources/Subs.php
</edit file>

<search for>
if($username != "Guest") {
	$request = mysql_query("SELECT COUNT(*) FROM {$db_prefix}instant_messages WHERE (toName='$username' && deletedBy!=1)");
	$temp = mysql_fetch_row($request);
	$mnum = $temp[0];
	$requestred = mysql_query("SELECT COUNT(*) FROM {$db_prefix}instant_messages WHERE (toName='$username' && readBy!=1 && deletedBy!=1)");
	$temp2 = mysql_fetch_row($requestred);
	$munred = $temp2[0];
	if ($munred == "1") { $isare = $txt[newmessages0]; }
	else { $isare = $txt[newmessages1]; }
	if($mnum == "1") { $yyim = "$txt[152] <a href=\"$cgi;action=im\">$mnum $txt[471]</a>$txt[newmessages4] $munred $isare $txt[newmessages2]."; }
	else { $yyim = "$txt[152] <a href=\"$cgi;action=im\">$mnum $txt[153]</a>$txt[newmessages4] $munred $isare $txt[newmessages2]."; }
	if($maintenance) { $yyim .= "<BR><B>$txt[616]</B>"; }
}
</search for>

<replace>
if($username != "Guest") {
	$request = mysql_query("SELECT COUNT(*) FROM {$db_prefix}instant_messages WHERE (toName='$username' && deletedBy!=1)");
	$temp = mysql_fetch_row($request);
	$mnum = $temp[0];
	$requestred = mysql_query("SELECT COUNT(*) FROM {$db_prefix}instant_messages WHERE (toName='$username' && readBy!=1 && deletedBy!=1)");
	$temp2 = mysql_fetch_row($requestred);
	$munred = $temp2[0];
	if ($munred == "1") { $isare = $txt[newmessages0]; }
	else { $isare = $txt[newmessages1]; }
	if($mnum == "1") { $yyim = "$txt[152] <a href=\"$cgi;action=im\">$mnum $txt[471]</a>$txt[newmessages4] $munred $isare $txt[newmessages2]."; }
	else { $yyim = "$txt[152] <a href=\"$cgi;action=im\">$mnum $txt[153]</a>$txt[newmessages4] $munred $isare $txt[newmessages2]."; }
	if($maintenance) { $yyim .= "<BR><B>$txt[616]</B>"; }
	$request4 = mysql_query("SELECT im_alert FROM {$db_prefix}members WHERE memberName='$username'");
	$alerter = mysql_fetch_array($request4);
	$request3 = mysql_query("SELECT COUNT(*) FROM {$db_prefix}instant_messages WHERE (toName='$username' && alerted!=1 && deletedBy!=1)");
	$tempalert = mysql_fetch_row($request3);
	$unalerted = $tempalert[0];
	if($unalerted > 0) {
		if($alerter[0] == 0) {
			if($munred > 0) {
				if ($munred == 1) {
					print ("<SCRIPT>alert ('$txt[newmessages6] $munred $txt[newmessages7].')</SCRIPT>");
						$request = mysql_query("UPDATE {$db_prefix}instant_messages SET alerted='1' WHERE (toName='$username')");
				}
				else {
					print ("<SCRIPT>alert ('$txt[newmessages6] $munred $txt[newmessages8].')</SCRIPT>");	
						$request = mysql_query("UPDATE {$db_prefix}instant_messages SET alerted='1' WHERE (toName='$username')");
				}
			}
		}
	}
}
</replace>

<edit file>
Sources/InstantMessage.php
</edit file>

<search for>
$yySetLocation = "$cgi;action=im";
</search for>

<replace>
$yySetLocation = "$cgi;action=imoutbox";
</replace>

<search for>
$request = mysql_query("SELECT im_ignore_list,im_email_notify FROM {$db_prefix}members WHERE ID_MEMBER=$ID_MEMBER");
</search for>

<replace>
$request = mysql_query("SELECT im_ignore_list,im_email_notify,im_alert FROM {$db_prefix}members WHERE ID_MEMBER=$ID_MEMBER");
</replace>

<search for>
$sel0 = $sel1 = '';
if ($imconfig[1]) {
	$sel0='';
	$sel1=' selected';
} else {
	$sel0=' selected';
	$sel1='';
}
</search for>

<add after>
$aler0 = $aler1 = '';
if ($imconfig[2]) {
	$aler0='';
	$aler1=' selected';
} else {
	$aler0=' selected';
	$aler1='';
}
</add after>

<search for>
    <tr>
     <td valign=top>
      <font size=2><b>$txt[327]:</b></font>
     </td>
     <td>
      <font size=2>
<select name="notify">
 <option value="0"$sel0>$txt[164]
 <option value="1"$sel1>$txt[163]
</select>
      </font>
     </td>
    </tr>
</search for>

<add after>
    <tr>
     <td valign=top>
      <font size=2><b>$txt[newmessages5]:</b></font>
     </td>
     <td>
      <font size=2>
<select name="alerter">
 <option value="0"$aler0>$txt[163]
 <option value="1"$aler1>$txt[164]
</select>
      </font>
     </td>
    </tr>
</add after>

<search for>
function IMPreferences (){
global $username,$txt,$ID_MEMBER,$yytitle,$cgi,$img,$imagesdir,$scripturl,$color,$mbname;
global $db_prefix, $settings, $menusep, $color, $modSettings;
</search for>

<add after>
global $alerter;
</add after>

<search for>
function IMPreferences2 () {
global $username,$ID_MEMBER,$yySetLocation,$ignore,$notify,$cgi,$db_prefix;
</search for>

<add after>
global $alerter;
</add after>

<search for>
$request = mysql_query("UPDATE {$db_prefix}members SET im_ignore_list='$ignorelist',im_email_notify=$notify WHERE ID_MEMBER=$ID_MEMBER");
</search for>

<replace>
$request = mysql_query("UPDATE {$db_prefix}members SET im_ignore_list='$ignorelist',im_email_notify=$notify,im_alert=$alerter WHERE ID_MEMBER=$ID_MEMBER");
</replace>

<edit file>
English.lng
</edit file>

<search for>
$txt['newmessages0'] = "is";
$txt['newmessages1'] = "are";
$txt['newmessages2'] = "new";
$txt['newmessages3'] = "New";
$txt['newmessages4'] = ",";
</search for>

<add after>
$txt['newmessages5'] = "Show alert for new messages";
$txt['newmessages6'] = "You have";
$txt['newmessages7'] = "new message";
$txt['newmessages8'] = "new messages";
</add after>

Αρχειοθετημένο

Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.

  • Δημιουργία νέου...