Creato admin model Aggiunte alcune classi di utility gui iniziato login manager creato session handler
63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
<?php
|
|
/*
|
|
Author: Riccardo Di Dato
|
|
Creation Date: 13/gen/2016
|
|
*/
|
|
|
|
class AdminModel extends Model{
|
|
const ADMIN_TYPE_SUPERADMIN = 1;
|
|
const ADMIN_TYPE_BANNER = 2;
|
|
const ADMIN_TYPE_ROLEADMIN = 4;
|
|
const ADMIN_TYPE_COMMENTI = 8;
|
|
const ADMIN_TYPE_STATISTICHE = 16;
|
|
const ADMIN_TYPE_NEWSLETTER = 32;
|
|
const ADMIN_TYPE_SONDAGGI = 64;
|
|
const ADMIN_TYPE_EDITORE = 128;
|
|
const ADMIN_TYPE_EDITORE_SUPERVISOR = 256;
|
|
|
|
public static $ROLE_ADMIN_HANDLED = array(
|
|
self::ADMIN_TYPE_EDITORE => array("label"=>"Editore")
|
|
);
|
|
|
|
public static $ROLE_SUPERADMIN_HANDLED = array(
|
|
self::ADMIN_TYPE_BANNER => array("label"=>"Banner"),
|
|
self::ADMIN_TYPE_ROLEADMIN => array("label"=>"Amministratore"),
|
|
self::ADMIN_TYPE_COMMENTI => array("label"=>"Commenti"),
|
|
self::ADMIN_TYPE_STATISTICHE => array("label"=>"Statistiche"),
|
|
self::ADMIN_TYPE_NEWSLETTER => array("label"=>"Newsletter"),
|
|
self::ADMIN_TYPE_SONDAGGI => array("label"=>"Sondaggi"),
|
|
self::ADMIN_TYPE_EDITORE => array("label"=>"Editore"),
|
|
self::ADMIN_TYPE_EDITORE_SUPERVISOR => array("label"=>"Supervisione Editori")
|
|
);
|
|
|
|
|
|
public function __construct($saveableObject = null){
|
|
parent::__construct($saveableObject);
|
|
if (!$this->hasProperty("roles")){
|
|
$this->roles = false;
|
|
}
|
|
}
|
|
|
|
public static function getCollectionName(){
|
|
return "administrators";
|
|
}
|
|
|
|
public function hasRole($role){
|
|
return $role & $this->role == $role;
|
|
}
|
|
|
|
public function addRole($role){
|
|
$this->role = $this->role | $role;
|
|
}
|
|
|
|
public function removeRole($role){
|
|
$this->role = $this->role & ~$role;
|
|
}
|
|
|
|
public function setRole($role){
|
|
$this->role = $role;
|
|
}
|
|
|
|
}
|
|
|
|
?>
|