当前位置: 首页>>代码示例>>PHP>>正文


PHP Topic::delete方法代码示例

本文整理汇总了PHP中Topic::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Topic::delete方法的具体用法?PHP Topic::delete怎么用?PHP Topic::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Topic的用法示例。


在下文中一共展示了Topic::delete方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deletetopic

function deletetopic()
{
	global $CONF;
	$user = $_SESSION['user'];

	if (!isset($_GET['topicid_deletetopic']) || empty($_GET['topicid_deletetopic']))
		return array('ok'=>'false','error'=>'no id');
	elseif ($user->isAnon())
		return array('ok'=>false,'error'=>'anon cannot delete topic');
	else {

		$topic = new Topic();
		$topic->setId($_GET['topicid_deletetopic']);
		$topic->load();
		if (
		    (!$topic->getUser()->isAnon() && $topic->getUser()->getId() == $user->getId()) ||
		    ($topic->getChannel()->getUser()->getId() == $user->getId())
		   )
		{
			$topic->delete();
			return array('ok'=>true,'error'=>'');
		}
		return array('ok'=>false,'error'=>'you cannot delete this topic');
	}
}
开发者ID:rczeus,项目名称:Rapid-Coffee,代码行数:25,代码来源:deletetopic.php

示例2: edit

 public function edit($id = 0)
 {
     $obj = new Topic();
     $obj->get_by_id((int) $id);
     if (!$_POST) {
         echo $obj->to_json();
     } else {
         if (isset($_POST['model']) and $model = $_POST['model']) {
             $testid = $this->session->userdata('testid');
             $topic = new Topic();
             $topic->from_json($model);
             $topic->test_id = $testid;
             if ($topic->save()) {
                 echo $topic->to_json();
             } else {
                 echo array('error' => $test->error->string);
             }
         } else {
             if (isset($_POST['_method']) and $_POST['_method'] === 'DELETE') {
                 $obj->delete();
             }
         }
     }
 }
开发者ID:htom78,项目名称:peersay,代码行数:24,代码来源:topics.php

示例3: Topic

        $id = $_GET['id'];
        $manager = new Topic($link);
        $message = $manager->selectById($id);
        $topic = $message->getTopic();
        $categorie = $topic->getCategory();
        $categoryName = $topic->getCategory()->getCategory();
        $topicName = urlencode($topic->getTitre());
    }
    //Mise à jour d'un message
    if (isset($_POST['update'], $_POST['contenu'])) {
        try {
            $message->setContenu($_POST['contenu']);
        } catch (Exception $e) {
            $error = $e->getMessage();
        }
        if (empty($error)) {
            $topic->update($message);
            // /!\ header('Location : ');
            exit;
        }
    } elseif (isset($_POST['delete'])) {
        $manager->delete($id);
        header('Location: ' . str_replace('index.php', '', $_SERVER['SCRIPT_NAME']) . 'home/' . $categoryName . '/' . $topicName);
        exit;
    } elseif (isset($_POST['signalement'])) {
        $message->signalement();
        $topic->update($message);
        header('Location: ' . str_replace('index.php', '', $_SERVER['SCRIPT_NAME']) . 'home/' . $categoryName . '/' . $topicName);
        exit;
    }
}
开发者ID:jmgerber,项目名称:forum,代码行数:31,代码来源:traitement-messages.php

示例4: delete

 function delete($id)
 {
     $topic = new Topic($id);
     $question = new Questionaire();
     $answer = new Answer();
     $answer->where_related('questionaire', 'topic_id', $id)->get()->delete_all();
     $choice = new Choice();
     $choice->where_related('questionaire', 'topic_id', $id)->get()->delete_all();
     $question->where('topic_id', $id)->get()->delete_all();
     $topic->delete();
     set_notify('success', 'ลบข้อมูลเรียบร้อยแล้วค่ะ');
     redirect($_SERVER['HTTP_REFERER']);
 }
开发者ID:unisexx,项目名称:thaigcd2015,代码行数:13,代码来源:docs.php

示例5: camp_html_breadcrumbs

if ($f_confirmed == 1) {
    // get a list of subtopics
    $deleteTopics = $deleteTopic->getSubtopics();
    // detach all subtopics from all articles
    foreach ($deleteTopics as $topic) {
        ArticleTopic::RemoveTopicFromArticles($topic->getTopicId());
    }
    // delete all subtopics
    foreach ($deleteTopics as $topic) {
        $topic->delete($f_topic_language_id);
    }
    $doDelete = true;
}
if ($doDelete) {
    ArticleTopic::RemoveTopicFromArticles($deleteTopic->getTopicId());
    $deleted = $deleteTopic->delete($f_topic_language_id);
    if ($deleted) {
        camp_html_add_msg(getGS("Topic was deleted."), "ok");
        camp_html_goto_page("/{$ADMIN}/topics/index.php");
    } else {
        $errorMsgs[] = getGS('The topic $1 could not be deleted.', '<B>' . $deleteTopic->getName($f_topic_language_id) . '</B>');
    }
}
$crumbs = array();
$crumbs[] = array(getGS("Configure"), "");
$crumbs[] = array(getGS("Topics"), "/{$ADMIN}/topics/");
$crumbs[] = array(getGS("Deleting topic"), "");
echo camp_html_breadcrumbs($crumbs);
?>

<P>
开发者ID:nidzix,项目名称:Newscoop,代码行数:31,代码来源:do_del.php

示例6: testCreate


//.........这里部分代码省略.........
		$this->assertEquals($subtopicsDepth1, $topic->getSubtopics());
		$this->assertEquals($subtopicsDepth1Ids, $topic->getSubtopics(true));
		$subtopicsDepth2 = array(new Topic(26), new Topic(15), new Topic(25), new Topic(24),
		new Topic(14), new Topic(22), new Topic(19), new Topic(16));
		$this->assertEquals($subtopicsDepth2, $topic->getSubtopics(false, 2));
		$subtopicsAll = array(new Topic(26), new Topic(15), new Topic(25), new Topic(24),
		new Topic(14), new Topic(22), new Topic(19), new Topic(16), new Topic(18), new Topic(17));
		$this->assertEquals($subtopicsAll, $topic->getSubtopics(false, 0));

		$topics = array(new Topic(2));
		$this->assertEquals($topics, Topic::GetTopics(2));
		$this->assertEquals($topics, Topic::GetTopics(null, 1, 'Education'));
		$this->assertEquals($subtopicsDepth1, Topic::GetTopics(null, null, null, 2));
		$this->assertEquals($subtopicsAll, Topic::GetTopics(null, null, null, 2, 0));
		$subtopicsDepth1Name = array(new Topic(14), new Topic(26), new Topic(15));
		$this->assertEquals($subtopicsDepth1Name, Topic::GetTopics(null, 1, null, 2, 1,
		null, array(array('field'=>'byname', 'dir'=>'asc'))));

		$tree = array(
		array(27=>new Topic(27)),
		array(2=>new Topic(2)),
		array(2=>new Topic(2), 26=>new Topic(26)),
		array(2=>new Topic(2), 15=>new Topic(15)),
		array(2=>new Topic(2), 15=>new Topic(15), 25=>new Topic(25)),
		array(2=>new Topic(2), 15=>new Topic(15), 24=>new Topic(24)),
		array(2=>new Topic(2), 14=>new Topic(14)),
		array(2=>new Topic(2), 14=>new Topic(14), 22=>new Topic(22)),
		array(2=>new Topic(2), 14=>new Topic(14), 19=>new Topic(19)),
		array(2=>new Topic(2), 14=>new Topic(14), 16=>new Topic(16)),
		array(2=>new Topic(2), 14=>new Topic(14), 16=>new Topic(16), 18=>new Topic(18)),
		array(2=>new Topic(2), 14=>new Topic(14), 16=>new Topic(16), 17=>new Topic(17)),
		array(3=>new Topic(3)),
		array(3=>new Topic(3), 9=>new Topic(9)),
		array(3=>new Topic(3), 4=>new Topic(4)),
		array(1=>new Topic(1))
		);
		$this->assertEquals($tree, Topic::GetTree());
		$subtree = array(
		array(26=>new Topic(26)),
		array(15=>new Topic(15)),
		array(15=>new Topic(15), 25=>new Topic(25)),
		array(15=>new Topic(15), 24=>new Topic(24)),
		array(14=>new Topic(14)),
		array(14=>new Topic(14), 22=>new Topic(22)),
		array(14=>new Topic(14), 19=>new Topic(19)),
		array(14=>new Topic(14), 16=>new Topic(16)),
		array(14=>new Topic(14), 16=>new Topic(16), 18=>new Topic(18)),
		array(14=>new Topic(14), 16=>new Topic(16), 17=>new Topic(17))
		);
		$this->assertEquals($subtree, Topic::GetTree(2));
		$subtree = array(
		array(22=>new Topic(22)),
		array(19=>new Topic(19)),
		array(16=>new Topic(16)),
		array(16=>new Topic(16), 18=>new Topic(18)),
		array(16=>new Topic(16), 17=>new Topic(17))
		);
		$this->assertEquals($subtree, Topic::GetTree(14));

		Topic::UpdateOrder(array('topic_2'=>array('topic_26', 'topic_14', 'topic_15')));
		$topic = new Topic(14);
		$this->assertEquals(6, $topic->getLeft());
		$this->assertEquals(17, $topic->getRight());
		$topic = new Topic(15);
		$this->assertEquals(18, $topic->getLeft());
		$this->assertEquals(23, $topic->getRight());
		$topic = new Topic(16);
		$this->assertEquals(11, $topic->getLeft());
		$this->assertEquals(16, $topic->getRight());
		Topic::UpdateOrder(array('topic_0'=>array('topic_27', 'topic_3', 'topic_2', 'topic_1')));
		$topic = new Topic(3);
		$this->assertEquals(3, $topic->getLeft());
		$this->assertEquals(8, $topic->getRight());
		$topic = new Topic(2);
		$this->assertEquals(9, $topic->getLeft());
		$this->assertEquals(30, $topic->getRight());
		$topic = new Topic(16);
		$this->assertEquals(17, $topic->getLeft());
		$this->assertEquals(22, $topic->getRight());

		// test setName()
		$topic->setName(1, 'My Music');
		$topic = new Topic(16);
		$this->assertEquals('My Music', $topic->getName(1));

		// test delete()
		$topic->delete(2);
		$this->assertEquals('My Music', $topic->getName(1));
		$this->assertEquals(1, $topic->getNumTranslations());
		$topic->delete();
		$topic = new Topic(15);
		$this->assertEquals(18, $topic->getLeft());
		$this->assertEquals(23, $topic->getRight());
		$topic = new Topic(1);
		$this->assertEquals(25, $topic->getLeft());
		$this->assertEquals(26, $topic->getRight());
		$topic = new Topic(14);
		$subtopics = array(22, 19);
		$this->assertEquals($subtopics, $topic->getSubtopics(true));
	} // fn testCreate
开发者ID:nistormihai,项目名称:Newscoop,代码行数:101,代码来源:TopicTest.php

示例7: destroy_topic

 public function destroy_topic()
 {
     if (!isset($_POST['topic_id'])) {
         error(__("Error"), __("No topic ID specified.", "discuss"));
     }
     $topic = new Topic($_POST['topic_id']);
     if ($topic->no_results) {
         error(__("Error"), __("Invalid topic ID specified.", "discuss"));
     }
     if (!$topic->deletable()) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to delete this topic.", "discuss"));
     }
     Topic::delete($topic->id);
     Flash::notice(__("Topic deleted.", "discuss"), $topic->forum->url());
 }
开发者ID:vito,项目名称:chyrp-site,代码行数:15,代码来源:controller.Discuss.php

示例8: newTopic

 /**
  * Crée un nouveau topic dans le forum désiré
  *
  * @param $slug Slug du forum dans lequel sera le topic
  * @param $id Id du forum dans lequel sera le topic
  */
 public function newTopic($slug, $id)
 {
     $user = Auth::user();
     $forum = Forum::find($id);
     $category = $forum->getCategory();
     $parsedContent = null;
     // L'utilisateur possède le droit de crée un topic ici
     if ($category->getPermission()->start_topic != true) {
         return Redirect::route('forum_index')->with('message', 'You can\'t start a new topic here');
     }
     // Prévisualisation du post
     if (Request::getMethod() == 'POST' && Input::get('preview') == true) {
         $code = new Decoda\Decoda(Input::get('content'));
         $code->defaults();
         $parsedContent = $code->parse();
     }
     if (Request::getMethod() == 'POST' && Input::get('post') == true) {
         // Crée le topic
         $topic = new Topic();
         $topic->name = Input::get('title');
         $topic->slug = Str::slug(Input::get('title'));
         $topic->state = 'open';
         $topic->first_post_user_id = $topic->last_post_user_id = $user->id;
         $topic->first_post_user_username = $topic->last_post_user_username = $user->username;
         $topic->views = 0;
         $topic->pinned = false;
         $topic->forum_id = $forum->id;
         $v = Validator::make($topic->toArray(), $topic->rules);
         if ($v->passes()) {
             $topic->save();
             $post = new Post();
             $post->content = Input::get('content');
             $post->user_id = $user->id;
             $post->topic_id = $topic->id;
             $v = Validator::make($post->toArray(), $post->rules);
             if ($v->passes()) {
                 $post->save();
                 $topic->num_post = 1;
                 $topic->save();
                 $forum->num_topic = $forum->getTopicCount($forum->id);
                 $forum->num_post = $forum->getPostCount($forum->id);
                 $forum->last_topic_id = $topic->id;
                 $forum->last_topic_name = $topic->name;
                 $forum->last_topic_slug = $topic->slug;
                 $forum->last_post_user_id = $user->id;
                 $forum->last_post_user_username = $user->username;
                 $forum->save();
                 return Redirect::route('forum_topic', array('slug' => $topic->slug, 'id' => $topic->id));
             } else {
                 // Impoossible de save le premier post donc delete le topic
                 $topic->delete();
             }
         } else {
             Session::put('message', 'An error has occurred with this topic. Try again.');
         }
     }
     return View::make('forum.new_topic', array('forum' => $forum, 'category' => $category, 'parsedContent' => $parsedContent, 'title' => Input::get('title'), 'content' => Input::get('content')));
 }
开发者ID:raphaeljorge,项目名称:tor,代码行数:64,代码来源:ForumController.php

示例9: Topic

 function test_delete()
 {
     $name = "Writing";
     $test_topic = new Topic($name);
     $test_topic->save();
     $name2 = "Interview";
     $test_topic2 = new Topic($name2);
     $test_topic2->save();
     $test_topic->delete();
     $result = Topic::getAll();
     $this->assertEquals([$test_topic2], $result);
 }
开发者ID:umamiMike,项目名称:promptr,代码行数:12,代码来源:TopicTest.php

示例10: actionAdmin

 /**
  * Topics administration
  */
 public function actionAdmin()
 {
     $this->layout = 'admin';
     $data = array();
     // delete request
     if (Rays::app()->request()->isPostRequest()) {
         if (isset($_POST['checked_topics'])) {
             $checkedTopics = $_POST['checked_topics'];
             foreach ($checkedTopics as $item) {
                 if (!is_numeric($item)) {
                     return;
                 } else {
                     $topic = new Topic();
                     $topic->id = $item;
                     $topic->delete();
                 }
             }
         }
     }
     $curPage = $this->getPage("page");
     $pageSize = $this->getPageSize("pagesize");
     $count = Topic::find()->count();
     $data['count'] = $count;
     $query = Topic::find()->join("user")->join("group")->join("rating")->join("counter");
     $orderBy = Rays::getParam("orderBy", "id");
     $order = Rays::getParam("order", "desc");
     switch ($orderBy) {
         case "id":
             $query = $query->order($order, "[Topic.id]");
             break;
         case "likes":
             $query = $query->order($order, "[RatingStatistic.value]");
             break;
         case "views":
             $query = $query->order($order, "[Counter.totalCount]");
             break;
         case "createTime":
             $query = $query->order($order, "[Topic.id]");
             break;
         default:
             $query = $query->order_desc("id");
     }
     $posts = $query->range(($curPage - 1) * $pageSize, $pageSize);
     $data['topics'] = $posts;
     $pager = new RPager('page', $count, $pageSize, RHtml::siteUrl("post/admin?orderBy={$orderBy}&&order={$order}"), $curPage);
     $pager = $pager->showPager();
     $data['pager'] = $pager;
     $this->render('admin', $data, false);
 }
开发者ID:a4501150,项目名称:FDUGroup,代码行数:52,代码来源:PostController.php


注:本文中的Topic::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。