} } if ($mybb->input['action'] == "del") { if ($mybb->settings[$prefix . 'removing'] != "1") { error($lang->sprintf($lang->tyl_error_removal_disabled, $pre)); } // Check tyl owner and tyl exists $options = array("limit" => 1); $query_r = $db->simple_select($prefix . "thankyoulike", "*", "pid='" . $pid . "' AND uid='" . $mybb->user['uid'] . "'", $options); $tyl_r = $db->fetch_array($query_r); if (isset($tyl_r['tlid'])) { if ($tyl_r['uid'] == $mybb->user['uid']) { // process delete $db->delete_query($prefix . "thankyoulike", "tlid='" . $tyl_r['tlid'] . "'", "1"); // if alert of user was added and unread then review if delete thanks and delete alert too. if (function_exists('myalerts_is_activated') && myalerts_is_activated() && $mybb->user['uid']) { $db->query("DELETE FROM " . TABLE_PREFIX . "alerts WHERE from_user_id={$mybb->user['uid']} AND object_id='{$pid}' AND unread=1 LIMIT 1"); } // Update counts if ($post['tyl_pnumtyls'] == 1) { // This was the last thanks in the post, so remove this post from user's thanked posts $db->write_query("UPDATE " . TABLE_PREFIX . "users SET tyl_unumptyls=tyl_unumptyls-1 WHERE uid='" . intval($post['uid']) . "'"); } $db->write_query("UPDATE " . TABLE_PREFIX . "posts SET tyl_pnumtyls=tyl_pnumtyls-1 WHERE pid='" . intval($pid) . "'"); $db->write_query("UPDATE " . TABLE_PREFIX . "threads SET tyl_tnumtyls=tyl_tnumtyls-1 WHERE tid='" . intval($tid) . "'"); $db->write_query("UPDATE " . TABLE_PREFIX . "users SET tyl_unumtyls=tyl_unumtyls-1 WHERE uid='" . intval($mybb->user['uid']) . "'"); $db->write_query("UPDATE " . TABLE_PREFIX . "users SET tyl_unumrcvtyls=tyl_unumrcvtyls-1 WHERE uid='" . intval($post['uid']) . "'"); $db->write_query("UPDATE " . TABLE_PREFIX . $prefix . "stats SET value=value-1 WHERE title='total'"); if ($mybb->input['ajax']) { // Do nothing here } else {
function thankyoulike_templatelist() { global $mybb, $cache, $lang, $code, $templatelist; $codename = basename(__FILE__, ".php"); $prefix = 'g33k_' . $codename . '_'; if ($mybb->settings[$prefix . 'enabled'] == "1") { $lang->load('thankyoulike', false, true); if ($mybb->settings[$prefix . 'thankslike'] == "like") { $lang->tyl_send = $lang->tyl_send_like; $lang->tyl_remove = $lang->tyl_remove_like; $lang->tyl_alert = $lang->tyl_alert_like; $lang->myalerts_setting_tyl = $lang->myalerts_setting_tyl_like; } else { if ($mybb->settings[$prefix . 'thankslike'] == "thanks") { $lang->tyl_send = $lang->tyl_send_thanks; $lang->tyl_remove = $lang->tyl_remove_thanks; $lang->tyl_alert = $lang->tyl_alert_thanks; $lang->myalerts_setting_tyl = $lang->myalerts_setting_tyl_thanks; } } // Registering alert formatter if (function_exists('myalerts_is_activated') && myalerts_is_activated() && $mybb->user['uid']) { global $cache, $formatterManager; tyl_myalerts_formatter_load(); // Load cache data and compare if version is the same or not $myalerts_plugins = $cache->read('mybbstuff_myalerts_alert_types'); if ($myalerts_plugins['tyl']['code'] == 'tyl' && $myalerts_plugins['tyl']['enabled'] == 1) { if (class_exists('MybbStuff_MyAlerts_AlertFormatterManager') && class_exists('ThankyouAlertFormatter')) { $code = 'tyl'; $formatterManager = MybbStuff_MyAlerts_AlertFormatterManager::getInstance(); $formatterManager->registerFormatter(new ThankyouAlertFormatter($mybb, $lang, $code)); } } } $template_list = ''; if (THIS_SCRIPT == 'showthread.php') { $template_list = "thankyoulike_users,thankyoulike_postbit,thankyoulike,thankyoulike_classic,thankyoulike_expcollapse,thankyoulike_button_add,thankyoulike_button_del"; } if (THIS_SCRIPT == 'member.php') { $template_list = "thankyoulike_memprofile"; } if (THIS_SCRIPT == 'announcements.php') { $template_list = "thankyoulike_postbit"; } if (THIS_SCRIPT == 'private.php') { $template_list = "thankyoulike_postbit"; } if (isset($templatelist)) { $templatelist .= "," . $template_list; } else { $templatelist = $template_list; } } }