function getRoles()
 {
     $roles = $this->db->getAll("SELECT id, contact_id, role_id FROM sotf_object_roles WHERE object_id='{$this->id}' ORDER BY role_id, contact_id");
     for ($i = 0; $i < count($roles); $i++) {
         $roles[$i]['role_name'] = $this->repository->getRoleName($roles[$i]['role_id']);
         $cobj = new sotf_Contact($roles[$i]['contact_id']);
         $roles[$i]['contact_data'] = $cobj->getAllWithIcon();
     }
     return $roles;
 }
 function delete()
 {
     global $db;
     // has to move contacts to another station if they are used elsewhere!
     sotf_Contact::moveContactsFromStation($this);
     parent::delete();
 }
    } elseif ($finish) {
        $prg->update();
        $page->redirect("editor.php");
    } else {
        $prg->update();
        $page->redirect("editMeta.php?id={$prg->id}");
    }
}
$smarty->assign('PRG_ID', $prgId);
$smarty->assign('PRG_TITLE', $prg->get('title'));
// delete role
$delrole = sotf_Utils::getParameter('delrole');
$roleid = sotf_Utils::getParameter('roleid');
if ($delrole) {
    $role = new sotf_NodeObject('sotf_object_roles', $roleid);
    $c = new sotf_Contact($role->get('contact_id'));
    $role->delete();
    $msg = $page->getlocalizedWithParams("deleted_contact", $c->get('name'));
    $page->addStatusMsg($msg, false);
    $page->redirect("editMeta.php?id={$prgId}#roles");
    exit;
}
// delete right
$delright = sotf_Utils::getParameter('delright');
$rid = sotf_Utils::getParameter('rid');
if ($delright) {
    $right = new sotf_NodeObject('sotf_rights', $rid);
    $right->delete();
    //$msg = $page->getlocalizedWithParams("deleted_", $c->get('name'));
    //$page->addStatusMsg($msg, false);
    $page->redirect("editMeta.php?id={$prgId}#rights");
 * Created for the StreamOnTheFly project (IST-2001-32226)
 * Authors: András Micsik, Máté Pataki, Tamás Déri 
 *          at MTA SZTAKI DSD, http://dsd.sztaki.hu
 */
require "init.inc.php";
$page->popup = true;
$page->forceLogin();
$stationId = sotf_Utils::getParameter('stationid');
$contactName = sotf_Utils::getParameter('name');
if ($contactName) {
    if (sotf_Contact::findByNameLocal($contactName)) {
        //$page->addStatusMsg('contact_name_exists');
        //$page->redirect("createCOntact.php);
        raiseError("contact_name_exists");
        exit;
    }
    // create a new contact
    $contact = new sotf_Contact();
    $status = $contact->create($contactName, $stationId);
    if (!$status) {
        $page->addStatusMsg('contact_create_failed');
    } else {
        $permissions->addPermission($contact->id, $user->id, 'admin');
        $page->redirect("editContact.php?id=" . $contact->id);
        exit;
    }
}
// general data
$smarty->assign("NAME", $contactName);
$smarty->assign("STATION_ID", $stationId);
$page->sendPopup();
    raiseError("Object id is missing!");
}
checkPerm($objectId, "change");
if ($scopeChange) {
    if (sotf_Utils::getParameter('change')) {
        $scope = sotf_Utils::getParameter('newscope');
    }
    $newPattern = sotf_Utils::getParameter('newpattern');
    if ($newPattern) {
        $scope = 6;
    }
    $page->redirect("editRole.php?roleid={$roleId}&objectid={$objectId}&pattern=" . urlencode($newPattern) . "&scope={$scope}");
}
if ($roleId) {
    $role =& new sotf_NodeObject('sotf_object_roles', $roleId);
    $contact = new sotf_Contact($role->get('contact_id'));
    if ($contactId) {
        $smarty->assign("CONTACT_SELECTED", $contactId);
    } else {
        $smarty->assign("CONTACT_NAME", $contact->get('name'));
        $smarty->assign("CONTACT_SELECTED", $contact->get('id'));
    }
    if ($roleSelected) {
        $smarty->assign("ROLE_SELECTED", $roleSelected);
    } else {
        $smarty->assign("ROLE_SELECTED", $role->get('role_id'));
    }
}
if ($save) {
    if (!$roleSelected) {
        raiseError("No role selected!");
 /** 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;
 }
 * $Id$
 * Created for the StreamOnTheFly project (IST-2001-32226)
 * Authors: András Micsik, Máté Pataki, Tamás Déri 
 *          at MTA SZTAKI DSD, http://dsd.sztaki.hu
 */
require "init.inc.php";
$page->popup = true;
$page->forceLogin();
//$contactId = sotf_Utils::getParameter('contactid');
$contactName = sotf_Utils::getParameter('name');
if ($contactName) {
    if (sotf_Contact::findByNameLocal($contactName)) {
        //$page->addStatusMsg('contact_name_exists');
        //$page->redirect("createCOntact.php);
        raiseError("contact_name_exists");
        exit;
    }
    // create a new contact
    $contact = new sotf_Contact();
    $status = $contact->create($contactName);
    if (!$status) {
        $page->addStatusMsg('contact_create_failed');
    } else {
        $permissions->addPermission($contact->id, $user->id, 'admin');
        $page->redirect("editContact.php?id=" . $contact->id);
        exit;
    }
}
// general data
$smarty->assign("NAME", $contactName);
$page->sendPopup();
<?php

// -*- tab-width: 3; indent-tabs-mode: 1; -*-
/*  
 * $Id: showContact.php 372 2005-02-03 15:15:51Z micsik $
 * Created for the StreamOnTheFly project (IST-2001-32226)
 * Authors: András Micsik, Máté Pataki, Tamás Déri 
 *          at MTA SZTAKI DSD, http://dsd.sztaki.hu
 */
require "init.inc.php";
$contactId = sotf_Utils::getParameter('id');
if (strpos($contactId, '@') !== FALSE) {
    // someone tries with e-mail address
    $contact = new sotf_Contact();
    $contact->set('email', $contactId);
    $contact->find();
    if ($contact->exists()) {
        $foundByEmail = 1;
        $contactId = $contact->id;
    }
}
if (!$foundByEmail) {
    $contact =& $repository->getObject($contactId);
}
if (!$contact) {
    raiseError("no_such_object", $contactId);
}
$smarty->assign('PAGETITLE', $contact->get('name'));
$smarty->assign('CONTACT_ID', $contactId);
$smarty->assign('CONTACT_NAME', $contact->get('name'));
$smarty->assign('CONTACT_DATA', $contact->getAllWithIcon());
Exemple #9
0
while (list(, $id) = each($ids)) {
    $obj = new sotf_Programme($id);
    $icon = $obj->getBlob('icon');
    $obj->saveBlob('icon', $icon);
    echo "<br>icon saved for {$id}";
}
$ids = $db->getCol("select id from sotf_stations");
while (list(, $id) = each($ids)) {
    $obj = new sotf_Station($id);
    $icon = $obj->getBlob('icon');
    $obj->saveBlob('icon', $icon);
    echo "<br>icon saved for {$id}";
}
$ids = $db->getCol("select id from sotf_series");
while (list(, $id) = each($ids)) {
    $obj = new sotf_Series($id);
    $icon = $obj->getBlob('icon');
    $obj->saveBlob('icon', $icon);
    echo "<br>icon saved for {$id}";
}
$ids = $db->getCol("select id from sotf_contacts");
while (list(, $id) = each($ids)) {
    $obj = new sotf_Contact($id);
    $icon = $obj->getBlob('icon');
    $obj->saveBlob('icon', $icon);
    echo "<br>icon saved for {$id}";
}
?>