public function userDeleted(UMEvent $e)
 {
     if ($e->getSource() instanceof AbstractEyeosUser) {
         $userDirPath = UMManager::getEyeosUserDirectory($e->getSource()->getName());
         AdvancedPathLib::rmdirs($userDirPath);
     }
 }
 protected function getUserMetaFilesPath($username)
 {
     $path = UMManager::getEyeosUserDirectory($username) . '/' . USERS_METAFILES_DIR;
     if (!is_dir($path)) {
         mkdir($path, 0777, true);
     }
     return $path;
 }
 protected function getUserSettingsPath(EyeosUser $user)
 {
     $path = UMManager::getEyeosUserDirectory($user) . '/' . USERS_CONF_DIR . '/' . USERS_META_DIR . '/' . USERS_META_SETTINGS_FILENAME;
     if (!is_dir(dirname($path))) {
         mkdir(dirname($path), 0777, true);
     }
     return $path;
 }
 protected static function getUserMountpointsPath($username)
 {
     $path = UMManager::getEyeosUserDirectory($username) . '/' . USERS_CONF_DIR . '/' . SERVICE_FILESYSTEM_MOUNTPOINTS_CONF_DIR;
     if (!is_dir($path)) {
         mkdir($path, 0777, true);
     }
     if (!is_file($path . '/' . SERVICE_FILESYSTEM_MOUNTPOINTS_CONF_FILENAME)) {
         file_put_contents($path . '/' . SERVICE_FILESYSTEM_MOUNTPOINTS_CONF_FILENAME, '<conf/>');
     }
     return $path . '/' . SERVICE_FILESYSTEM_MOUNTPOINTS_CONF_FILENAME;
 }
 /**
  * @param string $path
  * @param SimpleXMLElement $xmlConf
  * @return AbstractFile
  */
 public static function getRealFile($path, $xmlParams = null, $params = null)
 {
     $urlParts = EyeosAbstractVirtualFile::parse_url($path, AdvancedPathLib::OS_UNIX);
     if (!isset($urlParts['principalname'])) {
         throw new EyeInvalidArgumentException('Missing username in given path "' . $path . '".');
     }
     $userFilesPath = UMManager::getEyeosUserDirectory($urlParts['principalname']) . '/' . USERS_FILES_DIR;
     if (!is_dir($userFilesPath)) {
         try {
             if (!mkdir($userFilesPath, 0777, true)) {
                 throw new EyeIOException('Unable to create user files directory ' . $userFilesPath);
             }
         } catch (EyeErrorException $e) {
             throw new EyeIOException('Unable to create user files directory ' . $userFilesPath . '.', 0, $e);
         }
     }
     return new LocalFile($userFilesPath . $urlParts['path'], $params);
 }
 public function search(SearchQuery $obj)
 {
     if (AdvancedPathLib::getCurrentOS() == AdvancedPathLib::OS_WINDOWS) {
         return array(0, array());
     }
     $this->results = array();
     // setting the queryString to the variable.
     $searchArray = explode(' ', $obj->getQueryString());
     foreach ($searchArray as $word) {
         $this->searchQuery .= 'filename:' . $word . '* ';
     }
     // setting the queryTokens to the variable.
     $queryTokens = $obj->getQueryTokens();
     // for each valid token, we add the token and its parameters to the $searchQuery variable.
     if ($queryTokens) {
         foreach ($queryTokens as $token => $parameters) {
             if (in_array($token, $this->getValidTokens())) {
                 foreach ($parameters as $count => $value) {
                     $this->searchQuery .= $token . ':' . $value;
                     if ($count < count($parameters) - 1) {
                         $this->searchQuery .= ' OR ';
                     } else {
                         $this->searchQuery .= ' ';
                     }
                 }
                 $this->searchQuery .= 'AND ';
             }
         }
         // searching for an AND at the end of the searchQuery, if it's there we delete it
         // to conform the query to the recoll standards.
         // ( by the way, an AND at the end of a query does not make any sense, do it? :P )
         $pos = strpos($this->searchQuery, 'AND', strlen($this->searchQuery) - 4);
         $this->searchQuery = substr($this->searchQuery, 0, $pos - 1);
     }
     $user = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getName();
     $recollDirPath = UMManager::getEyeosUserDirectory($user) . '/' . USERS_CONF_DIR . '/' . FRAMEWORK_SEARCH_RECOLL_DIR;
     $result = shell_exec(AdvancedPathLib::realpath(FRAMEWORK_SEARCH_UTILS_PATH) . '/XmlBuilder.pl ' . escapeshellarg(AdvancedPathLib::realpath($recollDirPath)) . ' ' . escapeshellarg($this->searchQuery));
     $xmlResult = simplexml_load_string($result);
     if ($xmlResult) {
         $path = realpath(UMManager::getEyeosUserDirectory($user)) . '/files/';
         foreach ($xmlResult as $node => $markup) {
             if ($node == 'file') {
                 $cleanPath = utf8_substr($markup->path, 7);
                 $cleanPath = 'home://~' . $user . '/' . utf8_substr($cleanPath, strlen($path));
                 $tempFile = array('type' => (string) $markup->type, 'path' => (string) $cleanPath, 'name' => (string) $markup->name, 'size' => (string) $markup->size);
                 $this->results[] = $tempFile;
             } else {
                 if ($node == 'files') {
                     $this->totalFiles = $markup;
                 }
             }
         }
     }
     return array($this->totalFiles, $this->results);
 }