Exemplo n.º 1
0
 public function testInstallApp()
 {
     $pathOfTestApp = __DIR__;
     $pathOfTestApp .= '/../data/';
     $pathOfTestApp .= 'testapp.zip';
     $tmp = \OC::$server->getTempManager()->getTemporaryFile('.zip');
     \OC_Helper::copyr($pathOfTestApp, $tmp);
     $data = array('path' => $tmp, 'source' => 'path', 'appdata' => ['id' => 'Bar', 'level' => 100]);
     Installer::installApp($data);
     $isInstalled = Installer::isInstalled(self::$appid);
     $this->assertTrue($isInstalled);
 }
Exemplo n.º 2
0
 /**
  * enables an app
  *
  * @param mixed $app app
  * @param array $groups (optional) when set, only these groups will have access to the app
  * @throws \Exception
  * @return void
  *
  * This function set an app as enabled in appconfig.
  */
 public static function enable($app, $groups = null)
 {
     self::$enabledAppsCache = array();
     // flush
     if (!Installer::isInstalled($app)) {
         $app = self::installApp($app);
     }
     $appManager = \OC::$server->getAppManager();
     if (!is_null($groups)) {
         $groupManager = \OC::$server->getGroupManager();
         $groupsList = [];
         foreach ($groups as $group) {
             $groupItem = $groupManager->get($group);
             if ($groupItem instanceof \OCP\IGroup) {
                 $groupsList[] = $groupManager->get($group);
             }
         }
         $appManager->enableAppForGroups($app, $groupsList);
     } else {
         $appManager->enableApp($app);
     }
 }
Exemplo n.º 3
0
 /**
  * Installs shipped apps
  *
  * This function installs all apps found in the 'apps' directory that should be enabled by default;
  * @param bool $softErrors When updating we ignore errors and simply log them, better to have a
  *                         working ownCloud at the end instead of an aborted update.
  * @return array Array of error messages (appid => Exception)
  */
 public static function installShippedApps($softErrors = false)
 {
     $errors = [];
     foreach (\OC::$APPSROOTS as $app_dir) {
         if ($dir = opendir($app_dir['path'])) {
             while (false !== ($filename = readdir($dir))) {
                 if (substr($filename, 0, 1) != '.' and is_dir($app_dir['path'] . "/{$filename}")) {
                     if (file_exists($app_dir['path'] . "/{$filename}/appinfo/info.xml")) {
                         if (!Installer::isInstalled($filename)) {
                             $info = OC_App::getAppInfo($filename);
                             $enabled = isset($info['default_enable']);
                             if (($enabled || in_array($filename, \OC::$server->getAppManager()->getAlwaysEnabledApps())) && \OC::$server->getConfig()->getAppValue($filename, 'enabled') !== 'no') {
                                 if ($softErrors) {
                                     try {
                                         Installer::installShippedApp($filename);
                                     } catch (\Doctrine\DBAL\Exception\TableExistsException $e) {
                                         $errors[$filename] = $e;
                                         continue;
                                     }
                                 } else {
                                     Installer::installShippedApp($filename);
                                 }
                                 \OC::$server->getConfig()->setAppValue($filename, 'enabled', 'yes');
                             }
                         }
                     }
                 }
             }
             closedir($dir);
         }
     }
     return $errors;
 }