]> git.mxchange.org Git - friendica.git/commitdiff
Merge branch 'master' back into develop
authorFabrixxm <fabrix.xm@gmail.com>
Tue, 29 Sep 2015 08:00:13 +0000 (10:00 +0200)
committerFabrixxm <fabrix.xm@gmail.com>
Tue, 29 Sep 2015 08:00:13 +0000 (10:00 +0200)
1  2 
include/items.php

diff --combined include/items.php
index 40409bb8974748b4fcd5e5775ac0b1ce33bd56b2,63782675704f213b98ccbdafa3c63faa7bd7d2dc..2d05488bcd1e8e4b7302e35fe690f1c368128c92
@@@ -1096,48 -1096,6 +1096,48 @@@ function add_guid($item) 
                dbesc($item["uri"]), dbesc($item["network"]));
  }
  
 +// Adds a "lang" specification in a "postopts" element of given $arr,
 +// if possible and not already present.
 +// Expects "body" element to exist in $arr.
 +// TODO: add a parameter to request forcing override
 +function item_add_language_opt(&$arr) {
 +
 +      if (version_compare(PHP_VERSION, '5.3.0', '<')) return; // LanguageDetect.php not available ?
 +
 +      if ( x($arr, 'postopts') )
 +      {
 +              if ( strstr($arr['postopts'], 'lang=') )
 +              {
 +                      // do not override
 +                      // TODO: add parameter to request overriding
 +                      return;
 +              }
 +              $postopts = $arr['postopts'];
 +      }
 +      else
 +      {
 +              $postopts = "";
 +      }
 +
 +      require_once('library/langdet/Text/LanguageDetect.php');
 +      $naked_body = preg_replace('/\[(.+?)\]/','',$arr['body']);
 +      $l = new Text_LanguageDetect;
 +      //$lng = $l->detectConfidence($naked_body);
 +      //$arr['postopts'] = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : '');
 +      $lng = $l->detect($naked_body, 3);
 +
 +      if (sizeof($lng) > 0) {
 +              if ($postopts != "") $postopts .= '&'; // arbitrary separator, to be reviewed
 +              $postopts .= 'lang=';
 +              $sep = "";
 +              foreach ($lng as $language => $score) {
 +                      $postopts .= $sep . $language.";".$score;
 +                      $sep = ':';
 +              }
 +              $arr['postopts'] = $postopts;
 +      }
 +}
 +
  function item_store($arr,$force_parent = false, $notify = false, $dontcache = false) {
  
        // If it is a posting where users should get notifications, then define it as wall posting
        //if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false))
        //      $arr['body'] = strip_tags($arr['body']);
  
 -
 -      if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
 -              require_once('library/langdet/Text/LanguageDetect.php');
 -              $naked_body = preg_replace('/\[(.+?)\]/','',$arr['body']);
 -              $l = new Text_LanguageDetect;
 -              //$lng = $l->detectConfidence($naked_body);
 -              //$arr['postopts'] = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : '');
 -              $lng = $l->detect($naked_body, 3);
 -
 -              if (sizeof($lng) > 0) {
 -                      $postopts = "";
 -
 -                      foreach ($lng as $language => $score) {
 -                              if ($postopts == "")
 -                                      $postopts = "lang=";
 -                              else
 -                                      $postopts .= ":";
 -
 -                              $postopts .= $language.";".$score;
 -                      }
 -                      $arr['postopts'] = $postopts;
 -              }
 -      }
 +      item_add_language_opt($arr);
  
+       if ($notify)
+               $guid_prefix = "";
+       else
+               $guid_prefix = $arr['network'];
        $arr['wall']          = ((x($arr,'wall'))          ? intval($arr['wall'])                : 0);
-       $arr['guid']          = ((x($arr,'guid'))          ? notags(trim($arr['guid']))          : get_guid(32, $arr['network']));
+       $arr['guid']          = ((x($arr,'guid'))          ? notags(trim($arr['guid']))          : get_guid(32, $guid_prefix));
        $arr['uri']           = ((x($arr,'uri'))           ? notags(trim($arr['uri']))           : $arr['guid']);
        $arr['extid']         = ((x($arr,'extid'))         ? notags(trim($arr['extid']))         : '');
        $arr['author-name']   = ((x($arr,'author-name'))   ? notags(trim($arr['author-name']))   : '');
        // Fill the cache field
        put_item_in_cache($arr);
  
-       call_hooks('post_remote',$arr);
+       if ($notify)
+               call_hooks('post_local',$arr);
+       else
+               call_hooks('post_remote',$arr);
  
        if(x($arr,'cancel')) {
                logger('item_store: post cancelled by plugin.');
  
                $r = q('SELECT * FROM `item` WHERE id = %d', intval($current_post));
                if (count($r) == 1) {
-                       call_hooks('post_remote_end', $r[0]);
+                       if ($notify)
+                               call_hooks('post_local_end', $r[0]);
+                       else
+                               call_hooks('post_remote_end', $r[0]);
                } else
                        logger('item_store: new item not found in DB, id ' . $current_post);
        }
@@@ -2009,6 -2000,8 +2020,8 @@@ function dfrn_deliver($owner,$contact,$
  
        $rino = get_config('system','rino_encrypt');
        $rino = intval($rino);
+       // use RINO1 if mcrypt isn't installed and RINO2 was selected
+       if ($rino==2 and !function_exists('mcrypt_create_iv')) $rino=1;
  
        logger("Local rino version: ". $rino, LOGGER_DEBUG);