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