2 function edit_contact(&$a,$contact_id) {
6 function contacts_post(&$a) {
9 if(($a->argc != 3) || (! local_user()))
12 $contact_id = intval($a->argv[1]);
18 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
20 intval($_SESSION['uid'])
25 $photo = str_replace('-4.jpg', '' , $r[0]['photo']);
26 $photos = q("SELECT `id` FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d",
28 intval($_SESSION['uid'])
34 edit_contact($a,$contact_id);
37 $r = q("UPDATE `contact` SET `blocked` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1",
39 intval($_SESSION['uid'])
42 $_SESSION['sysmsg'] .= "Contact has been blocked." . EOL;
45 $r = q("DELETE FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
47 intval($_SESSION['uid']));
49 foreach($photos as $p) {
50 q("DELETE FROM `photos` WHERE `id` = %d LIMIT 1",
54 if($intval($contact_id))
55 q("DELETE * FROM `item` WHERE `contact-id` = %d ",
77 function contacts_content(&$a) {
79 $_SESSION['sysmsg'] .= "Permission denied." . EOL;
83 if(($a->argc2 == 2) && ($a->argv[1] == 'all'))
86 $sql_extra = " AND `blocked` = 0 ";
88 $tpl = file_get_contents("view/contacts-top.tpl");
89 $o .= replace_macros($tpl,array(
90 '$hide_url' => ((strlen($sql_extra)) ? 'contacts/all' : 'contacts' ),
91 '$hide_text' => ((strlen($sql_extra)) ? 'Show Blocked Connections' : 'Hide Blocked Connections')
95 $r = q("SELECT * FROM `contact` WHERE `uid` = %d",
96 intval($_SESSION['uid']));
100 $tpl = file_get_contents("view/contact_template.tpl");
105 $o .= replace_macros($tpl, array(
107 '$thumb' => $rr['thumb'],
108 '$name' => $rr['name'],