Пример #1
0
 /**
  * Table constructor.
  * @param string $table_name
  * @param string $table_key
  * @param array $config
  */
 public function __construct($table_name, $table_key = 'id', array $config = [])
 {
     $this->Cyan = \Cyan::initialize();
     $this->table_key = $table_key;
     $this->config = Config::getInstance($table_name);
     if (!empty($config)) {
         $this->config->loadArray($config);
     }
     parent::__construct($this->Cyan->getContainer('application')->Database->connect(), $table_name);
 }
Пример #2
0
 /**
  * Plan Details
  *
  * @return array|\ArrayObject|mixed
  */
 public function getPermissions()
 {
     /** @var ApplicationWeb $App */
     $App = $this->getContainer('application');
     $Dbo = $App->Database->connect();
     $Dbo->schema()->setBackReference('extension', 'rule', 'id');
     $Dbo->schema()->setBackReference('rule_action', 'rule', 'id');
     $in_groups = implode(',', $this->getRoles());
     $sql = $Dbo->getDatabaseQuery()->from('rule')->select('access')->select('extension.name AS extension_name')->select('rule_action.name AS action_name')->where('role_id IN (' . $in_groups . ')')->where('application_instance_id = ' . $App->getID());
     $sth = $Dbo->prepare($sql);
     $sth->execute();
     $rows = $sth->fetchAll(\PDO::FETCH_ASSOC);
     $acl = [];
     foreach ($rows as $row) {
         $acl[$row['extension_name']][$row['action_name']] = $row['access'];
     }
     $configAcl = new Config();
     $configAcl->loadArray($acl);
     return $configAcl;
 }