. */ /** * Status Service. This class provides functionality to * handle statuses */ require_once(FILESYSTEMROOTPATH."events/include/dao/StatusDao.php"); class StatusService { private $statusDao; /** * Default constructor * * @param StatusDao */ public function __construct(StatusDao $statusDao) { $this->statusDao = $statusDao; } /** * Load a status by id * * @param string id of the status to be loaded * @return Status containing the data of the requested status, or NULL in case status does not exist */ public function load($id) { $status = $this->statusDao->load($id); $ret = array ("id" => $status->getId(), "name" => $status->getName(), "active" => $status->getActive(), "description" => $status->getDescription()); return $ret; } /** * Load all Statuses * * @return array of Status */ public function loadAll() { $ret = array(); $statuses = $this->statusDao->loadAll(); foreach( $statuses as $status ) { $ret[ $status->getId() ] = array ("id" => $status->getId(), "name" => $status->getName(), "active" => $status->getActive(), "description" => $status->getDescription()); } return $ret; } public function loadNames() { $ret = array(); $statuses = $this->statusDao->loadNames(); foreach( $statuses as $status ) { $ret[ $status->getId() ] = array ("id" => $status->getId(), "name" => $status->getName(), ); } return $ret; } /** * Load all Active Statuses * * @return array of Status */ public function loadActive() { $ret = array(); $statuses = $this->statusDao->loadActive(); foreach( $statuses as $status ) { $ret[ $status->getId() ] = array ("id" => $status->getId(), "name" => $status->getName(), "active" => $status->getActive(), "description" => $status->getDescription()); } return $ret; } public function loadActiveNames() { $ret = array(); $statuses = $this->statusDao->loadActive(); foreach( $statuses as $status ) { $ret[ $status->getId() ] = array ("id" => $status->getId(), "name" => $status->getName()); } return $ret; } /** * Save or update a status * * @param Status object with the status data * @return boolean true in case of success, false otherwise */ public function saveOrUpdate(IModel $status) { return $this->statusDao->saveOrUpdate($status); } }