From 991cbd604a588e676bf316aa120f223071bdff94 Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Mon, 8 Feb 2016 01:56:15 +0100
Subject: [PATCH] contact-edit-actions-button: initial commit

---
 mod/contacts.php                | 71 ++++++++++++++++++++++++++++++++-
 view/global.css                 | 69 ++++++++++++++++++++++----------
 view/templates/contact_edit.tpl | 24 ++++++-----
 3 files changed, 132 insertions(+), 32 deletions(-)

diff --git a/mod/contacts.php b/mod/contacts.php
index 0b421433e..248ed47ab 100644
--- a/mod/contacts.php
+++ b/mod/contacts.php
@@ -565,6 +565,8 @@ function contacts_content(&$a) {
 			($contact['rel'] == CONTACT_IS_FOLLOWER))
 			$follow = $a->get_baseurl(true)."/follow?url=".urlencode($contact["url"]);
 
+		$contact_actions = contact_action_menu($contact);
+
 
 		$o .= replace_macros($tpl, array(
 			//'$header' => t('Contact Editor'),
@@ -574,7 +576,7 @@ function contacts_content(&$a) {
 			'$lbl_vis2' => sprintf( t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $contact['name']),
 			'$lbl_info1' => t('Contact Information / Notes'),
 			'$infedit' => t('Edit contact notes'),
-			'$common_text' => $common_text,
+			//'$common_text' => $common_text,
 			'$common_link' => $a->get_baseurl(true) . '/common/loc/' . local_user() . '/' . $contact['id'],
 			'$all_friends' => $all_friends,
 			'$relation_text' => $relation_text,
@@ -622,7 +624,9 @@ function contacts_content(&$a) {
 			'$about' => bbcode($contact["about"], false, false),
 			'$about_label' => t("About:"),
 			'$keywords' => $contact["keywords"],
-			'$keywords_label' => t("Tags:")
+			'$keywords_label' => t("Tags:"),
+			'$contact_action_button' => t("Actions"),
+			'$contact_actions' => $contact_actions,
 
 		));
 
@@ -954,3 +958,66 @@ function _contact_detail_for_template($rr){
 	);
 
 }
+
+function contact_action_menu($contact) {
+
+	$contact_action_menu = array(
+				'suggest' => array(
+					'label' => t('Suggest friends'),
+					'url'	=> app::get_baseurl(true) . '/fsuggest/' . $contact['id'],
+					'title'	=> '',
+					'sel'	=> '',
+					'id'	=>  'suggest',
+				),
+
+				'update' => array(
+					'label'	=> t('Update now'),
+					'url'	=> app::get_baseurl(true) . '/contacts/' . $contact['id'] . '/update',
+					'title'	=> '',
+					'sel'	=> '',
+					'id'	=> 'update',
+				),
+
+				'repair' => array(
+					'label'	=> t('Repair'),
+					'url'	=> app::get_baseurl(true) . '/crepair/' . $contact['id'],
+					'title' => t('Advanced Contact Settings'),
+					'sel'	=> '',
+					'id'	=> 'repair',
+				),
+
+				'block' => array(
+					'label'	=> (intval($contact['blocked']) ? t('Unblock') : t('Block') ),
+					'url'	=> app::get_baseurl(true) . '/contacts/' . $contact['id'] . '/block',
+					'title' => t('Toggle Blocked status'),
+					'sel'	=> (intval($contact['blocked']) ? 'active' : ''),
+					'id'	=> 'toggle-block',
+				),
+
+				'ignore' => array(
+					'label'	=> (intval($contact['readonly']) ? t('Unignore') : t('Ignore') ),
+					'url'	=> app::get_baseurl(true) . '/contacts/' . $contact['id'] . '/ignore',
+					'title' => t('Toggle Ignored status'),
+					'sel'	=> (intval($contact['readonly']) ? 'active' : ''),
+					'id'	=> 'toggle-ignore',
+				),
+
+				'archive' => array(
+					'label'	=> (intval($contact['archive']) ? t('Unarchive') : t('Archive') ),
+					'url'	=> app::get_baseurl(true) . '/contacts/' . $contact['id'] . '/archive',
+					'title' => t('Toggle Archive status'),
+					'sel'	=> (intval($contact['archive']) ? 'active' : ''),
+					'id'	=> 'toggle-archive',
+				),
+
+				'delete' => array(
+					'label'	=> t('Delete'),
+					'url'	=> app::get_baseurl(true) . '/contacts/' . $contact['id'] . '/drop', 
+					'title'	=> t('Delete contact'),
+					'sel'	=> '',
+					'id'	=> 'delete',
+				)
+	);
+
+	return $contact_action_menu;
+}
diff --git a/view/global.css b/view/global.css
index 8646bf8e4..df001ed36 100644
--- a/view/global.css
+++ b/view/global.css
@@ -1,6 +1,28 @@
 /* General style rules .*/
 .pull-right { float: right }
 
+/* General designing elements */
+.btn {
+  outline: none;
+  -moz-box-shadow: inset 0px 1px 0px 0px #ffffff;
+  -webkit-box-shadow: inset 0px 1px 0px 0px #ffffff;
+  box-shadow: inset 0px 1px 0px 0px #ffffff;
+  background-color: #ededed;
+  text-indent: 0;
+  border: 1px solid #dcdcdc;
+  display: inline-block;
+  color: #777777;
+  padding: 5px 10px;
+  text-align: center;
+}
+
+ul.menu-popup li.divider {
+  height: 1px;
+  margin: 3px 0;
+  overflow: hidden;
+  background-color: #2d2d2d;;
+}
+
 /* List of social Networks */
 img.connector, img.connector-disabled {
   height: 40px;
@@ -277,20 +299,20 @@ a {
   margin: 10px 0 10px;
 }
 .version-match {
-    font-weight: bold;
-    color: #00a700;
+  font-weight: bold;
+  color: #00a700;
 }
 .federation-graph {
-    width: 400px; 
-    height: 400px; 
-    float: right; 
-    margin: 20px;
+  width: 400px; 
+  height: 400px; 
+  float: right; 
+  margin: 20px;
 }
 .federation-network-graph {
-    width: 240px; 
-    height: 240px; 
-    float: left; 
-    margin: 20px;
+  width: 240px; 
+  height: 240px; 
+  float: left; 
+  margin: 20px;
 }
 ul.federation-stats,
 ul.credits {
@@ -302,10 +324,10 @@ ul.credits li {
   width: 240px;
 }
 table#federation-stats {
-    width: 100%;
+  width: 100%;
 }
 td.federation-data {
-    border-bottom: 1px solid #000;
+  border-bottom: 1px solid #000;
 }
 
 .contact-entry-photo img {
@@ -329,25 +351,30 @@ td.federation-data {
 }
 
 .crepair-label {
-        margin-top: 10px;
-        float: left;
-        width: 250px;
+  margin-top: 10px;
+  float: left;
+  width: 250px;
 }
 
 .crepair-input {
-        margin-top: 10px;
-        float: left;
-        width: 200px;
+  margin-top: 10px;
+  float: left;
+  width: 200px;
 }
 
 .renderinfo {
-	clear: both;
+  clear: both;
 }
 
 .p-addr {
-	clear: both;	
+  clear: both;	
 }
 
 #live-community {
-	clear: both;
+  clear: both;
 }
+
+/* contact-edit */
+#contact-edit-actions {
+    float: right;
+}
\ No newline at end of file
diff --git a/view/templates/contact_edit.tpl b/view/templates/contact_edit.tpl
index 15863b6a2..682ebfa36 100644
--- a/view/templates/contact_edit.tpl
+++ b/view/templates/contact_edit.tpl
@@ -4,6 +4,21 @@
 
 	{{$tab_str}}
 
+	<div id="contact-edit-actions">
+		<a class="btn" rel="#contact-actions-menu" href="#" id="contact-edit-actions-button">{{$contact_action_button}}</a>
+
+		<ul role="menu" aria-haspopup="true" id="contact-actions-menu" class="menu-popup" >
+			{{if $lblsuggest}}<li><a  href="#" title="{{$contact_actions.suggest.title}}" onclick="window.location.href='{{$contact_actions.suggest.url}}'; return false;">{{$contact_actions.suggest.label}}</a></li>{{/if}}
+			{{if $poll_enabled}}<li><a  href="#" title="{{$contact_actions.update.title}}" onclick="window.location.href='{{$contact_actions.update.url}}'; return false;">{{$contact_actions.update.label}}</a></li>{{/if}}
+			<li><a  href="#" title="{{$contact_actions.repair.title}}" onclick="window.location.href='{{$contact_actions.repair.url}}'; return false;">{{$contact_actions.repair.label}}</a></li>
+			<li class="divider"></li>
+			<li><a  href="#" title="{{$contact_actions.block.title}}" onclick="window.location.href='{{$contact_actions.block.url}}'; return false;">{{$contact_actions.block.label}}</a></li>
+			<li><a  href="#" title="{{$contact_actions.ignore.title}}" onclick="window.location.href='{{$contact_actions.ignore.url}}'; return false;">{{$contact_actions.ignore.label}}</a></li>
+			<li><a  href="#" title="{{$contact_actions.archive.title}}" onclick="window.location.href='{{$contact_actions.archive.url}}'; return false;">{{$contact_actions.archive.label}}</a></li>
+			<li><a  href="#" title="{{$contact_actions.delete.title}}" onclick="return confirmDelete();">{{$contact_actions.delete.label}}</a></li>
+		</ul>
+	</div>
+
 	<div id="contact-edit-drop-link" >
 		<a href="contacts/{{$contact_id}}/drop" class="icon drophide" id="contact-edit-drop-link" onclick="return confirmDelete();"  title="{{$delete}}" onmouseover="imgbright(this);" onmouseout="imgdull(this);"></a>
 	</div>
@@ -35,15 +50,6 @@
 			</ul>
 
 			<ul>
-
-				{{if $common_text}}
-					<li><div id="contact-edit-common"><a href="{{$common_link}}">{{$common_text}}</a></div></li>
-				{{/if}}
-				{{if $all_friends}}
-					<li><div id="contact-edit-allfriends"><a href="allfriends/{{$contact_id}}">{{$all_friends}}</a></div></li>
-				{{/if}}
-
-
 				<!-- <li><a href="network/0?nets=all&cid={{$contact_id}}" id="contact-edit-view-recent">{{$lblrecent}}</a></li> -->
 				{{if $lblsuggest}}
 					<li><a href="fsuggest/{{$contact_id}}" id="contact-edit-suggest">{{$lblsuggest}}</a></li>