tableName = DB_PREFIX_SERVICE.'Admin'; $this->DBObj($id); $this->Doc = $Doc; } function getTypes() { $sql = "SELECT name, title FROM {$this->tableNameDB}Type ORDER BY sorter"; return $this->db->queryAll($sql, null, MDB2_FETCHMODE_ASSOC, true); } function isLoginUnique($name) { $sql = "SELECT COUNT(*) FROM {$this->tableNameDB} WHERE login = ".$this->db->quote($name); if ($this->id){ $sql .= ' AND id != '.$this->db->quote($this->id); } return !(bool)$this->db->queryOne($sql) ; } function getRootType() { } function update() { if (empty($this->_data[$this->pass_field])){ unset($this->_data[$this->pass_field]); }else { $this->_data[$this->pass_field] = $this->_encryptPass($this->_data[$this->pass_field]); } parent::update(); } function insert() { if (empty($this->_data['type'])) { $this->_data['type'] = 'admin'; } $this->_data[$this->pass_field] = $this->_encryptPass($this->_data[$this->pass_field]); parent::insert($data); } function delete() { $user = $this->Doc->UserAuth->getData(); $list = $this->getList4Grid(); if (1 == $list['num_rows'] || $user['id'] == $this->id) { return false; } else { parent::delete(); return true; } } function _getJoin4Grid() { return "JOIN {$this->tableNameDB}Type AS AdminType ON AdminType.name = {$this->tableName}.type"; } function _getWhat4Grid() { return "{$this->tableName}.id, {$this->tableName}.login, AdminType.title AS type, {$this->tableName}.name"; } } ?>