From 7a21a000a2b02e7dd443fd0f3ee09172de825b08 Mon Sep 17 00:00:00 2001
From: Mike Macgirvin <mike@macgirvin.com>
Date: Sun, 11 Jul 2010 02:52:47 -0700
Subject: [PATCH] lots of little stuff

---
 include/group.php             | 34 +++++++++++++++++++++++++++++++++-
 include/nav.php               |  6 ++++++
 mod/contacts.php              | 17 ++++-------------
 mod/profiles.php              |  8 +++++++-
 updates.sql                   |  3 ++-
 view/contact_edit.tpl         |  2 +-
 view/profile-hide-friends.tpl | 16 ++++++++++++++++
 view/profile_edit.tpl         |  2 ++
 view/style.css                | 21 +++++++++++++++++----
 9 files changed, 88 insertions(+), 21 deletions(-)
 create mode 100644 view/profile-hide-friends.tpl

diff --git a/include/group.php b/include/group.php
index e92e4480ba..598d09c2ea 100644
--- a/include/group.php
+++ b/include/group.php
@@ -25,7 +25,7 @@ function group_rmv($uid,$name) {
 		$r = q("SELECT * FROM `group` WHERE `uid` = %d AND `name` = '%s' LIMIT 1",
 			intval($uid),
 			dbesc($name)
-		}
+		);
 		if(count($r))
 			$group_id = $r[0]['id'];
 		if(! $group_id)
@@ -102,4 +102,36 @@ function group_add_member($uid,$name,$member) {
 			intval($member)
 	);
 	return $r;
+}
+
+
+
+function group_side() {
+
+	if(! local_user())
+		return;
+$o .= <<< EOT
+
+<div id="group-sidebar">
+<h3>Groups</h3>
+
+<div id="sidebar-new-group">
+<a href="group/new">Create a new group</a>
+</div>
+
+<div id="sidebar-group-list">
+<ul id="sidebar-group-ul">
+<li class="sidebar-group-li"><a href="contacts">Everybody</a></li>
+EOT;
+
+	$r = q("SELECT * FROM `group` WHERE `uid` = %d",
+		intval($_SESSION['uid'])
+	);
+	if(count($r)) {
+		foreach($r as $rr)
+			$o .= "<li class=\"sidebar-group-li\"><a href=\"group/{$rr['id']}\">{$rr['name']}</li>";
+	}
+	$o .= '</ul></div></div>';	
+
+	return $o;
 }
\ No newline at end of file
diff --git a/include/nav.php b/include/nav.php
index c51c56ad22..d24abd4ac5 100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -2,6 +2,11 @@
 <?php
 	$a->page['nav'] .= "<span id=\"nav-link-wrapper\" >\r\n";
 
+	if(($a->module != 'home') && (! (x($_SESSION['uid']))))
+		$a->page['nav'] .= "<a id=\"nav-home-link\" class=\"nav-commlink\" href=\"\">Home</a>\r\n";
+	
+	$a->page['nav'] .= "<a id=\"nav-directory-link\" class=\"nav-commlink\" href=\"directory\">Site Directory</a>\r\n";
+
 	if(x($_SESSION,'uid')) {
 
 		$a->page['nav'] .= "<a id=\"nav-notify-link\" class=\"nav-commlink\" href=\"notifications\">Notifications</a>\r\n";
@@ -20,4 +25,5 @@
 		$a->page['nav'] .= "<a id=\"nav-home-link\" class=\"nav-link\" href=\"profile/{$_SESSION['uid']}\">Home</a>\r\n";
 		
 	}
+
 	$a->page['nav'] .= "</span>\r\n<span id=\"nav-end\"></span>\r\n";
diff --git a/mod/contacts.php b/mod/contacts.php
index 38b49475ac..5bf906e060 100644
--- a/mod/contacts.php
+++ b/mod/contacts.php
@@ -1,6 +1,8 @@
 <?php
-function edit_contact(&$a,$contact_id) {
 
+function contacts_init(&$a) {
+	require_once('include/group.php');
+	$a->page['aside'] .= group_side();
 }
 
 function contacts_post(&$a) {
@@ -12,8 +14,7 @@ function contacts_post(&$a) {
 	$contact_id = intval($a->argv[1]);
 	if(! $contact_id)
 		return;
-dbg(2);
-print_r($_POST);
+
 	$orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
 		intval($contact_id),
 		intval($_SESSION['uid'])
@@ -60,14 +61,6 @@ print_r($_POST);
 
 
 
-
-
-
-
-
-
-
-
 function contacts_content(&$a) {
 
 	if(! local_user()) {
@@ -75,8 +68,6 @@ function contacts_content(&$a) {
 		return;
 	}
 
-
-
 	if($a->argc == 3) {
 
 		$contact_id = intval($a->argv[1]);
diff --git a/mod/profiles.php b/mod/profiles.php
index 3f5980ba69..4bbfbb44cb 100644
--- a/mod/profiles.php
+++ b/mod/profiles.php
@@ -278,6 +278,12 @@ function profiles_content(&$a) {
 			'$no_selected' => (($r[0]['publish'] == 0) ? " checked=\"checked\" " : "")
 		));
 
+		$opt_tpl = file_get_contents("view/profile-hide-friends.tpl");
+		$hide_friends = replace_macros($opt_tpl,array(
+			'$yes_selected' => (($r[0]['hide-friends']) ? " checked=\"checked\" " : ""),
+			'$no_selected' => (($r[0]['hide-friends'] == 0) ? " checked=\"checked\" " : "")
+		));
+
 
 		$a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
 		$a->page['htmlhead'] .= "<script type=\"text/javascript\" src=\"include/country.js\" ></script>";
@@ -295,7 +301,7 @@ function profiles_content(&$a) {
 			'$default' => (($is_default) ? "<p id=\"profile-edit-default-desc\">This is your <strong>public</strong> profile.<br />It <strong>may</strong> be visible to anybody using the internet.</p>" : ""),
 			'$name' => $r[0]['name'],
 			'$dob' => dob($r[0]['dob']),
-			'$hide_birth' => (($r[0]['dob_hide']) ? " checked=\"checked\" " : ""),
+			'$hide_friends' => $hide_friends,
 			'$address' => $r[0]['address'],
 			'$locality' => $r[0]['locality'],
 			'$region' => $r[0]['region'],
diff --git a/updates.sql b/updates.sql
index de7bfa1e42..b7e2ab3ea4 100644
--- a/updates.sql
+++ b/updates.sql
@@ -25,4 +25,5 @@ ALTER TABLE `profile` DROP `age`;
  ALTER TABLE `profile` CHANGE `school` `education` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL  ;
  ALTER TABLE `profile` DROP `employer`  ;
 
-ALTER TABLE `profile` ADD `contact` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `education` ;
\ No newline at end of file
+ALTER TABLE `profile` ADD `contact` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `education` ;
+ALTER TABLE `profile` ADD `hide-friends` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `is-default` ;
diff --git a/view/contact_edit.tpl b/view/contact_edit.tpl
index 91ae30ec16..4a94f70837 100644
--- a/view/contact_edit.tpl
+++ b/view/contact_edit.tpl
@@ -28,7 +28,7 @@ $blocked
 <form action="contacts/$contact_id" method="post" >
 <input type="hidden" name="contact_id" value="$contact_id">
 
-<div class="contact-edit-profile-select-text">
+<div id="contact-edit-profile-select-text">
 <h4>Profile Visibility</h4>
 <p>Please choose the profile you would like to display to $name - when he/she connects securely to your profile page.
 </p> 
diff --git a/view/profile-hide-friends.tpl b/view/profile-hide-friends.tpl
new file mode 100644
index 0000000000..54ade00fec
--- /dev/null
+++ b/view/profile-hide-friends.tpl
@@ -0,0 +1,16 @@
+<p id="hide-friends-text">
+Hide my contact/friend list from viewers of this profile?
+</p>
+
+		<div id="hide-friends-yes-wrapper">
+		<label id="hide-friends-yes-label" for="hide-friends-yes">Yes</label>
+		<input type="radio" name="hide-friends" id="hide-friends-yes" $yes_selected value="1" />
+
+		<div id="hide-friends-break" ></div>	
+		</div>
+		<div id="hide-friends-no-wrapper">
+		<label id="hide-friends-no-label" for="hide-friends-no">No</label>
+		<input type="radio" name="hide-friends" id="hide-friends-no" $no_selected value="0"  />
+
+		<div id="hide-friends-end"></div>
+		</div>
diff --git a/view/profile_edit.tpl b/view/profile_edit.tpl
index 789da873c2..3dcf8df2cd 100644
--- a/view/profile_edit.tpl
+++ b/view/profile_edit.tpl
@@ -32,6 +32,8 @@ $dob $age
 </div>
 <div id="profile-edit-dob-end"></div>
 
+$hide_friends
+
 <div class="profile-edit-submit-wrapper" >
 <input type="submit" name="submit" class="profile-edit-submit-button" value="Submit" />
 </div>
diff --git a/view/style.css b/view/style.css
index 169a89589e..86876a697d 100644
--- a/view/style.css
+++ b/view/style.css
@@ -316,12 +316,17 @@ input#dfrn-url {
 #profile-edit-politic,
 #profile-edit-religion,
 #profile-in-dir-yes,
-#profile-in-dir-no {
+#profile-in-dir-no,
+#hide-friends-yes,
+#hide-friends-no {
 	float: left;
 	margin-bottom: 20px;
 }
 
-#profile-in-dir-yes-label, #profile-in-dir-no-label {
+#profile-in-dir-yes-label, 
+#profile-in-dir-no-label,
+#hide-friends-yes-label,
+#hide-friends-no-label {
 	margin-left: 125px;
 	float: left;
 	width: 50px;
@@ -347,10 +352,16 @@ input#dfrn-url {
 #profile-edit-religion-end,
 #profile-edit-homepage-end,
 #profile-in-dir-break, 
-#profile-in-dir-end {
+#profile-in-dir-end,
+#hide-friends-break,
+#hide-friends-end {
 	clear: both;
 }
 
+
+
+
+
 #gender-select, #marital-select, #sexual-select {
 	width: 220px;
 }
@@ -663,7 +674,9 @@ input#dfrn-url {
 	margin-left: 30px;
 }
 
-
+#contact-edit-photo-wrapper {
+	margin-bottom: 20px;
+}
 #contact-edit-links img {
 	margin-left: 20px;
 	border: none;
-- 
2.39.5