Topics

User Functions

Events

There are no upcoming events

What's New

Stories

No new stories

Comments last 2 weeks

No new comments

Trackbacks last 2 weeks

No new trackback comments

Links last 2 weeks

No recent new links

NEW FILES last 14 days

No new files

Welcome to Geeklog Thursday, May 23 2013 @ 09:38 PM EDT


 Forum Index > Development & Coding > Geeklog New Topic Post Reply
 Non permission story link in a block appears as text
   
MartinD
 01/18/13 04:27PM (Read 449 times)  
+----
Newbie

Status: offline


Registered: 01/15/13
Posts: 8
Why does a non permissioned story link (auto tag) in a right block display as
[story:20130111190308862 Captain's Address] instead of a clickable link "Captains's Address" ?

I have static pages which I don't want anonymous users to see so I set the access rights to non readable.


Martin

PS.

The link works fine for logged in users. I would have thought the link would appear as a normal link but display a login page when clicked if you don't have read permissions.

 
Profile Email
 Quote
::Ben
 01/19/13 02:54AM  
+++++
Full Member

Status: offline


Registered: 01/14/05
Posts: 1359
I'm trying to do this with autotag plugin. Work in progress...

We speak french on http://geeklog.fr
 
Profile Email Website
 Quote
::Ben
 01/19/13 03:57AM  
+++++
Full Member

Status: offline


Registered: 01/14/05
Posts: 1359
The difficulty is to handle the access rights to the article because anonymous users will be redirect to index of the site.

If you want to display the link to anonymous you can use autotag plugin. Create a new autotag call linkstory for exemple (check Replace with PHP).

In your lib-custom.php file add this function:

PHP Formatted Code

function phpautotags_linkstory ($p1,$p2) {

        global $_TABLES,$_CONF;
       
        $result = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE sid = '$p1'");
        $A = DB_fetchArray($result);

        if ($A['count'] > 0) {

                if (SEC_hasAccess ($A['owner_id'], $A['group_id'],
                    $A['perm_owner'], $A['perm_group'], $A['perm_members'],
                    $A['perm_anon']) >= 2) {
                $url = COM_buildUrl($_CONF['site_url'] . '/article.php?story='. $p1);
                } else {
                    // You can custom the page ID here
                    $url = COM_buildUrl($_CONF['site_url'] . '/staticpages/index.php?page=my_custom_page');
                }
                                                       
                $linktext = $p2;
                if (empty($linktext)|| $p1==$p2) {
                        $linktext = stripslashes(DB_getItem($_TABLES['stories'],
                                                                                'title', "sid = '$p1'"));
                }
                $content = COM_createLink($linktext, $url);
        }

        return $content;

}


Then create a php static page with ID: my_custom_page
Select execute php(return) and put this code in the content in text or html formatted

PHP Formatted Code
return SEC_loginRequiredForm();



We speak french on http://geeklog.fr
 
Profile Email Website
 Quote
MartinD
 01/20/13 08:30AM  
+----
Newbie

Status: offline


Registered: 01/15/13
Posts: 8
Hi Ben,

Thank you for your reply.

Where do I put the call to "phpautotags_linkstory" function ?

Martin

 
Profile Email
 Quote
::Ben
 01/20/13 01:07PM  
+++++
Full Member

Status: offline


Registered: 01/14/05
Posts: 1359
Martin,

Add this new function in your system/lib-custom.php file.

Ben

We speak french on http://geeklog.fr
 
Profile Email Website
 Quote
MartinD
 01/21/13 09:56AM  
+----
Newbie

Status: offline


Registered: 01/15/13
Posts: 8
Hi Ben,

I have completed all the tasks you suggested but at some point (not sure where) I will have to call your new function (phpautotags_linkstory). This function does not replace an existing function so it needs to be called when I'm creating an autotag link. If the user does not have access to the story link they redivert to the login page otherwise the get a valid story link. (or have I not grasped the autotag/link concept ?).

I am a Newbie so I'm not familiar (yet) with all the plugins jargon etc. I do understand PHP.


Cheers

Martin


 
Profile Email
 Quote
::Ben
 01/21/13 11:48AM  
+++++
Full Member

Status: offline


Registered: 01/14/05
Posts: 1359
Martin,

1. You need to install the autotag plugin
2. Create the "linkstory" autotag on the autotag admin page
3. Add function phpautotags_linkstory to your lib-custom.php file
4. The staic page with ID: my_custom_page
6. In your block create link with [ linkstory : XXXXXXXXXXXXX] where XXXXXXXXXXXXX is your story ID.

For anonymous users link will bring them to the my_custom_page where they can log in
For logged-in users link will bring theme to the story XXXXXXXXXXXXX

The senario is not perfect as "anonymous" will need to click once more on the link to go to the story. We need to handle a redirection just after the user log in...

Ben

We speak french on http://geeklog.fr
 
Profile Email Website
 Quote
Content generated in: 0.61 seconds
New Topic Post Reply

Normal Topic Normal Topic
Sticky Topic Sticky Topic
Locked Topic Locked Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to post 
Filtered HTML Allowed 
Censored Content