예제 #1
0
 function insert($name, $parent, $comment)
 {
     //debug
     //echo "$name - $parent - $comment<br>";
     $owner = user::id();
     // user id
     $status = 2;
     // descriptor
     $linktype = 1;
     // hyrarchic link
     $parentArray = search::get($parent, "exact");
     $entryArray = search::get($name, "exact");
     $parentId = $parentArray[0][ID];
     $entryId = $entryArray[0][ID];
     // entry already exists - create polyseme
     if ($entryId) {
         $name = "{$name} ({$parent})";
     }
     // create new entry
     $entryString = "INSERT INTO entry SET\r\n      name='{$name}',\r\n      owner='{$owner}',\r\n      status='{$status}',\r\n      comment='{$comment}'";
     mysql_query($entryString);
     // get new id
     $newId = mysql_insert_id();
     //debug
     //echo "$parent ($parentId) > $name ($newId)<br>";
     // create link to parent
     if ($newId) {
         $linkString = "INSERT INTO parent SET\r\n        parent='{$parentId}',\r\n        child='{$newId}',\r\n        type='{$linktype}'";
         mysql_query($linkString);
     }
     return $name;
 }
예제 #2
0
            }
            form::update_entry($_GET, $errorArray);
            echo "</div>";
        }
        //------------------------------------------------------------------------------
        // display hyrarchy list
        if (session::get("hyrarchy")) {
            echo "<div id='hyrarchy'>";
            $display->header();
            $display->display(0, -1, 0, $errorArray);
            //thesaurus-resource, parent, depth, position
            echo "</div>";
        }
        //------------------------------------------------------------------------------
        // search field
        $searchResult = search::get(session::get(search));
        // display search result
        if (!session::get(searchshow)) {
            unset($searchResult);
        }
        // clear serach string if nothing new
        if (count($searchResult) > 0 and session::get(searchshow)) {
            // display search window
            search::display($searchResult);
        }
        // display search formular
        search::form(session::get(search));
    } else {
        form::standard();
    }
}
예제 #3
0
 function insert($_arg, $mandatory)
 {
     $errorArray = array();
     if ($_arg[action] == "insert" or $_arg[action] == "update") {
         session::destroy(searchshow);
         $action = $_arg[action];
         $ok = TRUE;
         // set error default ok
         //-----------------------------------------------------------------------------
         // insert
         if ($_arg[action] == "insert") {
             //-----------------------------------------------------------------------------
             // check for existing name entry
             $tempArray = search::get("{$_arg['name']}", "exact");
             if (is_array($tempArray)) {
                 $ok = FALSE;
                 $errorArray[name] = "exist";
             } else {
                 // check for alike name entry
                 $tempArray = search::get("{$_arg['name']}%", "start");
                 if (is_array($tempArray)) {
                     //            $ok = FALSE;
                     $errorArray[name] = "alike";
                 }
             }
         }
         // check mandatory fields
         foreach ($mandatory as $check) {
             if (!$_arg[$check] != "") {
                 $ok = FALSE;
                 $errorArray[$check] = "error";
             }
         }
         //echoalert($errorArray);
         // mandatory fields ok -> create sql-string out of data
         if ($ok) {
             //echoalert($_GET);
             //-----------------------------------------------------------------------------
             // reset parameters for next entry
             unset($_GET[name]);
             // delete name, sysnonym and comment
             unset($_GET[comment]);
             unset($_arg[action]);
             // remove action comment from $_arg
             $errorArray = false;
             // combine parameters
             $queryArray = array();
             while ($entry = each($_arg)) {
                 switch ($entry[key]) {
                     case parent:
                         $parent = $entry[value];
                         // filter parent
                         break;
                     case id:
                         $child = $entry[value];
                         // filter ID
                         break;
                     case type:
                         $type = $entry[value];
                         // filter type
                         break;
                     case PHPSESSID:
                         // filter SSID
                         break;
                     case orderdefault:
                         system::setval("val_orderdefault", $entry[value]);
                         break;
                     default:
                         array_push($queryArray, $entry[key] . "='" . $entry[value] . "'");
                         break;
                 }
             }
             $insertString = implode(",", $queryArray);
             // add sql-clauses
             switch ($action) {
                 // query for entry insert
                 case insert:
                     $_GET[action] = "add";
                     // set for next entry
                     $insertString .= ",owner='" . user::id() . "'";
                     $queryString = "INSERT INTO entry SET {$insertString}";
                     // = "INSERT entry
                     //echoalert($queryString);
                     if (database::query($queryString)) {
                         // query for parent insert
                         $child = mysql_insert_id();
                         $parentString = "INSERT INTO parent SET child='{$child}',parent='{$parent}',type='{$type}',owner='{$user}'";
                         database::query($parentString);
                     }
                     break;
                     // query for entry update
                 // query for entry update
                 case update:
                     $queryString = "UPDATE entry SET {$insertString} WHERE ID='" . $_arg[id] . "';";
                     // = "UPDATE entry
                     database::query($queryString);
                     break;
             }
         }
         return $errorArray;
     }
 }