示例#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 createResourcesWidget()
 {
     $this->log('Creating resources_widget widget...');
     $roles = $this->om->getRepository('ClarolineCoreBundle:Role')->findAllPlatformRoles();
     $widget = new Widget();
     $widget->setName('resources_widget');
     $widget->setConfigurable(true);
     $widget->setPlugin(null);
     $widget->setExportable(false);
     $widget->setDisplayableInDesktop(true);
     $widget->setDisplayableInWorkspace(true);
     foreach ($roles as $role) {
         $widget->addRole($role);
     }
     $this->om->persist($widget);
     $this->om->flush();
 }
示例#3
0
 /**
  * Loads the core widgets.
  *
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $roles = $manager->getRepository('ClarolineCoreBundle:Role')->findAllPlatformRoles();
     //name, isConfigurable, isDisplayableInDesktop, isDisplayableInWorkspace
     $items = [['core_resource_logger', true, true, true], ['simple_text', true, true, true], ['my_workspaces', false, true, false], ['my_profile', false, true, false], ['resources_widget', true, true, true]];
     foreach ($items as $item) {
         $widget = new Widget();
         $widget->setName($item[0]);
         $widget->setConfigurable($item[1]);
         $widget->setPlugin(null);
         $widget->setExportable(false);
         $widget->setIsDisplayableInDesktop($item[2]);
         $widget->setIsDisplayableInWorkspace($item[3]);
         foreach ($roles as $role) {
             $widget->addRole($role);
         }
         $manager->persist($widget);
     }
 }
示例#4
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');
     }
 }
示例#5
0
 /**
  * @param array        $widgetConfiguration
  * @param Plugin       $plugin
  * @param PluginBundle $pluginBundle
  * @param Widget       $widget
  */
 private function persistWidget($widgetConfiguration, Plugin $plugin, PluginBundle $pluginBundle, Widget $widget)
 {
     $widget->setName($widgetConfiguration['name']);
     $widget->setConfigurable($widgetConfiguration['is_configurable']);
     $widget->setDisplayableInDesktop($widgetConfiguration['is_displayable_in_desktop']);
     $widget->setDisplayableInWorkspace($widgetConfiguration['is_displayable_in_workspace']);
     $widget->setExportable($widgetConfiguration['is_exportable']);
     $widget->setPlugin($plugin);
     $widget->setDefaultWidth($widgetConfiguration['default_width']);
     $widget->setDefaultHeight($widgetConfiguration['default_height']);
     $this->em->persist($widget);
 }
 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();
 }
示例#7
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();
 }