Frio: provide a template for received contact suggestions
authorrabuzarus <>
Thu, 14 Jun 2018 15:05:23 +0000 (17:05 +0200)
committerrabuzarus <>
Thu, 14 Jun 2018 15:05:23 +0000 (17:05 +0200)
mod/notifications.php
src/Core/NotificationsManager.php
view/templates/suggestions.tpl
view/theme/frio/css/style.css
view/theme/frio/templates/intros.tpl
view/theme/frio/templates/suggestions.tpl [new file with mode: 0644]

index f7f40d1..c583425 100644 (file)
@@ -164,14 +164,22 @@ function notifications_content(App $a) {
                        switch ($it['label']) {
                                case 'friend_suggestion':
                                        $notif_content[] = replace_macros($sugg, [
-                                               '$str_notifytype' => L10n::t('Notification type: '),
+                                               '$type' => $it['label'],
+                                               '$str_notifytype' => L10n::t('Notification type:'),
                                                '$notify_type' => $it['notify_type'],
                                                '$intro_id' => $it['intro_id'],
-                                               '$madeby' => L10n::t('suggested by %s', $it['madeby']),
-                                               '$contact_id' => $it['contact-id'],
+                                               '$lbl_madeby' => L10n::t('Suggested by:'),
+                                               '$madeby' => $it['madeby'],
+                                               '$madeby_url' => $it['madeby_url'],
+                                               '$madeby_zrl' => $it['madeby_zrl'],
+                                               '$madeby_addr' => $it['madeby_addr'],
+                                               '$contact_id' => $it['contact_id'],
                                                '$photo' => $it['photo'],
                                                '$fullname' => $it['name'],
                                                '$url' => $it['url'],
+                                               '$zrl' => $it['zrl'],
+                                               '$lbl_url' => L10n::t('Profile URL'),
+                                               '$addr' => $it['addr'],
                                                '$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($it['hidden'] == 1), ''],
 
                                                '$knowyou' => $it['knowyou'],
@@ -232,8 +240,9 @@ function notifications_content(App $a) {
                                        }
 
                                        $notif_content[] = replace_macros($tpl, [
+                                               '$type' => $it['label'],
                                                '$header' => htmlentities($header),
-                                               '$str_notifytype' => L10n::t('Notification type: '),
+                                               '$str_notifytype' => L10n::t('Notification type:'),
                                                '$notify_type' => $it['notify_type'],
                                                '$dfrn_text' => $dfrn_text,
                                                '$dfrn_id' => $it['dfrn_id'],
index 6e9d469..8a1c156 100644 (file)
@@ -775,7 +775,7 @@ class NotificationsManager extends BaseObject
                /// @todo Fetch contact details by "Contact::getDetailsByUrl" instead of queries to contact, fcontact and gcontact
                $r = q(
                        "SELECT `intro`.`id` AS `intro_id`, `intro`.*, `contact`.*,
-                               `fcontact`.`name` AS `fname`, `fcontact`.`url` AS `furl`,
+                               `fcontact`.`name` AS `fname`, `fcontact`.`url` AS `furl`, `fcontact`.`addr` AS `faddr`,
                                `fcontact`.`photo` AS `fphoto`, `fcontact`.`request` AS `frequest`,
                                `gcontact`.`location` AS `glocation`, `gcontact`.`about` AS `gabout`,
                                `gcontact`.`keywords` AS `gkeywords`, `gcontact`.`gender` AS `ggender`,
@@ -825,10 +825,14 @@ class NotificationsManager extends BaseObject
                                        'notify_type' => L10n::t('Friend Suggestion'),
                                        'intro_id' => $it['intro_id'],
                                        'madeby' => $it['name'],
+                                       'madeby_url' => $it['url'],
+                                       'madeby_zrl' => Contact::magicLink($it['url']),
+                                       'madeby_addr' => $it['addr'],
                                        'contact_id' => $it['contact-id'],
                                        'photo' => ((x($it, 'fphoto')) ? proxy_url($it['fphoto'], false, PROXY_SIZE_SMALL) : "images/person-175.jpg"),
                                        'name' => $it['fname'],
-                                       'url' => Contact::magicLink($it['furl']),
+                                       'url' => $it['furl'],
+                                       'zrl' => Contact::magicLink($it['furl']),
                                        'hidden' => $it['hidden'] == 1,
                                        'post_newfriend' => (intval(PConfig::get(local_user(), 'system', 'post_newfriend')) ? '1' : 0),
                                        'knowyou' => $knowyou,
index 9be529c..edc0dbd 100644 (file)
@@ -3,7 +3,7 @@
 <div class="intro-wrapper" >
 
 <p class="intro-desc">{{$str_notifytype}} {{$notify_type}}</p>
-<div class="intro-madeby">{{$madeby}}</div>
+{{if $madeby}}<div class="intro-madeby">{{$lbl_madeby}} {{$madeby}}</div>{{/if}}
 <div class="intro-fullname" >{{$fullname}}</div>
 <a class="intro-url-link" href="{{$url}}" ><img class="intro-photo lframe" src="{{$photo}}" width="175" height="175" title="{{$fullname|escape:'html'}}" alt="{{$fullname|escape:'html'}}" /></a>
 <div class="intro-note" >{{$note}}</div>
index b4bb84c..c324524 100644 (file)
@@ -2815,7 +2815,7 @@ ul.notif-network-list > li:hover .intro-action-buttons {
 }
 .intro-desc-label, .intro-url-label, .intro-network-label,
 .intro-location-label, .intro-gender-label, .intro-keywords-label,
-.intro-about-label, .intro-knowyou-label {
+.intro-about-label, .intro-knowyou-label, .intro-madeby-label {
     font-weight: bold;
 }
 .intro-contact-info.xs .intro-url-label, .intro-contact-info.xs .intro-network-label,
index c153fcd..df46e45 100644 (file)
@@ -1,15 +1,17 @@
 
-<div class="intro-wrapper media" id="intro-{{$contact_id}}" >
+{{* template incomming contact request and suggested contacts *}}
+
+<div class="intro-wrapper media" id="intro-{{$intro_id}}" >
 
        {{* Contact Photo *}}
        <div class="intro-photo-wrapper dropdown pull-left" >
-               <img id="photo-{{$contact_id}}" class="intro-photo media-object" src="{{$photo}}" title="{{$fullname|escape:'html'}}" alt="{{$fullname|escape:'html'}}" />
+               <img id="photo-{{$intro_id}}" class="intro-photo media-object" src="{{$photo}}" title="{{$fullname|escape:'html'}}" alt="{{$fullname|escape:'html'}}" />
        </div>
 
        <div class="media-body">
                {{* The intro actions like approve, ignore, discard intro*}}
                <div class="intro-actions pull-right nav-pills preferences">
-                       <button class="btn-link intro-action-link" onclick="addElmToModal('#intro-approve-wrapper-{{$contact_id}}');" aria-label="{{$approve|escape:'html'}}" title="{{$approve|escape:'html'}}" data-toggle="tooltip"><i class="fa fa-check" aria-hidden="true"></i></button>
+                       <button class="btn-link intro-action-link" onclick="addElmToModal('#intro-approve-wrapper-{{$intro_id}}');" aria-label="{{$approve|escape:'html'}}" title="{{$approve|escape:'html'}}" data-toggle="tooltip"><i class="fa fa-check" aria-hidden="true"></i></button>
 
                        <form class="intro-form" action="notifications/{{$intro_id}}" method="post">
                                <button class="btn-link intro-submit-ignore intro-action-link" type="submit" name="submit" value="{{$ignore|escape:'html'}}" aria-label="{{$ignore|escape:'html'}}" title="{{$ignore|escape:'html'}}" data-toggle="tooltip"><i class="fa fa-ban" aria-hidden="true"></i></button>
@@ -17,7 +19,9 @@
                        </form>
                </div>
                <div class='intro-enty-name'><h4 class="media-heading"><a href="{{$zrl}}">{{$fullname}}</a></h4></div>
-               <div class="intro-desc"><span class="intro-desc-label">{{$str_notifytype}}</span>{{$notify_type}}</div>
+               <div class="intro-desc"><span class="intro-desc-label">{{$str_notifytype}}</span>&nbsp;{{$notify_type}}</div>
+               {{* if the contact was suggestested by another contact, the contact who made the suggestion is displayed*}}
+               {{if $madeby}}<div class="intro-madeby"><span class="intro-madeby-label">{{$lbl_madeby}}</span>&nbsp;<a href="{{$madeby_zrl}}">{{$madeby}}</a></div>{{/if}}
 
                {{* Additional information of the contact *}}
                <div class="intro-contact-info hidden-xs">
@@ -28,7 +32,7 @@
                        {{if $keywords}}<div class="intro-keywords"><span class="intro-keywords-label">{{$lbl_keywords}}</span>&nbsp;{{$keywords}}</div>{{/if}}
                        {{if $about}}<div class="intro-about"><span class="intro-about-label">{{$lbl_about}}</span>&nbsp;{{$about}}</div>{{/if}}
                        <div class="intro-knowyou"><span class="intro-knowyou-label">{{$lbl_knowyou}}</span>{{$knowyou}}</div>
-                       <div class="intro-note intro-note-{{$contact_id}}">{{$note}}</div>
+                       <div class="intro-note intro-note-{{$intro_id}}">{{$note}}</div>
                </div>
 
                {{* Additional information of the contact for mobile view *}}
                        {{if $keywords}}<div class="intro-keywords"><span class="intro-keywords-label">{{$lbl_keywords}}</span>{{$keywords}}</div>{{/if}}
                        {{if $about}}<div class="intro-about"><span class="intro-about-label">{{$lbl_about}}</span>{{$about}}</div>{{/if}}
                        <div class="intro-knowyou"><span class="intro-knowyou-label">{{$lbl_knowyou}}</span>{{$knowyou}}</div>
-                       <div class="intro-note intro-note-{{$contact_id}}">{{$note}}</div>
+                       <div class="intro-note intro-note-{{$intro_id}}">{{$note}}</div>
                </div>
 
                {{* This sections contains special settings for contact approval. We hide it by default and load this section in
                a bootstrap modal in the case of approval *}}
-               <div id="intro-approve-wrapper-{{$contact_id}}" style="display: none;">
+               <div id="intro-approve-wrapper-{{$intro_id}}" style="display: none;">
 
                        <h3 class="heading">{{$fullname}}{{if $addr}}&nbsp;({{$addr}}){{/if}}</h3>
-                       <form class="intro-approve-form" action="dfrn_confirm" method="post">
+                       <form class="intro-approve-form" {{if $request}}action="{{$request}}" method="get"{{else}}action="dfrn_confirm" method="post"{{/if}}>
                                {{include file="field_checkbox.tpl" field=$hidden}}
+                               {{if $type != "friend_suggestion"}}
                                <input type="hidden" name="dfrn_id" value="{{$dfrn_id}}" >
                                <input type="hidden" name="intro_id" value="{{$intro_id}}" >
                                <input type="hidden" name="contact_id" value="{{$contact_id}}" >
+                               {{/if}}
 
                                {{$dfrn_text}}
 
@@ -71,7 +77,7 @@
                        <button class="btn btn-small btn-default intro-submit-ignore" type="submit" name="submit" value="{{$ignore|escape:'html'}}">{{$ignore|escape:'html'}}</button>
                        {{if $discard}}<button class="btn btn-small btn-default intro-submit-discard" type="submit" name="submit" value="{{$discard|escape:'html'}}">{{$discard|escape:'html'}}</button>&nbsp;{{/if}}
                </form>
-               <button class="btn btn-small btn-primary intro-submit-approve pull-right" onclick="addElmToModal('#intro-approve-wrapper-{{$contact_id}}')">{{$approve|escape:'html'}}</button>
+               <button class="btn btn-small btn-primary intro-submit-approve pull-right" onclick="addElmToModal('#intro-approve-wrapper-{{$intro_id}}')">{{$approve|escape:'html'}}</button>
        </div>
        <div class="clear"></div>
        {{/if}}
diff --git a/view/theme/frio/templates/suggestions.tpl b/view/theme/frio/templates/suggestions.tpl
new file mode 100644 (file)
index 0000000..e2399eb
--- /dev/null
@@ -0,0 +1,2 @@
+
+{{include file="intros.tpl"}}
\ No newline at end of file