1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
class GepadbalsController extends AppController
{
var $name = 'Gepadbals';
//appel des composants
public $components = array('gestionBal','zimbraAdmin','xmlParse','RequestHandler');
/**
* Fonction de connexion
* @return type
*/
public function login()
{
$cas = new phpCAS();
if($this->request->is('get'))
{
$etablissement = $this->request->pass;
$casHost = null; $domain = null;
if(isset($etablissement[0]))
{
switch ($etablissement[0])
{
case 1:
$casHost = "cas-ujf.grenet.fr";
$domain = "ujf-grenoble.fr";
break;
case 2:
$casHost = "cas-upmf.grenet.fr";
$domain = "upmf-grenoble.fr";
break;
case 3:
$casHost = "cas-ugr3.grenet.fr";
$domain = "u-grenoble3.fr";
break;
}
//redirection vers le serveur CAS pour authentification
$cas->client(CAS_VERSION_2_0,$casHost,443,'');
$cas->setNoCasServerValidation();
$cas->forceAuthentication();
//enregistrement des informations de session
$this->Session->write('username', $cas->getUser());
$this->Session->write('domain', $domain);
//Redirection vers index
if($cas->checkAuthentication()){$this->index();}
}
}
}
/**
* index method
* Page d'entrée
* @return void
*/
public function index()
{
$this->autoRender = false;
if($this->Session->read('username'))
{
//Définition des variables locales
$CN = null; $tabMail = null;
//Récupération des informations du compte logué
$account = $this->gestionBal->verifExistAccount($this->Session->read('username').'@'.$this->Session->read('domain'));
//Récupération de l'identitée du compte logué
$this->Session->write('mail', $account["ACCOUNT"]["NAME"]);
foreach($account["ACCOUNT"]["A"] as $arrayid)
{if(isset($arrayid["N"]) && $arrayid["N"]=="cn"){$CN=$arrayid["DATA"];}}
$addInst = json_decode(file_get_contents('http://zimbrapartage:sfth8:drt82@webdsi.upmf-grenoble.fr/BIPER4-WS-dev/rest/annuaire.php?q=/personnesMorales/comptes/3'));
foreach($addInst as $list)
{
if(is_array($list))
{
foreach($list as $objectStdClass)
{
foreach($objectStdClass as $key=>$value)
{
if($key == "mail_prefere")
{
$listePartage = $this->gestionBal->recuperationPartage($value);
if($listePartage != null)
{
foreach($listePartage as $mailRecevant => $droit)
{
if($mailRecevant == $this->Session->read('mail') && strpos($droit,"x"))
{$tabMail[]=$value;}
}
}
}
}
}
}
}
//Modélisation des informations;
$data['cn'] = $CN;
$data['error'] = null;
$data['identite'] = $tabMail;
//Envoie des informations au template
$this->set($data);
$this->render('index');
}
else {$this->redirect("http://gepadbal.u-grenoble3.fr/gepadbals/login");}
}
/**
* add method
* reçoit le mail qui doit recevoir le partage
* vérifie la validité du compte et des partages existants
* @return void
*/
public function add()
{
$this->autoRender = false;
var_dump($_SESSION);
/*if($this->Session->read('username'))
{
//Récupération du mail à partager
$mailAPartager = $this->request->params['pass'][0];
//Récupération des mails qui reçoivent déjà ce partage
$tabIdentite = $this->gestionBal->recupIdentities($mailAPartager);
//var_dump($tabIdentite);
$data['mail'] = $mailAPartager;
$data['identite'] = null;
$data['error'] = null;
$data['cn'] = $this->request->params['pass'][1];
if(!$this->gestionBal->getGb_error())
{
if(isset($tabIdentite[0]["zimbraPrefFromAddress"]))
{$data['identite'] = $tabIdentite;}
}
else {$data['error'] = $this->gestionBal->getGb_error();}
$this->set($data);
$this->render('add');
}
else {$this->redirect("http://gepadbal.u-grenoble3.fr/gepadbals/login");}*/
} |