Module help

This commit is contained in:
Michael RICOIS 2016-04-30 11:27:07 +02:00
parent d900029708
commit e1a91000f8
8 changed files with 90 additions and 174 deletions

View File

@ -22,6 +22,8 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
'auth' => __DIR__ . '/modules/auth/controllers',
'default' => __DIR__ . '/modules/default/controllers',
'file' => __DIR__ . '/modules/file/controllers',
'help' => __DIR__ . '/modules/help/controllers',
'print' => __DIR__ . '/modules/print/controllers',
'search' => __DIR__ . '/modules/search/controllers',
'user' => __DIR__ . '/modules/user/controllers',
));

View File

@ -1,108 +0,0 @@
<?php
class AideController extends Zend_Controller_Action
{
protected $theme;
public function init()
{
// --- Theme
$this->theme = Zend_Registry::get('theme');
}
/**
* Afficher bulle pour les nouveautés
*/
public function newAction()
{
$nbNewsMax = 5;
$nbJourGlisssant = 5;
$user = new Scores_Utilisateur();
$date = $user->getDateDerniereConnexion();
$nouveautes = array();
if ( $date!=null || $date!='0000-00-00 00:00:00' )
{
$time = mktime(0, 0, 0, date('m'), date('d')-$nbJourGlisssant, date('Y'));
$dateglissant = date('Y-m-d', $time);
$now = date('Y-m-d');
$nouveautesM = new Application_Model_Nouveautes();
$sql = $nouveautesM->select()
->where("date>='".$dateglissant."' AND date<='".$now."'")
->order('date DESC')
->limit($nbNewsMax);
$nouveautes = $nouveautesM->fetchAll($sql);
}
$this->view->assign('nouveautes', $nouveautes);
}
/**
* Afficher la liste des nouveautés
*/
public function newlisteAction()
{
$this->view->headTitle()->prepend('Nouveautés');
$request = $this->getRequest();
//Selection
$nouveautesM = new Application_Model_Nouveautes();
$sql = $nouveautesM->select()
->from('nouveautes', array('categorie', 'intitule', "date", 'fichier'))
->order('date DESC');
$nouveautes = $nouveautesM->fetchAll($sql);
$this->view->assign('nouveautes', $nouveautes);
}
/**
* Affichage et validation de "cgu"
* Conditions daccès à l'extranet
*/
public function cguAction()
{
$this->_helper->layout()->disableLayout();
$request = $this->getRequest();
$accept = $request->getParam('accept', 0);
if ( $accept == 1 ) {
require_once 'Scores/WsScores.php';
$ws = new WsScores();
$accept = $ws->setCGU();
Zend_Registry::get('firebug')->info($accept);
if ($accept) {
//Put in session
$auth = Zend_Auth::getInstance();
$identity = $auth->getIdentity();
$identity->acceptationCGU = date('Y-m-d H:i:s');
$auth->getStorage()->write($identity);
//Redirect
$this->redirect('/');
}
}
}
/**
* Afficher des propriétés du navigateur
* Compatibilités et version
*/
public function navinfoAction()
{
$bootstrap = $this->getInvokeArg('bootstrap');
$userAgent = $bootstrap->getResource('useragent');
$device = $userAgent->getDevice();
echo $device->getFeature('browser_compatibility').'<br/>';
echo $device->getFeature('browser_version').'<br/>';
echo "<pre>";
print_r($device);
echo "</pre>";
exit;
}
}

View File

@ -1,19 +0,0 @@
<?php if ( count($this->nouveautes)>0 ) {?>
<div style="position:absolute;width:680px;top:5px;" class="ui-state-highlight ui-corner-all">
<p>
<span style="float:left;margin-right:0.3em;" class="ui-icon ui-icon-info"></span>
<strong>Nouveau !</strong>
<?php $cpt = 0;?>
<?php foreach ( $this->nouveautes as $nouveaute) {?>
<a href="<?=$this->url(array('module'=>'file','controller'=>'index', 'action'=>'new',
'q'=>$nouveaute->fichier))?>" target="_blank">
<?=$nouveaute->intitule?></a>
<?php $cpt++;?>
<?php if ( $cpt < count($this->nouveautes) ) {?>,<?php }?>
<?php }?>
<br/>
<span style="font-size:10px;">Cliquez sur les intitulés pour consulter le document,
ou <a href="<?=$this->url(array('controller'=>'aide', 'action'=>'newliste'))?>">ici</a> pour retrouver la liste des modifications</span>
</p>
</div>
<?php }?>

View File

@ -1,42 +0,0 @@
<style>
table { width:100%; }
table th { border:1px solid; font-weight:bold; padding:5px; }
table tr { }
table td { border:1px solid; padding:5px; }
</style>
<div id="center">
<h1>Nouveautés</h1>
<div class="paragraph">
<!-- Tri par date - Tri par catégorie -->
</div>
<h2>Liste par date</h2>
<div class="paragraph">
<table>
<thead>
<tr>
<th>Date</th>
<th>Intitulé</th>
<th>Catégorie</th>
</tr>
</thead>
<tbody>
<?php if ( count($this->nouveautes)>0 ){?>
<?php foreach ( $this->nouveautes as $nouveau) {?>
<tr>
<td><?=substr($nouveau->date,8,2).'/'.substr($nouveau->date,5,2).'/'.substr($nouveau->date,0,4)?></td>
<td>
<a href="<?=$this->url(array('module'=>'file', 'controller'=>'index', 'action'=>'new',
'q'=>$nouveau->fichier))?>" target="_blank">
<?=$nouveau->intitule?></a>
</td>
<td><?=$nouveau->categorie?></td>
</tr>
<?php }?>
<?php }?>
</tbody>
</table>
</div>
</div>

View File

@ -0,0 +1,31 @@
<?php
class Help_CguController extends Zend_Controller_Action
{
/**
* Affichage et validation de "cgu"
* Conditions daccès à l'extranet
*/
public function indexAction()
{
$this->_helper->layout()->disableLayout();
$request = $this->getRequest();
$accept = $request->getParam('accept', 0);
if ( $accept == 1 ) {
require_once 'Scores/WsScores.php';
$ws = new WsScores();
$accept = $ws->setCGU();
Zend_Registry::get('firebug')->info($accept);
if ($accept) {
//Put in session
$auth = Zend_Auth::getInstance();
$identity = $auth->getIdentity();
$identity->acceptationCGU = date('Y-m-d H:i:s');
$auth->getStorage()->write($identity);
//Redirect
$this->redirect('/');
}
}
}
}

View File

@ -0,0 +1,55 @@
<?php
class Help_NewsController extends Zend_Controller_Action
{
protected $theme;
public function init()
{
// --- Theme
$this->theme = Zend_Registry::get('theme');
}
/**
* Afficher bulle pour les nouveautés
*/
public function indexAction()
{
$nbNewsMax = 5;
$nbJourGlisssant = 5;
$user = new Scores_Utilisateur();
$date = $user->getDateDerniereConnexion();
$nouveautes = array();
if ( $date!=null || $date!='0000-00-00 00:00:00' ){
$time = mktime(0, 0, 0, date('m'), date('d')-$nbJourGlisssant, date('Y'));
$dateglissant = date('Y-m-d', $time);
$now = date('Y-m-d');
$nouveautesM = new Application_Model_Nouveautes();
$sql = $nouveautesM->select()
->where("date>='".$dateglissant."' AND date<='".$now."'")
->order('date DESC')
->limit($nbNewsMax);
$nouveautes = $nouveautesM->fetchAll($sql);
}
$this->view->assign('nouveautes', $nouveautes);
}
/**
* Afficher la liste des nouveautés
*/
public function listeAction()
{
$this->view->headTitle()->prepend('Nouveautés');
$request = $this->getRequest();
//Selection
$nouveautesM = new Application_Model_Nouveautes();
$sql = $nouveautesM->select()
->from('nouveautes', array('categorie', 'intitule', "date", 'fichier'))
->order('date DESC');
$nouveautes = $nouveautesM->fetchAll($sql);
$this->view->assign('nouveautes', $nouveautes);
}
}

View File

@ -88,9 +88,9 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
}
// --- Check CGU
if ( $controller!='aide' && $action!='cgu' || $controller!='user' && $action!='logout') {
if ($module!='help' && $controller!='cgu' || $module!='auth') {
if ( empty($identity->acceptationCGU) || $identity->acceptationCGU=='0000-00-00 00:00:00' ) {
$request->setModuleName('default')->setControllerName('aide')->setActionName('cgu');
$request->setModuleName('help')->setControllerName('cgu')->setActionName('index');
}
}
@ -117,17 +117,14 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
}
// --- Pas Authentifié
else {
if ( $request->isXmlHttpRequest() ) {
$request->setModuleName('auth')->setControllerName('user')->setActionName('logout')
->setParam('ajax', 1);
} else {
$session = new Zend_Session_Namespace('login');
$session->url = $_SERVER['REQUEST_URI'];
$request->setModuleName('auth')->setControllerName('user')->setActionName('login');
}
}
}
}