예제 #1
0
 public function save()
 {
     $result = parent::save();
     if ($result) {
         $db = JFactory::getDBO();
         $db->setQuery("SELECT COUNT(*) FROM #__files_containers WHERE slug = 'fileman-files'");
         if (!$db->loadResult()) {
             $thumbnails = true;
             if (!extension_loaded('gd') && !extension_loaded('imagick')) {
                 JFactory::getApplication()->enqueueMessage('Your server does not have necessary image libraries for thumbnails. You need either GD or Imagemagick installed to make thumbnails visible.');
                 $thumbnails = false;
             }
             $params = json_encode((object) array('allowed_media_usergroup' => 3, 'thumbnails' => $thumbnails));
             $db->setQuery("INSERT INTO `#__files_containers` (`files_container_id`, `slug`, `title`, `path`, `parameters`)\n\t\t\t\t\tVALUES (NULL, 'fileman-files', 'FILEman', 'images', '{$params}');");
             $db->query();
         }
         if (version_compare(JVERSION, '1.6', '>')) {
             // Remove com_files from the menu table
             $db->setQuery("SELECT id FROM #__menu WHERE link = 'index.php?option=com_files'");
             $id = $db->loadResult();
             if ($id) {
                 $table = JTable::getInstance('menu');
                 $table->bind(array('id' => $id));
                 $table->delete();
             }
             // Managers should be able to access the component by default just like com_media
             if ($this->event === 'install') {
                 $rule = '{"core.admin":[],"core.manage":{"6":1},"core.create":[],"core.delete":[],"core.edit":[]}';
                 $db->setQuery(sprintf("UPDATE #__assets SET rules = '%s' WHERE name = '%s'", $rule, 'com_fileman'));
                 $db->query();
             }
         }
     }
     return $result;
 }
예제 #2
0
 public function save()
 {
     $result = parent::save();
     if ($result) {
         $db = JFactory::getDBO();
         if (version_compare(JVERSION, '1.6', '<')) {
             // Do not show the component in menu manager
             $db->setQuery("UPDATE #__components SET link = '' WHERE link = 'option=com_logman'");
             $db->query();
             $db->setQuery("SELECT id FROM #__modules WHERE module = 'mod_logman' AND title='MOD_LOGMAN' AND published = 0");
             $id = $db->loadResult();
             if ($id) {
                 $db->setQuery(sprintf("UPDATE `#__modules` SET title = 'LOGman - Activity Stream', position = 'cpanel', ordering = -1, published = 1\n\t\t\t\t    \tWHERE id = %d LIMIT 1", $id));
                 $db->query();
             }
         } else {
             $db->setQuery("SELECT id FROM #__modules WHERE module = 'mod_logman' AND published <> -2 AND position = ''");
             $id = $db->loadResult();
             if ($id) {
                 $db->setQuery(sprintf("UPDATE `#__modules` SET position = 'cpanel', ordering = -1, published = 1, params = '{\"limit\":\"10\",\"direction\":\"desc\"}'\n\t\t\t\t    \tWHERE id = %d LIMIT 1", $id));
                 $db->query();
                 $db->setQuery("REPLACE INTO #__modules_menu VALUES ({$id}, 0)");
                 $db->query();
             }
             // Remove com_activities from the menu table
             $db->setQuery("SELECT id FROM #__menu WHERE link = 'index.php?option=com_activities'");
             $id = $db->loadResult();
             if ($id) {
                 $table = JTable::getInstance('menu');
                 $table->bind(array('id' => $id));
                 $table->delete();
             }
         }
     }
     return $result;
 }
예제 #3
0
 /**
  * @return bool
  */
 public function save()
 {
     $result = parent::save();
     if ($result) {
         $this->_createFilesContainer();
         $this->_createIconsContainer();
         $this->_createImagesContainer();
         if (file_exists(dirname(__FILE__) . '/../../install/mimetypes.sql')) {
             $query = file_get_contents(dirname(__FILE__) . '/../../install/mimetypes.sql');
             if ($query) {
                 $db = JFactory::getDBO();
                 $db->setQuery($query);
                 $db->queryBatch(false);
             }
         }
         // Remove com_files from the menu table
         $db = JFactory::getDBO();
         $db->setQuery("SELECT id FROM #__menu WHERE link = 'index.php?option=com_files'");
         $id = $db->loadResult();
         if ($id) {
             $table = JTable::getInstance('menu');
             $table->bind(array('id' => $id));
             $table->delete();
         }
         // Add a rule to authorize Public group to download
         if ($this->event === 'install') {
             $asset = JTable::getInstance('Asset');
             $asset->loadByName('com_docman');
             $rules = new JAccessRules($asset->rules);
             $rules->mergeAction('com_docman.download', new JAccessRule(array(1 => true)));
             $asset->rules = (string) $rules;
             if ($asset->check()) {
                 $asset->store();
             }
             unset($asset);
             $asset = JTable::getInstance('Asset');
             $asset->loadByName('com_docman');
             $rules = new JAccessRules($asset->rules);
             $rules->mergeAction('com_docman.upload', new JAccessRule(array(6 => true, 2 => true)));
             $asset->rules = (string) $rules;
             if ($asset->check()) {
                 $asset->store();
             }
         }
         if ($this->old_version) {
             $this->_migrate();
         }
     }
     return $result;
 }
 public function save()
 {
     $result = parent::save();
     if ($result) {
         $db = JFactory::getDBO();
         $db->setQuery("SELECT COUNT(*) FROM #__files_containers WHERE slug = 'fileman-files'");
         if (!$db->loadResult()) {
             $thumbnails = true;
             if (!extension_loaded('gd') && !extension_loaded('imagick')) {
                 JFactory::getApplication()->enqueueMessage(JText::_('Your server does not have necessary image libraries for thumbnails. You need either GD or Imagemagick installed to make thumbnails visible.'));
                 $thumbnails = false;
             }
             $params = json_encode((object) array('allowed_media_usergroup' => 3, 'thumbnails' => $thumbnails));
             $db->setQuery("INSERT INTO `#__files_containers` (`files_container_id`, `slug`, `title`, `path`, `parameters`)\n\t\t\t\t\tVALUES (NULL, 'fileman-files', 'FILEman', 'images', '{$params}');");
             $db->query();
         }
         if (version_compare(JVERSION, '1.6', '>')) {
             // Remove com_files from the menu table
             $db->setQuery("SELECT id FROM #__menu WHERE link = 'index.php?option=com_files'");
             $id = $db->loadResult();
             if ($id) {
                 $table = JTable::getInstance('menu');
                 $table->bind(array('id' => $id));
                 $table->delete();
             }
             // Managers should be able to access the component by default just like com_media
             if ($this->event === 'install') {
                 $rule = '{"core.admin":[],"core.manage":{"6":1},"core.create":[],"core.delete":[],"core.edit":[]}';
                 $db->setQuery(sprintf("UPDATE #__assets SET rules = '%s' WHERE name = '%s'", $rule, 'com_fileman'));
                 $db->query();
             }
         }
         if ($this->old_version && version_compare($this->old_version, '1.0.0RC4', '<=')) {
             // Path encoding got removed in 1.0.0RC5
             $row = KService::get('com://admin/files.model.containers')->slug('fileman-files')->getItem();
             $path = $row->path;
             $rename = array();
             $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CHILD_FIRST);
             foreach ($iterator as $f) {
                 $name = $f->getFilename();
                 if ($name === rawurldecode($name)) {
                     continue;
                 }
                 $rename[$f->getPathname()] = $f->getPath() . '/' . rawurldecode($name);
             }
             foreach ($rename as $from => $to) {
                 rename($from, $to);
             }
         }
         if ($this->old_version && version_compare($this->old_version, '1.0.0RC4', '<=')) {
             // format=raw was removed from URLs in RC4
             $id = JComponentHelper::getComponent('com_fileman')->id;
             if ($id) {
                 $table = KService::get('com://admin/docman.database.table.menus', array('name' => 'menu'));
                 $items = $table->select(array('component_id' => $id));
                 foreach ($items as $item) {
                     parse_str(str_replace('index.php?', '', $item->link), $query);
                     if (!isset($query['view']) || $query['view'] !== 'file') {
                         continue;
                     }
                     $view = $query['view'];
                     $item->link = str_replace('&format=raw', '', $item->link);
                     $item->save();
                 }
             }
         }
     }
     return $result;
 }