public function delete() { $db =& JFactory::getDBO(); $query = 'DELETE FROM ' . $db->nameQuote('#__community_users') . ' ' . 'WHERE ' . $db->nameQuote('userid') . '=' . $db->Quote($this->id); $db->setQuery($query); $db->query(); return parent::delete(); }
/** * run from table model when deleting rows * * @return bol */ function onDeleteRowsForm(&$params, &$formModel, &$groups) { if ($params->get('juser_field_userid') != '' && $params->get('juser_delete_user', false)) { $useridfield = $this->getFieldName($params, 'juser_field_userid'); $useridfield .= '_raw'; foreach ($groups as $group) { foreach ($group as $rows) { foreach ($rows as $row) { if (isset($row->{$useridfield})) { if (!empty($row->{$useridfield})) { $user = new JUser((int) $row->{$useridfield}); // Bail out now and return false, or just carry on? if (!$user->delete()) { JError::raiseWarning(500, 'Unable to delete user id ' . $row->{$useridfield}); } } } } } } } return true; }
/** * Testing creation and deletion of users * * @return void */ public function testCreateDeleteUser() { include_once JPATH_BASE . '/libraries/joomla/event/dispatcher.php'; include_once JPATH_BASE . '/libraries/joomla/plugin/helper.php'; include_once JPATH_BASE . '/libraries/joomla/application/application.php'; //JFactory::getApplication('site'); $mockSession = $this->getMock('JSession', array('_start', 'get')); $mockSession->expects($this->any()) ->method('get') ->will($this->returnValue($this->object) ); JFactory::$session = $mockSession; $testUser = new JUser(); $testUser->name = "Floyd Smoot"; $testUser->username = "******"; $this->assertThat( $testUser->id, $this->equalTo(0), "Newly created id should be zero" ); $this->assertThat( $testUser->save(), $this->isFalse(), 'Cannot save without valid email' ); $this->assertThat( $testUser->getErrors(), $this->equalTo( array('JLIB_DATABASE_ERROR_VALID_MAIL') ), 'Should have caused valid email error' ); $testUser->email = "*****@*****.**"; //TODO: Fix this assertion $this->assertThat( $testUser->save(true), // Should be false $this->isTrue(), 'Line: ' . __LINE__ . ' Should not create new user when update only flag is set' ); //TODO: Fix this assertion $this->assertThat( $testUser->save(), // Should be true $this->isFalse(), 'Line: ' . __LINE__ . ' Should save the user successfully' ); $this->assertThat( $testUser->id, $this->greaterThan(0), 'Line: ' . __LINE__ . " Newly saved id should not be zero" ); $testUser->email = "*****@*****.**"; //TODO: Fix this assertion $this->assertThat( $testUser->save(), // Should be true $this->isFalse(), 'Line: ' . __LINE__ . ' Should update existing user.' ); $testUser1 = JUser::getInstance('Floyd'); $this->assertThat( $testUser1->id, $this->equalTo($testUser1->id), 'Line: ' . __LINE__ . " Id's should be the same" ); $this->assertThat( $testUser->delete(), $this->isTrue(), 'Line: ' . __LINE__ . ' Delete should succeed' ); $testUser2 = JUser::getInstance('Floyd'); $this->assertThat( $testUser2, $this->isFalse(), 'Line: ' . __LINE__ . " Id should not be found" ); }
function delete() { $cids = JRequest::getVar('cid', array(0), 'post', 'array'); $item = $this->getTable('Customer'); foreach ($cids as $cid) { if (!$item->delete($cid)) { $this->setError($item->getErrorMsg()); return false; } } jimport("joomla.database.table.user"); $db = JFactory::getDBO(); $user = new JUser(); foreach ($cids as $cid) { if (!$user->delete($cid)) { $this->setError($item->getErrorMsg()); return false; } } return true; }
/** * Override parent's delete implementation if necessary. * * @since 1.0 * @access public * @param null * @return bool The delete state. True on success, false otherwise. */ public function delete() { $state = parent::delete(); // Once the user is deleted, we also need to delete it from the #__social_users table. if ($state) { // Perform cleanup here. $model = FD::model('Users'); $model->delete($this->id); } return $state; }
/** * Override parent's delete implementation if necessary. * * @since 1.0 * @access public * @param null * @return bool The delete state. True on success, false otherwise. */ public function delete() { $state = parent::delete(); // Once the user is deleted, we also need to delete it from the #__social_users table. if ($state) { $model = FD::model('Users'); $model->delete($this->id); JPluginHelper::importPlugin('finder'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onFinderAfterDelete', array('easysocial.users', $this)); } return $state; }
/** * Run from list model when deleting rows * * @param array &$groups List data for deletion * * @return bool */ public function onDeleteRowsForm(&$groups) { $params = $this->getParams(); if ($params->get('juser_field_userid') != '' && $params->get('juser_delete_user', false)) { $userIdField = $this->getFieldName('juser_field_userid'); $userIdField .= '_raw'; foreach ($groups as $group) { foreach ($group as $rows) { foreach ($rows as $row) { if (isset($row->{$userIdField})) { if (!empty($row->{$userIdField})) { $user = new JUser((int) $row->{$userIdField}); // Bail out now and return false, or just carry on? if (!$user->delete()) { $this->app->enqueueMessage('Unable to delete user id ' . $row->{$userIdField}, 'error'); } } } } } } } return true; }