/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
- <?php
- /**
- * File Action.class.php
- *
- * This file contains the definition of the class object
- * type Action and at the end of the file,
- * a way to test the class (simply passing sending test = 1
- * via GET or POST ).
- * @author Marco Novo <mnovo@ncfsistemi.com>
- * @version 1.0
- */
- /**
- * This class defines fields and methods of Action
- */
- class Action {
- /**
- * $resourceLinkID
- * @access private
- * @var resource
- */
- private $resourceLinkID;
- /**
- * id
- * @access private
- * @var integer
- */
- private $id;
- /**
- * idModule
- * @access private
- * @var integer
- */
- private $idModule;
- /**
- * idModule_name
- * @access private
- * @var string
- */
- private $idModule_name;
- /**
- * action
- * @access private
- * @var string
- */
- private $action;
- /**
- * active
- * @access private
- * @var integer
- */
- private $active;
- /**
- * deleted
- * @access private
- * @var integer
- */
- private $deleted;
- /**
- * Set the value of resourceLinkID
- * @param resource $resourceLinkID
- */
- function setResourceLinkID($resourceLinkID){
- $this->resourceLinkID=$resourceLinkID;
- }
- /**
- * Get the value of resourceLinkID
- * @return resource
- */
- function getResourceLinkID(){
- return $this->resourceLinkID;
- }
- /**
- * Sets the value of field id
- * @param integer $id
- */
- function setId($id){
- $this->id=$id;
- }
- /**
- * Gets the value of field id
- * @return integer
- */
- function getId(){
- return $this->id;
- }
- /**
- * Sets the value of field idModule
- * @param integer $idModule
- */
- function setIdModule($idModule){
- $this->idModule=$idModule;
- }
- /**
- * Gets the value of field idModule
- * @return integer
- */
- function getIdModule(){
- return $this->idModule;
- }
- /**
- * Sets the value of foreign field idModule_name
- * @param string $idModule_name
- */
- function setIdModule_name($idModule_name){
- $this->idModule_name=$idModule_name;
- }
- /**
- * Gets the value of foreign field idModule_name
- * @return string
- */
- function getIdModule_name(){
- return $this->idModule_name;
- }
- /**
- * Sets the value of field action
- * @param string $action
- */
- function setAction($action){
- $this->action=$action;
- }
- /**
- * Gets the value of field action
- * @return string
- */
- function getAction(){
- return $this->action;
- }
- /**
- * Sets the value of field active
- * @param integer $active
- */
- function setActive($active){
- $this->active=$active;
- }
- /**
- * Gets the value of field active
- * @return integer
- */
- function getActive(){
- return $this->active;
- }
- /**
- * Sets the value of field deleted
- * @param integer $deleted
- */
- function setDeleted($deleted){
- $this->deleted=$deleted;
- }
- /**
- * Gets the value of field deleted
- * @return integer
- */
- function getDeleted(){
- return $this->deleted;
- }
- /**
- * Constructor of the class
- */
- function __construct($resourceLinkID='',
- $id='',
- $idModule='',
- $idModule_name='',
- $action='',
- $active='',
- $deleted='') {
- $this->resourceLinkID = $resourceLinkID;
- $this->id = $id;
- $this->idModule = $idModule;
- $this->idModule_name = $idModule_name;
- $this->action = $action;
- $this->active = $active;
- $this->deleted = $deleted;
- }
- /**
- * Destructor of the class
- */
- function __destruct() {
- }
- /**
- * Get the value of descriptive field
- * @return string
- */
- function getDescriptiveFields(){
- return trim($this->getIdModule().' '.$this->getAction().' '.' (id: '.$this->getId().')');
- }
- /**
- * Get the name and the value of mail fields
- * @return string
- */
- function getMailFields(){
- return trim("Id: ".$this->getId()."\n"."Module: ".$this->getIdModule()."\n"."Action: ".$this->getAction()."\n"."Active: ".$this->getActive()."\n"."Deleted: ".$this->getDeleted()."\n"."");
- }
- /**
- * Persistence selectById method (try to select)
- * @return true|false
- */
- function selectById(){
- $query="SELECT `ant_Action`.*,
- `ant_Module`.`name` AS `idModule_name`
- FROM `ant_Action`
- LEFT JOIN `ant_Module` ON `ant_Module`.`id` = `ant_Action`.`idModule`
- WHERE `ant_Action`.`id` = ".$this->getId()."";
- $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()));
- while($action_array=adodb_fetch_array($result)){
- $this->id = $action_array['id'];
- $this->idModule = $action_array['idModule'];
- $this->idModule_name = $action_array['idModule_name'];
- $this->action = $action_array['action'];
- $this->active = $action_array['active'];
- $this->deleted = $action_array['deleted'];
- }
- }
- /**
- * Persistence selectFiles method (try to select)
- * @return array
- */
- function selectFiles(){
- $query="SELECT `ant_Action_File`.*
- FROM `ant_Action_File`
- WHERE `ant_Action_File`.`idTableObject`= ".$this->getId()."
- AND `ant_Action_File`.`tableObject`='ant_Action'";
- $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()));
- $filesList=array();
- while($action_File_array=adodb_fetch_assoc($result)){
- array_push($filesList, $action_File_array);
- }
- return $filesList;
- }
- /**
- * Persistence selectFileById method (try to select)
- * @return array
- */
- function selectFileById($fileId){
- $query="SELECT `ant_Action_File`.*
- FROM `ant_Action_File`
- WHERE `ant_Action_File`.`id`='$fileId'";
- $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()));
- $action_File_array=adodb_fetch_assoc($result);
- return $action_File_array;
- }
- /**
- * Persistence selectCountFiles method (try to select)
- * @return array
- */
- function selectCountFiles(){
- $query="SELECT COUNT(*)
- FROM `ant_Action_File`
- WHERE `ant_Action_File`.`idTableObject`= ".$this->getId()."
- AND `ant_Action_File`.`tableObject`='ant_Action'";
- $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()));
- $action_File_array=adodb_fetch_array($result);
- return $action_File_array[0];
- }
- /**
- * Persistence selectCountLogs method (try to select count)
- * @return integer
- */
- function selectCountLogs(){
- $query="SELECT COUNT(*)
- FROM `ant_Action_Log`";
- $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()));
- $action_Log_array=adodb_fetch_array($result);
- return $action_Log_array[0];
- }
- /**
- * Persistence selectCountTrashes method (try to select count)
- * @return integer
- */
- function selectCountTrashes(){
- $query="SELECT COUNT(*)
- FROM `ant_Action`
- WHERE `deleted` = 1";
- $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()));
- $action_array=adodb_fetch_array($result);
- return $action_array[0];
- }
- /**
- * Persistence selectByFileId method (try to select)
- * @return true|false
- */
- function selectByFileId($idFile){
- $query="SELECT `ant_Action_File`.*
- FROM `ant_Action_File`
- WHERE `ant_Action_File`.`id` = '$idFile'";
- $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()));
- return adodb_fetch_array($result);
- }
- /**
- * Persistence listByIdModule method (try to select)
- * @return list/array
- */
- function listByIdModule($idModule){
- $query="SELECT `ant_Action`.*
- FROM `ant_Action`
- WHERE `ant_Action`.`idModule` = '$idModule'
- AND `ant_Action`.`active`=1
- AND `ant_Action`.`deleted`=0";
- //echo $query;
- $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()));
- $list= array();
- while($action_array=adodb_fetch_assoc($result)){
- array_push($list,$action_array);
- }
- return $list;
- }
- }
- ?>