hi all,
form listcontacts should list all available contacts with the following columns
firstname, lastname, position, phone, email, edit link, delete link
all but the delete link is working
usually a delete link would be set up defining a task which might look somewhat like this:
with the html looking like this:
however a task does not seem to be the right approach here. thus I suppose I would need a new event
the delete link would need to go into the foreach below the DBMRL
I created a new event called delete_contact and added a custom code action to it.
only where should I go with what? and would I need some server side validation somewhere?
I'm a bit lost here...
form listcontacts should list all available contacts with the following columns
firstname, lastname, position, phone, email, edit link, delete link
all but the delete link is working
usually a delete link would be set up defining a task which might look somewhat like this:
$task = JRequest::getVar('task','','get');
switch( $task ){
case 'deleteItem':
deleteItem();
break;
}
function deleteItem() {
global $mainframe;
$uid = JRequest::getVar( 'cf_uid' , '', 'get');
if ($uid) {
$user =& JFactory::getUser();
$cf_user_id = JRequest::getVar( 'cf_user_id' , '', 'get' );
if ( ($user->gid < '23' AND $cf_user_id = $user->id) OR $user->gid > '22' ) {
$database->setQuery("DELETE FROM #__chronoforms_data_contacts WHERE cf_uid = '$uid'");
$database->query();
$mainframe->redirect(JRoute::_("index.php?option=com_chronoforms&chronoform=listcontacts"), JText::_('DELETED_ITEM') );
} else {
$mainframe->redirect(JRoute::_("index.php?option=com_chronoforms&chronoform=listcontacts"), JText::_('NOT_AUTH') );
}
}
}
with the html looking like this:
?>
<script type="text/javascript">
//<![CDATA[
function deleteContact(uid) {
var yesno = confirm ('<?php echo JText::_('SURE_DELETE_RECORD');?>');
if (yesno == true) {
location = 'index.php?option=com_chronoforms&chronoform=listcontacts&task=deleteItem&cf_uid='+uid;
}
}
//]]>
</script>
<?php
$user =& JFactory::getUser();
$cf_user_id = JRequest::getVar( 'cf_user_id' , '', 'get' );
if ( ($user->gid < '23' AND $cf_user_id = $user->id) OR $user->gid > '22' ) { ?>
<a href="javascript:deleteContact(<?php echo JRequest::getVar( 'cf_uid' , '');?>);">
<?php echo JText::_('DELETE'); ?>
</a>
<?php } ?>
however a task does not seem to be the right approach here. thus I suppose I would need a new event
the delete link would need to go into the foreach below the DBMRL
I created a new event called delete_contact and added a custom code action to it.
only where should I go with what? and would I need some server side validation somewhere?
I'm a bit lost here...