コード例 #1
0
ファイル: newlink.php プロジェクト: DavidGarciaCat/eyeos
 public static function createLink($params)
 {
     $structure = array();
     $structure['url'] = $params[0];
     $structure['width'] = $params[1];
     $structure['height'] = $params[2];
     $structure['icon'] = str_replace('eyeos/extern/', 'index.php?extern=', $params[5]);
     $structure['openInNewWindow'] = $params[6];
     $structure['type'] = 'web';
     $linkName = utf8_basename($params[3]);
     $info = pathinfo($linkName);
     if (!isset($info['extension']) || $info['extension'] != 'lnk') {
         $linkName .= '.lnk';
     }
     $path = $params[4];
     $text = json_encode($structure);
     $linkName = str_replace('?', '_', $linkName);
     $linkName = str_replace('#', '_', $linkName);
     $newFile = FSI::getFile($path . '/' . $linkName);
     $newFile->createNewFile();
     $newFile->putContents($text);
     $currentUser = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
     $settings = MetaManager::getInstance()->retrieveMeta($currentUser);
     //TODO: better message?
     $message = new ClientBusMessage('file', 'uploadComplete', self::getFileInfo($newFile, $settings));
     ClientMessageBusController::getInstance()->queueMessage($message);
 }
コード例 #2
0
 /**
  * Retrieve the name of the user
  *
  * @param <AbstractEventNotification> $event
  */
 public static function retrieveContactName($userId)
 {
     $user = UMManager::getInstance()->getUserById($userId);
     $userMeta = MetaManager::getInstance()->retrieveMeta($user);
     $username = $userMeta->get('eyeos.user.firstname') . ' ' . $userMeta->get('eyeos.user.lastname');
     return $username;
 }
コード例 #3
0
 public function userDeleted(UMEvent $e)
 {
     if ($e->getSource() instanceof AbstractEyeosUser) {
         //Send message to the BUS
         $message = new ClientBusMessage('ummanager', 'userDeleted', $e->getSource()->getId());
         ClientMessageBusController::getInstance()->queueMessage($message);
         MetaManager::getInstance()->deleteMeta($e->getSource());
     }
 }
コード例 #4
0
ファイル: Meta.php プロジェクト: k-kalashnikov/forKoda
 private function __construct()
 {
     $this->tablesManager = TablesManager::getInstance();
     $this->fieldsManager = FieldsManager::getInstance();
     $this->metaManager = MetaManager::getInstance();
     $this->relationsManager = RelationsManager::getInstance();
     $this->itemsManager = ItemsManager::getInstance();
     $this->commentsManager = CommentsManager::getInstance();
     $this->tablesMeta = [];
 }
コード例 #5
0
 public function convertMetaData($fromObject, $toObject)
 {
     // this failback return void metadata
     $this->Logger->debug("Conversion from " . get_class($fromObject) . " => " . get_class($toObject) . " working...");
     $this->Logger->debug("Conversion from " . get_class($fromObject) . " => " . get_class($toObject) . " done");
     // create empty metadata
     $newMeta = MetaManager::getInstance()->getNewMetaDataInstance($toObject);
     $newMeta->set('creationTime', time());
     $newMeta->set('modificationTime', time());
     return $newMeta;
 }
コード例 #6
0
ファイル: welcomepage.php プロジェクト: DavidGarciaCat/eyeos
 public static function __run(AppExecutionContext $context, MMapResponse $response)
 {
     $currentUser = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
     $meta = MetaManager::getInstance()->retrieveMeta($currentUser);
     //		Every time this Application its executed, put a metadata for not show any more time in init,
     //		maybe its interesting to put it only if not exist, like that, not working for now
     //		if(!array_key_exists('eyeos.user.desktop.showWelcome', $meta)) {
     $meta->set('eyeos.user.desktop.showWelcome', 'false');
     //		}
     MetaManager::getInstance()->storeMeta($currentUser, $meta);
 }
コード例 #7
0
 function showIndex()
 {
     $pager = new fvPager(PageManager::getInstance());
     $this->__assign('Pages', $pager->paginate(null, "IF (page_parent_id = 0, id*100000, page_parent_id*100000 + id)"));
     $request = fvRequest::getInstance();
     if (!($Page = PageManager::getInstance()->getByPk($request->getRequestParameter('id')))) {
         $Page = new Page();
     }
     $this->__assign(array('Page' => $Page, 'PageManager' => PageManager::getInstance(), 'metaManager' => MetaManager::getInstance()));
     return $this->__display('page_list.tpl');
 }
コード例 #8
0
 function showEdit()
 {
     $request = fvRequest::getInstance();
     if (!($ex = NewsManager::getInstance()->getByPk($request->getRequestParameter('id')))) {
         $ex = new News();
     }
     $this->__assign('ex', $ex);
     $this->__assign('metaManager', MetaManager::getInstance());
     $this->__assign("module", $this->moduleName);
     $this->__assign("weights", range(0, 999));
     return $this->__display('edit.tpl');
 }
コード例 #9
0
 /**
  * @param mixed $object
  * @param String $params
  * @return IMetaData
  * @throws EyeException
  * @throws EyeErrorException
  */
 public function retrieveMeta($object, $params)
 {
     if (!$object instanceof EyeosApplicationDescriptor) {
         throw new EyeInvalidArgumentException('$object must be an EyeosApplicationDescriptor.');
     }
     $filepath = $object->getPath() . '/info.xml';
     $provider = new SimpleXMLMetaProvider((string) $params, array(SimpleXMLMetaProvider::PARAM_FILEPATH => $filepath));
     $meta = $provider->retrieveMeta(null);
     // no meta found (info.xml does not exist), generate default one
     if ($meta === null) {
         $meta = MetaManager::getInstance()->getNewMetaDataInstance($object);
         $meta->setAll(array('eyeos.application.name' => $object->getName(), 'eyeos.application.author' => '<Unknown>', 'eyeos.application.version' => '<Unknown>', 'eyeos.application.description' => 'This is an autogenerated default metadata content because no file named "info.xml" can be found in the application\'s directory.', 'eyeos.application.license' => '<Unknown>'));
     }
     if ($meta->get('eyeos.application.systemParameters') === null) {
         $meta->set('eyeos.application.systemParameters', array('listable' => 'true', 'owner' => 'root', 'group' => 'users', 'permissions' => '---x--x--x', 'anonymous' => 'false', 'suid' => 'false'));
     }
     return $meta;
 }
コード例 #10
0
 public function searchContacts($text)
 {
     try {
         $text = str_replace('_', '\\_', $text);
         // looking for username in database...
         $sqlQuery = 'SELECT id FROM eyeosuser WHERE name LIKE :text0 AND id != \'eyeID_EyeosUser_register\'';
         $bindParam = array('text0' => $text);
         $text = explode(' ', $text);
         for ($i = 0; $i < count($text); $i++) {
             $sqlQuery = $sqlQuery . ' OR name LIKE :text' . ($i + 1);
             $bindParam['text' . ($i + 1)] = '%' . $text[$i] . '%';
         }
         $sqlQuery .= ' LIMIT 20';
         $stmt = $this->dao->prepare($sqlQuery);
         $stmt = $this->dao->execute($stmt, $bindParam);
         $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
         // preparing the array the function will return...
         $return = array();
         foreach ($results as $result) {
             $return[] = $result['id'];
         }
         if (count($return) >= 20) {
             return $return;
         }
         $userObj = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
         $metaToLookFor = array('eyeos.user.firstname', 'eyeos.user.lastname', 'eyeos.user.email');
         for ($i = 0; $i < count($text); $i++) {
             foreach ($metaToLookFor as $metaValue) {
                 $searchForMetas = new PrincipalMetaData();
                 $searchForMetas->set($metaValue, $text[$i]);
                 $results = MetaManager::getInstance()->searchMeta($userObj, $searchForMetas);
                 $results = array_diff($results, $return);
                 if (count($results) > 0) {
                     foreach ($results as $result) {
                         $return[] = $result;
                     }
                 }
             }
         }
         return $return;
     } catch (Exception $e) {
         throw new EyePeopleException('Unable to search contacts for text ' . $text, 0, $e);
     }
 }
コード例 #11
0
 /**
  * TODO: To remove, only used by eyeos.socialbar-ShareWindow.
  * use contact manager instead
  *
  *
  * @param <type> $params
  * @return <type>
  */
 public static function getContacts($params)
 {
     $myProcManager = ProcManager::getInstance();
     $peopleController = PeopleController::getInstance();
     $currentUserId = $myProcManager->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
     $results = array();
     foreach ($params as $userId) {
         $otherUser = UMManager::getInstance()->getUserById($userId);
         $settings = MetaManager::getInstance()->retrieveMeta($otherUser);
         $myRelation = $peopleController->getContact($currentUserId, $userId);
         $lists = array();
         $listsName = array();
         $tagsPerImpression = ImpressionsManager::getInstance()->getTagsPerImpression($myRelation->getImpression());
         foreach ($tagsPerImpression as $tagPerImpression) {
             $lists[] = $tagPerImpression->getTagId();
             $listsName[] = $peopleController->getTagName($tagPerImpression->getTagId());
         }
         $result[] = array('id' => $userId, 'name' => $settings->get('eyeos.user.firstname') . ' ' . $settings->get('eyeos.user.lastname'), 'listsName' => $listsName);
     }
     return $result;
 }
コード例 #12
0
ファイル: register.php プロジェクト: DavidGarciaCat/eyeos
 public static function register($params)
 {
     /* verify permissions again */
     $meta = MetaManager::getInstance()->retrieveMeta(kernel::getInstance('SecurityManager'))->getAll();
     if (isset($meta['register']) && $meta['register'] == 'false') {
         return 'unable to register';
     }
     $procManager = ProcManager::getInstance();
     $savedLoginContext = $procManager->getCurrentProcess()->getLoginContext();
     try {
         $name = $params[0];
         $surname = $params[1];
         $username = $params[2];
         $password = $params[3];
         $email = $params[4];
         if (!$name || !$surname || !$username || !$password || !$email) {
             return 'incomplete';
         }
         $myUManager = UMManager::getInstance();
         // check existence
         $exists = false;
         try {
             $myUManager->getUserByName($username);
             $exists = true;
         } catch (EyeNoSuchUserException $e) {
         }
         if ($exists) {
             throw new EyeUserAlreadyExistsException('User with name "' . $username . '" already exists.');
         }
         $meta = new BasicMetaData();
         $meta->set('eyeos.user.email', $email);
         $userIds = MetaManager::getInstance()->searchMeta(new EyeosUser(), $meta);
         if (count($userIds) != 0) {
             throw new EyeUserAlreadyExistsException('User with email "' . $email . '" already exists.');
         }
         //create the user
         $user = $myUManager->getNewUserInstance();
         $user->setName($username);
         $user->setPassword($password, true);
         $user->setPrimaryGroupId($myUManager->getGroupByName(SERVICE_UM_DEFAULTUSERSGROUP)->getId());
         $myUManager->createUser($user);
         //login in the system with new user, if this works, for sure the user exists, even with the
         //most complex and strange errors
         $myUManager = UMManager::getInstance();
         $subject = new Subject();
         $loginContext = new LoginContext('eyeos-login', $subject);
         $cred = new EyeosPasswordCredential();
         $cred->setUsername($username);
         $cred->setPassword($password, true);
         $subject->getPrivateCredentials()->append($cred);
         $loginContext->login();
         //we are logged in, so we are going to change the credentials of login
         $procManager = ProcManager::getInstance();
         $procList = $procManager->getProcessesList();
         $currentProcess = $procManager->getCurrentProcess();
         $procManager->setProcessLoginContext($currentProcess->getPid(), $loginContext);
         foreach ($procList as $key => $value) {
             if (strtolower($value) == 'login') {
                 //we are in another login in execution, this is a refresh, lets see
                 //if the login was correct with the old login.
                 $loginProcess = $procManager->getProcessByPid($key);
                 $procManager->setProcessLoginContext($loginProcess->getPid(), $loginContext);
             }
         }
         // save basic metadata from form
         $userMeta = MetaManager::getInstance()->retrieveMeta($user);
         $userMeta->set('eyeos.user.firstname', strip_tags($name));
         $userMeta->set('eyeos.user.lastname', strip_tags($surname));
         $userMeta->set('eyeos.user.email', $email);
         $userMeta = MetaManager::getInstance()->storeMeta($user, $userMeta);
         return 'success';
     } catch (Exception $e) {
         // ROLLBACK
         // restore login context (root probably)
         $procManager->setProcessLoginContext($procManager->getCurrentProcess()->getPid(), $savedLoginContext);
         ////		delete invalid user created
         //			if (isset($user) && $user instanceof IPrincipal) {
         //				try {
         //					UMManager::getInstance()->deletePrincipal($user);
         //				} catch (Exception $e2) {}
         //			}
         throw $e;
     }
 }
コード例 #13
0
ファイル: topmenu.php プロジェクト: DavidGarciaCat/eyeos
 public static function searchPeople($params)
 {
     //Buscar en Provider con consulta rollo LIKE etc...
     $peopleController = PeopleController::getInstance();
     $resultsSearch = $peopleController->searchContacts($params);
     $myProcManager = ProcManager::getInstance();
     $currentUserId = $myProcManager->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
     //$peopleController = new PeopleController();
     $results = array();
     foreach ($resultsSearch as $result) {
         if ($result != $currentUserId) {
             // I don't want to search myself
             try {
                 $user = UMManager::getInstance()->getUserById($result);
             } catch (Exception $e) {
                 continue;
             }
             $settings = MetaManager::getInstance()->retrieveMeta($user);
             $nameOfUser = $user->getName();
             $realName = $nameOfUser;
             $description = 'No description';
             $pathImage = 'index.php?extern=images/48x48/apps/system-users.png';
             if ($settings != null) {
                 if ($settings->get('eyeos.user.firstname') != null && $settings->get('eyeos.user.lastname') != null) {
                     $realName = $settings->get('eyeos.user.firstname') . ' ' . $settings->get('eyeos.user.lastname');
                 }
                 if ($settings->get('eyeos.user.currentlife.city') != null) {
                     $description = $settings->get('eyeos.user.currentlife.city');
                 }
             }
             $myRelationManager = RelationsManager::getInstance();
             $relation = $myRelationManager->getRelation($result, $currentUserId);
             $state = $relation != null ? $relation->getState() : null;
             $results[] = array('userId' => $result, 'description' => $nameOfUser, 'realName' => $realName, 'state' => $state);
         }
     }
     return $results;
 }
コード例 #14
0
ファイル: upload.php プロジェクト: sebasalons/eyeos-u1db
 public static function submitFile($path)
 {
     try {
         if (!isset($_FILES['Filedata'])) {
             echo '<div style="font-size:20px;font-family:Helvetica, Arial, Verdana, Sans, FreeSans;margin-top:80px;margin-right:15px;"><center>&nbsp;&nbsp;<img style="position:relative;top:15px"src="index.php?extern=/images/48x48/actions/dialog-close.png" />Error uploading files</center>';
             exit;
         }
         $Logger = Logger::getLogger('application.upload');
         foreach ($_FILES['Filedata']['name'] as $k => $v) {
             if (!empty($v)) {
                 $filename = $_FILES['Filedata']['name'][$k];
                 if (!isset($_POST['UPLOAD_IDENTIFIER'])) {
                     $filename = utf8_encode($filename);
                 }
                 $tmpPath = $_FILES['Filedata']['tmp_name'][$k];
                 $Logger->debug("Filename: " . $filename);
                 if (!is_uploaded_file($tmpPath)) {
                     throw new EyeFileNotFoundException('Uploaded file not found at "' . $tmpPath . '".');
                 }
                 $request = MMapManager::getCurrentRequest();
                 $destPath = $path;
                 $filename = str_replace('?', '_', $filename);
                 $filename = str_replace('#', '_', $filename);
                 $tmp = pathinfo($filename);
                 if (isset($tmp['extension']) && "lnk" == $tmp['extension']) {
                     throw new EyeFileNotFoundException('This file cannot be uploaded (file type banned)');
                 }
                 /*
                 if ( '?' == $filename{0} ) {
                 	$filename{0} = "_";
                 }
                 */
                 $destFile = FSI::getFile($destPath . '/' . $filename);
                 //The uploaded file is necessarily on the local filesystem and we want to avoid any
                 //permission check through EyeLocalFile, so we use LocalFile directly
                 $tmpFile = new LocalFile($tmpPath);
                 $num = 1;
                 $extension = AdvancedPathLib::pathinfo($filename, PATHINFO_EXTENSION);
                 $filename = AdvancedPathLib::pathinfo($filename, PATHINFO_FILENAME);
                 $Logger->debug("CLASS: " . get_class($destFile));
                 $Logger->debug("Exists: " . $destFile->exists());
                 //exit();
                 while ($destFile->exists()) {
                     $newBasename = $filename . ' (' . $num++ . ')' . ($extension ? '.' . $extension : '');
                     $destFile = FSI::getFile($destPath . '/' . $newBasename);
                 }
                 $destFile->checkWritePermission();
                 $tmpFile->moveTo($destFile);
                 $currentUser = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
                 $settings = MetaManager::getInstance()->retrieveMeta($currentUser);
                 $message = new ClientBusMessage('file', 'uploadComplete', self::getFileInfo($destFile, $settings));
                 ClientMessageBusController::getInstance()->queueMessage($message);
                 $event = new FileEvent($destFile);
                 $destFile->fireEvent('fileWritten', $event);
             }
         }
         register_shutdown_function('endRequestUpload');
     } catch (EyeException $e) {
         echo '<div style="font-size:20px;font-family:Helvetica, Arial, Verdana, Sans, FreeSans;margin-top:80px;margin-right:15px;"><center>&nbsp;&nbsp;<img style="position:relative;top:15px"src="index.php?extern=/images/48x48/actions/dialog-close.png" />Error uploading files: ' . $e->getMessage() . '</center>';
         exit;
     }
 }
コード例 #15
0
ファイル: files.php プロジェクト: DavidGarciaCat/eyeos
 /**
  * TODO: Will need to be moved/merged to/with FileSystemExecModule
  */
 public static function rename($params)
 {
     $currentUser = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
     $settings = MetaManager::getInstance()->retrieveMeta($currentUser);
     $fileToRename = FSI::getFile($params[0]);
     $i = 1;
     $nameForCheck = $params[2];
     $renamed = FSI::getFile($params[1] . '/' . $params[2]);
     while ($renamed->exists()) {
         $name = explode(".", $params[2]);
         $extension = (string) $name[count($name) - 1];
         $futureName = array($name[0], $i);
         $nameForCheck = implode(' ', $futureName);
         if (!$fileToRename->isDirectory()) {
             $nameForCheck .= '.' . $extension;
         }
         $i++;
         $renamed = FSI::getFile($params[1] . '/' . $nameForCheck);
     }
     $fileToRename->renameTo($nameForCheck);
     self::updateUrlShare($params[0], $renamed->getPath());
     $return = self::getFileInfo($fileToRename, $settings);
     return $return;
 }
コード例 #16
0
 /**
  * Конструктор, приватный, нужен для singletone
  */
 private function __construct()
 {
     $this->db = \Base::instance()->get('db');
     $this->metaWriter = MetaManager::getInstance();
 }
コード例 #17
0
 /**
  * Retrieve Mail for current user and check if it is valid
  * 
  * @return String 
  */
 private static function retrieveCurrentUserMail()
 {
     $admin = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
     $setting = MetaManager::getInstance()->retrieveMeta($admin);
     try {
         $emailAdmin = $setting->get('eyeos.user.email');
     } catch (Exception $e) {
         throw new EyeMetaDataNotFoundException('Cannot retrieve email of admin user, check you correctly fill this field on usersetting application');
     }
     // Check if valid mail
     $regex_pattern = "|^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}\$|u";
     if (!preg_match($regex_pattern, $emailAdmin)) {
         throw new EyeMetaDataException('The email you specified on your settings is not valid, replace it with a valid address');
     }
     return $emailAdmin;
 }
コード例 #18
0
 public function testSetMeta()
 {
     /**** existing home file ****/
     $myMeta = $this->fixture_file1->getMeta();
     $myMeta->set('myKey1', 'myValue1');
     $this->fixture_file1->setMeta($myMeta);
     $meta = MetaManager::getInstance()->retrieveMeta($this->fixture_file1);
     $this->assertNotNull($meta);
     $this->assertEquals($myMeta, $meta);
     /**** existing home dir ****/
     $myMeta = $this->fixture_dir1->getMeta();
     $myMeta->set('myKey2', 'myValue2');
     $this->fixture_dir1->setMeta($myMeta);
     $meta = MetaManager::getInstance()->retrieveMeta($this->fixture_dir1);
     $this->assertNotNull($meta);
     $this->assertEquals($myMeta, $meta);
 }
コード例 #19
0
ファイル: interface.php プロジェクト: DavidGarciaCat/eyeos
 /**
  * @param IMetaData $metaData The metadata to be associated
  *        to the current object.
  */
 public function setMeta(IMetaData $metaData = null)
 {
     MetaManager::getInstance()->storeMeta($this, $metaData);
 }
コード例 #20
0
 public function setInstalledApplication(IApplicationDescriptor $application, $installed = true)
 {
     $currentUser = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
     $meta = MetaManager::getInstance()->retrieveMeta($currentUser);
     $installedMeta = $meta->get('eyeos.user.applications.installed');
     if ($installed) {
         $installedMeta[$application->getName()] = time();
     } else {
         unset($installedMeta[$application->getName()]);
     }
     $meta->set('eyeos.user.applications.installed', $installedMeta);
     MetaManager::getInstance()->storeMeta($currentUser, $meta);
 }
コード例 #21
0
 /**
  * @param mixed $object
  * @param String $params
  * @return IMetaData
  * @throws EyeException
  * @throws EyeErrorException
  */
 public function retrieveMeta($object, $params)
 {
     if (!$object instanceof EyeUserFile) {
         throw new EyeInvalidArgumentException('$object must be an EyeUserFile.');
     }
     $urlParts = $object->getURLComponents();
     if ($urlParts['path'] == '/') {
         $filepath = $this->getUserMetaFilesPath($urlParts['principalname']) . '/' . USERS_FILES_DIR . USERS_METAFILES_EXTENSION;
     } else {
         $filepath = $this->getUserMetaFilesPath($urlParts['principalname']) . '/' . USERS_FILES_DIR . $urlParts['path'] . USERS_METAFILES_EXTENSION;
     }
     $provider = new SimpleXMLMetaProvider((string) $params, array(SimpleXMLMetaProvider::PARAM_FILEPATH => $filepath));
     $meta = null;
     try {
         $meta = $provider->retrieveMeta(null);
     } catch (EyeFileNotFoundException $e) {
     }
     if ($meta === null && $object->exists()) {
         $owner = UMManager::getInstance()->getUserByName($urlParts['principalname']);
         $primaryGroup = UMManager::getInstance()->getGroupById($owner->getPrimaryGroupId());
         $meta = MetaManager::getInstance()->getNewMetaDataInstance($object);
         $meta->setAll(array(EyeosAbstractVirtualFile::METADATA_KEY_OWNER => $owner->getName(), EyeosAbstractVirtualFile::METADATA_KEY_GROUP => $primaryGroup->getName(), EyeosAbstractVirtualFile::METADATA_KEY_PERMISSIONS => '-rw-------', EyeosAbstractVirtualFile::METADATA_KEY_CREATIONTIME => null, EyeosAbstractVirtualFile::METADATA_KEY_MODIFICATIONTIME => null));
         if ($object->isDirectory()) {
             $meta->set(EyeosAbstractVirtualFile::METADATA_KEY_PERMISSIONS, '-rwx------');
         }
     }
     if ($meta !== null) {
         SecurityManager::getInstance()->checkPermission($meta, new MetaDataPermission('read', null, $object));
     }
     return $meta;
 }
コード例 #22
0
 public function setId($id)
 {
     if ($this->realFile === null) {
         throw new EyeUnsupportedOperationException(__METHOD__ . ' on ' . $this->path);
     }
     if (!is_string($id)) {
         throw new EyeInvalidArgumentException('$id must be a string (' . gettype($id) . ' given).');
     }
     $meta = $this->getMeta();
     if ($meta === null) {
         $meta = MetaManager::getInstance()->getNewMetaDataInstance($this);
     }
     $existingId = $meta->get(self::METADATA_KEY_ID);
     if ($existingId !== null) {
         throw new EyeBadMethodCallException('Cannot overwrite existing id for file ' . $this->path . '.');
     }
     $meta->set(self::METADATA_KEY_ID, $id);
     $this->setMeta($meta);
 }
コード例 #23
0
 /**
  * @param mixed $object
  * @param String $params
  * @return IMetaData
  * @throws EyeException
  * @throws EyeErrorException
  */
 public function retrieveMeta($object, $params)
 {
     if (!$object instanceof EyeosUser) {
         throw new EyeInvalidArgumentException('$object must be an EyeosUser.');
     }
     $filepath = $this->getUserSettingsPath($object);
     $provider = new SimpleXMLMetaProvider((string) $params, array(SimpleXMLMetaProvider::PARAM_FILEPATH => $filepath));
     $meta = $provider->retrieveMeta(null);
     if ($meta === null) {
         return MetaManager::getInstance()->getNewMetaDataInstance($object);
     }
     SecurityManager::getInstance()->checkPermission($meta, new MetaDataPermission('read', $meta, $object));
     return $meta;
 }
コード例 #24
0
 /**
  * @param array $params(
  * 		'id' => id,
  * 		['masterGroupId' => masterGroupId,]
  * 		['ownerId' => ownerId,]
  * 		['privacyMode' => privacyMode,]
  * 		['metadata' => {Map}]
  * 		['status' => status]
  * )
  */
 public function updateWorkgroup($params)
 {
     if (!isset($params['id']) || !is_string($params['id'])) {
         throw new EyeInvalidArgumentException('Missing or invalid $params[\'id\'].');
     }
     if (!isset($params['masterGroupId']) || !is_string($params['masterGroupId'])) {
         $params['masterGroupId'] = null;
     }
     if (!isset($params['ownerId']) || !is_string($params['ownerId'])) {
         $params['ownerId'] = null;
     }
     if (!isset($params['privacyMode']) || !is_numeric($params['privacyMode'])) {
         $params['privacyMode'] = null;
     }
     if (!isset($params['status']) || !is_numeric($params['status'])) {
         $params['status'] = null;
     }
     $newWorkgroup = UMManager::getInstance()->getWorkgroupById($params['id']);
     if ($params['masterGroupId'] !== null) {
         $newWorkgroup->setMasterGroupId($params['masterGroupId']);
     }
     if ($params['ownerId'] !== null) {
         $newWorkgroup->setOwnerId($params['ownerId']);
     }
     if ($params['privacyMode'] !== null) {
         $newWorkgroup->setPrivacyMode($params['privacyMode']);
     }
     if ($params['status'] !== null) {
         $newWorkgroup->setStatus($params['status']);
     }
     UMManager::getInstance()->updatePrincipal($newWorkgroup);
     if (isset($params['metadata']) && is_array($params['metadata'])) {
         $meta = MetaManager::getInstance()->retrieveMeta($newWorkgroup);
         if ($meta === null) {
             $meta = MetaManager::getInstance()->getNewMetaDataInstance($newWorkgroup);
         }
         $meta->setAll($params['metadata']);
         MetaManager::getInstance()->storeMeta($newWorkgroup, $meta);
     }
 }
コード例 #25
0
ファイル: desktop.php プロジェクト: DavidGarciaCat/eyeos
 public function copyFile($params)
 {
     $currentUser = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
     $settings = MetaManager::getInstance()->retrieveMeta($currentUser);
     $target = FSI::getFile($params[0]);
     $results = array();
     for ($i = 1; $i < count($params); $i++) {
         $source = FSI::getFile($params[$i]);
         if (!$source->isDirectory()) {
             $name = explode(".", $source->getName());
             $extension = (string) $name[count($name) - 1];
             $theName = substr($source->getName(), 0, strlen($source->getName()) - strlen($extension) - 1);
         } else {
             $theName = $source->getName();
         }
         $nameForCheck = $theName;
         if (!$source->isDirectory()) {
             $nameForCheck .= '.' . $extension;
         }
         $number = 1;
         $newFile = FSI::getFile($params[0] . "/" . $nameForCheck);
         while ($newFile->exists()) {
             $futureName = array($theName, $number);
             $nameForCheck = implode(' ', $futureName);
             if (!$source->isDirectory()) {
                 $nameForCheck .= '.' . $extension;
             }
             $number++;
             $newFile = FSI::getFile($params[0] . "/" . $nameForCheck);
         }
         $source->copyTo($newFile);
         $j = $i - 1;
         $return[$j] = array('class' => get_class($newFile), 'type' => $newFile->isDirectory() ? 'folder' : ($newFile->isLink() ? 'link' : 'file'), 'extension' => utf8_strtoupper($newFile->getExtension()), 'size' => $newFile->isDirectory() ? 0 : $newFile->getSize(), 'permissions' => $newFile->getPermissions(false), 'owner' => $newFile->getOwner(), 'group' => $newFile->getGroup(), 'absolutepath' => $newFile->getAbsolutePath(), 'meta' => $newFile->getMeta()->getAll());
         if ($return[$j]['extension'] == 'LNK') {
             $return[$j]['content'] = $newFile->getContents();
         }
         $return[$j]['name'] = $newFile->getName() != '/' ? $newFile->getName() : $return[$j]['absolutepath'];
         if ($newFile instanceof EyeosAbstractVirtualFile) {
             $return[$j]['virtual'] = 'true';
         } else {
             $return[$j]['virtual'] = 'false';
         }
     }
     return $return;
 }
コード例 #26
0
ファイル: files.php プロジェクト: sebasalons/eyeos-u1db
 /**
  * TODO: Will need to be moved/merged to/with FileSystemExecModule
  */
 public static function rename($params)
 {
     $currentUser = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
     $settings = MetaManager::getInstance()->retrieveMeta($currentUser);
     $fileToRename = FSI::getFile($params[0]);
     $apiManager = new ApiManager();
     $cloudspace = count($params) == 6 ? true : false;
     if ($cloudspace || count($params) === 9) {
         $cloud = $params[5];
         $parent = $params[4] === 0 ? 'null' : $params[4];
         if (!$fileToRename->isDirectory()) {
             if ($params[3] !== -1) {
                 $pathAbsolute = AdvancedPathLib::getPhpLocalHackPath($fileToRename->getRealFile()->getAbsolutePath());
                 $token = $_SESSION['access_token_' . $cloud . '_v2'];
                 $resourceUrl = null;
                 if (count($params) === 9) {
                     $token = new stdClass();
                     $resourceUrl = $params[7];
                     $token->key = $params[8];
                     $token->secret = $params[9];
                 }
                 $metadata = $apiManager->downloadMetadata($token, $params[3], $pathAbsolute, $currentUser->getId(), false, $cloud, $resourceUrl);
                 if (isset($metadata['error'])) {
                     if ($metadata['error'] == 403) {
                         $denied = self::permissionDeniedCloud($cloud);
                         $metadata['path'] = $denied['path'];
                     }
                     return $metadata;
                 }
             }
         }
         $i = 1;
         $nameForCheck = $params[2];
         $renamed = FSI::getFile($params[1] . '/' . $params[2]);
         while ($renamed->exists()) {
             $name = explode(".", $params[2]);
             $extension = (string) $name[count($name) - 1];
             $futureName = array($name[0], $i);
             $nameForCheck = implode(' ', $futureName);
             if (!$fileToRename->isDirectory()) {
                 $nameForCheck .= '.' . $extension;
             }
             $i++;
             $renamed = FSI::getFile($params[1] . '/' . $nameForCheck);
         }
         if ($fileToRename->renameTo($nameForCheck)) {
             $path = self::getPathCloud($renamed, $cloud);
             if ($params[3] !== -1) {
                 $token = $_SESSION['access_token_' . $cloud . '_v2'];
                 $resourceUrl = null;
                 if (count($params) === 9) {
                     $token = new stdClass();
                     $resourceUrl = $params[7];
                     $token->key = $params[8];
                     $token->secret = $params[9];
                 }
                 $resultado = $apiManager->renameMetadata($cloud, $token, !$fileToRename->isDirectory(), $params[3], $renamed->getName(), $path, $currentUser->getId(), $parent, $resourceUrl);
                 if (isset($resultado['error'])) {
                     if ($resultado['error'] == 403) {
                         $denied = self::permissionDeniedCloud($cloud);
                         $resultado['path'] = $denied['path'];
                     }
                     return $resultado;
                 }
             } else {
                 $event = new FileEvent($fileToRename);
                 $fileToRename->fireEvent('fileWritten', $event);
             }
         }
     } else {
         $i = 1;
         $nameForCheck = $params[2];
         $renamed = FSI::getFile($params[1] . '/' . $params[2]);
         while ($renamed->exists()) {
             $name = explode(".", $params[2]);
             $extension = (string) $name[count($name) - 1];
             $futureName = array($name[0], $i);
             $nameForCheck = implode(' ', $futureName);
             if (!$fileToRename->isDirectory()) {
                 $nameForCheck .= '.' . $extension;
             }
             $i++;
             $renamed = FSI::getFile($params[1] . '/' . $nameForCheck);
         }
         $fileToRename->renameTo($nameForCheck);
     }
     self::updateUrlShare($params[0], $renamed->getPath());
     $return = self::getFileInfo($fileToRename, $settings);
     return $return;
 }
コード例 #27
0
ファイル: VirtualFile.php プロジェクト: DavidGarciaCat/eyeos
 /**
  * @param VirtualFileMetaData $metaData The metadata to be associated
  *        to the current object.
  */
 public function setMeta(IMetaData $metaData = null)
 {
     if (!$metaData instanceof VirtualFileMetaData) {
         throw new EyeInvalidArgumentException('$metaData must be a VirtualFileMetaData.');
     }
     if (!$this->exists()) {
         throw new EyeFileNotFoundException('Cannot set meta on the non-existing file ' . $this->path . '.');
     }
     MetaManager::getInstance()->storeMeta($this, $metaData);
 }
コード例 #28
0
 public function getAvatarPicture($params)
 {
     $userId = $params[0];
     $user = UMManager::getInstance()->getUserById($params['userId']);
     $settings = MetaManager::getInstance()->retrieveMeta($user);
     $file = null;
     if ($settings->get('eyeos.user.picture.url') !== null) {
         $file = FSI::getFile($settings->get('eyeos.user.picture.url'));
     }
     if ($file === null || !$file->isReadable()) {
         $file = FSI::getFile('sys:///extern/images/empty_profile.png');
     }
     $response = MMapManager::getCurrentResponse();
     $bodyrenderer = new FileReaderBodyRenderer($file->getInputStream());
     // Set headers
     $response->getHeaders()->append('Content-Type: ' . mime_content_type($file->getName()));
     $response->getHeaders()->append('Content-Length: ' . $file->getSize());
     $response->getHeaders()->append('Accept-Ranges: bytes');
     $response->getHeaders()->append('X-Pad: avoid browser bug');
     $response->setBodyRenderer($bodyrenderer);
 }
コード例 #29
0
 /**
  * @param mixed $object
  * @param String $params
  * @return IMetaData
  * @throws EyeException
  * @throws EyeErrorException
  */
 public function retrieveMeta($object, $params)
 {
     if (!$object instanceof EyeSysFile) {
         throw new EyeInvalidArgumentException('$object must be an EyeSysFile.');
     }
     $urlParts = $object->getURLComponents();
     //{
     $meta = null;
     // TODO: attempt to load metadata from database if it exists
     //}
     //if no metadata has been found, create a default one
     if ($meta === null) {
         $meta = MetaManager::getInstance()->getNewMetaDataInstance($object);
         $meta->setAll(array(EyeosAbstractVirtualFile::METADATA_KEY_GROUP => 'root', EyeosAbstractVirtualFile::METADATA_KEY_OWNER => 'root', EyeosAbstractVirtualFile::METADATA_KEY_PERMISSIONS => '-rwxr--r--'));
     }
     SecurityManager::getInstance()->checkPermission($meta, new MetaDataPermission('read', null, $object));
     return $meta;
 }
コード例 #30
0
 /**
  * @param mixed $object
  * @param String $params
  * @return IMetaData
  * @throws EyeException
  * @throws EyeErrorException
  */
 public function retrieveMeta($object, $params)
 {
     if (!$object instanceof EyeUserConfFile) {
         throw new EyeInvalidArgumentException('$object must be an EyeUserConfFile.');
     }
     $urlParts = $object->getURLComponents();
     //{
     $meta = null;
     // TODO: attempt to load metadata from database if it exists
     //}
     //if no metadata has been found, create a default one
     if ($meta === null) {
         $owner = UMManager::getInstance()->getUserByName($urlParts['principalname']);
         $primaryGroup = UMManager::getInstance()->getGroupById($owner->getPrimaryGroupId());
         $meta = MetaManager::getInstance()->getNewMetaDataInstance($object);
         $meta->setAll(array(EyeosAbstractVirtualFile::METADATA_KEY_OWNER => $owner->getName(), EyeosAbstractVirtualFile::METADATA_KEY_GROUP => $primaryGroup->getName(), EyeosAbstractVirtualFile::METADATA_KEY_PERMISSIONS => '-rw-------', EyeosAbstractVirtualFile::METADATA_KEY_CREATIONTIME => null, EyeosAbstractVirtualFile::METADATA_KEY_MODIFICATIONTIME => null));
         if ($object->isDirectory()) {
             $meta->set(EyeosAbstractVirtualFile::METADATA_KEY_PERMISSIONS, '-rwx------');
         }
     }
     SecurityManager::getInstance()->checkPermission($meta, new MetaDataPermission('read', null, $object));
     return $meta;
 }