Updating database value each time PHP List icon clicked

This line looks wrong to me:

Code:
if (!empty($path) and $linktype=2)

it should be
Code:
if (!empty($path) and $linktype == 2)

(single = means assign 2 to $linktype, double == means is 2 equal to $linktype, and triple === means is 2 equal to link type and the the same type (string, integer etc)
 
Thanks Rob.

I have implemented that change and now I have the following PHP and JS code in the PHP list plugin:

PHP:
$app = JFactory::getApplication();
$ids = $app->input->get('ids', array(), 'array');
$id = array_pop($ids);
 
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query = "UPDATE erd_resources SET hits = hits + 1 WHERE id=".$id ;
$db->setQuery($query);
$result = $db->execute();
 
$ids_str = json_encode($ids);
$row = $model->getRow($id);
$path = $row->erd_resources___link;
$linktype = $row->erd_resources___linkTypeId;
 
if (!empty($path) and $linktype == 2)
{
echo '<pre>';
$result2 = system($path);
echo '</pre>';
  exit;
}
$statusMsg = " Ids: " . $ids_str . "," . $id .  " Path: " . $path;

Code:
// rows is an array of objects representing the selected table rows.
// You might need to add the _raw prefix to the full element name, depending on the field type (e.g. if its a dropdown).
var linkTypeId = parseInt(rows[0].erd_resources___id_linktype, 10);
var path = rows[0].erd_resources___link;
 
if (linkTypeId != 2) {
    window.open(path);
//    return false;
}

The first of the two major problems I noted above of the ERD list display not reappearing after a resource was selected is no longer occurring even with the exit line in the PHP code no longer commented out - which is excellent.

However I am still left with the second major issue of the linktype 2 resources (win apps on the server) not opening in a separate window. I understand that this is asking for a great deal for a browser on a client machine being able to interact with a windows app on a windows server. However I am still interested in investigating whether the test html mentioned above that does allow this to occur in IE (albeit via a user button press and then acceptance of a security warning) provides any hope for integration within the user's interaction with the Fabrik list.
 
No idea I'm afraid, could be because IE is tied closely to windows and thus allows features that chrome doesn't - but that is just a complete guess.
 
Well the only way that code would work is if that bat file was stored locally on the machine the browser is running on. All it does is run a file on your C: drive:

Code:
<input type="button" value="Launch Application" onclick="window.open('file:///C:/TSapplications/Scripts/A245CD1.bat')" />

So in theory, you could do it by first having the user the file (which you could probably do with a custom link that duplicates the style of link used by our fileupload element in "download script" mode), which the user would have to store in a pre-determined folder, then do that window.open().

-- hugh
 
The only other way of doing that I could think of would be if all your clients are on your intranet, and you have tight enough administrative control to have everyone mount a share from the server, then you could open //sharename/path/to/file.bat, but I've never actually tried that. Browsers may not like doing that, as it would be open up vectors for horrific abuse..

-- hugh
 
Thanks Hugh.

For some unknown reason I am no longer getting notifications of replies so I was coming here to report progress before i saw your last two posts.

We have achieved success (largely) by moving the location of the .cmd and .bat scripts to a folder within the public_html folder of the webserver, and then referring to them by their URL. As you noted my client relies on restricting which clients can access this server. I assume this includes access to the actual application. This approach still gives the user an unattractive security message (with Run/Save/Cancel options) that seems to be unavoidable on the latest version of Windows Server.

This solution works on IE. In Chrome by default it downloads the .bat file and you need to right click on the downloaded file to Open it - when it then runs.

The client is currently considering how its users can best cope with the security message - an alternative approach would be to have an intermediate page with a Launch button together with user guidance about what to expect and do when the button is pressed.

I have a hopefully simpler Fabrik question related to the PHP List Plugin. I can alter the text of the Success Message but I do not seem to be able to turn it off. With the Success message field empty I still get a Code Run message on the Joomla page. Is there a simple way to turn this off for just this plugin? If no simple way can you point me to where I need to hack the plugin code?

David
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top