]> git.mxchange.org Git - friendica-addons.git/blob - qcomment/qcomment.php
qcomment addon
[friendica-addons.git] / qcomment / qcomment.php
1 <?php
2
3
4 /**
5  * Name: Quick Comment
6  * Description: Two click comments
7  * Version: 1.0
8  * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
9  * 
10  */
11
12 function qcomment_install() {
13         register_hook('plugin_settings', 'addon/qcomment/qcomment.php', 'qcomment_addon_settings');
14         register_hook('plugin_settings_post', 'addon/qcomment/qcomment.php', 'qcomment_addon_settings_post');
15
16 }
17
18
19 function qcomment_uninstall() {
20         unregister_hook('plugin_settings', 'addon/qcomment/qcomment.php', 'qcomment_addon_settings');
21         unregister_hook('plugin_settings_post', 'addon/qcomment/qcomment.php', 'qcomment_addon_settings_post');
22
23 }
24
25
26
27
28
29 function qcomment_addon_settings(&$a,&$s) {
30
31         if(! local_user())
32                 return;
33
34     /* Add our stylesheet to the page so we can make our settings look nice */
35
36     $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/qcomment/qcomment.css' . '" media="all" />' . "\r\n";
37
38         $words = get_pconfig(local_user(),'qcomment','words');
39         if($words === false)
40                 $words = t(':-)') . "\n" . t(':-(') . "\n" .  t('lol');
41
42     $s .= '<div class="settings-block">';
43     $s .= '<h3>' . t('Quick Comment Settings') . '</h3>';
44     $s .= '<div id="qcomment-wrapper">';
45     $s .= '<label id="qcomment-label" for="qcomment-words">' . t('Enter quick comments, one per line') . ' </label>';
46     $s .= '<textarea id="qcomment-words" type="text" name="qcomment-words" >' . htmlspecialchars(unxmlify($words)) . '</textarea>';
47     $s .= '</div><div class="clear"></div>';
48
49     $s .= '<div class="settings-submit-wrapper" ><input type="submit" id="qcomment-submit" name="qcomment-submit" class="settings-submit" value="' . t('Submit') . '" /></div>';
50         $s .= '</div>';
51
52         return;
53
54 }
55
56 function qcomment_addon_settings_post(&$a,&$b) {
57
58         if(! local_user())
59                 return;
60
61         if($_POST['qcomment-submit']) {
62                 set_pconfig(local_user(),'qcomment','words',xmlify($_POST['qcomment-words']));
63                 info( t('Quick Comment settings saved.') . EOL);
64         }
65 }
66