예제 #1
0
function createGenre($id, $english)
{
    $o1 = new sotf_NodeObject("sotf_genres");
    $o1->set('genre_id', $id);
    $o1->set('language', 'en');
    $o1->set('name', $english);
    $o1->create();
}
 function create()
 {
     $succ = parent::create();
     if ($succ) {
         $this->checkDirs();
         $this->saveMetadataFile();
     }
     return $succ;
 }
예제 #3
0
function createRole($id, $english, $creator = 'f')
{
    $o1 = new sotf_NodeObject("sotf_roles");
    $o1->set('role_id', $id);
    $o1->set('creator', $creator);
    $o1->create();
    $o2 = new sotf_NodeObject("sotf_role_names");
    $o2->set('role_id', $id);
    $o2->set('language', 'en');
    $o2->set('name', $english);
    $o2->create();
}
 /** Creates a deletion record: used when a replicated object is deleted. */
 function createDeletionRecord()
 {
     global $db;
     $dr = new sotf_NodeObject('sotf_deletions');
     $dr->set('del_id', $this->id);
     $dr->set('del_time', $db->getTimestampTz());
     $dr->create();
 }
예제 #5
0
$topic_counter = sotf_Utils::getParameter('topic_counter');
$find = sotf_Utils::getParameter('find');
$add = sotf_Utils::getParameter('add');
if ($name != "") {
    $x = new sotf_NodeObject("sotf_topic_tree_defs");
    $x->set('supertopic', $parent);
    $x->set('name', $name);
    $x->create();
    $id = $x->getID();
}
if ($topic_name != "") {
    $x = new sotf_NodeObject("sotf_topics");
    $x->set('topic_id', $topic_id);
    $x->set('language', "en");
    $x->set('topic_name', $topic_name);
    $x->create();
    $id = $x->getID();
    print $id;
}
if ($topic_counter != "") {
    $x = new sotf_Object("sotf_topics_counter");
    $x->set('topic_id', $topic_id);
    $x->set('number', $topic_counter);
    $x->create();
    $id = $x->getID();
    print $id;
}
$query = "SELECT sotf_topic_tree_defs.*, sotf_topics.topic_name, sotf_topics_counter.number from sotf_topic_tree_defs" . " LEFT JOIN sotf_topics ON sotf_topics.topic_id = sotf_topic_tree_defs.id" . " LEFT JOIN sotf_topics_counter ON sotf_topics_counter.topic_id = sotf_topic_tree_defs.id";
$result = $db->getAll($query);
usort($result, "SORTIT");
$parentid;
 /** Imports genre translations from a text files into database */
 function importGenres($lines, $language)
 {
     if (empty($lines)) {
         logError("importGenres: file is empty");
         return;
     }
     reset($lines);
     while (list(, $line) = each($lines)) {
         if (preg_match('/^\\s*$/', $line) || preg_match('/^#/', $line)) {
             continue;
         }
         if (!preg_match('/^\\s*(\\d+)\\s+(.*)/', $line, $items)) {
             logError("bad line syntax: {$line}");
             continue;
         }
         debug("genre item", $items);
         $id = $items[1];
         $name = trim($items[2]);
         $o1 = new sotf_NodeObject("sotf_genres");
         $o1->setID($o1->makeId(0, $o1->tablename, $id . $language));
         $o1->set('genre_id', $id);
         $o1->set('language', $language);
         $o1->set('name', $name);
         $o1->create();
     }
 }
예제 #7
0
    // save
    if (is_object($role)) {
        $role->set('contact_id', $contactId);
        $role->set('role_id', $roleSelected);
        $role->update();
    } else {
        if (sotf_ComplexNodeObject::findRole($objectId, $contactId, $roleSelected)) {
            // this role already exists
            $page->addStatusMsg("role_exists");
            $page->redirectSelf();
        }
        $role = new sotf_NodeObject("sotf_object_roles");
        $role->set('object_id', $objectId);
        $role->set('contact_id', $contactId);
        $role->set('role_id', $roleSelected);
        $role->create();
    }
    $page->redirect("closeAndRefresh.php?anchor=roles");
}
// general data
$obj =& $repository->getObject($objectId);
$smarty->assign("OBJECT_ID", $objectId);
$smarty->assign("STATION_ID", $obj->getStationId());
$smarty->assign("ROLE_ID", $roleId);
$smarty->assign('ROLE_LIST', $vocabularies->getRoles());
if (!$scope) {
    $scope = 1;
}
switch ($scope) {
    case 1:
        $contacts = sotf_Contact::listMyContactNames();
 /** static: create contact record from metadata */
 function importContact($contactData, $contactRole, $prgId, $stationId, $admins)
 {
     global $db, $permissions, $repository, $vocabularies, $config;
     $db->begin();
     // find out what should go into the 'name' field
     if ($contactData['type'] == 'organisation') {
         $name = $contactData['organizationname'];
     } elseif ($contactData['type'] == 'individual') {
         $name = $contactData['firstname'] . ' ' . $contactData['lastname'];
     } else {
         logError("unknown type of contact: " . $contactData['type']);
         return null;
     }
     // if not exists, create new contact
     $id = sotf_Contact::findByNameLocal($name);
     if (!$id) {
         $contact = new sotf_Contact();
         $status = $contact->create($name, $stationId);
         if (!$status) {
             //$page->addStatusMsg('contact_create_failed');
             return null;
         }
         // add permissions for all station admins (??)
         while (list(, $adminId) = each($admins)) {
             $permissions->addPermission($contact->id, $adminId, 'admin');
         }
     } else {
         $contact = $repository->getObject($id);
     }
     //debug("contactData", $contactData);
     // set/update contact data
     $contact->set('acronym', $contactData['organizationacronym']);
     $contact->set('alias', $contactData['alias']);
     $contact->set('url', $contactData['uri']);
     $contact->set('email', $contactData['email']);
     $contact->set('address', $contactData['address']);
     $contact->update();
     // determine role
     if ($contactData['role']) {
         $language = 'eng';
         // for now
         $rid = $vocabularies->getRoleId($contactData['role'], $language);
         if ($rid) {
             $contactRole = $rid;
         }
     }
     // create role
     if (!sotf_ComplexNodeObject::findRole($prgId, $contact->id, $contactRole)) {
         $role = new sotf_NodeObject("sotf_object_roles");
         $role->set('object_id', $prgId);
         $role->set('contact_id', $contact->id);
         $role->set('role_id', $contactRole);
         $role->create();
     }
     $db->commit();
     // fetch logo from url and store
     if (!empty($contactData['logo'])) {
         $url = $contactData['logo'];
         if ($handle = @fopen($url, 'rb')) {
             $contents = "";
             while (!feof($handle)) {
                 $contents .= fread($handle, 8192);
             }
             /*
             		  do {
             			 $data = fread ($handle, 100000);
             			 if (strlen($data) == 0) {
             				break;
             			 }
             			 //debug("received", strlen($data));
             			 $contents .= $data;
             			 } while(0); */
             fclose($handle);
             $tmpFile = tempnam($config['tmpDir'], 'logo_u');
             debug("received logo from", $url);
             sotf_Utils::save($tmpFile, $contents);
             chmod($tmpFile, 0660);
             $contact->setIcon($tmpFile);
             unlink($tmpFile);
         } else {
             logError("Could not fetch icon from {$url}");
         }
     }
     return $contact->id;
 }
 function addToTopic($progId, $topicId)
 {
     global $db;
     // TODO: ha mar van, akkor ne adja hozza
     $query = "SELECT id  FROM sotf_prog_topics WHERE  prog_id = '" . $progId . "' AND topic_id  = '" . $topicId . "'";
     $result = $db->getAll($query);
     if (count($result) == 0) {
         $x = new sotf_NodeObject("sotf_prog_topics");
         $x->set('prog_id', $progId);
         $x->set('topic_id', $topicId);
         $x->create();
         $query = "UPDATE sotf_topics_counter SET number = number+1 WHERE topic_id = '" . $topicId . "'";
         $result = $db->query($query);
         $query = "SELECT supertopic FROM sotf_topic_tree_defs WHERE id = '" . $topicId . "'";
         $supertopic = $db->getOne($query);
         if (!$supertopic) {
             $supertopic = $topicId;
         }
         $query = "UPDATE sotf_topics_counter SET total = total+1 WHERE topic_id = '" . $supertopic . "'";
         $result = $db->query($query);
     }
 }
예제 #10
0
    $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();
예제 #11
0
function addChild($parent, $name, $topic_name = "", $lang = "en", $treeId = 2)
{
    $x = new sotf_NodeObject("sotf_topic_tree_defs");
    $x->set('supertopic', $parent);
    $x->set('name', $name);
    $x->set('tree_id', $treeId);
    $x->create();
    $id = $x->getID();
    if ($topic_name != "") {
        $y = new sotf_NodeObject("sotf_topics");
        $y->set('topic_id', $id);
        $y->set('language', $lang);
        $y->set('topic_name', $topic_name);
        $y->create();
        //print($id);
    }
    return $x->getID();
}
 /** Creates a deletion record: used when a replicated object is deleted. */
 function createDeletionRecord()
 {
     $dr = new sotf_NodeObject('sotf_deletions');
     $dr->set('del_id', $this->id);
     $dr->create();
 }