public function canDelete(&$msg, $oid = null, $joins = null) { $tables[] = array('label' => 'Projects', 'name' => 'projects', 'idfield' => 'project_id', 'joinfield' => 'project_company'); $tables[] = array('label' => 'Departments', 'name' => 'departments', 'idfield' => 'dept_id', 'joinfield' => 'dept_company'); $tables[] = array('label' => 'Users', 'name' => 'users', 'idfield' => 'user_id', 'joinfield' => 'user_company'); // call the parent class method to assign the oid return parent::canDelete($msg, $oid, $tables); }
public function canDelete(&$msg, $oid = null, $joins = null) { global $AppUI; if ($oid) { // Check to see if there is a user $q = new DBQuery(); $q->addTable('users'); $q->addQuery('count(user_id) as user_count'); $q->addWhere('user_contact = ' . (int) $oid); $user_count = $q->loadResult(); if ($user_count > 0) { $msg = $AppUI->_('contactsDeleteUserError'); return false; } } return parent::canDelete($msg, $oid, $joins); }