/** * Add the subpage vocabulary * */ public function action_plugin_activation($file) { if (Plugins::id_from_file($file) == Plugins::id_from_file(__FILE__)) { $params = array('name' => self::$vocabulary, 'description' => 'A vocabulary for describing hierarchical relationships between pages', 'features' => array('hierarchical')); $subpages = new Vocabulary($params); $subpages->insert(); } }
/** * Create a vocabulary and save it. * * @param array $paramarray An associative array of vocabulary fields * @return Vocabulary The new vocabulary object */ static function create($paramarray) { $vocabulary = new Vocabulary($paramarray); $vocabulary->insert(); return $vocabulary; }
/** * Add the tags vocabulary */ private function create_tags_vocabulary() { $vocabulary = new Vocabulary(array('name' => 'tags', 'description' => 'Habari\'s tags implementation', 'features' => array('multiple', 'free'))); $vocabulary->insert(); return true; }
public function test_delete_vocabulary() { // Set up // Create and insert a vocabulary $params = array( 'name' => $this->vocab_name, 'description' => $this->vocab_desc, 'features' => array( 'hierarchical' ) ); $v = new Vocabulary( $params ); $v->insert(); // Count the number of vocabularies before deletion $vocab_count = count( Vocabulary::names() ); // Retrieve and delete vocabulary $v = Vocabulary::get( $this->vocab_name ); try { $v->delete(); } catch ( Exception $e ) { echo 'Caught exception: ',$e->getMessage(), "\n"; } $this->assert_equal( $vocab_count - 1, count( Vocabulary::names() ), 'Number of vocabularies should decrease by one' ); $this->assert_false( in_array( $this->vocab_name, Vocabulary::names() ), 'Deleted vocabulary name should not be in list of vocabulary names' ); }
/** * Set up needed permissions */ private static function install() { // Create post types Post::add_new_type('forum'); Post::add_new_type('thread'); Post::add_new_type('reply'); // Create vocabulary $params = array('name' => self::$vocab, 'description' => 'A vocabulary for describing relationships between threads', 'features' => array('hierarchical')); $vocabulary = new Vocabulary($params); $vocabulary->insert(); // Create tokens ACL::create_token('forum_see_private', _t('See Private Threads'), 'Forum', false); ACL::create_token('forum_close_thread', _t('Close Threads'), 'Forum', false); // Grant tokens $group = UserGroup::get_by_name('admin'); $group->grant('forum_close_thread'); $group->grant('forum_see_private'); }
public function test_update_vocabulary() { // Set up // Create and insert a vocabulary $params = array('name' => $this->vocab_name, 'description' => $this->vocab_desc, 'features' => array('hierarchical')); $v = new Vocabulary($params); $v->insert(); // Change description and update $v = Vocabulary::get($this->vocab_name); $v->description = "new description"; $v->update(); // Re-retrieve vocabulary (this step may be unnecessary) $v = Vocabulary::get($this->vocab_name); $this->assert_equal($v->description, "new description", 'Vocabulary description was not updated'); $v->delete(); }