_initAnnouncementData($id_announcement); $this->DBObj($id); } function _initAnnouncementData($id_announcement) { $id_announcement = (int) $id_announcement; $announcement = SiteMap::getObj('Announcement/Announcement.php'); $data = $announcement->getFromDb($id_announcement); if (!empty($data)) { $this->_id_announcement = $id_announcement; $this->_announcement_title = $data['title']; $this->_announcement_alias = $data['alias']; } } function getIdAnnouncement() { return (int) $this->_id_announcement; } function getAnnouncementTitle() { return $this->_announcement_title; } function getAnnouncementAlias() { return $this->_announcement_alias; } function _getWhat4Grid($opt = array()) { $where = parent::_getWhat4Grid($opt); $where .= ", CONCAT_WS(' ', Member.first_name, Member.last_name) AS member_name"; $where .= ", Admin.name AS admin_name "; return $where; } function _getJoin4Grid($opt = array()) { $join = parent::_getJoin4Grid($opt); $join .= " LEFT JOIN {$this->db->tblMember} as Member ON Member.id = {$this->tableName}.id_member "; $join .= " LEFT JOIN {$this->db->tblzz_Admin} as Admin ON Admin.id = ABS({$this->tableName}.id_member) "; return $join; } function _getWhere4Grid($opt = array()) { $where = parent::_getWhere4Grid($opt); $where .= " AND id_announcement = " . $this->getIdAnnouncement();; if (null !== $this->_approved) { $where .= " AND approved = " . $this->db->quote((((bool) $this->_approved) ? 'y' : 'n')); } return $where; } function setFilter($filter) { $this->_filterQuery = (array) $filter; } function _filterSql() { $where = (string) DBObj_Filter::perseQr($this->db, $this->_filterFields, $this->_filterQuery['query']); if (in_array($this->_filterQuery['approved'], array('y', 'n'))) { $where .= " AND {$this->tableName}.approved = " . $this->db->quote($this->_filterQuery['approved']);; } return $where; } function getMemberName($id) { $id = (int) $id; if ($id < 0) { $sql = "select name from {$this->db->tblzz_Admin} where id = " . abs($id); } else { $sql = "select concat_ws(' ', first_name, last_name) from {$this->db->tblMember} where id = " . $id; } $name = $this->db->queryOne($sql); if ($this->isDBError($name)) { $name = ''; } return $name; } function setApproved($value = true) { $this->_approved = $value; } }