6 * Description: block people
8 * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
12 function superblock_install() {
14 register_hook('plugin_settings', 'addon/superblock/superblock.php', 'superblock_addon_settings');
15 register_hook('plugin_settings_post', 'addon/superblock/superblock.php', 'superblock_addon_settings_post');
16 register_hook('conversation_start', 'addon/superblock/superblock.php', 'superblock_conversation_start');
17 register_hook('item_photo_menu', 'addon/superblock/superblock.php', 'superblock_item_photo_menu');
18 register_hook('enotify_store', 'addon/superblock/superblock.php', 'superblock_enotify_store');
23 function superblock_uninstall() {
25 unregister_hook('plugin_settings', 'addon/superblock/superblock.php', 'superblock_addon_settings');
26 unregister_hook('plugin_settings_post', 'addon/superblock/superblock.php', 'superblock_addon_settings_post');
27 unregister_hook('conversation_start', 'addon/superblock/superblock.php', 'superblock_conversation_start');
28 unregister_hook('item_photo_menu', 'addon/superblock/superblock.php', 'superblock_item_photo_menu');
29 unregister_hook('enotify_store', 'addon/superblock/superblock.php', 'superblock_enotify_store');
37 function superblock_addon_settings(&$a,&$s) {
42 /* Add our stylesheet to the page so we can make our settings look nice */
44 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/superblock/superblock.css' . '" media="all" />' . "\r\n";
47 $words = get_pconfig(local_user(),'system','blocked');
51 $s .= '<div class="settings-block">';
52 $s .= '<h3>' . t('"Superblock" Settings') . '</h3>';
53 $s .= '<div id="superblock-wrapper">';
54 $s .= '<label id="superblock-label" for="superblock-words">' . t('Comma separated profile URLS to block') . ' </label>';
55 $s .= '<textarea id="superblock-words" type="text" name="superblock-words" >' . htmlspecialchars($words) . '</textarea>';
56 $s .= '</div><div class="clear"></div>';
58 $s .= '<div class="settings-submit-wrapper" ><input type="submit" id="superblock-submit" name="superblock-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
64 function superblock_addon_settings_post(&$a,&$b) {
69 if($_POST['superblock-submit']) {
70 set_pconfig(local_user(),'system','blocked',trim($_POST['superblock-words']));
71 info( t('SUPERBLOCK Settings saved.') . EOL);
75 function superblock_enotify_store(&$a,&$b) {
77 $words = get_pconfig($b['uid'],'system','blocked');
79 $arr = explode(',',$words);
87 foreach($arr as $word) {
88 if(! strlen(trim($word))) {
92 if(link_compare($b['url'],$word)) {
104 function superblock_conversation_start(&$a,&$b) {
109 $words = get_pconfig(local_user(),'system','blocked');
111 $a->data['superblock'] = explode(',',$words);
113 $a->page['htmlhead'] .= <<< EOT
116 function superblockBlock(author) {
117 $.get('superblock?block=' +author, function(data) {
118 location.reload(true);
127 function superblock_item_photo_menu(&$a,&$b) {
129 if((! local_user()) || ($b['item']['self']))
133 $author = $b['item']['author-link'];
134 if(is_array($a->data['superblock'])) {
135 foreach($a->data['superblock'] as $bloke) {
136 if(link_compare($bloke,$author)) {
143 $b['menu'][ t('Block Completely')] = 'javascript:superblockBlock(\'' . $author . '\'); return false;';
146 function superblock_module() {}
149 function superblock_init(&$a) {
154 $words = get_pconfig(local_user(),'system','blocked');
156 if(array_key_exists('block',$_GET) && $_GET['block']) {
159 $words .= trim($_GET['block']);
162 set_pconfig(local_user(),'system','blocked',$words);
163 info( t('superblock settings updated') . EOL );