示例#1
0
 /**
  * {@inheritDoc}
  */
 public function termDelete(\stdClass $term)
 {
     $status = 0;
     if (isset($term->tid)) {
         $status = \taxonomy_term_delete($term->tid);
     }
     // Will be SAVED_DELETED (3) on success.
     return $status;
 }
示例#2
0
 /**
  * Delete a taxonomy term.
  *
  * @param int $tid
  *    Taxonomy term ID.
  *
  * @return int
  *   Constant indicating items were deleted.
  */
 public function deleteTaxonomyTerm($tid)
 {
     return taxonomy_term_delete($tid);
 }
示例#3
0
 /**
  * Delete entities. This is a copy of entity_delete_multiple() function in
  * entity.module since entity module may not be present.
  *
  * @param string $entity_type
  *   Entity type.
  * @param int $min_entity_id
  *  Minimum entity id over which all entities will be deleted.
  *
  * @return bool
  *   TRUE if entities got deleted and FALSE otherwise.
  */
 public static function deleteEntities($entity_type, $min_entity_id)
 {
     $query = new \EntityFieldQuery();
     $results = $query->entityCondition('entity_type', $entity_type)->entityCondition('entity_id', $min_entity_id, '>')->execute();
     if (isset($results[$entity_type])) {
         $entity_ids = array_keys($results[$entity_type]);
         $info = entity_get_info($entity_type);
         if (isset($info['deletion callback'])) {
             foreach ($entity_ids as $id) {
                 $info['deletion callback']($id);
             }
         } elseif (in_array('EntityAPIControllerInterface', class_implements($info['controller class']))) {
             entity_get_controller($entity_type)->delete($entity_ids);
         } else {
             if ($entity_type == 'node') {
                 node_delete_multiple($entity_ids);
             } elseif ($entity_type == 'user') {
                 user_delete_multiple($entity_ids);
             } elseif ($entity_type == 'taxonomy_term') {
                 foreach ($entity_ids as $entity_id) {
                     taxonomy_term_delete($entity_id);
                 }
             } elseif ($entity_type == 'comment') {
                 foreach ($entity_ids as $entity_id) {
                     comment_delete($entity_id);
                 }
             }
             return FALSE;
         }
     }
 }
示例#4
0
 function createAndCheckForum($id, $tag, $description, array $accesses)
 {
     $this->setUp2();
     taxonomy_term_delete(1);
     $this->pass("#########################<br />#{$id} - {$tag} Configuration test @" . (time() - $this->time), '<a id="jump1" href="#jump2">/\\<br />######<br />\\/</a>');
     $forum = $this->createForum($id, $tag, $description, $accesses);
     $this->checkForum($forum);
     $this->pass("#########################<br />#{$id} - END {$tag} Configuration test @" . (time() - $this->time), '<a id="jump2" href="#jump3">/\\<br />######<br />\\/</a>');
 }
<?php

// Create some variables.
$clear_old_terms = TRUE;
$vocabulary = 'vocab_machine_name';
$new_terms = array('Example 1', 'Example 2', 'Example 3');
// Load the vocabulary ID.
$vid = taxonomy_vocabulary_machine_name_load($vocabulary)->vid;
// Check if we want to clear out the old terms from the vocabulary.
if ($clear_old_terms == TRUE) {
    $terms = taxonomy_get_tree((int) $vid);
    foreach ($terms as $t) {
        taxonomy_term_delete($t->tid);
    }
}
// Create new terms from the $new_terms array.
foreach ($new_terms as $item) {
    $new_term = new stdClass();
    $new_term->name = $item;
    $new_term->vid = $vid;
    taxonomy_term_save($new_term);
}
示例#6
0
$PAGE->set_title($site->fullname);
$PAGE->navbar->add(get_string('navbartaxonomy', 'local_taxonomy'), new moodle_url('/local/taxonomy/index.php'));
$courseshortname = $term->shortname;
if (!$delete) {
    $strdeletecheck = get_string("deletecheck", "", $term->name);
    $strdeletecoursecheck = get_string("term:delete:confirm", 'local_taxonomy');
    $PAGE->navbar->add($strdeletecheck);
    $PAGE->set_title("{$site->shortname}: {$strdeletecheck}");
    $PAGE->set_heading($site->fullname);
    echo $OUTPUT->header();
    $message = "{$strdeletecoursecheck} <br/><br/><b style=\"margin-left: 80px;\">" . $term->name . "</b>";
    echo $OUTPUT->confirm($message, "TermDeletePage.php?id={$term->id}&delete=" . md5($term->shortname), "/local/taxonomy/index.php");
    echo $OUTPUT->footer();
    exit;
}
if ($delete != md5($term->shortname)) {
    print_error("invalidmd5");
}
if (!confirm_sesskey()) {
    print_error('confirmsesskeybad', 'error');
}
// OK checks done, delete the course now.
$strdeletingcourse = get_string("deletingcourse", "", $courseshortname);
$PAGE->navbar->add($strdeletingcourse);
$PAGE->set_title("{$site->shortname}: {$strdeletingcourse}");
$PAGE->set_heading($site->fullname);
echo $OUTPUT->header();
echo $OUTPUT->heading($strdeletingcourse);
taxonomy_term_delete($term);
echo $OUTPUT->continue_button("/local/taxonomy/index.php");
echo $OUTPUT->footer();
示例#7
0
 public function deleteProgrammatically()
 {
     taxonomy_term_delete($this->getId());
     return TRUE;
 }
示例#8
0
 /**
  * Delete a term in a given vocabulary.
  *
  * @param $term_name
  *  The name of the term.
  */
 public static function DeleteTerm($term_name)
 {
     $taxonomies = taxonomy_get_term_by_name($term_name);
     $term = reset($taxonomies);
     taxonomy_term_delete($term->tid);
 }
                        // Check if parent exists.
                        if ($item['target_id'] == $parent_id) {
                            $parent_found = TRUE;
                        }
                    }
                    if ($parent_found) {
                        // Remove child.
                        foreach ($items as $i => $item) {
                            if ($item['target_id'] == $row->tid) {
                                unset($node->field_location[$lang][$i]);
                                break;
                            }
                        }
                    } else {
                        // Replace child with parent.
                        foreach ($items as $i => $item) {
                            if ($item['target_id'] == $row->tid) {
                                $node->field_location[$lang][$i]['target_id'] = $parent_id;
                                break;
                            }
                        }
                    }
                }
            }
            node_save($node);
        }
    } else {
        taxonomy_term_delete($row->tid);
        drush_log('Deleting ' . $row->tid . ': ' . $row->l1 . ' > ' . $row->l2 . ' > ' . $row->l3 . ' > ' . $row->l4 . ' > ' . $row->l5);
    }
}