the "correct" way to do that is to extend the location plugin and replace
the function generating/returning the recenter.tpl
<?php
/**
* Overrides the plugin Location
*/
class ClientLocationExtended extends ClientLocation {
public function replacePlugin() {
return 'location';
}
protected function drawRecenter() {
$this->smarty = new Smarty_Plugin($this->getCartoclient(), $this);
$tplFile = 'recenter.tpl';
$sm = SecurityManager::getInstance();
$hasRoleMyrole = $sm->hasRole('testblablabla');
if ($hasRoleMyrole) {
$tplFile = 'some_other_recenter.tpl';
}
return $this->smarty->fetch($tplFile);
}
}
?>
make a new locationExtended/client/ folders and create a new file name
ClientLocationExtended.php
activate that plugin in your client.ini
regards
Oliver
Yes, I want to generate myplugin.tpl file dinamically respect to the role
of the user. I did this simply modifying ClientAuth.php and fwrite
function (with "w" access).
Thanks a lot!
Fabio
Hi!
From my own plugin I want to generate dinamically .tpl file after
querying a table in the database linked to auth plugin trought
dbSecurityDsn = pgsql://......
dbSecurityQueryUser = "SELECT * FROM operatori WHERE op_login='%s' AND
op_password='%s'"
dbSecurityQueryRoles = "SELECT cast(id_operatore AS text) FROM operatori
WHERE op_login='%s'"
and fill combo values in the template. How can i do it?
I've tried as following:
My_plugin.tpl file:
<center>
<fieldset><legend>{t}Scegli il Comune{/t}</legend>
<div><b>
<select name="exampleRecenterField">
<option value=''>Seleziona...
<option value = "{$value}">{$value}
</select>
<!-- <input value="Vai" type="submit"/> -->
<a href="javascript:doSubmit();"><img src="{r
type=gfx/layout}xy.gif{/r}" id="refresh_recenter" alt="{t}Recenter{/t}"
title="{t}Recenter{/t}"></img></a>
</b></div>
</center>
ClientAuth.php
protected function drawAuth() {
$smarty = new Smarty_Plugin($this->getCartoclient(), $this);
$anonymous = SecurityManager::getInstance()->hasRole(
SecurityManager::ANONYMOUS_ROLE);
$smarty->assign('show_login', $anonymous);
$smarty->assign('show_logout', !$anonymous);
// My code STARTS
$sm = SecurityManager::getInstance();
$Role = $sm->getRoles();
$hasRoleMyrole = $sm->hasRole($Role[2]);
$filename = "$Role[2].tpl";
$dsn = $this->getConfig()->dbSecurityDsn;
$db = Utils::getDb($db, $dsn);
$sql = "select operatori.id_affiliato, affiliati.id_affiliato,
affiliati.comune_az from operatori, affiliati where
affiliati.id_affiliato = operatori.id_affiliato and
operatori.id_operatore=$Role[2]";
$res = $db->query($sql);
Utils::checkDbError($res);
$row =& $res->fetchRow(DB_FETCHMODE_OBJECT);
$value = $row->comune_az;
//print_r($Role[2]." ");
//print_r($value);
$smarty->fetch('C:/ms4w/apps/cartoweb3/projects/k21/plugins/exampleRecentering/templates/recenter.tpl');
$smarty->get_template_vars('value');
//echo $smarty->get_template_vars('value');
$smarty->assign('value', $value);
//echo $smarty->get_template_vars('value');
// END
return $smarty->fetch('auth.tpl');
}
--
Ing. Fabio D'Ovidio
iQuadro - Informatica e Innovazione s.r.l.
Via C. Pisacane 23, Aversa (CE) - 81031
Web : www.ii2.it
Tel.: 081 197 57 600
mail: [EMAIL PROTECTED]
_______________________________________________
Cartoweb-users mailing list
Cartoweb-users@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/cartoweb-users
_______________________________________________
Cartoweb-users mailing list
Cartoweb-users@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/cartoweb-users