Initial commit
425
forumplugins/plugins/achivements/include/hooks.php
Normal file
|
@ -0,0 +1,425 @@
|
|||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* MyBB 1.6
|
||||
* Copyright 2012 MyBB-Es Team, All Rights Reserved
|
||||
*
|
||||
* Website: http://www.mybb-es.com.com
|
||||
*
|
||||
* $Id: hooks.php 2013-08-20 10:58Z EdsonOrdaz $
|
||||
*/
|
||||
|
||||
if(!defined("IN_MYBB"))
|
||||
{
|
||||
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
|
||||
}
|
||||
|
||||
$plugins->add_hook("member_profile_end", "profile_achivements");
|
||||
$plugins->add_hook("postbit", "postbit_achivements");
|
||||
$plugins->add_hook("usercp_start", "usercp_achivements");
|
||||
$plugins->add_hook("modcp_start", "modcp_achivements");
|
||||
|
||||
function postbit_achivements(&$post)
|
||||
{
|
||||
global $templates, $mybb, $lang;
|
||||
$lang->load("achivements", false, true);
|
||||
static $static_achievements;
|
||||
$post['achivements'] = getarchivements($post['uid']);
|
||||
if (!$post['achivements'])
|
||||
{
|
||||
$achivements = $lang->notachivements;
|
||||
}
|
||||
else
|
||||
{
|
||||
$num_achiviements = 0;
|
||||
foreach($post['achivements'] as $column => $logro)
|
||||
{
|
||||
if($logro['showpostbit'] == 1)
|
||||
{
|
||||
++$num_achiviements;
|
||||
$achivements .= "<img src=\"".htmlspecialchars_uni($logro['image'])."\" title=\"".htmlspecialchars_uni($logro['name'])."\" /> ";
|
||||
if ($num_achiviements >= $mybb->settings['achivements_maxpostbit'])
|
||||
break;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($num_achiviements >= $mybb->settings['achivements_maxpostbit'])
|
||||
break;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
if(!$achivements)
|
||||
{
|
||||
$achivements = $lang->achshide;
|
||||
}
|
||||
}
|
||||
if($mybb->settings['achivements_showachvpostbit'] == 1)
|
||||
{
|
||||
eval("\$post['achivementspostbit'] = \"".$templates->get("achivements_postbit")."\";");
|
||||
}
|
||||
}
|
||||
|
||||
function profile_achivements()
|
||||
{
|
||||
global $mybb, $memprofile, $templates, $lang, $theme, $achivements, $achivementsprofile;
|
||||
$lang->load("achivements", false, true);
|
||||
$memprofile['achivements'] = getarchivements($memprofile['uid']);
|
||||
|
||||
if(!$memprofile['achivements'])
|
||||
{
|
||||
$lang->achisemptytableprofile = $lang->sprintf($lang->achisemptytableprofile, $memprofile['username']);
|
||||
$achivements = $lang->achisemptytableprofile;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
foreach($memprofile['achivements'] as $archivement)
|
||||
{
|
||||
if($archivement['showprofile'] == 1)
|
||||
{
|
||||
$achivements .= "<img src=\"".htmlspecialchars_uni($archivement['image'])."\" title=\"".htmlspecialchars_uni($archivement['name'])."\" /> ";
|
||||
}
|
||||
}
|
||||
if(!$achivements)
|
||||
{
|
||||
$lang->achishidetableprofile = $lang->sprintf($lang->achishidetableprofile, $memprofile['username']);
|
||||
$achivements = $lang->achishidetableprofile;
|
||||
}
|
||||
}
|
||||
$lang->achsmemprofile = $lang->sprintf($lang->achsmemprofile, $memprofile['username']);
|
||||
if($mybb->settings['achivements_showachvprofile'] == 1)
|
||||
{
|
||||
eval("\$achivementsprofile = \"".$templates->get("achivements_profile")."\";");
|
||||
}
|
||||
}
|
||||
|
||||
function usercp_achivements()
|
||||
{
|
||||
global $mybb,$db,$templates,$theme,$lang,$headerinclude,$header,$footer,$usercpnav;
|
||||
if($mybb->input['action'] != "achivements" && $mybb->input['action'] != "do_achivements")
|
||||
{
|
||||
return;
|
||||
}
|
||||
if($mybb->input['action'] == "do_achivements" && $mybb->request_method == "post")
|
||||
{
|
||||
verify_post_check($mybb->input['my_post_key']);
|
||||
$mybb->user['achivements'] = getarchivements($mybb->user['uid']);
|
||||
if($mybb->input['profile'])
|
||||
{
|
||||
$db->update_query('user_achivements', array('showprofile' => 0), '`uid`='.$mybb->user['uid']);
|
||||
if($mybb->input['showachivement'])
|
||||
{
|
||||
foreach($mybb->input['showachivement'] as $achs)
|
||||
{
|
||||
$db->update_query('user_achivements', array('showprofile' => 1), '`uid`='.$mybb->user['uid'].' AND `aid`='.$achs);
|
||||
}
|
||||
}
|
||||
}
|
||||
if($mybb->input['postbit'])
|
||||
{
|
||||
$db->update_query('user_achivements', array('showpostbit' => 0), '`uid`='.$mybb->user['uid']);
|
||||
if($mybb->input['showachivement'])
|
||||
{
|
||||
$count = 0;
|
||||
foreach($mybb->input['showachivement'] as $achs)
|
||||
{
|
||||
$db->update_query('user_achivements', array('showpostbit' => 1), '`uid`='.$mybb->user['uid'].' AND `aid`='.$achs);
|
||||
++$count;
|
||||
if($count >= $mybb->settings['achivements_maxpostbit'])
|
||||
break;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
redirect("usercp.php", $lang->redirect_profileupdated);
|
||||
}
|
||||
if($errors)
|
||||
{
|
||||
$errors = inline_error($errors);
|
||||
}
|
||||
$lang->load("achivements", false, true);
|
||||
add_breadcrumb($lang->nav_usercp, "usercp.php");
|
||||
add_breadcrumb($lang->achivements, "usercp.php");
|
||||
|
||||
static $static_achievements;
|
||||
$mybb->user['achivements'] = getarchivements($mybb->user['uid']);
|
||||
|
||||
if(!$mybb->user['achivements'])
|
||||
{
|
||||
$achivements = "<span class='smalltext'>{$lang->achisemptytableprofileusercp}</span>";
|
||||
$currentachivements = "<span class='smalltext'>{$lang->achisemptytableprofileusercp}</span>";
|
||||
$currentachivementspostbit = "<span class='smalltext'>{$lang->achisemptytableprofileusercp}</span>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$intshow = 0;
|
||||
$intshowpostbit = 0;
|
||||
$currentachivements = "<small>{$lang->achivementsshowprofilecurrent}</small><br />";
|
||||
$lang->achivementsshowpostbitcurrent = $lang->sprintf($lang->achivementsshowpostbitcurrent, $mybb->settings['achivements_maxpostbit']);
|
||||
$currentachivementspostbit = "<small>{$lang->achivementsshowpostbitcurrent}</small><br />";
|
||||
|
||||
|
||||
$countachs = 1;
|
||||
$postbit = 0;
|
||||
//die(var_dump($mybb->user['achivements']));
|
||||
foreach($mybb->user['achivements'] as $archivement)
|
||||
{
|
||||
if($archivement['showprofile'] == 1)
|
||||
{
|
||||
$intshow = 1;
|
||||
$currentachivements .= "<img src=\"".htmlspecialchars_uni($archivement['image'])."\" title=\"".htmlspecialchars_uni($archivement['name'])."\" /> ";
|
||||
}
|
||||
if($archivement['showpostbit'] == 1 && $postbit == 0)
|
||||
{
|
||||
$intshowpostbit = 1;
|
||||
$currentachivementspostbit .= "<img src=\"".htmlspecialchars_uni($archivement['image'])."\" title=\"".htmlspecialchars_uni($archivement['name'])."\" /> ";
|
||||
if($countachs >= intval($mybb->settings['achivements_maxpostbit']))
|
||||
{
|
||||
$postbit = 1;
|
||||
}else{
|
||||
$postbit = 0;
|
||||
}
|
||||
++$countachs;
|
||||
}
|
||||
}
|
||||
|
||||
if($intshowpostbit == 0)
|
||||
{
|
||||
$currentachivementspostbit = "<small>{$lang->notachshowpostbit}</small>";
|
||||
}
|
||||
if($intshow == 0)
|
||||
{
|
||||
$currentachivements = "<small>{$lang->notachshowprofile}</small>";
|
||||
}
|
||||
foreach($mybb->user['achivements'] as $ach)
|
||||
{
|
||||
$achivement .= "<img src=\"".htmlspecialchars_uni($ach['image'])."\" title=\"".htmlspecialchars_uni($ach['name'])."\" /> ";
|
||||
eval("\$achivements .= \"".$templates->get("achivements_usercp_all")."\";");
|
||||
unset($achivement);
|
||||
}
|
||||
}
|
||||
eval("\$achivementsusercp = \"".$templates->get("achivements_usercp")."\";");
|
||||
output_page($achivementsusercp);
|
||||
}
|
||||
|
||||
function modcp_achivements()
|
||||
{
|
||||
global $templates, $modcp_nav, $lang, $mybb, $db;
|
||||
global $headerinclude, $header, $errors, $theme, $cache, $footer;
|
||||
$lang->load("achivements", false, true);
|
||||
$lang->load("admin/achivements", false, true);
|
||||
|
||||
if($mybb->settings['achivements_modcp'] == 1)
|
||||
{
|
||||
eval("\$nav_achivements = \"".$templates->get("achivements_modcp_nav")."\";");
|
||||
$modcp_nav = str_replace('<!--modcp_achivements-->', $nav_achivements, $modcp_nav);
|
||||
}
|
||||
|
||||
if($mybb->input['action'] == "achivements" && $mybb->usergroup['canmodcp'] == 1 && $mybb->settings['achivements_modcp'] == 1)
|
||||
{
|
||||
add_breadcrumb($lang->nav_modcp, "modcp.php");
|
||||
add_breadcrumb($lang->achivements, 'modcp.php?action=achivements');
|
||||
if($mybb->input['mod'] == "give")
|
||||
{
|
||||
$query = $db->simple_select('achivements_custom', '*', "acid='".intval($mybb->input['acid'])."'");
|
||||
$custom = $db->fetch_array($query);
|
||||
if(!$custom['acid'])
|
||||
{
|
||||
error_no_permission();
|
||||
}
|
||||
if($custom['modcp'] == 0)
|
||||
{
|
||||
error_no_permission();
|
||||
}
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$query = $db->simple_select("users", '*', "username='".$db->escape_string($mybb->input['username'])."'");
|
||||
$user = $db->fetch_array($query);
|
||||
if(!$user['uid'])
|
||||
{
|
||||
error_no_permission();
|
||||
}
|
||||
$achivements = unserialize($user['achivements']);
|
||||
$acid = intval($custom['acid']);
|
||||
|
||||
if(!empty($achivements['acid'][$acid]['acid']))
|
||||
{
|
||||
$lang->repeatcustom = $lang->sprintf($lang->repeatcustom, $user['username'], $custom['name']);
|
||||
redirect("modcp.php?action=achivements", $lang->repeatcustom);
|
||||
}
|
||||
|
||||
$achivements['acid'][$acid] = array('acid' => $acid, 'name' => $db->escape_string($custom['name']), 'image' => $db->escape_string($custom['image']), 'showprofile' => 1, 'showpostbit' => 0);
|
||||
|
||||
$updateuser = array(
|
||||
'achivements' => serialize($achivements)
|
||||
);
|
||||
|
||||
$lang->successachcustom = $lang->sprintf($lang->successachcustom, $custom['name'], $user['username']);
|
||||
$db->update_query("users", $updateuser,"uid=".$user['uid']);
|
||||
|
||||
$add = array(
|
||||
'user' => $mybb->user['uid'],
|
||||
'give' => $user['uid'],
|
||||
'dateline' => TIME_NOW,
|
||||
'log' => 'give',
|
||||
'acid' => $custom['acid'],
|
||||
'ipaddress' => get_ip()
|
||||
);
|
||||
$add = serialize($add);
|
||||
add_log_custom_modcp($add);
|
||||
|
||||
require_once MYBB_ROOT."inc/plugins/achivements/include/mp.php";
|
||||
$sendmp = unserialize($mybb->settings['achivements_sendmp']);
|
||||
if($sendmp['custom'] == 1)
|
||||
{
|
||||
send_mp_achivement_new($user['uid'], 'custom', $custom['acid']);
|
||||
}
|
||||
|
||||
redirect("modcp.php?action=achivements", $lang->successachcustom);
|
||||
exit;
|
||||
}
|
||||
$lang->giveuserform = $lang->sprintf($lang->giveuserform, $custom['name']);
|
||||
eval("\$give = \"".$templates->get("achivements_modcp_give")."\";");
|
||||
output_page($give);
|
||||
exit;
|
||||
}
|
||||
elseif($mybb->input['mod'] == "quit")
|
||||
{
|
||||
$query = $db->simple_select('achivements_custom', '*', "acid='".intval($mybb->input['acid'])."'");
|
||||
$custom = $db->fetch_array($query);
|
||||
if(!$custom['acid'])
|
||||
{
|
||||
error_no_permission();
|
||||
}
|
||||
if($custom['modcp'] == 0)
|
||||
{
|
||||
error_no_permission();
|
||||
}
|
||||
if($mybb->request_method == "post")
|
||||
{
|
||||
$query = $db->simple_select("users", '*', "username='".$db->escape_string($mybb->input['username'])."'");
|
||||
$user = $db->fetch_array($query);
|
||||
if(!$user['uid'])
|
||||
{
|
||||
error_no_permission();
|
||||
}
|
||||
$achivements = unserialize($user['achivements']);
|
||||
$acid = intval($custom['acid']);
|
||||
|
||||
if(empty($achivements['acid'][$acid]['acid']))
|
||||
{
|
||||
$lang->notcustomuser = $lang->sprintf($lang->notcustomuser, $user['username'], $custom['name']);
|
||||
redirect("modcp.php?action=achivements", $lang->notcustomuser);
|
||||
}
|
||||
|
||||
unset($achivements['acid'][$acid]);
|
||||
if(empty($achivements['acid']))
|
||||
{
|
||||
unset($achivements['acid']);
|
||||
}
|
||||
|
||||
$updateuser = array(
|
||||
'achivements' => serialize($achivements)
|
||||
);
|
||||
$db->update_query("users", $updateuser,"uid=".$user['uid']);
|
||||
|
||||
$add = array(
|
||||
'user' => $mybb->user['uid'],
|
||||
'revoke' => $user['uid'],
|
||||
'dateline' => TIME_NOW,
|
||||
'log' => 'revoke',
|
||||
'acid' => $custom['acid'],
|
||||
'ipaddress' => get_ip()
|
||||
);
|
||||
$add = serialize($add);
|
||||
add_log_custom_modcp($add);
|
||||
|
||||
$lang->successachivementcustomdelete = $lang->sprintf($lang->successachivementcustomdelete, $user['username'], $custom['name']);
|
||||
redirect("modcp.php?action=achivements", $lang->successachivementcustomdelete);
|
||||
exit;
|
||||
}
|
||||
$lang->quitcustom = $lang->sprintf($lang->quitcustom, $custom['name']);
|
||||
eval("\$quit = \"".$templates->get("achivements_modcp_quit")."\";");
|
||||
output_page($quit);
|
||||
exit;
|
||||
}
|
||||
|
||||
$query = $db->simple_select('achivements_custom', '*', 'modcp="1"', array('order_by' => 'acid', 'order_dir' => 'DESC'));
|
||||
while($custom = $db->fetch_array($query))
|
||||
{
|
||||
$trow = alt_trow();
|
||||
eval("\$custom_achivements .= \"".$templates->get("achivements_modcp_list")."\";");
|
||||
}
|
||||
if(empty($custom_achivements))
|
||||
{
|
||||
$custom_achivements = "<tr><td class=\"trow1\" align=\"center\" colspan=\"10\">{$lang->emptycustom_modules}</td></tr>";
|
||||
}
|
||||
eval("\$modcpachivements = \"".$templates->get("achivements_modcp")."\";");
|
||||
output_page($modcpachivements);
|
||||
}
|
||||
}
|
||||
|
||||
function add_log_custom_modcp($log)
|
||||
{
|
||||
global $db, $lang;
|
||||
$log = unserialize($log);
|
||||
$user = get_user(intval($log['user']));
|
||||
//$custom = getcustom($log['acid']);
|
||||
|
||||
if($log['log'] == 'add')
|
||||
{
|
||||
$lang->logadd = $lang->sprintf($lang->logadd, $custom['name']);
|
||||
$loginsert = $lang->logadd;
|
||||
}
|
||||
elseif($log['log'] == 'quit')
|
||||
{
|
||||
$lang->logdelete = $lang->sprintf($lang->logdelete, $custom['name']);
|
||||
$loginsert = $lang->logdelete;
|
||||
}
|
||||
elseif($log['log'] == 'give')
|
||||
{
|
||||
$give = get_user($log['give']);
|
||||
$username = format_name($give['username'], $give['usergroup'], $give['displaygroup']);
|
||||
$profilelink = build_profile_link($username, $give['uid'], "_blank");
|
||||
$lang->loggive = $lang->sprintf($lang->loggive, $custom['name'], $profilelink);
|
||||
$loginsert = $lang->loggive;
|
||||
}
|
||||
elseif($log['log'] == 'revoke')
|
||||
{
|
||||
$revoke = get_user($log['revoke']);
|
||||
$username = format_name($revoke['username'], $revoke['usergroup'], $revoke['displaygroup']);
|
||||
$profilelink = build_profile_link($username, $revoke['uid'], "_blank");
|
||||
$lang->logrevoke = $lang->sprintf($lang->logrevoke, $custom['name'], $profilelink);
|
||||
$loginsert = $lang->logrevoke;
|
||||
}
|
||||
elseif($log['log'] == 'truncate')
|
||||
{
|
||||
$db->query("truncate ".TABLE_PREFIX."achivements_customlog");
|
||||
$loginsert = $lang->logtruncate;
|
||||
}
|
||||
|
||||
$lid = $db->insert_id();
|
||||
$updatelog = array(
|
||||
"lid" => $lid,
|
||||
"user" => intval($log['user']),
|
||||
"log" => $loginsert,
|
||||
"dateline" => intval($log['dateline']),
|
||||
"ipaddress" => $log['ipaddress']
|
||||
);
|
||||
$db->insert_query("achivements_customlog", $updatelog);
|
||||
}
|
||||
|
||||
function getarchivements($uid)
|
||||
{
|
||||
global $db;
|
||||
$query = $db->query("SELECT * FROM `".TABLE_PREFIX."achivements` a LEFT JOIN `".TABLE_PREFIX."user_achivements` ua ON ua.`aid`=a.`id` WHERE ua.uid='".intval($uid)."'");
|
||||
while($row = $db->fetch_array($query)){
|
||||
$custom[] = $row;
|
||||
}
|
||||
$db->free_result($query);
|
||||
return $custom;
|
||||
}
|
||||
?>
|
BIN
forumplugins/plugins/achivements/include/images/achivements.png
Normal file
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 607 B |
BIN
forumplugins/plugins/achivements/include/images/custom.png
Normal file
After Width: | Height: | Size: 690 B |
BIN
forumplugins/plugins/achivements/include/images/extensions.png
Normal file
After Width: | Height: | Size: 591 B |
BIN
forumplugins/plugins/achivements/include/images/modcp.png
Normal file
After Width: | Height: | Size: 690 B |
BIN
forumplugins/plugins/achivements/include/images/posts.png
Normal file
After Width: | Height: | Size: 647 B |
BIN
forumplugins/plugins/achivements/include/images/regdate.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
forumplugins/plugins/achivements/include/images/reputation.png
Normal file
After Width: | Height: | Size: 669 B |
BIN
forumplugins/plugins/achivements/include/images/threads.png
Normal file
After Width: | Height: | Size: 709 B |
BIN
forumplugins/plugins/achivements/include/images/timeonline.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
592
forumplugins/plugins/achivements/include/install.php
Normal file
|
@ -0,0 +1,592 @@
|
|||
<?php
|
||||
|
||||
if(!defined("IN_MYBB"))
|
||||
{
|
||||
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
|
||||
}
|
||||
|
||||
function delete_images_unlink()
|
||||
{
|
||||
global $db;
|
||||
$query = $db->simple_select('achivements');
|
||||
$delete_images = array();
|
||||
while($achivement_img = $db->fetch_array($query))
|
||||
{
|
||||
$delete_images[] = @unlink(MYBB_ROOT.$achivement_img['image']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$tables[] = array('name' => 'achivements', 'insert' => "CREATE TABLE IF NOT EXISTS `".TABLE_PREFIX."achivements` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(50) NOT NULL DEFAULT '',
|
||||
`description` varchar(200) NOT NULL DEFAULT '',
|
||||
`type` enum('post','threads','rep','time','regdate','custom','archivements'),
|
||||
`requirement` int(11) NOT NULL DEFAULT 0,
|
||||
`requirement_unit` varchar(20) NOT NULL DEFAULT 0,
|
||||
`required_achivements` TEXT NOT NULL DEFAULT '',
|
||||
`requirement_text` TEXT NOT NULL DEFAULT '',
|
||||
`modcp` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`image` varchar(250) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM");
|
||||
|
||||
$tables[] = array('name' => 'user_achivements', 'insert' => "CREATE TABLE IF NOT EXISTS `".TABLE_PREFIX."user_achivements` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`uid` int(11) unsigned NOT NULL,
|
||||
`aid` int(11) unsigned NOT NULL,
|
||||
`showprofile` tinyint(1) unsigned NOT NULL DEFAULT 0,
|
||||
`showpostbit` tinyint(1) unsigned NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `uid` (`uid`),
|
||||
KEY `aid` (`aid`)
|
||||
) ENGINE=MyISAM");
|
||||
|
||||
$templates[] = array(
|
||||
"title" => 'achivements',
|
||||
"template" => $db->escape_string('<html>
|
||||
<head>
|
||||
<title>{$mybb->settings[\'bbname\']} - {$lang->achivements}</title>
|
||||
{$headerinclude}
|
||||
</head>
|
||||
<body>
|
||||
{$header}
|
||||
<table width="100%" border="0" align="center">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
|
||||
<tr>
|
||||
<td class="thead" colspan="4">
|
||||
<strong>{$lang->achivementsbyposts}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tcat" width="10%" align="center"><strong>{$lang->image}</strong></td>
|
||||
<td class="tcat" width="10%" align="center"><strong>{$lang->posts}</strong></td>
|
||||
<td class="tcat" width="20%"><strong>{$lang->name}</strong></td>
|
||||
<td class="tcat"><strong>{$lang->description}</strong></td>
|
||||
</tr>
|
||||
{$posts}
|
||||
</table>
|
||||
<br />
|
||||
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
|
||||
<tr>
|
||||
<td class="thead" colspan="4">
|
||||
<strong>{$lang->achivementsbythreads}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tcat" width="10%" align="center"><strong>{$lang->image}</strong></td>
|
||||
<td class="tcat" width="10%" align="center"><strong>{$lang->threads}</strong></td>
|
||||
<td class="tcat" width="20%"><strong>{$lang->name}</strong></td>
|
||||
<td class="tcat"><strong>{$lang->description}</strong></td>
|
||||
</tr>
|
||||
{$threads}
|
||||
</table>
|
||||
<br />
|
||||
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
|
||||
<tr>
|
||||
<td class="thead" colspan="4">
|
||||
<strong>{$lang->achivementsbyreputation}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tcat" width="10%" align="center"><strong>{$lang->image}</strong></td>
|
||||
<td class="tcat" width="10%" align="center"><strong>{$lang->reputation}</strong></td>
|
||||
<td class="tcat" width="20%"><strong>{$lang->name}</strong></td>
|
||||
<td class="tcat"><strong>{$lang->description}</strong></td>
|
||||
</tr>
|
||||
{$reputation}
|
||||
</table>
|
||||
<br />
|
||||
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
|
||||
<tr>
|
||||
<td class="thead" colspan="4">
|
||||
<strong>{$lang->achivementsbytimeonline}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tcat" width="10%" align="center"><strong>{$lang->image}</strong></td>
|
||||
<td class="tcat" width="15%" align="center"><strong>{$lang->timeonline}</strong></td>
|
||||
<td class="tcat" width="20%"><strong>{$lang->name}</strong></td>
|
||||
<td class="tcat"><strong>{$lang->description}</strong></td>
|
||||
</tr>
|
||||
{$timeonline}
|
||||
</table>
|
||||
<br />
|
||||
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
|
||||
<tr>
|
||||
<td class="thead" colspan="4">
|
||||
<strong>{$lang->achivementsbyregdate}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tcat" width="10%" align="center"><strong>{$lang->image}</strong></td>
|
||||
<td class="tcat" width="15%" align="center"><strong>{$lang->regdate}</strong></td>
|
||||
<td class="tcat" width="20%"><strong>{$lang->name}</strong></td>
|
||||
<td class="tcat"><strong>{$lang->description}</strong></td>
|
||||
</tr>
|
||||
{$regdate}
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
|
||||
<tr>
|
||||
<td class="thead" colspan="4">
|
||||
<strong>{$lang->achivementscustom}</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tcat" width="10%" align="center"><strong>{$lang->image}</strong></td>
|
||||
<td class="tcat" width="15%" align="center"><strong>{$lang->requirement}</strong></td>
|
||||
<td class="tcat" width="20%"><strong>{$lang->name}</strong></td>
|
||||
<td class="tcat"><strong>{$lang->description}</strong></td>
|
||||
</tr>
|
||||
{$custom}
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{$footer}
|
||||
</body>
|
||||
</html>'),
|
||||
"sid" => -1,
|
||||
"version" => 1604,
|
||||
"dateline" => TIME_NOW,
|
||||
);
|
||||
|
||||
$templates[] = array(
|
||||
"title" => 'achivements_empty',
|
||||
"template" => $db->escape_string('<tr><td class="trow1" colspan="4" align="center">{$lang->achiviementstableempty}</td></tr>'),
|
||||
"sid" => -1,
|
||||
"version" => 1604,
|
||||
"dateline" => TIME_NOW,
|
||||
);
|
||||
|
||||
$templates[] = array(
|
||||
"title" => 'achivements_list',
|
||||
"template" => $db->escape_string('<tr>
|
||||
<td class="{$color}" width="10%" align="center"><img src="{$achivements[\'image\']}" /></td>
|
||||
<td class="{$color}" width="10%" align="center">{$achivements[\'value\']}</td>
|
||||
<td class="{$color}" width="20%">{$achivements[\'name\']}</td>
|
||||
<td class="{$color}">{$achivements[\'description\']}</td>
|
||||
</tr>'),
|
||||
"sid" => -1,
|
||||
"version" => 1604,
|
||||
"dateline" => TIME_NOW,
|
||||
);
|
||||
|
||||
$templates[] = array(
|
||||
"title" => 'achivements_profile',
|
||||
"template" => $db->escape_string('<br />
|
||||
<table id="achivements" border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
|
||||
<tr>
|
||||
<td class="thead"><strong>{$lang->achsmemprofile}</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="trow1">
|
||||
{$achivements}
|
||||
</td>
|
||||
</tr>
|
||||
</table>'),
|
||||
"sid" => -1,
|
||||
"version" => 1604,
|
||||
"dateline" => TIME_NOW,
|
||||
);
|
||||
|
||||
$templates[] = array(
|
||||
"title" => 'achivements_postbit',
|
||||
"template" => $db->escape_string('{$lang->achivements}: {$achivements}'),
|
||||
"sid" => -1,
|
||||
"version" => 1604,
|
||||
"dateline" => TIME_NOW,
|
||||
);
|
||||
|
||||
//add templates v2.1
|
||||
$templates[] = array(
|
||||
"title" => 'achivements_usercp',
|
||||
"template" => $db->escape_string('<html>
|
||||
<head>
|
||||
<title>{$mybb->settings[\'bbname\']} - {$lang->achivements}</title>
|
||||
{$headerinclude}
|
||||
|
||||
<script languaje="javascript">
|
||||
function select_all_achivements(){
|
||||
for (i=0;i<document.achivements_form.elements.length;i++)
|
||||
if(document.achivements_form.elements[i].type == "checkbox")
|
||||
document.achivements_form.elements[i].checked=1
|
||||
}
|
||||
function unselect_all_achivements(){
|
||||
for (i=0;i<document.achivements_form.elements.length;i++)
|
||||
if(document.achivements_form.elements[i].type == "checkbox")
|
||||
document.achivements_form.elements[i].checked=0
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
{$header}
|
||||
<form method="post" name="achivements_form" enctype="multipart/form-data" action="usercp.php">
|
||||
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
|
||||
<table width="100%" border="0" align="center">
|
||||
<tr>
|
||||
{$usercpnav}
|
||||
<td valign="top">
|
||||
{$errors}
|
||||
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
|
||||
<tr>
|
||||
<td class="thead"><strong>{$lang->achivements}</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tcat"><strong>{$lang->achivementscurrentprofile}</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="trow1">{$currentachivements}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tcat"><strong>{$lang->achivementscurrentpostbit}</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="trow1">{$currentachivementspostbit}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tcat"><strong>{$lang->myachivements}</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="trow2">
|
||||
<a href="javascript:select_all_achivements()"><small>{$lang->markall}</small></a> |
|
||||
<a href="javascript:unselect_all_achivements()"><small>{$lang->marknone}</small></a><br />
|
||||
{$achivements}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<div align="center">
|
||||
<input type="hidden" name="action" value="do_achivements" />
|
||||
<input type="submit" class="button" name="profile" value="{$lang->showinprofile}" />
|
||||
<input type="submit" class="button" name="postbit" value="{$lang->showinpostbit}" />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
{$footer}
|
||||
</body>
|
||||
</html>'),
|
||||
"sid" => -1,
|
||||
"version" => 1604,
|
||||
"dateline" => TIME_NOW,
|
||||
);
|
||||
|
||||
$templates[] = array(
|
||||
"title" => 'achivements_usercp_all',
|
||||
"template" => $db->escape_string('<label for="{$ach[\'name\']}"><input type="checkbox" name="showachivement[]" value="{$ach[\'id\']}" /> {$achivement}</label>'),
|
||||
"sid" => -1,
|
||||
"version" => 1604,
|
||||
"dateline" => TIME_NOW,
|
||||
);
|
||||
|
||||
$templates[] = array(
|
||||
"title" => 'achivements_modcp',
|
||||
"template" => $db->escape_string('<html>
|
||||
<head>
|
||||
<title>{$mybb->settings[\'bbname\']} - {$lang->achivements}</title>
|
||||
{$headerinclude}
|
||||
</head>
|
||||
<body>
|
||||
{$header}
|
||||
<table width="100%" border="0" align="center">
|
||||
<tr>
|
||||
{$modcp_nav}
|
||||
<td valign="top">
|
||||
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
|
||||
<tr>
|
||||
<td class="thead" colspan="4"><strong>{$lang->custom_modules}</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tcat" width="10%" align="center"><span class="smalltext"><strong>{$lang->image}</strong></span>
|
||||
<td class="tcat"><span class="smalltext"><strong>{$lang->namedescription}</strong></span>
|
||||
<td class="tcat" width="20%" align="center" colspan="2"><span class="smalltext"><strong>{$lang->option}</strong></span>
|
||||
</td>
|
||||
<tr>
|
||||
{$custom_achivements}
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{$footer}
|
||||
</body>
|
||||
</html>'),
|
||||
"sid" => -1,
|
||||
"version" => 1604,
|
||||
"dateline" => TIME_NOW,
|
||||
);
|
||||
|
||||
$templates[] = array(
|
||||
"title" => 'achivements_modcp_give',
|
||||
"template" => $db->escape_string('<html>
|
||||
<head>
|
||||
<title>{$mybb->settings[\'bbname\']} - {$lang->giveachivements}</title>
|
||||
{$headerinclude}
|
||||
</head>
|
||||
<body>
|
||||
{$header}
|
||||
<table width="100%" border="0" align="center">
|
||||
<tr>
|
||||
{$modcp_nav}
|
||||
<td valign="top">
|
||||
<form action="modcp.php?action=achivements" method="post">
|
||||
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
|
||||
<input type="hidden" name="mod" value="{$mybb->input[\'mod\']}" />
|
||||
<input type="hidden" name="id" value="{$mybb->input[\'id\']}" />
|
||||
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
|
||||
<tr>
|
||||
<td class="thead" colspan="2"><strong>{$lang->giveuserform}</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="trow1"><strong>{$lang->user}</strong>:</td>
|
||||
<td class="trow2"><input type="text" class="textbox" id="username" name="username" size="40" maxlength="85" tabindex="1" /></td>
|
||||
</table>
|
||||
<br />
|
||||
<div style="text-align:center"><input type="submit" class="button" name="submit" value="{$lang->giveachivements}"/></div>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{$footer}
|
||||
<script type="text/javascript" src="jscripts/autocomplete.js?ver=1400"></script>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
if(use_xmlhttprequest == "1")
|
||||
{
|
||||
new autoComplete("username", "xmlhttp.php?action=get_users", {valueSpan: "username"});
|
||||
}
|
||||
// -->
|
||||
</script>
|
||||
</body>
|
||||
</html>'),
|
||||
"sid" => -1,
|
||||
"version" => 1604,
|
||||
"dateline" => TIME_NOW,
|
||||
);
|
||||
|
||||
$templates[] = array(
|
||||
"title" => 'achivements_modcp_quit',
|
||||
"template" => $db->escape_string('<html>
|
||||
<head>
|
||||
<title>{$mybb->settings[\'bbname\']} - {$lang->quitachivement}</title>
|
||||
{$headerinclude}
|
||||
</head>
|
||||
<body>
|
||||
{$header}
|
||||
<table width="100%" border="0" align="center">
|
||||
<tr>
|
||||
{$modcp_nav}
|
||||
<td valign="top">
|
||||
<form action="modcp.php?action=achivements" method="post">
|
||||
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
|
||||
<input type="hidden" name="mod" value="{$mybb->input[\'mod\']}" />
|
||||
<input type="hidden" name="acid" value="{$mybb->input[\'acid\']}" />
|
||||
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
|
||||
<tr>
|
||||
<td class="thead" colspan="2"><strong>{$lang->quitcustom}</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="trow1"><strong>{$lang->user}</strong>:</td>
|
||||
<td class="trow2"><input type="text" class="textbox" id="username" name="username" size="40" maxlength="85" tabindex="1" /></td>
|
||||
</table>
|
||||
<br />
|
||||
<div style="text-align:center"><input type="submit" class="button" name="submit" value="{$lang->quitachivement}"/></div>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{$footer}
|
||||
<script type="text/javascript" src="jscripts/autocomplete.js?ver=1400"></script>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
if(use_xmlhttprequest == "1")
|
||||
{
|
||||
new autoComplete("username", "xmlhttp.php?action=get_users", {valueSpan: "username"});
|
||||
}
|
||||
// -->
|
||||
</script>
|
||||
</body>
|
||||
</html>'),
|
||||
"sid" => -1,
|
||||
"version" => 1604,
|
||||
"dateline" => TIME_NOW,
|
||||
);
|
||||
|
||||
$templates[] = array(
|
||||
"title" => 'achivements_modcp_nav',
|
||||
"template" => $db->escape_string('<tr>
|
||||
<td class="trow1 smalltext">
|
||||
<a href="modcp.php?action=achivements" style="display: block;padding: 1px 0 1px 23px;background: url(inc/plugins/achivements/include/images/modcp.png) no-repeat left center;">{$lang->custom_modules}</a></td>
|
||||
</tr>'),
|
||||
"sid" => -1,
|
||||
"version" => 1604,
|
||||
"dateline" => TIME_NOW,
|
||||
);
|
||||
|
||||
$templates[] = array(
|
||||
"title" => 'achivements_modcp_list',
|
||||
"template" => $db->escape_string('<tr>
|
||||
<td class="{$trow}" align="center"><img src="{$custom[\'image\']}" title="{$custom[\'name\']}" /></td>
|
||||
<td class="{$trow}"><strong>{$custom[\'name\']}</strong><br /><span class="smalltext">{$custom[\'reason\']}</span></td>
|
||||
<td class="{$trow}" width="10%" align="center"><a href="modcp.php?action=achivements&mod=give&id={$custom[\'id\']}" />{$lang->give}</a></td>
|
||||
<td class="{$trow}" width="10%" align="center"><a href="modcp.php?action=achivements&mod=quit&id={$custom[\'id\']}" />{$lang->quit}</a></td>
|
||||
</tr>'),
|
||||
"sid" => -1,
|
||||
"version" => 1604,
|
||||
"dateline" => TIME_NOW,
|
||||
);
|
||||
|
||||
$fields[] = array('table' => 'users', 'column' => 'threads', 'insert' => 'int(11) unsigned NOT NULL default \'0\'');
|
||||
|
||||
function settings_insert()
|
||||
{
|
||||
global $lang;
|
||||
$lang->load('achivements');
|
||||
$settings_achivements[] = array(
|
||||
"name" => "achivements_enable",
|
||||
"title" => $lang->enable,
|
||||
"description" => $lang->enable_des,
|
||||
"optionscode" => "yesno",
|
||||
"value" => "1",
|
||||
"disporder" => 1,
|
||||
"gid" => 0
|
||||
);
|
||||
$settings_achivements[] = array(
|
||||
"name" => "achivements_showachvprofile",
|
||||
"title" => $lang->showachvprofile,
|
||||
"description" => $lang->showachvprofiledes,
|
||||
"optionscode" => "yesno",
|
||||
"value" => "1",
|
||||
"disporder" => 2,
|
||||
"gid" => 0
|
||||
);
|
||||
$settings_achivements[] = array(
|
||||
"name" => "achivements_showachvpostbit",
|
||||
"title" => $lang->showachvpostbit,
|
||||
"description" => $lang->showachvpostbitdes,
|
||||
"optionscode" => "yesno",
|
||||
"value" => "1",
|
||||
"disporder" => 3,
|
||||
"gid" => 0
|
||||
);
|
||||
$settings_achivements[] = array(
|
||||
"name" => "achivements_sendmp",
|
||||
"title" => $lang->sendmpachivements,
|
||||
"description" => $lang->sendmpachivements_des,
|
||||
"optionscode" => "textarea",
|
||||
"value" => "",
|
||||
"disporder" => 4,
|
||||
"gid" => 0
|
||||
);
|
||||
$settings_achivements[] = array(
|
||||
"name" => "achivements_subjectmp",
|
||||
"title" => $lang->titlemp,
|
||||
"description" => $lang->titlempdes,
|
||||
"optionscode" => "textarea",
|
||||
"value" => $lang->subjectvalue,
|
||||
"disporder" => 5,
|
||||
"gid" => 0
|
||||
);
|
||||
$settings_achivements[] = array(
|
||||
"name" => "achivements_bodymp",
|
||||
"title" => $lang->bodymp,
|
||||
"description" => $lang->bodympdes,
|
||||
"optionscode" => "textarea",
|
||||
"value" => $lang->bodyvalue,
|
||||
"disporder" => 6,
|
||||
"gid" => 0
|
||||
);
|
||||
$settings_achivements[] = array(
|
||||
"name" => "achivements_usermp",
|
||||
"title" => $lang->user,
|
||||
"description" => $lang->usersendmp,
|
||||
"optionscode" => "text",
|
||||
"value" => "1",
|
||||
"disporder" => 7,
|
||||
"gid" => 0
|
||||
);
|
||||
$settings_achivements[] = array(
|
||||
"name" => "achivements_rebuild",
|
||||
"title" => $lang->rebuild,
|
||||
"description" => $lang->rebuild,
|
||||
"optionscode" => "yesno",
|
||||
"value" => "0",
|
||||
"disporder" => 8,
|
||||
"gid" => 0
|
||||
);
|
||||
$settings_achivements[] = array(
|
||||
"name" => "achivements_maxpostbit",
|
||||
"title" => $lang->maxpostbit,
|
||||
"description" => $lang->maxpostbitdes,
|
||||
"optionscode" => "text",
|
||||
"value" => "15",
|
||||
"disporder" => 9,
|
||||
"gid" => 0
|
||||
);
|
||||
$settings_achivements[] = array(
|
||||
"name" => "achivements_taskuseroffline",
|
||||
"title" => $lang->taskoffline,
|
||||
"description" => $lang->taskofflinedes,
|
||||
"optionscode" => "yesno",
|
||||
"value" => "1",
|
||||
"disporder" => 10,
|
||||
"gid" => 0
|
||||
);
|
||||
$settings_achivements[] = array(
|
||||
"name" => "achivements_modcp",
|
||||
"title" => $lang->canmodcpachs,
|
||||
"description" => $lang->canmodcpachsdes,
|
||||
"optionscode" => "yesno",
|
||||
"value" => "1",
|
||||
"disporder" => 11,
|
||||
"gid" => 0
|
||||
);
|
||||
$settings_achivements[] = array(
|
||||
"name" => "achivements_showonlycurrent",
|
||||
"title" => $lang->showonlycurrent,
|
||||
"description" => $lang->showonlycurrentdes,
|
||||
"optionscode" => "yesno",
|
||||
"value" => "1",
|
||||
"disporder" => 12,
|
||||
"gid" => 0
|
||||
);
|
||||
return $settings_achivements;
|
||||
}
|
||||
|
||||
function count_threads_update()
|
||||
{
|
||||
global $db;
|
||||
$query = $db->simple_select("users", "uid");
|
||||
while($user = $db->fetch_array($query))
|
||||
{
|
||||
$users[$user['uid']] = $user;
|
||||
}
|
||||
foreach($users as $user)
|
||||
{
|
||||
$query = $db->simple_select("threads", "COUNT(tid) AS threads", "uid = '".$user['uid']."'");
|
||||
$threads_count = intval($db->fetch_field($query, "threads"));
|
||||
$db->update_query("users", array("threads" => $threads_count), "uid = '".$user['uid']."'");
|
||||
}
|
||||
}
|
||||
|
||||
function create_task_tools()
|
||||
{
|
||||
global $db, $lang;
|
||||
$lang->load('achivements');
|
||||
$new_task_achivements = array(
|
||||
"title" => "Achivements",
|
||||
"description" => $lang->desctaks,
|
||||
"file" => "achivements",
|
||||
"minute" => '0',
|
||||
"hour" => '0',
|
||||
"day" => '*',
|
||||
"month" => '*',
|
||||
"weekday" => '*',
|
||||
"nextrun" => TIME_NOW + (1*24*60*60),
|
||||
"enabled" => '0',
|
||||
"logging" => '1'
|
||||
);
|
||||
$db->insert_query("tasks", $new_task_achivements);
|
||||
}
|
||||
?>
|
107
forumplugins/plugins/achivements/include/mp.php
Normal file
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* MyBB 1.6
|
||||
* Copyright 2012 MyBB-Es Team, All Rights Reserved
|
||||
*
|
||||
* Website: http://www.mybb-es.com.com
|
||||
*
|
||||
* $Id: mp.php 2012-05-27 10:58Z EdsonOrdaz $
|
||||
*/
|
||||
|
||||
if(!defined("IN_MYBB"))
|
||||
{
|
||||
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
|
||||
}
|
||||
|
||||
function get_achivement($table, $id)
|
||||
{
|
||||
global $db;
|
||||
$query = $db->simple_select('achivements_'.$table, '*', $id);
|
||||
$achivement = $db->fetch_array($query);
|
||||
$read = array(
|
||||
"name" => $achivement['name'],
|
||||
"image" => $achivement['image'],
|
||||
"description" => $achivement['description'],
|
||||
"reason" => $achivement['reason']
|
||||
);
|
||||
return $read;
|
||||
}
|
||||
|
||||
function send_mp_achivement_new($uid, $table, $id)
|
||||
{
|
||||
global $mybb;
|
||||
require_once MYBB_ROOT."inc/datahandlers/pm.php";
|
||||
$pmhandler = new PMDataHandler();
|
||||
$user = get_user($uid);
|
||||
switch($table)
|
||||
{
|
||||
case 'posts':
|
||||
$achivement = get_achivement('posts', "apid='".$id."'");
|
||||
break;
|
||||
|
||||
case 'threads':
|
||||
$achivement = get_achivement('threads', "atid='".$id."'");
|
||||
break;
|
||||
|
||||
case 'reputation':
|
||||
$achivement = get_achivement('reputation', "arid='".$id."'");
|
||||
break;
|
||||
|
||||
case 'timeonline':
|
||||
$achivement = get_achivement('timeonline', "toid='".$id."'");
|
||||
break;
|
||||
|
||||
case 'regdate':
|
||||
$achivement = get_achivement('regdate', "rgid='".$id."'");
|
||||
break;
|
||||
|
||||
case 'custom':
|
||||
$achivement = get_achivement('custom', "acid='".$id."'");
|
||||
break;
|
||||
|
||||
case 'achivement':
|
||||
$achivement = get_achivement('achivement', "aaid='".$id."'");
|
||||
break;
|
||||
}
|
||||
$message = $mybb->settings['achivements_bodymp'];
|
||||
$message = str_replace('{user}', $user['username'], $message);
|
||||
$message = str_replace('{bburl}', $mybb->settings['bburl'], $message);
|
||||
$message = str_replace('{bbname}', $mybb->settings['bbname'], $message);
|
||||
$message = str_replace('{name}', $achivement['name'], $message);
|
||||
if($table == 'custom')
|
||||
{
|
||||
$message = str_replace('{description}', $achivement['reason'], $message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = str_replace('{description}', $achivement['description'], $message);
|
||||
}
|
||||
$message = str_replace('{image}', "[img]".$mybb->settings['bburl']."/".$achivement['image']."[/img]", $message);
|
||||
|
||||
$pm = array(
|
||||
"subject" => $mybb->settings['achivements_subjectmp'],
|
||||
"message" => $message,
|
||||
"icon" => -1,
|
||||
"fromid" => intval($mybb->settings['achivements_usermp']),
|
||||
"toid" => array($user['uid']),
|
||||
"do" => '',
|
||||
"pmid" => ''
|
||||
);
|
||||
$pm['options'] = array(
|
||||
"signature" => 1,
|
||||
"disablesmilies" => 0,
|
||||
"savecopy" => 0,
|
||||
"readreceipt" => 0
|
||||
);
|
||||
$pm['saveasdraft'] = 0;
|
||||
$pmhandler->admin_override = 1;
|
||||
$pmhandler->set_data($pm);
|
||||
if($pmhandler->validate_pm())
|
||||
{
|
||||
$pmhandler->insert_pm();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
132
forumplugins/plugins/achivements/include/plugin.php
Normal file
|
@ -0,0 +1,132 @@
|
|||
<?php
|
||||
|
||||
|
||||
|
||||
|
||||
if(!defined("IN_MYBB"))
|
||||
{
|
||||
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
|
||||
}
|
||||
|
||||
function achivements_init_info()
|
||||
{
|
||||
global $lang;
|
||||
$lang->load('achivements');
|
||||
return array(
|
||||
"name" => "Achivements",
|
||||
"description" => $lang->achivements_description,
|
||||
"website" => "http://coppertopia.net/",
|
||||
"author" => "genuine",
|
||||
"version" => "1.0",
|
||||
"compatibility" => "16*",
|
||||
);
|
||||
}
|
||||
|
||||
function achivements_init_is_installed()
|
||||
{
|
||||
global $db;
|
||||
if ($db->table_exists('achivements') && $db->table_exists('user_achivements'))
|
||||
{
|
||||
$return = true;
|
||||
}else{
|
||||
$return = false;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
function achivements_init_install()
|
||||
{
|
||||
global $db, $cache;
|
||||
require_once MYBB_ROOT."inc/plugins/achivements/include/install.php";
|
||||
$collation = $db->build_create_table_collation();
|
||||
foreach($tables as $table){
|
||||
if(!$db->table_exists($table['name']))
|
||||
{
|
||||
$db->query($table['insert'].$collation);
|
||||
}
|
||||
}
|
||||
foreach($fields as $field)
|
||||
{
|
||||
if(!$db->field_exists($field['column'], $field['table']))
|
||||
{
|
||||
$db->add_column($field['table'], $field['column'], $field['insert']);
|
||||
}
|
||||
}
|
||||
count_threads_update();
|
||||
if(file_exists(MYBB_ROOT."inc/tasks/achivements.php"))
|
||||
{
|
||||
create_task_tools();
|
||||
}
|
||||
foreach(settings_insert() as $installsettings)
|
||||
{
|
||||
$db->insert_query("settings", $installsettings);
|
||||
}
|
||||
foreach($templates as $template)
|
||||
{
|
||||
$db->insert_query("templates", $template);
|
||||
}
|
||||
rebuildsettings();
|
||||
|
||||
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
|
||||
find_replace_templatesets('member_profile', '#{\$profilefields}#', '{\$profilefields}<!-- Profile_achivements -->{\$achivementsprofile}<!-- /Profile_achivements -->');
|
||||
find_replace_templatesets('usercp_nav_profile', '#{\$changesigop}#', '{\$changesigop}<!-- usercp_achivements --><div><a href="usercp.php?action=achivements" class="usercp_nav_item" style="padding-left: 40px;background: url(inc/plugins/achivements/include/images/achivements_usercp.png) no-repeat left center;">Achivements</a></div><!-- /usercp_achivements -->');
|
||||
find_replace_templatesets('modcp_nav', '#{\$lang->mcp_nav_editprofile}</a></td></tr>#', '{\$lang->mcp_nav_editprofile}</a></td></tr><!--modcp_achivements-->');
|
||||
find_replace_templatesets('postbit', '#'.preg_quote('{$post[\'user_details\']}').'#', "{\$post['user_details']}<!-- postbit_achivements -->{\$post['achivementspostbit']}<!-- /postbit_achivements -->");
|
||||
find_replace_templatesets('postbit_classic', '#'.preg_quote('{$post[\'user_details\']}').'#', "{\$post['user_details']}<!-- postbit_achivements -->{\$post['achivementspostbit']}<!-- /postbit_achivements -->");
|
||||
|
||||
change_admin_permission("achivements", true, 1);
|
||||
change_admin_permission("achivements", "posts", 0);
|
||||
change_admin_permission("achivements", "threads", 0);
|
||||
change_admin_permission("achivements", "reputation", 0);
|
||||
change_admin_permission("achivements", "timeonline", 0);
|
||||
change_admin_permission("achivements", "regdate", 0);
|
||||
change_admin_permission("achivements", "custom", 0);
|
||||
change_admin_permission("achivements", "achivements", 0);
|
||||
change_admin_permission("achivements", "settings", 0);
|
||||
change_admin_permission("achivements", "extensions", 0);
|
||||
change_admin_permission("achivements", "config", 0);
|
||||
}
|
||||
|
||||
function achivements_init_uninstall()
|
||||
{
|
||||
global $db, $cache;
|
||||
require_once MYBB_ROOT."inc/plugins/achivements/include/install.php";
|
||||
delete_images_unlink();
|
||||
foreach($tables as $table){
|
||||
if($db->table_exists($table['name']))
|
||||
{
|
||||
$db->drop_table($table['name']);
|
||||
}
|
||||
}
|
||||
foreach($fields as $field)
|
||||
{
|
||||
if($db->field_exists($field['column'], $field['table']))
|
||||
{
|
||||
$db->drop_column($field['table'], $field['column']);
|
||||
}
|
||||
}
|
||||
$db->delete_query('tasks', 'file=\'achivements\'');
|
||||
$db->delete_query("settings","name LIKE 'achivements_%'");
|
||||
$db->delete_query("templates","title LIKE 'achivements%'");
|
||||
rebuildsettings();
|
||||
|
||||
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
|
||||
find_replace_templatesets('member_profile', '#\<!--\sProfile_achivements\s--\>(.+)\<!--\s/Profile_achivements\s--\>#is', '', 0);
|
||||
find_replace_templatesets('usercp_nav_profile', '#\<!--\susercp_achivements\s--\>(.+)\<!--\s/usercp_achivements\s--\>#is', '', 0);
|
||||
find_replace_templatesets('modcp_nav', '#\<!--modcp_achivements-->#is', '', 0);
|
||||
find_replace_templatesets('postbit', '#\<!--\spostbit_achivements\s--\>(.+)\<!--\s/postbit_achivements\s--\>#is', '', 0);
|
||||
find_replace_templatesets('postbit_classic', '#\<!--\spostbit_achivements\s--\>(.+)\<!--\s/postbit_achivements\s--\>#is', '', 0);
|
||||
|
||||
change_admin_permission("achivements", false, -1);
|
||||
change_admin_permission("achivements", "posts", -1);
|
||||
change_admin_permission("achivements", "threads", -1);
|
||||
change_admin_permission("achivements", "reputation", -1);
|
||||
change_admin_permission("achivements", "timeonline", -1);
|
||||
change_admin_permission("achivements", "regdate", -1);
|
||||
change_admin_permission("achivements", "custom", -1);
|
||||
change_admin_permission("achivements", "achivements", -1);
|
||||
change_admin_permission("achivements", "settings", -1);
|
||||
change_admin_permission("achivements", "extensions", -1);
|
||||
change_admin_permission("achivements", "config", -1);
|
||||
}
|
||||
?>
|