X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fcontacts.php;h=a129a665d131d67f2e55ab020218e01d2d22e1ef;hb=a0530d1066d7268f1b1ea67bc3c254e9f9fc5ec8;hp=9394e81bb0f34ca86b830eb265d433086c6e7e6b;hpb=9d5384f107ddb5d4c652e75c91ef8622a00d3ce0;p=friendica.git diff --git a/mod/contacts.php b/mod/contacts.php index 9394e81bb0..a129a665d1 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 )); @@ -191,13 +195,13 @@ function contacts_post(App $a) { $fetch_further_information = intval($_POST['fetch_further_information']); - $ffi_keyword_blacklist = fix_mce_lf(escape_tags(trim($_POST['ffi_keyword_blacklist']))); + $ffi_keyword_blacklist = escape_tags(trim($_POST['ffi_keyword_blacklist'])); $priority = intval($_POST['poll']); if($priority > 5 || $priority < 0) $priority = 0; - $info = fix_mce_lf(escape_tags(trim($_POST['info']))); + $info = escape_tags(trim($_POST['info'])); $r = q("UPDATE `contact` SET `profile-id` = %d, `priority` = %d , `info` = '%s', `hidden` = %d, `notify_new_posts` = %d, `fetch_further_information` = %d, @@ -240,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", @@ -260,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", @@ -278,14 +282,14 @@ function _contact_update_profile($contact_id) { } foreach($updatefields AS $field) - if (isset($data[$field]) AND ($data[$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) { @@ -304,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"]); @@ -344,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']); } @@ -490,13 +503,13 @@ function contacts_content(App $a) { $contact = $a->data['contact']; $a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), array( - '$baseurl' => App::get_baseurl(true), + '$baseurl' => System::baseUrl(true), )); $a->page['end'] .= replace_macros(get_markup_template('contact_end.tpl'), array( - '$baseurl' => App::get_baseurl(true), + '$baseurl' => System::baseUrl(true), )); - require_once('include/contact_selectors.php'); + require_once 'include/contact_selectors.php'; $tpl = get_markup_template("contact_edit.tpl"); @@ -534,13 +547,13 @@ function contacts_content(App $a) { $insecure = t('Private communications are not available for this contact.'); - $last_update = (($contact['last-update'] == '0000-00-00 00:00:00') + $last_update = (($contact['last-update'] <= NULL_DATE) ? t('Never') : datetime_convert('UTC',date_default_timezone_get(),$contact['last-update'],'D, j M Y, g:i A')); - if($contact['last-update'] !== '0000-00-00 00:00:00') + if ($contact['last-update'] > NULL_DATE) { $last_update .= ' ' . (($contact['last-update'] <= $contact['success_update']) ? t("\x28Update was successful\x29") : t("\x28Update was not successful\x29")); - + } $lblsuggest = (($contact['network'] === NETWORK_DFRN) ? t('Suggest friends') : ''); $poll_enabled = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2)); @@ -558,21 +571,27 @@ function contacts_content(App $a) { // tabs $tab_str = contacts_tab($a, $contact_id, 2); - $lost_contact = (($contact['archive'] && $contact['term-date'] != '0000-00-00 00:00:00' && $contact['term-date'] < datetime_convert('','','now')) ? t('Communications lost with this contact!') : ''); + $lost_contact = (($contact['archive'] && $contact['term-date'] > NULL_DATE && $contact['term-date'] < datetime_convert('','','now')) ? t('Communications lost with this contact!') : ''); - if ($contact['network'] == NETWORK_FEED) + if ($contact['network'] == NETWORK_FEED) { $fetch_further_information = array('fetch_further_information', t('Fetch further information for feeds'), $contact['fetch_further_information'], t('Fetch further information for feeds'), array('0'=>t('Disabled'), '1'=>t('Fetch information'), '2'=>t('Fetch information and keywords'))); - + } if (in_array($contact['network'], array(NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2))) $poll_interval = contact_poll_interval($contact['priority'],(! $poll_enabled)); if ($contact['network'] == NETWORK_DFRN) $profile_select = contact_profile_assign($contact['profile-id'],(($contact['network'] !== NETWORK_DFRN) ? true : false)); - if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS)) AND - ($contact['rel'] == CONTACT_IS_FOLLOWER)) - $follow = App::get_baseurl(true)."/follow?url=".urlencode($contact["url"]); + if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS))) { + if ($contact['rel'] == CONTACT_IS_FOLLOWER) { + $follow = System::baseUrl(true)."/follow?url=".urlencode($contact["url"]); + $follow_text = t("Connect/Follow"); + } elseif ($contact['rel'] == CONTACT_IS_FRIEND) { + $follow = System::baseUrl(true)."/unfollow?url=".urlencode($contact["url"]); + $follow_text = t("Disconnect/Unfollow"); + } + } // Load contactact related actions like hide, suggest, delete and others $contact_actions = contact_actions($contact); @@ -586,6 +605,8 @@ function contacts_content(App $a) { '$lbl_vis1' => t('Profile Visibility'), '$lbl_vis2' => sprintf( t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $contact['name']), '$lbl_info1' => t('Contact Information / Notes'), + '$lbl_info2' => t('Their personal note'), + '$reason' => trim(notags($contact['reason'])), '$infedit' => t('Edit contact notes'), '$common_text' => $common_text, '$common_link' => 'common/loc/' . local_user() . '/' . $contact['id'], @@ -607,7 +628,7 @@ function contacts_content(App $a) { '$last_update' => $last_update, '$udnow' => t('Update now'), '$follow' => $follow, - '$follow_text' => t("Connect/Follow"), + '$follow_text' => $follow_text, '$profile_select' => $profile_select, '$contact_id' => $contact['id'], '$block_text' => (($contact['blocked']) ? t('Unblock') : t('Block') ), @@ -796,7 +817,7 @@ function contacts_content(App $a) { $tpl = get_markup_template("contacts-template.tpl"); $o .= replace_macros($tpl, array( - '$baseurl' => z_root(), + '$baseurl' => System::baseUrl(), '$header' => t('Contacts') . (($nets) ? ' - ' . network_to_name($nets) : ''), '$tabs' => $t, '$total' => $total, @@ -828,7 +849,7 @@ function contacts_content(App $a) { * * Available Pages are 'Status', 'Profile', 'Contacts' and 'Common Friends' * - * @param app $a + * @param App $a * @param int $contact_id The ID of the contact * @param int $active_tab 1 if tab should be marked as active *