Webcam links on member list fixed
authorLaury GvR <laury@gaslightmedia.com>
Tue, 4 Oct 2016 15:03:13 +0000 (11:03 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Tue, 4 Oct 2016 15:03:13 +0000 (11:03 -0400)
The webcam links were not properly sending people to the image
(if a url was selected) or the member page (if image was selected)
It will now also check whether a link has http prefix and add it
if not.

classes/data/dataMemberInfo.php
models/front/members/list.php
setup/frontHooks.php
views/front/members/list.html

index 03a5572..fbe7ba7 100644 (file)
@@ -505,6 +505,13 @@ class GlmDataMemberInfo extends GlmDataAbstract
         if (strlen($r['short_descr']) > 120 ) {
             $dotdotdot = ' ...';
         }
+        
+        /*
+         * This will add a protocol prefix to the live cam url
+         */
+        $liveCamUrl = $r['live_cam_url'];
+        $r['live_cam_url'] = addUrlProtocol($liveCamUrl);
+
         $formattedStr = trim(preg_replace('/\s\s+/', ' ', $r['short_descr']));
         $r['short_descr'] = substr($formattedStr, 0, 120).$dotdotdot;
 
index 9fbaf03..b6aebc7 100644 (file)
@@ -525,7 +525,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
             $alphaList = $this->getAlphaList(' AND '.$where, $alphaSelected);
 
         }
-
+        
         /*
          * Check for which view file to use, else default to list
          */
index e584ff4..f41b9d0 100644 (file)
@@ -174,9 +174,9 @@ if (is_plugin_active($plugin_name)) {
 if (!function_exists('is_in_tree')) {
     function is_in_tree( $pid ) {
         global $post;
-        if ( is_page($pid) )
+        if ( is_page( $pid ) ) {
             return true;
-
+        }
         $anc = get_post_ancestors( $post->ID );
         foreach ( $anc as $ancestor ) {
             if( is_page() && $ancestor == $pid ) {
@@ -262,6 +262,19 @@ function glm_members_only_template( $template ) {
     return $template;
 }
 
+
+/*
+ * This function adds a protocol prefix if the given url does not have one already
+ */
+if (!function_exists('addUrlProtocol')) {
+    function addUrlProtocol($url) {
+        if (!preg_match("~^(?:f|ht)tps?://~i", $url)) {
+            $url = "http://" . $url;
+        }
+        return $url;
+    }
+}
+
 /*
  *
  */
index 6b16c0b..85abbad 100644 (file)
         <!--                        {if $member.phone && $settings.list_map_show_phone}<a href="tel:+{$member.phone}">Phone</a>{/if}-->
                                 {$packageLink = apply_filters('glm-member-db-front-members-list-linksBottom', '', $member.member_pointer)}
                                 {if $packageLink}<li>{$packageLink}</li>{/if}
-                                {if $member.live_cam_type.value == 1}
+                                
+                                {if $member.live_cam_type.name == "Web Page" && $member.live_cam_url}
                                     <li><a target="_blank" href="{$member.live_cam_url}">{$terms.term_webcam_cap}</a></li>
+                                {else if $member.live_cam_type.name == "Camera Image"}
+                                    <li><a href="{$siteBaseUrl}{$settings.canonical_member_page}/{$member.member_slug}/?expanded=live-cam">{$terms.term_webcam_cap}</a></li>
                                 {/if}
+                                
                                 <li><a href="{$siteBaseUrl}{$settings.canonical_member_page}/{$member.member_slug}/">View&nbsp;More</a></li>
                                 {apply_filters('glm-member-db-front-members-list-memberBelow', '', $member.member_pointer)}
                             </ul>