Exemple #1
0
 /**
  * Deletes a message type.
  *
  * @param   integer  $pk  Primary key of the message type to be deleted.
  *
  * @return  boolean  True on success, false on failure.
  *
  */
 public function delete($pk = null)
 {
     // Add configuration helper file
     require_once JPATH_COMPONENT . '/helpers/configuration.php';
     // If message type is defined as default in configuration, it cannot be removed
     if (ConfigurationHelper::isMessageTypeUsedInConfiguration($this->id)) {
         // Raise a warning
         JFactory::getApplication()->enqueueMessage(JText::_('COM_ISSNREGISTRY_MESSAGE_TYPE_DELETE_FAILED_SETTINGS'), 'warning');
         // Return false as the item can't be deleted
         return false;
     }
     // Load message template model
     $messageTemplateModel = JModelLegacy::getInstance('messagetemplate', 'IssnregistryModel');
     // Get number of templates that use this message type
     $templateCount = $messageTemplateModel->getMessageTemplatesCountByMessageType($this->id);
     // If template count is not zero, message type cannot be deleted
     if ($templateCount != 0) {
         // Raise a warning
         JFactory::getApplication()->enqueueMessage(JText::_('COM_ISSNREGISTRY_MESSAGE_TYPE_DELETE_FAILED_USED'), 'warning');
         // Return false as the item can't be deleted
         return false;
     }
     // No ISSNs have been used, delete the item
     return parent::delete($pk);
 }
 /**
  * Deletes a message template.
  *
  * @param   integer  $pk  Primary key of the message template to be deleted.
  *
  * @return  boolean  True on success, false on failure.
  *
  */
 public function delete($pk = null)
 {
     // Add configuration helper file
     require_once JPATH_COMPONENT . '/helpers/configuration.php';
     // If message template's message type is defined as default in
     // configuration, it cannot be removed
     if (ConfigurationHelper::isMessageTypeUsedInConfiguration($this->message_type_id)) {
         // Raise a warning
         JFactory::getApplication()->enqueueMessage(JText::_('COM_ISSNREGISTRY_MESSAGE_TEMPLATE_DELETE_FAILED_SETTINGS'), 'warning');
         // Return false as the item can't be deleted
         return false;
     }
     // No ISSNs have been used, delete the item
     return parent::delete($pk);
 }