]> git.mxchange.org Git - friendica.git/blobdiff - mod/contacts.php
ostatus completion of threads now works with longer threads well.
[friendica.git] / mod / contacts.php
index 769239fe0cd81c62c5fd41cb1841978044fa1fbe..a405cedbc6329b6d80cf937a8788b0b67c39d9c7 100644 (file)
@@ -2,6 +2,7 @@
 
 require_once('include/Contact.php');
 require_once('include/socgraph.php');
+require_once('include/contact_selectors.php');
 
 function contacts_init(&$a) {
        if(! local_user())
@@ -28,21 +29,42 @@ function contacts_init(&$a) {
 
        if($contact_id) {
                        $a->data['contact'] = $r[0];
-                       $o .= '<div class="vcard">';
-                       $o .= '<div class="fn">' . $a->data['contact']['name'] . '</div>';
-                       $o .= '<div id="profile-photo-wrapper"><img class="photo" style="width: 175px; height: 175px;" src="' . $a->data['contact']['photo'] . '" alt="' . $a->data['contact']['name'] . '" /></div>';
-                       $o .= '</div>';
-                       $a->page['aside'] .= $o;
-
-       }       
-       else
-               $a->page['aside'] .= follow_widget();
+                       $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"),array(
+                               '$name' => $a->data['contact']['name'],
+                               '$photo' => $a->data['contact']['photo']
+                       ));
+                       $follow_widget = '';
+       }
+       else {
+               $vcard_widget = '';
+               $follow_widget = follow_widget();
+       }
 
-       $a->page['aside'] .= group_side('contacts','group',false,0,$contact_id);
+       $groups_widget .= group_side('contacts','group',false,0,$contact_id);
+       $findpeople_widget .= findpeople_widget();
+       $networks_widget .= networks_widget('contacts',$_GET['nets']);
+       $a->page['aside'] .= replace_macros(get_markup_template("contacts-widget-sidebar.tpl"),array(
+               '$vcard_widget' => $vcard_widget,
+               '$follow_widget' => $follow_widget,
+               '$groups_widget' => $groups_widget,
+               '$findpeople_widget' => $findpeople_widget,
+               '$networks_widget' => $networks_widget
+       ));
+
+       $base = $a->get_baseurl();
+       $tpl = get_markup_template("contacts-head.tpl");
+       $a->page['htmlhead'] .= replace_macros($tpl,array(
+               '$baseurl' => $a->get_baseurl(true),
+               '$base' => $base
+       ));
+
+       $tpl = get_markup_template("contacts-end.tpl");
+       $a->page['end'] .= replace_macros($tpl,array(
+               '$baseurl' => $a->get_baseurl(true),
+               '$base' => $base
+       ));
 
-       $a->page['aside'] .= findpeople_widget();
 
-       $a->page['aside'] .= networks_widget('contacts',$_GET['nets']);
 }
 
 function contacts_post(&$a) {
@@ -190,6 +212,9 @@ function contacts_content(&$a) {
                                intval($contact_id),
                                intval(local_user())
                        );
+                       if ($archived) {
+                               q("UPDATE `item` SET `private` = 2 WHERE `contact-id` = %d AND `uid` = %d", intval($contact_id), intval(local_user()));
+                       }
                        if($r) {
                                //notice( t('Contact has been ') . (($archived) ? t('archived') : t('unarchived')) . EOL );
                                info( (($archived) ? t('Contact has been archived') : t('Contact has been unarchived')) . EOL );
@@ -200,6 +225,36 @@ function contacts_content(&$a) {
 
                if($cmd === 'drop') {
 
+                       // Check if we should do HTML-based delete confirmation
+                       if($_REQUEST['confirm']) {
+                               // <form> can't take arguments in its "action" parameter
+                               // so add any arguments as hidden inputs
+                               $query = explode_querystring($a->query_string);
+                               $inputs = array();
+                               foreach($query['args'] as $arg) {
+                                       if(strpos($arg, 'confirm=') === false) {
+                                               $arg_parts = explode('=', $arg);
+                                               $inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]);
+                                       }
+                               }
+
+                               $a->page['aside'] = '';
+                               return replace_macros(get_markup_template('confirm.tpl'), array(
+                                       '$method' => 'get',
+                                       '$message' => t('Do you really want to delete this contact?'),
+                                       '$extra_inputs' => $inputs,
+                                       '$confirm' => t('Yes'),
+                                       '$confirm_url' => $query['base'],
+                                       '$confirm_name' => 'confirmed',
+                                       '$cancel' => t('Cancel'),
+                               ));
+                       }
+                       // Now check how the user responded to the confirmation query
+                       if($_REQUEST['canceled']) {
+                               goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']);
+
+                       }
+
                        require_once('include/Contact.php');
 
                        terminate_friendship($a->user,$a->contact,$orig_record[0]);
@@ -214,19 +269,27 @@ function contacts_content(&$a) {
                }
        }
 
+
+
+       $_SESSION['return_url'] = $a->query_string;
+
        if((x($a->data,'contact')) && (is_array($a->data['contact']))) {
 
                $contact_id = $a->data['contact']['id'];
                $contact = $a->data['contact'];
 
-               $editselect = 'exact';
-               if(intval(get_pconfig(local_user(),'system','plaintext')))
-                       $editselect = 'none';
+               $editselect = 'none';
+               if( feature_enabled(local_user(),'richtext') )
+                       $editselect = 'exact';
 
                $a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), array(
                        '$baseurl' => $a->get_baseurl(true),
                        '$editselect' => $editselect,
                ));
+               $a->page['end'] .= replace_macros(get_markup_template('contact_end.tpl'), array(
+                       '$baseurl' => $a->get_baseurl(true),
+                       '$editselect' => $editselect,
+               ));
 
                require_once('include/contact_selectors.php');
 
@@ -315,8 +378,9 @@ function contacts_content(&$a) {
                $tab_tpl = get_markup_template('common_tabs.tpl');
                $tab_str = replace_macros($tab_tpl, array('$tabs' => $tabs));
 
+               $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!') : '');
 
-               $o .= replace_macros($tpl,array(
+               $o .= replace_macros($tpl, array(
                        '$header' => t('Contact Editor'),
                        '$tab_str' => $tab_str,
                        '$submit' => t('Submit'),
@@ -339,6 +403,7 @@ function contacts_content(&$a) {
                        '$poll_interval' => contact_poll_interval($contact['priority'],(! $poll_enabled)),
                        '$poll_enabled' => $poll_enabled,
                        '$lastupdtext' => t('Last update:'),
+                       '$lost_contact' => $lost_contact,
                        '$updpub' => t('Update public posts'),
                        '$last_update' => $last_update,
                        '$udnow' => t('Update now'),
@@ -357,7 +422,7 @@ function contacts_content(&$a) {
                        '$dir_icon' => $dir_icon,
                        '$alt_text' => $alt_text,
                        '$sparkle' => $sparkle,
-                       '$url' => $url
+                       '$url' => $url,
 
                ));
 
@@ -374,8 +439,6 @@ function contacts_content(&$a) {
        $ignored = false;
        $all = false;
 
-       $_SESSION['return_url'] = $a->query_string;
-
        if(($a->argc == 2) && ($a->argv[1] === 'all')) {
                $sql_extra = '';
                $all = true;
@@ -457,12 +520,13 @@ function contacts_content(&$a) {
 
 
 
-
+       $searching = false;
        if($search) {
                $search_hdr = $search;
-               $search = dbesc($search.'*');
+               $search_txt = dbesc(protect_sprintf(preg_quote($search)));
+               $searching = true;
        }
-       $sql_extra .= ((strlen($search)) ? " AND MATCH `name` AGAINST ('$search' IN BOOLEAN MODE) " : "");
+       $sql_extra .= (($searching) ? " AND `name` REGEXP '$search_txt' " : "");
 
        if($nets)
                $sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets));
@@ -479,7 +543,6 @@ function contacts_content(&$a) {
        }
 
 
-
        $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ORDER BY `name` ASC LIMIT %d , %d ",
                intval($_SESSION['uid']),
                intval($a->pager['start']),
@@ -540,13 +603,13 @@ function contacts_content(&$a) {
        }
        
        $tpl = get_markup_template("contacts-template.tpl");
-       $o .= replace_macros($tpl,array(
+       $o .= replace_macros($tpl, array(
                '$header' => t('Contacts') . (($nets) ? ' - ' . network_to_name($nets) : ''),
                '$tabs' => $t,
                '$total' => $total,
                '$search' => $search_hdr,
                '$desc' => t('Search your contacts'),
-               '$finding' => (strlen($search) ? t('Finding: ') . "'" . $search . "'" : ""),
+               '$finding' => (($searching) ? t('Finding: ') . "'" . $search . "'" : ""),
                '$submit' => t('Find'),
                '$cmd' => $a->cmd,
                '$contacts' => $contacts,