]> git.mxchange.org Git - friendica.git/blobdiff - mod/contacts.php
forgotten templates
[friendica.git] / mod / contacts.php
index 10a4f6b1b852cf8b1aecabbd23a49568e5e1bf80..c58dc0fc4f0fdffa059cececf6ee9213ff3a6acc 100644 (file)
@@ -1,16 +1,19 @@
 <?php
-
+/**
+ * @file mod/contacts.php
+ */
 use Friendica\App;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBM;
-use Friendica\Model\GlobalContact;
+use Friendica\Model\Contact;
+use Friendica\Model\GContact;
+use Friendica\Model\Group;
 use Friendica\Network\Probe;
 
-require_once 'include/Contact.php';
 require_once 'include/contact_selectors.php';
 require_once 'mod/proxy.php';
-require_once 'include/Photo.php';
+require_once 'include/follow.php';
 
 function contacts_init(App $a) {
        if (! local_user()) {
@@ -30,11 +33,11 @@ function contacts_init(App $a) {
                }
        }
 
-       require_once 'include/group.php';
        require_once 'include/contact_widgets.php';
 
-       if ($_GET['nets'] == "all") {
-               $_GET['nets'] = "";
+       $nets = defaults($_GET, 'nets', '');
+       if ($nets == "all") {
+               $nets = "";
        }
 
        if (! x($a->page,'aside')) {
@@ -58,25 +61,25 @@ function contacts_init(App $a) {
                        '$addr' => (($a->data['contact']['addr'] != "") ? ($a->data['contact']['addr']) : ""),
                        '$network_name' => $networkname,
                        '$network' => t('Network:'),
-                       '$account_type' => account_type($a->data['contact'])
+                       '$account_type' => Contact::getAccountType($a->data['contact'])
                ));
 
-               $finpeople_widget = '';
+               $findpeople_widget = '';
                $follow_widget = '';
                $networks_widget = '';
        } else {
                $vcard_widget = '';
-               $networks_widget .= networks_widget('contacts',$_GET['nets']);
+               $networks_widget = networks_widget('contacts', $nets);
                if (isset($_GET['add'])) {
                        $follow_widget = follow_widget($_GET['add']);
                } else {
                        $follow_widget = follow_widget();
                }
 
-               $findpeople_widget .= findpeople_widget();
+               $findpeople_widget = findpeople_widget();
        }
 
-       $groups_widget .= group_side('contacts','group','full',0,$contact_id);
+       $groups_widget = Group::sidebarWidget('contacts','group','full',0,$contact_id);
 
        $a->page['aside'] .= replace_macros(get_markup_template("contacts-widget-sidebar.tpl"),array(
                '$vcard_widget' => $vcard_widget,
@@ -131,7 +134,7 @@ function contacts_batch_actions(App $a) {
                        if ($r) $count_actions++;
                }
                if (x($_POST, 'contacts_batch_drop')) {
-                       _contact_drop($contact_id, $orig_record);
+                       _contact_drop($orig_record);
                        $count_actions++;
                }
        }
@@ -309,10 +312,10 @@ function _contact_update_profile($contact_id) {
        );
 
        // Update the entry in the contact table
-       update_contact_avatar($data['photo'], local_user(), $contact_id, true);
+       Contact::updateAvatar($data['photo'], local_user(), $contact_id, true);
 
        // Update the entry in the gcontact table
-       GlobalContact::updateFromProbe($data["url"]);
+       GContact::updateFromProbe($data["url"]);
 }
 
 function _contact_block($contact_id, $orig_record) {
@@ -346,7 +349,9 @@ function _contact_archive($contact_id, $orig_record) {
        }
        return $r;
 }
-function _contact_drop($contact_id, $orig_record) {
+
+function _contact_drop($orig_record)
+{
        $a = get_app();
 
        $r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid`
@@ -357,9 +362,8 @@ function _contact_drop($contact_id, $orig_record) {
                return;
        }
 
-       $self = ""; // Unused parameter
-       terminate_friendship($r[0], $self, $orig_record);
-       contact_remove($orig_record['id']);
+       Contact::terminateFriendship($r[0], $orig_record);
+       Contact::remove($orig_record['id']);
 }
 
 
@@ -479,7 +483,7 @@ function contacts_content(App $a) {
                                }
                        }
 
-                       _contact_drop($contact_id, $orig_record[0]);
+                       _contact_drop($orig_record[0]);
                        info( t('Contact has been removed.') . EOL );
                        if (x($_SESSION,'return_url')) {
                                goaway('' . $_SESSION['return_url']);
@@ -512,8 +516,6 @@ function contacts_content(App $a) {
 
                require_once 'include/contact_selectors.php';
 
-               $tpl = get_markup_template("contact_edit.tpl");
-
                switch($contact['rel']) {
                        case CONTACT_IS_FRIEND:
                                $dir_icon = 'images/lrarrow.gif';
@@ -557,7 +559,7 @@ function contacts_content(App $a) {
                }
                $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));
+               $poll_enabled = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL));
 
                $nettype = sprintf( t('Network type: %s'),network_to_name($contact['network'], $contact["url"]));
 
@@ -574,16 +576,30 @@ function contacts_content(App $a) {
 
                $lost_contact = (($contact['archive'] && $contact['term-date'] > NULL_DATE && $contact['term-date'] < datetime_convert('','','now')) ? t('Communications lost with this contact!') : '');
 
+               $fetch_further_information = null;
                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')));
+                       $fetch_further_information = array('fetch_further_information',
+                                                       t('Fetch further information for feeds'),
+                                                       $contact['fetch_further_information'],
+                                                       t("Fetch information like preview pictures, title and teaser from the feed item. You can activate this if the feed doesn't contain much text. Keywords are taken from the meta header in the feed item and are posted as hash tags."),
+                                                               array('0' => t('Disabled'),
+                                                                       '1' => t('Fetch information'),
+                                                                       '3' => t('Fetch keywords'),
+                                                                       '2' => t('Fetch information and keywords')));
                }
-               if (in_array($contact['network'], array(NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2)))
+
+               $poll_interval = null;
+               if (in_array($contact['network'], array(NETWORK_FEED, NETWORK_MAIL))) {
                        $poll_interval = contact_poll_interval($contact['priority'],(! $poll_enabled));
+               }
 
-               if ($contact['network'] == NETWORK_DFRN)
+               $profile_select = null;
+               if ($contact['network'] == NETWORK_DFRN) {
                        $profile_select = contact_profile_assign($contact['profile-id'],(($contact['network'] !== NETWORK_DFRN) ? true : false));
+               }
 
+               $follow = '';
+               $follow_text = '';
                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"]);
@@ -597,7 +613,7 @@ function contacts_content(App $a) {
                // Load contactact related actions like hide, suggest, delete and others
                $contact_actions = contact_actions($contact);
 
-
+               $tpl = get_markup_template("contact_edit.tpl");
                $o .= replace_macros($tpl, array(
                        //'$header' => t('Contact Editor'),
                        '$header' => t("Contact"),
@@ -609,9 +625,7 @@ function contacts_content(App $a) {
                        '$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'],
-                       '$all_friends' => $all_friends,
                        '$relation_text' => $relation_text,
                        '$visit' => sprintf( t('Visit %s\'s profile [%s]'),$contact['name'],$contact['url']),
                        '$blockunblock' => t('Block/Unblock contact'),
@@ -640,6 +654,7 @@ function contacts_content(App $a) {
                        '$blocked' => (($contact['blocked']) ? t('Currently blocked') : ''),
                        '$ignored' => (($contact['readonly']) ? t('Currently ignored') : ''),
                        '$archived' => (($contact['archive']) ? t('Currently archived') : ''),
+                       '$pending' => (($contact['pending']) ? t('Awaiting connection acknowledge') : ''),
                        '$hidden' => array('hidden', t('Hide this contact from others'), ($contact['hidden'] == 1), t('Replies/likes to your public posts <strong>may</strong> still be visible')),
                        '$notify' => array('notify', t('Notification for new posts'), ($contact['notify_new_posts'] == 1), t('Send a notification of every new post of this contact')),
                        '$fetch_further_information' => $fetch_further_information,
@@ -648,12 +663,11 @@ function contacts_content(App $a) {
                        '$photo' => $contact['photo'],
                        '$name' => htmlentities($contact['name']),
                        '$dir_icon' => $dir_icon,
-                       '$alt_text' => $alt_text,
                        '$sparkle' => $sparkle,
                        '$url' => $url,
                        '$profileurllabel' => t('Profile URL'),
                        '$profileurl' => $contact['url'],
-                       '$account_type' => account_type($contact),
+                       '$account_type' => Contact::getAccountType($contact),
                        '$location' => bbcode($contact["location"]),
                        '$location_label' => t("Location:"),
                        '$xmpp' => bbcode($contact["xmpp"]),
@@ -678,36 +692,33 @@ function contacts_content(App $a) {
 
        }
 
-       $blocked = false;
-       $hidden = false;
-       $ignored = false;
-       $all = false;
+       $blocked  = false;
+       $hidden   = false;
+       $ignored  = false;
+       $archived = false;
+       $all      = false;
 
        if(($a->argc == 2) && ($a->argv[1] === 'all')) {
                $sql_extra = '';
                $all = true;
-       }
-       elseif(($a->argc == 2) && ($a->argv[1] === 'blocked')) {
+       } elseif(($a->argc == 2) && ($a->argv[1] === 'blocked')) {
                $sql_extra = " AND `blocked` = 1 ";
                $blocked = true;
-       }
-       elseif(($a->argc == 2) && ($a->argv[1] === 'hidden')) {
+       } elseif(($a->argc == 2) && ($a->argv[1] === 'hidden')) {
                $sql_extra = " AND `hidden` = 1 ";
                $hidden = true;
-       }
-       elseif(($a->argc == 2) && ($a->argv[1] === 'ignored')) {
+       } elseif(($a->argc == 2) && ($a->argv[1] === 'ignored')) {
                $sql_extra = " AND `readonly` = 1 ";
                $ignored = true;
-       }
-       elseif(($a->argc == 2) && ($a->argv[1] === 'archived')) {
+       } elseif(($a->argc == 2) && ($a->argv[1] === 'archived')) {
                $sql_extra = " AND `archive` = 1 ";
                $archived = true;
-       }
-       else
+       } else {
                $sql_extra = " AND `blocked` = 0 ";
+       }
 
-       $search = ((x($_GET,'search')) ? notags(trim($_GET['search'])) : '');
-       $nets = ((x($_GET,'nets')) ? notags(trim($_GET['nets'])) : '');
+       $search = x($_GET, 'search') ? notags(trim($_GET['search'])) : '';
+       $nets = x($_GET, 'nets') ? notags(trim($_GET['nets'])) : '';
 
        $tabs = array(
                array(
@@ -776,25 +787,25 @@ function contacts_content(App $a) {
        $tab_tpl = get_markup_template('common_tabs.tpl');
        $t = replace_macros($tab_tpl, array('$tabs'=>$tabs));
 
-
-
        $searching = false;
-       if($search) {
+       $search_hdr = null;
+       if ($search) {
                $search_hdr = $search;
                $search_txt = dbesc(protect_sprintf(preg_quote($search)));
                $searching = true;
        }
        $sql_extra .= (($searching) ? " AND (name REGEXP '$search_txt' OR url REGEXP '$search_txt'  OR nick REGEXP '$search_txt') " : "");
 
-       if($nets)
+       if ($nets) {
                $sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets));
+       }
 
        $sql_extra2 = ((($sort_type > 0) && ($sort_type <= CONTACT_IS_FRIEND)) ? sprintf(" AND `rel` = %d ",intval($sort_type)) : '');
 
-
        $r = q("SELECT COUNT(*) AS `total` FROM `contact`
                WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ",
-               intval($_SESSION['uid']));
+               intval($_SESSION['uid'])
+       );
        if (DBM::is_result($r)) {
                $a->set_pager_total($r[0]['total']);
                $total = $r[0]['total'];
@@ -824,7 +835,7 @@ function contacts_content(App $a) {
                '$total' => $total,
                '$search' => $search_hdr,
                '$desc' => t('Search your contacts'),
-               '$finding' => (($searching) ? sprintf(t('Results for: %s'),$search) : ""),
+               '$finding' => $searching ? t('Results for: %s', $search) : "",
                '$submit' => t('Find'),
                '$cmd' => $a->cmd,
                '$contacts' => $contacts,
@@ -839,7 +850,6 @@ function contacts_content(App $a) {
                ),
                '$h_batch_actions' => t('Batch Actions'),
                '$paginate' => paginate($a),
-
        ));
 
        return $o;
@@ -878,7 +888,7 @@ function contacts_tab($a, $contact_id, $active_tab) {
        );
 
        // Show this tab only if there is visible friend list
-       $x = GlobalContact::countAllFriends(local_user(), $contact_id);
+       $x = GContact::countAllFriends(local_user(), $contact_id);
        if ($x)
                $tabs[] = array('label'=>t('Contacts'),
                                'url' => "allfriends/".$contact_id,
@@ -888,7 +898,7 @@ function contacts_tab($a, $contact_id, $active_tab) {
                                'accesskey' => 't');
 
        // Show this tab only if there is visible common friend list
-       $common = GlobalContact::countCommonFriends(local_user(), $contact_id);
+       $common = GContact::countCommonFriends(local_user(), $contact_id);
        if ($common)
                $tabs[] = array('label'=>t('Common Friends'),
                                'url' => "common/loc/".local_user()."/".$contact_id,
@@ -916,15 +926,14 @@ function contact_posts($a, $contact_id) {
        if ($r) {
                $contact = $r[0];
                $a->page['aside'] = "";
-               profile_load($a, "", 0, get_contact_details_by_url($contact["url"]));
-       } else
-               $profile = "";
+               profile_load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
+       }
 
        $tab_str = contacts_tab($a, $contact_id, 1);
 
-       $o .= $tab_str;
+       $o = $tab_str;
 
-       $o .= posts_from_contact_url($a, $contact["url"]);
+       $o .= Contact::getPostsFromUrl($contact["url"]);
 
        return $o;
 }
@@ -959,14 +968,14 @@ function _contact_detail_for_template($rr){
        return array(
                'img_hover' => sprintf( t('Visit %s\'s profile [%s]'),$rr['name'],$rr['url']),
                'edit_hover' => t('Edit contact'),
-               'photo_menu' => contact_photo_menu($rr),
+               'photo_menu' => Contact::photoMenu($rr),
                'id' => $rr['id'],
                'alt_text' => $alt_text,
                'dir_icon' => $dir_icon,
                'thumb' => proxy_url($rr['thumb'], false, PROXY_SIZE_THUMB),
                'name' => htmlentities($rr['name']),
                'username' => htmlentities($rr['name']),
-               'account_type' => account_type($rr),
+               'account_type' => Contact::getAccountType($rr),
                'sparkle' => $sparkle,
                'itemurl' => (($rr['addr'] != "") ? $rr['addr'] : $rr['url']),
                'url' => $url,
@@ -985,7 +994,7 @@ function _contact_detail_for_template($rr){
  */
 function contact_actions($contact) {
 
-       $poll_enabled = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2));
+       $poll_enabled = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL));
        $contact_action = array();
 
        // Provide friend suggestion only for Friendica contacts