200 lines
7.8 KiB
PHP
Executable File

<?php
/**-----------------------------------------------
*
* Rooty, 2018 <rooty@rooty.me>
*
*
* This software is protected by copyright, please
* read the file COPYRIGHT.
* This program is distributed in the hope that it
* will be useful, but without any warranty; without
* even the implied warranty of merchantability or
* fitness for a particular purpose. Please
* read the file LICENCE.
*
* Fichier UserPrint.php
*
* Ce fichier contient la classe UserPrint
*
* @author Initiance <www.initiance.com|martial@initiance.com>
* @copyright Copyright &copy; 2009-2018, Rooty
* @since 2004/06/07
* @version 0.3
* @link www.rooty.me
* @package object_printing
* @subpackage UserPrint
*/
if ( !defined('SYSTEM_IN') )
{
die("Hacking attempt");
}
/**
* Classe UserPrint
*<p>Cette classe permet la recuperation des UserPrint</p>
* @package object_printing
* @subpackage UserPrint
*/
class UserPrint extends Printing
{
//
// Constructor
//
/**
* Constructeur de la classe UserPrint
* @access public
*/
function UserPrint()
{
$this->__construct();
}
function __construct()
{
parent::__construct("1.0", "Olivier DEVAINE", "Affichage soit du formulaire d'UserPrint, soit de déconnection (avec les infos utilisateurs)");
}
/**
* Remplace dans la template principale
* @access public
*/
function __print()
{
global $SERVER_NAME, $SCRIPT_NAME, $CONF_AUTH_SECURE;
if ($GLOBALS["SYSTEM_USER_SESSION"]->user->getId()==$GLOBALS["SYSTEM_DEFAULT_USER_GUEST"])
{
$nodeId = $GLOBALS["SYSTEM_USER_SESSION"]->navigationNodeId;
$GLOBALS['SYSTEM_TEMPLATE']->MxText("imgPath", $GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']);
$MaTemplate = new ModeliXeQware($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_printing/userprint/auth.mxt");
//$template->SetMxFileParameter($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['TEMPLATE_DIR'].$GLOBALS['TEMPLATE_CONF']);
$MaTemplate->SetModeliXe(true);
/* création de l'url de login */
$url =$_SERVER['SCRIPT_NAME'];
$url.="?system=authSession";
$url=addIdToUrl($url);
$tabObject =$this->getObjectSon(eid());
for ($i=0; $i<count($tabObject);$i++)
{
if ($tabObject[$i][0]->getClassName()=="home")
{
$urlArray["id"]=$tabObject[$i][1]->getId();
}
}
/* Création de l'URL pour nouveau compte */
$urlNewAccount = $_SERVER['SCRIPT_NAME'];
$urlNewAccount.= "?system=authNewAccount";
$urlNewAccount = addIdToUrl($urlNewAccount);
// if( isset($_SERVER["HTTPS"]) )
// $proto = "https://";
// else
// $proto = "http://";
// $MaTemplate->MxAttribut("urlActionNewAccount", $proto."www.fab-l3.org/wwwfab_lorg-142-les_communautes-formlecture-2.htm?abs=1&amp;param=139");
$MaTemplate->MxAttribut("urlActionNewAccount", formatUrl($urlArray["id"],"Home","formLecture","",$this->recupCommunauty()));
$MaTemplate->MxAttribut("urlActionNewSubscription", formatUrl($urlArray["id"],"Home","formLectureAdh","",$this->recupCommunauty()));
/* Création de l'URL pour rappel du mot de passe */
$urlForgotPassword = $_SERVER['SCRIPT_NAME'];
// $urlForgotPassword.= "?system=authForgotPassword";
$urlForgotPassword.= "?msg=forgotPasswordTempDisabled";
$urlForgotPassword = addIdToUrl($urlForgotPassword);
/* picto en fonction de la template */
$MaTemplate->MxImage("pictoAuth", $GLOBALS['CONF_DATA_PATH']."data/template/".$GLOBALS['SYSTEM_TEMPLATE_DIR']."media/picto/authorise.png");
$MaTemplate->MxText("auth", getMessage("UserPrintAuth"));
$MaTemplate->MxText("LOGIN", getMessage("UserPrintLogin"));
$MaTemplate->MxFormField("login", "text", "login", "", "title='".getMessage("tipUserPrintLogin")."'");
$MaTemplate->MxText("PASSWORD", getMessage("UserPrintPassword"));
$MaTemplate->MxFormField("password", "password", "password", "", "title='".getMessage("tipUserPrintPassword")."'");
$MaTemplate->MxAttribut("urlActionNewAccount", $urlNewAccount);
$MaTemplate->MxText("NEWACCOUNT", getMessage("UserPrintNewAccount"));
$MaTemplate->MxText("NEWSUBSCRIPTION", getMessage("UserPrintNewSubscription"));
$MaTemplate->MxAttribut("urlActionForgotPassword", $urlForgotPassword);
$MaTemplate->MxText("FORGOTPASSWORD", getMessage("UserPrintForgotPassword"));
$MaTemplate->MxAttribut("urlActionLogin", $url);
$MaTemplate->MxAttribut("BtnEnter", getMessage("UserPrintEnter"));
$MaTemplate->MxText("BtnEnter", getMessage("UserPrintEnter"));
$MaTemplate->MxAttribut("titleButton", getMessage("tipUserPrintEnter"));
$data=$MaTemplate->MxWrite();
}else{
$MaTemplate = new ModeliXeQware($GLOBALS['SYSTEM_TEMPLATE_PATH'].$GLOBALS['SYSTEM_TEMPLATE_DIR']."object_printing/userprint/userinfo.mxt");
$MaTemplate->SetModeliXe(true);
/* picto en fonction de la template */
$MaTemplate->MxImage("picto", $GLOBALS['CONF_DATA_PATH']."data/template/".$GLOBALS['SYSTEM_TEMPLATE_DIR']."media/picto/user.png");
$MaTemplate->MxText("firstName", $GLOBALS["SYSTEM_USER_SESSION"]->user->getFirstName());
$MaTemplate->MxText("lastName", $GLOBALS["SYSTEM_USER_SESSION"]->user->getLastName());
$MaTemplate->MxText("id", $GLOBALS["SYSTEM_USER_SESSION"]->user->getId());
$MaTemplate->MxText("mail", $GLOBALS["SYSTEM_USER_SESSION"]->user->getMail());
$MaTemplate->MxText("organisation", $GLOBALS["SYSTEM_USER_SESSION"]->user->getOrganisation());
$MaTemplate->MxText("title", $GLOBALS["SYSTEM_USER_SESSION"]->user->getTitle());
$MaTemplate->MxText("postalAddress", $GLOBALS["SYSTEM_USER_SESSION"]->user->getPostalAddress());
$MaTemplate->MxText("postalCode", $GLOBALS["SYSTEM_USER_SESSION"]->user->getPostalCode());
$MaTemplate->MxText("state", $GLOBALS["SYSTEM_USER_SESSION"]->user->getState());
$MaTemplate->MxText("country", $GLOBALS["SYSTEM_USER_SESSION"]->user->getCountry());
$MaTemplate->MxText("login", $GLOBALS["SYSTEM_USER_SESSION"]->user->getLogin());
$MaTemplate->MxText("tel", $GLOBALS["SYSTEM_USER_SESSION"]->user->getTel());
$MaTemplate->MxText("decon", getMessage("UserPrintDecon"));
$MaTemplate->MxAttribut("decon", getMessage("UserPrintDecon"));
$MaTemplate->MxText("fax", $GLOBALS["SYSTEM_USER_SESSION"]->user->getFax());
$MaTemplate->MxText("TxtWelcome", getMessage("TxtWelcome"));
/* création de l'url de login */
$url =$_SERVER['SCRIPT_NAME'];
$url.="?system=disconnectSession";
$url=addIdToUrl($url);
/* picto en fonction de la template */
$MaTemplate->MxAttribut("pictoDisco", $GLOBALS['CONF_DATA_PATH']."data/template/".$GLOBALS['SYSTEM_TEMPLATE_DIR']."media/picto/exit.png");
$MaTemplate->MxAttribut("disconnect", $url);
$data=$MaTemplate->MxWrite();
}
$GLOBALS["SYSTEM_TEMPLATE"]->MxText("userprint", $data); // Et voila!!!!!
return true;
}
/**
* recupere les fils d'un noeud depuis le noeud principal
* @access public
*/
private function getObjectSon($nodeId)
{
$tab=$GLOBALS["SYSTEM_CONTROL"]->getListObjectForNavigation($nodeId);
return $tab;
}
/**
* Function permettant de modifier le contenu dans la bd et redirection
* @access private
* @return chaine entier noeud de configuration
*/
function recupCommunauty($get='id',$langcode="fr")
{
/* Récupération de la communauté courante */
$myEntryNode =$GLOBALS["SYSTEM_USER_SESSION"]->entryNodeId; /* Noeud d'entrée de l'utilisateur */
$myTree =$GLOBALS["SYSTEM_MANAGER"]["TREE_NODE"]->createInstance($myEntryNode); /* Récupération du Tree correspondant */
$nodeId=NULL;
for ($i=0; $i<count($myTree->tabFather); $i++)
{
if ($myTree->tabFather[$i]->getIdPere()==1)
{
if( $get == 'id' ) { $nodeId=$myTree->tabFather[$i]->getId();}
elseif( $get == 'ctype' ) { $nodeId=$myTree->tabFather[$i]->getCType();}
elseif( $get == 'lib' ) {$nodeId=$myTree->tabFather[$i]->getLibelle($langcode);}
break;
}
}
if (is_null($nodeId))
{
systemRedirect( $GLOBALS["CONF_PAGE_EXECUTION"] );
}
/* -- Fin Recup Communauté */
return $nodeId;
}
}
?>