AddSubTopicController.inc 730 B

12345678910111213141516171819
  1. <?php
  2. class AddSubTopicController implements IController {
  3. public function execute() {
  4. //TODO: only admin, owner, moderator can see this page
  5. $form = new Form();
  6. $topicId = $form->getCleanDefaulted('id', 0);
  7. $topicName = $form->postCleanDefaulted('addSubtopic', "");
  8. $topicModel = new TopicModel();
  9. $subscribingTopicId = $topicModel->getIdForTopicName($topicName);
  10. if($subscribingTopicId != 0 && $subscribingTopicId != $topicId) {
  11. $sql = sprintf("INSERT INTO topic_topic_associations (topic_id, subtopic_id) VALUES (%s, %s)", $topicId, $subscribingTopicId);
  12. $database = new Database();
  13. $database->write($sql);
  14. }
  15. $header = new Header();
  16. $header->redirect('?a=topicmanagement&id=' . $topicId);
  17. }
  18. }