/** * checks if customfield(s) are still in use (have values) * * @param array $ids * @throws Tinebase_Exception_SystemGeneric */ protected function _checkCFUsage($ids) { $filter = new Tinebase_Model_CustomField_ValueFilter(array(array('field' => 'customfield_id', 'operator' => 'in', 'value' => (array) $ids))); $result = $this->_customfieldController->search($filter, NULL, FALSE, TRUE); if ($result->count() > 0) { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . count($result) . ' records still have custom field values.'); } throw new Tinebase_Exception_SystemGeneric('Customfield is still in use!'); } }
/** * checks if customfield(s) are still in use (have values) * * @param array $ids * @throws Tinebase_Exception_SystemGeneric */ protected function _checkCFUsage($ids) { $filter = new Tinebase_Model_CustomField_ValueFilter(array(array('field' => 'customfield_id', 'operator' => 'in', 'value' => (array) $ids))); $result = $this->_customfieldController->search($filter, NULL, FALSE, TRUE); if ($result->count() > 0) { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . count($result) . ' records still have custom field values.'); } $foundIds = array_values(array_unique($result->customfield_id)); $filter = new Tinebase_Model_CustomField_ConfigFilter(array(array('field' => 'id', 'operator' => 'in', 'value' => (array) $foundIds))); $result = $this->search($filter); $names = $result->name; throw new Tinebase_Exception_Record_StillInUse('Customfields: ' . join(', ', $names) . ' are still in use! Are you sure you want to delete them?'); } }