function frio_install() {
register_hook('prepare_body_final', 'view/theme/frio/theme.php', 'frio_item_photo_links');
register_hook('item_photo_menu', 'view/theme/frio/theme.php', 'frio_item_photo_menu');
+ register_hook('contact_photo_menu', 'view/theme/frio/theme.php', 'frio_contact_photo_menu');
register_hook('nav_info', 'view/theme/frio/theme.php', 'frio_remote_nav');
+ register_hook('acl_lookup_end', 'view/theme/frio/theme.php', 'frio_acl_lookup');
logger("installed theme frio");
}
function frio_uninstall() {
unregister_hook('prepare_body_final', 'view/theme/frio/theme.php', 'frio_item_photo_links');
unregister_hook('item_photo_menu', 'view/theme/frio/theme.php', 'frio_item_photo_menu');
+ unregister_hook('contact_photo_menu', 'view/theme/frio/theme.php', 'frio_contact_photo_menu');
+ unregister_hook('nav_info', 'view/theme/frio/theme.php', 'frio_remote_nav');
+ unregister_hook('acl_lookup_end', 'view/theme/frio/theme.php', 'frio_acl_lookup');
logger("uninstalled theme frio");
}
if(strpos($v,'poke/?f=&c=') === 0 || strpos($v,'message/new/') === 0) {
$v = "javascript:addToModal('" . $v . "'); return false;";
$arr["menu"][$k] = $v;
- $testvariable = $testvariable+1;
}
}
$args = array('item' => $item, 'menu' => $menu);
}
+/**
+ * @brief Replace links of the contact_photo_menu
+ *
+ * This function replaces the original poke and the message links
+ * to call the addToModal javascript function so this pages can
+ * be loaded in a bootstrap modal
+ * Additionally the profile, status and photo page links will be changed
+ * to don't open in a new tab if the contact is a friendica contact.
+ *
+ * @param app $a The app data
+ * @param array $args Contains contact data and the original photo_menu
+ */
+function frio_contact_photo_menu($a, &$args){
+
+ $pokelink = "";
+ $pmlink = "";
+ $cid = "";
+
+ $cid = $args["contact"]["id"];
+ $pokelink = $args["menu"]["poke"][1];
+ $pmlink = $args["menu"]["pm"][1];
+
+ // Set the the indicator for opening the status, profile and photo pages
+ // in a new tab to false if the contact a dfrn (friendica) contact
+ // We do this because we can go back on foreign friendica pages throuhg
+ // friendicas "magic-link" which indicates a friendica user on froreign
+ // friendica servers as remote user or visitor
+ //
+ // The value for opening in a new tab is e.g. when
+ // $args["menu"]["status"][2] is true. If the value of the [2] key is true
+ // and if it's a friendica contact we set it to false
+ foreach($args["menu"] as $k =>$v) {
+ if($k === "status" || $k === "profile" || $k === "photos") {
+ $v[2] = (($args["contact"]["network"] === "dfrn") ? false : true);
+ $args["menu"][$k][2] = $v[2];
+ }
+ }
+
+ // Add to pm and poke links a new key with the value 'modal'.
+ // Later we can make conditions in the corresponing templates (e.g.
+ // contact_template.tpl)
+ if(strpos($pokelink,'poke/?f=&c='. $cid) !== false)
+ $args["menu"]["poke"][3] = "modal";
+
+ if(strpos($pmlink,'message/new/' . $cid) !== false)
+ $args["menu"]["pm"][3] = "modal";
+
+ $args = array('contact' => $contact, 'menu' => &$menu);
+}
+
/**
* @brief Construct remote nav menu
*
} elseif(!local_user() && remote_user()) {
$r = q("SELECT `name`, `nick`, `micro` AS `photo` FROM `contact` WHERE `id` = %d", intval(remote_user()));
- $nav['remote'] = 1;
+ $nav['remote'] = t("Remote");
} elseif(get_my_url ()) {
$r = q("SELECT `name`, `nick`, `photo` FROM `gcontact`
WHERE `addr` = '%s' AND `network` = 'dfrn'",
dbesc($webbie));
- $nav['remote'] = 1;
+ $nav['remote'] = t("Visitor");
}
if(count($r)){
$nav['userinfo'] = array(
'icon' => (count($r) ? $r[0]['photo'] : "images/person-48.jpg"),
- 'name' => $r['name'],
+ 'name' => $r[0]['name'],
);
}
$nav['messages'] = array($server_url . '/message', t('Messages'), "", t('Private mail'));
$nav['settings'] = array($server_url . '/settings', t('Settings'),"", t('Account settings'));
$nav['contacts'] = array($server_url . '/contacts', t('Contacts'),"", t('Manage/edit friends and contacts'));
+ $nav['sitename'] = $a->config['sitename'];
}
}
+/**
+ * @brief: Search for contacts
+ *
+ * This function search for a users contacts. The code is copied from contact search
+ * in /mod/contacts.php. With this function the contacts will permitted to acl_lookup()
+ * and can grabbed as json. For this we use the type="r". This is usful to to let js
+ * grab the contact data.
+ * We use this to give the data to textcomplete and have a filter function at the
+ * contact page.
+ *
+ * @param App $a The app data
+ * @param array $results The array with the originals from acl_lookup()
+ */
+function frio_acl_lookup($a, &$results) {
+ require_once("mod/contacts.php");
+
+ $nets = ((x($_GET,"nets")) ? notags(trim($_GET["nets"])) : "");
+
+ // we introduce a new search type, r should do the same query like it's
+ // done in /mod/contacts for connections
+ if($results["type"] == "r") {
+ $searching = false;
+ if($search) {
+ $search_hdr = $search;
+ $search_txt = dbesc(protect_sprintf(preg_quote($search)));
+ $searching = true;
+ }
+ $sql_extra .= (($searching) ? " AND (`attag` LIKE '%%".dbesc($search_txt)."%%' OR `name` LIKE '%%".dbesc($search_txt)."%%' OR `nick` LIKE '%%".dbesc($search_txt)."%%') " : "");
+
+ if($nets)
+ $sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets));
+
+ $sql_extra2 = ((($sort_type > 0) && ($sort_type <= CONTACT_IS_FRIEND)) ? sprintf(" AND `rel` = %d ",intval($sort_type)) : '');
+
+
+ $r = q("SELECT COUNT(*) AS `total` FROM `contact`
+ WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ",
+ intval($_SESSION['uid']));
+ if(count($r)) {
+ $total = $r[0]["total"];
+ }
+
+ $sql_extra3 = unavailable_networks();
+
+ $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 $sql_extra3 ORDER BY `name` ASC LIMIT 100 ",
+ intval($_SESSION['uid'])
+ );
+
+ $contacts = array();
+
+ if(count($r)) {
+ foreach($r as $rr) {
+ $contacts[] = _contact_detail_for_template($rr);
+ }
+ }
+
+ $results["items"] = $contacts;
+ $results["tot"] = $total;
+ }
+}
\ No newline at end of file