function canIngestHere($collection_pid) { global $user; module_load_include('php', 'Fedora_Repository', 'ObjectHelper'); $objectHelper = new ObjectHelper(); //get the childsecurity policy from the collection. $policyStream = $objectHelper->getStream($collection_pid, SECURITYCLASS::$SECURITYSTREAM, false); if ($policyStream == null) { //no child policy stream so collection is wide open to anyone to ingest, that has the permission ingest in Drupal. //maybe we should return false here?? would be more secure. return true; } $allowedUsersAndRoles = $this->getAllowedUsersAndRoles($policyStream); if (!$allowedUsersAndRoles) { //error processing stream so don't let them ingest here. return false; } $allowedUsers = $allowedUsersAndRoles["users"]; $allowedRoles = $allowedUsersAndRoles["roles"]; foreach ($user->roles as $role) { if (in_array($role, $allowedRoles)) { return true; } } if (in_array($user->name, $allowedUsers)) { return true; } return false; }
private function getNid($pid) { module_load_include('php', 'Fedora_Repository', 'ObjectHelper'); //get Nid from Pid $object = new ObjectHelper($pid); $spec = $object->getStream($pid, 'MAG', 0); $xml = new SimpleXMLElement($spec); $nid = implode($xml->xpath('//nid')); // $urlNid = implode($xml->xpath('//nurl')); // $strNid = explode('node/', $urlNid); // $nid = $strNid[1]; return $nid; }
function createPolicy($collectionPid, &$dom, &$rootElement) { module_load_include('php', 'Fedora_Repository', 'ObjectHelper'); $objectHelper = new ObjectHelper(); $dsid = 'CHILD_SECURITY'; $policyStreamDoc = $objectHelper->getStream($collectionPid, $dsid, false); if (!isset($policyStreamDoc)) { return null; //there is no policy stream so object will not have a policy stream } try { $xml = new SimpleXMLElement($policyStreamDoc); } catch (Exception $e) { watchdog(t("Fedora_Repository"), t("Problem getting Security Policy!"), NULL, WATCHDOG_ERROR); drupal_set_message(t('Problem getting Security Policy! ') . $e->getMessage(), 'error'); return false; } $policyElement = $dom->createDocumentFragment(); if (!$policyElement) { drupal_set_message(t('error parsing security policy stream!')); watchdog(t("Fedora_Repository"), t("Error parsing security policy stream, could not parse policy stream!"), NULL, WATCHDOG_NOTICE); return false; } $dom->importNode($policyElement, true); $value = $policyElement->appendXML($policyStreamDoc); if (!$value) { drupal_set_message(t('error creating security policy stream!')); watchdog(t("Fedora_Repository"), t("Error creating security policy stream, could not parse collection policy template file!"), NULL, WATCHDOG_NOTICE); return false; } $ds1 = $dom->createElement("foxml:datastream"); $rootElement->appendChild($ds1); $ds1->setAttribute("ID", "POLICY"); $ds1->setAttribute("STATE", "A"); $ds1->setAttribute("CONTROL_GROUP", "X"); $ds1v = $dom->createElement("foxml:datastreamVersion"); $ds1->appendChild($ds1v); $ds1v->setAttribute("ID", "POLICY.0"); $ds1v->setAttribute("MIMETYPE", "text/xml"); $ds1v->setAttribute("LABEL", "POLICY"); //$ds1v->setAttribute("FORMAT_URI","info:fedora/fedora-system:format/xml.fedora.audit"); $content = $dom->createElement("foxml:xmlContent"); $ds1v->appendChild($content); $content->appendChild($policyElement); return true; }
function show_compound_details($compound_pid) { module_load_include('php', 'fedora_repository', 'ObjectHelper'); $object_helper = new ObjectHelper(); $compound_stream = new SimpleXMLElement($object_helper->getStream($compound_pid, 'COMPOUND')); $fields = array('weight', 'ptp1b', 'hct116', 'hela', 'pc3', 'are', 'antiproliferative'); foreach ($fields as $field) { if (implode($compound_stream->xpath("//compounds:{$field}")) == 'Hit') { $td = '<td bgcolor="red">'; } elseif (implode($compound_stream->xpath("//compounds:{$field}")) == 'Strong') { $td = '<td bgcolor = "yellow">'; } elseif (implode($compound_stream->xpath("//compounds:{$field}")) == 'Medium') { $td = '<td bgcolor = "orange">'; } elseif (implode($compound_stream->xpath("//compounds:{$field}")) == 'Low') { $td = '<td bgcolor = "grey">'; } else { $td = '<td>'; } $row_html .= $td . implode($compound_stream->xpath("//compounds:{$field}")) . '</td>'; } return $row_html; }
function buildFractionEditForm() { module_load_include('php', 'Fedora_Repository', 'ObjectHelper'); $object = new ObjectHelper(); $frac = $object->getStream($this->pid, 'FRACTION', 0); $doc = new DomDocument(); if (!isset($frac)) { drupal_set_message(t('Error getting fraction metadata stream'), 'error'); return null; } $xml = new SimpleXMLElement($frac); $radioValues = array(); $radioValues['No_Assay'] = 'No_Assay'; $radioValues['Hit'] = 'Hit'; $radioValues['Strong'] = 'Strong'; $radioValues['Medium'] = 'Medium'; $radioValues['Low'] = 'Low'; $radioValues['Inactive'] = 'Inactive'; $form = array(); $identifier = $xml->xpath('//fractions:identifier'); $form['identifier'] = array('#type' => 'hidden', '#title' => t('<strong>Identifier</strong>'), '#value' => implode($identifier)); $form['ident'] = array('#type' => 'item', '#title' => t('<strong>Identifier</strong>'), '#value' => implode($identifier)); $plate = $xml->xpath('//fractions:plate'); $form['plate'] = array('#type' => 'textfield', '#default_value' => implode($plate), '#title' => t('<strong>Plate</strong>')); $weight = $xml->xpath('//fractions:weight'); $form['weight'] = array('#type' => 'textfield', '#default_value' => implode($weight), '#title' => t('<strong>Weight</strong>')); $pt = $xml->xpath('//fractions:ptp1b'); $form['pt'] = array('#type' => 'radios', '#default_value' => implode($pt), '#options' => $radioValues, '#title' => t('<strong>PTP1B</strong>')); $pt_com = $xml->xpath('//fractions:ptp1b_com'); $form['pt_com'] = array('#type' => 'textfield', '#default_value' => implode($pt_com), '#title' => t('<strong>PTP1B Comments</strong>')); $hct = $xml->xpath('//fractions:hct116'); $form['hct'] = array('#type' => 'radios', '#default_value' => implode($hct), '#options' => $radioValues, '#title' => t('<strong>HCT116</strong>')); $hct_com = $xml->xpath('//fractions:hct116_com'); $form['hct_com'] = array('#type' => 'textfield', '#default_value' => implode($hct_com), '#title' => t('<strong>HCT116 Comments</strong>')); $hela = $xml->xpath('//fractions:hela'); $form['hela'] = array('#type' => 'radios', '#default_value' => implode($hela), '#options' => $radioValues, '#title' => t('<strong>HELA</strong>')); $hela_com = $xml->xpath('//fractions:hela_com'); $form['hela_com'] = array('#type' => 'textfield', '#default_value' => implode($hela_com), '#title' => t('<strong>HELA Comments</strong>')); $pc3 = $xml->xpath('//fractions:pc3'); $form['pc3'] = array('#type' => 'radios', '#default_value' => implode($pc3), '#options' => $radioValues, '#title' => t('<strong>PC3</strong>')); $pc3_com = $xml->xpath('//fractions:pc3_com'); $form['pc3_com'] = array('#type' => 'textfield', '#default_value' => implode($pc3_com), '#title' => t('<strong>PC3 Comments</strong>')); $are = $xml->xpath('//fractions:are'); $form['are'] = array('#type' => 'radios', '#default_value' => implode($are), '#options' => $radioValues, '#title' => t('<strong>ARE</strong>')); $are_com = $xml->xpath('//fractions:are_com'); $form['are_com'] = array('#type' => 'textfield', '#default_value' => implode($are_com), '#title' => t('<strong>ARE Comments</strong>')); $antiproliferative = $xml->xpath('//fractions:antiproliferative'); $form['antiproliferative'] = array('#type' => 'radios', '#default_value' => implode($antiproliferative), '#options' => $radioValues, '#title' => t('<strong>Antiproliferative</strong>')); $antiproliferative_com = $xml->xpath('//fractions:antiproliferative_com'); $form['antiproliferative_com'] = array('#type' => 'textfield', '#default_value' => implode($antiproliferative_com), '#title' => t('<strong>Antiproliferative Comments</strong>')); $location = $xml->xpath('//fractions:location'); $form['location'] = array('#type' => 'textfield', '#default_value' => implode($location), '#title' => t('<strong>Location</strong>')); $notes = $xml->xpath('//fractions:notes'); $form['notes'] = array('#type' => 'textarea', '#default_value' => implode($notes), '#title' => t('<strong>Notes</strong>')); $form['#redirect'] = 'fedora/repository/' . $this->pid; $form['pid'] = array('#type' => 'hidden', '#value' => $this->pid); $form['dsid'] = array('#type' => 'hidden', '#value' => 'FRACTION'); $form['submit'] = array('#type' => 'submit', '#value' => 'Update'); return $form; }
function getStream($pid, $dsid, $showError = 1) { module_load_include('php', 'Fedora_Repository', 'ObjectHelper'); $objectHelper = new ObjectHelper(); return $objectHelper->getStream($pid, $dsid, $showError); }
function handleVideoEditForm($form_id, $form_values, $soap_client) { //echo "FORM_ID: ".$form_id; $pid = $form_values['pid']; module_load_include('php', 'Fedora_Repository', 'ObjectHelper'); $object = new ObjectHelper($pid); $spec = $object->getStream($pid, 'MAG', TRUE); $xml = new SimpleXMLElement($spec); $dom = new DomDocument("1.0", "UTF-8"); $dom->formatOutput = true; $mag = $dom->createElement("mag"); // $dom->appendChild($mag); $vid = $dom->createElement("video"); $proxies = $dom->createElement("proxies"); $metrics = $dom->createElement("video_metrics"); $dimensions = $dom->createElement("video_dimensions"); $format = $dom->createElement("format"); $dis = $dom->createElement("dis"); $gen = $dom->createElement("gen"); $bib = $dom->createElement("bib"); $drup = $dom->createElement("dru"); $vid->appendChild($dom->createElement('sequence_number', implode($xml->xpath('//sequence_number')))); $proxies->appendChild($dom->createElement('size', implode($xml->xpath('//size')))); $proxies->appendChild($dom->createElement('md5', implode($xml->xpath('//md5')))); $proxies->appendChild($dom->createElement('file', implode($xml->xpath('//file')))); $metrics->appendChild($dom->createElement('framerate', implode($xml->xpath('//framerate')))); $dimensions->appendChild($dom->createElement('framewidth', implode($xml->xpath('//framewidth')))); $dimensions->appendChild($dom->createElement('frameheight', implode($xml->xpath('//frameheight')))); $metrics->appendChild($dom->createElement('bitrate', implode($xml->xpath('//bitrate')))); $format->appendChild($dom->createElement('mime', implode($xml->xpath('//mime')))); // $vid->appendChild($dom->createElement('samplingfrequencyunit', implode($xml->xpath('//samplingfrequencyunit')))); // $vid->appendChild($dom->createElement('samplingfrequencyplane', implode($xml->xpath('//samplingfrequencyplane')))); $dis->appendChild($dom->createElement('item', implode($xml->xpath('//item')))); $drup->appendChild($dom->createElement('nid', implode($xml->xpath('//nid')))); $drup->appendChild($dom->createElement('nurl', implode($xml->xpath('//nurl')))); $previousElement = null; //used in case we have to nest elements for qualified dublin core foreach ($form_values as $key => $value) { $index = strrpos($key, '-'); if ($index > 01) { $key = substr($key, 0, $index); } $value = trim($value); $test = substr($key, 0, 3); $element = substr($key, 4); if ($test == 'vid') { //don't try to process other form values try { $previousElement = $dom->createElement($element, $value); if (in_array($element, array('file', 'md5', 'size', 'note'))) { $proxies->appendChild($previousElement); } elseif (in_array($element, array('bitrate', 'framerate'))) { $metrics->appendChild($previousElement); } elseif (in_array($element, array('framewidth', 'frameheight'))) { $dimensions->appendChild($previousElement); } elseif (in_array($element, array('mime'))) { $format->appendChild($previousElement); } else { $vid->appendChild($previousElement); } } catch (exception $e) { drupal_set_message(t($e->getMessage()), 'error'); continue; } } if ($test == 'dis') { //don't try to process other form values try { $previousElement = $dom->createElement(substr($key, 4), $value); $dis->appendChild($previousElement); } catch (exception $e) { drupal_set_message(t($e->getMessage()), 'error'); continue; } } if ($test == 'gen') { //don't try to process other form values try { $previousElement = $dom->createElement(substr($key, 4), $value); $gen->appendChild($previousElement); } catch (exception $e) { drupal_set_message(t($e->getMessage()), 'error'); continue; } } if ($test == 'bib') { //don't try to process other form values try { $previousElement = $dom->createElement(substr($key, 4), $value); $bib->appendChild($previousElement); } catch (exception $e) { drupal_set_message(t($e->getMessage()), 'error'); continue; } } if ($test == 'dru') { //don't try to process other form values try { $previousElement = $dom->createElement(substr($key, 4), $value); $drup->appendChild($previousElement); } catch (exception $e) { drupal_set_message(t($e->getMessage()), 'error'); continue; } } //$rootElement->appendChild($datastream); } $proxies->appendChild($metrics); $proxies->appendChild($dimensions); $proxies->appendChild($format); $vid->appendChild($proxies); $mag->appendChild($vid); $mag->appendChild($gen); $mag->appendChild($bib); $mag->appendChild($dis); $mag->appendChild($drup); $dom->appendChild($mag); $params = array("pid" => "{$pid}", "dsID" => "MAG", "altIDs" => "", "dsLabel" => "Mag Metadata", "MIMEType" => "text/xml", "formatURI" => "", "dsContent" => $dom->saveXML(), "checksumType" => "DISABLED", "checksum" => "none", "logMessage" => "datastream_modified", "force" => "true"); //drupal_set_message($mag); $ccks = array(); module_load_include('php', 'Fedora_Repository', 'epistemetec/plugins/Node'); $node = new EpistemetecNode(); $ccks = $node->hashCCK($form_values); try { //$soapHelper = new ConnectionHelper(); //$client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); $object = $soap_client->__soapCall('ModifyDatastreamByValue', array($params)); $node->editNode($ccks); return $form_id; } catch (exception $e) { drupal_set_message(t("Error updating MAG metadata ") . $e->getMessage(), 'error'); } }