1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3 <title>SAMURAI: Permiso.php Source File</title>
4 <link href="doxygen.css" rel="stylesheet" type="text/css">
6 <!-- Generado por Doxygen 1.3.2 -->
7 <div class="qindex"><a class="qindex" href="main.html">Página principal</a> | <a class="qindex" href="classes.html">Lista alfabética</a> | <a class="qindex" href="annotated.html">Lista de componentes</a> | <a class="qindex" href="files.html">Lista de archivos</a> | <a class="qindex" href="functions.html">Miembros de las clases</a></div>
8 <h1>Permiso.php</h1><a href="Permiso_8php.html">Ir a la documentación de este archivo.</a><div class="fragment"><pre>00001 <?php
9 00002 <span class="comment">// vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:</span>
10 00003 <span class="comment">// +----------------------------------------------------------------------+</span>
11 00004 <span class="comment">// | PHP Version 4 |</span>
12 00005 <span class="comment">// +----------------------------------------------------------------------+</span>
13 00006 <span class="comment">// | Copyright (c) 1997-2003 The PHP Group |</span>
14 00007 <span class="comment">// +----------------------------------------------------------------------+</span>
15 00008 <span class="comment">// | This source file is subject to version 2.02 of the PHP license, |</span>
16 00009 <span class="comment">// | that is bundled with this package in the file LICENSE, and is |</span>
17 00010 <span class="comment">// | available at through the world-wide-web at |</span>
18 00011 <span class="comment">// | http://www.php.net/license/2_02.txt. |</span>
19 00012 <span class="comment">// | If you did not receive a copy of the PHP license and are unable to |</span>
20 00013 <span class="comment">// | obtain it through the world-wide-web, please send a note to |</span>
21 00014 <span class="comment">// | license@php.net so we can mail you a copy immediately. |</span>
22 00015 <span class="comment">// +----------------------------------------------------------------------+</span>
23 00016 <span class="comment">// | Created: Tue May 27 11:20:04 2003</span>
24 00017 <span class="comment">// | Author: Martin Marrese - Myrna Degano <mmarre@mecon.gov.ar - mdegan@mecon.gov.ar></span>
25 00018 <span class="comment">// +----------------------------------------------------------------------+</span>
26 00019 <span class="comment">//</span>
27 00020 <span class="comment">// $Id: Permiso.php 26 2003-07-07 22:45:35Z mmarre $</span>
28 00021 <span class="comment">// $Author: mmarre $</span>
29 00022 <span class="comment">// $URL: http://portal.mecon.ar/svn/samurai/tronco/lib/SAMURAI/Permiso.php $</span>
30 00023 <span class="comment">// $Date: 2003-07-07 19:45:35 -0300 (Mon, 07 Jul 2003) $</span>
31 00024 <span class="comment">// $Rev: 26 $</span>
32 00025 <span class="comment">//</span>
34 00027 require_once 'PEAR.php';
36 00029 <span class="comment">// +X2C Class 210 :SAMURAI_Permiso</span>
37 <a name="l00035"></a><a class="code" href="classSAMURAI__Permiso.html">00035</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="classSAMURAI__Permiso.html">SAMURAI_Permiso</a> {
38 <a name="l00042"></a><a class="code" href="classSAMURAI__Permiso.html#o0">00042</a> var $<a class="code" href="classSAMURAI__Permiso.html#o0">_id</a>;
40 <a name="l00050"></a><a class="code" href="classSAMURAI__Permiso.html#o1">00050</a> var $<a class="code" href="classSAMURAI__Permiso.html#o1">_descripcion</a>;
42 <a name="l00058"></a><a class="code" href="classSAMURAI__Permiso.html#o2">00058</a> var $<a class="code" href="classSAMURAI__Permiso.html#o2">_db</a>;
44 <a name="l00066"></a><a class="code" href="classSAMURAI__Permiso.html#o3">00066</a> var $<a class="code" href="classSAMURAI__Permiso.html#o3">_responsable</a>;
46 <a name="l00074"></a><a class="code" href="classSAMURAI__Permiso.html#a0">00074</a> function <a class="code" href="classSAMURAI__Permiso.html#a0">getId</a>()
48 00076 <span class="keywordflow">return</span> $this-><a class="code" href="classSAMURAI__Permiso.html#o0">_id</a>;
50 <a name="l00086"></a><a class="code" href="classSAMURAI__Permiso.html#a1">00086</a> function <a class="code" href="classSAMURAI__Permiso.html#a1">setId</a>($id)
52 00088 $this-><a class="code" href="classSAMURAI__Permiso.html#o0">_id</a> = $id;
55 <a name="l00097"></a><a class="code" href="classSAMURAI__Permiso.html#a2">00097</a> function <a class="code" href="classSAMURAI__Permiso.html#a2">getDescripcion</a>()
57 00099 <span class="keywordflow">return</span> $this-><a class="code" href="classSAMURAI__Permiso.html#o1">_descripcion</a>;
59 <a name="l00109"></a><a class="code" href="classSAMURAI__Permiso.html#a3">00109</a> function <a class="code" href="classSAMURAI__Permiso.html#a3">setDescripcion</a>($descripcion)
61 00111 $this-><a class="code" href="classSAMURAI__Permiso.html#o1">_descripcion</a> = $descripcion;
64 <a name="l00120"></a><a class="code" href="classSAMURAI__Permiso.html#a4">00120</a> function <a class="code" href="classSAMURAI__Permiso.html#a4">getResponsable</a>()
66 00122 <span class="keywordflow">return</span> $this-><a class="code" href="classSAMURAI__Permiso.html#o3">_responsable</a>;
68 <a name="l00132"></a><a class="code" href="classSAMURAI__Permiso.html#a5">00132</a> function <a class="code" href="classSAMURAI__Permiso.html#a5">setResponsable</a>($responsable)
70 00134 $this-><a class="code" href="classSAMURAI__Permiso.html#o3">_responsable</a> = $responsable;
73 00137 <span class="comment">// ~X2C</span>
75 00139 <span class="comment">// +X2C Operation 259</span>
76 <a name="l00149"></a><a class="code" href="classSAMURAI__Permiso.html#a6">00149</a> <span class="comment"></span> function <a class="code" href="classSAMURAI__Permiso.html#a6">SAMURAI_Permiso</a>(&$db, $id = null) <span class="comment">// ~X2C</span>
78 00151 $this-><a class="code" href="classSAMURAI__Permiso.html#o2">_db</a> = $db;
79 00152 $this-><a class="code" href="classSAMURAI__Permiso.html#o0">_id</a> = $id;
80 00153 $this-><a class="code" href="classSAMURAI__Permiso.html#a3">setDescripcion</a>(null);
81 00154 <span class="keywordflow">if</span> (!is_null($id)) {
82 00155 $this-><a class="code" href="classSAMURAI__Permiso.html#a7">_obtenerDatosDb</a>();
85 00158 <span class="comment">// -X2C</span>
87 00160 <span class="comment">// +X2C Operation 295</span>
88 <a name="l00167"></a><a class="code" href="classSAMURAI__Permiso.html#a7">00167</a> <span class="comment"></span> function <a class="code" href="classSAMURAI__Permiso.html#a7">_obtenerDatosDb</a>() <span class="comment">// ~X2C</span>
90 00169 $sql = parse_ini_file(dirname(__FILE__) . '/Permiso/consultas.ini', <span class="keyword">true</span>);
91 00170 $tmp = $sql['obtener_datos_permiso'].$sql['obtener_datos_permiso2'];
92 00171 $dbh = $this-><a class="code" href="classSAMURAI__Permiso.html#o2">_db</a>->prepare($tmp);
93 00172 $tmp = array ($this->_id);
94 00173 $res = $this-><a class="code" href="classSAMURAI__Permiso.html#o2">_db</a>->execute($dbh,$tmp);
96 00175 <span class="keywordflow">if</span> ($re = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
97 00176 <span class="keywordflow">if</span> (isset($re['desc_permiso'])) {
98 00177 $this-><a class="code" href="classSAMURAI__Permiso.html#a3">setDescripcion</a>($re['desc_permiso']);
100 00179 <span class="keywordflow">else</span> {
101 00180 $this-><a class="code" href="classSAMURAI__Permiso.html#a3">setDescripcion</a>();
103 00182 <span class="keywordflow">if</span> (isset($re['responsable'])) {
104 00183 $this-><a class="code" href="classSAMURAI__Permiso.html#a5">setResponsable</a>($re['responsable']);
106 00185 <span class="keywordflow">else</span> {
107 00186 $this-><a class="code" href="classSAMURAI__Permiso.html#a5">setResponsable</a>();
111 00190 <span class="comment">// -X2C</span>
115 00194 <span class="comment">// +X2C Operation 316</span>
116 <a name="l00203"></a><a class="code" href="classSAMURAI__Permiso.html#a8">00203</a> <span class="comment"></span> function <a class="code" href="classSAMURAI__Permiso.html#a8">guardarDatos</a>($accion = grabar) <span class="comment">// ~X2C</span>
118 00205 $accion = strtolower($accion);
119 00206 <span class="keywordflow">switch</span> ($accion) {
120 00207 <span class="keywordflow">case</span> 'grabar':
121 00208 $res = $this-><a class="code" href="classSAMURAI__Permiso.html#a9">_grabarDb</a>();
122 00209 <span class="keywordflow">break</span>;
123 00210 <span class="keywordflow">case</span> 'modificar':
124 00211 $res = $this-><a class="code" href="classSAMURAI__Permiso.html#a11">_modificarDb</a>();
125 00212 <span class="keywordflow">break</span>;
126 00213 <span class="keywordflow">case</span> 'eliminar':
127 00214 $res = $this-><a class="code" href="classSAMURAI__Permiso.html#a10">_borrarDb</a>();
128 00215 <span class="keywordflow">break</span>;
130 00217 <span class="keywordflow">return</span> $res;
132 00219 <span class="comment">// -X2C</span>
134 00221 <span class="comment">// +X2C Operation 317</span>
135 <a name="l00228"></a><a class="code" href="classSAMURAI__Permiso.html#a9">00228</a> <span class="comment"></span> function <a class="code" href="classSAMURAI__Permiso.html#a9">_grabarDb</a>() <span class="comment">// ~X2C</span>
137 00230 $idPermiso = $this-><a class="code" href="classSAMURAI__Permiso.html#o2">_db</a>->nextId('permiso');
138 00231 $datos = array (
139 00232 'id_permiso' => $idPermiso,
140 00233 'desc_permiso' => $this->getDescripcion(),
141 00234 'responsable' => $this-><a class="code" href="classSAMURAI__Permiso.html#a4">getResponsable</a>(),
143 00236 <span class="keywordflow">return</span> $this-><a class="code" href="classSAMURAI__Permiso.html#o2">_db</a>->autoExecute('permiso', $datos, DB_AUTOQUERY_INSERT);
145 00238 <span class="comment">// -X2C</span>
147 00240 <span class="comment">// +X2C Operation 318</span>
148 <a name="l00247"></a><a class="code" href="classSAMURAI__Permiso.html#a10">00247</a> <span class="comment"></span> function <a class="code" href="classSAMURAI__Permiso.html#a10">_borrarDb</a>() <span class="comment">// ~X2C</span>
150 00249 $sql = parse_ini_file(dirname(__FILE__) . '/Permiso/consultas.ini', <span class="keyword">true</span>);
151 00250 $datos[] = $this-><a class="code" href="classSAMURAI__Permiso.html#a0">getId</a>();
152 00251 <span class="comment">//Verifico que el permiso no tenga asociaciones</span>
153 00252 $tmp = $sql['verificar_asociaciones1'].$sql['obtener_datos_permiso2'];
154 00253 $dbh = $this-><a class="code" href="classSAMURAI__Permiso.html#o2">_db</a>->prepare($tmp);
155 00254 $res = $this-><a class="code" href="classSAMURAI__Permiso.html#o2">_db</a>->execute($dbh, $datos);
156 00255 <span class="keywordflow">if</span> (($re = $res->fetchRow(DB_FETCHMODE_ASSOC)) && !$re['cuenta'] == 0) {
157 00256 <span class="keywordflow">return</span> <span class="keyword">new</span> PEAR_Error(<span class="stringliteral">"Hay sistemas asociados al permiso seleccionado"</span>);
159 00258 $tmp = $sql['verificar_asociaciones2'].$sql['obtener_datos_permiso2'];
160 00259 $dbh = $this-><a class="code" href="classSAMURAI__Permiso.html#o2">_db</a>->prepare($tmp);
161 00260 $res = $this-><a class="code" href="classSAMURAI__Permiso.html#o2">_db</a>->execute($dbh, $datos);
162 00261 <span class="keywordflow">if</span> (($re = $res->fetchRow(DB_FETCHMODE_ASSOC)) && !$re['cuenta'] == 0) {
163 00262 <span class="keywordflow">return</span> <span class="keyword">new</span> PEAR_Error(<span class="stringliteral">"Hay pefiles asociados al permiso seleccionado"</span>);
165 00264 <span class="comment">//</span>
166 00265 <span class="comment">//Borro el permiso de la base </span>
167 00266 $tmp = $sql['borrar_permiso'].$sql['obtener_datos_permiso2'];
168 00267 $dbh = $this-><a class="code" href="classSAMURAI__Permiso.html#o2">_db</a>->prepare($tmp);
169 00268 <span class="keywordflow">return</span> $this-><a class="code" href="classSAMURAI__Permiso.html#o2">_db</a>->execute($dbh, $datos);
170 00269 <span class="comment">//</span>
172 00271 <span class="comment">// -X2C</span>
174 00273 <span class="comment">// +X2C Operation 319</span>
175 <a name="l00280"></a><a class="code" href="classSAMURAI__Permiso.html#a11">00280</a> <span class="comment"></span> function <a class="code" href="classSAMURAI__Permiso.html#a11">_modificarDb</a>() <span class="comment">// ~X2C</span>
177 00282 $datos = array (
178 00283 'id_permiso' => $this->getId(),
179 00284 'desc_permiso' => $this-><a class="code" href="classSAMURAI__Permiso.html#a2">getDescripcion</a>(),
180 00285 'responsable' => $this-><a class="code" href="classSAMURAI__Permiso.html#a4">getResponsable</a>(),
182 00287 <span class="keywordflow">return</span> $this-><a class="code" href="classSAMURAI__Permiso.html#o2">_db</a>->autoExecute('permiso', $datos, DB_AUTOQUERY_UPDATE, 'id_permiso ='.$this->getId());
184 00289 <span class="comment">// -X2C</span>
187 00292 <span class="comment">// +X2C Operation 332</span>
188 <a name="l00302"></a><a class="code" href="classSAMURAI__Permiso.html#e0">00302</a> <span class="comment"></span> function <a class="code" href="classSAMURAI__Permiso.html#e0">_getIdPermisos</a>(&$db) <span class="comment">// ~X2C</span>
190 00304 <span class="comment">//OBTENGO LOS ID DE LA BASE</span>
191 00305 $rta = array();
192 00306 $sql = parse_ini_file(dirname(__FILE__) . '/Permiso/consultas.ini', <span class="keyword">true</span>);
193 00307 $dbh = $db->prepare($sql['obtener_datos_permiso']);
194 00308 $tmp[] = $_SESSION['samurai']['id_sistema'];
195 00309 $res = $db->execute($dbh, $tmp);
196 00310 <span class="keywordflow">while</span> ($re = $res->fetchrow(DB_FETCHMODE_ASSOC)) {
197 00311 array_push($rta,$re['id_permiso']);
199 00313 $res->free();
200 00314 <span class="keywordflow">return</span> $rta;
202 00316 <span class="comment">// -X2C</span>
204 00318 <span class="comment">// +X2C Operation 333</span>
205 <a name="l00328"></a><a class="code" href="classSAMURAI__Permiso.html#e1">00328</a> <span class="comment"></span> function <a class="code" href="classSAMURAI__Permiso.html#e1">getArrayPermisos</a>(&$db) <span class="comment">// ~X2C</span>
207 00330 <span class="comment">//FORECHEO LO QUE ME DEVUELVA GET PERMISOS</span>
208 00331 $rta = array ();
209 00332 foreach (<a class="code" href="classSAMURAI__Permiso.html#e2">SAMURAI_Permiso::getPermisos</a>($db) as $permiso) {
210 00333 $rta[$permiso->getId()] = $permiso->getDescripcion();
212 00335 <span class="keywordflow">return</span> $rta;
214 00337 <span class="comment">// -X2C</span>
216 00339 <span class="comment">// +X2C Operation 334</span>
217 <a name="l00349"></a><a class="code" href="classSAMURAI__Permiso.html#e2">00349</a> <span class="comment"></span> function <a class="code" href="classSAMURAI__Permiso.html#e2">getPermisos</a>(&$db) <span class="comment">// ~X2C</span>
219 00351 $rta = array ();
220 00352 foreach (<a class="code" href="classSAMURAI__Permiso.html#e0">SAMURAI_Permiso::_getIdPermisos</a>($db) as $id) {
221 00353 $tmp = <span class="keyword">new</span> <a class="code" href="classSAMURAI__Permiso.html#a6">SAMURAI_Permiso</a>($db,$id);
222 00354 array_push($rta, $tmp);
224 00356 <span class="keywordflow">return</span> $rta;
226 00358 <span class="comment">// -X2C</span>
228 00360 } <span class="comment">// -X2C Class :SAMURAI_Permiso</span>
231 </pre></div><hr size="1"><address style="align: right;"><small>Generado el Tue Jul 8 11:36:21 2003 para SAMURAI por
232 <a href="http://www.doxygen.org/index.html">
233 <img src="doxygen.png" alt="doxygen" align="middle" border=0 >
234 </a>1.3.2 </small></address>