RE: Thank You 2.0 - WinterFrost - 16.03.2011
Hallo,
ich weiß das Thema ist schon etwas älter, doch ich habe eine Frage zu diesem Plugin.
Ich habe das selbe Problem wie TopM2, das Plugin ist nicht für meine MyBB Version geeignet. Doch dieses Plugin ist das einzige, was meinen Vorstellungen entspricht (laut Beschreibung). Gibt es eine Möglichkeit das Plugin doch noch zu verwenden? Oder gibt es eine alternative zu diesem Plugin? Ich nutze MyBB 1.6.2.
Mit freundlichen Grüßen, WinterFrost.
RE: Thank You 2.0 - StefanT - 17.03.2011
Du müsstest das Plugin selber umschreiben: https://www.mybb.de/forum/thread-10640.html
RE: Thank You 2.0 - WinterFrost - 17.03.2011
Wenn ich es so mache, wie dort beschrieben, klappt es dann auch?
MfG
RE: Thank You 2.0 - StefanT - 17.03.2011
In der Regel schon, aber versprechen kann ich nichts.
RE: Thank You 2.0 - WinterFrost - 17.03.2011
Gibt es auch ein Programm o.Ä. welches das für mich erledigt? Ich bin damit nicht sehr vertraut.
RE: Thank You 2.0 - StefanT - 17.03.2011
Nein, man muss ja Zeile für Zeile prüfen.
RE: Thank You 2.0 - WinterFrost - 17.03.2011
Na das wird 'ne Arbeit. :/ Danke trotzdem. So, ich habe jetzt rumprobiert & es funktioniert immernoch nicht. Kannst du vllt mal rüberschauen?
RE: Thank You 2.0 - StefanT - 17.03.2011
Dazu müsstest du mal den Code posten. Wie gesagt, es kann durchaus sein, dass man das Plugin nicht updaten kann.
RE: Thank You 2.0 - WinterFrost - 17.03.2011
Hier der Code:
[spoiler]Code: <?php
/**
* Thank you 2.0
* Copyright TECHEX - The Site
* http://www.thetechex.net
*/
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
//Necessary hooks
$plugins->add_hook("postbit", "thx");
$plugins->add_hook("xmlhttp", "do_action");
function thx_info()
{
return array(
'name' => 'Thank you',
'description' => 'Add a thank you note to a certain post.',
'website' => 'http://www.thetechex.net',
'author' => 'Zaher1988',
'authorsite' => 'http://www.thetechex.net',
'version' => '2.0',
);
}
function thx_activate()
{
global $db, $mybb;
//Create DB table
$query = $db->query("CREATE TABLE ".TABLE_PREFIX."thx (
txid INT UNSIGNED NOT NULL AUTO_INCREMENT ,
uid int( 10 ) NOT NULL ,
adduid int( 10 ) NOT NULL ,
pid int( 10 ) NOT NULL ,
tid int( 10 ) NOT NULL ,
time bigint(30) NOT NULL,
PRIMARY KEY ( txid )
) TYPE = MYISAM ;"
);
require MYBB_ROOT.'/inc/adminfunctions_templates.php';
//Edite needed templates
find_replace_templatesets("postbit", '#'.preg_quote('{$seperator}').'#', '{$post[\'thxdsp\']}{$seperator}');
find_replace_templatesets("postbit", '#'.preg_quote('{$post[\'button_quote\']}').'#', '{$post[\'button_quote\']}{$post[\'thanks\']}');
find_replace_templatesets("headerinclude","#".preg_quote('{$newpmmsg}').'#','<script language="javascript" type="text/javascript">
function thxFunction(uid,puid,pid,tid){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Ajax request was not established!");
return false;
}
}
}
// Create a function that will receive data sent from the server
var txDisp = "displayThx" + pid + tid;
var trDisp = "displayThxtr" + pid + tid;
var ajaxDisplay = getbyID(txDisp);
ajaxRequest.onreadystatechange = function()
{
if(ajaxRequest.readyState == 4)
{
getbyID(trDisp).style.display= \'\';
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
else
{
ajaxDisplay.innerHTML = \'<div><img src="./images/spinner.gif" /></div>\';
}
}
var queryString = "&uid=" + uid + "&adduid=" + puid + "&pid=" + pid + "&tid=" + tid;
ajaxRequest.open("GET", "xmlhttp.php?action=thankyou" + queryString, true);
ajaxRequest.send(null);
}
function getbyID(id)
{
var box= \'\';
if(document.all && !document.getElementById)
{
return box = document.all.id;
}
else if(document.getElementById)
{
return box = document.getElementById(id);
}
else
{
return box = document.layers[id];
}
}
function expandCollapse(id)
{
var check = id.split(\'_\');
var div = getbyID(id);
if(check[2] == \'e\')
{
if(div && div.style)
{
div.style.display = \'\';
getbyID(\'expcol_\'+id).href = getbyID(\'expcol_\'+id).href.replace(\'_e\', \'_c\');
getbyID(\'expcol_\'+id).id = getbyID(\'expcol_\'+id).id.replace(\'_e\', \'_c\');
div.id = div.id.replace(\'_e\', \'_c\');
}
}
else
{
if(div && div.style)
{
div.style.display = \'none\';
getbyID(\'expcol_\'+id).href = getbyID(\'expcol_\'+id).href.replace(\'_c\', \'_e\');
getbyID(\'expcol_\'+id).id = getbyID(\'expcol_\'+id).id.replace(\'_c\', \'_e\');
div.id = div.id.replace(\'_c\', \'_e\');
}
}
}
</script>
{$newpmmsg}');
//installing settings
$thx_group = array(
"gid" => "NULL",
"name" => "Thank you",
"title" => "Thank you",
"description" => "Displays thank you note below each post.",
"disporder" => "3",
"isdefault" => "no",
);
$db->insert_query(TABLE_PREFIX."settinggroups", $thx_group);
$gid = $db->insert_id();
$thx_setting_1 = array(
"sid" => "NULL",
"name" => "thx_max",
"title" => "Max number to directly display",
"description" => "Set how many thanks you want to display before the Show All button appears.",
"optionscode" => "text",
"value" => '5',
"disporder" => '1',
"gid" => intval($gid),
);
$db->insert_query(TABLE_PREFIX."settings", $thx_setting_1);
rebuild_settings();
}
function thx_deactivate()
{
global $db, $mybb;
require MYBB_ROOT.'/inc/adminfunctions_templates.php';
//Deleting table
$query = $db->query("drop TABLE ".TABLE_PREFIX."thx");
//Restoring templates
find_replace_templatesets("postbit", '#'.preg_quote('{$post[\'thxdsp\']}').'#', '', 0);
find_replace_templatesets("postbit", '#'.preg_quote('{$post[\'thanks\']}').'#', '', 0);
find_replace_templatesets("headerinclude","#".preg_quote('<script language="javascript" type="text/javascript">
function thxFunction(uid,puid,pid,tid){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Ajax request was not established!");
return false;
}
}
}
// Create a function that will receive data sent from the server
var txDisp = "displayThx" + pid + tid;
var trDisp = "displayThxtr" + pid + tid;
var ajaxDisplay = getbyID(txDisp);
ajaxRequest.onreadystatechange = function()
{
if(ajaxRequest.readyState == 4)
{
getbyID(trDisp).style.display= \'\';
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
else
{
ajaxDisplay.innerHTML = \'<div><img src="./images/spinner.gif" /></div>\';
}
}
var queryString = "&uid=" + uid + "&adduid=" + puid + "&pid=" + pid + "&tid=" + tid;
ajaxRequest.open("GET", "xmlhttp.php?action=thankyou" + queryString, true);
ajaxRequest.send(null);
}
function getbyID(id)
{
var box= \'\';
if(document.all && !document.getElementById)
{
return box = document.all.id;
}
else if(document.getElementById)
{
return box = document.getElementById(id);
}
else
{
return box = document.layers[id];
}
}
function expandCollapse(id)
{
var check = id.split(\'_\');
var div = getbyID(id);
if(check[2] == \'e\')
{
if(div && div.style)
{
div.style.display = \'\';
getbyID(\'expcol_\'+id).href = getbyID(\'expcol_\'+id).href.replace(\'_e\', \'_c\');
getbyID(\'expcol_\'+id).id = getbyID(\'expcol_\'+id).id.replace(\'_e\', \'_c\');
div.id = div.id.replace(\'_e\', \'_c\');
}
}
else
{
if(div && div.style)
{
div.style.display = \'none\';
getbyID(\'expcol_\'+id).href = getbyID(\'expcol_\'+id).href.replace(\'_c\', \'_e\');
getbyID(\'expcol_\'+id).id = getbyID(\'expcol_\'+id).id.replace(\'_c\', \'_e\');
div.id = div.id.replace(\'_c\', \'_e\');
}
}
}
</script>
{$newpmmsg}').'#','{$newpmmsg}',0);
//Delete settings
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='thx_max'");
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='Thank you'");
rebuild_settings();
}
function thx($post)
{
global $db, $mybb, $lang;
$lang->load("thx");
//Start adding necessary buttons to postbit
$uid = $mybb->user['uid'];
if($mybb->user['uid'] != 0 && $mybb->user['uid'] != $post['uid'])
{
$post['thanks'] = "<a href=\"javascript:thxFunction({$uid},{$post['uid']},{$post['pid']},{$post['tid']})\"><img src=\"images/english/postbit_thx.gif\" border=\"0\" alt=\"{$lang->thx_main}\" /></a>";
}
//Show row for each postbit
$post['thxdsp'] = build_thxlot($post['pid'],$post['tid']);
}
//Build up the row of the thanks notes
function build_thxlot($pid,$tid)
{
global $post, $altbg, $lang;
//Read entries
$entries = read_entries($pid,$tid,"f");
//Show or hide thanks row
if(!$entries)
{
$css_display = "none";
} else {
$css_display = "";
}
$display = "<tr id=\"displayThxtr{$post['pid']}{$post['tid']}\" style=\"display:{$css_display}\"><td class=\"{$altbg}\" align=\"center\" colspan=\"2\"><div id=\"displayThx{$post['pid']}{$post['tid']}\">{$entries}</div></td></tr>";
//return row
return $display;
}
//Do the hidden work
function do_action()
{
global $mybb, $pid, $tid, $db, $lang, $theme;
$lang->load("thx");
if ($mybb->input['action'] == "thankyou")
{
$pid = $_GET['pid'];
$tid = $_GET['tid'];
$uid = $_GET['uid'];
$check_query = $db->query("SELECT * FROM ".TABLE_PREFIX."thx WHERE uid='".intval($uid)."' AND tid='".intval($tid)."' AND pid='".intval($pid)."'");
$check = $db->num_rows($check_query);
if ($check == 0)
{
$database = array (
"txid" => "NULL",
"uid" => $mybb->user['uid'],
"adduid" => $_GET['adduid'],
"pid" => $_GET['pid'],
"tid" => $_GET['tid'],
"time" => time()
);
//Insert entry to DB
$query = $db->insert_query(TABLE_PREFIX."thx", $database);
//Output entries to row
echo "<html><head><script type=\"text/javascript\" src=\"jscripts/prototype.lite.js?ver=121\"></script><script type=\"text/javascript\" src=\"jscripts/general.js?ver=121\"></script><link rel=\"stylesheet\" type=\"text/css\" href=\"{$theme['css_url']}\" /></head><body>".read_entries($pid,$tid,"p")."</body></html>";
}
else
{
echo $lang->thx_error;
}
}
}
//Let's read the specified entries from the DB
function read_entries($pid,$tid,$type)
{
global $db, $entries, $mybb, $showall, $additional, $lang;
//Reset entries list
$entries = "";
$entries2 = "";
//Get all entries
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."thx WHERE pid='$pid' AND tid='$tid' ORDER BY time DESC");
$counter = 0;
while($ft = $db->fetch_array($query))
{
$query2 = $db->query("SELECT * FROM ".TABLE_PREFIX."users WHERE uid='".$ft['uid']."'");
while ($ft2 = $db->fetch_array($query2))
{
$date = gmdate("M-j-Y", $ft['time']);
//Check if we need to hide/show X number set in the settings panel
if($counter < $mybb->settings['thx_max'])
{
$entries .= $r1comma."<a href=\"member.php?action=profile&uid=".$ft2['uid']."\">".format_name($ft2[username], $ft2['usergroup'], $dt2['displaygroup'])."</a> <span class=\"smalltext\">(".$date.")</span>";
}
else
{
$entries2 .= $r2comma."<a href=\"member.php?action=profile&uid=".$ft2['uid']."\">".format_name($ft2[username], $ft2['usergroup'], $dt2['displaygroup'])."</a> <span class=\"smalltext\">(".$date.")</span>";
$r2comma =", ";
}
$r1comma =", ";
}
$counter++;
}
if($entries2 == "" && $entries != "")
{
$entries = "<div class=\"smalltext\" style=\"float:left;width:20%\">{$lang->thx_givenby}</div><div align=\"left\">{$entries}</div>";
return $entries;
}
elseif($entries2 != "" && $entries != "")
{
$additional = "<div style=\"display:none\" id=\"thx_{$pid}_e\" align=\"left\">{$entries2}</div>";
$entrieslist = "<div class=\"smalltext\" style=\"float:left;width:20%\">{$lang->thx_givenby}</div><div align=\"left\">{$entries} <a href=\"javascript:expandCollapse('thx_{$pid}_e');\" id=\"expcol_thx_{$pid}_e\">....</a></div>{$additional}";
return $entrieslist;
}
else
{
$entries =""; // just to make sure
return $entries;
}
}
//Function to rebuilt all settings
if(!function_exists("rebuild_settings"))
{
function rebuild_settings()
{
global $db, $mybb;
if(!file_exists(MYBB_ROOT."inc/settings.php"))
{
$mode = "x";
}
else
{
$mode = "w";
}
$options = array(
"order_by" => "title",
"order_dir" => "ASC"
);
$query = $db->simple_select(TABLE_PREFIX."settings", "value, name", "", $options);
while($setting = $db->fetch_array($query))
{
$setting['value'] = str_replace("\"", "\\\"", $setting['value']);
$settings .= "\$settings['".$setting['name']."'] = \"".$setting['value']."\";\n";
$mybb->settings[$setting['name']] = $setting['value'];
}
$settings = "<"."?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n?".">";
$file = @fopen(MYBB_ROOT."inc/settings.php", $mode);
@fwrite($file, $settings);
@fclose($file);
$GLOBALS['settings'] = &$mybb->settings;
}
}
?>
[/spoiler]
RE: Thank You 2.0 - StefanT - 17.03.2011
Und was ist das Problem damit?
PS: Als Attachment wäre es besser gewesen.
|