diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/dba.php | 28 | ||||
-rw-r--r-- | include/items.php | 44 | ||||
-rw-r--r-- | include/profile_selectors.php | 18 |
3 files changed, 60 insertions, 30 deletions
diff --git a/include/dba.php b/include/dba.php index 44a663eac..c9f880241 100644 --- a/include/dba.php +++ b/include/dba.php @@ -75,22 +75,28 @@ class dba { if((! $this->db) || (! $this->connected)) return false; + $this->error = ''; + if($this->mysqli) $result = @$this->db->query($sql); else $result = @mysql_query($sql,$this->db); + if($this->mysqli) { + if($this->db->errno) + $this->error = $this->db->error; + } + elseif(mysql_errno($this->db)) + $this->error = mysql_error($this->db); + + if(strlen($this->error)) { + logger('dba: ' . $this->error); + } + if($this->debug) { $mesg = ''; - if($this->mysqli) { - if($this->db->errno) - logger('dba: ' . $this->db->error); - } - elseif(mysql_errno($this->db)) - logger('dba: ' . mysql_error($this->db)); - if($result === false) $mesg = 'false'; elseif($result === true) @@ -102,7 +108,9 @@ class dba { $mesg = mysql_num_rows($result) . ' results' . EOL; } - $str = 'SQL = ' . printable($sql) . EOL . 'SQL returned ' . $mesg . EOL; + $str = 'SQL = ' . printable($sql) . EOL . 'SQL returned ' . $mesg + . (($this->error) ? ' error: ' . $this->error : '') + . EOL; logger('dba: ' . $str ); } @@ -114,9 +122,9 @@ class dba { */ if($result === false) { - logger('dba: ' . printable($sql) . ' returned false.'); + logger('dba: ' . printable($sql) . ' returned false.' . "\n" . $this->error); if(file_exists('dbfail.out')) - file_put_contents('dbfail.out', datetime_convert() . "\n" . printable($sql) . ' returned false' . "\n", FILE_APPEND); + file_put_contents('dbfail.out', datetime_convert() . "\n" . printable($sql) . ' returned false' . "\n" . $this->error . "\n", FILE_APPEND); } if(($result === true) || ($result === false)) diff --git a/include/items.php b/include/items.php index 07f62ece5..a1dcdb6d8 100644 --- a/include/items.php +++ b/include/items.php @@ -2227,10 +2227,10 @@ function local_delivery($importer,$data) { logger('local_delivery: received remote comment'); $is_like = false; // remote reply to our post. Import and then notify everybody else. - $datarray = get_atom_elements($feed,$item); + $datarray = get_atom_elements($feed,$item); - $r = q("SELECT `id`, `uid`, `last-child`, `edited`, `body` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + $r = q("SELECT `id`, `uid`, `last-child`, `edited`, `body` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($item_id), intval($importer['importer_uid']) ); @@ -2266,14 +2266,22 @@ function local_delivery($importer,$data) { // return 0; // } + // our user with $importer['importer_uid'] is the owner + + $own = q("select name,url,thumb from contact where uid = %d and self = 1 limit 1", + intval($importer['importer_uid']) + ); + + $datarray['type'] = 'remote-comment'; $datarray['wall'] = 1; $datarray['parent-uri'] = $parent_uri; $datarray['uid'] = $importer['importer_uid']; - $datarray['owner-name'] = $r[0]['name']; - $datarray['owner-link'] = $r[0]['url']; - $datarray['owner-avatar'] = $r[0]['thumb']; + $datarray['owner-name'] = $own[0]['name']; + $datarray['owner-link'] = $own[0]['url']; + $datarray['owner-avatar'] = $own[0]['thumb']; $datarray['contact-id'] = $importer['id']; + if(($datarray['verb'] === ACTIVITY_LIKE) || ($datarray['verb'] === ACTIVITY_DISLIKE)) { $is_like = true; $datarray['type'] = 'activity'; @@ -2290,26 +2298,34 @@ function local_delivery($importer,$data) { } if(($datarray['verb'] === ACTIVITY_TAG) && ($datarray['object-type'] === ACTIVITY_OBJ_TAGTERM)) { - - + $xo = parse_xml_string($datarray['object'],false); $xt = parse_xml_string($datarray['target'],false); - if(($xt->type == ACTIVITY_OBJ_NOTE) && ($xt->id == $r[0]['uri'])) { + if(($xt->type == ACTIVITY_OBJ_NOTE) && ($xt->id)) { + + // fetch the parent item + + $tagp = q("select * from item where uri = '%s' and uid = %d limit 1", + dbesc($xt->id), + intval($importer['importer_uid']) + ); + if(! count($tagp)) + continue; // extract tag, if not duplicate, and this user allows tags, add to parent item if($xo->id && $xo->content) { $newtag = '#[url=' . $xo->id . ']'. $xo->content . '[/url]'; - - if(! (stristr($r[0]['tag'],$newtag))) { + if(! (stristr($tagp[0]['tag'],$newtag))) { $i = q("SELECT `blocktags` FROM `user` where `uid` = %d LIMIT 1", intval($importer['importer_uid']) ); - if(count($i) && ! ($i[0]['blocktags'])) { - q("UPDATE item SET tag = '%s' WHERE id = %d LIMIT 1", - dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . $newtag), - intval($r[0]['id']) + if(count($i) && ! intval($i[0]['blocktags'])) { + q("UPDATE item SET tag = '%s', `edited` = '%s' WHERE id = %d LIMIT 1", + dbesc($tagp[0]['tag'] . (strlen($tagp[0]['tag']) ? ',' : '') . $newtag), + intval($tagp[0]['id']), + dbesc(datetime_convert()) ); } } diff --git a/include/profile_selectors.php b/include/profile_selectors.php index a2cef959d..4700bb96f 100644 --- a/include/profile_selectors.php +++ b/include/profile_selectors.php @@ -7,8 +7,10 @@ function gender_selector($current="",$suffix="") { $o .= "<select name=\"gender$suffix\" id=\"gender-select$suffix\" size=\"1\" >"; foreach($select as $selection) { - $selected = (($selection == $current) ? ' selected="selected" ' : ''); - $o .= "<option value=\"$selection\" $selected >$selection</option>"; + if($selection !== 'NOTRANSLATION') { + $selected = (($selection == $current) ? ' selected="selected" ' : ''); + $o .= "<option value=\"$selection\" $selected >$selection</option>"; + } } $o .= '</select>'; return $o; @@ -20,8 +22,10 @@ function sexpref_selector($current="",$suffix="") { $o .= "<select name=\"sexual$suffix\" id=\"sexual-select$suffix\" size=\"1\" >"; foreach($select as $selection) { - $selected = (($selection == $current) ? ' selected="selected" ' : ''); - $o .= "<option value=\"$selection\" $selected >$selection</option>"; + if($selection !== 'NOTRANSLATION') { + $selected = (($selection == $current) ? ' selected="selected" ' : ''); + $o .= "<option value=\"$selection\" $selected >$selection</option>"; + } } $o .= '</select>'; return $o; @@ -34,8 +38,10 @@ function marital_selector($current="",$suffix="") { $o .= "<select name=\"marital\" id=\"marital-select\" size=\"1\" >"; foreach($select as $selection) { - $selected = (($selection == $current) ? ' selected="selected" ' : ''); - $o .= "<option value=\"$selection\" $selected >$selection</option>"; + if($selection !== 'NOTRANSLATION') { + $selected = (($selection == $current) ? ' selected="selected" ' : ''); + $o .= "<option value=\"$selection\" $selected >$selection</option>"; + } } $o .= '</select>'; return $o; |