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