本文整理汇总了PHP中tag_delete函数的典型用法代码示例。如果您正苦于以下问题:PHP tag_delete函数的具体用法?PHP tag_delete怎么用?PHP tag_delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tag_delete函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: test_tag_set_add
/**
* Test the tag_set_add function.
*/
public function test_tag_set_add()
{
global $DB;
// Create a course to tag.
$course = $this->getDataGenerator()->create_course();
// Create the tag and tag instance.
tag_set_add('course', $course->id, 'A random tag', 'core', context_course::instance($course->id)->id);
// Get the tag instance that should have been created.
$taginstance = $DB->get_record('tag_instance', array('itemtype' => 'course', 'itemid' => $course->id), '*', MUST_EXIST);
$this->assertEquals('core', $taginstance->component);
$this->assertEquals(context_course::instance($course->id)->id, $taginstance->contextid);
// Remove the tag we just created.
$tag = $DB->get_record('tag', array('rawname' => 'A random tag'));
tag_delete($tag->id);
// Now call the tag_set_add function without specifying the component or
// contextid and ensure the function debugging is called.
tag_set_add('course', $course->id, 'Another tag');
$this->assertDebuggingCalled();
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:22,代码来源:taglib_test.php
示例2: tag_cleanup
/**
* Clean up the tag tables, making sure all tagged object still exists.
*
* This should normally not be necessary, but in case related tags are not deleted
* when the tagged record is removed, this should be done once in a while, perhaps on
* an occasional cron run. On a site with lots of tags, this could become an expensive
* function to call: don't run at peak time.
*/
function tag_cleanup()
{
global $CFG;
$instances = get_recordset('tag_instance');
// cleanup tag instances
while ($instance = rs_fetch_next_record($instances)) {
$delete = false;
if (!record_exists('tag', 'id', $instance->tagid)) {
// if the tag has been removed, instance should be deleted.
$delete = true;
} else {
switch ($instance->itemtype) {
case 'user':
// users are marked as deleted, but not actually deleted
if (record_exists('user', 'id', $instance->itemid, 'deleted', 1)) {
$delete = true;
}
break;
default:
// anything else, if the instance is not there, delete.
if (!record_exists($instance->itemtype, 'id', $instance->itemid)) {
$delete = true;
}
break;
}
}
if ($delete) {
tag_delete_instance($instance->itemtype, $instance->itemid, $instance->tagid);
//debugging('deleting tag_instance #'. $instance->id .', linked to tag id #'. $instance->tagid, DEBUG_DEVELOPER);
}
}
rs_close($instances);
// TODO: this will only clean tags of type 'default'. This is good as
// it won't delete 'official' tags, but the day we get more than two
// types, we need to fix this.
$unused_tags = get_recordset_sql("SELECT tg.id FROM {$CFG->prefix}tag tg WHERE tg.tagtype = 'default' AND NOT EXISTS (" . "SELECT 'x' FROM {$CFG->prefix}tag_instance ti WHERE ti.tagid = tg.id)");
// cleanup tags
while ($unused_tag = rs_fetch_next_record($unused_tags)) {
tag_delete($unused_tag->id);
//debugging('deleting unused tag #'. $unused_tag->id, DEBUG_DEVELOPER);
}
rs_close($unused_tags);
}
开发者ID:r007,项目名称:PMoodle,代码行数:51,代码来源:lib.php
示例3: delete_otags
function delete_otags($tagids, $sitecontext)
{
foreach ($tagids as $tagid) {
if (!($tag = tag_by_id($tagid))) {
error('Can not delete tag, tag doesn\'t exist');
}
if ($tag->tagtype != 'official') {
continue;
}
if ($tag->tagtype == 'official' and !has_capability('moodle/blog:manageofficialtags', $sitecontext)) {
//can not delete
error('Can not delete tag, you don\'t have permission to delete an official tag');
}
// Delete the tag itself
if (!tag_delete($tagid)) {
error('Can not delete tag');
}
}
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:19,代码来源:edit.php
示例4: test_tag_deleted
/**
* Test the tag deleted event.
*/
public function test_tag_deleted()
{
global $DB;
$this->setAdminUser();
// Create a course.
$course = $this->getDataGenerator()->create_course();
// Create tag we are going to delete.
$tag = $this->getDataGenerator()->create_tag();
// Trigger and capture the event for deleting a tag.
$sink = $this->redirectEvents();
tag_delete($tag->id);
$events = $sink->get_events();
$event = reset($events);
// Check that the tag was deleted and the event data is valid.
$this->assertEquals(0, $DB->count_records('tag'));
$this->assertInstanceOf('\\core\\event\\tag_deleted', $event);
$this->assertEquals(context_system::instance(), $event->get_context());
// Create two tags we are going to delete to ensure passing multiple tags work.
$tag = $this->getDataGenerator()->create_tag();
$tag2 = $this->getDataGenerator()->create_tag();
// Trigger and capture the events for deleting multiple tags.
$sink = $this->redirectEvents();
tag_delete(array($tag->id, $tag2->id));
$events = $sink->get_events();
// Check that the tags were deleted and the events data is valid.
$this->assertEquals(0, $DB->count_records('tag'));
foreach ($events as $event) {
$this->assertInstanceOf('\\core\\event\\tag_deleted', $event);
$this->assertEquals(context_system::instance(), $event->get_context());
}
// Create another tag to delete.
$tag = $this->getDataGenerator()->create_tag();
// Add a tag instance to a course.
tag_assign('course', $course->id, $tag->id, 0, 2, 'course', context_course::instance($course->id)->id);
// Trigger and capture the event for deleting a personal tag for a user for a course.
$sink = $this->redirectEvents();
coursetag_delete_keyword($tag->id, 2, $course->id);
$events = $sink->get_events();
$event = $events[1];
// Check that the tag was deleted and the event data is valid.
$this->assertEquals(0, $DB->count_records('tag'));
$this->assertInstanceOf('\\core\\event\\tag_deleted', $event);
$this->assertEquals(context_system::instance(), $event->get_context());
// Create a new tag we are going to delete.
$tag = $this->getDataGenerator()->create_tag();
// Add the tag instance to the course again as it was deleted.
tag_assign('course', $course->id, $tag->id, 0, 2, 'course', context_course::instance($course->id)->id);
// Trigger and capture the event for deleting all tags in a course.
$sink = $this->redirectEvents();
coursetag_delete_course_tags($course->id);
$events = $sink->get_events();
$event = $events[1];
// Check that the tag was deleted and the event data is valid.
$this->assertEquals(0, $DB->count_records('tag'));
$this->assertInstanceOf('\\core\\event\\tag_deleted', $event);
$this->assertEquals(context_system::instance(), $event->get_context());
// Create two tags we are going to delete to ensure passing multiple tags work.
$tag = $this->getDataGenerator()->create_tag();
$tag2 = $this->getDataGenerator()->create_tag();
// Add multiple tag instances now and check that it still works.
tag_assign('course', $course->id, $tag->id, 0, 2, 'course', context_course::instance($course->id)->id);
tag_assign('course', $course->id, $tag2->id, 0, 2, 'course', context_course::instance($course->id)->id);
// Trigger and capture the event for deleting all tags in a course.
$sink = $this->redirectEvents();
coursetag_delete_course_tags($course->id);
$events = $sink->get_events();
$events = array($events[2], $events[3]);
// Check that the tags were deleted and the events data is valid.
$this->assertEquals(0, $DB->count_records('tag'));
foreach ($events as $event) {
$this->assertInstanceOf('\\core\\event\\tag_deleted', $event);
$this->assertEquals(context_system::instance(), $event->get_context());
}
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:77,代码来源:events_test.php
示例5: Copyright
<?php
# Mantis - a php based bugtracking system
# Copyright (C) 2000 - 2002 Kenzaburo Ito - [email protected]
# Copyright (C) 2002 - 2007 Mantis Team - [email protected]
# Mantis is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Mantis is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Mantis. If not, see <http://www.gnu.org/licenses/>.
# --------------------------------------------------------
# $Id: tag_delete.php,v 1.1.2.1 2007-10-13 22:34:44 giallu Exp $
# --------------------------------------------------------
require_once 'core.php';
$t_core_path = config_get('core_path');
require_once $t_core_path . 'tag_api.php';
form_security_validate('tag_delete');
access_ensure_global_level(config_get('tag_edit_threshold'));
$f_tag_id = gpc_get_int('tag_id');
$t_tag_row = tag_get($f_tag_id);
helper_ensure_confirmed(lang_get('tag_delete_message'), lang_get('tag_delete_button'));
tag_delete($f_tag_id);
form_security_purge('tag_delete');
print_successful_redirect(config_get('default_home_page'));
开发者ID:renemilk,项目名称:spring-website,代码行数:31,代码来源:tag_delete.php
示例6: mc_tag_delete
/**
*
* Deletes a tag
*
* @param string $p_username The user's username
* @param string $p_password The user's password * @param unknown_type $p_tag_id
* @param int $p_tag_id The id of the tag
* @return soap_fault|boolean
*/
function mc_tag_delete($p_username, $p_password, $p_tag_id)
{
$t_user_id = mci_check_login($p_username, $p_password);
if ($t_user_id === false) {
return mci_soap_fault_login_failed();
}
if (!access_has_global_level(config_get('tag_edit_threshold'))) {
return mci_soap_fault_access_denied($t_user_id);
}
if (!tag_exists($p_tag_id)) {
return SoapObjectsFactory::newSoapFault('Client', 'No tag with id ' . $p_tag_id);
}
return tag_delete($p_tag_id);
}
开发者ID:fur81,项目名称:zofaxiopeu,代码行数:23,代码来源:mc_tag_api.php
示例7: array
// get all the possible tag types from db
$existing_tagtypes = array();
if ($ptypes = $DB->get_records_sql("SELECT DISTINCT(tagtype) FROM {tag}")) {
foreach ($ptypes as $ptype) {
$existing_tagtypes[$ptype->tagtype] = $ptype->tagtype;
}
}
$existing_tagtypes['official'] = get_string('tagtype_official', 'tag');
$existing_tagtypes['default'] = get_string('tagtype_default', 'tag');
switch ($action) {
case 'delete':
if (!data_submitted() or !confirm_sesskey()) {
break;
}
$str_tagschecked = implode(', ', tag_get_name($tagschecked));
tag_delete($tagschecked);
$notice = $str_tagschecked . ' -- ' . get_string('deleted', 'tag');
break;
case 'reset':
if (!data_submitted() or !confirm_sesskey()) {
break;
}
$str_tagschecked = implode(', ', tag_get_name($tagschecked));
tag_unset_flag($tagschecked);
$notice = $str_tagschecked . ' -- ' . get_string('reset', 'tag');
break;
case 'changetype':
if (!data_submitted() or !confirm_sesskey()) {
break;
}
$changed = array();
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:31,代码来源:manage.php
示例8: tag_cleanup
/**
* Clean up the tag tables, making sure all tagged object still exists.
*
* This should normally not be necessary, but in case related tags are not deleted
* when the tagged record is removed, this should be done once in a while, perhaps on
* an occasional cron run. On a site with lots of tags, this could become an expensive
* function to call: don't run at peak time.
*/
function tag_cleanup()
{
global $DB;
$instances = $DB->get_recordset('tag_instance');
// cleanup tag instances
foreach ($instances as $instance) {
$delete = false;
if (!$DB->record_exists('tag', array('id' => $instance->tagid))) {
// if the tag has been removed, instance should be deleted.
$delete = true;
} else {
switch ($instance->itemtype) {
case 'user':
// users are marked as deleted, but not actually deleted
if ($DB->record_exists('user', array('id' => $instance->itemid, 'deleted' => 1))) {
$delete = true;
}
break;
default:
// anything else, if the instance is not there, delete.
if (!$DB->record_exists($instance->itemtype, array('id' => $instance->itemid))) {
$delete = true;
}
break;
}
}
if ($delete) {
tag_delete_instance($instance->itemtype, $instance->itemid, $instance->tagid);
//debugging('deleting tag_instance #'. $instance->id .', linked to tag id #'. $instance->tagid, DEBUG_DEVELOPER);
}
}
$instances->close();
// TODO: this will only clean tags of type 'default'. This is good as
// it won't delete 'official' tags, but the day we get more than two
// types, we need to fix this.
$unused_tags = $DB->get_recordset_sql("SELECT tg.id\n FROM {tag} tg\n WHERE tg.tagtype = 'default'\n AND NOT EXISTS (\n SELECT 'x'\n FROM {tag_instance} ti\n WHERE ti.tagid = tg.id\n )");
// cleanup tags
foreach ($unused_tags as $unused_tag) {
tag_delete($unused_tag->id);
//debugging('deleting unused tag #'. $unused_tag->id, DEBUG_DEVELOPER);
}
$unused_tags->close();
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:51,代码来源:lib.php
示例9: coursetag_delete_course_tags
/**
* Course tagging function used only during the deletion of a course (called by lib/moodlelib.php) to clean up associated tags
*
* @package core_tag
* @param int $courseid the course we wish to delete tag instances from
* @param bool $showfeedback if we should output a notification of the delete to the end user
*/
function coursetag_delete_course_tags($courseid, $showfeedback = false)
{
global $DB, $OUTPUT;
if ($taginstances = $DB->get_fieldset_select('tag_instance', 'tagid', "itemtype = 'course' AND itemid = :courseid", array('courseid' => $courseid))) {
tag_delete(array_values($taginstances));
}
if ($showfeedback) {
echo $OUTPUT->notification(get_string('deletedcoursetags', 'tag'), 'notifysuccess');
}
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:17,代码来源:coursetagslib.php
示例10: array
$existing_tagtypes = array();
if ($ptypes = get_records_sql("SELECT DISTINCT(tagtype), id FROM {$CFG->prefix}tag")) {
foreach ($ptypes as $ptype) {
$existing_tagtypes[$ptype->tagtype] = $ptype->tagtype;
}
}
$existing_tagtypes['official'] = get_string('tagtype_official', 'tag');
$existing_tagtypes['default'] = get_string('tagtype_default', 'tag');
switch ($action) {
case 'delete':
if (!data_submitted or !confirm_sesskey()) {
break;
}
$str_tagschecked = tag_name_from_string(implode($tagschecked, ','));
$str_tagschecked = str_replace(',', ', ', $str_tagschecked);
tag_delete(implode($tagschecked, ','));
$notice = $str_tagschecked . ' -- ' . get_string('deleted', 'tag');
break;
case 'reset':
if (!data_submitted or !confirm_sesskey()) {
break;
}
$str_tagschecked = tag_name_from_string(implode($tagschecked, ','));
$str_tagschecked = str_replace(',', ', ', $str_tagschecked);
tag_flag_reset(implode($tagschecked, ','));
$notice = $str_tagschecked . ' -- ' . get_string('reset', 'tag');
break;
case 'changetype':
if (!data_submitted or !confirm_sesskey()) {
break;
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:31,代码来源:manage.php
示例11: tag_cleanup
/**
* Clean up the tag tables, making sure all tagged object still exists.
*
* This should normally not be necessary, but in case related tags are not deleted when the tagged record is removed, this should be
* done once in a while, perhaps on an occasional cron run. On a site with lots of tags, this could become an expensive function to
* call: don't run at peak time.
*
* @package core_tag
* @access private
* @todo MDL-31212 Update tag cleanup sql so that it supports multiple types of tags
*/
function tag_cleanup()
{
global $DB;
// Get ids to delete from instances where the tag has been deleted. This should never happen apparently.
$sql = "SELECT ti.id\n FROM {tag_instance} ti\n LEFT JOIN {tag} t ON t.id = ti.tagid\n WHERE t.id IS null";
$tagids = $DB->get_records_sql($sql);
$tagarray = array();
foreach ($tagids as $tagid) {
$tagarray[] = $tagid->id;
}
// Next get ids from instances that have an owner that has been deleted.
$sql = "SELECT ti.id\n FROM {tag_instance} ti, {user} u\n WHERE ti.itemid = u.id\n AND ti.itemtype = 'user'\n AND u.deleted = 1";
$tagids = $DB->get_records_sql($sql);
foreach ($tagids as $tagid) {
$tagarray[] = $tagid->id;
}
// Get the other itemtypes.
$sql = "SELECT itemtype\n FROM {tag_instance}\n WHERE itemtype <> 'user'\n GROUP BY itemtype";
$tagitemtypes = $DB->get_records_sql($sql);
foreach ($tagitemtypes as $key => $notused) {
$sql = 'SELECT ti.id
FROM {tag_instance} ti
LEFT JOIN {' . $key . '} it ON it.id = ti.itemid
WHERE it.id IS null
AND ti.itemtype = \'' . $key . '\'';
$tagids = $DB->get_records_sql($sql);
foreach ($tagids as $tagid) {
$tagarray[] = $tagid->id;
}
}
// Get instances for each of the ids to be deleted.
if (count($tagarray) > 0) {
list($sqlin, $params) = $DB->get_in_or_equal($tagarray);
$sql = "SELECT ti.*, COALESCE(t.name, 'deleted') AS name, COALESCE(t.rawname, 'deleted') AS rawname\n FROM {tag_instance} ti\n LEFT JOIN {tag} t ON t.id = ti.tagid\n WHERE ti.id {$sqlin}";
$instances = $DB->get_records_sql($sql, $params);
tag_bulk_delete_instances($instances);
}
// TODO MDL-31212 this will only clean tags of type 'default'. This is good as
// it won't delete 'official' tags, but the day we get more than two
// types, we need to fix this.
$unused_tags = $DB->get_recordset_sql("SELECT tg.id\n FROM {tag} tg\n WHERE tg.tagtype = 'default'\n AND NOT EXISTS (\n SELECT 'x'\n FROM {tag_instance} ti\n WHERE ti.tagid = tg.id\n )");
// cleanup tags
foreach ($unused_tags as $unused_tag) {
tag_delete($unused_tag->id);
//debugging('deleting unused tag #'. $unused_tag->id, DEBUG_DEVELOPER);
}
$unused_tags->close();
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:59,代码来源:lib.php
示例12: test_tag_deleted
/**
* Test the tag deleted event
*/
public function test_tag_deleted()
{
global $DB;
$this->setAdminUser();
// Create a course and a user.
$course = $this->getDataGenerator()->create_course();
$user = $this->getDataGenerator()->create_user();
// Create tag we are going to delete.
$tag = $this->getDataGenerator()->create_tag();
// Trigger and capture the event for deleting a tag.
$sink = $this->redirectEvents();
tag_delete($tag->id);
$this->assertDebuggingCalled();
$events = $sink->get_events();
$event = reset($events);
// Check that the tag was deleted and the event data is valid.
$this->assertEquals(0, $DB->count_records('tag'));
$this->assertInstanceOf('\\core\\event\\tag_deleted', $event);
$this->assertEquals(context_system::instance(), $event->get_context());
// Create two tags we are going to delete to ensure passing multiple tags work.
$tag = $this->getDataGenerator()->create_tag();
$tag2 = $this->getDataGenerator()->create_tag();
// Trigger and capture the events for deleting multiple tags.
$sink = $this->redirectEvents();
tag_delete(array($tag->id, $tag2->id));
$this->assertDebuggingCalled();
$events = $sink->get_events();
// Check that the tags were deleted and the events data is valid.
$this->assertEquals(0, $DB->count_records('tag'));
foreach ($events as $event) {
$this->assertInstanceOf('\\core\\event\\tag_deleted', $event);
$this->assertEquals(context_system::instance(), $event->get_context());
}
// Add a tag instance to a course.
core_tag_tag::add_item_tag('core', 'course', $course->id, context_course::instance($course->id), 'cat', $user->id);
// Trigger and capture the event for deleting a personal tag for a user for a course.
$sink = $this->redirectEvents();
core_tag_tag::remove_item_tag('core', 'course', $course->id, 'cat', $user->id);
$events = $sink->get_events();
$event = $events[1];
// Check that the tag was deleted and the event data is valid.
$this->assertEquals(0, $DB->count_records('tag'));
$this->assertInstanceOf('\\core\\event\\tag_deleted', $event);
$this->assertEquals(context_system::instance(), $event->get_context());
// Add the tag instance to the course again as it was deleted.
core_tag_tag::add_item_tag('core', 'course', $course->id, context_course::instance($course->id), 'dog', $user->id);
// Trigger and capture the event for deleting all tags in a course.
$sink = $this->redirectEvents();
core_tag_tag::remove_all_item_tags('core', 'course', $course->id);
$events = $sink->get_events();
$event = $events[1];
// Check that the tag was deleted and the event data is valid.
$this->assertEquals(0, $DB->count_records('tag'));
$this->assertInstanceOf('\\core\\event\\tag_deleted', $event);
$this->assertEquals(context_system::instance(), $event->get_context());
// Add multiple tag instances now and check that it still works.
core_tag_tag::set_item_tags('core', 'course', $course->id, context_course::instance($course->id), array('fish', 'hamster'), $user->id);
// Trigger and capture the event for deleting all tags in a course.
$sink = $this->redirectEvents();
core_tag_tag::remove_all_item_tags('core', 'course', $course->id);
$events = $sink->get_events();
$events = array($events[1], $events[3]);
// Check that the tags were deleted and the events data is valid.
$this->assertEquals(0, $DB->count_records('tag'));
foreach ($events as $event) {
$this->assertInstanceOf('\\core\\event\\tag_deleted', $event);
$this->assertEquals(context_system::instance(), $event->get_context());
}
}
开发者ID:rushi963,项目名称:moodle,代码行数:72,代码来源:events_test.php
注:本文中的tag_delete函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论