本文整理汇总了PHP中JModelAdmin::canDelete方法的典型用法代码示例。如果您正苦于以下问题:PHP JModelAdmin::canDelete方法的具体用法?PHP JModelAdmin::canDelete怎么用?PHP JModelAdmin::canDelete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JModelAdmin
的用法示例。
在下文中一共展示了JModelAdmin::canDelete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: canDelete
/**
* Method to test whether a record can be deleted.
*
* @param object A record object.
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id)) {
$user = JFactory::getUser();
// Check that user have access permission to data banks and can delete
if ($user->authorise('core.core', $this->option) && parent::canDelete($record)) {
// Check that desease not used in these tables
$tables = array('dairies', 'fruits', 'sweeteners', 'prescriptions', 'foods', 'compositions');
$db = JFactory::getDbo();
foreach ($tables as $table) {
$query = $db->getQuery(true);
$query->select("COUNT(s.id) AS scount");
$query->from('#__sibdiet_' . $table . ' AS s');
$query->where("s.compositions LIKE '%\"" . $record->id . "\":%'");
$db->setQuery($query);
try {
// Execute the query in Joomla 3.0.
$compositionUsed = $db->loadResult();
} catch (Exception $e) {
// catch any database errors.
}
if ($compositionUsed) {
// echo that item is used
$this->setError(JText::sprintf('COM_SIBDIET_ERR_COMPOSITION_USED', $record->title));
return;
}
}
return true;
}
return;
}
}
示例2: canDelete
/**
* Метод для проверки, может ли пользователь удалять существующую запись.
*
* @param object $record Объект записи.
*
* @return boolean True, если разрешено удалять запись.
*/
protected function canDelete($record)
{
if (!empty($record->id)) {
return JFactory::getUser()->authorise('core.delete', $this->option . '.message.' . (int) $record->id);
} else {
return parent::canDelete($record);
}
}
示例3: canDelete
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the permission for the component.
*
* @since 1.0.0
*/
protected function canDelete($record)
{
if (!empty($record->id)) {
if ($record->catid) {
return JFactory::getUser()->authorise('core.delete', 'com_digicom.discount.' . (int) $record->catid);
}
return parent::canDelete($record);
}
}
示例4: canDelete
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
* @since 1.6
*/
protected function canDelete($record)
{
$user = JFactory::getUser();
if ($record->catid) {
return $user->authorise('core.delete', 'com_contact.category.' . (int) $record->catid);
} else {
return parent::canDelete($record);
}
}
示例5: canDelete
protected function canDelete($record)
{
if ($record->home) {
// default record cannot be deleted
return false;
} else {
return parent::canDelete($record);
}
}
示例6: canDelete
/**
* Method to test whether a record can be deleted.
*
* @param object A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id)) {
if ($record->published != -2) {
return;
}
return parent::canDelete($record);
}
}
示例7: canDelete
protected function canDelete($record)
{
$user = JFactory::getUser();
if (!empty($record->catid)) {
return $user->authorise('core.delete', 'com_phocagallery.phocagalleryco.' . (int) $record->catid);
} else {
return parent::canDelete($record);
}
}
示例8: canDelete
protected function canDelete($record)
{
$user = JFactory::getUser();
/*if ($record->catid) {
return $user->authorise('core.delete', 'com_phocagallery.phocagalleryuser');
} else {*/
return parent::canDelete($record);
//}
}
示例9: canDelete
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
*
* @since 3.1
*/
protected function canDelete($record)
{
if (!empty($record->id)) {
if ($record->published != -2) {
return;
}
$user = JFactory::getUser();
return parent::canDelete($record);
}
}
示例10: canDelete
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the permission for the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id)) {
if ($record->state != -2) {
return;
}
if ($record->catid) {
return JFactory::getUser()->authorise('core.delete', 'com_htraininglogs.category.' . (int) $record->catid);
}
return parent::canDelete($record);
}
}
示例11: canDelete
/**
* Method to test whether a record can be deleted.
*
* @param object A record object.
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id)) {
if ($record->state != -2) {
return;
}
$user = JFactory::getUser();
if ($record->catid) {
return $user->authorise('core.delete', 'com_faqs.category.' . (int) $record->catid);
} else {
return parent::canDelete($record);
}
}
}
示例12: canDelete
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the permission for the component.
*
* @since 1.0.0
*/
protected function canDelete($record)
{
if (!empty($record->id)) {
if ($record->published != -2) {
return;
}
if (!$this->checkOrderExist($record->id)) {
return;
}
if ($record->catid) {
return JFactory::getUser()->authorise('core.delete', 'com_digicom.category.' . (int) $record->catid);
}
return parent::canDelete($record);
}
}
示例13: canDelete
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
* @since 1.6
*/
protected function canDelete($record)
{
// Check if the access level is being used by any content.
if ($this->levelsInUse === null) {
// Populate the list once.
$this->levelsInUse = array();
$db = $this->getDbo();
$query = $db->getQuery(true)->select('DISTINCT access');
// from is added dynamically
// Get all the tables and the prefix
$tables = $db->getTableList();
//$fields = $db->getTableFields($tables);
$prefix = $db->getPrefix();
foreach ($tables as $table) {
// Get all of the columns in the table
$fields = $db->getTableColumns($table);
// We are looking for the access field. If custom tables are using something other
// than the 'access' field they are on their own unfortunately.
// Also make sure the table prefix matches the live db prefix (eg, it is not a "bak_" table)
if (strpos($table, $prefix) === 0 && isset($fields['access'])) {
// Lookup the distinct values of the field.
$query->clear('from')->from($db->quoteName($table));
$db->setQuery($query);
$values = $db->loadColumn();
$error = $db->getErrorMsg();
// Check for DB error.
if ($error) {
$this->setError($error);
return false;
}
$this->levelsInUse = array_merge($this->levelsInUse, $values);
// TODO Could assemble an array of the tables used by each view level list those,
// giving the user a clue in the error where to look.
}
}
// Get uniques.
$this->levelsInUse = array_unique($this->levelsInUse);
// Ok, after all that we are ready to check the record :)
}
if (in_array($record->id, $this->levelsInUse)) {
$this->setError(JText::sprintf('COM_USERS_ERROR_VIEW_LEVEL_IN_USE', $record->id, $record->title));
return false;
}
return parent::canDelete($record);
}
示例14: canDelete
/**
* Method to test whether a record can be deleted.
*
* @param
* object A record object.
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id)) {
if ($record->published != -2) {
return;
}
$user = JFactory::getUser();
if (!empty($record->catid)) {
$canDelete = $user->authorise('core.delete', 'com_edashboard.category.' . (int) $record->catid);
} else {
$canDelete = parent::canDelete($record);
}
}
// ABP: Additional check on pub dates: deny if published, only superadmin can change
if ($canDelete && !$user->authorise('core.admin') && $record->id) {
$item = $this->getItem($record->id);
$canDelete = !$this->isPublished($item);
}
return $canDelete;
}
示例15: canDelete
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the permission for the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id)) {
if ($record->state != -2) {
return;
}
$user = JFactory::getUser();
// Check that desease not used in given diets
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select("q.id")->from('#__testyourself_questions AS q')->where("q.formid = " . $record->id);
$db->setQuery($query);
try {
$used = $db->loadColumn();
} catch (Exception $e) {
// catch any database errors.
}
if (count($used)) {
// echo that item is used
$this->setError(JText::sprintf('COM_TESTYOURSELF_ERR_FORM_USED', $record->title . ' (' . implode(' - ', $used) . ')'));
return;
}
return parent::canDelete($record);
}
}