Redirect Plugin?
13 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: April 25, 2012 (RSS)
By nmsinc - February 25, 2012
Please note that I'm using more than one postsave plugin which should not be a problem; or is it?
Thanks nmsinc
<?php
addAction('record_postsave', '_plugin_redirectonsubmitt', null, 4);
// redirect to specific page on submitt
function _plugin_redirectonsubmitt($tablename, $isNewRecord, $oldRecord, $recordNum) {
redirectBrowserToURL('/claims/listing.php');
}
?>
Re: [nmsinc] Redirect Plugin?
By Dave - February 28, 2012
Sorry for the delay, it's because you are asking tricky questions! ;)
The edit page saved with AJAX, so anything returned is alert()'d with javascript. Here's a plugin that catches the values on the list page and redirects from there after a save:
addFilter('section_init', '_plugin_RedirectOnSave', null, 2);
function _plugin_redirectonsave($tableName, $action) {
if ($tableName != 'accounts') { return; } // only run on accounts table
if ($action != 'list') { return; } // only run on list
if (!@$_REQUEST['saved']) { return; } // only run when a record was saved
$recordNum = @$_REQUEST['saved'];
$url = "https://www.google.com/search?q=" . urlencode("Saved record $recordNum in $tableName");
redirectBrowserToURL($url);
}
Let me know if that works for you or any questions. Thanks!
interactivetools.com
Re: [Dave] Redirect Plugin?
By nmsinc - February 29, 2012
Worked perfect as always - you may want to add this plugin to the AddOns list as I can see others needing it!
Thanks again - nmsinc
Re: [nmsinc] Redirect Plugin?
By Dave - February 29, 2012
Just curious, what are you using it for?
interactivetools.com
Re: [Dave] Redirect Plugin?
By nmsinc - February 29, 2012
This site has multiple companies with multiple users all having different rights for record creating, editing and viewing. I have a record-listing page that delivers records based on each users privilege. Each record has multiple users and each user may or may not have edit rights on the record.
In the CMS, setting users to “Author/Edit” only gives that user the right to create and edit their own records when others may also need to do so. Setting users to “Editor” gives access to all records on the CMS listing page once the record was saved or edited including records from other companies.
The only idea I came up with was to use a redirect back to the record listing page that we setup each time a user saves a record to keep them from viewing and editing records that belong to other companies!
Thanks - nmsinc
Re: [nmsinc] Redirect Plugin?
By Dave - February 29, 2012
Well good luck with it and let me know if you have any other questions. Thanks!
interactivetools.com
Re: [Dave] Redirect Plugin?
By nmsinc - April 23, 2012
Thanks - nmisnc
Re: [nmsinc] Redirect Plugin?
By Dave - April 23, 2012
Are the users who are viewing the page logging in with the website membership plugin? Or how are they getting the URL to the page?
interactivetools.com
Re: [Dave] Redirect Plugin?
By nmsinc - April 23, 2012
Thanks - nmsinc
Re: [nmsinc] Redirect Plugin?
By Dave - April 23, 2012
if ($CURRENT_USER['group'] != $record['group']) {
die("Sorry, you don't have access to this record");
}
Another way is to use two keys to access the record so it would be much harder to guess. One example might be the createdTime, so you could have an url such as: ?num=123&token=1335201606 then some code:
if ($record['createdTime'] != $_REQUEST['token']) {
die("Sorry, record token is invalid, please check your link!");
}
Or you could just create a new field (eg: lookupID), populate that with an unused random value and lookup on that. eg: viewer.php?lookupID=d131dd02c5e6eec4
If you want a nice random looking string sometimes I used the md5() function for that.
Hope that helps! Let me know any questions.
interactivetools.com