Esempio n. 1
0
 public function uninstall()
 {
     try {
         \Database::getInstance()->exec('DROP table pages');
         return TRUE;
     } catch (\Exception $ex) {
         \Uno\Log::error($ex);
     }
     return FALSE;
 }
Esempio n. 2
0
 public function names($limit = NULL, $offset = NULL)
 {
     $query = 'SELECT name FROM modules';
     if (NULL !== $limit) {
         $query .= ' LIMIT ' . $limit;
         if (NULL !== $offset) {
             $query .= ' OFFSET ' . $offset;
         }
     }
     $stm = $this->db->prepare($query);
     try {
         $stm->execute();
         return $stm->fetchAll(\PDO::FETCH_COLUMN, 0);
     } catch (\Exception $ex) {
         \Uno\Log::error($ex);
     }
     return FALSE;
 }
Esempio n. 3
0
 protected function createNewMenu()
 {
     try {
         $this->val->addRule('name', array('required'), array(_('Menu name is a required field.')));
         $this->val->addCallback('name', array($this, '_check_menu_name_is_unique'));
         if ($this->val->validate()) {
             $orm = \ORM::factory('menus');
             $orm->name = $this->name;
             $orm->description = $this->val->get('description', '');
             $orm->save();
             $this->setProperty('msg', sprintf(_('Menu "%s" created successfully.'), $this->name));
             return TRUE;
         }
     } catch (Exception $ex) {
         \Uno\Log::error($ex);
     }
     return FALSE;
 }
Esempio n. 4
0
 public function role($reload = FALSE)
 {
     if (!empty($this->role) && !$reload) {
         return $this->role;
     }
     $query = 'SELECT roles.name as role FROM roles JOIN users_roles ON users_roles.role_id=roles.id WHERE users_roles.user_id=?';
     $stm = $this->db->prepare($query);
     $stm->bindValue(1, intval($this->id), \PDO::PARAM_INT);
     if (!$stm->execute()) {
         $info = $stm->errorInfo();
         \Uno\Log::error($info);
         throw new Exception($info[2]);
     }
     $this->role = $stm->fetchColumn();
     return $this->role;
 }
Esempio n. 5
0
 public function deactivate($module)
 {
     try {
         $mod = Module::factory($module);
         if ($mod->loaded()) {
             $mod->enabled = 0;
             $mod->save();
             $this->session->set('success', sprintf(_('Module "%s" deactivated successfully.'), $module));
         }
     } catch (\Exception $ex) {
         \Uno\Log::error($ex);
     }
     $this->redirect('admin/modules');
 }