Advertisement
Guest User

Untitled

a guest
May 15th, 2017
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 48.52 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <hookexport>
  3. <hookdata>
  4. <config>
  5. <hook_name><![CDATA[[EN34] Ajax Thanks]]></hook_name>
  6. <hook_desc>This hook adds the ability for members to thank posters via Ajax.</hook_desc>
  7. <hook_author>Elad Nava</hook_author>
  8. <hook_email>eladnava@gmail.com</hook_email>
  9. <hook_website>http://invisionize.com/</hook_website>
  10. <hook_update_check>http://eladnava.com/hooks.php?hook=ajaxthanks</hook_update_check>
  11. <hook_requirements><![CDATA[a:3:{s:21:"required_applications";a:0:{}s:20:"hook_php_version_min";s:1:"0";s:20:"hook_php_version_max";s:1:"0";}]]></hook_requirements>
  12. <hook_version_human>1.0.8</hook_version_human>
  13. <hook_version_long>10008</hook_version_long>
  14. <hook_extra_data><![CDATA[a:7:{s:7:"display";a:5:{s:8:"settings";s:35:"Setting groups: [EN34] Ajax Thanks";s:8:"language";s:180:"From forums_public_topic: en30_show, en30_thank, en30_thanked, en30_thanked_by, en30_thanks, en30_thank_author, en30_times, en30_unthank, en30_unthank_author, en30_user, en30_users";s:8:"database";s:105:"ALTER TABLE profile_portal ADD thanked int(10) DEFAULT '0'<br />ALTER TABLE posts ADD thankers mediumtext";s:6:"custom";s:22:"install_ajaxThanks.php";s:9:"templates";s:125:"From skin_topic: ajaxThankedCount, ajaxThankedCountProfile, ajaxThankerLink, ajaxThankersList, ajaxThanksButton, ajaxThanksJS";}s:13:"settingGroups";a:1:{s:0:"";s:15:"en30_ajaxthanks";}s:8:"settings";a:0:{}s:8:"language";a:1:{s:19:"forums_public_topic";a:11:{s:0:"";s:9:"en30_show";i:1;s:10:"en30_thank";i:2;s:12:"en30_thanked";i:3;s:15:"en30_thanked_by";i:4;s:11:"en30_thanks";i:5;s:17:"en30_thank_author";i:6;s:10:"en30_times";i:7;s:12:"en30_unthank";i:8;s:19:"en30_unthank_author";i:9;s:9:"en30_user";i:10;s:10:"en30_users";}}s:9:"templates";a:1:{s:10:"skin_topic";a:6:{s:0:"";s:16:"ajaxThankedCount";i:1;s:23:"ajaxThankedCountProfile";i:2;s:15:"ajaxThankerLink";i:3;s:16:"ajaxThankersList";i:4;s:16:"ajaxThanksButton";i:5;s:12:"ajaxThanksJS";}}s:8:"database";a:1:{s:5:"alter";a:2:{i:0;a:6:{s:9:"altertype";s:3:"add";s:5:"table";s:14:"profile_portal";s:5:"field";s:7:"thanked";s:8:"newfield";s:0:"";s:9:"fieldtype";s:7:"int(10)";s:7:"default";s:3:"'0'";}i:1;a:6:{s:9:"altertype";s:3:"add";s:5:"table";s:5:"posts";s:5:"field";s:8:"thankers";s:8:"newfield";s:0:"";s:9:"fieldtype";s:10:"mediumtext";s:7:"default";s:0:"";}}}s:6:"custom";s:14:"ajaxThanks.php";}]]></hook_extra_data>
  15. <hook_key>en30_ajaxthanks</hook_key>
  16. <hook_global_caches/>
  17. </config>
  18. </hookdata>
  19. <hookfiles>
  20. <file>
  21. <hook_file_real>ajaxThanksJS.php</hook_file_real>
  22. <hook_type>templateHooks</hook_type>
  23. <hook_classname>ajaxThanksJS</hook_classname>
  24. <hook_data><![CDATA[a:8:{s:12:"dataLocation";s:0:"";s:14:"libApplication";s:0:"";s:15:"classToOverload";s:0:"";s:9:"skinGroup";s:11:"skin_global";s:12:"skinFunction";s:9:"includeJS";s:4:"type";s:2:"if";s:2:"id";s:8:"minifyjs";s:8:"position";s:10:"post.endif";}]]></hook_data>
  25. <hooks_source><![CDATA[<?php
  26.  
  27. class ajaxThanksJS
  28. {
  29. protected $registry;
  30. protected $settings;
  31.  
  32. public function __construct()
  33. {
  34. $this->registry = ipsRegistry::instance();
  35. $this->settings =& $this->registry->fetchSettings();
  36. }
  37.  
  38. public function getOutput()
  39. {
  40. if ( $this->settings['en30_ajaxthanks'] )
  41. {
  42. return $this->registry->getClass('output')->getTemplate('topic')->ajaxThanksJS();
  43. }
  44. }
  45. }
  46.  
  47. ?>]]></hooks_source>
  48. </file>
  49. <file>
  50. <hook_file_real>ajaxThanksPostData.php</hook_file_real>
  51. <hook_type>commandHooks</hook_type>
  52. <hook_classname>ajaxThanksPostData</hook_classname>
  53. <hook_data><![CDATA[a:8:{s:12:"dataLocation";s:0:"";s:14:"libApplication";s:0:"";s:15:"classToOverload";s:27:"public_forums_forums_topics";s:9:"skinGroup";N;s:12:"skinFunction";N;s:4:"type";N;s:2:"id";N;s:8:"position";N;}]]></hook_data>
  54. <hooks_source><![CDATA[<?php
  55.  
  56. class ajaxThanksPostData extends (~extends~)
  57. {
  58. public function _getPosts()
  59. {
  60. $posts = parent::_getPosts();
  61.  
  62. //-----------------------------------------
  63. // [EN31] Ajax Thanks
  64. //-----------------------------------------
  65.  
  66. foreach ( $posts as $pid => $post )
  67. {
  68. //-----------------------------------------
  69. // INIT
  70. //-----------------------------------------
  71.  
  72. $posts[ $pid ]['thanks'] = array(
  73. 'count' => 0,
  74. 'button' => 0,
  75. 'thankers' => array()
  76. );
  77.  
  78. //-----------------------------------------
  79. // INIT
  80. //-----------------------------------------
  81.  
  82. $thankButton = 1;
  83. $removeThanks = 0;
  84.  
  85. //-----------------------------------------
  86. // System online?
  87. //-----------------------------------------
  88.  
  89. if ( ! $this->settings['en30_ajaxthanks'] )
  90. {
  91. $thankButton = 0;
  92. }
  93.  
  94. //-----------------------------------------
  95. // Not logged in?
  96. //-----------------------------------------
  97.  
  98. if ( ! $this->memberData['member_id'] )
  99. {
  100. $thankButton = 0;
  101. }
  102. else
  103. {
  104. //-----------------------------------------
  105. // You can't thank yourself, silly!
  106. //-----------------------------------------
  107.  
  108. if ( $this->memberData['member_id'] == $posts[ $pid ]['author_id'] )
  109. {
  110. $thankButton = 0;
  111. }
  112. }
  113.  
  114. //-----------------------------------------
  115. // Only first post can be thanked?
  116. //-----------------------------------------
  117.  
  118. if ( $this->settings['en30_thankfirstonly'] && ! $posts[ $pid ]['new_topic'] )
  119. {
  120. $thankButton = 0;
  121. }
  122.  
  123. //-----------------------------------------
  124. // Forum excluded?
  125. //-----------------------------------------
  126.  
  127. $topicData = $this->registry->getClass('topics')->getTopicData();
  128.  
  129. if ( $topicData )
  130. {
  131. $fid = $topicData['forum_id'];
  132.  
  133. if ( in_array( $fid, explode( ",", $this->settings['en30_ajaxthanksforums'] ) ) )
  134. {
  135. $thankButton = 0;
  136. }
  137. }
  138.  
  139. //-----------------------------------------
  140. // Member group excluded?
  141. //-----------------------------------------
  142.  
  143. if ( in_array( $this->memberData['member_group_id'], explode( ",", $this->settings['en30_ajaxthanksgroups'] ) ) )
  144. {
  145. $thankButton = 0;
  146. }
  147.  
  148. //-----------------------------------------
  149. // Post has been thanked before?
  150. //-----------------------------------------
  151.  
  152. if ( ! empty( $posts[ $pid ]['thankers'] ) )
  153. {
  154. //-----------------------------------------
  155. // Unserialize thankers list
  156. //-----------------------------------------
  157.  
  158. $thankers = unserialize( stripslashes( $posts[ $pid ]['thankers'] ) );
  159.  
  160. //-----------------------------------------
  161. // INIT
  162. //-----------------------------------------
  163.  
  164. $posts[ $pid ]['thanks']['count'] = count( $thankers );
  165. $posts[ $pid ]['thankers'] = "";
  166.  
  167. //-----------------------------------------
  168. // Already thanked this post?
  169. //-----------------------------------------
  170.  
  171. if ( array_key_exists( $this->memberData['member_id'], $thankers ) )
  172. {
  173. $thankButton = 0;
  174. $removeThanks = 1;
  175. }
  176.  
  177. //-----------------------------------------
  178. // Link thankers list
  179. //-----------------------------------------
  180.  
  181. foreach ( $thankers as $mid => $name )
  182. {
  183. $posts[ $pid ]['thanks']['thankers'][] = $this->registry->getClass('output')->getTemplate('topic')->ajaxThankerLink( $mid, $name, IPSText::makeSeoTitle( $name ) );
  184. }
  185. }
  186.  
  187. //-----------------------------------------
  188. // Show/hide thanks button
  189. //-----------------------------------------
  190.  
  191. if ( $thankButton )
  192. {
  193. $posts[ $pid ]['thanks']['button'] = 'thank';
  194. }
  195. else if ( $removeThanks )
  196. {
  197. $posts[ $pid ]['thanks']['button'] = 'remove';
  198. }
  199. else
  200. {
  201. $posts[ $pid ]['thanks']['button'] = 'none';
  202. }
  203. }
  204.  
  205. return $posts;
  206. }
  207. }
  208.  
  209. ?>]]></hooks_source>
  210. </file>
  211. <file>
  212. <hook_file_real>ajaxThanksDummy.php</hook_file_real>
  213. <hook_type>templateHooks</hook_type>
  214. <hook_classname>ajaxThanksDummy</hook_classname>
  215. <hook_data><![CDATA[a:8:{s:12:"dataLocation";s:0:"";s:14:"libApplication";s:0:"";s:15:"classToOverload";s:0:"";s:9:"skinGroup";s:10:"skin_topic";s:12:"skinFunction";s:4:"post";s:4:"type";s:2:"if";s:2:"id";s:7:"canEdit";s:8:"position";s:11:"pre.startif";}]]></hook_data>
  216. <hooks_source><![CDATA[<?php
  217.  
  218. class ajaxThanksDummy
  219. {
  220. public function __construct()
  221. {
  222. // The purpose of this file is to prevent IPB from skipping
  223. // hook duties for the Topic View -> 'post' template bit
  224. }
  225.  
  226. public function getOutput()
  227. {
  228. }
  229. }
  230.  
  231. ?>]]></hooks_source>
  232. </file>
  233. <file>
  234. <hook_file_real>ajaxThanksButton.php</hook_file_real>
  235. <hook_type>templateHooks</hook_type>
  236. <hook_classname>ajaxThanksButton</hook_classname>
  237. <hook_data><![CDATA[a:8:{s:12:"dataLocation";s:0:"";s:14:"libApplication";s:0:"";s:15:"classToOverload";s:0:"";s:9:"skinGroup";s:10:"skin_topic";s:12:"skinFunction";s:17:"topicViewTemplate";s:4:"type";s:7:"foreach";s:2:"id";s:9:"post_data";s:8:"position";s:10:"outer.post";}]]></hook_data>
  238. <hooks_source><![CDATA[<?php
  239.  
  240. class ajaxThanksButton
  241. {
  242. protected $registry;
  243. protected $settings;
  244.  
  245. public function __construct()
  246. {
  247. $this->registry = ipsRegistry::instance();
  248. $this->settings =& $this->registry->fetchSettings();
  249. }
  250.  
  251. public function getOutput()
  252. {
  253.  
  254. }
  255.  
  256. public function replaceOutput( $output, $key )
  257. {
  258. $tag = '<!--hook.if.skin_topic.post.canEdit.pre.startif-->';
  259. $lastFound = 0;
  260.  
  261. foreach( $this->registry->output->getTemplate('topic')->functionData['topicViewTemplate'][0]['post_data'] as $post )
  262. {
  263. if ( ! $post['post']['_isDeleted'] )
  264. {
  265. $pos = strpos( $output, $tag, $lastFound );
  266. $strToInsert = $this->registry->output->replaceMacros( $this->registry->getClass('output')->getTemplate('topic')->ajaxThanksButton( $post ) );
  267.  
  268. if ( $pos )
  269. {
  270. $output = substr_replace( $output, $strToInsert . $tag, $pos, strlen( $tag ) );
  271. $lastFound = $pos + strlen( $tag . $strToInsert );
  272. }
  273. }
  274. }
  275.  
  276. return $output;
  277. }
  278. }
  279.  
  280. ?>]]></hooks_source>
  281. </file>
  282. <file>
  283. <hook_file_real>ajaxThanksProfileView.php</hook_file_real>
  284. <hook_type>templateHooks</hook_type>
  285. <hook_classname>ajaxThanksProfileView</hook_classname>
  286. <hook_data><![CDATA[a:8:{s:12:"dataLocation";s:0:"";s:14:"libApplication";s:0:"";s:15:"classToOverload";s:0:"";s:9:"skinGroup";s:12:"skin_profile";s:12:"skinFunction";s:13:"profileModern";s:4:"type";s:2:"if";s:2:"id";s:8:"pcfields";s:8:"position";s:10:"post.endif";}]]></hook_data>
  287. <hooks_source><![CDATA[<?php
  288.  
  289. class ajaxThanksProfileView
  290. {
  291. protected $registry;
  292. protected $DB;
  293. protected $request;
  294. protected $settings;
  295. protected $memberData;
  296.  
  297. public function __construct()
  298. {
  299. $this->registry = ipsRegistry::instance();
  300. $this->DB = $this->registry->DB();
  301. $this->request =& $this->registry->fetchRequest();
  302. $this->settings =& $this->registry->fetchSettings();
  303. $this->memberData =& $this->registry->member()->fetchMemberData();
  304. }
  305.  
  306. public function getOutput()
  307. {
  308. if ( $this->settings['en30_ajaxthanks'] )
  309. {
  310. //-----------------------------------------
  311. // Load public_topic lang file
  312. //-----------------------------------------
  313.  
  314. $this->registry->getClass( 'class_localization')->loadLanguageFile( array( 'public_topic' ), 'forums' );
  315.  
  316. //-----------------------------------------
  317. // Get the member array
  318. //-----------------------------------------
  319.  
  320. $member = $this->registry->output->getTemplate('profile')->functionData['profileModern'][0]['member'];
  321.  
  322. //-----------------------------------------
  323. // Show thanked count
  324. //-----------------------------------------
  325.  
  326. return $this->registry->getClass('output')->getTemplate('topic')->ajaxThankedCountProfile( $member );
  327. }
  328. }
  329. }
  330.  
  331. ?>]]></hooks_source>
  332. </file>
  333. <file>
  334. <hook_file_real>ajaxThankersList.php</hook_file_real>
  335. <hook_type>templateHooks</hook_type>
  336. <hook_classname>ajaxThankersList</hook_classname>
  337. <hook_data><![CDATA[a:8:{s:12:"dataLocation";s:0:"";s:14:"libApplication";s:0:"";s:15:"classToOverload";s:0:"";s:9:"skinGroup";s:10:"skin_topic";s:12:"skinFunction";s:17:"topicViewTemplate";s:4:"type";s:7:"foreach";s:2:"id";s:9:"post_data";s:8:"position";s:10:"inner.post";}]]></hook_data>
  338. <hooks_source><![CDATA[<?php
  339.  
  340. class ajaxThankersList
  341. {
  342. protected $registry;
  343. protected $settings;
  344.  
  345. public function __construct()
  346. {
  347. $this->registry = ipsRegistry::instance();
  348. $this->settings =& $this->registry->fetchSettings();
  349. }
  350.  
  351. public function getOutput()
  352. {
  353. }
  354.  
  355. public function replaceOutput( $output, $key )
  356. {
  357. $tag = '<!--hook.'.$key.'-->';
  358. $lastFound = 0;
  359.  
  360. foreach( $this->registry->output->getTemplate('topic')->functionData['topicViewTemplate'][0]['post_data'] as $pid => $post )
  361. {
  362. $pos = strpos( $output, $tag, $lastFound );
  363. $strToInsert = $this->registry->output->replaceMacros( $this->registry->getClass('output')->getTemplate('topic')->ajaxThankersList( $post ) );
  364.  
  365. if ( $pos )
  366. {
  367. $output = substr_replace( $output, $strToInsert . $tag, $pos, strlen( $tag ) );
  368. $lastFound = $pos + strlen( $tag . $strToInsert );
  369.  
  370. }
  371. }
  372.  
  373. return $output;
  374. }
  375. }
  376.  
  377. ?>]]></hooks_source>
  378. </file>
  379. <file>
  380. <hook_file_real>ajaxThanksInfoPane.php</hook_file_real>
  381. <hook_type>templateHooks</hook_type>
  382. <hook_classname>ajaxThanksInfoPane</hook_classname>
  383. <hook_data><![CDATA[a:8:{s:12:"dataLocation";s:0:"";s:14:"libApplication";s:0:"";s:15:"classToOverload";s:0:"";s:9:"skinGroup";s:11:"skin_global";s:12:"skinFunction";s:12:"userInfoPane";s:4:"type";s:2:"if";s:2:"id";s:9:"postCount";s:8:"position";s:10:"post.endif";}]]></hook_data>
  384. <hooks_source><![CDATA[<?php
  385.  
  386. class ajaxThanksInfoPane
  387. {
  388. protected $registry;
  389. protected $settings;
  390.  
  391. public function __construct()
  392. {
  393. $this->registry = ipsRegistry::instance();
  394. $this->settings =& $this->registry->fetchSettings();
  395. }
  396.  
  397. public function getOutput()
  398. {
  399. }
  400.  
  401. public function replaceOutput( $output, $key )
  402. {
  403. $tag = '<!--hook.'.$key.'-->';
  404. $lastFound = 0;
  405.  
  406. foreach( $this->registry->output->getTemplate('global')->functionData['userInfoPane'] as $mid => $author )
  407. {
  408. $author = $author['author'];
  409.  
  410. $pos = strpos( $output, $tag, $lastFound );
  411. $strToInsert = $this->registry->output->replaceMacros( $this->registry->getClass('output')->getTemplate('topic')->ajaxThankedCount( $author ) );
  412.  
  413. if ( $pos )
  414. {
  415. $output = substr_replace( $output, $strToInsert . $tag, $pos, strlen( $tag ) );
  416. $lastFound = $pos + strlen( $tag . $strToInsert );
  417.  
  418. }
  419. }
  420.  
  421. return $output;
  422. }
  423. }
  424.  
  425. ?>]]></hooks_source>
  426. </file>
  427. <file>
  428. <hook_file_real>ajaxThanksAdd.php</hook_file_real>
  429. <hook_type>commandHooks</hook_type>
  430. <hook_classname>ajaxThanksAdd</hook_classname>
  431. <hook_data><![CDATA[a:8:{s:12:"dataLocation";s:0:"";s:14:"libApplication";s:0:"";s:15:"classToOverload";s:24:"public_forums_ajax_stats";s:9:"skinGroup";N;s:12:"skinFunction";N;s:4:"type";N;s:2:"id";N;s:8:"position";N;}]]></hook_data>
  432. <hooks_source><![CDATA[<?php
  433.  
  434. class ajaxThanksAdd extends (~extends~)
  435. {
  436. public $registry;
  437.  
  438. public function doExecute( ipsRegistry $registry )
  439. {
  440. switch( $this->request['do'] )
  441. {
  442. case 'ajaxThanks':
  443. $this->doAjaxThanks( $registry );
  444. break;
  445. case 'ajaxRemoveThanks':
  446. $this->removeAjaxThanks( $registry );
  447. break;
  448. default:
  449. parent::doExecute( $registry );
  450. break;
  451. }
  452. }
  453.  
  454. private function removeAjaxThanks( ipsRegistry $registry )
  455. {
  456. //-----------------------------------------
  457. // INIT
  458. //-----------------------------------------
  459.  
  460. $pid = intval( $this->request['pid'] );
  461. $fid = intval( $this->request['fid'] );
  462. $tid = intval( $this->request['tid'] );
  463.  
  464. //-----------------------------------------
  465. // Permissions
  466. //-----------------------------------------
  467.  
  468. if ( ! $pid || ! $tid || ! $fid )
  469. {
  470. $this->returnJsonError( 'No post/topic/forum passed.' );
  471. }
  472.  
  473. $pass = 1;
  474.  
  475. if ( ! $this->settings['en30_ajaxthanks'] )
  476. {
  477. // Mod is off
  478. $pass = 0;
  479. }
  480.  
  481. if ( ! $this->memberData['member_id'] )
  482. {
  483. // Must be logged in
  484. $pass = 0;
  485. }
  486.  
  487. if ( in_array( $fid, explode( ",", $this->settings['en30_ajaxthanksforums'] ) ) )
  488. {
  489. // Forum excluded
  490. $pass = 0;
  491. }
  492.  
  493. if ( in_array( $this->memberData['member_group_id'], explode( ",", $this->settings['en30_ajaxthanksgroups'] ) ) )
  494. {
  495. // Group excluded
  496. $pass = 0;
  497. }
  498.  
  499. if ( ! $pass )
  500. {
  501. $this->returnJsonError( 'Unauthorized action.' );
  502. }
  503.  
  504. $post = $this->DB->buildAndFetch( array( 'select' => 'author_id, thankers, new_topic', 'from' => 'posts', 'where' => "pid = '{$pid}' AND topic_id = '{$tid}'" ) );
  505.  
  506. if ( ! $this->DB->getTotalRows() )
  507. {
  508. $this->returnJsonError( 'Invalid post or topic ID.' );
  509. }
  510.  
  511. if ( ! empty( $post['thankers'] ) )
  512. {
  513. $post['thankers'] = unserialize( stripslashes( $post['thankers'] ) );
  514.  
  515. if ( ! array_key_exists( $this->memberData['member_id'], $post['thankers'] ) )
  516. {
  517. $this->returnJsonError( "You haven't thanked this topic yet." );
  518. }
  519.  
  520. unset( $post['thankers'][ $this->memberData['member_id'] ] );
  521. }
  522. else
  523. {
  524. $this->returnJsonError( "No one has thanked this topic yet." );
  525. }
  526.  
  527. $serialized = addslashes( serialize( $post['thankers'] ) );
  528.  
  529. $this->DB->update( 'posts', array( 'thankers' => $serialized ), 'pid='.$pid );
  530. $this->DB->update( 'profile_portal', 'thanked=thanked-1', 'pp_member_id='.$post['author_id'], false, true );
  531.  
  532. foreach ( $post['thankers'] as $mid => $name )
  533. {
  534. $thankers .= $this->registry->getClass('output')->getTemplate('topic')->ajaxThankerLink( $mid, $name, IPSText::makeSeoTitle( $name ) );
  535. }
  536.  
  537. $this->returnJsonArray( array( 'member_id' => $this->memberData['member_id'],
  538. 'members_display_name' => $this->memberData['members_display_name'],
  539. 'thankers' => $thankers
  540. ) );
  541. }
  542.  
  543. private function doAjaxThanks( ipsRegistry $registry )
  544. {
  545. //-----------------------------------------
  546. // INIT
  547. //-----------------------------------------
  548.  
  549. $pid = intval( $this->request['pid'] );
  550. $fid = intval( $this->request['fid'] );
  551. $tid = intval( $this->request['tid'] );
  552.  
  553. //-----------------------------------------
  554. // Permissions
  555. //-----------------------------------------
  556.  
  557. if ( ! $pid || ! $tid || ! $fid )
  558. {
  559. $this->returnJsonError( 'No post/topic/forum passed.' );
  560. }
  561.  
  562. $pass = 1;
  563.  
  564. if ( ! $this->settings['en30_ajaxthanks'] )
  565. {
  566. // Mod is off
  567. $pass = 0;
  568. }
  569.  
  570. if ( ! $this->memberData['member_id'] )
  571. {
  572. // Must be logged in
  573. $pass = 0;
  574. }
  575.  
  576. if ( in_array( $fid, explode( ",", $this->settings['en30_ajaxthanksforums'] ) ) )
  577. {
  578. // Forum excluded
  579. $pass = 0;
  580. }
  581.  
  582. if ( in_array( $this->memberData['member_group_id'], explode( ",", $this->settings['en30_ajaxthanksgroups'] ) ) )
  583. {
  584. // Group excluded
  585. $pass = 0;
  586. }
  587.  
  588. if ( ! $pass )
  589. {
  590. $this->returnJsonError( 'Unauthorized action.' );
  591. }
  592.  
  593. $post = $this->DB->buildAndFetch( array( 'select' => 'author_id, thankers, new_topic', 'from' => 'posts', 'where' => "pid = '{$pid}' AND topic_id = '{$tid}'" ) );
  594.  
  595. if ( ! $this->DB->getTotalRows() )
  596. {
  597. $this->returnJsonError( 'Invalid post or topic ID.' );
  598. }
  599.  
  600. if ( $post['author_id'] == $this->memberData['member_id'] )
  601. {
  602. $this->returnJsonError( 'You can\'t thank yourself, silly!' );
  603. }
  604.  
  605. if ( $this->settings['en30_thankfirstonly'] && ! $post['new_topic'] )
  606. {
  607. $this->returnJsonError( 'You are not allowed to thank topic replies.' );
  608. }
  609.  
  610. $thankers = array( $this->memberData['member_id'] => $this->memberData['members_display_name'] );
  611.  
  612. if ( ! empty( $post['thankers'] ) )
  613. {
  614. $post['thankers'] = unserialize( stripslashes( $post['thankers'] ) );
  615.  
  616. if ( array_key_exists( $this->memberData['member_id'], $post['thankers'] ) )
  617. {
  618. $this->returnJsonError( 'You have already thanked this topic.' );
  619. }
  620.  
  621. foreach ( $post['thankers'] as $k => $v )
  622. {
  623. $thankers[ $k ] = $v;
  624. }
  625. }
  626.  
  627. $thankers = addslashes( serialize( $thankers ) );
  628.  
  629. $this->DB->update( 'posts', array( 'thankers' => $thankers ), 'pid='.$pid );
  630. $this->DB->update( 'profile_portal', 'thanked=thanked+1', 'pp_member_id='.$post['author_id'], false, true );
  631.  
  632. $postContent = "";
  633.  
  634. if ( $this->settings['en30_ajaxthankshidehack'] && isset( $this->settings['tb_hc_groups'] ) )
  635. {
  636. $this->DB->build( array( 'select' => '*', 'from' => 'posts', 'where' => 'pid='.$pid ) );
  637. $this->DB->execute();
  638.  
  639. $row = $this->DB->fetch();
  640.  
  641. if ( ! is_object( $this->postClass ) )
  642. {
  643. require_once( IPSLib::getAppDir( 'forums' ) . "/sources/classes/post/classPost.php" );
  644. require_once( IPSLib::getAppDir( 'forums' ) . "/sources/classes/post/classPostForms.php" );
  645.  
  646. $this->registry->getClass( 'class_localization')->loadLanguageFile( array( 'public_editors' ), 'core' );
  647.  
  648. $this->postClass = new classPostForms( $this->registry );
  649. }
  650.  
  651. $this->cache->updateCacheWithoutSaving( 'tb_hide_topic', array( 'tid' => $tid, 'starter_id' => $post['author_id'], 'last_poster_id' => $this->memberData['member_id'] ) );
  652.  
  653. //-----------------------------------------
  654. // Pre-display-parse
  655. //-----------------------------------------
  656.  
  657. IPSText::getTextClass( 'bbcode' )->parse_smilies = $row['use_emo'];
  658. IPSText::getTextClass( 'bbcode' )->parse_html = ( $this->registry->getClass('class_forums')->forum_by_id[ $fid ]['use_html'] and $this->memberData['g_dohtml'] and $row['post_htmlstate'] ) ? 1 : 0;
  659. IPSText::getTextClass( 'bbcode' )->parse_nl2br = $row['post_htmlstate'] == 2 ? 1 : 0;
  660. IPSText::getTextClass( 'bbcode' )->parse_bbcode = 1;
  661. IPSText::getTextClass( 'bbcode' )->parsing_section = 'topics';
  662. IPSText::getTextClass( 'bbcode' )->parsing_mgroup = $this->postClass->getAuthor('member_group_id');
  663. IPSText::getTextClass( 'bbcode' )->parsing_mgroup_others = $this->postClass->getAuthor('mgroup_others');
  664.  
  665. $postContent = IPSText::getTextClass( 'bbcode' )->preDisplayParse( $row['post'] );
  666.  
  667. //-----------------------------------------
  668. // Attachments
  669. //-----------------------------------------
  670.  
  671. $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'core' ) . '/sources/classes/attach/class_attach.php', 'class_attach' );
  672. $this->class_attach = new $classToLoad( $this->registry );
  673.  
  674. $this->class_attach->type = 'post';
  675. $this->class_attach->init();
  676.  
  677. if ( IPSMember::checkPermissions('download') === false )
  678. {
  679. $this->settings['show_img_upload'] = 0;
  680. }
  681.  
  682. $postContent = $this->class_attach->renderAttachments( $postContent, array( $row['pid'] => $row['pid'] ) );
  683. $postContent = $postContent[0]['html'];
  684.  
  685. //-----------------------------------------
  686. // Macros...
  687. //-----------------------------------------
  688.  
  689. $postContent = $this->registry->output->replaceMacros( $postContent );
  690. }
  691.  
  692. $this->returnJsonArray( array( 'member_id' => $this->memberData['member_id'],
  693. 'members_display_name' => $this->memberData['members_display_name'],
  694. 'post' => $postContent
  695. ) );
  696. }
  697. }
  698.  
  699. ?>]]></hooks_source>
  700. </file>
  701. </hookfiles>
  702. <hookextras_custom>
  703. <file>
  704. <filename>ajaxThanks.php</filename>
  705. <source><![CDATA[<?php
  706.  
  707. class ajaxThanks
  708. {
  709. protected $registry;
  710. protected $DB;
  711.  
  712. public function __construct( ipsRegistry $registry )
  713. {
  714. $this->registry = $registry;
  715. $this->DB = $this->registry->DB();
  716. }
  717.  
  718. public function install()
  719. {
  720. //-----------------------------------------
  721. // Migrate thanked count to profile_portal
  722. //-----------------------------------------
  723.  
  724. $prefix = $this->registry->dbFunctions()->getPrefix();
  725.  
  726. //-----------------------------------------
  727. // Is this a fresh install?
  728. //-----------------------------------------
  729.  
  730. $post = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'posts', 'limit' => array( 0, 1 ) ) );
  731.  
  732. if ( isset( $post['thanked'] ) )
  733. {
  734. $this->DB->build( array(
  735. 'update' => "profile_portal p, {$prefix}members m",
  736. 'set' => 'p.thanked = m.thanked',
  737. 'where' => 'm.thanked > 0 AND p.pp_member_id = m.member_id'
  738. ) );
  739.  
  740. $this->DB->execute();
  741. }
  742. }
  743.  
  744. public function uninstall()
  745. {
  746. }
  747. }
  748.  
  749. ?>]]></source>
  750. </file>
  751. </hookextras_custom>
  752. <hookextras_settings>
  753. <setting>
  754. <conf_is_title>1</conf_is_title>
  755. <conf_title_title><![CDATA[ [EN34] Ajax Thanks]]></conf_title_title>
  756. <conf_title_desc><![CDATA[Settings for the [EN34] Ajax Thanks modification by Elad Nava.]]></conf_title_desc>
  757. <conf_title_noshow>0</conf_title_noshow>
  758. <conf_title_keyword>en30_ajaxthanks</conf_title_keyword>
  759. <conf_title_app>core</conf_title_app>
  760. <conf_title_tab>System</conf_title_tab>
  761. </setting>
  762. <setting>
  763. <conf_id>315</conf_id>
  764. <conf_title>System online?</conf_title>
  765. <conf_description>Master switch.</conf_description>
  766. <conf_group>31</conf_group>
  767. <conf_type>yes_no</conf_type>
  768. <conf_key>en30_ajaxthanks</conf_key>
  769. <conf_value/>
  770. <conf_default>1</conf_default>
  771. <conf_extra/>
  772. <conf_evalphp/>
  773. <conf_protected>1</conf_protected>
  774. <conf_position>1</conf_position>
  775. <conf_start_group>Functionality</conf_start_group>
  776. <conf_add_cache>1</conf_add_cache>
  777. <conf_keywords/>
  778. <conf_title_keyword>en30_ajaxthanks</conf_title_keyword>
  779. <conf_is_title>0</conf_is_title>
  780. </setting>
  781. <setting>
  782. <conf_id>319</conf_id>
  783. <conf_title>Collapse thankers?</conf_title>
  784. <conf_description>This setting will collapse the thankers box if the amount of thankers exceeds the number specified in the setting below.</conf_description>
  785. <conf_group>31</conf_group>
  786. <conf_type>yes_no</conf_type>
  787. <conf_key>en30_ajaxthankscollapse</conf_key>
  788. <conf_value/>
  789. <conf_default>1</conf_default>
  790. <conf_extra/>
  791. <conf_evalphp/>
  792. <conf_protected>1</conf_protected>
  793. <conf_position>5</conf_position>
  794. <conf_start_group>Collapsing</conf_start_group>
  795. <conf_add_cache>1</conf_add_cache>
  796. <conf_keywords/>
  797. <conf_title_keyword>en30_ajaxthanks</conf_title_keyword>
  798. <conf_is_title>0</conf_is_title>
  799. </setting>
  800. <setting>
  801. <conf_id>317</conf_id>
  802. <conf_title>Disable thanking in certain forums?</conf_title>
  803. <conf_description>Select forum(s) in which members cannot thank posters.</conf_description>
  804. <conf_group>31</conf_group>
  805. <conf_type>multi</conf_type>
  806. <conf_key>en30_ajaxthanksforums</conf_key>
  807. <conf_value/>
  808. <conf_default/>
  809. <conf_extra>#show_forums#</conf_extra>
  810. <conf_evalphp><![CDATA[if ( $save == 1)
  811. {
  812. if ( is_array($_POST['en30_ajaxthanksforums']) )
  813. {
  814. $_POST['en30_ajaxthanksforums'] = implode(",",$_POST['en30_ajaxthanksforums']);
  815. }
  816. else
  817. {
  818. $_POST['en30_ajaxthanksforums'] = "";
  819. }
  820.  
  821. $key = 'en30_ajaxthanksforums';
  822. }
  823. if ( $show == 1 )
  824. {
  825. $key = 'en30_ajaxthanksforums[]';
  826. }]]></conf_evalphp>
  827. <conf_protected>1</conf_protected>
  828. <conf_position>4</conf_position>
  829. <conf_start_group/>
  830. <conf_add_cache>1</conf_add_cache>
  831. <conf_keywords/>
  832. <conf_title_keyword>en30_ajaxthanks</conf_title_keyword>
  833. <conf_is_title>0</conf_is_title>
  834. </setting>
  835. <setting>
  836. <conf_id>316</conf_id>
  837. <conf_title>Exclude groups from thanking?</conf_title>
  838. <conf_description>Select group(s) that will not be able to thank posters.</conf_description>
  839. <conf_group>31</conf_group>
  840. <conf_type>multi</conf_type>
  841. <conf_key>en30_ajaxthanksgroups</conf_key>
  842. <conf_value/>
  843. <conf_default/>
  844. <conf_extra>#show_groups#</conf_extra>
  845. <conf_evalphp><![CDATA[if ( $save == 1)
  846. {
  847. if ( is_array($_POST['en30_ajaxthanksgroups']) )
  848. {
  849. $_POST['en30_ajaxthanksgroups'] = implode(",",$_POST['en30_ajaxthanksgroups']);
  850. }
  851. else
  852. {
  853. $_POST['en30_ajaxthanksgroups'] = "";
  854. }
  855.  
  856. $key = 'en30_ajaxthanksgroups';
  857. }
  858. if ( $show == 1 )
  859. {
  860. $key = 'en30_ajaxthanksgroups[]';
  861. }]]></conf_evalphp>
  862. <conf_protected>1</conf_protected>
  863. <conf_position>3</conf_position>
  864. <conf_start_group>Permissions</conf_start_group>
  865. <conf_add_cache>1</conf_add_cache>
  866. <conf_keywords/>
  867. <conf_title_keyword>en30_ajaxthanks</conf_title_keyword>
  868. <conf_is_title>0</conf_is_title>
  869. </setting>
  870. <setting>
  871. <conf_id>318</conf_id>
  872. <conf_title>Enable integration?</conf_title>
  873. <conf_description><![CDATA[Reveal hidden content to thankers automatically after thanking a post if <a href="http://www.invisionbyte.net/index.php?showtopic=3055" target="_blank" title="(T30) Hide Content">(T30) Hide Content</a> is installed?]]></conf_description>
  874. <conf_group>31</conf_group>
  875. <conf_type>yes_no</conf_type>
  876. <conf_key>en30_ajaxthankshidehack</conf_key>
  877. <conf_value/>
  878. <conf_default>1</conf_default>
  879. <conf_extra/>
  880. <conf_evalphp/>
  881. <conf_protected>1</conf_protected>
  882. <conf_position>7</conf_position>
  883. <conf_start_group>(T30) Hide Content Integration</conf_start_group>
  884. <conf_add_cache>1</conf_add_cache>
  885. <conf_keywords/>
  886. <conf_title_keyword>en30_ajaxthanks</conf_title_keyword>
  887. <conf_is_title>0</conf_is_title>
  888. </setting>
  889. <setting>
  890. <conf_id>320</conf_id>
  891. <conf_title>Number of thankers to trigger collapse</conf_title>
  892. <conf_description>Specify the minimum number of thankers to cause the thankers box to collapse. The setting above must be enabled for this to have any effect.</conf_description>
  893. <conf_group>31</conf_group>
  894. <conf_type>input</conf_type>
  895. <conf_key>en30_ajaxthanksmaxthankers</conf_key>
  896. <conf_value/>
  897. <conf_default>25</conf_default>
  898. <conf_extra/>
  899. <conf_evalphp/>
  900. <conf_protected>1</conf_protected>
  901. <conf_position>6</conf_position>
  902. <conf_start_group/>
  903. <conf_add_cache>1</conf_add_cache>
  904. <conf_keywords/>
  905. <conf_title_keyword>en30_ajaxthanks</conf_title_keyword>
  906. <conf_is_title>0</conf_is_title>
  907. </setting>
  908. <setting>
  909. <conf_id>321</conf_id>
  910. <conf_title>Disable thanking topic replies?</conf_title>
  911. <conf_description>Allow thanking only the first post in a topic?</conf_description>
  912. <conf_group>31</conf_group>
  913. <conf_type>yes_no</conf_type>
  914. <conf_key>en30_thankfirstonly</conf_key>
  915. <conf_value/>
  916. <conf_default>0</conf_default>
  917. <conf_extra/>
  918. <conf_evalphp/>
  919. <conf_protected>1</conf_protected>
  920. <conf_position>2</conf_position>
  921. <conf_start_group/>
  922. <conf_add_cache>1</conf_add_cache>
  923. <conf_keywords/>
  924. <conf_title_keyword>en30_ajaxthanks</conf_title_keyword>
  925. <conf_is_title>0</conf_is_title>
  926. </setting>
  927. <setting>
  928. <conf_id>322</conf_id>
  929. <conf_title>Allow members to remove thanks?</conf_title>
  930. <conf_description>Do you want to allow members to remove their thanks, if they clicked the button by accident?</conf_description>
  931. <conf_group>31</conf_group>
  932. <conf_type>yes_no</conf_type>
  933. <conf_key>en31_remove_thanks</conf_key>
  934. <conf_value/>
  935. <conf_default>1</conf_default>
  936. <conf_extra/>
  937. <conf_evalphp/>
  938. <conf_protected>1</conf_protected>
  939. <conf_position>8</conf_position>
  940. <conf_start_group>Убрать благодарность</conf_start_group>
  941. <conf_add_cache>1</conf_add_cache>
  942. <conf_keywords/>
  943. <conf_title_keyword>en30_ajaxthanks</conf_title_keyword>
  944. <conf_is_title>0</conf_is_title>
  945. </setting>
  946. </hookextras_settings>
  947. <hookextras_language>
  948. <language>
  949. <word_app>forums</word_app>
  950. <word_pack>public_topic</word_pack>
  951. <word_key>en30_user</word_key>
  952. <word_default>пользователей:</word_default>
  953. <word_custom/>
  954. <word_js>0</word_js>
  955. </language>
  956. <language>
  957. <word_app>forums</word_app>
  958. <word_pack>public_topic</word_pack>
  959. <word_key>en30_users</word_key>
  960. <word_default>пользователей:</word_default>
  961. <word_custom/>
  962. <word_js>0</word_js>
  963. </language>
  964. <language>
  965. <word_app>forums</word_app>
  966. <word_pack>public_topic</word_pack>
  967. <word_key>en30_unthank_author</word_key>
  968. <word_default>Убрать благодарность с сообщения</word_default>
  969. <word_custom/>
  970. <word_js>0</word_js>
  971. </language>
  972. <language>
  973. <word_app>forums</word_app>
  974. <word_pack>public_topic</word_pack>
  975. <word_key>en30_unthank</word_key>
  976. <word_default>Убрать благодарность</word_default>
  977. <word_custom/>
  978. <word_js>0</word_js>
  979. </language>
  980. <language>
  981. <word_app>forums</word_app>
  982. <word_pack>public_topic</word_pack>
  983. <word_key>en30_times</word_key>
  984. <word_default>times</word_default>
  985. <word_custom/>
  986. <word_js>0</word_js>
  987. </language>
  988. <language>
  989. <word_app>forums</word_app>
  990. <word_pack>public_topic</word_pack>
  991. <word_key>en30_thanked_by</word_key>
  992. <word_default>Поблагодарили за полезное сообщение</word_default>
  993. <word_custom/>
  994. <word_js>0</word_js>
  995. </language>
  996. <language>
  997. <word_app>forums</word_app>
  998. <word_pack>public_topic</word_pack>
  999. <word_key>en30_thank_author</word_key>
  1000. <word_default>Поблагодарить автора за полезное сообщение</word_default>
  1001. <word_custom/>
  1002. <word_js>0</word_js>
  1003. </language>
  1004. <language>
  1005. <word_app>forums</word_app>
  1006. <word_pack>public_topic</word_pack>
  1007. <word_key>en30_thanks</word_key>
  1008. <word_default>Получено благодарностей</word_default>
  1009. <word_custom/>
  1010. <word_js>0</word_js>
  1011. </language>
  1012. <language>
  1013. <word_app>forums</word_app>
  1014. <word_pack>public_topic</word_pack>
  1015. <word_key>en30_thanked</word_key>
  1016. <word_default>Thanked</word_default>
  1017. <word_custom/>
  1018. <word_js>0</word_js>
  1019. </language>
  1020. <language>
  1021. <word_app>forums</word_app>
  1022. <word_pack>public_topic</word_pack>
  1023. <word_key>en30_thank</word_key>
  1024. <word_default>Поблагодарить</word_default>
  1025. <word_custom/>
  1026. <word_js>0</word_js>
  1027. </language>
  1028. <language>
  1029. <word_app>forums</word_app>
  1030. <word_pack>public_topic</word_pack>
  1031. <word_key>en30_show</word_key>
  1032. <word_default><![CDATA[[Show]]]></word_default>
  1033. <word_custom/>
  1034. <word_js>0</word_js>
  1035. </language>
  1036. </hookextras_language>
  1037. <hookextras_modules/>
  1038. <hookextras_help/>
  1039. <hookextras_templates>
  1040. <templates>
  1041. <template_group>skin_topic</template_group>
  1042. <template_content><![CDATA[ <if test="ajaxThanksEnabled:|:$this->settings['en30_ajaxthanks']">
  1043. <li class="post_count desc lighter">
  1044. {$author['thanked']} {$this->lang->words['en30_thanks']}
  1045. </li>
  1046. </if>
  1047. ]]></template_content>
  1048. <template_name>ajaxThankedCount</template_name>
  1049. <template_data>$author</template_data>
  1050. <template_updated>1311325211</template_updated>
  1051. <template_removable>1</template_removable>
  1052. <template_added_to>0</template_added_to>
  1053. <template_user_added>1</template_user_added>
  1054. <template_user_edited>1</template_user_edited>
  1055. <template_master_key>root</template_master_key>
  1056. <template_set_id>0</template_set_id>
  1057. </templates>
  1058. <templates>
  1059. <template_group>skin_topic</template_group>
  1060. <template_content><![CDATA[ <li>
  1061. <span class='row_title'>{$this->lang->words['en30_thanked']}</span>
  1062. <span class='row_data'>{$member['thanked']} {$this->lang->words['en30_times']}</span>
  1063. </li>]]></template_content>
  1064. <template_name>ajaxThankedCountProfile</template_name>
  1065. <template_data>$пользователей</template_data>
  1066. <template_updated>1311324842</template_updated>
  1067. <template_removable>1</template_removable>
  1068. <template_added_to>0</template_added_to>
  1069. <template_user_added>1</template_user_added>
  1070. <template_user_edited>1</template_user_edited>
  1071. <template_master_key>root</template_master_key>
  1072. <template_set_id>0</template_set_id>
  1073. </templates>
  1074. <templates>
  1075. <template_group>skin_topic</template_group>
  1076. <template_content><![CDATA[<php>$member = array( 'member_id' => $mid, 'members_display_name' => $name, 'members_seo_name' => $seoName );</php>
  1077. <span class="author vcard">{parse template="userHoverCard" group="global" params="$member"}</span>]]></template_content>
  1078. <template_name>ajaxThankerLink</template_name>
  1079. <template_data>$mid, $name, $seoName</template_data>
  1080. <template_updated>1311257015</template_updated>
  1081. <template_removable>1</template_removable>
  1082. <template_added_to>0</template_added_to>
  1083. <template_user_added>1</template_user_added>
  1084. <template_user_edited>1</template_user_edited>
  1085. <template_master_key>root</template_master_key>
  1086. <template_set_id>0</template_set_id>
  1087. </templates>
  1088. <templates>
  1089. <template_group>skin_topic</template_group>
  1090. <template_content><![CDATA[<if test="ajaxThanksEnabled:|:$this->settings['en30_ajaxthanks'] && $post['post']['thanks']['count'] != 0">
  1091. <div class="row2" id="thankersBox_{$post['post']['pid']}" title="visible" style="padding: 4px 0 4px 0">
  1092. <table class="ipb_table" cellpadding="6" cellspacing="1" border="0" width="100%" align="center">
  1093. <tbody>
  1094. <tr valign="top">
  1095. <td width="1%" nowrap="nowrap">
  1096. <div id="thankedBy_{$post['post']['pid']}" title="{$post['post']['thanks']['count']}" style="font-weight: bold">{$this->lang->words['en30_thanked_by']} {$post['post']['thanks']['count']} <if test="isPlural:|:$post['post']['thanks']['count'] == 1">{$this->lang->words['en30_user']}<else />{$this->lang->words['en30_users']}</if></div>
  1097. </td>
  1098. <td width="99%">
  1099. <div id="thankers_{$post['post']['pid']}" <if test="collapseThankers:|:$this->settings['en30_ajaxthankscollapse'] && $post['post']['thanks']['count'] > $this->settings['en30_ajaxthanksmaxthankers']">style="display: none;"</if>>
  1100. {parse expression="implode( ", ", $post['post']['thanks']['thankers'] )"}
  1101. </div>
  1102. <if test="collapseThankers2:|:$this->settings['en30_ajaxthankscollapse'] && $post['post']['thanks']['count'] > $this->settings['en30_ajaxthanksmaxthankers']">
  1103. <div id="show_thankers_{$post['post']['pid']}">
  1104. <a href="javascript: ajaxThanksExpand( '{$post['post']['pid']}' );">{$this->lang->words['en30_show']}</a>
  1105. </div>
  1106. <else />
  1107. <div id="show_thankers_{$post['post']['pid']}" style="display: none;"></div>
  1108. </if>
  1109. </td>
  1110. </tr>
  1111. </tbody>
  1112. </table>
  1113. </div>
  1114. <else />
  1115. <div class="row2" id="thankersBox_{$post['post']['pid']}" title="hidden" style="padding: 4px 0 4px 0; display: none">
  1116. <table class="ipb_table" cellpadding="6" cellspacing="1" border="0" width="100%" align="center">
  1117. <tbody>
  1118. <tr valign="top">
  1119. <td width="1%" nowrap="nowrap">
  1120. <div id="thankedBy_{$post['post']['pid']}" title="0" style="font-weight: bold">{$this->lang->words['en30_thanked_by']} 1 {$this->lang->words['en30_user']}</div>
  1121. </td>
  1122. <td width="99%">
  1123. <div id="thankers_{$post['post']['pid']}">{$post['post']['thankers']}</div>
  1124. </td>
  1125. </tr>
  1126. </tbody>
  1127. </table>
  1128. </div>
  1129. </if>]]></template_content>
  1130. <template_name>ajaxThankersList</template_name>
  1131. <template_data>$post</template_data>
  1132. <template_updated>1311256223</template_updated>
  1133. <template_removable>1</template_removable>
  1134. <template_added_to>0</template_added_to>
  1135. <template_user_added>1</template_user_added>
  1136. <template_user_edited>1</template_user_edited>
  1137. <template_master_key>root</template_master_key>
  1138. <template_set_id>0</template_set_id>
  1139. </templates>
  1140. <templates>
  1141. <template_group>skin_topic</template_group>
  1142. <template_content><![CDATA[ <if test="ajaxThanksButton:|:$post['post']['thanks']['button'] == 'thank'">
  1143. <li class='ajax_thanks' id='ajaxThanks_{$post['post']['pid']}'>
  1144. <a href="javascript: ajaxThanks( '{$post['post']['pid']}' );" title='{$this->lang->words['en30_thank_author']}' class='ipsButton_secondary'>{$this->lang->words['en30_thank']}</a>
  1145. </li>
  1146. </if>
  1147. <if test="ajaxThanksButton:|:$post['post']['thanks']['button'] == 'remove' && $this->settings['en31_remove_thanks']">
  1148. <li class='ajax_thanks' id='ajaxRemoveThanks_{$post['post']['pid']}'>
  1149. <a href="javascript: ajaxRemoveThanks( '{$post['post']['pid']}' );" title='{$this->lang->words['en30_unthank_author']}' class='ipsButton_secondary'>{$this->lang->words['en30_unthank']}</a>
  1150. </li>
  1151. </if>]]></template_content>
  1152. <template_name>ajaxThanksButton</template_name>
  1153. <template_data>$post</template_data>
  1154. <template_updated>1311257864</template_updated>
  1155. <template_removable>1</template_removable>
  1156. <template_added_to>0</template_added_to>
  1157. <template_user_added>1</template_user_added>
  1158. <template_user_edited>1</template_user_edited>
  1159. <template_master_key>root</template_master_key>
  1160. <template_set_id>0</template_set_id>
  1161. </templates>
  1162. <templates>
  1163. <template_group>skin_topic</template_group>
  1164. <template_content><![CDATA[<script type='text/javascript'>
  1165.  
  1166. ipb.lang['en30_thanked_by'] = "{$this->lang->words['en30_thanked_by']}";
  1167. ipb.lang['en30_thank'] = "{$this->lang->words['en30_thank']}";
  1168. ipb.lang['en30_thank_author'] = "{$this->lang->words['en30_thank_author']}";
  1169. ipb.lang['en30_user'] = "{$this->lang->words['en30_user']}";
  1170. ipb.lang['en30_users'] = "{$this->lang->words['en30_users']}";
  1171. ipb.lang['en30_thanked'] = "{$this->lang->words['en30_thanked']}";
  1172.  
  1173. function ajaxThanksExpand( pid )
  1174. {
  1175. var thankersBox = $( 'thankers_' + pid );
  1176. var showThankers = $( 'show_thankers_' + pid );
  1177.  
  1178. showThankers.style.display = "none";
  1179. thankersBox.style.display = "block";
  1180. }
  1181.  
  1182. function ajaxRemoveThanks( pid )
  1183. {
  1184. // Kill the thanks button of this specific post
  1185.  
  1186. new Effect.DropOut( 'ajaxRemoveThanks_' + pid );
  1187. var url = ipb.vars['base_url'] + 'app=forums&module=ajax&section=stats&do=ajaxRemoveThanks';
  1188.  
  1189. new Ajax.Request( url,
  1190. {
  1191. method: 'post',
  1192. evalJSON: 'force',
  1193. parameters: {
  1194. md5check: ipb.vars['secure_hash'],
  1195. pid: pid,
  1196. tid: ipb.topic.topic_id,
  1197. fid: ipb.topic.forum_id
  1198. },
  1199. onSuccess: function(t)
  1200. {
  1201. if( t.responseJSON['error'] )
  1202. {
  1203. alert( t.responseJSON['error'] );
  1204. }
  1205. else
  1206. {
  1207. var thankers = $( 'thankers_' + pid );
  1208. var thankedBy = $( 'thankedBy_' + pid );
  1209. var thankersBox = $( 'thankersBox_' + pid );
  1210.  
  1211. if ( thankersBox.getAttribute( 'title' ) == 'hidden' )
  1212. {
  1213. thankersBox.style.display = "block";
  1214.  
  1215. thankers.innerHTML = t.responseJSON['thankers'];
  1216. }
  1217. else
  1218. {
  1219. ajaxThanksExpand( pid );
  1220. thankers.innerHTML = t.responseJSON['thankers'];
  1221. }
  1222.  
  1223. if ( thankersBox.getAttribute( 'title' ) == 'hidden' )
  1224. {
  1225. thankersBox.style.display = "block";
  1226. }
  1227.  
  1228. // Update thanked by text (increment number show plural)
  1229.  
  1230. if ( thankedBy.title != '0' )
  1231. {
  1232. var thankers = parseInt( thankedBy.title ) - 1;
  1233.  
  1234. if ( thankers > 1 )
  1235. {
  1236. thankedBy.innerHTML = ipb.lang['en30_thanked_by'] + ' ' + thankers + ' ' + ipb.lang['en30_users'];
  1237. new Effect.Pulsate( thankersBox, { pulses: 3, duration: 1.5 } );
  1238. }
  1239. if ( thankers == 1 )
  1240. {
  1241. thankedBy.innerHTML = ipb.lang['en30_thanked_by'] + ' ' + thankers + ' ' + ipb.lang['en30_user'];
  1242. new Effect.Pulsate( thankersBox, { pulses: 3, duration: 1.5 } );
  1243. }
  1244. else
  1245. {
  1246. thankersBox.style.display = "none";
  1247. }
  1248. }
  1249. }
  1250. }
  1251. }
  1252. );
  1253. }
  1254.  
  1255. function ajaxThanks( pid )
  1256. {
  1257. // Kill the thanks button of this specific post
  1258.  
  1259. new Effect.DropOut( 'ajaxThanks_' + pid );
  1260. var url = ipb.vars['base_url'] + 'app=forums&module=ajax&section=stats&do=ajaxThanks';
  1261.  
  1262. new Ajax.Request( url,
  1263. {
  1264. method: 'post',
  1265. evalJSON: 'force',
  1266. parameters: {
  1267. md5check: ipb.vars['secure_hash'],
  1268. pid: pid,
  1269. tid: ipb.topic.topic_id,
  1270. fid: ipb.topic.forum_id
  1271. },
  1272. onSuccess: function(t)
  1273. {
  1274. if( t.responseJSON['error'] )
  1275. {
  1276. alert( t.responseJSON['error'] );
  1277. }
  1278. else
  1279. {
  1280. var thankers = $( 'thankers_' + pid );
  1281. var thankedBy = $( 'thankedBy_' + pid );
  1282. var thankersBox = $( 'thankersBox_' + pid );
  1283.  
  1284. var newLink = "<a href='" + ipb.vars['base_url'] + "showuser=" + t.responseJSON['member_id'] + "' title='" + t.responseJSON['members_display_name'] + "'>" + t.responseJSON['members_display_name'] + "</a>" + "&nbsp;<a href='" + ipb.vars['base_url'] + "showuser=" + t.responseJSON['member_id'] + "' class='__user __id" + t.responseJSON['member_id'] + "' title='{$this->lang->words['view_profile']}'>{parse replacement="user_popup"}</a>";
  1285. if ( thankersBox.getAttribute( 'title' ) == 'hidden' )
  1286. {
  1287. thankersBox.style.display = "block";
  1288.  
  1289. thankers.innerHTML = newLink;
  1290. }
  1291. else
  1292. {
  1293. ajaxThanksExpand( pid );
  1294. thankers.innerHTML = newLink + ", " + thankers.innerHTML;
  1295. }
  1296.  
  1297. if ( thankersBox.getAttribute( 'title' ) == 'hidden' )
  1298. {
  1299. thankersBox.style.display = "block";
  1300. }
  1301.  
  1302. // Update thanked by text (increment number show plural)
  1303.  
  1304. if ( thankedBy.title != '0' )
  1305. {
  1306. thankedBy.innerHTML = ipb.lang['en30_thanked_by'] + ' ' + ( parseInt( thankedBy.title ) + 1 ) + ' ' + ipb.lang['en30_users'];
  1307. }
  1308.  
  1309. // Update post content for hide hack
  1310.  
  1311. if ( t.responseJSON['post'] != "" )
  1312. {
  1313. // Editless attempt to reach the post content
  1314.  
  1315. var postDivider = $( 'post_id_' + pid ).children[1].children[2].children[1];
  1316. postDivider.innerHTML = t.responseJSON['post'];
  1317.  
  1318. new Effect.Pulsate( postDivider, { duration: 1.5, pulses: 3 } );
  1319. }
  1320.  
  1321. new Effect.Pulsate( thankersBox, { pulses: 3, duration: 1.5 } );
  1322. }
  1323. }
  1324. }
  1325. );
  1326. }
  1327.  
  1328. </script>]]></template_content>
  1329. <template_name>ajaxThanksJS</template_name>
  1330. <template_data/>
  1331. <template_updated>1311252744</template_updated>
  1332. <template_removable>1</template_removable>
  1333. <template_added_to>0</template_added_to>
  1334. <template_user_added>1</template_user_added>
  1335. <template_user_edited>1</template_user_edited>
  1336. <template_master_key>root</template_master_key>
  1337. <template_set_id>0</template_set_id>
  1338. </templates>
  1339. </hookextras_templates>
  1340. <hookextras_css/>
  1341. <hookextras_tasks/>
  1342. <hookextras_database_create/>
  1343. <hookextras_database_alter>
  1344. <alter>
  1345. <altertype>add</altertype>
  1346. <table>profile_portal</table>
  1347. <field>thanked</field>
  1348. <newfield/>
  1349. <fieldtype>int(10)</fieldtype>
  1350. <default><![CDATA['0']]></default>
  1351. </alter>
  1352. <alter>
  1353. <altertype>add</altertype>
  1354. <table>posts</table>
  1355. <field>thankers</field>
  1356. <newfield/>
  1357. <fieldtype>mediumtext</fieldtype>
  1358. <default><![CDATA['']]></default>
  1359. </alter>
  1360. </hookextras_database_alter>
  1361. <hookextras_database_update/>
  1362. <hookextras_database_insert/>
  1363. </hookexport>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement