]> git.mxchange.org Git - friendica.git/blob - mod/suggest.php
Merge pull request #3444 from annando/1705-mail-duplicates
[friendica.git] / mod / suggest.php
1 <?php
2
3 use Friendica\App;
4
5 require_once('include/socgraph.php');
6 require_once('include/contact_widgets.php');
7
8 function suggest_init(App $a) {
9         if (! local_user()) {
10                 return;
11         }
12
13         if (x($_GET,'ignore') && intval($_GET['ignore'])) {
14                 // Check if we should do HTML-based delete confirmation
15                 if ($_REQUEST['confirm']) {
16                         // <form> can't take arguments in its "action" parameter
17                         // so add any arguments as hidden inputs
18                         $query = explode_querystring($a->query_string);
19                         $inputs = array();
20                         foreach ($query['args'] as $arg) {
21                                 if (strpos($arg, 'confirm=') === false) {
22                                         $arg_parts = explode('=', $arg);
23                                         $inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]);
24                                 }
25                         }
26
27                         $a->page['content'] = replace_macros(get_markup_template('confirm.tpl'), array(
28                                 '$method' => 'get',
29                                 '$message' => t('Do you really want to delete this suggestion?'),
30                                 '$extra_inputs' => $inputs,
31                                 '$confirm' => t('Yes'),
32                                 '$confirm_url' => $query['base'],
33                                 '$confirm_name' => 'confirmed',
34                                 '$cancel' => t('Cancel'),
35                         ));
36                         $a->error = 1; // Set $a->error so the other module functions don't execute
37                         return;
38                 }
39                 // Now check how the user responded to the confirmation query
40                 if (!$_REQUEST['canceled']) {
41                         q("INSERT INTO `gcign` ( `uid`, `gcid` ) VALUES ( %d, %d ) ",
42                                 intval(local_user()),
43                                 intval($_GET['ignore'])
44                         );
45                 }
46         }
47
48 }
49
50
51
52
53
54 function suggest_content(App $a) {
55
56         require_once("mod/proxy.php");
57
58         $o = '';
59         if (! local_user()) {
60                 notice( t('Permission denied.') . EOL);
61                 return;
62         }
63
64         $_SESSION['return_url'] = App::get_baseurl() . '/' . $a->cmd;
65
66         $a->page['aside'] .= findpeople_widget();
67         $a->page['aside'] .= follow_widget();
68
69
70         $r = suggestion_query(local_user());
71
72         if (! dbm::is_result($r)) {
73                 $o .= t('No suggestions available. If this is a new site, please try again in 24 hours.');
74                 return $o;
75         }
76
77         require_once 'include/contact_selectors.php';
78
79         foreach ($r as $rr) {
80
81                 $connlnk = App::get_baseurl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
82                 $ignlnk = App::get_baseurl() . '/suggest?ignore=' . $rr['id'];
83                 $photo_menu = array(
84                         'profile' => array(t("View Profile"), zrl($rr["url"])),
85                         'follow' => array(t("Connect/Follow"), $connlnk),
86                         'hide' => array(t('Ignore/Hide'), $ignlnk)
87                 );
88
89                 $contact_details = get_contact_details_by_url($rr["url"], local_user(), $rr);
90
91                 $entry = array(
92                         'url' => zrl($rr['url']),
93                         'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
94                         'img_hover' => $rr['url'],
95                         'name' => $contact_details['name'],
96                         'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
97                         'details'       => $contact_details['location'],
98                         'tags'          => $contact_details['keywords'],
99                         'about'         => $contact_details['about'],
100                         'account_type'  => account_type($contact_details),
101                         'ignlnk' => $ignlnk,
102                         'ignid' => $rr['id'],
103                         'conntxt' => t('Connect'),
104                         'connlnk' => $connlnk,
105                         'photo_menu' => $photo_menu,
106                         'ignore' => t('Ignore/Hide'),
107                         'network' => network_to_name($rr['network'], $rr['url']),
108                         'id' => ++$id,
109                 );
110                 $entries[] = $entry;
111         }
112
113         $tpl = get_markup_template('viewcontact_template.tpl');
114
115         $o .= replace_macros($tpl,array(
116                 '$title' => t('Friend Suggestions'),
117                 '$contacts' => $entries,
118         ));
119
120         return $o;
121 }