コード例 #1
0
ファイル: tracks.php プロジェクト: joebushi/joomla
 /**
  * Method to delete rows.
  *
  * @param	array	An array of item ids.
  *
  * @return	boolean	Returns true on success, false on failure.
  */
 public function delete()
 {
     // Initialise variables
     $user = JFactory::getUser();
     // Access checks.
     $categoryId = $this->getState('category_id');
     if ($categoryId) {
         $allow = $user->authorise('core.delete', 'com_banners.category.' . (int) $categoryId);
     } else {
         $allow = $user->authorise('core.delete', 'com_banners');
     }
     if ($allow) {
         // Delete tracks from this banner
         $query = new JQuery();
         $query->delete();
         $query->from('`#__banner_tracks`');
         // Filter by type
         $type = $this->getState('filter.type');
         if (!empty($type)) {
             $query->where('track_type = ' . (int) $type);
         }
         // Filter by begin date
         $begin = $this->getState('filter.begin');
         if (!empty($begin)) {
             $query->where('track_date >= ' . $this->_db->Quote($begin));
         }
         // Filter by end date
         $end = $this->getState('filter.end');
         if (!empty($end)) {
             $query->where('track_date <= ' . $this->_db->Quote($end));
         }
         $where = '1';
         // Filter by client
         $clientId = $this->getState('filter.client_id');
         if (!empty($clientId)) {
             $where .= ' AND cid = ' . (int) $clientId;
         }
         // Filter by category
         if (!empty($categoryId)) {
             $where .= ' AND catid = ' . (int) $categoryId;
         }
         $query->where('banner_id IN (SELECT id FROM `#__banners` WHERE ' . $where . ')');
         $this->_db->setQuery((string) $query);
         $this->setError((string) $query);
         $this->_db->query();
         // Check for a database error.
         if ($this->_db->getErrorNum()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
     } else {
         JError::raiseWarning(403, JText::_('JError_Core_Delete_not_permitted'));
     }
     return true;
 }
コード例 #2
0
ファイル: banners.php プロジェクト: joebushi/joomla
 /**
  * Method to delete rows.
  *
  * @param	array	An array of item ids.
  *
  * @return	boolean	Returns true on success, false on failure.
  */
 public function delete(&$pks)
 {
     // Initialise variables
     $user = JFactory::getUser();
     // Typecast variable.
     $pks = (array) $pks;
     // Get a row instance.
     $table =& $this->getTable();
     // Iterate the items to delete each one.
     foreach ($pks as $i => $pk) {
         if ($table->load($pk)) {
             // Access checks.
             if ($table->catid) {
                 $allow = $user->authorise('core.delete', 'com_banners.category.' . (int) $table->catid);
             } else {
                 $allow = $user->authorise('core.delete', 'com_banners');
             }
             if ($allow) {
                 if (!$table->delete($pk)) {
                     $this->setError($table->getError());
                     return false;
                 }
                 // Delete tracks from this banner
                 $query = new JQuery();
                 $query->delete();
                 $query->from('#__banner_tracks');
                 $query->where('banner_id=' . (int) $pk);
                 $this->_db->setQuery((string) $query);
                 $this->_db->query();
                 // Check for a database error.
                 if ($this->_db->getErrorNum()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
             } else {
                 // Prune items that you can't change.
                 unset($pks[$i]);
                 JError::raiseWarning(403, JText::_('JError_Core_Delete_not_permitted'));
             }
         } else {
             $this->setError($table->getError());
             return false;
         }
     }
     return true;
 }
コード例 #3
0
ファイル: module.php プロジェクト: joebushi/joomla
 /**
  * Method to delete rows.
  *
  * @param	array	An array of item ids.
  *
  * @return	boolean	Returns true on success, false on failure.
  */
 public function delete(&$pks)
 {
     // Initialise variables.
     $pks = (array) $pks;
     $user = JFactory::getUser();
     $table = $this->getTable();
     // Iterate the items to delete each one.
     foreach ($pks as $i => $pk) {
         if ($table->load($pk)) {
             // Access checks.
             if (!$user->authorise('core.delete', 'com_modules')) {
                 throw new Exception(JText::_('JError_Core_Delete_not_permitted'));
             }
             if (!$table->delete($pk)) {
                 throw new Exception($table->getError());
             } else {
                 // Delete the menu assignments
                 $query = new JQuery();
                 $query->delete();
                 $query->from('#__modules_menu');
                 $query->where('moduleid=' . (int) $pk);
                 $this->_db->setQuery((string) $query);
                 $this->_db->query();
             }
         } else {
             throw new Exception($table->getError());
         }
     }
     return true;
 }