當前位置: 首頁>>代碼示例>>PHP>>正文


PHP JModelAdmin::canDelete方法代碼示例

本文整理匯總了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;
     }
 }
開發者ID:smhnaji,項目名稱:sdnet,代碼行數:39,代碼來源:composition.php

示例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);
     }
 }
開發者ID:thebeuving,項目名稱:joomla-25-component-example,代碼行數:15,代碼來源:helloworld.php

示例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);
     }
 }
開發者ID:Shtier,項目名稱:digicom,代碼行數:18,代碼來源:discount.php

示例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);
     }
 }
開發者ID:reechalee,項目名稱:joomla1.6,代碼行數:17,代碼來源:contact.php

示例5: canDelete

 protected function canDelete($record)
 {
     if ($record->home) {
         // default record cannot be deleted
         return false;
     } else {
         return parent::canDelete($record);
     }
 }
開發者ID:Lothurm,項目名稱:J3.x,代碼行數:9,代碼來源:jt_theme.php

示例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);
     }
 }
開發者ID:woakes070048,項目名稱:joomlatools-platform,代碼行數:17,代碼來源:item.php

示例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);
     }
 }
開發者ID:scarsroga,項目名稱:blog-soa,代碼行數:9,代碼來源:phocagalleryco.php

示例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);
     //}
 }
開發者ID:optimosolution,項目名稱:marhk,代碼行數:9,代碼來源:phocagalleryuser.php

示例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);
     }
 }
開發者ID:GitIPFire,項目名稱:Homeworks,代碼行數:19,代碼來源:tag.php

示例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);
     }
 }
開發者ID:hogeh,項目名稱:htraininglogs,代碼行數:21,代碼來源:htraininglog.php

示例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);
         }
     }
 }
開發者ID:bubujie,項目名稱:xixia,代碼行數:21,代碼來源:faq.php

示例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);
     }
 }
開發者ID:Shtier,項目名稱:digicom,代碼行數:24,代碼來源:product.php

示例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);
 }
開發者ID:christianesperar,項目名稱:joomla-example,代碼行數:53,代碼來源:level.php

示例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;
 }
開發者ID:site4com,項目名稱:acts,代碼行數:28,代碼來源:post.php

示例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);
     }
 }
開發者ID:smhnaji,項目名稱:sdnet,代碼行數:33,代碼來源:form.php


注:本文中的JModelAdmin::canDelete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。