public function testOwnerIdNotSetWhenUpdatingCollection() { $user = $this->_getDefaultUser(); $this->_authenticateUser($user); //create collection $collection = new Collection(); $elementTexts = array('Dublin Core' => array('Title' => array(array('text' => 'foobar', 'html' => false)), 'Description' => array(array('text' => 'baz', 'html' => false)))); $collection->addElementTextsByArray($elementTexts); $collection->owner_id = $user->id + 1; $collection->save(); $csrf = new Omeka_Form_Element_SessionCsrfToken('csrf_token'); $this->request->setPost(array('Elements' => array(), 'csrf_token' => $csrf->getToken())); $this->request->setMethod('post'); $this->dispatch('collections/edit/' . $collection->id); $this->assertRedirect(); $updatedCollection = $this->db->getTable('Collection')->find($collection->id); $this->assertNotEquals($user->id, $updatedCollection->owner_id, "The owner_id for the collection should not be that of the user who updated the collection."); }
/** * * @return void */ public function browseAction() { $params = $this->_getAllParams(); $perms = array(); //Check to see whether it will be tags for exhibits or for items //Default is Item if (isset($params['tagType'])) { $for = $params['tagType']; unset($params['tagType']); } else { $for = 'Item'; } //Since tagType must correspond to a valid classname, this will barf an error on Injection attempts if (!class_exists($for)) { throw new InvalidArgumentException(__('Invalid tagType given.')); } if ($record = $this->_getParam('record')) { $filter['record'] = $record; } //For the count, we only need to check based on permission levels $count_params = array_merge($perms, array('type' => $for)); $total_tags = $this->_helper->db->count($count_params); $findByParams = array_merge(array('sort_field' => 'name'), $params, $perms, array('type' => $for)); $limit = isset($params['limit']) ? $params['limit'] : null; $tags = $this->_helper->db->findBy($findByParams, $limit); $total_results = count($tags); Zend_Registry::set('total_tags', $total_tags); Zend_Registry::set('total_results', $total_results); $browse_for = $for; $sort = array_intersect_key($findByParams, array('sort_field' => '', 'sort_dir' => '')); //dig up the record types for filtering $db = get_db(); $sql = "SELECT DISTINCT record_type FROM `{$db->RecordsTag}`"; $record_types = array_keys($db->fetchAssoc($sql)); foreach ($record_types as $index => $record_type) { if (!class_exists($record_type)) { unset($record_types[$index]); } } $csrf = new Omeka_Form_Element_SessionCsrfToken('csrf_token'); $this->view->csrfToken = $csrf->getToken(); $this->view->record_types = $record_types; $this->view->assign(compact('tags', 'total_tags', 'browse_for', 'sort')); }
/** * Adds an element text with dirty html to a post array * @param string $dirtyHtml The dirty html to add to the new element text * @param string $elementSetName The element set name of the new element text * @param string $elementSetName The element name of the new element text * @param string $post The post array to which to add an element text * @return array $post **/ protected function _addElementTextWithDirtyHtmlToPost($dirtyHtml, $elementSetName, $elementName, $post = array()) { $titleElement = $this->db->getTable('Element')->findByElementSetNameAndElementName($elementSetName, $elementName); $elementsArray = array(); $elementsArray[strval($titleElement->id)] = array(array('text' => $dirtyHtml, 'html' => 1)); $post['Elements'] = $elementsArray; $csrf = new Omeka_Form_Element_SessionCsrfToken('csrf_token'); $post['csrf_token'] = $csrf->getToken(); return $post; }