public function listAction() { $elementSetName = $this->_getParam('elset'); $elementName = $this->_getParam('elname'); $curPage = $this->_getParam('page'); $elementTextTable = $this->getDb()->getTable('ElementText'); $el = $this->getDb()->getTable('Element')->findByElementSetNameAndElementName($this->_unslugify($elementSetName), $this->_unslugify($elementName)); //$elTexts = $this->getDb()->getTable('ElementText')->findByElement($el->id); $select = $elementTextTable->getSelect()->where('element_id = ?', $el->id)->order('text')->group('text'); $elTexts = $elementTextTable->fetchObjects($select); //$sortedTexts = $elTexts->getSelect()->findByElement($el->id)->order('text'); $totalCategories = count($elTexts); release_object($el); // set-up pagination routine $paginationUrl = $this->getRequest()->getBaseUrl() . '/categories/list/' . $elementSetName . '/' . $elementName . "/"; /* $pageAdapter = new Zend_Paginator_Adapter_DbSelect($elementTextTable->getSelect()->where('element_id = ?', $el->id)->order('text')->group('text')); */ $paginator = Zend_Paginator::factory($select); $paginator->setItemCountPerPage(20); //$totalCategories = count($paginator); $paginator->setCurrentPageNumber($curPage); $this->view->paginator = $paginator; //Serve up the pagination // add other pagination items $pagination = array('page' => $curPage, 'per_page' => 20, 'total_results' => $totalCategories, 'link' => $paginationUrl); Zend_Registry::set('pagination', $pagination); //$this->view->assign(array('texts'=>$elTexts, 'elset'=>$elementSetName, 'elname'=>$elementName, 'total_results'=>$totalCategories)); $this->view->assign(array('elset' => $elementSetName, 'elname' => $elementName, 'total_results' => $totalCategories)); }
function emiglio_exhibit_builder_page_nav($exhibitPage = null, $currentPageId) { if (!$exhibitPage) { $exhibitPage = get_current_record('exhibit_page'); } $parents = array(); $currentPage = get_record_by_id('Exhibit Page', $currentPageId); while ($currentPage->parent_id) { $currentPage = $currentPage->getParent(); array_unshift($parents, $currentPage->id); } $class = ''; $class .= $exhibitPage->id == $currentPageId ? 'current' : ''; $parent = array_search($exhibitPage->id, $parents) !== false ? ' parent' : ''; $html = '<li class="' . $class . $parent . '">' . '<a href="' . exhibit_builder_exhibit_uri(get_current_record('exhibit'), $exhibitPage) . '">' . metadata($exhibitPage, 'title') . '</a>'; $children = $exhibitPage->getChildPages(); if ($children) { $html .= '<ul>'; foreach ($children as $child) { $html .= emiglio_exhibit_builder_page_nav($child, $currentPageId); release_object($child); } $html .= '</ul>'; } $html .= '</li>'; return $html; }
/** * This is a filter function. * * If the relation text begins with thumb:, then the thumb: portion * is stripped and the remaining urn is displayed as a thumbnail. * If the relation text begins with full:, the full: portion * is stripped and the remaining urn is displayed as a link. * * Any other relation text not meeting the criteria is simply returned as is. * * @param string - the text from the Relation field * @return string - this will be an img tag if thumb:, a href tag if full:, or currently existing text. */ public function replaceDigitalObjectRelations($text, $args) { //If the relation has a full string, check to see if it has a thumb relation. If so, then //display the thumb and link it out to the full image. Otherwise just make it a link. if (preg_match(get_option('digitalobjectlinkerplugin_preg_full_image_string'), $text)) { //Strip the full: from the text. $fulllink = substr($text, strlen(get_option('digitalobjectlinkerplugin_full_image_tag'))); $fullid = $this->parseUniqueId($fulllink); if ($fullid != 'no-id') { $fulllink = trim(str_replace($fullid . ":", "", $fulllink)); } //Create the link with parameters. $fulllinkwithparams = $fulllink . "?buttons=Y"; //The only way that I could find to get all relations during the filter was to pull the relations from the database. //Trying to pull from the metadata function seemed to throw this into an infinite loop. //This first gets the element_id for the 'Relation' element from the 'Element' table (omeka_elements if you are looking in the db). //Second, it then finds all of the 'Relation' element texts from the 'ElementText' table (omeka_element_texts) using //the record ID which was passed in from the filter and the element_id that was retrieved. $element = get_db()->getTable('Element')->findByElementSetNameAndElementName('Dublin Core', 'Relation'); $elementID = $element->id; //Record ID that was passed in from the filter. $recordID = $args['record']->id; //We no longer need the element object that we retrieved so releas it. release_object($element); //Create the select for the ElementText table. $select = get_db()->select()->from(array(get_db()->ElementText), array('text'))->where('record_id=' . $recordID . ' AND element_id = ' . $elementID); //Fetch all of the relations. They come back as an array in this form: //array(0 => array('text' => full:urn...), 1 => array('text' => thumb:urn....)) $relations = get_db()->getTable('ElementText')->fetchAll($select); //Logger::log($relations); //As long as at least one relation was returned, we can continue. if (count($relations) > 0) { foreach ($relations as $relation) { //Make sure the relation is not the full relation that we are filtering. If it isn't, //check to see if it is the thumb relation. if ($relation['text'] != $text && preg_match(get_option('digitalobjectlinkerplugin_preg_thumb_string'), $relation['text'])) { //Create a thumb image that links out to the full image. $thumblink = substr($relation['text'], strlen(get_option('digitalobjectlinkerplugin_thumb_tag'))); if (!empty($thumblink)) { $thumbid = $this->parseUniqueId($thumblink); if ($thumbid != 'no-id') { $thumblink = trim(str_replace($thumbid . ":", "", $thumblink)); } if ($fullid == $thumbid) { //Determine the width and height of the thumb. $width = is_admin_theme() ? get_option('digitalobjectlinkerplugin_width_admin') : get_option('digitalobjectlinkerplugin_width_public'); return "<div class=\"item-relation\"><a href=\"" . $fulllinkwithparams . "\" target=\"_blank\"><img src=\"" . $thumblink . "\" alt=\"" . $thumblink . "\" height=\"" . $width . "\"></img></a></div>"; } } } } } //If it reaches this point, the relations did not contain a thumbnail so return a plain link. return "<a href=\"" . $fulllinkwithparams . "\" target=\"_blank\">" . $fulllink . "</a>"; } elseif (!preg_match(get_option('digitalobjectlinkerplugin_preg_thumb_string'), $text)) { return $text; } return NULL; }
public function makeNotPublic() { $this->public = false; $item = $this->Item; $item->public = false; $item->save(); release_object($item); }
private function _filterResultsByCollection($results, $collection) { $collection_id = is_numeric($collection) ? $collection : $collection->id; foreach ($results as $index => $result) { if (!$result->appliesToCollection($collection_id)) { unset($results[$index]); release_object($result); } } return $results; }
public function getItems() { $iiTable = $this->getDb()->getTable('FeedImporter_ImportedItem'); $itemTable = $this->getDb()->getTable('Item'); $importedItems = $iiTable->findByImportId($this->id); $items = array(); foreach ($importedItems as $importedItem) { $items[] = $itemTable->find($importedItem->item_id); release_object($importedItem); } return $items; }
public function render(array $records) { $entries = array(); foreach ($records as $record) { $entries[] = $this->itemToRss($record); release_object($record); } $headers = $this->buildRSSHeaders(); $headers['entries'] = $entries; $feed = Zend_Feed::importArray($headers, 'rss'); return $feed->saveXML(); }
/** * Return a COinS span tag for every passed item. * * @param array|Item An array of item records or one item record. * @return string */ public function coins($items) { if (!is_array($items)) { return $this->_getCoins($items); } $coins = ''; foreach ($items as $item) { $coins .= $this->_getCoins($item); release_object($item); } return $coins; }
public function testCanInsertItem() { $db = $this->db; // Insert an item and verify with a second query. $item = insert_item(array('public' => true), array('Dublin Core' => array('Title' => array(array('text' => 'foobar', 'html' => true))))); $sql = "SELECT public FROM {$db->Item} WHERE id = {$item->id}"; $row = $db->fetchRow($sql); $this->assertEquals(array('public' => 1), $row); // Verify that element texts are inserted correctly into the database. $sql = "SELECT COUNT(id) FROM {$db->ElementText} WHERE html = 1 AND " . "text = 'foobar' AND record_id = {$item->id}"; $this->assertEquals(1, $db->fetchOne($sql)); release_object($item); }
public static function addItem(Omeka_Db $db) { // Keep the record objects from dying. Zend_Registry::get('bootstrap')->getContainer()->db = $db; $itemBuilder = new Builder_Item($db); // Item should be public to avoid weird issues with ACL integration // (test must authenticate a user in order to retrieve non-public // items). $itemBuilder->setRecordMetadata(array('public' => 1)); $itemBuilder->setElementTexts(array('Dublin Core' => array('Title' => array(array('text' => self::TEST_ITEM_TITLE, 'html' => 0))))); $item = $itemBuilder->build(); release_object($item); }
public function getCollectionNames() { $collectionTable = $this->getDb()->getTable('Collection'); $returnArray = array(); if (is_array(unserialize($this->collection_ids))) { foreach (unserialize($this->collection_ids) as $collection_id) { $collection = $collectionTable->find($collection_id); $returnArray[] = $collection->name; release_object($collection); } } return $returnArray; }
public function browseAction() { //TODO: select by feed_id if ($_POST) { foreach ($_POST['tc'] as $tcId => $data) { $record = $this->getTable()->find($tcId); foreach ($data as $field => $value) { switch ($field) { case 'elements_map': case 'tags_map': $value = serialize($value); break; } $record->{$field} = $value; $record->save(); } } } $page = $this->_getParam('page', 1); $table = $this->getTable(); $feed_id = $this->_getParam('feed_id'); $fi_tags = $table->findBy(array('feed_id' => $feed_id), 10, $page); $count = $table->fetchOne($table->getSelectForCount()->where('feed_id = ?', $feed_id)); /** * Now process the pagination * **/ $paginationUrl = $this->getRequest()->getBaseUrl() . '/tags/browse/'; //Serve up the pagination $pagination = array('page' => $page, 'per_page' => 10, 'total_results' => $count, 'link' => $paginationUrl); Zend_Registry::set('pagination', $pagination); $db = get_db(); $elSets = $db->getTable('ElementSet')->findAll(); //print_r($elSets); $elSetPairs = array(); foreach ($elSets as $elSet) { $elSetPairs[$elSet->id] = $elSet->name; release_object($elSet); } $tagTable = $db->getTable('Tag'); $o_tags = $tagTable->findBy(array('sort' => 'alpha')); $tagPairs = array(); foreach ($o_tags as $o_tag) { $tagPairs[$o_tag->id] = $o_tag->name; release_object($o_tag); } $priorityArray = range(1, 10); $this->view->assign(array('tags' => $fi_tags, 'debug' => $pagination, 'elSetPairs' => $elSetPairs, 'tagPairs' => $tagPairs, 'priorityArray' => $priorityArray, 'feed_id' => $feed_id)); }
public function testDeleteItem() { $item = insert_item(); $record = new OaipmhHarvester_Record(); $record->item_id = $item->id; $record->identifier = 'foo-bar'; $record->harvest_id = 10000; $record->datestamp = '2011-07-11'; $record->save(); $item->delete(); $table = $this->db->getTable('OaipmhHarvester_Record'); release_object($item); release_object($record); $this->assertEquals(0, $table->count()); }
public function getElementSetAndElement() { $db = get_db(); $elTable = $db->getTable('Element'); $retObject = new StdClass(); $el_ids = unserialize($this->element_ids); $retArray = array(); foreach ($el_ids as $el_id) { $el = $elTable->find($el_id); $elSet = $el->getElementSet(); $retArray[$elSet->name][] = $el->name; release_object($el); release_object($elSet); } return $retArray; }
public function perform() { $db = get_db(); //import the contributors to Guest Users $sql = "SELECT * FROM {$db->ContributionContributors}"; $res = $db->query($sql); $data = $res->fetchAll(); $contributorUserMap = array(); $validatorOptions = array('table' => $db->getTable('User')->getTableName(), 'field' => 'username', 'adapter' => $db->getAdapter()); $emailValidator = new Zend_Validate_EmailAddress(); foreach ($data as $contributor) { //create username from email and set up for some validation checks $username = $contributor['email']; $email = $contributor['email']; if ($user = $db->getTable('User')->findByEmail($contributor['email'])) { $userContributorMap[$user->id][] = $contributor['id']; } else { if (!$emailValidator->isValid($email)) { //can't save as a new user w/o valid unique email, so assign to superuser _log("Email {$email} is invalid. Assigning to super user.", Zend_Log::INFO); $user = $db->getTable('User')->find(1); } else { _log("Creating new guest user for email {$email}."); $user = new User(); $name = trim($contributor['name']); $user->username = $username; $user->name = empty($name) ? "user" : $name; $user->email = $email; $user->role = "guest"; $user->active = false; try { $user->save(); } catch (Exception $e) { _log($e->getMessage()); $user = $db->getTable('User')->find(1); } } $userContributorMap[$user->id] = array($contributor['id']); } release_object($user); } $this->_mapUsersToItems($userContributorMap); //we need to keep track of which contributors got mapped to which users //so that the UserProfiles import of contributor info can match people up $serialized = serialize($userContributorMap); $putResult = file_put_contents(CONTRIBUTION_PLUGIN_DIR . '/upgrade_files/user_contributor_map.txt', $serialized); }
public function perform() { $db = get_db(); $elementSet = new ElementSet(); $elementSet->record_type = "UserProfilesType"; $elementSet->name = "Contributor Elements"; $elementSet->description = ""; $elementSet->save(); $importData = $this->_importContributorFields($elementSet); $type_id = $importData['type_id']; $contribFieldElementMap = $importData['contribFieldElementMap']; $userContributorMap = unserialize(file_get_contents(CONTRIBUTION_PLUGIN_DIR . '/upgrade_files/user_contributor_map.txt')); foreach ($userContributorMap as $userId => $contributorIds) { $contribIds = implode(',', $contributorIds); $sql = "SELECT * FROM {$db->ContributionContributorValue} WHERE `contributor_id` IN ({$contribIds})"; $res = $db->query($sql); $contributorValues = $res->fetchAll(); $profile = new UserProfilesProfile(); $profile->owner_id = $userId; $profile->public = true; $profile->element_set_id = $elementSet->id; $profile->type_id = $type_id; $profile->setRelationData(array('subject_id' => $userId)); $profile->save(); $elTextArray = array(); foreach ($contributorValues as $value) { //dig up element_id $fieldId = $value['field_id']; $elementId = $contribFieldElementMap[$fieldId]; $elementText = new ElementText(); $elementText->element_id = $elementId; $elementText->text = $value['value']; $elementText->html = 0; $elementText->record_type = 'UserProfilesProfile'; $elementText->record_id = $profile->id; $elementText->save(); release_object($elementText); } release_object($profile); } set_option('user_profiles_contributors_imported', true); }
/** * Process all PDF files in Omeka. */ public function perform() { $pdfTextPlugin = new PdfTextPlugin(); $fileTable = $this->_db->getTable('File'); $select = $this->_db->select()->from($this->_db->File)->where('mime_type IN (?)', $pdfTextPlugin->getPdfMimeTypes()); // Iterate all PDF file records. $pageNumber = 1; while ($files = $fileTable->fetchObjects($select->limitPage($pageNumber, 50))) { foreach ($files as $file) { // Delete any existing PDF text element texts from the file. $textElement = $file->getElement(PdfTextPlugin::ELEMENT_SET_NAME, PdfTextPlugin::ELEMENT_NAME); $file->deleteElementTextsByElementId(array($textElement->id)); // Extract the PDF text and add it to the file. $file->addTextForElement($textElement, $pdfTextPlugin->pdfToText(FILES_DIR . '/original/' . $file->filename)); $file->save(); // Prevent memory leaks. release_object($file); } $pageNumber++; } }
/** * Bulk index all valid records. */ public function perform() { // Truncate the `search_texts` table before indexing to clean out // obsolete records. $sql = "TRUNCATE TABLE {$this->_db->SearchText}"; $this->_db->query($sql); foreach (get_custom_search_record_types() as $key => $value) { $recordType = is_string($key) ? $key : $value; if (!class_exists($recordType)) { // The class does not exist or cannot be found. continue; } $record = new $recordType(); if (!$record instanceof Omeka_Record_AbstractRecord) { // The class is not a valid record. continue; } if (!is_callable(array($record, 'addSearchText'))) { // The record does not implement the search mixin. continue; } $pageNumber = 1; $recordTable = $record->getTable(); // Query a limited number of rows at a time to prevent memory issues. while ($recordObjects = $recordTable->fetchObjects($recordTable->getSelect()->limitPage($pageNumber, 100))) { foreach ($recordObjects as $recordObject) { // Save the record object, which indexes its search text. try { $recordObject->save(); } catch (Omeka_Validate_Exception $e) { _log($e, Zend_Log::ERR); _log(sprintf('Failed to index %s #%s', get_class($recordObject), $recordObject->id), Zend_Log::ERR); } release_object($recordObject); } $pageNumber++; } } }
public function getElementSetsAndElements() { $terms = $this->findAll(); $returnArray = array(); foreach ($terms as $term) { $termData = $term->getElementSetAndElement(); $elSets = array_keys($termData); foreach ($elSets as $elSet) { if (isset($returnArray[$elSet])) { $returnArray[$elSet] = array_merge($returnArray[$elSet], $termData[$elSet]); } else { $returnArray[$elSet] = array(); $returnArray[$elSet] = array_merge($returnArray[$elSet], $termData[$elSet]); } } release_object($term); } foreach ($returnArray as $elSet => $array) { $returnArray[$elSet] = array_unique($array); } return $returnArray; }
public function hookAfterSaveItem($args) { $item = $args['record']; $post = $args['post']; if (!($post && isset($post['dropbox-files']))) { return; } $fileNames = $post['dropbox-files']; if ($fileNames) { if (!dropbox_can_access_files_dir()) { throw new Dropbox_Exception(__('The Dropbox files directory must be both readable and writable.')); } $filePaths = array(); foreach ($fileNames as $fileName) { $filePaths[] = dropbox_validate_file($fileName); } $files = array(); try { $files = insert_files_for_item($item, 'Filesystem', $filePaths, array('file_ingest_options' => array('ignore_invalid_files' => false))); } catch (Omeka_File_Ingest_InvalidException $e) { release_object($files); $item->addError('Dropbox', $e->getMessage()); return; } catch (Exception $e) { release_object($files); throw $e; } release_object($files); // delete the files foreach ($filePaths as $filePath) { try { unlink($filePath); } catch (Exception $e) { throw $e; } } } }
/** * Create a new Item for each of the given files. * * @param array $filenames * @return array An array of errors that occurred when creating the * Items, indexed by the filename that caused the error. */ protected function _uploadFiles($fileNames) { if (!dropbox_can_access_files_dir()) { throw new Dropbox_Exception('The Dropbox files directory must be both readable and writable.'); } $fileErrors = array(); foreach ($fileNames as $fileName) { $item = null; try { $filePath = dropbox_validate_file($fileName); $itemMetadata = array('public' => $_POST['dropbox-public'], 'featured' => $_POST['dropbox-featured'], 'collection_id' => $_POST['dropbox-collection-id'] ? $_POST['dropbox-collection-id'] : null, 'tags' => $_POST['dropbox-tags']); $elementTexts = array('Dublin Core' => array('Title' => array(array('text' => $fileName, 'html' => false)))); $fileMetadata = array('file_transfer_type' => 'Filesystem', 'file_ingest_options' => array('ignore_invalid_files' => false), 'files' => array($filePath)); $item = insert_item($itemMetadata, $elementTexts, $fileMetadata); release_object($item); // delete the file from the dropbox folder unlink($filePath); } catch (Exception $e) { release_object($item); $fileErrors[$fileName] = $e->getMessage(); } } return $fileErrors; }
public function perform() { if (!($itemIds = $this->_options['itemIds'])) { return; } $delete = $this->_options['delete']; $metadata = $this->_options['metadata']; $custom = $this->_options['custom']; foreach ($itemIds as $id) { $item = $this->_getItem($id); if ($delete == '1') { $item->delete(); } else { foreach ($metadata as $key => $value) { if ($value === '') { unset($metadata[$key]); } } update_item($item, $metadata); fire_plugin_hook('items_batch_edit_custom', array('item' => $item, 'custom' => $custom)); } release_object($item); } }
/** * Get HTML for random featured items. * * @package Omeka\Function\View\Item * @uses get_random_featured_items() * @param int $count Maximum number of items to show. * @param boolean $withImage Whether or not the featured items must have * images associated. If null, as default, all featured items can appear, * whether or not they have files. If true, only items with files will appear, * and if false, only items without files will appear. * @return string */ function random_featured_items($count = 5, $hasImage = null) { $items = get_random_featured_items($count, $hasImage); if ($items) { $html = ''; foreach ($items as $item) { $html .= get_view()->partial('items/single.php', array('item' => $item)); release_object($item); } } else { $html = '<p>' . __('No featured items are available.') . '</p>'; } return $html; }
?> </h2> <div class="five columns omega"> <ul> <?php $itemCheckboxes = array(); foreach ($itemIds as $id) { if (!($item = get_record_by_id('item', $id))) { continue; } $showItemFields = true; if (!is_allowed($item, 'edit') || !is_allowed($item, 'delete')) { $showItemFields = false; } $itemCheckboxes[$id] = strip_formatting(metadata($item, array('Dublin Core', 'Title'), array('no_escape' => true))); release_object($item); } echo '<li>' . $this->formMultiCheckbox('items[]', null, array('checked' => 'checked'), $itemCheckboxes, '</li><li>') . '</li>'; ?> </ul> <p class="explanation"><?php echo __('Changes will be applied to checked items.'); ?> </p> </div> </fieldset> <fieldset id="item-fields"> <h2><?php echo __('Item Metadata'); ?>
public function tearDown() { release_object($this->super); release_object($this->admin); parent::tearDown(); }
/** * Adds a new item based on a row string in the CSV file and returns it. * * @param string $row A row string in the CSV file * @return Item|boolean The inserted item or false if an item could not be added. */ protected function _addItemFromRow($row) { $result = $this->getColumnMaps()->map($row); $tags = $result[CsvImport_ColumnMap::TYPE_TAG]; $itemMetadata = array(Builder_Item::IS_PUBLIC => $this->is_public, Builder_Item::IS_FEATURED => $this->is_featured, Builder_Item::ITEM_TYPE_ID => $this->item_type_id, Builder_Item::COLLECTION_ID => $this->collection_id, Builder_Item::TAGS => $tags); // If this is coming from CSV Report, bring in the itemmetadata coming from the report if (!is_null($result[CsvImport_ColumnMap::TYPE_COLLECTION])) { $itemMetadata[Builder_Item::COLLECTION_ID] = $result[CsvImport_ColumnMap::TYPE_COLLECTION]; } if (!is_null($result[CsvImport_ColumnMap::TYPE_PUBLIC])) { $itemMetadata[Builder_Item::IS_PUBLIC] = $result[CsvImport_ColumnMap::TYPE_PUBLIC]; } if (!is_null($result[CsvImport_ColumnMap::TYPE_FEATURED])) { $itemMetadata[Builder_Item::IS_FEATURED] = $result[CsvImport_ColumnMap::TYPE_FEATURED]; } if (!empty($result[CsvImport_ColumnMap::TYPE_ITEM_TYPE])) { $itemMetadata[Builder_Item::ITEM_TYPE_NAME] = $result[CsvImport_ColumnMap::TYPE_ITEM_TYPE]; } $elementTexts = $result[CsvImport_ColumnMap::TYPE_ELEMENT]; try { $item = insert_item($itemMetadata, $elementTexts); } catch (Omeka_Validator_Exception $e) { $this->_log($e, Zend_Log::ERR); return false; } catch (Omeka_Record_Builder_Exception $e) { $this->_log($e, Zend_Log::ERR); return false; } $fileUrls = $result[CsvImport_ColumnMap::TYPE_FILE]; foreach ($fileUrls as $url) { try { $file = insert_files_for_item($item, 'Url', $url, array('ignore_invalid_files' => false)); } catch (Omeka_File_Ingest_InvalidException $e) { $msg = "Invalid file URL '{$url}': " . $e->getMessage(); $this->_log($msg, Zend_Log::ERR); $item->delete(); release_object($item); return false; } catch (Omeka_File_Ingest_Exception $e) { $msg = "Could not import file '{$url}': " . $e->getMessage(); $this->_log($msg, Zend_Log::ERR); $item->delete(); release_object($item); return false; } release_object($file); } // Makes it easy to unimport the item later. $this->_recordImportedItemId($item->id); return $item; }
private function _addNewUserWithRole($role) { $username = $role . 'user'; $existingUser = $this->_getUser($username); if ($existingUser) { $existingUser->delete(); release_object($existingUser); } $newUser = new User(); $newUser->username = $username; $newUser->setPassword('foobar'); $newUser->role = $role; $newUser->active = 1; $newUser->name = ucwords($role) . ' User'; $newUser->email = $role . '@example.com'; $newUser->save(); return $newUser; }
/** * Check simultaneous change of identifier and collection of the item. */ protected function _testChangeIdentifierAndCollection() { $elementSetName = 'Dublin Core'; $elementName = 'Identifier'; // Create a new collection. $this->collection = insert_collection(array('public' => true)); // Need to release item and to reload it. $itemId = $this->item->id; release_object($this->item); $this->item = get_record_by_id('Item', $itemId); // Update item. update_item($this->item, array('collection_id' => $this->collection->id, 'overwriteElementTexts' => true), array($elementSetName => array($elementName => array(array('text' => 'my_new_item_identifier', 'html' => false))))); $files = $this->item->getFiles(); foreach ($files as $key => $file) { $this->_checkFile($file); } }
public function tearDown() { release_object($this->_users); release_object($this->_items); parent::tearDown(); }
public function _mapOwners($contribItemData, $map) { $itemTable = $this->_db->getTable('Item'); foreach ($contribItemData as $contribItem) { $item = $itemTable->find($contribItem['item_id']); $item->owner_id = $map[$contribItem['contributor_id']]; $item->save(); release_object($item); } }