X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fcontacts.php;h=93013972f1c583e5ec3986b96a9367c0af834df0;hb=10ede7314136edb1c475e1af546a59ff4c5648cf;hp=11a83f0a0429495ae72001886c6392a8a3b667f7;hpb=0cd241bcbe762e38e2eba0c58800eb60a2240e36;p=friendica.git diff --git a/mod/contacts.php b/mod/contacts.php index 11a83f0a04..93013972f1 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -1,11 +1,15 @@ argc == 2) && intval($a->argv[1])) OR (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) { + if((($a->argc == 2) && intval($a->argv[1])) || (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) { $contact_id = intval($a->argv[1]); $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1", intval(local_user()), @@ -25,8 +29,8 @@ function contacts_init(App $a) { } } - require_once('include/group.php'); - require_once('include/contact_widgets.php'); + require_once 'include/group.php'; + require_once 'include/contact_widgets.php'; if ($_GET['nets'] == "all") { $_GET['nets'] = ""; @@ -39,7 +43,7 @@ function contacts_init(App $a) { if ($contact_id) { $a->data['contact'] = $r[0]; - if (($a->data['contact']['network'] != "") AND ($a->data['contact']['network'] != NETWORK_DFRN)) { + if (($a->data['contact']['network'] != "") && ($a->data['contact']['network'] != NETWORK_DFRN)) { $networkname = format_network_name($a->data['contact']['network'],$a->data['contact']['url']); } else { $networkname = ''; @@ -81,16 +85,16 @@ function contacts_init(App $a) { '$networks_widget' => $networks_widget )); - $base = z_root(); + $base = System::baseUrl(); $tpl = get_markup_template("contacts-head.tpl"); $a->page['htmlhead'] .= replace_macros($tpl,array( - '$baseurl' => App::get_baseurl(true), + '$baseurl' => System::baseUrl(true), '$base' => $base )); $tpl = get_markup_template("contacts-end.tpl"); $a->page['end'] .= replace_macros($tpl,array( - '$baseurl' => App::get_baseurl(true), + '$baseurl' => System::baseUrl(true), '$base' => $base )); @@ -107,7 +111,7 @@ function contacts_batch_actions(App $a) { ); $count_actions=0; - foreach ($orig_records as $orig_record) { + foreach($orig_records as $orig_record) { $contact_id = $orig_record['id']; if (x($_POST, 'contacts_batch_update')) { _contact_update($contact_id); @@ -136,7 +140,8 @@ function contacts_batch_actions(App $a) { if (x($_SESSION,'return_url')) { goaway('' . $_SESSION['return_url']); - } else { + } + else { goaway('contacts'); } @@ -193,10 +198,8 @@ function contacts_post(App $a) { $ffi_keyword_blacklist = escape_tags(trim($_POST['ffi_keyword_blacklist'])); $priority = intval($_POST['poll']); - - if ($priority > 5 || $priority < 0) { + if($priority > 5 || $priority < 0) $priority = 0; - } $info = escape_tags(trim($_POST['info'])); @@ -213,20 +216,17 @@ function contacts_post(App $a) { intval($contact_id), intval(local_user()) ); - if ($r) { + if($r) info( t('Contact updated.') . EOL); - } else { + else notice( t('Failed to update contact record.') . EOL); - } - $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", + $r = q("select * from contact where id = %d and uid = %d limit 1", intval($contact_id), intval(local_user()) ); - - if (dbm::is_result($r)) { + if($r && dbm::is_result($r)) $a->data['contact'] = $r[0]; - } return; @@ -244,7 +244,7 @@ function _contact_update($contact_id) { return; if ($r[0]["network"] == NETWORK_OSTATUS) { - $result = new_contact($uid, $r[0]["url"], false); + $result = new_contact($uid, $r[0]["url"], false, $r[0]["network"]); if ($result['success']) $r = q("UPDATE `contact` SET `subhub` = 1 WHERE `id` = %d", @@ -264,10 +264,10 @@ function _contact_update_profile($contact_id) { if ($uid != local_user()) return; - $data = probe_url($r[0]["url"]); + $data = Probe::uri($r[0]["url"], "", 0, false); // "Feed" or "Unknown" is mostly a sign of communication problems - if ((in_array($data["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) AND ($data["network"] != $r[0]["network"])) + if ((in_array($data["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) && ($data["network"] != $r[0]["network"])) return; $updatefields = array("name", "nick", "url", "addr", "batch", "notify", "poll", "request", "confirm", @@ -281,18 +281,18 @@ function _contact_update_profile($contact_id) { $update["subhub"] = true; } - foreach ($updatefields AS $field) - if (isset($data[$field]) AND ($data[$field] != "")) + foreach($updatefields AS $field) + if (isset($data[$field]) && ($data[$field] != "")) $update[$field] = $data[$field]; $update["nurl"] = normalise_link($data["url"]); $query = ""; - if (isset($data["priority"]) AND ($data["priority"] != 0)) + if (isset($data["priority"]) && ($data["priority"] != 0)) $query = "`priority` = ".intval($data["priority"]); - foreach ($update AS $key => $value) { + foreach($update AS $key => $value) { if ($query != "") $query .= ", "; @@ -308,7 +308,7 @@ function _contact_update_profile($contact_id) { ); // Update the entry in the contact table - update_contact_avatar($data['photo'], local_user(), $contact_id); + update_contact_avatar($data['photo'], local_user(), $contact_id, true); // Update the entry in the gcontact table update_gcontact_from_probe($data["url"]); @@ -348,7 +348,16 @@ function _contact_archive($contact_id, $orig_record) { function _contact_drop($contact_id, $orig_record) { $a = get_app(); - terminate_friendship($a->user,$a->contact,$orig_record); + $r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid` + WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1", + intval($a->user['uid']) + ); + if (!dbm::is_result($r)) { + return; + } + + $self = ""; // Unused parameter + terminate_friendship($r[0], $self, $orig_record); contact_remove($orig_record['id']); } @@ -365,10 +374,10 @@ function contacts_content(App $a) { return; } - if ($a->argc == 3) { + if($a->argc == 3) { $contact_id = intval($a->argv[1]); - if (! $contact_id) + if(! $contact_id) return; $cmd = $a->argv[2]; @@ -378,25 +387,25 @@ function contacts_content(App $a) { intval(local_user()) ); - if (! count($orig_record)) { + if(! count($orig_record)) { notice( t('Could not access contact record.') . EOL); goaway('contacts'); return; // NOTREACHED } - if ($cmd === 'update') { + if($cmd === 'update') { _contact_update($contact_id); goaway('contacts/' . $contact_id); // NOTREACHED } - if ($cmd === 'updateprofile') { + if($cmd === 'updateprofile') { _contact_update_profile($contact_id); goaway('crepair/' . $contact_id); // NOTREACHED } - if ($cmd === 'block') { + if($cmd === 'block') { $r = _contact_block($contact_id, $orig_record[0]); if ($r) { $blocked = (($orig_record[0]['blocked']) ? 0 : 1); @@ -407,7 +416,7 @@ function contacts_content(App $a) { return; // NOTREACHED } - if ($cmd === 'ignore') { + if($cmd === 'ignore') { $r = _contact_ignore($contact_id, $orig_record[0]); if ($r) { $readonly = (($orig_record[0]['readonly']) ? 0 : 1); @@ -419,7 +428,7 @@ function contacts_content(App $a) { } - if ($cmd === 'archive') { + if($cmd === 'archive') { $r = _contact_archive($contact_id, $orig_record[0]); if ($r) { $archived = (($orig_record[0]['archive']) ? 0 : 1); @@ -430,16 +439,16 @@ function contacts_content(App $a) { return; // NOTREACHED } - if ($cmd === 'drop') { + if($cmd === 'drop') { // Check if we should do HTML-based delete confirmation - if ($_REQUEST['confirm']) { + if($_REQUEST['confirm']) { //