function contacts_init(&$a) { if (!local_user()) { return; } $contact_id = 0; if ($a->argc == 2 && intval($a->argv[1])) { $contact_id = intval($a->argv[1]); $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1", intval(local_user()), intval($contact_id)); if (!count($r)) { $contact_id = 0; } } require_once 'include/group.php'; require_once 'include/contact_widgets.php'; if (!x($a->page, 'aside')) { $a->page['aside'] = ''; } if ($contact_id) { $a->data['contact'] = $r[0]; $o .= '<div class="vcard">'; $o .= '<div class="fn">' . $a->data['contact']['name'] . '</div>'; $o .= '<div id="profile-photo-wrapper"><img class="photo" style="width: 175px; height: 175px;" src="' . $a->data['contact']['photo'] . '" alt="' . $a->data['contact']['name'] . '" /></div>'; $o .= '</div>'; $a->page['aside'] .= $o; } else { $a->page['aside'] .= follow_widget(); } $a->page['aside'] .= group_side('contacts', 'group', false, 0, $contact_id); $a->page['aside'] .= findpeople_widget(); $a->page['aside'] .= networks_widget('contacts', $_GET['nets']); }
function network_init(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); return; } $group_id = $a->argc > 1 && intval($a->argv[1]) ? intval($a->argv[1]) : 0; require_once 'include/group.php'; require_once 'include/contact_widgets.php'; if (!x($a->page, 'aside')) { $a->page['aside'] = ''; } $search = x($_GET, 'search') ? escape_tags($_GET['search']) : ''; if (x($_GET, 'save')) { $r = q("select * from `search` where `uid` = %d and `term` = '%s' limit 1", intval(local_user()), dbesc($search)); if (!count($r)) { q("insert into `search` ( `uid`,`term` ) values ( %d, '%s') ", intval(local_user()), dbesc($search)); } } if (x($_GET, 'remove')) { q("delete from `search` where `uid` = %d and `term` = '%s' limit 1", intval(local_user()), dbesc($search)); } // search terms header if (x($_GET, 'search')) { $a->page['content'] .= '<h2>' . t('Search Results For:') . ' ' . $search . '</h2>'; } $a->page['aside'] .= group_side('network', 'network', true, $group_id); $a->page['aside'] .= networks_widget($a->get_baseurl() . '/network', $_GET['nets'] ? $_GET['nets'] : ''); $a->page['aside'] .= saved_searches($search); }
function group_post(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); return; } if ($a->argc == 2 && $a->argv[1] == 'new') { $name = notags(trim($_POST['groupname'])); $r = group_add($name); if ($r) { notice(t('Group created.') . EOL); $r = group_byname($name); if ($r) { goaway($a->get_baseurl() . '/group/' . $r); } } else { notice(t('Could not create group.') . EOL); } goaway($a->get_baseurl() . '/group'); return; // NOTREACHED } if ($a->argc == 2 && intval($a->argv[1])) { $r = q("SELECT * FROM `group` WHERE `id` = %d LIMIT 1", intval($a->argv[1])); if (!count($r)) { notice(t('Group not found.') . EOL); goaway($a->get_baseurl() . '/contacts'); } $group = $r[0]; $groupname = notags(trim($_POST['groupname'])); if (strlen($groupname) && $groupname != $group['name']) { $r = q("UPDATE `group` SET `name` = '%s' WHERE `id` = %d LIMIT 1", dbesc($groupname), intval($group['id'])); if ($r) { notice(t('Group name changed.') . EOL); } } $members = $_POST['group_members_select']; array_walk($members, 'validate_members'); $r = q("DELETE FROM `group_member` WHERE `gid` = %d ", intval($a->argv[1])); $result = true; if (count($members)) { foreach ($members as $member) { $r = q("INSERT INTO `group_member` ( `gid`, `contact-id`)\n\t\t\t\t\tVALUES ( %d, %d )", intval($group['id']), intval($member)); if (!$r) { $result = false; } } } if ($result) { notice(t('Membership list updated.') . EOL); } $a->page['aside'] = group_side(); } }
function nogroup_init(&$a) { if (!local_user()) { return; } require_once 'include/group.php'; require_once 'include/contact_widgets.php'; if (!x($a->page, 'aside')) { $a->page['aside'] = ''; } $a->page['aside'] .= group_side('contacts', 'group', 'extended', 0, $contact_id); }
function contacts_init(&$a) { if (!local_user()) { return; } $contact_id = 0; if ($a->argc == 2 && intval($a->argv[1]) or $a->argc == 3 && intval($a->argv[1]) && $a->argv[2] == "posts") { $contact_id = intval($a->argv[1]); $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1", intval(local_user()), intval($contact_id)); if (!count($r)) { $contact_id = 0; } } require_once 'include/group.php'; require_once 'include/contact_widgets.php'; if ($_GET['nets'] == "all") { $_GET['nets'] = ""; } if (!x($a->page, 'aside')) { $a->page['aside'] = ''; } if ($contact_id) { $a->data['contact'] = $r[0]; if ($a->data['contact']['network'] != "" and $a->data['contact']['network'] != NETWORK_DFRN) { $networkname = format_network_name($a->data['contact']['network'], $a->data['contact']['url']); } else { $networkname = ''; } $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), array('$name' => htmlentities($a->data['contact']['name']), '$photo' => $a->data['contact']['photo'], '$url' => $a->data['contact']['network'] == NETWORK_DFRN ? z_root() . "/redir/" . $a->data['contact']['id'] : $a->data['contact']['url'], '$addr' => $a->data['contact']['addr'] != "" ? $a->data['contact']['addr'] : "", '$network_name' => $networkname, '$network' => t('Network:'), 'account_type' => $a->data['contact']['forum'] || $a->data['contact']['prv'] ? t('Forum') : '')); $finpeople_widget = ''; $follow_widget = ''; $networks_widget = ''; } else { $vcard_widget = ''; $networks_widget .= networks_widget('contacts', $_GET['nets']); if (isset($_GET['add'])) { $follow_widget = follow_widget($_GET['add']); } else { $follow_widget = follow_widget(); } $findpeople_widget .= findpeople_widget(); } $groups_widget .= group_side('contacts', 'group', 'full', 0, $contact_id); $a->page['aside'] .= replace_macros(get_markup_template("contacts-widget-sidebar.tpl"), array('$vcard_widget' => $vcard_widget, '$findpeople_widget' => $findpeople_widget, '$follow_widget' => $follow_widget, '$groups_widget' => $groups_widget, '$networks_widget' => $networks_widget)); $base = z_root(); $tpl = get_markup_template("contacts-head.tpl"); $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$base' => $base)); $tpl = get_markup_template("contacts-end.tpl"); $a->page['end'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$base' => $base)); }
function contacts_init(&$a) { if (!local_user()) { return; } $contact_id = 0; if ($a->argc == 2 && intval($a->argv[1])) { $contact_id = intval($a->argv[1]); $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1", intval(local_user()), intval($contact_id)); if (!count($r)) { $contact_id = 0; } } require_once 'include/group.php'; require_once 'include/contact_widgets.php'; if (!x($a->page, 'aside')) { $a->page['aside'] = ''; } if ($contact_id) { $a->data['contact'] = $r[0]; $o .= '<div class="vcard">'; $o .= '<div class="fn">' . $a->data['contact']['name'] . '</div>'; $o .= '<div id="profile-photo-wrapper"><img class="photo" style="width: 175px; height: 175px;" src="' . $a->data['contact']['photo'] . '" alt="' . $a->data['contact']['name'] . '" /></div>'; $o .= '</div>'; $a->page['aside'] .= $o; } else { $a->page['aside'] .= follow_widget(); } $a->page['aside'] .= group_side('contacts', 'group', false, 0, $contact_id); $a->page['aside'] .= findpeople_widget(); $a->page['aside'] .= networks_widget('contacts', $_GET['nets']); $base = $a->get_baseurl(); $a->page['htmlhead'] .= '<script src="' . $a->get_baseurl(true) . '/library/jquery_ac/friendica.complete.js" ></script>'; $a->page['htmlhead'] .= <<<EOT <script>\$(document).ready(function() { \tvar a; \ta = \$("#contacts-search").autocomplete({ \t\tserviceUrl: '{$base}/acl', \t\tminChars: 2, \t\twidth: 350, \t}); \ta.setOptions({ params: { type: 'a' }}); }); </script> EOT; }
function group_post(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); return; } if ($a->argc == 2 && $a->argv[1] === 'new') { check_form_security_token_redirectOnErr('/group/new', 'group_edit'); $name = notags(trim($_POST['groupname'])); $r = group_add(local_user(), $name); if ($r) { info(t('Group created.') . EOL); $r = group_byname(local_user(), $name); if ($r) { goaway($a->get_baseurl() . '/group/' . $r); } } else { notice(t('Could not create group.') . EOL); } goaway($a->get_baseurl() . '/group'); return; // NOTREACHED } if ($a->argc == 2 && intval($a->argv[1])) { check_form_security_token_redirectOnErr('/group', 'group_edit'); $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[1]), intval(local_user())); if (!count($r)) { notice(t('Group not found.') . EOL); goaway($a->get_baseurl() . '/contacts'); return; // NOTREACHED } $group = $r[0]; $groupname = notags(trim($_POST['groupname'])); if (strlen($groupname) && $groupname != $group['name']) { $r = q("UPDATE `group` SET `name` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1", dbesc($groupname), intval(local_user()), intval($group['id'])); if ($r) { info(t('Group name changed.') . EOL); } } $a->page['aside'] = group_side(); } return; }
function contacts_init(&$a) { if (!local_user()) { return; } $contact_id = 0; if ($a->argc == 2 && intval($a->argv[1])) { $contact_id = intval($a->argv[1]); $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1", intval(local_user()), intval($contact_id)); if (!count($r)) { $contact_id = 0; } } require_once 'include/group.php'; require_once 'include/contact_widgets.php'; if (!x($a->page, 'aside')) { $a->page['aside'] = ''; } if ($contact_id) { $a->data['contact'] = $r[0]; $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), array('$name' => $a->data['contact']['name'], '$photo' => $a->data['contact']['photo'], '$url' => $a->data['contact']['network'] == NETWORK_DFRN ? $a->get_baseurl() . "/redir/" . $a->data['contact']['id'] : $a->data['contact']['url'])); $follow_widget = ''; } else { $vcard_widget = ''; if (isset($_GET['add'])) { $follow_widget = follow_widget($_GET['add']); } else { $follow_widget = follow_widget(); } } if ($_GET['nets'] == "all") { $_GET['nets'] = ""; } $groups_widget .= group_side('contacts', 'group', false, 0, $contact_id); $findpeople_widget .= findpeople_widget(); $networks_widget .= networks_widget('contacts', $_GET['nets']); $a->page['aside'] .= replace_macros(get_markup_template("contacts-widget-sidebar.tpl"), array('$vcard_widget' => $vcard_widget, '$follow_widget' => $follow_widget, '$groups_widget' => $groups_widget, '$findpeople_widget' => $findpeople_widget, '$networks_widget' => $networks_widget)); $base = $a->get_baseurl(); $tpl = get_markup_template("contacts-head.tpl"); $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$base' => $base)); $tpl = get_markup_template("contacts-end.tpl"); $a->page['end'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$base' => $base)); }
function widget_collections($args) { require_once 'include/group.php'; $mode = array_key_exists('mode', $args) ? $args['mode'] : 'conversation'; switch ($mode) { case 'conversation': $every = argv(0); $each = argv(0); $edit = true; $current = $_REQUEST['gid']; $abook_id = 0; $wmode = 0; break; case 'connections': $every = 'connections'; $each = 'group'; $edit = true; $current = $_REQUEST['gid']; $abook_id = 0; $wmode = 0; case 'groups': $every = 'connections'; $each = argv(0); $edit = false; $current = intval(argv(1)); $abook_id = 0; $wmode = 1; break; case 'abook': $every = 'connections'; $each = 'group'; $edit = false; $current = 0; $abook_id = get_app()->poi['abook_xchan']; $wmode = 1; break; default: return ''; break; } return group_side($every, $each, $edit, $current, $abook_id, $wmode); }
function network_init(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); return; } $group_id = $a->argc > 1 && intval($a->argv[1]) ? intval($a->argv[1]) : 0; require_once 'include/group.php'; if (!x($a->page, 'aside')) { $a->page['aside'] = ''; } $search = x($_GET, 'search') ? escape_tags($_GET['search']) : ''; // We need a better way of managing a growing argument list // moved into savedsearches() // $srchurl = '/network' // . ((x($_GET,'cid')) ? '?cid=' . $_GET['cid'] : '') // . ((x($_GET,'star')) ? '?star=' . $_GET['star'] : '') // . ((x($_GET,'bmark')) ? '?bmark=' . $_GET['bmark'] : ''); if (x($_GET, 'save')) { $r = q("select * from `search` where `uid` = %d and `term` = '%s' limit 1", intval(local_user()), dbesc($search)); if (!count($r)) { q("insert into `search` ( `uid`,`term` ) values ( %d, '%s') ", intval(local_user()), dbesc($search)); } } if (x($_GET, 'remove')) { q("delete from `search` where `uid` = %d and `term` = '%s' limit 1", intval(local_user()), dbesc($search)); } // search terms header if (x($_GET, 'search')) { $a->page['content'] .= '<h2>Search Results For: ' . $search . '</h2>'; } $a->page['aside'] .= group_side('network', 'network', true, $group_id); // moved to saved searches to have it in the same div //$a->page['aside'] .= search($search,'netsearch-box',$srchurl,true); $a->page['aside'] .= saved_searches($search); }
function network_init(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); return; } $is_a_date_query = false; if ($a->argc > 1) { for ($x = 1; $x < $a->argc; $x++) { if (is_a_date_arg($a->argv[$x])) { $is_a_date_query = true; break; } } } // convert query string to array. remove friendica args $query_array = array(); $query_string = str_replace($a->cmd . "?", "", $a->query_string); parse_str($query_string, $query_array); array_shift($query_array); // fetch last used network view and redirect if needed if (!$is_a_date_query) { $sel_tabs = network_query_get_sel_tab($a); $sel_nets = network_query_get_sel_net(); $sel_groups = network_query_get_sel_group($a); $last_sel_tabs = get_pconfig(local_user(), 'network.view', 'tab.selected'); $last_sel_nets = get_pconfig(local_user(), 'network.view', 'net.selected'); $last_sel_groups = get_pconfig(local_user(), 'network.view', 'group.selected'); $remember_tab = $sel_tabs[0] === 'active' && is_array($last_sel_tabs) && $last_sel_tabs[0] !== 'active'; $remember_net = $sel_nets === false && $last_sel_nets && $last_sel_nets !== 'all'; $remember_group = $sel_groups === false && $last_sel_groups && $last_sel_groups != 0; $net_baseurl = '/network'; $net_args = array(); if ($remember_group) { $net_baseurl .= '/' . $last_sel_groups; // Note that the group number must come before the "/new" tab selection } else { if ($sel_groups !== false) { $net_baseurl .= '/' . $sel_groups; } } if ($remember_tab) { // redirect if current selected tab is '/network' and // last selected tab is _not_ '/network?f=&order=comment'. // and this isn't a date query $tab_baseurls = array('', '', '', '/new', '', '', ''); $tab_args = array('f=&order=comment', 'f=&order=post', 'f=&conv=1', '', 'f=&star=1', 'f=&bmark=1', 'f=&spam=1'); $k = array_search('active', $last_sel_tabs); $net_baseurl .= $tab_baseurls[$k]; // parse out tab queries $dest_qa = array(); $dest_qs = $tab_args[$k]; parse_str($dest_qs, $dest_qa); $net_args = array_merge($net_args, $dest_qa); } else { if ($sel_tabs[4] === 'active') { // The '/new' tab is selected $net_baseurl .= '/new'; } } if ($remember_net) { $net_args['nets'] = $last_sel_nets; } else { if ($sel_nets !== false) { $net_args['nets'] = $sel_nets; } } if ($remember_tab || $remember_net || $remember_group) { $net_args = array_merge($query_array, $net_args); $net_queries = build_querystring($net_args); $redir_url = $net_queries ? $net_baseurl . "?" . $net_queries : $net_baseurl; goaway($a->get_baseurl() . $redir_url); } } if (x($_GET['nets']) && $_GET['nets'] === 'all') { unset($_GET['nets']); } $group_id = $a->argc > 1 && is_numeric($a->argv[1]) ? intval($a->argv[1]) : 0; set_pconfig(local_user(), 'network.view', 'group.selected', $group_id); require_once 'include/group.php'; require_once 'include/contact_widgets.php'; require_once 'include/items.php'; if (!x($a->page, 'aside')) { $a->page['aside'] = ''; } $search = x($_GET, 'search') ? escape_tags($_GET['search']) : ''; if (x($_GET, 'save')) { $r = q("select * from `search` where `uid` = %d and `term` = '%s' limit 1", intval(local_user()), dbesc($search)); if (!count($r)) { q("insert into `search` ( `uid`,`term` ) values ( %d, '%s') ", intval(local_user()), dbesc($search)); } } if (x($_GET, 'remove')) { q("delete from `search` where `uid` = %d and `term` = '%s'", intval(local_user()), dbesc($search)); } // search terms header if (x($_GET, 'search')) { $a->page['content'] .= replace_macros(get_markup_template("section_title.tpl"), array('$title' => sprintf(t('Search Results For: %s'), $search))); } $a->page['aside'] .= feature_enabled(local_user(), 'groups') ? group_side('network/0', 'network', true, $group_id) : ''; $a->page['aside'] .= posted_date_widget($a->get_baseurl() . '/network', local_user(), false); $a->page['aside'] .= networks_widget($a->get_baseurl(true) . '/network', x($_GET, 'nets') ? $_GET['nets'] : ''); $a->page['aside'] .= saved_searches($search); $a->page['aside'] .= fileas_widget($a->get_baseurl(true) . '/network', x($_GET, 'file') ? $_GET['file'] : ''); }
function network_init(&$a) { require_once 'include/group.php'; $a->page['aside'] .= group_side('network', 'network'); }
function contacts_init(&$a) { require_once 'include/group.php'; $a->page['aside'] .= group_side(); }