Exemplo n.º 1
1
 public function delete($pk = null)
 {
     // Get form model
     $formModel = JModelLegacy::getInstance('form', 'IssnregistryModel');
     if ($pk != null) {
         // Get number of forms related to this publisher
         $formsCount = $formModel->getFormsCountByPublisherId($pk);
         // Check result
         if ($formsCount != 0) {
             // If there are forms, the publisher can't be deleted
             JFactory::getApplication()->enqueueMessage(JText::_('COM_ISSNREGISTRY_PUBLISHER_DELETE_FAILED_FORMS_EXIST'), 'warning');
             // Return false as the item can't be deleted
             return false;
         }
         // Delete messages
         //$messageModel = JModelLegacy::getInstance('message', 'IssnregistryModel');
         //$messageModel->deleteByPublisherId($pk);
     }
     if (parent::delete($pk)) {
         // If this publisher was created based on a form, remove
         // publisher created attribute from the form
         if ($this->form_id != 0) {
             $formModel->removePublisherCreated($this->form_id);
         }
         // Get message model
         $messageModel = JModelLegacy::getInstance('message', 'IssnregistryModel');
         // Delete messages related to this publisher
         $messageModel->deleteByPublisherId($pk);
         // Return true
         return true;
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * Deletes a group message.
  *
  * @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)
 {
     // Delete messages
     $messageModel = JModelLegacy::getInstance('message', 'IsbnregistryModel');
     $messageModel->deleteByGroupMessageId($pk);
     return parent::delete($pk);
 }
Exemplo n.º 3
0
 /**
  * Method to delete a row from the database table by primary key value.
  *
  * @param	mixed	An optional primary key value to delete.  If not set the
  * 			instance property value is used.
  * @return	boolean	True on success.
  * @since	1.0
  * */
 public function deleteBy($params = null)
 {
     if (!empty($params) && !is_array($params)) {
         return parent::delete($params);
     }
     // If no primary key is given, return false.
     if (empty($params)) {
         $e = new JException(JText::_('MIGUR_PARAMS_IS_ABSENT'));
         $this->setError($e);
         return false;
     }
     // Delete the row by primary key.
     $query = $this->_db->getQuery(true);
     $query->delete();
     $query->from($this->_tbl);
     $fields = array_keys($this->getFields());
     //print_r($fields);
     foreach ($params as $name => $val) {
         if (in_array($name, $fields)) {
             $query->where($name . ' = ' . $this->_db->quote($val));
         } else {
             $e = new JException(JText::_('MIGUR_THE_FIELD_NOT_IN_THE_TABLE'));
             $this->setError($e);
             return false;
         }
     }
     $this->_db->setQuery($query);
     // Check for a database error.
     if (!$this->_db->query()) {
         $e = new JException(JText::_('JLIB_DATABASE_ERROR_DELETE_FAILED', get_class($this), $this->_db->getErrorMsg()));
         $this->setError($e);
         return false;
     }
     return true;
 }
Exemplo n.º 4
0
 function delete($pk = null)
 {
     // Initialise variables.
     $k = $this->_tbl_key;
     $pk = is_null($pk) ? $this->{$k} : $pk;
     // If no primary key is given, return false.
     if ($pk === null) {
         $e = new JException(JText::_('JLIB_DATABASE_ERROR_NULL_PRIMARY_KEY'));
         $this->setError($e);
         return false;
     }
     // Check if the category has products related
     $query = 'SELECT product_id FROM #__cp_products WHERE category_id = ' . $pk;
     $this->_db->setQuery($query);
     if (!$this->_db->execute()) {
         $this->db_error = true;
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if ($this->_db->getNumRows() > 0) {
         $e = new JException(JText::_('COM_CP_ERROR_DELETING_CATEGORIES'));
         $this->setError($e);
         return false;
     }
     // Delete associations
     return parent::delete($pk);
 }
Exemplo n.º 5
0
 /**
  * Deletes a Publication.
  *
  * @param   integer  $pk  Primary key of the publication to be deleted.
  *
  * @return  boolean  True on success, false on failure.
  *
  */
 public function delete($pk = null)
 {
     // Item can be deleted only if it doesn't have ISSN yet
     if (!empty($this->issn)) {
         // If identifier exists, raise a warning
         JFactory::getApplication()->enqueueMessage(JText::_('COM_ISSNREGISTRY_PUBLICATIONS_DELETE_FAILED'), 'warning');
         // Return false as the item can't be deleted
         return false;
     }
     // No identifiers found, delete the item
     if (parent::delete($pk)) {
         if ($this->form_id > 0) {
             // Load form model
             $formModel = JModelLegacy::getInstance('form', 'IssnregistryModel');
             // Get form
             $form = $formModel->getItem($this->form_id);
             // Decrease publication count by one
             if (!$formModel->decreasePublicationCount($form->id, $form->publication_count)) {
                 //JFactory::getApplication()->enqueueMessage(JText::_('COM_ISSNREGISTRY_FORM_UPDATE_PUBLICATION_COUNT_FAILED'), 'warning');
             }
         }
         // Load publication archive model
         $publicationArchiveModel = JModelLegacy::getInstance('publicationarchive', 'IssnregistryModel');
         // Delete archive record
         $publicationArchiveModel->deleteByPublicationId($this->id);
         return true;
     }
     return false;
 }
Exemplo n.º 6
0
 /**
  * Method to delete a row from the database table by primary key value.
  *
  * @param	mixed	An optional primary key value to delete.  If not set the
  *					instance property value is used.
  * @return	boolean	True on success.
  * @since	1.0
  * @link	http://docs.joomla.org/JTable/delete
  */
 public function delete($pk = null)
 {
     $query = $this->_db->getQuery(true);
     // Delete all rooms belong to it
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_solidres/models', 'SolidresModel');
     $query->clear();
     $query->select('*')->from($this->_db->quoteName('#__sr_rooms'))->where('room_type_id = ' . $this->_db->quote($pk));
     $rooms = $this->_db->setQuery($query)->loadObjectList();
     $roomModel = JModelLegacy::getInstance('Room', 'SolidresModel');
     foreach ($rooms as $room) {
         $roomModel->delete($room->id);
     }
     // Delete all coupons relation
     $query->clear();
     $query->delete($this->_db->quoteName('#__sr_room_type_coupon_xref'))->where('room_type_id = ' . $this->_db->quote($pk));
     $this->_db->setQuery($query)->execute();
     // Delete all extras relation
     $query->clear();
     $query->delete($this->_db->quoteName('#__sr_room_type_extra_xref'))->where('room_type_id = ' . $this->_db->quote($pk));
     $this->_db->setQuery($query)->execute();
     // Delete all custom fields
     $query->clear();
     $query->delete($this->_db->quoteName('#__sr_room_type_fields'))->where('room_type_id = ' . $this->_db->quote($pk));
     $this->_db->setQuery($query)->execute();
     // Delete all media
     $query->clear();
     $query->delete($this->_db->quoteName('#__sr_media_roomtype_xref'))->where('room_type_id = ' . $this->_db->quote($pk));
     $this->_db->setQuery($query)->execute();
     // Delete all prices
     $query->clear();
     $query->delete($this->_db->quoteName('#__sr_prices'))->where('room_type_id = ' . $this->_db->quote($pk));
     $this->_db->setQuery($query)->execute();
     // Delete itself
     return parent::delete($pk);
 }
Exemplo n.º 7
0
 /**
  * Method to delete a row from the database table by primary key value.
  *
  * @param   mixed    $pk  An optional primary key value to delete.  If not set the
  *                        instance property value is used.
  *
  * @return  boolean  True on success.
  * @since   0.3.0
  */
 public function delete($pk = null)
 {
     $k = $this->_tbl_key;
     $pk = is_null($pk) ? $this->{$k} : $pk;
     $query = $this->_db->getQuery(true);
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_solidres/models', 'UsersModel');
     // Take care of Customer records
     $query->select('COUNT(id)')->from($this->_db->quoteName('#__sr_customers'))->where('customer_group_id = ' . $pk);
     $this->_db->setQuery($query);
     $result = (int) $this->_db->loadResult();
     if ($result > 0) {
         $e = new JException(JText::sprintf('SR_ERROR_CUSTOMER_GROUP_CONTAINS_CUSTOMER', $this->name));
         $this->setError($e);
         return false;
     }
     // Delete all prices
     $query->clear();
     $query->delete($this->_db->quoteName('#__sr_prices'))->where('customer_group_id = ' . $this->_db->quote($pk));
     $this->_db->setQuery($query)->execute();
     // Take care of Coupon
     $couponsModel = JModelLegacy::getInstance('Coupons', 'SolidresModel', array('ignore_request' => true));
     $couponModel = JModelLegacy::getInstance('Coupon', 'SolidresModel', array('ignore_request' => true));
     $couponsModel->setState('filter.customer_group_id', $pk);
     $coupons = $couponsModel->getItems();
     foreach ($coupons as $coupon) {
         $couponModel->delete($coupon->id);
     }
     // Delete it
     return parent::delete($pk);
 }
Exemplo n.º 8
0
 /**
  * Method to delete a row from the database table by primary key value.
  *
  * @param	mixed	An optional primary key value to delete.  If not set the
  *					instance property value is used.
  * @return	boolean	True on success.
  * @since	1.0
  * @link	http://docs.joomla.org/JTable/delete
  */
 public function delete($pk = null)
 {
     $query = $this->_db->getQuery(true);
     // Delete from Media roomtype xref first
     // We delete manually instead of using ON DELETE CASCADE of Innodb table type
     // If has any relationship with RoomType, delete them all
     $query->clear();
     $query->delete()->from($this->_db->quoteName('#__sr_media_roomtype_xref'))->where('media_id = ' . $pk);
     $this->_db->setQuery($query);
     if (!$this->_db->execute()) {
         JError::raiseWarning(100, JText::sprintf('SolidresControllerMedia::delete ' . $this->_db->quoteName('#__sr_media_roomtype_xref') . ' failed', get_class($this), $this->_db->getErrorMsg()));
         return false;
     }
     // Delete the relationship with ReservationAsset first
     // We delete manually instead of using ON DELETE CASCADE of Innodb table type
     // If has any relationship with ReservationAsset, delete them all
     $query->clear();
     $query->delete()->from($this->_db->quoteName('#__sr_media_reservation_assets_xref'))->where('media_id = ' . $pk);
     $this->_db->setQuery($query);
     if (!$this->_db->execute()) {
         JError::raiseWarning(100, JText::sprintf('SolidresControllerMedia::delete from ' . $this->_db->quoteName('#__sr_media_reservation_assets_xref') . ' failed', get_class($this), $this->_db->getErrorMsg()));
         return false;
     }
     return parent::delete($pk);
 }
Exemplo n.º 9
0
 /**
  * Overrides Joomla's JTable delete method so that we can update the ordering
  * upon deleting
  * 
  * @return boolean true on success
  **/
 public function delete()
 {
     $db =& $this->getDBO();
     $query = "UPDATE " . $db->nameQuote('#__community_fields') . ' ' . 'SET ' . $db->nameQuote('ordering') . ' = (' . $db->nameQuote('ordering') . ' -1 ) ' . 'WHERE ' . $db->nameQuote('ordering') . '>' . $this->ordering;
     $db->setQuery($query);
     $db->query();
     return parent::delete();
 }
Exemplo n.º 10
0
 public function delete($pk = null)
 {
     if ($this->id) {
         // Delete Template
         // Delete Views
     }
     return parent::delete();
 }
Exemplo n.º 11
0
 public function delete($oid = null)
 {
     $result = parent::delete($oid);
     if ($result) {
         $this->_updateGroupStats();
     }
     return $result;
 }
Exemplo n.º 12
0
	/**
	 * Test for delete method with keys provided.
	 *
	 * @covers JTable::delete
	 *
	 * @return  void
	 *
	 * @since   12.3
	 */
	public function testDeleteKeysProvided()
	{
		$this->assertEquals(2, $this->getConnection()->getRowCount('jos_dbtest_composite'), "Pre-Condition");

		$this->object->delete(array('id1' => 25, 'id2' => 50));

		$this->assertEquals(1, $this->getConnection()->getRowCount('jos_dbtest_composite'), "Delete failed.");
	}
Exemplo n.º 13
0
 /**
  * Overloads the delete method to ensure we're not deleting the default profile
  *
  * @param int $id Optional; the record id
  */
 function delete($id = null)
 {
     if ($id == 1 || is_null($id) && $this->id == 1) {
         $this->setError(JText::_('TABLE_PROFILE_CANNOTDELETEDEFAULT'));
         return false;
     } else {
         return parent::delete($id);
     }
 }
Exemplo n.º 14
0
 public function delete($pk = null)
 {
     //Delete criterias first.
     $criterias = $this->getCriterias();
     foreach ($criterias as $criteria) {
         $criteria->delete();
     }
     return parent::delete();
 }
Exemplo n.º 15
0
 /**
  * Override the delete function as we need to delete the fields also
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		public
  * @param
  * @return
  * @since 		5.9.5
  */
 public function delete($pk = null)
 {
     if (parent::delete($pk)) {
         $query = $this->_db->getQuery(true)->delete($this->_db->qn('#__csvi_mapheaders'))->where($this->_db->qn('map_id') . '=' . $this->_db->q($pk));
         $this->_db->setQuery($query);
         $this->_db->execute();
         return true;
     }
 }
Exemplo n.º 16
0
 public function delete($pk = null)
 {
     $table = JTable::getInstance('Categories', 'DJMediatoolsTable');
     if (!empty($pk) && $table->load(array('parent_id' => $pk))) {
         JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_DJMEDIATOOLS_ALBUM_DELETE_FAILD_CONTAINS_SUBALBUMS', $pk), 'error');
         return false;
     }
     return parent::delete($pk);
 }
Exemplo n.º 17
0
 /**
  * Deletes a message.
  *
  * @param   integer  $pk  Primary key of the message to be deleted.
  *
  * @return  boolean  True on success, false on failure.
  *
  */
 public function delete($pk = null)
 {
     // Check if message has attachments
     if ($this->has_attachment) {
         if (!unlink(JPATH_COMPONENT . '/email/' . $this->attachment_name)) {
             JFactory::getApplication()->enqueueMessage(JText::_('COM_ISBNREGISTRY_ERROR_MESSAGE_DELETE_ATTACHMENT_FAILED'), 'warning');
         }
     }
     return parent::delete($pk);
 }
Exemplo n.º 18
0
	/**
	 * Overloads the delete method to ensure we're not deleting the default profile
	 *
	 * @param int $id Optional; the record id
	 */
	public function delete( $id=null )
	{
		if (($id==1) || ( is_null($id) && ($this->id == 1) ))
		{
			$this->setError(JText::_('TABLE_PROFILE_CANNOTDELETEDEFAULT'));
			return false;
		}
		else
		return parent::delete($id);
	}
Exemplo n.º 19
0
 /**
  * Delete the discussion
  * @param  [type] $oid [description]
  * @return [type]
  */
 public function delete($oid = null)
 {
     // Delete the stream related to the discussion replies
     CActivities::remove('groups.discussion.reply', $this->id);
     $result = parent::delete($oid);
     if ($result) {
         $this->_updateGroupStats();
     }
     return $result;
 }
Exemplo n.º 20
0
 public function delete($pk = null)
 {
     if ($pk) {
         $this->load($pk);
         $result = parent::delete($pk);
         if ($result) {
         }
         return $result;
     }
     return false;
 }
Exemplo n.º 21
0
 /**
  * Override parents delete method
  **/
 public function delete()
 {
     parent::delete();
     // @rule: Deleting a multiple profile should revert all users using it to the default profile
     $db =& JFactory::getDBO();
     $query = 'UPDATE #__community_users SET `profile_id`=' . $db->Quote(COMMUNITY_DEFAULT_PROFILE) . ' ' . 'WHERE `profile_id`=' . $db->Quote($this->id);
     $db->setQuery($query);
     $db->Query();
     // @rule: Delete all childs related to this multiprofile
     $this->deleteChilds();
 }
Exemplo n.º 22
0
 public function delete($pk = null)
 {
     $result = parent::delete($pk);
     if ($result) {
         $joomdoc = $this->_db->getTableColumns('#__joomdoc');
         if (isset($joomdoc['field' . $this->id])) {
             $this->_db->setQuery('ALTER TABLE #__joomdoc DROP field' . (int) $pk)->query();
             $this->_db->setQuery('ALTER TABLE #__joomdoc_flat DROP field' . (int) $pk)->query();
         }
     }
     return $result;
 }
Exemplo n.º 23
0
 public function delete($pk = null)
 {
     $k = $this->_tbl_key;
     $pk = is_null($pk) ? $this->{$k} : $pk;
     if (parent::delete($pk)) {
         $db = JFactory::getDbo();
         $query = "UPDATE #__judownload_documents SET license_id=0 WHERE license_id = {$pk}";
         $db->setQuery($query);
         $db->execute();
         return true;
     }
     return false;
 }
Exemplo n.º 24
0
 /**
  * Method to delete a row from the database table by primary key value.
  *
  * @param	mixed	An optional primary key value to delete.  If not set the
  *					instance property value is used.
  * @return	boolean	True on success.
  * @since	1.0
  * @link	http://docs.joomla.org/JTable/delete
  */
 public function delete($pk = null)
 {
     $query = $this->_db->getQuery(true);
     // Take care of relationshop with Reservation and Room
     $query->update($this->_db->quoteName('#__sr_reservation_room_extra_xref'))->set('extra_id = NULL')->where('extra_id = ' . $this->_db->quote($pk));
     $this->_db->setQuery($query)->execute();
     // Take care of relationship with Room Type
     $query->clear();
     $query->delete($this->_db->quoteName('#__sr_room_type_extra_xref'))->where('extra_id = ' . $this->_db->quote($pk));
     $this->_db->setQuery($query)->execute();
     // Delete itself
     return parent::delete($pk);
 }
Exemplo n.º 25
0
 public function delete($pk = null)
 {
     $k = $this->_tbl_key;
     $pk = is_null($pk) ? $this->{$k} : $pk;
     if (parent::delete($pk)) {
         $db = JFactory::getDbo();
         $query = "DELETE FROM #__judownload_moderators_xref WHERE mod_id=" . $db->quote($pk);
         $db->setQuery($query);
         $db->execute();
         return true;
     }
     return false;
 }
Exemplo n.º 26
0
 public function delete($pk = null)
 {
     $k = $this->_tbl_key;
     $pk = is_null($pk) ? $this->{$k} : $pk;
     if (parent::delete($pk)) {
         $db = JFactory::getDbo();
         $query = "DELETE FROM #__judownload_criterias_values WHERE criteria_id = {$pk}";
         $db->setQuery($query);
         $db->execute();
         return true;
     }
     return false;
 }
Exemplo n.º 27
0
 /**
  * Method to delete a row from the database table by primary key value.
  *
  * @param	mixed	An optional primary key value to delete.  If not set the
  *					instance property value is used.
  * @return	boolean	True on success.
  * @since	0.3.0
  * @link	http://docs.joomla.org/JTable/delete
  */
 public function delete($pk = null)
 {
     $query = $this->_db->getQuery(true);
     // Take care of left over in Reservation table
     $query->update($this->_db->quoteName('#__sr_reservations'))->set('coupon_id = NULL')->where('coupon_id = ' . $this->_db->quote($pk));
     $this->_db->setQuery($query)->execute();
     // Take care of left over in any relationships with Room Type
     $query->clear();
     $query->delete($this->_db->quoteName('#__sr_room_type_coupon_xref'))->where('coupon_id = ' . $this->_db->quote($pk));
     $this->_db->setQuery($query)->execute();
     // Delete it
     return parent::delete($pk);
 }
Exemplo n.º 28
0
 public function delete($pk = null, $children = false)
 {
     if ($pk) {
         $query = 'DELETE FROM #__tz_pinboard_categories' . ' WHERE catid = ' . $pk;
         $db = JFactory::getDbo();
         $db->setQuery($query);
         if (!$db->query()) {
             var_dump($db->getErrorMsg());
             return false;
         }
     }
     return parent::delete($pk, $children);
 }
Exemplo n.º 29
0
 public function delete($pk = null)
 {
     $k = $this->_tbl_key;
     $pk = is_null($pk) ? $this->{$k} : $pk;
     if (parent::delete($pk)) {
         $db = JFactory::getDbo();
         $query = "DELETE FROM #__judirectory_tags_xref WHERE tag_id = {$pk}";
         $db->setQuery($query);
         $db->execute();
         return true;
     }
     return false;
 }
Exemplo n.º 30
0
 /**
  * Method to delete a row from the database table by primary key value.
  *
  * @param	mixed	An optional primary key value to delete.  If not set the
  *					instance property value is used.
  * @return	boolean	True on success.
  * @since	1.0
  * @link	http://docs.joomla.org/JTable/delete
  */
 public function delete($pk = null)
 {
     $query = $this->_db->getQuery(true);
     // Take care of relationship with Reservation
     $query->update('#__sr_reservation_room_xref')->set('room_id = NULL')->where('room_id = ' . $this->_db->quote($pk));
     $this->_db->setQuery($query)->execute();
     // Take care of relationship with Extra in Reservation
     $query->clear();
     $query->update('#__sr_reservation_room_extra_xref')->set('room_id = NULL')->where('room_id = ' . $this->_db->quote($pk));
     $this->_db->setQuery($query)->execute();
     // Delete it
     return parent::delete($pk);
 }