示例#1
0
 public function postUpdate()
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     $process = false;
     if (in_array('claro_forum_subject_temp', $this->conn->getSchemaManager()->listTableNames())) {
         $columns = $this->conn->getSchemaManager()->listTableColumns('claro_forum_subject_temp');
         foreach ($columns as $column) {
             if ($column->getName() === 'forum_id') {
                 $process = true;
                 break;
             }
         }
     }
     if ($process) {
         $this->log('restoring the subjects...');
         $forums = $em->getRepository('ClarolineForumBundle:Forum')->findAll();
         $sql = 'SELECT * FROM claro_forum_subject_temp WHERE forum_id = :forumId';
         $stmt = $this->conn->prepare($sql);
         foreach ($forums as $forum) {
             $category = new Category();
             $category->setName($forum->getResourceNode()->getName());
             $category->setForum($forum);
             $em->persist($category);
             $em->flush();
             $stmt->bindValue('forumId', $forum->getId());
             $stmt->execute();
             foreach ($stmt->fetchAll() as $rowsSubject) {
                 $this->conn->query("INSERT INTO claro_forum_subject VALUES (\n                        {$rowsSubject['id']},\n                        {$category->getId()},\n                        {$rowsSubject['user_id']},\n                        {$this->conn->quote($rowsSubject['title'])},\n                        '{$rowsSubject['created']}',\n                        '{$rowsSubject['updated']}',\n                        false\n                    )");
             }
         }
         $this->log('restoring the messages...');
         $this->conn->query('INSERT IGNORE INTO claro_forum_message SELECT * FROM claro_forum_message_temp');
         $this->conn->query('DROP TABLE claro_forum_message_temp');
         $this->conn->query('DROP TABLE claro_forum_subject_temp');
         $this->conn->query('DROP TABLE claro_forum_options');
     } else {
         $this->log('categories already added');
     }
     $widget = $em->getRepository('ClarolineCoreBundle:Widget\\Widget')->findBy(array('name' => 'claroline_forum_widget'));
     if (!$widget) {
         $this->log('adding the forum widget...');
         $plugin = $em->getRepository('ClarolineCoreBundle:Plugin')->findOneBy(array('vendorName' => 'Claroline', 'bundleName' => 'ForumBundle'));
         $widget = new Widget();
         $widget->setName('claroline_forum_widget');
         $widget->setDisplayableInDesktop(true);
         $widget->setDisplayableInWorkspace(true);
         $widget->setConfigurable(false);
         $widget->setExportable(false);
         $widget->setIcon('none');
         $widget->setPlugin($plugin);
         $em->persist($widget);
         $plugin->setHasOptions(true);
         $em->persist($widget);
         $em->flush();
     } else {
         $this->log('forum widget already added');
     }
 }
示例#2
0
 private function createWorkspaceListWidget()
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     try {
         $workspaceWidget = $em->getRepository('ClarolineCoreBundle:Widget\\Widget')->findOneByName('my_workspaces');
         if (is_null($workspaceWidget)) {
             $this->log('Creating workspace list widget...');
             $widget = new Widget();
             $widget->setName('my_workspaces');
             $widget->setConfigurable(false);
             $widget->setIcon('fake/icon/path');
             $widget->setPlugin(null);
             $widget->setExportable(false);
             $widget->setDisplayableInDesktop(true);
             $widget->setDisplayableInWorkspace(false);
             $em->persist($widget);
             $em->flush();
         }
     } catch (MappingException $e) {
         $this->log('A MappingException has been thrown while trying to get Widget repository');
     }
 }
 protected static function createWidget($name, $configurable, $exportable, $icon)
 {
     $widget = new Widget();
     $widget->setName($name);
     $widget->setConfigurable($configurable);
     $widget->setExportable($exportable);
     $widget->setIcon($icon);
     self::create($name, $widget);
     self::$om->flush();
 }
示例#4
0
 private function addAgendaWidget()
 {
     $existingWidget = $this->om->getRepository('ClarolineCoreBundle:Widget\\Widget')->findOneByName('agenda');
     if (!$existingWidget) {
         $newWidget = new Widget();
         $newWidget->setName('agenda');
         $newWidget->setConfigurable(false);
         $newWidget->setIcon('fake/icon/path');
         $newWidget->setPlugin(null);
         $newWidget->setExportable(false);
         $newWidget->setDisplayableInDesktop(true);
         $newWidget->setDisplayableInWorkspace(true);
         $this->om->persist($newWidget);
         $this->log("'agenda' widget added.");
     } else {
         $this->log("The 'agenda' widget already exists");
     }
     $this->om->flush();
 }