]> git.mxchange.org Git - friendica.git/commitdiff
suggestion notifications
authorfriendica <info@friendica.com>
Wed, 4 Jan 2012 01:29:07 +0000 (17:29 -0800)
committerfriendica <info@friendica.com>
Wed, 4 Jan 2012 01:29:07 +0000 (17:29 -0800)
boot.php
include/conversation.php
include/enotify.php
include/items.php
mod/settings.php
view/settings.tpl

index 619a3fead6376d1fac9aa4f5dd02a6519abbbeef..df9daf4835b170c581c2875ee62c65da02e1dbbf 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -127,6 +127,9 @@ define ( 'NOTIFY_CONFIRM', 0x0002 );
 define ( 'NOTIFY_WALL',    0x0004 );
 define ( 'NOTIFY_COMMENT', 0x0008 );
 define ( 'NOTIFY_MAIL',    0x0010 );
+define ( 'NOTIFY_SUGGEST', 0x0020 );
+define ( 'NOTIFY_PROFILE', 0x0040 );
+
 
 /**
  * various namespaces we may need to parse
index 1b1d09d6b57c7c2f377d50262db143813c00d7d4..a30a782718dd0ad405cbd3af6639e10577a61b01 100644 (file)
@@ -902,29 +902,35 @@ function conv_sort($arr,$order) {
        elseif(stristr($order,'commented'))
                usort($parents,'sort_thr_commented');
 
-       foreach($parents as $x) 
-               $x['children'] = array();
+       if(count($parents))
+               foreach($parents as $x) 
+                       $x['children'] = array();
 
        foreach($arr as $x) {
                if($x['id'] != $x['parent']) {
                        $p = find_thread_parent_index($parents,$x);
-                       $parents[$p]['children'][] = $x;
+                       if($p !== false)
+                               $parents[$p]['children'][] = $x;
                }
        }
-       foreach($parents as $k => $v) {
-               if(count($parents[$k]['children'])) {
-                       $y = $parents[$k]['children'];
-                       usort($y,'sort_thr_created_rev');
-                       $parents[$k]['children'] = $y;
-               }
+       if(count($parents)) {
+               foreach($parents as $k => $v) {
+                       if(count($parents[$k]['children'])) {
+                               $y = $parents[$k]['children'];
+                               usort($y,'sort_thr_created_rev');
+                               $parents[$k]['children'] = $y;
+                       }
+               }       
        }
 
        $ret = array();
-       foreach($parents as $x) {
-               $ret[] = $x;
-               if(count($x['children']))
-                       foreach($x['children'] as $y)
-                               $ret[] = $y;
+       if(count($parents)) {
+               foreach($parents as $x) {
+                       $ret[] = $x;
+                       if(count($x['children']))
+                               foreach($x['children'] as $y)
+                                       $ret[] = $y;
+               }
        }
 
        return $ret;
@@ -947,4 +953,5 @@ function find_thread_parent_index($arr,$x) {
        foreach($arr as $k => $v)
                if($v['id'] == $x['parent'])
                        return $k;
+       return false;
 }
\ No newline at end of file
index f6f291e5d45be663ffa47523c997eb9652b681e3..9df9b57e5d8d2dc62b670d0e3a5db3447ea5af6a 100644 (file)
@@ -65,6 +65,19 @@ function notification($params) {
                $itemlink =  $params['link'];
        }
 
+       if($params['type'] == NOTIFY_SUGGEST) {
+               $subject = sprintf( t('Friend suggestion received at %s'), $sitename);
+               $preamble = sprintf( t('You\'ve received a friend suggestion from \'%s\' at %s'), $params['source_name'], $sitename); 
+               $body = t('Name:') . ' ' . $params['item']['name'] . "\n";
+               $body .= t('Photo:') . ' ' . $params['item']['photo'] . "\n";
+               $body .= sprintf( t('You may visit their profile at %s'),$params['item']['url']);
+
+               $sitelink = t('Please visit %s to approve or reject the suggestion.');
+               $tsitelink = sprintf( $sitelink, $siteurl );
+               $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
+               $itemlink =  $params['link'];
+       }
+
        if($params['type'] == NOTIFY_CONFIRM) {
 
        }
index 7f003ab5750c34665a4de81e401b39d4b4e68ec5..9f006306f8e37b7b9a7eae93dec95e256e43d6e4 100644 (file)
@@ -1788,7 +1788,18 @@ function local_delivery($importer,$data) {
                        intval(0)
                );
 
-               // TODO - send email notify (which may require a new notification preference)
+               notification(array(
+                       'type'         => NOTIFY_SUGGEST,
+                       'notify_flags' => $importer['notify-flags'],
+                       'language'     => $importer['language'],
+                       'to_name'      => $importer['username'],
+                       'to_email'     => $importer['email'],
+                       'item'         => $fsugg,
+                       'link'         => $a->get_baseurl() . '/notifications/intros',
+                       'source_name'  => $importer['name'],
+                       'source_link'  => $importer['url'],
+                       'source_photo' => $importer['photo']
+               ));
 
                return 0;
        }
index 35902f831a7bc1a52fde17e8237a15fb32935750..8ca0bb7f811c16ef606c963e976b9571c2dddf2a 100644 (file)
@@ -255,6 +255,10 @@ function settings_post(&$a) {
                $notify += intval($_POST['notify4']);
        if(x($_POST,'notify5'))
                $notify += intval($_POST['notify5']);
+       if(x($_POST,'notify6'))
+               $notify += intval($_POST['notify6']);
+       if(x($_POST,'notify7'))
+               $notify += intval($_POST['notify7']);
 
        $email_changed = false;
 
@@ -807,7 +811,7 @@ function settings_content(&$a) {
                '$notify3'      => array('notify3', t('Someone writes on your profile wall'), ($notify & NOTIFY_WALL), NOTIFY_WALL, ''),
                '$notify4'      => array('notify4', t('Someone writes a followup comment'), ($notify & NOTIFY_COMMENT), NOTIFY_COMMENT, ''),
                '$notify5'      => array('notify5', t('You receive a private message'), ($notify & NOTIFY_MAIL), NOTIFY_MAIL, ''),
-               
+               '$notify6'  => array('notify6', t('You receive a friend suggestion'), ($notify & NOTIFY_SUGGEST), NOTIFY_SUGGEST, ''),          
                
                
                '$h_advn' => t('Advanced Page Settings'),
index e15976581ba27df3f05f3000c0f5b28671c35309..6310ff47e8f7f45ea2b9036656a1cdb937970403 100644 (file)
@@ -107,6 +107,7 @@ $suggestme
 {{inc field_intcheckbox.tpl with $field=$notify3 }}{{endinc}}
 {{inc field_intcheckbox.tpl with $field=$notify4 }}{{endinc}}
 {{inc field_intcheckbox.tpl with $field=$notify5 }}{{endinc}}
+{{inc field_intcheckbox.tpl with $field=$notify6 }}{{endinc}}
 </div>