SetInitialValues(); } /** * Sets object to some sane initial values */ function SetInitialValues() { $this->bookmark_id = -1; $this->title = ''; $this->url = ''; $this->user_id = -1; } /** * Saves the bookmark to the database. If no id is set, then a new record * is created. If the id is set, then the record is updated to all values * in the Bookmark object. * * @return mixed If successful, true. If it fails, false. */ function Save() { $result = false; $bookops = cmsms()->GetBookmarkOperations(); if ($this->bookmark_id > -1) { $result = $bookops->UpdateBookmark($this); } else { $newid = $bookops->InsertBookmark($this); if ($newid > -1) { $this->bookmark_id = $newid; $result = true; } } return $result; } /** * Delete the record for this Bookmark from the database and resets * all values to their initial values. * * @return mixed If successful, true. If it fails, false. */ function Delete() { $result = false; $bookops = cmsms()->GetBookmarkOperations(); if ($this->bookmark_id > -1) { $result = $bookops->DeleteBookmarkByID($this->bookmark_id); if ($result) $this->SetInitialValues(); } return $result; } } # vim:ts=4 sw=4 noet ?>