]> git.mxchange.org Git - friendica.git/commitdiff
community discovery cont., cleanup of DB debugging
authorfriendica <info@friendica.com>
Mon, 19 Mar 2012 05:12:36 +0000 (22:12 -0700)
committerfriendica <info@friendica.com>
Mon, 19 Mar 2012 05:12:36 +0000 (22:12 -0700)
include/dba.php
include/delivery.php
include/items.php
include/notifier.php
include/poller.php
mod/dfrn_poll.php
view/atom_feed.tpl
view/atom_feed_dfrn.tpl

index 7455b6b3ee2c8053a1f45937e2196062554104d5..5beea7a3acad8a642a9df15549c729ddcabe7ff1 100755 (executable)
@@ -1,5 +1,7 @@
 <?php
 
+require_once('include/datetime.php');
+
 /**
  *
  * MySQL database class
@@ -104,19 +106,17 @@ class dba {
 
                        logger('dba: ' . $str );
                }
-               else {
 
-                       /**
-                        * If dbfail.out exists, we will write any failed calls directly to it,
-                        * regardless of any logging that may or may nor be in effect.
-                        * These usually indicate SQL syntax errors that need to be resolved.
-                        */
+               /**
+                * If dbfail.out exists, we will write any failed calls directly to it,
+                * regardless of any logging that may or may nor be in effect.
+                * These usually indicate SQL syntax errors that need to be resolved.
+                */
 
-                       if($result === false) {
-                               logger('dba: ' . printable($sql) . ' returned false.');
-                               if(file_exists('dbfail.out'))
-                                       file_put_contents('dbfail.out', printable($sql) . ' returned false' . "\n", FILE_APPEND);
-                       }
+               if($result === false) {
+                       logger('dba: ' . printable($sql) . ' returned false.');
+                       if(file_exists('dbfail.out'))
+                               file_put_contents('dbfail.out', datetime_convert() . "\n" . printable($sql) . ' returned false' . "\n", FILE_APPEND);
                }
 
                if(($result === true) || ($result === false))
@@ -140,7 +140,7 @@ class dba {
 
     
                if($this->debug)
-                       logger('dba: ' . printable(print_r($r, true)), LOGGER_DATA);
+                       logger('dba: ' . printable(print_r($r, true)));
                return($r);
        }
 
index 44a482ca28945368718d0c1be408a6f88df35ca4..532dcd6991a551c5e84130e0ae2322c76873d6ec 100755 (executable)
@@ -256,7 +256,8 @@ function delivery_run($argv, $argc){
                                        '$picdate'      => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , ATOM_TIME)) ,
                                        '$uridate'      => xmlify(datetime_convert('UTC','UTC',$owner['uri-date']    . '+00:00' , ATOM_TIME)) ,
                                        '$namdate'      => xmlify(datetime_convert('UTC','UTC',$owner['name-date']   . '+00:00' , ATOM_TIME)) ,
-                                       '$birthday'     => $birthday
+                                       '$birthday'     => $birthday,
+                                       '$community'    => (($owner['page-flags'] == PAGE_COMMUNITY) ? '<dfrn:community>1</dfrn:community>' : '')
                        ));
 
                        foreach($items as $item) {
index 5e1fec55785d55e41611a439ee93f4e0de8e0c93..5a297c83ef5422690bf2eb542861025fd0c33e6f 100755 (executable)
@@ -28,7 +28,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
 
        $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid`  = '' AND `deny_gid`  = '' ";
 
-       $r = q("SELECT `contact`.*, `user`.`uid` AS `user_uid`, `user`.`nickname`, `user`.`timezone`
+       $r = q("SELECT `contact`.*, `user`.`uid` AS `user_uid`, `user`.`nickname`, `user`.`timezone`, `user`.`page-flags`
                FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
                WHERE `contact`.`self` = 1 AND `user`.`nickname` = '%s' LIMIT 1",
                dbesc($owner_nick)
@@ -156,7 +156,8 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
                '$picdate'      => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , ATOM_TIME)) ,
                '$uridate'      => xmlify(datetime_convert('UTC','UTC',$owner['uri-date']    . '+00:00' , ATOM_TIME)) ,
                '$namdate'      => xmlify(datetime_convert('UTC','UTC',$owner['name-date']   . '+00:00' , ATOM_TIME)) , 
-               '$birthday'     => ((strlen($birthday)) ? '<dfrn:birthday>' . xmlify($birthday) . '</dfrn:birthday>' : '')
+               '$birthday'     => ((strlen($birthday)) ? '<dfrn:birthday>' . xmlify($birthday) . '</dfrn:birthday>' : ''),
+               '$community'    => (($owner['page-flags'] == PAGE_COMMUNITY) ? '<dfrn:community>1</dfrn:community>' : '')
        ));
 
        call_hooks('atom_feed', $atom);
@@ -1404,6 +1405,19 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
 
        }
 
+       $community_page = 0;
+       $rawtags = $feed->get_feed_tags( NAMESPACE_DFRN, 'community');
+       if($rawtags) {
+               $community_page = intval($rawtags[0]['data']);
+       }
+       if(is_array($contact) && intval($contact['forum']) != $community_page) {
+               q("update contact set forum = %d where id = %d limit 1",
+                       intval($community_page),
+                       intval($contact['id'])
+               );
+               $contact['forum'] = (string) $community_page;
+       }
+
 
        // process any deleted entries
 
@@ -1987,6 +2001,19 @@ function local_delivery($importer,$data) {
 
                // NOTREACHED
        }       
+
+       $community_page = 0;
+       $rawtags = $feed->get_feed_tags( NAMESPACE_DFRN, 'community');
+       if($rawtags) {
+               $community_page = intval($rawtags[0]['data']);
+       }
+       if(intval($importer['forum']) != $community_page) {
+               q("update contact set forum = %d where id = %d limit 1",
+                       intval($community_page),
+                       intval($importer['id'])
+               );
+               $importer['forum'] = (string) $community_page;
+       }
        
        logger('local_delivery: feed item count = ' . $feed->get_item_quantity());
 
index 07edc70465a07b7dfb3f828b62b8d7a54e01ec75..d63ad7ae7cceba578572595d34ecad8d3a640107 100755 (executable)
@@ -337,7 +337,9 @@ function notifier_run($argv, $argc){
                        '$picdate'      => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , ATOM_TIME)) ,
                        '$uridate'      => xmlify(datetime_convert('UTC','UTC',$owner['uri-date']    . '+00:00' , ATOM_TIME)) ,
                        '$namdate'      => xmlify(datetime_convert('UTC','UTC',$owner['name-date']   . '+00:00' , ATOM_TIME)) ,
-                       '$birthday'     => $birthday
+                       '$birthday'     => $birthday,
+                       '$community'    => (($owner['page-flags'] == PAGE_COMMUNITY) ? '<dfrn:community>1</dfrn:community>' : '')
+
        ));
 
        if($mail) {
index 3bc98e36ff2f479ca53dec54eefd63186381f357..8262c1d605242b0cd7122fb3eec94d5e06e6c181 100755 (executable)
@@ -232,7 +232,7 @@ function poller_run($argv, $argc){
 
                        $importer_uid = $contact['uid'];
                
-                       $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
+                       $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` LEFT JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
                                intval($importer_uid)
                        );
                        if(! count($r))
index b12e0713285a2b59ebe595558a8a69e1f9a4e6a9..fe5cd49063ee0dee05dcdfe3f868077b1e960b2b 100755 (executable)
@@ -199,7 +199,7 @@ function dfrn_poll_post(&$a) {
        $ptype        = ((x($_POST,'type'))         ? $_POST['type']                 : '');
        $dfrn_version = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version'] : 2.0);
        $perm         = ((x($_POST,'perm'))         ? $_POST['perm']                 : 'r');
-
+          
        if($ptype === 'profile-check') {
 
                if((strlen($challenge)) && (strlen($sec))) {
@@ -358,8 +358,8 @@ function dfrn_poll_post(&$a) {
                                        intval($contact_id)
                                );
                        }
-               }                               
-
+               }
+                               
                header("Content-type: application/atom+xml");
                $o = get_feed_for($a,$dfrn_id, $a->argv[1], $last_update, $direction);
                echo $o;
index 72cf8e4fd8a828004542590db10d3acded5438b7..2feb547ee2ab4750a35c8327166c36354a4f11eb 100755 (executable)
@@ -16,6 +16,7 @@
   <link rel="license" href="http://creativecommons.org/licenses/by/3.0/" />
   $hub
   $salmon
+  $community
 
   <updated>$feed_updated</updated>
 
index 3d6bcc5b5acc1a4d77d215fa37cb06a211c5a9a7..0bae62b526af65261ba68fb27a99d62fbdf6ecea 100755 (executable)
 
   <id>$feed_id</id>
   <title>$feed_title</title>
-  <generator uri="http://friendika.com" version="$version">Friendika</generator>
+  <generator uri="http://friendica.com" version="$version">Friendica</generator>
   <link rel="license" href="http://creativecommons.org/licenses/by/3.0/" />
   $hub
   $salmon
+  $community
 
   <updated>$feed_updated</updated>