function saveReplica()
 {
     if ($this->id) {
         $changed = $this->db->getOne("SELECT last_change FROM sotf_node_objects WHERE id='{$this->id}' ");
         //debug("changed", $changed);
         //debug("lch", $this->lastChange);
         if ($changed) {
             if ($this->lastChange && strtotime($this->lastChange) > strtotime($changed)) {
                 sotf_NodeObject::update();
                 reset($this->binaryFields);
                 while (list(, $field) = each($this->binaryFields)) {
                     sotf_Object::setBlob($field, $this->db->unescape_bytea($this->data[$field]));
                 }
                 debug("updated ", $this->id);
                 return true;
             } else {
                 debug("arrived older version of", $this->id);
                 return false;
             }
         }
     }
     $success = sotf_NodeObject::create();
     debug("created ", $this->id);
     return $success;
 }
 function update()
 {
     parent::update();
     if (parent::isLocal()) {
         $this->checkDirs();
         $this->saveMetadataFile();
     }
 }
$capid = sotf_Utils::getParameter('capid');
$capvalue = sotf_Utils::getParameter('capvalue');
$capurl = sotf_Utils::getParameter('capurl');
$capname = sotf_Utils::getParameter('capname');
if ($capname == "ofiles") {
    $x = new sotf_NodeObject("sotf_other_files", $capid);
    $x->set('caption', addslashes($capvalue));
    $x->update();
    if (!strstr($capurl, "#")) {
        $capurl .= "#ofiles";
    }
    $page->redirect($capurl);
} elseif ($capname == "mfiles") {
    $x = new sotf_NodeObject("sotf_media_files", $capid);
    $x->set('caption', addslashes($capvalue));
    $x->update();
    if (!strstr($capurl, "#")) {
        $capurl .= "#mfiles";
    }
    $page->redirect($capurl);
}
$prg =& new sotf_Programme($id);
if (!$prg->isLocal()) {
    raiseError("You can only edit programmes locally!");
}
if ($prg->isVideoPrg()) {
    $video = true;
} else {
    $video = false;
}
$converting = false;
 function update()
 {
     $this->set('modify_date', date('Y-m-d'));
     sotf_NodeObject::update();
     if ($this->isLocal()) {
         $this->checkDirs();
         $this->addToUpdate('updateMeta', $this->id);
         // instead of immediate update:
         // $this->saveMetadataFile();
     }
 }
    $startTime = sotf_Utils::getParameter('start_time');
    $stopTime = sotf_Utils::getParameter('stop_time');
    $rightsText = sotf_Utils::getParameter('rights_text');
    $fullProg = sotf_Utils::getParameter('fullprog');
    // save
    if ($newRight) {
        $rights = new sotf_NodeObject("sotf_rights");
    }
    if ($fullProg) {
        $rights->set('start_time', null);
        $rights->set('stop_time', null);
    } else {
        // check input params
        if (!is_int($startTime) || !is_int($stopTime)) {
            raiseError("not_integer");
        }
        $rights->set('start_time', $startTime);
        $rights->set('stop_time', $stopTime);
    }
    $rights->set('rights_text', $rightsText);
    if ($newRight) {
        $rights->set('prog_id', $objectId);
        $rights->create();
    } else {
        $rights->update();
    }
    $page->redirect("closeAndRefresh.php?anchor=rights");
}
// general data
$smarty->assign("OBJECT_ID", $objectId);
$page->sendPopup();