From 219447cc53d20f69dd6c2c4eedfb0eef22adb89a Mon Sep 17 00:00:00 2001 From: tony baldwin Date: Thu, 12 Apr 2012 23:33:26 -0400 Subject: [PATCH 1/3] added admin interface for irc to set popular chans, auto connect chans --- irc/irc.css | 15 +++++++++ irc/irc.php | 74 +++++++++++++++++++++++++++++++++++++-------- planets/planets.php | 9 +----- 3 files changed, 77 insertions(+), 21 deletions(-) create mode 100644 irc/irc.css diff --git a/irc/irc.css b/irc/irc.css new file mode 100644 index 00000000..76aa2159 --- /dev/null +++ b/irc/irc.css @@ -0,0 +1,15 @@ +/* irc css */ +#irc-chans, { + float: left; + width: 200px; + margin-top: 10px; +} + +#irc-checkbox { + float: left; + margin-top: 10px; +} + +#irc-submit { + margin-top: 15px; +} diff --git a/irc/irc.php b/irc/irc.php index 065e4808..1ce4ee14 100644 --- a/irc/irc.php +++ b/irc/irc.php @@ -10,17 +10,66 @@ * you will then have "irc chatroom" listed at yoursite/apps * and the app will run at yoursite/irc * documentation at http://tonybaldwin.me/hax/doku.php?id=friendica:irc + * admin can set popular chans, auto connect chans in settings->plugin settings */ function irc_install() { -register_hook('app_menu', 'addon/irc/irc.php', 'irc_app_menu'); + register_hook('app_menu', 'addon/irc/irc.php', 'irc_app_menu'); + register_hook('plugin_settings', 'addon/irc/irc.php', 'irc_addon_settings'); + register_hook('plugin_settings_post', 'addon/irc/irc.php', 'irc_addon_settings_post'); } function irc_uninstall() { -unregister_hook('app_menu', 'addon/irc/irc.php', 'irc_app_menu'); + unregister_hook('app_menu', 'addon/irc/irc.php', 'irc_app_menu'); + unregister_hook('plugin_settings', 'addon/irc/irc.php', 'irc_addon_settings'); } + +function irc_addon_settings(&$a,&$s) { + + + if(! is_site_admin()) + return; + + /* Add our stylesheet to the page so we can make our settings look nice */ + + $a->page['htmlhead'] .= '' . "\r\n"; + + /* setting popular channels, auto connect channels */ + $sitechats = get_config('irc','sitechats'); /* popular channels */ + $autochans = get_config('irc','autochans'); /* auto connect chans */ + + $s .= '
'; + $s .= '

' . t('IRC Settings') . '

'; + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + $s .= '
'; + + return; + +} + +function irc_addon_settings_post(&$a,&$b) { + if(! is_site_admin()) + return; + + if($_POST['irc-submit']) { + set_config('irc','autochans',trim($_POST['autochans'])); + set_config('irc','sitechats',trim($_POST['sitechats'])); + /* stupid pop-up thing */ + info( t('IRC settings saved.') . EOL); + } +} + function irc_app_menu($a,&$b) { $b['app_menu'][] = '
' . t('IRC Chatroom') . '
'; } @@ -36,11 +85,12 @@ function irc_content(&$a) { $baseurl = $a->get_baseurl() . '/addon/irc'; $o = ''; - $sitechats = get_config('irc','channels'); + /* set the list of popular channels */ + $sitechats = get_config('irc','sitechats'); if($sitechats) $chats = explode(',',$sitechats); else - $chats = array('friendica','chat','chatback','hottub','ircbar','dateroom','teentalk'); + $chats = array('friendica','chat','chatback','hottub','ircbar','dateroom','debian'); $a->page['aside'] .= '

' . t('Popular Channels') . '

'; + /* setting the channel(s) to auto connect */ + $autochans = get_config('irc','autochans'); + if($autochans) + $channels = $autochans; + else + $channels = ((x($_GET,'channels')) ? $_GET['channels'] : 'friendica'); - - - -$channels = ((x($_GET,'channels')) ? $_GET['channels'] : 'friendica'); - -/* add the chatroom frame and some html - * by altering the "channels=friendica" part of the URL, you can add/remove channels. - * At free-haven.org, I have "?channels=friendica,free-haven", for instance, to open #friendica and #free-haven - */ +/* add the chatroom frame and some html */ $o .= <<< EOT

IRC chat

A beginner's guide to using IRC. [en]

diff --git a/planets/planets.php b/planets/planets.php index 1c6ed43b..d1b59eeb 100755 --- a/planets/planets.php +++ b/planets/planets.php @@ -108,14 +108,7 @@ function planets_post_hook($a, &$item) { */ $planets = array('Alderaan','Tatooine','Dagoba','Polis Massa','Coruscant','Hoth','Endor','Kamino','Rattatak','Mustafar','Iego','Geonosis','Felucia','Dantooine','Ansion','Artaru','Bespin','Boz Pity','Cato Neimoidia','Christophsis','Kashyyk','Kessel','Malastare','Mygeeto','Nar Shaddaa','Ord Mantell','Saleucami','Subterrel','Death Star','Teth','Tund','Utapau','Yavin'); -# $zones = timezone_identifiers_list(); -# foreach($zones as $zone) { -# if((strpos($zone,'/')) && (! stristr($zone,'US/')) && (! stristr($zone,'Etc/'))) -# $planets[] = str_replace('_', ' ',substr($zone,strpos($zone,'/') + 1)); -# } -# -# if(! count($planets)) -# return; + $planet = array_rand($planets,1); $item['location'] = $planets[$planet]; From e816b3bb18057855747bd70c0edafb60b5fdc73a Mon Sep 17 00:00:00 2001 From: tony baldwin Date: Thu, 12 Apr 2012 23:35:27 -0400 Subject: [PATCH 2/3] clean up clean up everybody everywhere... --- planets/planets.php | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/planets/planets.php b/planets/planets.php index d1b59eeb..0df91d7c 100755 --- a/planets/planets.php +++ b/planets/planets.php @@ -4,22 +4,7 @@ * Description: Sample Friendica plugin/addon. Set a random planet from the Emprire when posting. * Version: 1.0 * Author: Mike Macgirvin - * Author: Darth Baldwin - * - * - * - * - * Addons are registered with the system in the - * .htconfig.php file. - * - * $a->config['system']['addon'] = 'plugin1,plugin2,etc.'; - * - * When registration is detected, the system calls the plugin - * name_install() function, located in 'addon/name/name.php', - * where 'name' is the name of the addon. - * If the addon is removed from the configuration list, the - * system will call the name_uninstall() function. - * + * Author: Tony Baldwin */ From 27134d4b5751d1d0b5c3a11737d9abdd763e622a Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Apr 2012 21:19:09 -0700 Subject: [PATCH 3/3] package update --- irc.tgz | Bin 1117 -> 1697 bytes planets.tgz | Bin 2346 -> 2090 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/irc.tgz b/irc.tgz index cb86460599f429d1304f82ec46525225d70f591f..a07e38ee95da2f3cdafbd0180ba32b798bb023da 100644 GIT binary patch literal 1697 zcmV;S2449eiwFQPsfSMh1MOJrZ`(Ey_gDL`xM@b^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