Пример #1
0
 /**
  * Action used to redirect request made to root of tao.
  */
 public function rootEntry()
 {
     if (\common_session_SessionManager::isAnonymous()) {
         /* @var $urlRouteService DefaultUrlService */
         $urlRouteService = $this->getServiceManager()->get(DefaultUrlService::SERVICE_ID);
         $this->redirect($urlRouteService->getLoginUrl());
     } else {
         $this->redirect(_url('entry', 'Main', 'tao'));
     }
 }
 /**
  * retrieve the logged in user
  *
  * @access public
  * @author Jerome Bogaerts, <*****@*****.**>
  * @return core_kernel_classes_Resource
  */
 public function getCurrentUser()
 {
     $returnValue = null;
     if (!common_session_SessionManager::isAnonymous()) {
         $userUri = \common_session_SessionManager::getSession()->getUser()->getIdentifier();
         if (!empty($userUri)) {
             $returnValue = new core_kernel_classes_Resource($userUri);
         } else {
             common_Logger::d('no userUri');
         }
     }
     return $returnValue;
 }
Пример #3
0
 /**
  * First page, when arriving on a system
  * to choose front or back office
  */
 public function entry()
 {
     $entries = array();
     foreach (EntryPointService::getRegistry()->getEntryPoints() as $entry) {
         if (tao_models_classes_accessControl_AclProxy::hasAccessUrl($entry->getUrl())) {
             $entries[] = $entry;
         }
     }
     if (empty($entries)) {
         // no access -> error
         if (common_session_SessionManager::isAnonymous()) {
             /* @var $urlRouteService DefaultUrlService */
             $urlRouteService = $this->getServiceManager()->get(DefaultUrlService::SERVICE_ID);
             $this->redirect($urlRouteService->getLoginUrl());
         } else {
             common_session_SessionManager::endSession();
             return $this->returnError(__('You currently have no access to the platform'));
         }
     } elseif (count($entries) == 1 && !common_session_SessionManager::isAnonymous()) {
         // single entrypoint -> redirect
         $entry = current($entries);
         return $this->redirect($entry->getUrl());
     } else {
         // multiple entries -> choice
         if (!common_session_SessionManager::isAnonymous()) {
             $this->setData('user', common_session_SessionManager::getSession()->getUserLabel());
         }
         $this->setData('entries', $entries);
         $naviElements = $this->getNavigationElementsByGroup('settings');
         foreach ($naviElements as $key => $naviElement) {
             if ($naviElement['perspective']->getId() !== 'user_settings') {
                 unset($naviElements[$key]);
                 continue;
             }
         }
         $this->setData('userLabel', \common_session_SessionManager::getSession()->getUserLabel());
         $this->setData('settings-menu', $naviElements);
         $this->setData('current-section', $this->getRequestParameter('section'));
         $this->setData('content-template', array('blocks/entry-points.tpl', 'tao'));
         $this->setView('layout.tpl', 'tao');
     }
 }
 /**
  * First page, when arriving on a system
  * to choose front or back office
  */
 public function entry()
 {
     $entries = array();
     foreach (MenuService::getEntryPoints() as $entry) {
         if ($entry->hasAccess()) {
             $entries[] = $entry;
         }
     }
     if (empty($entries)) {
         // no access -> error
         if (common_session_SessionManager::isAnonymous()) {
             return $this->redirect(_url('login'));
         } else {
             common_session_SessionManager::endSession();
             return $this->returnError(__('You currently have no access to the platform'));
         }
     } elseif (count($entries) == 1 && !common_session_SessionManager::isAnonymous()) {
         // single entrypoint -> redirect
         $entry = current($entries);
         return $this->redirect($entry->getUrl());
     } else {
         // multiple entries -> choice
         if (!common_session_SessionManager::isAnonymous()) {
             $this->setData('user', common_session_SessionManager::getSession()->getUserLabel());
         }
         $this->setData('entries', $entries);
         $naviElements = $this->getNavigationElementsByGroup('settings');
         foreach ($naviElements as $key => $naviElement) {
             if ($naviElement['perspective']->getId() !== 'user_settings') {
                 unset($naviElements[$key]);
                 continue;
             }
         }
         $this->setData('userLabel', \common_session_SessionManager::getSession()->getUserLabel());
         $this->setData('settings-menu', $naviElements);
         $this->setData('content-template', array('blocks/entry-points.tpl', 'tao'));
         $this->setView('layout.tpl', 'tao');
     }
 }
Пример #5
0
 /**
  * Load external resources for the current context
  * @see tao_helpers_Scriptloader
  */
 protected function scripts()
 {
     $assetService = $this->getServiceManager()->get(AssetService::SERVICE_ID);
     $cssFiles = array($assetService->getJsBaseWww('tao') . 'css/layout.css', $assetService->getJsBaseWww('tao') . 'css/tao-main-style.css', $assetService->getJsBaseWww('tao') . 'css/tao-3.css');
     //stylesheets to load
     \tao_helpers_Scriptloader::addCssFiles($cssFiles);
     if (\common_session_SessionManager::isAnonymous()) {
         \tao_helpers_Scriptloader::addCssFile($assetService->getJsBaseWww('tao') . 'css/portal.css');
     }
 }
Пример #6
0
 /**
  * Short description of method setPropertyValueByLg
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  Resource resource
  * @param  Property property
  * @param  string value
  * @param  string lg
  * @return boolean
  */
 public function setPropertyValueByLg(core_kernel_classes_Resource $resource, core_kernel_classes_Property $property, $value, $lg)
 {
     $returnValue = (bool) false;
     $platform = $this->getPersistence()->getPlatForm();
     $userId = \common_session_SessionManager::isAnonymous() ? null : \common_session_SessionManager::getSession()->getUser()->getIdentifier();
     $mask = 'yyy[admin,administrators,authors]';
     //now it's the default right mode
     $query = 'INSERT INTO statements (modelid,subject,predicate,object,l_language,author,epoch)
     			VALUES  (?, ?, ?, ?, ?, ?, ?)';
     $returnValue = $this->getPersistence()->exec($query, array($this->getNewTripleModelId(), $resource->getUri(), $property->getUri(), $value, $property->isLgDependent() ? $lg : '', $userId, $platform->getNowExpression()));
     return (bool) $returnValue;
 }
Пример #7
0
 /**
  * Short description of method duplicate
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  Resource resource
  * @param  array excludedProperties
  * @return core_kernel_classes_Resource
  */
 public function duplicate(core_kernel_classes_Resource $resource, $excludedProperties = array())
 {
     $returnValue = null;
     $newUri = common_Utils::getNewUri();
     $collection = $this->getRdfTriples($resource);
     if ($collection->count() > 0) {
         $platform = $this->getPersistence()->getPlatForm();
         $multipleInsertQueryHelper = $platform->getMultipleInsertsSqlQueryHelper();
         $user = common_session_SessionManager::isAnonymous() ? $platform->getNullString() : $this->getPersistence()->quote(\common_session_SessionManager::getSession()->getUser()->getIdentifier());
         $columns = array("modelid", "subject", "predicate", "object", "l_language", "author", "epoch");
         $query = $multipleInsertQueryHelper->getFirstStaticPart('statements', $columns);
         foreach ($collection->getIterator() as $triple) {
             if (!in_array($triple->predicate, $excludedProperties)) {
                 $query .= $multipleInsertQueryHelper->getValuePart('statements', $columns, array("modelid" => $this->getNewTripleModelId(), "subject" => $this->getPersistence()->quote($newUri), "predicate" => $this->getPersistence()->quote($triple->predicate), "object" => $triple->object == null ? $platform->getNullString() : $this->getPersistence()->quote($triple->object), "l_language" => $triple->lg == null ? $platform->getNullString() : $this->getPersistence()->quote($triple->lg), "author" => $user, "epoch" => $this->getPersistence()->quote($platform->getNowExpression())));
             }
         }
         $query = substr($query, 0, strlen($query) - 1);
         $query .= $multipleInsertQueryHelper->getEndStaticPart();
         if ($this->getPersistence()->exec($query)) {
             $returnValue = new core_kernel_classes_Resource($newUri);
         }
     }
     return $returnValue;
 }
Пример #8
0
 /**
  * Load external resources for the current context
  * @see tao_helpers_Scriptloader
  */
 protected function scripts()
 {
     $cssFiles = array(TAOBASE_WWW . 'css/layout.css', TAOBASE_WWW . 'css/tao-main-style.css', TAOBASE_WWW . 'css/tao-3.css');
     //stylesheets to load
     \tao_helpers_Scriptloader::addCssFiles($cssFiles);
     if (\common_session_SessionManager::isAnonymous()) {
         \tao_helpers_Scriptloader::addCssFile(TAOBASE_WWW . 'css/portal.css');
     }
     //ajax file upload works only without HTTP_AUTH
     if (!USE_HTTP_AUTH) {
         \tao_helpers_Scriptloader::addCssFile(TAOBASE_WWW . 'js/lib/jquery.uploadify/uploadify.css');
     }
 }
Пример #9
0
 /**
  * Indicates if an Authenticated Session is open.
  *
  * @access public
  * @author Jerome Bogaerts, <*****@*****.**>
  * @return boolean
  */
 public function isASessionOpened()
 {
     return !common_session_SessionManager::isAnonymous();
 }
Пример #10
0
 /**
  * Check if it is time to perform an action.
  * If `$this->lastExecution` is null (action has never been executed)
  * or since the last execution took time more than specified interval (`$this->interval`) then action must be performed.
  * @return bool
  */
 protected function checkTime()
 {
     $result = false;
     $lastExecution = $this->getExecutionTime();
     $interval = $this->getInterval();
     $anonymous = \common_session_SessionManager::isAnonymous();
     if ($lastExecution === null && !$anonymous) {
         $result = true;
     } elseif ($lastExecution !== null && $interval !== null && !$anonymous) {
         $mustBeExecutedAt = clone $lastExecution;
         $mustBeExecutedAt->add($interval);
         $now = new DateTime('now');
         $result = $mustBeExecutedAt < $now;
     }
     return $result;
 }
Пример #11
0
 /**
  * Build script element for AMD loader
  *
  * @return string
  */
 public static function getAmdLoader()
 {
     if (\common_session_SessionManager::isAnonymous()) {
         $amdLoader = array('src' => Template::js('lib/require.js', 'tao'), 'data-main' => TAOBASE_WWW . 'js/login', 'data-config' => get_data('client_config_url'));
     } else {
         if (\tao_helpers_Mode::is('production')) {
             $amdLoader = array('src' => Template::js('main.min.js', 'tao'), 'data-config' => get_data('client_config_url'));
         } else {
             $amdLoader = array('src' => Template::js('lib/require.js', 'tao'), 'data-config' => get_data('client_config_url'), 'data-main' => TAOBASE_WWW . 'js/main');
         }
     }
     $amdScript = '<script id="amd-loader" ';
     foreach ($amdLoader as $attr => $value) {
         $amdScript .= $attr . '="' . $value . '" ';
     }
     return trim($amdScript) . '></script>';
 }
Пример #12
0
 /**
  * Create the AMD loader for the current context.
  * It will load login's modules for anonymous session.
  * Loads the bundle mode in production and the dynamic mode in debug.
  *
  * @param string $bundle the bundle URL
  * @param string $controller the controller module id
  * @param array  $params additional parameters
  * @return string the script tag
  */
 public static function getAmdLoader($bundle = null, $controller = null, $params = null)
 {
     $bundleMode = \tao_helpers_Mode::is('production');
     $configUrl = get_data('client_config_url');
     $requireJsUrl = Template::js('lib/require.js', 'tao');
     $bootstrapUrl = Template::js('loader/bootstrap', 'tao');
     $loader = new AmdLoader($configUrl, $requireJsUrl, $bootstrapUrl);
     if (\common_session_SessionManager::isAnonymous()) {
         $controller = 'controller/login';
         $bundle = Template::js('loader/login.min.js', 'tao');
     }
     if ($bundleMode) {
         return $loader->getBundleLoader($bundle, $controller, $params);
     }
     return $loader->getDynamicLoader($controller, $params);
 }