Possibility to bypass the current DELETE ROW entry from list

acayer

New Member
I currently use the CANDELETROW plugin on a field. Furthermore, I would like to have like a LIST PLUGIN (or any bypass) to be able to skip the default DELETE ROW script and add to it.
I want to be able to delete other related rows (with linked ID) in other list as to be coherent. If I delete row in first list, it also needs to be del in 2nd list and/or 3rd to be coherent.

Also, another good bypass, instead of realy deleting, it could be nice to change the script to change their VISIBLE (bool element) in the list so the row is only not displayed (like with a pre filter query) and the real data shall only be use for admin, for example. I think it is possible to do something like that with the LIST PHP plugin for list but, I won'b be able to use the CANDELETEROW.... I just think it shall be possible to enforce something other then default.

Anyone would have an idea to proceed ?

Thanks
 
You should be able to use the "update col" list plugin, and change a hidden status field value, so (say) setting an "inactive" field to 1, and pre-filtering on that.

-- hugh
 
Note - you'll also need to add an extra J! viewing access level (VAL), for "not admins", so you can apply the filter only to folk who aren't admins. There isn't a pre-configured VAL that satisfies that condition.

-- hugh
 
You should be able to use the "update col" list plugin, and change a hidden status field value, so (say) setting an "inactive" field to 1, and pre-filtering on that.

-- hugh


The Update col would be good for the second part, as to have a fake del row. However, I would still need to have, for admin, the need to push a DBO request to del another row in another table with the same ID or unique variable.
 
Are we talking about when you really delete a row, or when you "fake" delete it by making it inactive?

if we're talking about when you really delete a row, you can use the php_events list plugin, using the onDeleteRows hook. The id's for the rows being deleted would be in the 'ids' request variable, so it'd be just half a dozen lines of code, something like ...


PHP:
$app = JFactory::getApplications();
$ids = $app->input->get('ids');
if (!empty($ids)) {
  $db = JFactory::getDbo();
  $query = $db->getQuery(true);
  $query->delete($db->quoteName('your_table')->where($db->quoteName('your_fk') . ' IN (' . explode(',',$ids) . ')');
  $db->setQuery($query);
  $db->execute();
}

... or whatever query(s) you need, based on the PK's being deleted form the main table.

If we're talking about "fake" deleting by using update_col to set a status ... not so simple, as we don't have a hook you can hang a plugin on for that, and the update_col plugin itself doesn't have an eval'ed code option.

You could actually use the email feature ... that has an eval'ed option for the content ... so you could send an email to a junk address, and do your querying in there, using the same code as above.

Or I could potentially add a specific "code to eval after processing" to update_col if you really need it.

-- hugh

-- hugh
 
Hugh,
The code wasn't working !?!?!?!? I made a scrap test with:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$rowid=$model->rowsToDelete[0][0]->__pk_val;
$query="delete from `g1weq_fb_file_folder` where file_number =". $rowid . ";";
$db->setQuery($query);
$db->execute();

which seems to work.... of course its pretty basic and only work with 1 row... Any workaround on yours or mine ? A cycling through rowsToDelete[X][0]->__pk_val in a string (like with your explode) and then have the IN statement instead of the = ?
Also, is by default the 0 0 value always ID ? my cross table is made by reference to ID in initial table which then reference as file_number in other list... Therefore this works with first list since the reference is ID but if i try to implement the same thing in second table, my reference will be file_number... and not ID. Could i be using: $model->rowsToDelete[0]['file_number']->__pk_val
 
Are we talking about when you really delete a row, or when you "fake" delete it by making it inactive?


Or I could potentially add a specific "code to eval after processing" to update_col if you really need it.


-- hugh

Hugh, it doesn't make sense to send an actual email each time. The addition, as you suggest, of a specific field would make much more sense and could also be use by everyone. Can you let me know files to update.
 
Hugh,

My query only works when the record is in the first page. If my record is in the 3rd page of pagination, the $rowid=$model->rowsToDelete[0][0]->__pk_val; doesn't work... would need some thought on that.

Alex
 
You never really answered my question about whether you are doing this one a "real" delete, or when using update_col to set an "inactive" status.

It sounds like we need to add that eval'ed code option.

-- hugh
 
Hi Hugh,

I'm currently using the real Delete fct and then I will switch to a dummy one. As mention, I'm going a little bit blind to use something that would work with the list and I have seen that (on the Hover of the label in admin), it says to use $rowid=$model->rowsToDelete object. However, as I mention, as soon as there is more than one page on the list, the $rowid=$model->rowsToDelete[0][0]->__pk_val; doesn't work and I'm not familiar enough with it to build an "all time" workaround.

To you have something to suggest to:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$rowid=$model->rowsToDelete[0][0]->__pk_val;
$query="delete from `g1weq_fb_file_folder` where file_number =". $rowid . ";";
$db->setQuery($query);
$db->execute();

As for the "inactive statuts" the eval code option will solve it all.
 
I've added a couple of eval features to update_col:

1) An eval switch for the actual col update value, so that can be eval'ed code instead of a static value.

2) a "Post Eval", which is an optional code block you can run once all the other update processing is done.

I haven't committed the changes yet, I just want to do a little more testing first, plus I have some unmerged changes to the same code I forgot I was working on a month or so back, which I need to finish. I should get it done tonight.

-- hugh
 
Working on getting this stuff committed. Fighting with ssh keys and agents at the moment, having auth issues with github ... still getting my new dev machine and environment sorted out, gradually transferring all my project work to the new 'puter.

-- hugh
 
OK, new eval options should be in github.

So ... to post process a list of rows which have been updated with update_col, fetching the data for each one, might look like ...

PHP:
$aids = explode(',', $ids);
foreach ($aids as $id)
{
    // You code here to process the related tables, where $id is the rowid (PK value) of the main row
}
 
OK, new eval options should be in github.

So ... to post process a list of rows which have been updated with update_col, fetching the data for each one, might look like ...

PHP:
$aids = explode(',', $ids);
foreach ($aids as $id)
{
    // You code here to process the related tables, where $id is the rowid (PK value) of the main row
}

Just finish with my reservation attempt to hack the date plugin, I will look around as next thing on my list to try to make it work.

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

Thank you.

Members online

Back
Top