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