function _buildQuery() { global $database; $this->init(); $query = DBModel::getInstance(); $query->reset('Entries'); $query->setQualifier('blogid', 'equals', $this->blogid); if (isset($this->id)) { if (!Validator::number($this->id, 1)) { return $this->_error('id'); } $query->setQualifier('id', 'equals', $this->id); } if (isset($this->userid)) { if (!Validator::number($this->userid, 1)) { return $this->_error('userid'); } $query->setQualifier('userid', 'equals', $this->userid); } if (isset($this->title)) { $query->setAttribute('title', Utils_Unicode::lessenAsEncoding($this->title, 255), true); } if (isset($this->content)) { $query->setAttribute('content', $this->content, true); $query->setAttribute('contentformatter', $this->contentformatter, true); $query->setAttribute('contenteditor', $this->contenteditor, true); } if (isset($this->visibility)) { switch ($this->visibility) { case 'appointed': $query->setAttribute('visibility', -2); break; case 'private': $query->setAttribute('visibility', 0); break; case 'protected': $query->setAttribute('visibility', 1); if (empty($this->password)) { $this->password = $this->makePassword(); } break; case 'public': $query->setAttribute('visibility', 2); break; case 'syndicated': $query->setAttribute('visibility', 3); break; default: return $this->_error('visibility'); } } if (isset($this->starred)) { $query->setAttribute('starred', $this->starred); } else { $query->setAttribute('starred', 0); } if (isset($this->category)) { if (!Category::doesExist($this->category)) { return $this->_error('category'); } $query->setAttribute('category', $this->category); } if (isset($this->location)) { $query->setAttribute('location', Utils_Unicode::lessenAsEncoding($this->location, 255), true); } if (isset($this->password)) { $query->setAttribute('password', $this->password, true); } if (isset($this->acceptcomment)) { $query->setAttribute('acceptcomment', Validator::getBit($this->acceptcomment)); } if (isset($this->accepttrackback)) { $query->setAttribute('accepttrackback', Validator::getBit($this->accepttrackback)); } if (isset($this->published)) { if (!Validator::number($this->published, 0)) { return $this->_error('published'); } $query->setAttribute('published', $this->published); } if (isset($this->longitude) && Validator::number($this->longitude)) { $query->setAttribute('longitude', $this->longitude); } if (isset($this->latitude) && Validator::number($this->latitude)) { $query->setAttribute('latitude', $this->latitude); } if (isset($this->created)) { if (!Validator::number($this->created, 0)) { return $this->_error('created'); } $query->setAttribute('created', $this->created); } if (isset($this->modified)) { if (!Validator::number($this->modified, 0)) { return $this->_error('modified'); } $query->setAttribute('modified', $this->modified); } return $query; }