本文整理汇总了PHP中ArtefactType::delete_by_artefacttype方法的典型用法代码示例。如果您正苦于以下问题:PHP ArtefactType::delete_by_artefacttype方法的具体用法?PHP ArtefactType::delete_by_artefacttype怎么用?PHP ArtefactType::delete_by_artefacttype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArtefactType
的用法示例。
在下文中一共展示了ArtefactType::delete_by_artefacttype方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: group_delete
/**
* Deletes a group.
*
* All group deleting should be done through this function, even though it is
* simple. What is required to perform group deletion may change over time.
*
* @param int $groupid The group to delete
* @param string $shortname shortname of the group
* @param string $institution institution of the group
*
* {{@internal Maybe later we can have a group_can_be_deleted function if
* necessary}}
*/
function group_delete($groupid, $shortname = null, $institution = null, $notifymembers = true)
{
if (empty($groupid) && !empty($institution) && !is_null($shortname) && strlen($shortname)) {
// External call to delete a group, check permission of $USER.
global $USER;
if (!$USER->can_edit_institution($institution)) {
throw new AccessDeniedException("group_delete: cannot delete a group in this institution");
}
$group = get_record('group', 'shortname', $shortname, 'institution', $institution);
} else {
$groupid = group_param_groupid($groupid);
$group = get_record('group', 'id', $groupid);
}
db_begin();
// Leave the group_member table alone, it's needed for the deleted
// group notification that's about to happen on cron.
delete_records('group_member_invite', 'group', $group->id);
delete_records('group_member_request', 'group', $group->id);
delete_records('view_access', 'group', $group->id);
// Delete views owned by the group
require_once get_config('libroot') . 'view.php';
foreach (get_column('view', 'id', 'group', $group->id) as $viewid) {
$view = new View($viewid);
$view->delete();
}
// Release views submitted to the group
foreach (get_column('view', 'id', 'submittedgroup', $group->id) as $viewid) {
$view = new View($viewid);
$view->release();
}
// Delete artefacts
require_once get_config('docroot') . 'artefact/lib.php';
ArtefactType::delete_by_artefacttype(get_column('artefact', 'id', 'group', $group->id));
// Delete forums
require_once get_config('docroot') . 'interaction/lib.php';
foreach (get_column('interaction_instance', 'id', 'group', $group->id) as $forumid) {
$forum = interaction_instance_from_id($forumid);
$forum->delete();
}
if ($notifymembers) {
require_once 'activity.php';
activity_occurred('groupmessage', array('group' => $group->id, 'deletedgroup' => true, 'strings' => (object) array('subject' => (object) array('key' => 'deletegroupnotificationsubject', 'section' => 'group', 'args' => array(hsc($group->name))), 'message' => (object) array('key' => 'deletegroupnotificationmessage', 'section' => 'group', 'args' => array(hsc($group->name), get_config('sitename'))))));
}
// make sure the group name + deleted suffix will fit within 128 chars
$delete_name = $group->name;
if (strlen($delete_name) > 100) {
$delete_name = substr($delete_name, 0, 100) . '(...)';
}
update_record('group', array('deleted' => 1, 'name' => $delete_name . '.deleted.' . time(), 'shortname' => null, 'institution' => null, 'category' => null, 'urlid' => null), array('id' => $group->id));
db_commit();
}
示例2: delete
public function delete()
{
// ArtefactType::delete() deletes all the child artefacts one by one.
// If the folder contains a lot of artefacts, it's too slow to do this
// but for very small directories it seems to be slightly faster.
$descendants = artefact_get_descendants(array($this->id));
if (count($descendants) < 10) {
parent::delete();
} else {
ArtefactType::delete_by_artefacttype($descendants);
}
}