]> git.mxchange.org Git - friendica.git/blobdiff - include/items.php
Continued a bit:
[friendica.git] / include / items.php
index 6f9403701121eed158ed9c98266aebcd77269a57..c2b3d7d1f5c0c50038a628b10be7a2db0f05cd5c 100644 (file)
@@ -60,7 +60,7 @@ function limit_body_size($body) {
                $img_start = strpos($orig_body, '[img');
                $img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
                $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
-               while (($img_st_close !== false) && ($img_end !== false)) {
+               while(($img_st_close !== false) && ($img_end !== false)) {
 
                        $img_st_close++; // make it point to AFTER the closing bracket
                        $img_end += $img_start;
@@ -1099,7 +1099,7 @@ function item_body_set_hashtags(&$item) {
                        "#$2", $item["body"]);
 
 
-       foreach ($tags as $tag) {
+       foreach($tags as $tag) {
                if (strpos($tag,'#') !== 0)
                        continue;
 
@@ -1170,7 +1170,7 @@ function get_item_id($guid, $uid = 0) {
 function get_item_contact($item,$contacts) {
        if (! count($contacts) || (! is_array($item)))
                return false;
-       foreach ($contacts as $contact) {
+       foreach($contacts as $contact) {
                if ($contact['id'] == $item['contact-id']) {
                        return $contact;
                        break; // NOTREACHED
@@ -1224,7 +1224,7 @@ function tag_deliver($uid,$item_id) {
 
        $cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
        if ($cnt) {
-               foreach ($matches as $mtch) {
+               foreach($matches as $mtch) {
                        if (link_compare($link,$mtch[1]) || link_compare($dlink,$mtch[1])) {
                                $mention = true;
                                logger('tag_deliver: mention found: ' . $mtch[2]);
@@ -1496,17 +1496,19 @@ function item_is_remote_self($contact, &$datarray) {
        return true;
 }
 
-function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
+function new_follower($importer, $contact, $datarray, $item, $sharing = false) {
        $url = notags(trim($datarray['author-link']));
        $name = notags(trim($datarray['author-name']));
        $photo = notags(trim($datarray['author-avatar']));
 
        if (is_object($item)) {
                $rawtag = $item->get_item_tags(NAMESPACE_ACTIVITY,'actor');
-               if ($rawtag && $rawtag[0]['child'][NAMESPACE_POCO]['preferredUsername'][0]['data'])
+               if ($rawtag && $rawtag[0]['child'][NAMESPACE_POCO]['preferredUsername'][0]['data']) {
                        $nick = $rawtag[0]['child'][NAMESPACE_POCO]['preferredUsername'][0]['data'];
-       } else
+               }
+       } else {
                $nick = $item;
+       }
 
        if (is_array($contact)) {
                if (($contact['network'] == NETWORK_OSTATUS && $contact['rel'] == CONTACT_IS_SHARING)
@@ -1544,11 +1546,9 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
                        update_contact_avatar($photo, $importer["uid"], $contact_record["id"], true);
                }
 
-
                $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
                        intval($importer['uid'])
                );
-               $a = get_app();
 
                if (dbm::is_result($r) AND !in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) {
 
@@ -1567,8 +1567,9 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
 
                        $def_gid = get_default_group($importer['uid'], $contact_record["network"]);
 
-                       if (intval($def_gid))
-                               group_add_member($importer['uid'],'',$contact_record['id'],$def_gid);
+                       if (intval($def_gid)) {
+                               group_add_member($importer['uid'], '', $contact_record['id'], $def_gid);
+                       }
 
                        if (($r[0]['notify-flags'] & NOTIFY_INTRO) &&
                                in_array($r[0]['page-flags'], array(PAGE_NORMAL))) {
@@ -1599,7 +1600,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
        }
 }
 
-function lose_follower($importer,$contact,$datarray = array(),$item = "") {
+function lose_follower($importer, $contact, array $datarray = array(), $item = "") {
 
        if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_SHARING)) {
                q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d",
@@ -1611,7 +1612,7 @@ function lose_follower($importer,$contact,$datarray = array(),$item = "") {
        }
 }
 
-function lose_sharer($importer,$contact,$datarray = array(),$item = "") {
+function lose_sharer($importer, $contact, array $datarray = array(), $item = "") {
 
        if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_FOLLOWER)) {
                q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d",
@@ -1623,7 +1624,7 @@ function lose_sharer($importer,$contact,$datarray = array(),$item = "") {
        }
 }
 
-function subscribe_to_hub($url,$importer,$contact,$hubmode = 'subscribe') {
+function subscribe_to_hub($url, $importer, $contact, $hubmode = 'subscribe') {
 
        $a = get_app();
 
@@ -1681,7 +1682,7 @@ function fix_private_photos($s, $uid, $item = null, $cid = 0) {
        $img_start = strpos($orig_body, '[img');
        $img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
        $img_len = ($img_start !== false ? strpos(substr($orig_body, $img_start + $img_st_close + 1), '[/img]') : false);
-       while ( ($img_st_close !== false) && ($img_len !== false) ) {
+       while( ($img_st_close !== false) && ($img_len !== false) ) {
 
                $img_st_close++; // make it point to AFTER the closing bracket
                $image = substr($orig_body, $img_start + $img_st_close, $img_len);
@@ -1810,7 +1811,7 @@ function item_getfeedtags($item) {
        $matches = false;
        $cnt = preg_match_all('|\#\[url\=(.*?)\](.*?)\[\/url\]|',$item['tag'],$matches);
        if ($cnt) {
-               for ($x = 0; $x < $cnt; $x ++) {
+               for($x = 0; $x < $cnt; $x ++) {
                        if ($matches[1][$x])
                                $ret[$matches[2][$x]] = array('#',$matches[1][$x], $matches[2][$x]);
                }
@@ -1818,7 +1819,7 @@ function item_getfeedtags($item) {
        $matches = false;
        $cnt = preg_match_all('|\@\[url\=(.*?)\](.*?)\[\/url\]|',$item['tag'],$matches);
        if ($cnt) {
-               for ($x = 0; $x < $cnt; $x ++) {
+               for($x = 0; $x < $cnt; $x ++) {
                        if ($matches[1][$x])
                                $ret[] = array('@',$matches[1][$x], $matches[2][$x]);
                }
@@ -1876,7 +1877,7 @@ function item_expire($uid, $days, $network = "", $force = false) {
 
        logger('expire: # items=' . count($r). "; expire items: $expire_items, expire notes: $expire_notes, expire starred: $expire_starred, expire photos: $expire_photos");
 
-       foreach ($r as $item) {
+       foreach($r as $item) {
 
                // don't expire filed items
 
@@ -1909,7 +1910,7 @@ function drop_items($items) {
                return;
 
        if (count($items)) {
-               foreach ($items as $item) {
+               foreach($items as $item) {
                        $owner = drop_item($item,false);
                        if ($owner && ! $uid)
                                $uid = $owner;
@@ -1949,7 +1950,7 @@ function drop_item($id,$interactive = true) {
        // check if logged in user is either the author or owner of this item
 
        if (is_array($_SESSION['remote'])) {
-               foreach ($_SESSION['remote'] as $visitor) {
+               foreach($_SESSION['remote'] as $visitor) {
                        if ($visitor['uid'] == $item['uid'] && $visitor['cid'] == $item['contact-id']) {
                                $contact_id = $visitor['cid'];
                                break;
@@ -1966,7 +1967,7 @@ function drop_item($id,$interactive = true) {
                        // so add any arguments as hidden inputs
                        $query = explode_querystring($a->query_string);
                        $inputs = array();
-                       foreach ($query['args'] as $arg) {
+                       foreach($query['args'] as $arg) {
                                if (strpos($arg, 'confirm=') === false) {
                                        $arg_parts = explode('=', $arg);
                                        $inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]);
@@ -2005,7 +2006,7 @@ function drop_item($id,$interactive = true) {
                $matches = false;
                $cnt = preg_match_all('/<(.*?)>/',$item['file'],$matches,PREG_SET_ORDER);
                if ($cnt) {
-                       foreach ($matches as $mtch) {
+                       foreach($matches as $mtch) {
                                file_tag_unsave_file($item['uid'],$item['id'],$mtch[1],true);
                        }
                }
@@ -2014,7 +2015,7 @@ function drop_item($id,$interactive = true) {
 
                $cnt = preg_match_all('/\[(.*?)\]/',$item['file'],$matches,PREG_SET_ORDER);
                if ($cnt) {
-                       foreach ($matches as $mtch) {
+                       foreach($matches as $mtch) {
                                file_tag_unsave_file($item['uid'],$item['id'],$mtch[1],false);
                        }
                }
@@ -2044,7 +2045,7 @@ function drop_item($id,$interactive = true) {
 
                // If item has attachments, drop them
 
-               foreach (explode(",",$item['attach']) as $attach){
+               foreach(explode(",",$item['attach']) as $attach){
                        preg_match("|attach/(\d+)|", $attach, $matches);
                        q("DELETE FROM `attach` WHERE `id` = %d AND `uid` = %d",
                                intval($matches[1]),
@@ -2179,7 +2180,7 @@ function list_post_dates($uid, $wall) {
 
        // Starting with the current month, get the first and last days of every
        // month down to and including the month of the first post
-       while (substr($dnow, 0, 7) >= substr($dthen, 0, 7)) {
+       while(substr($dnow, 0, 7) >= substr($dthen, 0, 7)) {
                $dyear = intval(substr($dnow,0,4));
                $dstart = substr($dnow,0,8) . '01';
                $dend = substr($dnow,0,8) . get_dim(intval($dnow),intval(substr($dnow,5)));
@@ -2208,7 +2209,7 @@ function posted_dates($uid,$wall) {
        $ret = array();
        // Starting with the current month, get the first and last days of every
        // month down to and including the month of the first post
-       while (substr($dnow, 0, 7) >= substr($dthen, 0, 7)) {
+       while(substr($dnow, 0, 7) >= substr($dthen, 0, 7)) {
                $dstart = substr($dnow,0,8) . '01';
                $dend = substr($dnow,0,8) . get_dim(intval($dnow),intval(substr($dnow,5)));
                $start_month = datetime_convert('','',$dstart,'Y-m-d');