/branches/assicurazioniesinistri/include/Object/Action.class.php

http://antilophpe.googlecode.com/ · PHP · 324 lines · 156 code · 17 blank · 151 comment · 0 complexity · 7583615cbca457a96e76ef78a436d415 MD5 · raw file

  1. <?php
  2. /**
  3. * File Action.class.php
  4. *
  5. * This file contains the definition of the class object
  6. * type Action and at the end of the file,
  7. * a way to test the class (simply passing sending test = 1
  8. * via GET or POST ).
  9. * @author Marco Novo <mnovo@ncfsistemi.com>
  10. * @version 1.0
  11. */
  12. /**
  13. * This class defines fields and methods of Action
  14. */
  15. class Action {
  16. /**
  17. * $resourceLinkID
  18. * @access private
  19. * @var resource
  20. */
  21. private $resourceLinkID;
  22. /**
  23. * id
  24. * @access private
  25. * @var integer
  26. */
  27. private $id;
  28. /**
  29. * idModule
  30. * @access private
  31. * @var integer
  32. */
  33. private $idModule;
  34. /**
  35. * idModule_name
  36. * @access private
  37. * @var string
  38. */
  39. private $idModule_name;
  40. /**
  41. * action
  42. * @access private
  43. * @var string
  44. */
  45. private $action;
  46. /**
  47. * active
  48. * @access private
  49. * @var integer
  50. */
  51. private $active;
  52. /**
  53. * deleted
  54. * @access private
  55. * @var integer
  56. */
  57. private $deleted;
  58. /**
  59. * Set the value of resourceLinkID
  60. * @param resource $resourceLinkID
  61. */
  62. function setResourceLinkID($resourceLinkID){
  63. $this->resourceLinkID=$resourceLinkID;
  64. }
  65. /**
  66. * Get the value of resourceLinkID
  67. * @return resource
  68. */
  69. function getResourceLinkID(){
  70. return $this->resourceLinkID;
  71. }
  72. /**
  73. * Sets the value of field id
  74. * @param integer $id
  75. */
  76. function setId($id){
  77. $this->id=$id;
  78. }
  79. /**
  80. * Gets the value of field id
  81. * @return integer
  82. */
  83. function getId(){
  84. return $this->id;
  85. }
  86. /**
  87. * Sets the value of field idModule
  88. * @param integer $idModule
  89. */
  90. function setIdModule($idModule){
  91. $this->idModule=$idModule;
  92. }
  93. /**
  94. * Gets the value of field idModule
  95. * @return integer
  96. */
  97. function getIdModule(){
  98. return $this->idModule;
  99. }
  100. /**
  101. * Sets the value of foreign field idModule_name
  102. * @param string $idModule_name
  103. */
  104. function setIdModule_name($idModule_name){
  105. $this->idModule_name=$idModule_name;
  106. }
  107. /**
  108. * Gets the value of foreign field idModule_name
  109. * @return string
  110. */
  111. function getIdModule_name(){
  112. return $this->idModule_name;
  113. }
  114. /**
  115. * Sets the value of field action
  116. * @param string $action
  117. */
  118. function setAction($action){
  119. $this->action=$action;
  120. }
  121. /**
  122. * Gets the value of field action
  123. * @return string
  124. */
  125. function getAction(){
  126. return $this->action;
  127. }
  128. /**
  129. * Sets the value of field active
  130. * @param integer $active
  131. */
  132. function setActive($active){
  133. $this->active=$active;
  134. }
  135. /**
  136. * Gets the value of field active
  137. * @return integer
  138. */
  139. function getActive(){
  140. return $this->active;
  141. }
  142. /**
  143. * Sets the value of field deleted
  144. * @param integer $deleted
  145. */
  146. function setDeleted($deleted){
  147. $this->deleted=$deleted;
  148. }
  149. /**
  150. * Gets the value of field deleted
  151. * @return integer
  152. */
  153. function getDeleted(){
  154. return $this->deleted;
  155. }
  156. /**
  157. * Constructor of the class
  158. */
  159. function __construct($resourceLinkID='',
  160. $id='',
  161. $idModule='',
  162. $idModule_name='',
  163. $action='',
  164. $active='',
  165. $deleted='') {
  166. $this->resourceLinkID = $resourceLinkID;
  167. $this->id = $id;
  168. $this->idModule = $idModule;
  169. $this->idModule_name = $idModule_name;
  170. $this->action = $action;
  171. $this->active = $active;
  172. $this->deleted = $deleted;
  173. }
  174. /**
  175. * Destructor of the class
  176. */
  177. function __destruct() {
  178. }
  179. /**
  180. * Get the value of descriptive field
  181. * @return string
  182. */
  183. function getDescriptiveFields(){
  184. return trim($this->getIdModule().' '.$this->getAction().' '.' (id: '.$this->getId().')');
  185. }
  186. /**
  187. * Get the name and the value of mail fields
  188. * @return string
  189. */
  190. function getMailFields(){
  191. return trim("Id: ".$this->getId()."\n"."Module: ".$this->getIdModule()."\n"."Action: ".$this->getAction()."\n"."Active: ".$this->getActive()."\n"."Deleted: ".$this->getDeleted()."\n"."");
  192. }
  193. /**
  194. * Persistence selectById method (try to select)
  195. * @return true|false
  196. */
  197. function selectById(){
  198. $query="SELECT `ant_Action`.*,
  199. `ant_Module`.`name` AS `idModule_name`
  200. FROM `ant_Action`
  201. LEFT JOIN `ant_Module` ON `ant_Module`.`id` = `ant_Action`.`idModule`
  202. WHERE `ant_Action`.`id` = ".$this->getId()."";
  203. $result = adodb_query($query, $this->getResourceLinkId()) or die('Query: '.$query.' Error during selection in table ``ant_Action``: '.adodb_errno($this->getResourceLinkId()).' - '.adodb_error($this->getResourceLinkId()));
  204. while($action_array=adodb_fetch_array($result)){
  205. $this->id = $action_array['id'];
  206. $this->idModule = $action_array['idModule'];
  207. $this->idModule_name = $action_array['idModule_name'];
  208. $this->action = $action_array['action'];
  209. $this->active = $action_array['active'];
  210. $this->deleted = $action_array['deleted'];
  211. }
  212. }
  213. /**
  214. * Persistence selectFiles method (try to select)
  215. * @return array
  216. */
  217. function selectFiles(){
  218. $query="SELECT `ant_Action_File`.*
  219. FROM `ant_Action_File`
  220. WHERE `ant_Action_File`.`idTableObject`= ".$this->getId()."
  221. AND `ant_Action_File`.`tableObject`='ant_Action'";
  222. $result = adodb_query($query, $this->getResourceLinkId()) or die('Query: '.$query.' Error during selection in table ``ant_Action_File``: '.adodb_errno($this->getResourceLinkId()).' - '.adodb_error($this->getResourceLinkId()));
  223. $filesList=array();
  224. while($action_File_array=adodb_fetch_assoc($result)){
  225. array_push($filesList, $action_File_array);
  226. }
  227. return $filesList;
  228. }
  229. /**
  230. * Persistence selectFileById method (try to select)
  231. * @return array
  232. */
  233. function selectFileById($fileId){
  234. $query="SELECT `ant_Action_File`.*
  235. FROM `ant_Action_File`
  236. WHERE `ant_Action_File`.`id`='$fileId'";
  237. $result = adodb_query($query, $this->getResourceLinkId()) or die('Query: '.$query.' Error during selection file in table ``ant_Action_File``: '.adodb_errno($this->getResourceLinkId()).' - '.adodb_error($this->getResourceLinkId()));
  238. $action_File_array=adodb_fetch_assoc($result);
  239. return $action_File_array;
  240. }
  241. /**
  242. * Persistence selectCountFiles method (try to select)
  243. * @return array
  244. */
  245. function selectCountFiles(){
  246. $query="SELECT COUNT(*)
  247. FROM `ant_Action_File`
  248. WHERE `ant_Action_File`.`idTableObject`= ".$this->getId()."
  249. AND `ant_Action_File`.`tableObject`='ant_Action'";
  250. $result = adodb_query($query, $this->getResourceLinkId()) or die('Query: '.$query.' Error during selection in table ``ant_Action_File``: '.adodb_errno($this->getResourceLinkId()).' - '.adodb_error($this->getResourceLinkId()));
  251. $action_File_array=adodb_fetch_array($result);
  252. return $action_File_array[0];
  253. }
  254. /**
  255. * Persistence selectCountLogs method (try to select count)
  256. * @return integer
  257. */
  258. function selectCountLogs(){
  259. $query="SELECT COUNT(*)
  260. FROM `ant_Action_Log`";
  261. $result = adodb_query($query, $this->getResourceLinkId()) or die('Query: '.$query.' Error during select count from table `ant_Action_Log`: '.adodb_errno($this->getResourceLinkId()).' - '.adodb_error($this->getResourceLinkId()));
  262. $action_Log_array=adodb_fetch_array($result);
  263. return $action_Log_array[0];
  264. }
  265. /**
  266. * Persistence selectCountTrashes method (try to select count)
  267. * @return integer
  268. */
  269. function selectCountTrashes(){
  270. $query="SELECT COUNT(*)
  271. FROM `ant_Action`
  272. WHERE `deleted` = 1";
  273. $result = adodb_query($query, $this->getResourceLinkId()) or die('Query: '.$query.' Error during select count from table ``ant_Action``: '.adodb_errno($this->getResourceLinkId()).' - '.adodb_error($this->getResourceLinkId()));
  274. $action_array=adodb_fetch_array($result);
  275. return $action_array[0];
  276. }
  277. /**
  278. * Persistence selectByFileId method (try to select)
  279. * @return true|false
  280. */
  281. function selectByFileId($idFile){
  282. $query="SELECT `ant_Action_File`.*
  283. FROM `ant_Action_File`
  284. WHERE `ant_Action_File`.`id` = '$idFile'";
  285. $result = adodb_query($query, $this->getResourceLinkId()) or die('Query: '.$query.' Error during selection in table ``ant_Action_File``: '.adodb_errno($this->getResourceLinkId()).' - '.adodb_error($this->getResourceLinkId()));
  286. return adodb_fetch_array($result);
  287. }
  288. /**
  289. * Persistence listByIdModule method (try to select)
  290. * @return list/array
  291. */
  292. function listByIdModule($idModule){
  293. $query="SELECT `ant_Action`.*
  294. FROM `ant_Action`
  295. WHERE `ant_Action`.`idModule` = '$idModule'
  296. AND `ant_Action`.`active`=1
  297. AND `ant_Action`.`deleted`=0";
  298. //echo $query;
  299. $result = adodb_query($query, $this->getResourceLinkId()) or die('Query: '.$query.' Error during selection in table `ant_Action`: '.adodb_errno($this->getResourceLinkId()).' - '.adodb_error($this->getResourceLinkId()));
  300. $list= array();
  301. while($action_array=adodb_fetch_assoc($result)){
  302. array_push($list,$action_array);
  303. }
  304. return $list;
  305. }
  306. }
  307. ?>