]> git.mxchange.org Git - friendica.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorMichael Vogel <icarus@dabo.de>
Sun, 5 Jan 2014 15:22:42 +0000 (16:22 +0100)
committerMichael Vogel <icarus@dabo.de>
Sun, 5 Jan 2014 15:22:42 +0000 (16:22 +0100)
Conflicts:
mod/crepair.php

13 files changed:
1  2 
boot.php
include/api.php
include/conversation.php
include/ostatus_conversation.php
library/slinky.php
mod/contacts.php
mod/crepair.php
mod/parse_url.php
mods/readme.txt
view/templates/crepair.tpl
view/theme/vier/style.css
view/theme/vier/templates/threaded_conversation.tpl
view/theme/vier/templates/wall_thread.tpl

diff --combined boot.php
index 72eaec8fe58db17bb87739926067901bb4e65202,035550463656819b29506e83bc7efed00d939156..9264d34fc0df93b3e9c3121964a1d99459513aea
+++ b/boot.php
@@@ -12,9 -12,9 +12,9 @@@ require_once('library/Mobile_Detect/Mob
  require_once('include/features.php');
  
  define ( 'FRIENDICA_PLATFORM',     'Friendica');
- define ( 'FRIENDICA_VERSION',      '3.2.1745' );
+ define ( 'FRIENDICA_VERSION',      '3.2.1747' );
  define ( 'DFRN_PROTOCOL_VERSION',  '2.23'    );
 -define ( 'DB_UPDATE_VERSION',      1167      );
 +define ( 'DB_UPDATE_VERSION',      1169      );
  define ( 'EOL',                    "<br />\r\n"     );
  define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
  
@@@ -197,7 -197,6 +197,7 @@@ define ( 'NOTIFY_PROFILE',  0x0040 )
  define ( 'NOTIFY_TAGSELF',  0x0080 );
  define ( 'NOTIFY_TAGSHARE', 0x0100 );
  define ( 'NOTIFY_POKE',     0x0200 );
 +define ( 'NOTIFY_SHARE',    0x0400 );
  
  define ( 'NOTIFY_SYSTEM',   0x8000 );
  
@@@ -396,9 -395,6 +396,9 @@@ if(! class_exists('App')) 
                // array of instanced template engines ('name'=>'instance')
                public $template_engine_instance = array();
  
 +              // Used for reducing load to the ostatus completion
 +              public $last_ostatus_conversation_url;
 +
                private $ldelim = array(
                        'internal' => '',
                        'smarty3' => '{{'
diff --combined include/api.php
index 3d8ecb35d30a9c8a8795c4e7e2f687e17805b196,c6d29c47a54d27e779562e137f56ba7d5e118af9..9c3bb15244aa7d33366adffdf79b0a98805f1326
@@@ -1,6 -1,7 +1,6 @@@
  <?php
  /* To-Do:
   - Automatically detect if incoming data is HTML or BBCode
 - - search for usernames should first search friendica, then the other open networks, then the closed ones
  */
        require_once("include/bbcode.php");
        require_once("include/datetime.php");
@@@ -74,7 -75,7 +74,7 @@@
                        logger('API_login: ' . print_r($_SERVER,true), LOGGER_DEBUG);
                        header('WWW-Authenticate: Basic realm="Friendica"');
                        header('HTTP/1.0 401 Unauthorized');
-                       die((api_error(&$a, 'json', "This api requires login")));
+                       die((api_error($a, 'json', "This api requires login")));
  
                        //die('This api requires login');
                }
                }
                header("HTTP/1.1 404 Not Found");
                logger('API call not implemented: '.$a->query_string." - ".print_r($_REQUEST,true));
-               return(api_error(&$a, $type, "not implemented"));
+               return(api_error($a, $type, "not implemented"));
  
        }
  
                $url = "";
                $nick = "";
  
 +              logger("api_get_user: Fetching user data for user ".$contact_id, LOGGER_DEBUG);
 +
                // Searching for contact URL
                if(!is_null($contact_id) AND (intval($contact_id) == 0)){
                        $user = dbesc(normalise_link($contact_id));
                                $user
                );
  
 +              // Selecting the id by priority, friendica first
 +              api_best_nickname($uinfo);
 +
                // if the contact wasn't found, fetch it from the unique contacts
                if (count($uinfo)==0) {
                        $r = array();
                                        'uid' => 0,
                                        'cid' => 0,
                                        'self' => 0,
 +                                      'network' => '',
                                );
  
                                return $ret;
                        );
  
                        // count public wall messages
 -                      $r = q("SELECT COUNT(`id`) as `count` FROM `item`
 +                      $r = q("SELECT COUNT(`id`) as `count` FROM `item` USE INDEX (uid, type)
                                        WHERE  `uid` = %d
                                        AND `type`='wall'
                                        AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`=''",
                        'uid' => intval($uinfo[0]['uid']),
                        'cid' => intval($uinfo[0]['cid']),
                        'self' => $uinfo[0]['self'],
 +                      'network' => $uinfo[0]['network'],
                );
  
                return $ret;
                unset($_REQUEST["user_id"]);
                unset($_GET["user_id"]);
  
 +              unset($_REQUEST["screen_name"]);
 +              unset($_GET["screen_name"]);
 +
 +              $skip_status = (x($_REQUEST,'skip_status')?$_REQUEST['skip_status']:false);
 +
                $user_info = api_get_user($a);
  
                // "verified" isn't used here in the standard
                unset($user_info["verified"]);
  
                // - Adding last status
 -              $user_info["status"] = api_status_show($a,"raw");
 -              if (!count($user_info["status"]))
 -                      unset($user_info["status"]);
 -              else
 -                      unset($user_info["status"]["user"]);
 +              if (!$skip_status) {
 +                      $user_info["status"] = api_status_show($a,"raw");
 +                      if (!count($user_info["status"]))
 +                              unset($user_info["status"]);
 +                      else
 +                              unset($user_info["status"]["user"]);
 +              }
  
                // "cid", "uid" and "self" are only needed for some internal stuff, so remove it from here
                unset($user_info["cid"]);
                return api_status_show($a,$type);
        }
        api_register_func('api/statuses/update','api_statuses_update', true);
 +      api_register_func('api/statuses/update_with_media','api_statuses_update', true);
  
  
        function api_status_show(&$a, $type){
                unset($_REQUEST["user_id"]);
                unset($_GET["user_id"]);
  
 +              unset($_REQUEST["screen_name"]);
 +              unset($_GET["screen_name"]);
 +
                $user_info = api_get_user($a);
                // get last newtork messages
  
                unset($_REQUEST["user_id"]);
                unset($_GET["user_id"]);
  
 +              unset($_REQUEST["screen_name"]);
 +              unset($_GET["screen_name"]);
 +
                $user_info = api_get_user($a);
                // get last newtork messages
  
                if ($user_info['self']==0) {
                        $ret = array();
                } else {
 +                      $sql_extra = "";
  
                        // params
 +                      $since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
 +                      $max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_id']:0);
                        $count = (x($_GET,'count')?$_GET['count']:20);
                        $page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
                        if ($page<0) $page=0;
  
                        $start = $page*$count;
  
 +                      if ($max_id > 0)
 +                              $sql_extra .= ' AND `item`.`id` <= '.intval($max_id);
 +
                        $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
                                `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
                                `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
                                AND `contact`.`id` = `item`.`contact-id`
                                AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
                                $sql_extra
 +                              AND `item`.`id`>%d
                                ORDER BY `item`.`received` DESC LIMIT %d ,%d ",
                                //intval($user_info['uid']),
                                intval(api_user()),
 +                              intval($since_id),
                                intval($start), intval($count)
                        );
  
                if (api_user()===false) return false;
                $user_info = api_get_user($a);
  
 -
 -              // friends and followers only for self
 -              if ($user_info['self']==0){
 -                      return false;
 -              }
 -
                if (x($_GET,'cursor') && $_GET['cursor']=='undefined'){
                        /* this is to stop Hotot to load friends multiple times
                        *  I'm not sure if I'm missing return something or
                if($qtype == 'followers')
                        $sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_FOLLOWER), intval(CONTACT_IS_FRIEND));
  
 -              $r = q("SELECT id FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 $sql_extra",
 +              // friends and followers only for self
 +              if ($user_info['self'] == 0)
 +                      $sql_extra = " AND false ";
 +
 +              $r = q("SELECT `nurl` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 $sql_extra",
                        intval(api_user())
                );
  
                $ret = array();
                foreach($r as $cid){
 -                      $user =  api_get_user($a, $cid['id']);
 +                      $user = api_get_user($a, $cid['nurl']);
                        // "cid", "uid" and "self" are only needed for some internal stuff, so remove it from here
                        unset($user["cid"]);
                        unset($user["uid"]);
                                $ret[] = $user;
                }
  
 -
                return array('$users' => $ret);
  
        }
                if(! api_user())
                        return false;
  
 +              $user_info = api_get_user($a);
 +
                if($qtype == 'friends')
                        $sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
                if($qtype == 'followers')
                        $sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_FOLLOWER), intval(CONTACT_IS_FRIEND));
  
 +              if (!$user_info["self"])
 +                      $sql_extra = " AND false ";
 +
 +              $stringify_ids = (x($_REQUEST,'stringify_ids')?$_REQUEST['stringify_ids']:false);
  
                $r = q("SELECT unique_contacts.id FROM contact, unique_contacts WHERE contact.nurl = unique_contacts.url AND `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 $sql_extra",
                        intval(api_user())
                        elseif($type === 'json') {
                                $ret = array();
                                header("Content-type: application/json");
 -                              foreach($r as $rr) $ret[] = $rr['id'];
 +                              foreach($r as $rr)
 +                                      if ($stringify_ids)
 +                                              $ret[] = $rr['id'];
 +                                      else
 +                                              $ret[] = intval($rr['id']);
 +
                                echo json_encode($ret);
                                killme();
                        }
                require_once("include/message.php");
  
                if ($_POST['screen_name']) {
 -                      $r = q("SELECT `id`, `nurl` FROM `contact` WHERE `uid`=%d AND `nick`='%s'",
 +                      $r = q("SELECT `id`, `nurl`, `network` FROM `contact` WHERE `uid`=%d AND `nick`='%s'",
                                        intval(api_user()),
                                        dbesc($_POST['screen_name']));
  
 +                      // Selecting the id by priority, friendica first
 +                      api_best_nickname($r);
 +
                        $recipient = api_get_user($a, $r[0]['nurl']);
                } else
                        $recipient = api_get_user($a, $_POST['user_id']);
                unset($_REQUEST["user_id"]);
                unset($_GET["user_id"]);
  
 +              unset($_REQUEST["screen_name"]);
 +              unset($_GET["screen_name"]);
 +
                $user_info = api_get_user($a);
  
                // params
                if ($page<0) $page=0;
  
                $since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
 +              $max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_id']:0);
  
                $start = $page*$count;
  
                        $sql_extra = "`mail`.`from-url`!='".dbesc( $profile_url )."'";
                }
  
 +              if ($max_id > 0)
 +                      $sql_extra .= ' AND `mail`.`id` <= '.intval($max_id);
 +
                $r = q("SELECT `mail`.*, `contact`.`nurl` AS `contact-url` FROM `mail`,`contact` WHERE `mail`.`contact-id` = `contact`.`id` AND `mail`.`uid`=%d AND $sql_extra AND `mail`.`id` > %d ORDER BY `mail`.`created` DESC LIMIT %d,%d",
                                intval(api_user()),
                                intval($since_id),
@@@ -2071,7 -2025,7 +2071,7 @@@ function api_share_as_retweet($a, $uid
  function api_get_nick($profile) {
  /* To-Do:
   - remove trailing jung from profile url
 - - pump.io check has to check the websitr
 + - pump.io check has to check the website
  */
  
        $nick = "";
@@@ -2163,46 -2117,6 +2163,46 @@@ function api_cleanup_share($shared) 
          return(trim($text));
  }
  
 +function api_best_nickname(&$contacts) {
 +      $best_contact = array();
 +
 +      foreach ($contacts AS $contact)
 +              if ($contact["network"] == "") {
 +                      $contact["network"] = "dfrn";
 +                      $best_contact = array($contact);
 +              }
 +
 +      if (sizeof($best_contact) == 0)
 +              foreach ($contacts AS $contact)
 +                      if ($contact["network"] == "dfrn")
 +                              $best_contact = array($contact);
 +
 +      if (sizeof($best_contact) == 0)
 +              foreach ($contacts AS $contact)
 +                      if ($contact["network"] == "dspr")
 +                              $best_contact = array($contact);
 +
 +      if (sizeof($best_contact) == 0)
 +              foreach ($contacts AS $contact)
 +                      if ($contact["network"] == "stat")
 +                              $best_contact = array($contact);
 +
 +      if (sizeof($best_contact) == 0)
 +              foreach ($contacts AS $contact)
 +                      if ($contact["network"] == "pump")
 +                              $best_contact = array($contact);
 +
 +      if (sizeof($best_contact) == 0)
 +              foreach ($contacts AS $contact)
 +                      if ($contact["network"] == "twit")
 +                              $best_contact = array($contact);
 +
 +      if (sizeof($best_contact) == 1)
 +              $contacts = $best_contact;
 +      else
 +              $contacts = array($contacts[0]);
 +}
 +
  /*
  Not implemented by now:
  favorites
diff --combined include/conversation.php
index 31f40aa6f8ca20767b47f90e94194719e091a8f5,31f40aa6f8ca20767b47f90e94194719e091a8f5..5b9a11bde11c273acecd88e495111c24bcc7a06e
@@@ -504,6 -504,6 +504,7 @@@ function conversation(&$a, $items, $mod
                        $tpl = 'search_item.tpl';
  
                        foreach($items as $item) {
++
                                if($arr_blocked) {
                                        $blocked = false;
                                        foreach($arr_blocked as $b) {
                                $tmp_item = array(
                                        'template' => $tpl,
                                        'id' => (($preview) ? 'P0' : $item['item_id']),
++                                      'network' => $item['item_network'],
                                        'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])),
                                        'profile_url' => $profile_link,
                                        'item_photo_menu' => item_photo_menu($item),
                                call_hooks('display_item', $arr);
  
                                $threads[$threadsid]['id'] = $item['item_id'];
++                              $threads[$threadsid]['network'] = $item['item_network'];
                                $threads[$threadsid]['items'] = array($arr['output']);
  
                        }
index 65c0d67871bc8a988ccd6dcc27fdade0dfc4a0c7,65c0d67871bc8a988ccd6dcc27fdade0dfc4a0c7..ad90e3d3118c664861a753abb95a79465138717e
@@@ -44,6 -44,6 +44,11 @@@ function check_conversations() 
  function complete_conversation($itemid, $conversation_url, $only_add_conversation = false) {
        global $a;
  
++      if ($a->last_ostatus_conversation_url == $conversation_url)
++              return;
++
++      $a->last_ostatus_conversation_url = $conversation_url;
++
        //logger('complete_conversation: completing conversation url '.$conversation_url.' for id '.$itemid);
  
        $messages = q("SELECT `uid`, `parent`, `created` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));
diff --combined library/slinky.php
index cae1f755ff0fa56c75c98f77cf95a11ba2814403,cae1f755ff0fa56c75c98f77cf95a11ba2814403..fc3714c2019598395844317a8ed7ff8324ab6e0c
@@@ -341,7 -341,7 +341,7 @@@ abstract class Slinky_Service 
                curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );                  // Don't stress about SSL validity
                curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );                  // Return the response, don't output it
                curl_setopt( $ch, CURLOPT_TIMEOUT, SLINKY_TIMEOUT );    // Limit how long we'll wait for a response
--              curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );                  // Allow following of redirections
++              //curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );                        // Allow following of redirections
                $r  = curl_exec( $ch );
                if ( curl_errno( $ch ) ) {
                        return false;
                curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );                  // Don't stress about SSL validity
                curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );                  // Return the response, don't output it
                curl_setopt( $ch, CURLOPT_TIMEOUT, SLINKY_TIMEOUT );    // Limit how long we'll wait for a response
--              curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );                  // Allow following of redirections
++              //curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );                        // Allow following of redirections
                $r  = curl_exec( $ch );
                if ( curl_errno( $ch ) ) {
                        return false;
diff --combined mod/contacts.php
index f48978aaecadd11c953f2b2f3a6ec5c98f996d18,d19c75ab9694dffe99ccdde4143c3399bf1d1f15..ad50376b704441f268571bcdd7e25530854aec8b
@@@ -67,11 -67,61 +67,61 @@@ function contacts_init(&$a) 
  
  }
  
+ function contacts_batch_actions(&$a){
+       $contacts_id = $_POST['contact_batch'];
+       if (!is_array($contacts_id)) return;
+       
+       $orig_records = q("SELECT * FROM `contact` WHERE `id` IN (%s) AND `uid` = %d AND `self` = 0",
+               implode(",", $contacts_id),
+               intval(local_user())
+       );
+       
+       $count_actions=0;
+       foreach($orig_records as $orig_record) {
+               $contact_id = $orig_record['id'];
+               if (x($_POST, 'contacts_batch_update')) {
+                       _contact_update($contact_id);
+                       $count_actions++;
+               }
+               if (x($_POST, 'contacts_batch_block')) {
+                       $r  = _contact_block($contact_id, $orig_record);
+                       if ($r) $count_actions++;
+               }
+               if (x($_POST, 'contacts_batch_ignore')) {
+                       $r = _contact_ignore($contact_id, $orig_record);
+                       if ($r) $count_actions++;
+               }
+               if (x($_POST, 'contacts_batch_archive')) {
+                       $r = _contact_archive($contact_id, $orig_record);
+                       if ($r) $count_actions++;
+               }
+               if (x($_POST, 'contacts_batch_drop')) {
+                       _contact_drop($contact_id, $orig_record);
+                       $count_actions++;
+               }
+       }
+       if ($count_actions>0) {
+               info ( sprintf( tt("%d contact edited.", "%d contacts edited", $count_actions), $count_actions) );
+       }
+       
+       if(x($_SESSION,'return_url'))
+               goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']);
+       else
+               goaway($a->get_baseurl(true) . '/contacts');
+ }
  function contacts_post(&$a) {
 -      
 +
        if(! local_user())
                return;
  
+       if ($a->argv[1]==="batch") {
+               contacts_batch_actions($a);
+               return;
+       }
        $contact_id = intval($a->argv[1]);
        if(! $contact_id)
                return;
  
        $hidden = intval($_POST['hidden']);
  
 +      $notify = intval($_POST['notify']);
 +
 +      $fetch_further_information = intval($_POST['fetch_further_information']);
 +
        $priority = intval($_POST['poll']);
        if($priority > 5 || $priority < 0)
                $priority = 0;
        $info = fix_mce_lf(escape_tags(trim($_POST['info'])));
  
        $r = q("UPDATE `contact` SET `profile-id` = %d, `priority` = %d , `info` = '%s',
 -              `hidden` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
 +              `hidden` = %d, `notify_new_posts` = %d, `fetch_further_information` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
                intval($profile_id),
                intval($priority),
                dbesc($info),
                intval($hidden),
 +              intval($notify),
 +              intval($fetch_further_information),
                intval($contact_id),
                intval(local_user())
        );
  
  }
  
+ /*contact actions*/
+ function _contact_update($contact_id) {
+       // pull feed and consume it, which should subscribe to the hub.
+       proc_run('php',"include/poller.php","$contact_id"); 
+ }
+ function _contact_block($contact_id, $orig_record) {
+       $blocked = (($orig_record['blocked']) ? 0 : 1);
+       $r = q("UPDATE `contact` SET `blocked` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
+               intval($blocked),
+               intval($contact_id),
+               intval(local_user())
+       );
+       return $r;
+ }
+ function _contact_ignore($contact_id, $orig_record) {
+       $readonly = (($orig_record['readonly']) ? 0 : 1);
+       $r = q("UPDATE `contact` SET `readonly` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
+               intval($readonly),
+               intval($contact_id),
+               intval(local_user())
+       );
+       return $r;
+ }
+ function _contact_archive($contact_id, $orig_record) {
+       $archived = (($orig_record['archive']) ? 0 : 1);
+       $r = q("UPDATE `contact` SET `archive` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
+               intval($archived),
+               intval($contact_id),
+               intval(local_user())
+       );
+       if ($archived) {
+               q("UPDATE `item` SET `private` = 2 WHERE `contact-id` = %d AND `uid` = %d", intval($contact_id), intval(local_user()));
+       }
+       return $r;
+ }
+ function _contact_drop($contact_id, $orig_record) {
+       require_once('include/Contact.php');
+       $a = get_app();
+       terminate_friendship($a->user,$a->contact,$orig_record);
+       contact_remove($orig_record['id']);
+ }
  
  
  function contacts_content(&$a) {
                }
                
                if($cmd === 'update') {
-                       // pull feed and consume it, which should subscribe to the hub.
-                       proc_run('php',"include/poller.php","$contact_id");
+                       _contact_update($contact_id);
                        goaway($a->get_baseurl(true) . '/contacts/' . $contact_id);
                        // NOTREACHED
                }
  
                if($cmd === 'block') {
-                       $blocked = (($orig_record[0]['blocked']) ? 0 : 1);
-                       $r = q("UPDATE `contact` SET `blocked` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
-                               intval($blocked),
-                               intval($contact_id),
-                               intval(local_user())
-                       );
+                       $r = _contact_block($contact_id, $orig_record[0]);
                        if($r) {
-                               //notice( t('Contact has been ') . (($blocked) ? t('blocked') : t('unblocked')) . EOL );
                                info( (($blocked) ? t('Contact has been blocked') : t('Contact has been unblocked')) . EOL );
                        }
+                       
                        goaway($a->get_baseurl(true) . '/contacts/' . $contact_id);
                        return; // NOTREACHED
                }
  
                if($cmd === 'ignore') {
-                       $readonly = (($orig_record[0]['readonly']) ? 0 : 1);
-                       $r = q("UPDATE `contact` SET `readonly` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
-                               intval($readonly),
-                               intval($contact_id),
-                               intval(local_user())
-                       );
+                       $r = _contact_ignore($contact_id, $orig_record[0]);
                        if($r) {
                                info( (($readonly) ? t('Contact has been ignored') : t('Contact has been unignored')) . EOL );
                        }
+                       
                        goaway($a->get_baseurl(true) . '/contacts/' . $contact_id);
                        return; // NOTREACHED
                }
  
  
                if($cmd === 'archive') {
-                       $archived = (($orig_record[0]['archive']) ? 0 : 1);
-                       $r = q("UPDATE `contact` SET `archive` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
-                               intval($archived),
-                               intval($contact_id),
-                               intval(local_user())
-                       );
-                       if ($archived) {
-                               q("UPDATE `item` SET `private` = 2 WHERE `contact-id` = %d AND `uid` = %d", intval($contact_id), intval(local_user()));
-                       }
+                       $r = _contact_archive($contact_id, $orig_record[0]);
                        if($r) {
-                               //notice( t('Contact has been ') . (($archived) ? t('archived') : t('unarchived')) . EOL );
                                info( (($archived) ? t('Contact has been archived') : t('Contact has been unarchived')) . EOL );
-                       }
+                       }                       
+                       
                        goaway($a->get_baseurl(true) . '/contacts/' . $contact_id);
                        return; // NOTREACHED
                }
                        }
                        // Now check how the user responded to the confirmation query
                        if($_REQUEST['canceled']) {
-                               goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']);
+                               if(x($_SESSION,'return_url'))
+                                       goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']);
+                               else
+                                       goaway($a->get_baseurl(true) . '/contacts');
                        }
  
-                       require_once('include/Contact.php');
-                       terminate_friendship($a->user,$a->contact,$orig_record[0]);
-                       contact_remove($orig_record[0]['id']);
+                       _contact_drop($contact_id, $orig_record[0]);
                        info( t('Contact has been removed.') . EOL );
                        if(x($_SESSION,'return_url'))
                                goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']);
                        '$ignored' => (($contact['readonly']) ? t('Currently ignored') : ''),
                        '$archived' => (($contact['archive']) ? t('Currently archived') : ''),
                        '$hidden' => array('hidden', t('Hide this contact from others'), ($contact['hidden'] == 1), t('Replies/likes to your public posts <strong>may</strong> still be visible')),
 +                      '$notify' => array('notify', t('Notification for new posts'), ($contact['notify_new_posts'] == 1), t('Send a notification of every new post of this contact')),
 +                      '$fetch_further_information' => array('fetch_further_information', t('Fetch further information for feeds'), ($contact['fetch_further_information'] == 1), t('Fetch further information for feeds')),
                        '$photo' => $contact['photo'],
                        '$name' => $contact['name'],
                        '$dir_icon' => $dir_icon,
                $search_txt = dbesc(protect_sprintf(preg_quote($search)));
                $searching = true;
        }
-       $sql_extra .= (($searching) ? " AND `name` REGEXP '$search_txt' " : "");
+       $sql_extra .= (($searching) ? " AND (name REGEXP '$search_txt' OR url REGEXP '$search_txt'  OR nick REGEXP '$search_txt') " : "");
  
        if($nets)
                $sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets));
        
        $tpl = get_markup_template("contacts-template.tpl");
        $o .= replace_macros($tpl, array(
+               '$baseurl' => $a->get_baseurl(),
                '$header' => t('Contacts') . (($nets) ? ' - ' . network_to_name($nets) : ''),
                '$tabs' => $t,
                '$total' => $total,
                '$submit' => t('Find'),
                '$cmd' => $a->cmd,
                '$contacts' => $contacts,
+               '$contact_drop_confirm' => t('Do you really want to delete this contact?'),
+               '$batch_actions' => array(
+                       'contacts_batch_update' => t('Update'),
+                       'contacts_batch_block' => t('Block')."/".t("Unblock"),
+                       "contacts_batch_ignore" => t('Ignore')."/".t("Unignore"),
+                       "contacts_batch_archive" => t('Archive')."/".t("Unarchive"),
+                       "contacts_batch_drop" => t('Delete'),
+               ),
                '$paginate' => paginate($a),
  
        )); 
diff --combined mod/crepair.php
index 171e88f3120f3a510b30a22764609e271d298ccb,f8336ef0bacfc33e067932e116d9516d537024d3..0fdab7eebe1cd7cacde8e66a115ab11142d59ab0
@@@ -28,7 -28,7 +28,7 @@@ function crepair_init(&$a) 
                        $o .= '</div>';
                        $a->page['aside'] .= $o;
  
 -      }       
 +      }
  }
  
  
@@@ -59,9 -59,9 +59,9 @@@ function crepair_post(&$a) 
        $poll    = ((x($_POST,'poll')) ? $_POST['poll'] : '');
        $attag   = ((x($_POST,'attag')) ? $_POST['attag'] : '');
        $photo   = ((x($_POST,'photo')) ? $_POST['photo'] : '');
 -      $remote_self = ((x($_POST,'remote_self')) ? intval($_POST['remote_self']) : 0);
 +      $remote_self = ((x($_POST,'remote_self')) ? $_POST['remote_self'] : false);
  
 -      $r = q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `url` = '%s', `request` = '%s', `confirm` = '%s', `notify` = '%s', `poll` = '%s', `attag` = '%s', `remote_self` = '%d'
 +      $r = q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `url` = '%s', `request` = '%s', `confirm` = '%s', `notify` = '%s', `poll` = '%s', `attag` = '%s' , `remote_self` = %d
                WHERE `id` = %d AND `uid` = %d LIMIT 1",
                dbesc($name),
                dbesc($nick),
@@@ -71,7 -71,7 +71,7 @@@
                dbesc($notify),
                dbesc($poll),
                dbesc($attag),
 -              $remote_self,
 +              intval($remote_self),
                intval($contact['id']),
                local_user()
        );
@@@ -156,7 -156,9 +156,9 @@@ function crepair_content(&$a) 
                '$label_notify' => t('Notification Endpoint URL'),
                '$label_poll' => t('Poll/Feed URL'),
                '$label_photo' => t('New photo from this URL'),
-               '$label_self' => t('Mirror all posts to the wall?'),
+               '$label_remote_self' => t('Remote Self'),
+               '$allow_remote_self' => get_config('system','allow_users_remote_self'),
+               '$remote_self' => array('remote_self', t('Mirror postings from this contact'), $contact['remote_self'], t('Mark this contact as remote_self, this will cause friendica to repost new entries from this contact.')),  
                '$contact_name' => $contact['name'],
                '$contact_nick' => $contact['nick'],
                '$contact_id'   => $contact['id'],
                '$notify'       => $contact['notify'],
                '$poll'         => $contact['poll'],
                '$contact_attag'  => $contact['attag'],
 +              '$contact_self' => array('remote_self', t('Mirror all posts to the wall?'), $contact['remote_self'], 
 +                                      t('Shall all posts from this contact posted like your own posts?')),
                '$lbl_submit'   => t('Submit')
-       ));
+           ));
  
        return $o;
  
diff --combined mod/parse_url.php
index cb7268c1df83acd0e14bb9db4e0b1617346e2bc4,cb7268c1df83acd0e14bb9db4e0b1617346e2bc4..cf52011f158eb373bfec7741e44b4977bff7cdcc
@@@ -311,9 -311,9 +311,9 @@@ function parse_url_content(&$a) 
        logger('parse_url: ' . $url);
  
        if($textmode)
--              $template = $br . '[bookmark=%s]%s[/bookmark]%s' . $br;
++              $template = '[bookmark=%s]%s[/bookmark]%s' . $br;
        else
--              $template = "<br /><a class=\"bookmark\" href=\"%s\" >%s</a>%s<br />";
++              $template = "<a class=\"bookmark\" href=\"%s\" >%s</a>%s<br />";
  
        $arr = array('url' => $url, 'text' => '');
  
        if($url && $title && $text) {
  
                if($textmode)
--                      $text = $br . '[quote]' . trim($text) . '[/quote]' . $br;
++                      $text = '[quote]' . trim($text) . '[/quote]' . $br;
                else
--                      $text = '<br /><blockquote>' . trim($text) . '</blockquote><br />';
++                      $text = '<blockquote>' . trim($text) . '</blockquote><br />';
  
                $title = str_replace(array("\r","\n"),array('',''),$title);
  
  
        $siteinfo = parseurl_getsiteinfo($url);
  
++      $sitedata = "";
++
        if($siteinfo["title"] == "") {
--              echo sprintf($template,$url,$url,'') . $str_tags;
++              $sitedata .= sprintf($template,$url,$url,'') . $str_tags;
                killme();
        } else {
                $text = $siteinfo["text"];
  
        if(strlen($text)) {
                if($textmode)
--                      $text = $br.'[quote]'.trim($text).'[/quote]'.$br ;
++                      $text = '[quote]'.trim($text).'[/quote]';
                else
--                      $text = '<br /><blockquote>'.trim($text).'</blockquote><br />';
++                      $text = '<blockquote>'.trim($text).'</blockquote>';
        }
  
        if($image) {
                $text = $br.$br.$image.$text;
        }
++
        $title = str_replace(array("\r","\n"),array('',''),$title);
  
        $result = sprintf($template,$url,($title) ? $title : $url,$text) . $str_tags;
  
        logger('parse_url: returns: ' . $result);
  
--      echo trim($result);
++      $sitedata .=  trim($result);
++
++      echo "[class=type-link]".$sitedata."[/class]";
++
        killme();
  }
diff --combined mods/readme.txt
index d74b846d00005733a5da998b4095db2a4e4a7f55,d74b846d00005733a5da998b4095db2a4e4a7f55..9f47f85d5a21742ca139e62ecef92a6cbdda9ef2
@@@ -1,6 -1,6 +1,18 @@@
--Site speed can be improved when the following indexes are set. They cannot be set through the update script because on large sites they will block the site for several minutes.
++Site speed can be improved when the following indexes are set. They 
++cannot be set through the update script because on large sites they will 
++block the site for several minutes.
  
  CREATE INDEX `uid_commented` ON `item` (`uid`, `commented`);
  CREATE INDEX `uid_created` ON `item` (`uid`, `created`);
  CREATE INDEX `uid_unseen` ON `item` (`uid`, `unseen`);
  CREATE INDEX `resource-id` ON `item` (`resource-id`);
++CREATE INDEX `uri_received` ON item(`uri`, `received`);
++CREATE INDEX `received_uri` ON item(`received`, `uri`);
++CREATE INDEX `contact-id_created` ON item(`contact-id`, created);
++CREATE INDEX `uid_network_received` ON item(`uid`, `network`, `received`);
++CREATE INDEX `uid_parent` ON item(`uid`, `parent`);
++CREATE INDEX `uid_received` ON item(`uid`, `received`);
++CREATE INDEX `uid_network_commented` ON item(`uid`, `network`, `commented`);
++CREATE INDEX `uid_commented` ON item(`uid`, `commented`);
++CREATE INDEX `uid_title` ON item(uid, `title`);
++CREATE INDEX `created_contact-id` ON item(`created`, `contact-id`);
index 5278e42f089b0455a9d646815c8df0062c2b7ff0,d53af5dad783d4a81b42bd21c6e4a19fbb36a679..5cc4462b390e341b83125a377100aac51ec2d314
@@@ -1,9 -1,3 +1,3 @@@
- {{*
-  *    AUTOMATICALLY GENERATED TEMPLATE
-  *    DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN
-  *
-  *}}
  <form id="crepair-form" action="crepair/{{$contact_id}}" method="post" >
  
  <h4>{{$contact_name}}</h4>
  <label id="crepair-photo-label" class="crepair-label" for="crepair-photo">{{$label_photo}}</label>
  <input type="text" id="crepair-photo" class="crepair-input" name="photo" value="" />
  <div class="clear"></div>
+ {{if $allow_remote_self eq 1}}
+ <h4>{{$label_remote_self}}</h4>
+ {{include file="field_checkbox.tpl" field=$remote_self}}
+ {{/if}}
  
 +{{include file="field_checkbox.tpl" field=$contact_self}}
 +
  <input type="submit" name="submit" value="{{$lbl_submit}}" />
  
  </form>
index 03aaf89400439cf98b34781735cfc68723e00e6c,03aaf89400439cf98b34781735cfc68723e00e6c..5561cb65ee9f89ca09e3568630eb478c129962d4
@@@ -291,7 -291,7 +291,9 @@@ blockquote.shared_content 
  body {
    font-family: 'Lato', "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 14px;
--  background-color: #ffffff;
++  /* background-color: #ffffff; */
++  background-color: #FAFAFA;
++  /* background-color: rgb(252, 252, 252); */
    color: #2d2d2d;
    margin: 0px 0px 0px 0px;
    display: table;
@@@ -1087,7 -1087,7 +1089,9 @@@ section 
    width: 766px;
    max-width: 766px;
    padding: 10px 10px 10px 10px;
--  background-color: white;
++  /* background-color: white; */
++  /* background-color: rgb(252, 252, 252); */
++  background-color: #FAFAFA;
    border-bottom: 1px solid lightgray;
    border-right: 1px solid lightgray;
    border-left: 1px solid lightgray;
@@@ -1410,6 -1410,6 +1414,31 @@@ border-bottom: 1px solid #D2D2D2
        padding-right: 12px; */
  }
  
++.twit {
++  background-color: #FFFAFA;
++}
++.pump {
++  background-color: #FAFFFA;
++}
++.face {
++  background-color: #FAFAFF;
++}
++.feed {
++  background-color: #FFFFFA;
++}
++.dspr {
++  background-color: #FFFAFF;
++}
++.dfrn {
++  background-color: #FAFFFF;
++}
++.stat {
++  background-color: #FAFAFA;
++}
++.mail {
++  background-color: #FFFFF9;
++}
++
  #profile-jot-form #profile-jot-text {
    height: 2.0em;
    /* width: 99%; */
index dc3e918f610e0fe099a79add9dc5fd030075fea8,dc3e918f610e0fe099a79add9dc5fd030075fea8..397046a4e37ac07c3a065787fff8880fc24949d8
@@@ -7,7 -7,7 +7,7 @@@
  
  {{foreach $threads as $thread}}
  
--<div id="tread-wrapper-{{$thread.id}}" class="tread-wrapper {{if $thread.threaded}}threaded{{/if}}  {{$thread.toplevel}}">
++<div id="tread-wrapper-{{$thread.id}}" class="tread-wrapper {{if $thread.threaded}}threaded{{/if}}  {{$thread.toplevel}} {{$thread.network}}">
         
         
                {{if $thread.type == tag}}
index d51014a9694766bf0e8aac4d11d8d67be7a2291c,d51014a9694766bf0e8aac4d11d8d67be7a2291c..0ec3c526b4f23b89f806932fef9f9237dcb94d7f
@@@ -32,7 -32,7 +32,7 @@@
        <img id="like-rotator-{{$item.id}}" class="like-rotator" src="images/rotator.gif" alt="{{$item.wait}}" title="{{$item.wait}}" style="display: none;" />
  </div>
  
--<div class="wall-item-container {{$item.indent}} {{$item.shiny}} " id="item-{{$item.id}}">
++<div class="wall-item-container {{$item.indent}} {{$item.shiny}} {{$item.network}}" id="item-{{$item.id}}">
        <div class="wall-item-item">
                <div class="wall-item-info">
                        <div class="contact-photo-wrapper mframe{{if $item.owner_url}} wwfrom{{/if}}"