setType("TextStimulus"); $this->setName("Text Stimulus"); $this->setTable("text_stimulus"); $this->setActions(array("view"=>_("View"), "edit"=>_("Edit"))); if ($id) { $data = $this->load($id); if ($data) { $this->setBody($data->body); } } } function create() { if ($id = parent::create()) { $insert = query_insert("INSERT INTO " . DB_PREFIX . $this->getTable() . " (base_id, body) values (".$id.", '".mysql_real_escape_string($this->getBody())."')"); return $id; } return false; } function save() { if (parent::save()) { $update = query_update("UPDATE " . DB_PREFIX . $this->getTable() . " SET body='".mysql_real_escape_string($this->getBody())."' WHERE base_id=".$this->getId()); if ($update) return $this->getId(); } return false; } function copy($locked=false) { $copy = $this->create(); if ($copy && $locked) { $lock = $this->lock($copy); } return $copy; } function build($data) { if (isset($data["body"]) && !empty($data["body"])) { if (parent::build($data)) { $this->setBody($data["body"]); if ($this->getId() > 0) { return $this->save(); } else { return $this->create(); } } } return false; } function delete() { if (is_admin() || $this->getCreator()==get_logged_in_user()->getId()) { if (parent::delete()) { return true; } } return false; } function getBody() { return $this->body; } function setBody($bt) { $this->body = $bt; } function buildFromXML($obj, $folder=0, $dir, $version=1) { parent::buildFromXML($obj, $folder, $dir); $this->setBody($obj->bodyText[0][0]); return $this->create(); } function getObjectsXML() { $xml = "getBody()."]]>\n"; return $xml; } } ?>