aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-06-23 21:55:27 -0700
committerFriendika <info@friendika.com>2011-06-23 21:55:27 -0700
commit694c1c1af4ec1e19486fcb97da697cba70a9546a (patch)
tree061eba3823320e2b1ce667b80ad95b46fe2fc432
parent8ffcd4323b883b66d9249c9742fb26a5c5f91605 (diff)
downloadvolse-hubzilla-694c1c1af4ec1e19486fcb97da697cba70a9546a.tar.gz
volse-hubzilla-694c1c1af4ec1e19486fcb97da697cba70a9546a.tar.bz2
volse-hubzilla-694c1c1af4ec1e19486fcb97da697cba70a9546a.zip
new contact_selector function to provide more fine-tuned selection options.
-rw-r--r--addon/facebook/facebook.php37
-rw-r--r--include/acl_selectors.php99
2 files changed, 119 insertions, 17 deletions
diff --git a/addon/facebook/facebook.php b/addon/facebook/facebook.php
index e9290b10e..49f193804 100644
--- a/addon/facebook/facebook.php
+++ b/addon/facebook/facebook.php
@@ -43,6 +43,25 @@
define('FACEBOOK_MAXPOSTLEN', 420);
+
+function facebook_install() {
+ register_hook('post_local_end', 'addon/facebook/facebook.php', 'facebook_post_hook');
+ register_hook('jot_networks', 'addon/facebook/facebook.php', 'facebook_jot_nets');
+ register_hook('plugin_settings', 'addon/facebook/facebook.php', 'facebook_plugin_settings');
+ register_hook('cron', 'addon/facebook/facebook.php', 'facebook_cron');
+ register_hook('queue_predeliver', 'addon/facebook/facebook.php', 'fb_queue_hook');
+}
+
+
+function facebook_uninstall() {
+ unregister_hook('post_local_end', 'addon/facebook/facebook.php', 'facebook_post_hook');
+ unregister_hook('jot_networks', 'addon/facebook/facebook.php', 'facebook_jot_nets');
+ unregister_hook('plugin_settings', 'addon/facebook/facebook.php', 'facebook_plugin_settings');
+ unregister_hook('cron', 'addon/facebook/facebook.php', 'facebook_cron');
+ unregister_hook('queue_predeliver', 'addon/facebook/facebook.php', 'fb_queue_hook');
+}
+
+
/* declare the facebook_module function so that /facebook url requests will land here */
function facebook_module() {}
@@ -339,22 +358,6 @@ function facebook_content(&$a) {
return $o;
}
-function facebook_install() {
- register_hook('post_local_end', 'addon/facebook/facebook.php', 'facebook_post_hook');
- register_hook('jot_networks', 'addon/facebook/facebook.php', 'facebook_jot_nets');
- register_hook('plugin_settings', 'addon/facebook/facebook.php', 'facebook_plugin_settings');
- register_hook('cron', 'addon/facebook/facebook.php', 'facebook_cron');
- register_hook('queue_predeliver', 'addon/facebook/facebook.php', 'fb_queue_hook');
-}
-
-
-function facebook_uninstall() {
- unregister_hook('post_local_end', 'addon/facebook/facebook.php', 'facebook_post_hook');
- unregister_hook('jot_networks', 'addon/facebook/facebook.php', 'facebook_jot_nets');
- unregister_hook('plugin_settings', 'addon/facebook/facebook.php', 'facebook_plugin_settings');
- unregister_hook('cron', 'addon/facebook/facebook.php', 'facebook_cron');
- unregister_hook('queue_predeliver', 'addon/facebook/facebook.php', 'fb_queue_hook');
-}
function facebook_cron($a,$b) {
@@ -432,7 +435,7 @@ function facebook_post_hook(&$a,&$b) {
if((local_user()) && (local_user() == $b['uid'])) {
// Facebook is not considered a private network
- if($b['prvnets'])
+ if($b['prvnets'] && $b['private'])
return;
if($b['parent']) {
diff --git a/include/acl_selectors.php b/include/acl_selectors.php
index 921a8275b..c19a0f5d3 100644
--- a/include/acl_selectors.php
+++ b/include/acl_selectors.php
@@ -41,6 +41,104 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
}
+function contact_selector($selname, $selclass, $preselected = false, $options) {
+
+ $a = get_app();
+
+ $mutual = false;
+ $networks = null;
+ $single = false;
+
+ if($is_array($options)) {
+ if(x($options,'mutual_friends'))
+ $mutual = true;
+ if(x($options,'single'))
+ $single = true;
+ if(x($options,'multiple'))
+ $single = false;
+ if(x($options,'networks')) {
+ switch($options['networks']) {
+ case 'DFRN_ONLY':
+ $networks = array('dfrn');
+ break;
+ case 'PRIVATE':
+ if(is_array($a->user) && $a->user['prvnets'])
+ $networks = array('dfrn','mail','dspr');
+ else
+ $networks = array('dfrn','face','mail', 'dspr');
+ break;
+ case 'TWO_WAY':
+ if(is_array($a->user) && $a->user['prvnets'])
+ $networks = array('dfrn','mail','dspr');
+ else
+ $networks = array('dfrn','face','mail','dspr','stat');
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ $x = array('options' => $options, 'single' => $single, 'mutual' => $mutual, 'networks' => $networks);
+
+ call_hooks('contact_select_options', $x);
+
+ $o = '';
+
+ $sql_extra = '';
+
+ if($x['mutual']) {
+ $sql_extra .= sprintf(" AND `rel` = %d ", intval(REL_BUD));
+ }
+
+ if(is_array($x['networks']) && count($x['networks'])) {
+ for($y = 0; $y < count($x['networks']) ; $y ++)
+ $x['networks'][$y] = "'" . dbesc($x['networks'][$y]) . "'";
+ $str_nets = implode(',',$x['networks']);
+ $sql_extra .= " AND `network` IN ( $str_nets ) ";
+ }
+
+ if($x['single'])
+ $o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\" >\r\n";
+ else
+ $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" >\r\n";
+
+ $r = q("SELECT `id`, `name`, `url`, `network` FROM `contact`
+ WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `notify` != ''
+ $sql_extra
+ ORDER BY `name` ASC ",
+ intval(local_user())
+ );
+
+
+ $arr = array('contact' => $r, 'entry' => $o);
+
+ // e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow'
+
+ call_hooks($a->module . '_pre_' . $selname, $arr);
+
+ if(count($r)) {
+ foreach($r as $rr) {
+ if((is_array($preselected)) && in_array($rr['id'], $preselected))
+ $selected = " selected=\"selected\" ";
+ else
+ $selected = '';
+
+ $trimmed = mb_substr($rr['name'],0,20);
+
+ $o .= "<option value=\"{$rr['id']}\" $selected title=\"{$rr['name']}|{$rr['url']}\" >$trimmed</option>\r\n";
+ }
+
+ }
+
+ $o .= "</select>\r\n";
+
+ call_hooks($a->module . '_post_' . $selname, $o);
+
+ return $o;
+}
+
+
function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false) {
@@ -106,6 +204,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
return $o;
}
+
function fixacl(&$item) {
$item = intval(str_replace(array('<','>'),array('',''),$item));
}