コード例 #1
0
 /**
  * Modification d'un profil de cache
  */
 public function processEdit()
 {
     $type = _request('type', null);
     if ($type !== null) {
         if (!in_array($type, CopixConfig::instance()->copixcache_getRegistered())) {
             return _arRedirect(_url('admin||'));
         }
         CopixSession::set('admin|cache|edit', CopixConfig::instance()->copixcache_getType($type));
     }
     $type = CopixSession::get('admin|cache|edit');
     $ppo = new CopixPpo();
     $ppo->TITLE_PAGE = _i18n('cache.update');
     $ppo->cache = CopixSession::get('admin|cache|edit');
     //var_dump(CopixSession::get ('admin|cache|edit')); exit;
     $ppo->arStrategies = Copixcache::getStrategies();
     //Liens déjà établi
     if ($ppo->cache['link'] != "") {
         $ppo->asLinked = explode("|", $ppo->cache['link']);
     }
     $link = CopixConfig::instance()->copixcache_getRegistered();
     $finalLink = array();
     foreach ($link as $lien) {
         if (!($lien == $ppo->cache['name'] || isset($ppo->asLinked) && in_array($lien, $ppo->asLinked))) {
             $finalLink[$lien] = $lien;
         }
     }
     $ppo->arLink = $finalLink;
     return _arPpo($ppo, 'cache.update.tpl');
 }
コード例 #2
0
 /**
  *
  */
 public function processLaunch()
 {
     //Si aucun test n'est donné, on redirige vers la page de choix
     if (($test = _request('tests')) === null) {
         return _arRedirect(_url('unittest|'));
     }
     //Si on a demandé à lancer les tests avec Ajax, on génère le template d'appel pour chaque élément
     if (_request('ajax')) {
         $ppo = new CopixPpo();
         $ppo->TITLE_PAGE = 'Lancements des tests unitaires';
         $ppo->arTests = $this->_getTest();
         return _arPpo($ppo, 'tests.launch.php');
     } else {
         //on a pas demandé d'appel type ajax, donc on lance directement les tests demandés.
         if (CopixAjax::isAJAXRequest()) {
         } else {
             //C'est une demande normale, la réponse sera de type HTML
             $more = '';
         }
     }
     //On lance enfin la demande de test
     $httpClientRequest = new CopixHTTPClientRequest(CopixUrl::appendToUrl(_url() . 'test.php', array('tests' => $test, 'xml' => CopixAjax::isAJAXRequest())));
     $httpClient = new CopixHttpClient();
     $response = $httpClient->launch($httpClientRequest);
     return _arContent($response[0]->getBody(), array('content-type' => 'text/html'));
 }
コード例 #3
0
 public function processLogin()
 {
     include_once COPIX_UTILS_PATH . '../../CAS-1.2.2/CAS.php';
     $_SESSION['chartValid'] = false;
     $ppo = new CopixPPO();
     $ppo->user = _currentUser();
     if ($ppo->user->isConnected()) {
         $url_return = CopixUrl::get('kernel||doSelectHome');
         /*
          * PATCH FOR CHARTE
          */
         $this->user->forceReload();
         if (!$this->service('charte|CharteService')->checkUserValidation()) {
             $this->flash->redirect = $url_return;
             return $this->go('charte|charte|valid');
         }
         return _arRedirect($url_return);
         //return new CopixActionReturn (COPIX_AR_REDIRECT, $url_return);
     } else {
         $conf_Cas_host = CopixConfig::get('default|conf_Cas_host');
         $conf_Cas_port = CopixConfig::get('default|conf_Cas_port');
         $conf_Cas_path = CopixConfig::get('default|conf_Cas_path');
         phpCAS::client(CAS_VERSION_2_0, $conf_Cas_host, (int) $conf_Cas_port, $conf_Cas_path, false);
         phpCAS::setNoCasServerValidation();
         phpCAS::forceAuthentication();
         $ppo->cas_user = phpCAS::getUser();
         if ($ppo->cas_user) {
             $ppo->iconito_user = Kernel::getUserInfo("LOGIN", $ppo->cas_user);
             if ($ppo->iconito_user['login']) {
                 _currentUser()->login(array('login' => $ppo->iconito_user['login'], 'assistance' => true));
                 $url_return = CopixUrl::get('kernel||doSelectHome');
                 // $url_return = CopixUrl::get ('assistance||users');
                 $this->user->forceReload();
                 if (!$this->service('charte|CharteService')->checkUserValidation()) {
                     $this->flash->redirect = $url_return;
                     return $this->go('charte|charte|valid');
                 }
                 return new CopixActionReturn(COPIX_AR_REDIRECT, $url_return);
             } else {
                 $ppo->cas_error = 'no-iconito-user';
                 return _arPpo($ppo, 'cas.tpl');
             }
         }
     }
     $ppo = new CopixPPO();
     $ppo->TITLE_PAGE = $pTitle;
     phpCAS::setDebug();
     $conf_Cas_host = CopixConfig::get('default|conf_Cas_host');
     $conf_Cas_port = CopixConfig::get('default|conf_Cas_port');
     $conf_Cas_path = CopixConfig::get('default|conf_Cas_path');
     phpCAS::client(CAS_VERSION_2_0, $conf_Cas_host, (int) $conf_Cas_port, $conf_Cas_path, false);
     phpCAS::setNoCasServerValidation();
     phpCAS::forceAuthentication();
     if (isset($_REQUEST['logout'])) {
         phpCAS::logout();
     }
     die(phpCAS::getUser());
     die('ok');
     return _arPpo($ppo, 'handlers.list.tpl');
 }
コード例 #4
0
 /**
  * Fonction appellée lorsque l'on veut lister les aide saisies
  *
  */
 public function processListAide()
 {
     $ppo = new CopixPPO(array('TITLE_PAGE' => _i18n('simplehelp.title.list')));
     // Récupération des élements
     $ppo->arAides = _ioDao('simplehelp')->findAll();
     return _arPpo($ppo, 'simplehelp|simplehelp.list.tpl');
 }
コード例 #5
0
 /**
  * Formulaire de modification ou de création d'un élément en base de données
  * On édite soit a partir de données passées en paramètre
  */
 public function getEdit()
 {
     $ppo = new CopixPPO();
     $ppo->TITLE_PAGE = "Modification d'un élément";
     if (!($ppo->toEdit = _ioDAO('copixtestautodao')->get(CopixRequest::get('id_test', null, true)))) {
         throw new Exception("Impossible de retrouver l'élément demandé");
     }
     $ppo->errors = CopixRequest::get('errors', array(), true);
     return _arPpo($ppo, 'autodao.form.tpl');
 }
コード例 #6
0
 /**
  * Affichage de la liste des plugins disponibles
  */
 public function processDefault()
 {
     $ppo = new CopixPPO();
     $arPlugins = array();
     $ppo->TITLE_PAGE = _i18n('install.plugins.title');
     foreach (CopixPluginRegistry::getAvailable() as $pluginName) {
         $arPlugins[] = array('name' => $pluginName, 'enabled' => CopixPluginRegistry::isRegistered($pluginName));
     }
     $ppo->arPlugins = $arPlugins;
     return _arPpo($ppo, 'plugins.list.tpl');
 }
コード例 #7
0
 /**
  * Affichage du PHPInfo dans la charte courante.
  */
 public function processDefault()
 {
     $ppo = new CopixPPO();
     $ppo->TITLE_PAGE = _i18n('webserver.titlepage');
     ob_start();
     phpinfo();
     $info = ob_get_contents();
     ob_end_clean();
     $ppo->phpinfo = preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $info);
     return _arPpo($ppo, 'webserver.tpl');
 }
コード例 #8
0
 /**
  * Page de choix de thème
  */
 public function processDefault()
 {
     $ppo = new CopixPPO();
     $ppo->TITLE_PAGE = _i18n('admin|themes.titlePage.selectTheme');
     $arThemes = CopixPluginRegistry::getConfig('themechooser|themechooser', true)->getThemeList();
     $ppo->arThemes = array();
     foreach ($arThemes as $theme) {
         $ppo->arThemes[] = CopixTpl::getThemeInformations($theme);
     }
     $ppo->selectedTheme = CopixSession::get('themechooser|theme');
     return _arPpo($ppo, 'theme.list.tpl');
 }
コード例 #9
0
 public function processPhpinfo()
 {
     $ppo = new CopixPPO();
     $ppo->TITLE_PAGE = 'PHPInfo';
     $ppo->MENU = Admin::getMenu('phpinfo');
     $ppo->CopixVersion = COPIX_VERSION;
     ob_start();
     phpinfo();
     $info = ob_get_contents();
     ob_end_clean();
     $ppo->phpinfo = preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $info);
     return _arPpo($ppo, 'phpinfo.tpl');
 }
コード例 #10
0
 public function beforeProcess(&$action)
 {
     if (CopixConfig::get('conf_Saml_actif') != 1) {
         return;
     }
     require_once COPIX_UTILS_PATH . '../../simplesamlphp/lib/_autoload.php';
     $asId = 'iconito-sql';
     if (CopixConfig::exists('default|conf_Saml_authSource') && CopixConfig::get('default|conf_Saml_authSource')) {
         $asId = CopixConfig::get('default|conf_Saml_authSource');
     }
     $as = new SimpleSAML_Auth_Simple($asId);
     $ppo->user = _currentUser();
     if ($as->isAuthenticated() && !$ppo->user->isConnected()) {
         $attributes = $as->getAttributes();
         $uidAttribute = 'login_dbuser';
         if (CopixConfig::exists('default|conf_Saml_uidAttribute') && CopixConfig::get('default|conf_Saml_uidAttribute')) {
             $uidAttribute = CopixConfig::get('default|conf_Saml_uidAttribute');
         }
         $ppo->saml_user = null;
         if (isset($attributes[$uidAttribute]) && isset($attributes[$uidAttribute][0])) {
             $ppo->saml_user = $attributes[$uidAttribute][0];
         }
         if ($ppo->saml_user) {
             $ppo->iconito_user = Kernel::getUserInfo("LOGIN", $ppo->saml_user);
             if ($ppo->iconito_user['login']) {
                 _currentUser()->login(array('login' => $ppo->iconito_user['login'], 'assistance' => true));
                 $url_return = CopixUrl::get('kernel||doSelectHome');
                 // $url_return = CopixUrl::get ('assistance||users');
                 return new CopixActionReturn(COPIX_AR_REDIRECT, $url_return);
             } else {
                 $ppo->cas_error = 'no-iconito-user';
                 return _arPpo($ppo, 'cas.tpl');
             }
         }
     }
     if (!$as->isAuthenticated() && $ppo->user->isConnected()) {
         $ppo->user = _currentUser();
         if ($ppo->user->isConnected()) {
             CopixAuth::getCurrentUser()->logout(array());
             CopixEventNotifier::notify('logout', array('login' => CopixAuth::getCurrentUser()->getLogin()));
             CopixAuth::destroyCurrentUser();
             CopixSession::destroyNamespace('default');
         }
     }
 }
コード例 #11
0
 /**
  * Méthode qui gère réellement les handlers
  *
  * @param string $pType le type de handler que l'on gère
  * @param strng $pTitle le title de la page
  * @return ActionReturn
  */
 private function _handlers($pType, $pTitle)
 {
     $ppo = new CopixPPO();
     $ppo->TITLE_PAGE = $pTitle;
     //On lance la récupération depuis les module.xml
     $handlers = CopixModule::getParsedModuleInformation('copix|' . $pType . 'handlers', '/moduledefinition/' . $pType . 'handlers/' . $pType . 'handler', array('CopixAuthParserHandler', 'parse' . $pType . 'Handler'));
     //Instanciation de l'objet qui récupère la config dans le fichier
     _classInclude('auth|useConfigurationFile');
     $configurationFile = new useConfigurationFile($pType);
     $activeHandler = $configurationFile->get();
     $ppo->handlers = array();
     //On tri les handlers activer
     foreach ($handlers as $key => $handler) {
         $ppo->handlers[$key] = false;
         if (in_array($key, $activeHandler)) {
             $ppo->handlers[$key] = true;
         }
     }
     $ppo->type = $pType;
     return _arPpo($ppo, 'handlers.list.tpl');
 }
コード例 #12
0
 public function processList()
 {
     CopixRequest::assert('id_group', 'handler_group');
     $id_group = _request('id_group');
     $handler_group = _request('handler_group');
     $arData = array();
     $arDc = _dao('dynamiccredentials')->findAll();
     $arDroitDc = array();
     foreach ($arDc as $dc) {
         $arDroitDCTemp = new StdClass();
         $arDroitDCTemp->record = $dc;
         $arDroitDCTemp->checked = count(_dao('dynamiccredentialsgroups')->findBy(_daoSP()->addCondition('id_dc', '=', $dc->id_dc)->addCondition('id_dcv', '=', null)->addCondition('id_group', '=', $id_group)->addCondition('handler_group', '=', $handler_group))) > 0 ? 'checked' : '';
         $arDroitDCTemp->delete = true;
         $arValues = array();
         foreach (_dao('dynamiccredentialsvalues')->findBy(_daoSP()->addCondition('id_dc', '=', $dc->id_dc)->orderBy('level_dcv')) as $value) {
             $value->checked = count(_dao('dynamiccredentialsgroups')->findBy(_daoSP()->addCondition('id_dc', '=', $dc->id_dc)->addCondition('id_dcv', '=', $value->id_dcv)->addCondition('id_group', '=', $id_group)->addCondition('handler_group', '=', $handler_group))) > 0 ? 'checked' : '';
             $arValues[] = $value;
         }
         $arDroitDCTemp->data = $arValues;
         $arDroitDc[] = $arDroitDCTemp;
     }
     return _arPpo(new CopixPpo(array('id_group' => $id_group, 'handler_group' => $handler_group, 'list' => $arDroitDc, 'url_return' => _request('url_return', _url('#')))), 'dynamics.list.php');
 }
コード例 #13
0
 /**
  * Mise a jour du module
  */
 public function processUpdateModule()
 {
     return _arPpo(new CopixPPO(array('TITLE_PAGE' => _i18n('install.title.updateModule', _request('moduleName')), 'module' => _request('moduleName'))), 'admin|updatemodule.tpl');
 }
コード例 #14
0
 /**
  * Affiche le PHPInfo
  */
 public function processPHPInfo()
 {
     CopixAuth::getCurrentUser()->assertCredential('basic:admin');
     $ppo = new CopixPPO();
     $ppo->TITLE_PAGE = 'PHPInfo';
     $ppo->CopixVersion = COPIX_VERSION;
     ob_start();
     phpinfo();
     $info = ob_get_contents();
     ob_end_clean();
     $ppo->phpinfo = preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $info);
     return _arPpo($ppo, 'phpinfo.tpl');
 }
コード例 #15
0
 public function processLogout_Cas()
 {
     $ppo = new CopixPPO();
     $ppo->conf_Saml_CasLogoutUrl = CopixConfig::exists('default|conf_Saml_caslogouturl') ? CopixConfig::get('default|conf_Saml_caslogouturl') : 0;
     if ($ppo->conf_Saml_CasLogoutUrl) {
         CopixHTMLHeader::addOthers('<meta HTTP-EQUIV="REFRESH" content="3; url=' . _url('||') . '"');
     }
     return _arPpo($ppo, 'saml_logout_cas.tpl');
 }
コード例 #16
0
 /**
  * Confirmation de l'installation et affichage des infos login / mot de passe
  *
  * @return CopixActionReturn
  */
 public function processDone()
 {
     _currentUser()->logout();
     if (($loginInformations = CopixSession::get('admin|database|loginInformations')) !== null) {
         //CopixSession::set ('admin|database|loginInformations', null);
         $ppo = new CopixPpo();
         $ppo->TITLE_PAGE = _i18n("install.result.installok");
         $ppo->loginInformations = $loginInformations;
         return _arPpo($ppo, 'install.done.tpl');
     }
     return _arRedirect(_url('||'));
 }
コード例 #17
0
 /**
  * Modification d'un profil de log
  */
 public function processEdit()
 {
     if ($profile = _request('profile')) {
         if (!in_array($profile, CopixConfig::instance()->copixLog_getRegistered())) {
             return _arRedirect(_url('admin||'));
         }
         CopixSession::set('admin|log|edit', CopixConfig::instance()->copixlog_getProfile($profile));
     }
     $ppo = new CopixPpo();
     $ppo->TITLE_PAGE = _i18n('logs.update');
     $ppo->log = CopixSession::get('admin|log|edit');
     if (!isset($ppo->log['email'])) {
         $ppo->log['email'] = '';
     }
     $ppo->arErrors = array();
     if (_request('error') !== null) {
         $ppo->arErrors[] = _i18n('logs.error.' . _request('error'));
     }
     $ppo->arStrategies = CopixLog::getStrategies();
     $ppo->arLevel = CopixLog::getLevels();
     return _arPpo($ppo, 'log.update.tpl');
 }
コード例 #18
0
 public function processList()
 {
     CopixRequest::assert('id_group', 'handler_group');
     $id_group = _request('id_group');
     $handler_group = _request('handler_group');
     $arDroit = array();
     $arDroitSansModule = array();
     foreach (CopixModule::getList() as $module) {
         $arDroitSansModule = array_merge($arDroitSansModule, CopixModule::getInformations($module)->credential_notspecific);
         $arDroit[$module] = CopixModule::getInformations($module)->credential;
         //Creation des droits si ils n'existent pas
         foreach ($arDroit[$module] as $name => $values) {
             $results = _dao('modulecredentials')->findBy(_daoSP()->addCondition('name_mc', '=', $name)->addCondition('module_mc', '=', $module));
             $id_mc = null;
             if (count($results) == 0) {
                 $record = _record('modulecredentials');
                 $record->name_mc = $name;
                 $record->module_mc = $module;
                 _dao('modulecredentials')->insert($record);
                 $id_mc = $record->id_mc;
             } else {
                 $id_mc = $results[0]->id_mc;
             }
             foreach ($values as $value) {
                 $results = _dao('modulecredentialsvalues')->findBy(_daoSP()->addCondition('id_mc', '=', $id_mc)->addCondition('value_mcv', '=', $value->name)->addCondition('level_mcv', '=', $value->level));
                 if (count($results) == 0) {
                     $record = _record('modulecredentialsvalues');
                     $record->id_mc = $id_mc;
                     $record->value_mcv = $value->name;
                     $record->level_mcv = $value->level;
                     _dao('modulecredentialsvalues')->insert($record);
                 }
             }
         }
         //Fin de création des droits
     }
     $arData = array();
     $arModuleCredential = _dao('modulecredentials')->findBy(_daoSP()->groupBy('module_mc'));
     foreach ($arModuleCredential as $module) {
         $module = $module->module_mc;
         $droits = new StdClass();
         $droits->name = $module;
         $droits->delete = false;
         if ($module != null) {
             if (!isset($arDroit[$module]) || count($arDroit[$module]) == 0) {
                 $droits->delete = true;
             }
         }
         $arMc = _dao('modulecredentials')->findBy(_daoSP()->addCondition('module_mc', '=', $module));
         $arDroitMc = array();
         foreach ($arMc as $mc) {
             $arDroitMCTemp = new stdClass();
             $arDroitMCTemp->record = $mc;
             $arDroitMCTemp->checked = count(_dao('modulecredentialsgroups')->findBy(_daoSP()->addCondition('id_mc', '=', $mc->id_mc)->addCondition('id_mcv', '=', null)->addCondition('id_group', '=', $id_group)->addCondition('handler_group', '=', $handler_group))) > 0 ? 'checked' : '';
             $arDroitMCTemp->delete = true;
             if ($module != null) {
                 if (isset($arDroit[$module]) && isset($arDroit[$module][$mc->name_mc])) {
                     $arDroitMCTemp->delete = false;
                 }
             } else {
                 if (isset($arDroitSansModule[$mc->name_mc])) {
                     $arDroitMCTemp->delete = false;
                 }
             }
             $arValues = array();
             foreach (_dao('modulecredentialsvalues')->findBy(_daoSP()->addCondition('id_mc', '=', $mc->id_mc)->orderBy('level_mcv')) as $value) {
                 $value->checked = count(_dao('modulecredentialsgroups')->findBy(_daoSP()->addCondition('id_mc', '=', $mc->id_mc)->addCondition('id_mcv', '=', $value->id_mcv)->addCondition('id_group', '=', $id_group)->addCondition('handler_group', '=', $handler_group))) > 0 ? 'checked' : '';
                 $value->delete = true;
                 if ($module != null) {
                     if (isset($arDroit[$module]) && isset($arDroit[$module][$mc->name_mc])) {
                         $valueName = $value->value_mcv;
                         foreach ($arDroit[$mc->module_mc][$mc->name_mc] as $ssDroit) {
                             if ($ssDroit->name == $valueName) {
                                 $value->delete = false;
                             }
                         }
                     }
                 } else {
                     if (isset($arDroitSansModule[$mc->name_mc])) {
                         $valueName = $value->value_mcv;
                         foreach ($arDroitSansModule[$mc->name_mc] as $ssDroit) {
                             if ($ssDroit->name == $valueName) {
                                 $value->delete = false;
                             }
                         }
                     }
                 }
                 $arValues[] = $value;
             }
             $arDroitMCTemp->data = $arValues;
             $arDroitMc[] = $arDroitMCTemp;
         }
         $droits->data = $arDroitMc;
         $arData[] = $droits;
     }
     //Le groupe en cours de modification est en session, on peut le récupérer.
     if ($group = CopixSession::get('auth|group')) {
         $groupName = $group->id_dbgroup === null ? _i18n('auth.newGroup') : $group->caption_dbgroup;
     } else {
         $groupName = _i18n('auth.newGroup');
     }
     return _arPpo(new CopixPpo(array('TITLE_PAGE' => _i18n('auth.editModuleCredentials', $groupName), 'id_group' => $id_group, 'handler_group' => $handler_group, 'list' => $arData, 'url_return' => _request('url_return', _url('#')))), 'modules.list.php');
 }
コード例 #19
0
 /**
  * Fonction permettant d'afficher une exception à l'écran.
  * Principalement destinée à l'utilisation interne, pas nécessairement à l'utilisation depuis l'url
  *
  */
 public function processException()
 {
     CopixRequest::assert('exception');
     $e = _request('exception');
     //Absolument impossible dans le contexte normal d'utilisation, $e est nécessairement une exception
     //catchée par le processus.
     if (!$e instanceof Exception) {
         return _arRedirect(_url('||'));
     }
     $ppo = new CopixPPO();
     $ppo->TITLE_PAGE = _request('TITLE_PAGE', get_class($e));
     switch (get_class($e)) {
         case 'CopixDAOCheckException':
             $ppo->message = sprintf('Une erreur de validation est survenue avec le message [%s]', implode(', ', $e->getErrors()));
             break;
         default:
             $ppo->message = $e->getMessage();
     }
     $ppo->type = get_class($e);
     $ppo->file = $e->getFile();
     $ppo->line = $e->getLine();
     $ppo->trace = $e->getTrace();
     $ppo->id = uniqid();
     $ppo->urlBack = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
     switch (CopixConfig::instance()->getMode()) {
         case CopixConfig::DEVEL:
             $ppo->mode = 'DEVEL';
             break;
         case CopixConfig::PRODUCTION:
             $ppo->mode = 'FORCE_INITIALISATION';
             break;
         case CopixConfig::FORCE_INITIALISATION:
             $ppo->mode = 'FORCE_INITIALISATION';
             break;
         default:
             $ppo->mode = 'UNKNOW';
             break;
     }
     return _arPpo($ppo, 'default|exception.tpl');
 }
コード例 #20
0
 /**
  * Affichage du contenu de la session dans une popup
  */
 public function processShow()
 {
     $ppo = $this->_getShowPPO();
     $ppo->popup = CopixRequest::get('popup');
     return _arPpo($this->_getShowPPO(), $ppo->popup ? array('template' => 'session.show.tpl', 'mainTemplate' => '|blank.tpl') : 'session.show.tpl');
 }