public static function deleteArticle($id) { if (isset($id)) { $article = new Article($id); $article->delete(); } }
function delete($id = FALSE) { if ($id) { $article = new Article($id); $article->delete(); set_notify('success', lang('delete_data_complete')); } redirect('articles/admin/articles'); }
public function delete($f3, $param) { $table = $param['table']; $db_table_name = MyConst::$tables[$table]; if ($this->f3->exists('PARAMS.id')) { $article = new Article($this->db, MyConst::$tables[$table], MyConst::$cols[$table]); $article->delete($this->f3->get('PARAMS.id')); } $this->f3->reroute('/list/' . $param['table']); // echo Template::instance()->render('layout.htm'); }
public function testAdd() { // Build a request like it looks in Ext JS. $rawPostData = json_encode(array(array('action' => 'Article', 'method' => 'create', 'tid' => 1, 'type' => 'rpc', 'data' => array(array('data' => array('title' => 'Hello World', 'body' => 'foobar', 'published' => false, 'user_id' => 1)))))); $dispatcher = new BanchaDispatcher(); $responses = json_decode($dispatcher->dispatch(new BanchaRequestCollection($rawPostData), array('return' => true))); $this->assertNotNull($responses[0]->result->data->id); $this->assertEquals('Hello World', $responses[0]->result->data->title); $this->assertEquals(false, $responses[0]->result->data->published); $this->assertEquals(1, $responses[0]->result->data->user_id); // general response checks (check dispatcher, collections and transformers) $this->assertEquals('Article', $responses[0]->action); $this->assertEquals('create', $responses[0]->method); $this->assertEquals('rpc', $responses[0]->type); $this->assertEquals(1, $responses[0]->tid); $this->assertEquals(1, count($responses)); // Clean up operations: delete article $article = new Article(); $article->id = $responses[0]->result->data->id; $article->delete(); }
function test_article() { $article = new Article(9000001,9000002,9000003,9000004); // Test create $article->create("Unit Test Long Name", "Unit Test Short Name", "fastnews"); $this->assertTrue($article->exists()); // Test SET functions $article->setTitle("Unit Test New Title"); $article->setCreatorId(9000005); $article->setOnFrontPage(true); $article->setOnSection(true); $article->setWorkflowStatus('Y'); $article->setKeywords("Unit, Test"); $article->setIsIndexed(true); // Test GET functions $articleCopy = new Article(9000001, 9000002, 9000003, 9000004, $article->getArticleId()); $this->assertEquals(9000001, $articleCopy->getPublicationId()); $this->assertEquals(9000002, $articleCopy->getIssueNumber()); $this->assertEquals(9000003, $articleCopy->getSectionNumber()); $this->assertEquals(9000004, $articleCopy->getLanguageId()); $this->assertEquals(9000005, $articleCopy->getCreatorId()); $this->assertEquals("Unit Test New Title", $articleCopy->getTitle()); $this->assertEquals(true, $articleCopy->onFrontPage()); $this->assertEquals(true, $articleCopy->onSection()); $this->assertEquals('Y', $articleCopy->getWorkflowStatus()); $this->assertEquals("Unit, Test", $articleCopy->getKeywords()); $this->assertEquals(true, $articleCopy->isIndexed()); // Test DELETE functions $article->delete(); $this->assertFalse($article->exists()); }
/** * Delete the file, or an earlier version of it */ public function delete() { $file = $this->mPage->getFile(); if (!$file->exists() || !$file->isLocal() || $file->getRedirected()) { // Standard article deletion parent::delete(); return; } $deleter = new FileDeleteForm($file); $deleter->execute(); }
$returnJson['messages'][] = buildMessage('notAffected', $notAffectedNo, $errorMessage); return json_encode($returnJson); } switch ($f_action) { case 'delete': if (!$g_user->hasPermission('DeleteArticle')) { $success = false; $data->error = $translator->trans('You do not have the right to delete articles.', array(), 'library'); break; } $affectedArticles = 0; $notAffectedArticles = 0; foreach ($articleCodes as $articleCode) { $article = new Article($articleCode['language_id'], $articleCode['article_id']); $creatorId = $article->getCreatorId(); if ($article->delete()) { \Zend_Registry::get('container')->getService('dispatcher')->dispatch('user.set_points', new \Newscoop\EventDispatcher\Events\GenericEvent(null, array('user' => $creatorId))); $success = true; $affectedArticles += 1; } else { $notAffectedArticles += 1; } } $message = $translator->trans("\$1 articles have been removed", array('$1' => $affectedArticles), 'library'); $errorMessage = $translator->trans("\$1 articles have not been removed", array('$1' => $notAffectedArticles), 'library'); break; case "workflow_publish": if (!$g_user->hasPermission('Publish')) { $success = false; $data->error = $translator->trans('You do not have the right to change this article status. Once submitted an article can only be changed by authorized users.', array(), 'library'); break;
/** * Delete the file, or an earlier version of it */ public function delete() { global $wgUploadMaintenance; if ($wgUploadMaintenance && $this->mTitle && $this->mTitle->getNamespace() == NS_FILE) { global $wgOut; $wgOut->wrapWikiMsg("<div class='error'>\n\$1\n</div>\n", array('filedelete-maintenance')); return; } $this->loadFile(); if (!$this->img->exists() || !$this->img->isLocal() || $this->img->getRedirected()) { // Standard article deletion parent::delete(); return; } $deleter = new FileDeleteForm($this->img); $deleter->execute(); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy(Request $request, Article $article) { $article->delete(); if ($request->ajax() || $request->wantsJson()) { return new JsonResponse($article); } return redirect('article'); }
$articleObj->setWorkflowStatus('S'); } } camp_html_add_msg(getGS("Article status set to '\$1'", getGS("Submitted")), "ok"); break; case "workflow_publish": foreach ($articleCodes as $articleCode) { $articleObj = new Article($articleCode['language_id'], $articleCode['article_id']); $articleObj->setWorkflowStatus('Y'); } camp_html_add_msg(getGS("Article status set to '\$1'", getGS("Published")), "ok"); break; case "delete": foreach ($articleCodes as $articleCode) { $articleObj = new Article($articleCode['language_id'], $articleCode['article_id']); $articleObj->delete(); } if ($f_article_offset > 15 && count($articleCodes) + $f_article_offset == $f_total_articles) { $f_article_offset -= $ArticlesPerPage; } camp_html_add_msg(getGS("Article(s) deleted."), "ok"); break; case "toggle_front_page": foreach ($articleCodes as $articleCode) { $articleObj = new Article($articleCode['language_id'], $articleCode['article_id']); if ($articleObj->userCanModify($g_user)) { $articleObj->setOnFrontPage(!$articleObj->onFrontPage()); } } camp_html_add_msg(getGS("\$1 toggled.", """ . getGS("On Front Page") . """), "ok"); break;
function delete() { global $wgOut, $wgRequest, $wgUser; if (!$wgRequest->wasPosted()) { $wgOut->addHTML(wfMsg('mv_stream_delete_warrning', MV_Index::countMVDInRange($this->mvTitle->getStreamId()))); } //update text button to delete stream rather than delete stream parent::delete(); }
$issuePublishEvent->dumpToHtml(); echo "Executing pending events:<br>"; $events = IssuePublish::GetPendingActions(); foreach ($events as $event) { $event->doAction(); $event->dumpToHtml(); } // Check if issues are published echo "Is the issue published?<br>"; $issue->fetch(); $issue->dumpToHtml(); // Are the articles published? echo "Are the articles published?<br>"; $article1->fetch(); $article1->dumpToHtml(); $article2->fetch(); $article2->dumpToHtml(); echo "Number of remaining events (should be zero): ".count(IssuePublish::GetPendingActions())."<br>"; echo "Deleting objects.<br>"; $issue->delete(); $article1->delete(); $article2->delete(); $issuePublishEvent->delete(); echo "done.<br>"; ?>
<?php $delete = new Article($DB); //Die geholte imageID aus dem img via jQuery $id = htmlspecialchars($_POST['catchedID']); //$id als Parameter übergeben $q_result = $delete->delete($id);
/** * ensure that exists() does not persist between method calls reset on create * * @return void */ public function testResetOfExistsOnCreate() { $this->loadFixtures('Article'); $Article = new Article(); $Article->id = 1; $Article->saveField('title', 'Reset me'); $Article->delete(); $Article->id = 1; $this->assertFalse($Article->exists()); $Article->create(); $this->assertFalse($Article->exists()); $Article->id = 2; $Article->saveField('title', 'Staying alive'); $result = $Article->read(null, 2); $this->assertEquals('Staying alive', $result['Article']['title']); }
/** * Delete the file, or an earlier version of it */ public function delete() { if (!$this->img->exists() || !$this->img->isLocal()) { // Standard article deletion Article::delete(); return; } $deleter = new FileDeleteForm($this->img); $deleter->execute(); }
/** * testDeleteLinks method * * @access public * @return void */ function testDeleteLinks() { $this->loadFixtures('Article', 'ArticlesTag', 'Tag'); $TestModel = new Article(); $result = $TestModel->ArticlesTag->find('all'); $expected = array(array('ArticlesTag' => array('article_id' => '1', 'tag_id' => '1')), array('ArticlesTag' => array('article_id' => '1', 'tag_id' => '2')), array('ArticlesTag' => array('article_id' => '2', 'tag_id' => '1')), array('ArticlesTag' => array('article_id' => '2', 'tag_id' => '3'))); $this->assertEqual($result, $expected); $TestModel->delete(1); $result = $TestModel->ArticlesTag->find('all'); $expected = array(array('ArticlesTag' => array('article_id' => '2', 'tag_id' => '1')), array('ArticlesTag' => array('article_id' => '2', 'tag_id' => '3'))); $this->assertEqual($result, $expected); $result = $TestModel->deleteAll(array('Article.user_id' => 999)); $this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s'); }
public function delete($id) { try { $article = new Article($id); if (!UserHelper::isEditor()) { throw new fValidationException('not allowed'); } $article->delete(); $this->ajaxReturn(array('result' => 'success')); } catch (fException $e) { $this->ajaxReturn(array('result' => 'failure', 'message' => $e->getMessage())); } }
/** * This test ensures that multiple requests, which are sent with multiple requests are executed in the correct order. * Thus it ensures that a request with a higher transaction ID is not executed before a request with a lower TID. * */ public function testEditEditMultipleRequests() { $this->markTestSkipped("Consistancy is not yet implemented."); // Preparation: create article $article = new Article(); $article->create(); $article->save(array('title' => 'foo')); // Execute two requests in parallel. $clientId = uniqid(); // The syntax of the fake_request script is // php _fake_request.php client_id article_id tid new_title sleep_time // These processes are executed in the background and we do not need the output. exec('php ' . dirname(__FILE__) . '/_fake_request.php ' . $clientId . ' ' . $article->id . ' 1 foobar 5 ' . '>/dev/null &'); sleep(3); exec('php ' . dirname(__FILE__) . '/_fake_request.php ' . $clientId . ' ' . $article->id . ' 2 barfoo 0 ' . ' >/dev/null &'); // Wait some seconds until the backround process are executed. sleep(8); // Read article from database and check if the value is correct. $data = $article->read(null, $article->id); $this->assertEquals('foobar', $data['Article']['title']); // Clean up operations: delete article $article->delete(); }
/** * testDeleteDependent method * * @return void */ public function testDeleteDependent() { $this->loadFixtures('Bidding', 'BiddingMessage', 'Article', 'ArticlesTag', 'Comment', 'User', 'Attachment'); $Bidding = new Bidding(); $result = $Bidding->find('all', array('order' => array('Bidding.id' => 'ASC'))); $expected = array(array('Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'), 'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1')), array('Bidding' => array('id' => 2, 'bid' => 'Two', 'name' => 'Bid 2'), 'BiddingMessage' => array('bidding' => 'Two', 'name' => 'Message 2')), array('Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'), 'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3')), array('Bidding' => array('id' => 4, 'bid' => 'Five', 'name' => 'Bid 5'), 'BiddingMessage' => array('bidding' => '', 'name' => ''))); $this->assertEquals($expected, $result); $Bidding->delete(4, true); $result = $Bidding->find('all', array('order' => array('Bidding.id' => 'ASC'))); $expected = array(array('Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'), 'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1')), array('Bidding' => array('id' => 2, 'bid' => 'Two', 'name' => 'Bid 2'), 'BiddingMessage' => array('bidding' => 'Two', 'name' => 'Message 2')), array('Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'), 'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3'))); $this->assertEquals($expected, $result); $Bidding->delete(2, true); $result = $Bidding->find('all', array('order' => array('Bidding.id' => 'ASC'))); $expected = array(array('Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'), 'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1')), array('Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'), 'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3'))); $this->assertEquals($expected, $result); $result = $Bidding->BiddingMessage->find('all', array('order' => array('BiddingMessage.name' => 'ASC'))); $expected = array(array('BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1'), 'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1')), array('BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3'), 'Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3')), array('BiddingMessage' => array('bidding' => 'Four', 'name' => 'Message 4'), 'Bidding' => array('id' => '', 'bid' => '', 'name' => ''))); $this->assertEquals($expected, $result); $Article = new Article(); $result = $Article->Comment->find('count', array('conditions' => array('Comment.article_id' => 1))); $this->assertEquals(4, $result); $result = $Article->delete(1, true); $this->assertSame($result, true); $result = $Article->Comment->find('count', array('conditions' => array('Comment.article_id' => 1))); $this->assertEquals(0, $result); }
/** * test that a plugin model as the 'with' model doesn't have issues * * @return void */ public function testDeleteLinksWithPLuginJoinModel() { $this->loadFixtures('Article', 'ArticlesTag', 'Tag'); $Article = new Article(); $Article->unbindModel(array('hasAndBelongsToMany' => array('Tag')), false); unset($Article->Tag, $Article->ArticleTags); $Article->bindModel(array('hasAndBelongsToMany' => array('Tag' => array('with' => 'TestPlugin.ArticlesTag'))), false); $this->assertTrue($Article->delete(1)); }
/** * Test nested transaction * * @return void */ public function testNestedTransaction() { $this->Dbo->useNestedTransactions = true; $this->skipIf($this->Dbo->nestedTransactionSupported() === false, 'The Postgres server do not support nested transaction'); $this->loadFixtures('Article'); $model = new Article(); $model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = array(); $model->cacheQueries = false; $this->Dbo->cacheMethods = false; $this->assertTrue($this->Dbo->begin()); $this->assertNotEmpty($model->read(null, 1)); $this->assertTrue($this->Dbo->begin()); $this->assertTrue($model->delete(1)); $this->assertEmpty($model->read(null, 1)); $this->assertTrue($this->Dbo->rollback()); $this->assertNotEmpty($model->read(null, 1)); $this->assertTrue($this->Dbo->begin()); $this->assertTrue($model->delete(1)); $this->assertEmpty($model->read(null, 1)); $this->assertTrue($this->Dbo->commit()); $this->assertEmpty($model->read(null, 1)); $this->assertTrue($this->Dbo->rollback()); $this->assertNotEmpty($model->read(null, 1)); }
if (getUser()->getRank() < RANK_WRITER) { header("Location: " . orongoURL("orongo-admin/index.php?msg=0")); exit; } try { $article = new Article($id); } catch (Exception $e) { if ($e->getCode() == ARTICLE_NOT_EXIST) { header("Location: " . orongoURL("orongo-admin/manage.php?msg=0&obj=articles")); exit; } else { header("Location: " . orongoURL("orongo-admin/index.php?msg=2")); exit; } } $article->delete(); header("Location: " . orongoURL("orongo-admin/manage.php?msg=1&obj=articles")); break; case "user": if (getUser()->getRank() < RANK_ADMIN) { header("Location: " . orongoURL("orongo-admin/index.php?msg=0")); exit; } try { $user = new User($id); } catch (Exception $e) { if ($e->getCode() == USER_NOT_EXIST) { header("Location: " . orongoURL("orongo-admin/manage.php?msg=0&obj=users")); exit; } else { header("Location: " . orongoURL("orongo-admin/index.php?msg=2"));