function saveSlogan($slogan = null) { global $database; $this->init(); if (!Validator::number($this->id, 1)) { return $this->_error('id'); } if (!Validator::number($this->userid, 1)) { return $this->_error('userid'); } if (isset($slogan)) { $this->slogan = $slogan; } $query = new DBModel(); $query->reset('Entries'); $query->setQualifier('blogid', $this->blogid); if (isset($this->userid)) { $query->setQualifier('userid', $this->userid); } $query->setQualifier('id', $this->id); if (!$query->doesExist()) { return $this->_error('id'); } if (isset($this->slogan) && $this->validateSlogan($this->slogan)) { $slogan0 = $this->slogan; } else { $slogan0 = $this->slogan = $this->makeSlogan($this->title); } $slogan0 = Utils_Unicode::lessenAsEncoding($slogan0, 255); for ($i = 1; $i < 1000; $i++) { // $checkSlogan = POD::escapeString($this->slogan); $checkSlogan = $this->slogan; $query->setAttribute('slogan', $checkSlogan, true); if (!POD::queryExistence("SELECT id FROM {$database['prefix']}Entries " . "WHERE blogid = " . $this->blogid . " AND id <> {$this->id} AND slogan ='{$checkSlogan}'")) { if (!$query->update()) { return $this->_error('update'); } return true; } $this->slogan = Utils_Unicode::lessenAsEncoding($slogan0, 245) . '-' . $i; } // if try saveSlogan again, slogan string has more $i return $this->_error('limit'); }