本文整理汇总了PHP中BlockInstance::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP BlockInstance::delete方法的具体用法?PHP BlockInstance::delete怎么用?PHP BlockInstance::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BlockInstance
的用法示例。
在下文中一共展示了BlockInstance::delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmldb_core_upgrade
//.........这里部分代码省略.........
if ($oldversion < 2009070700) {
foreach (array('addfriend', 'removefriend', 'addfriendrequest', 'removefriendrequest') as $eventtype) {
$event = (object) array('name' => $eventtype);
ensure_record_exists('event_type', $event, $event);
}
}
if ($oldversion < 2009070900) {
if (is_mysql()) {
execute_sql("ALTER TABLE {usr} DROP FOREIGN KEY {usr_las_fk}");
execute_sql("ALTER TABLE {usr} DROP INDEX {usr_las_ix}");
}
$table = new XMLDBTable('usr');
$field = new XMLDBField('lastauthinstance');
drop_field($table, $field);
}
if ($oldversion < 2009080600) {
$table = new XMLDBTable('view');
$index = new XMLDBIndex('view_own_type_uix');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('owner'));
if (!index_exists($table, $index)) {
// Delete duplicate profile views if there are any, then add an index
// that will prevent it happening again - but only on postgres, as it's
// the only db that supports partial indexes
if ($viewdata = get_records_sql_array("\n SELECT owner, id\n FROM {view}\n WHERE owner IN (\n SELECT owner\n FROM {view}\n WHERE type = 'profile'\n GROUP BY owner\n HAVING COUNT(*) > 1\n )\n AND type = 'profile'\n ORDER BY owner, id", array())) {
require_once 'view.php';
$seen = array();
foreach ($viewdata as $record) {
$seen[$record->owner][] = $record->id;
}
foreach ($seen as $owner => $views) {
// Remove the first one, which is their real profile view
array_shift($views);
foreach ($views as $viewid) {
delete_records('artefact_feedback', 'view', $viewid);
delete_records('view_feedback', 'view', $viewid);
delete_records('view_access', 'view', $viewid);
delete_records('view_access_group', 'view', $viewid);
delete_records('view_access_usr', 'view', $viewid);
delete_records('view_access_token', 'view', $viewid);
delete_records('view_autocreate_grouptype', 'view', $viewid);
delete_records('view_tag', 'view', $viewid);
delete_records('usr_watchlist_view', 'view', $viewid);
if ($blockinstanceids = get_column('block_instance', 'id', 'view', $viewid)) {
foreach ($blockinstanceids as $id) {
if (table_exists(new XMLDBTable('blocktype_wall_post'))) {
delete_records('blocktype_wall_post', 'instance', $id);
}
delete_records('view_artefact', 'block', $id);
delete_records('block_instance', 'id', $id);
}
}
delete_records('view', 'id', $viewid);
}
}
}
if (is_postgres()) {
execute_sql("CREATE UNIQUE INDEX {view_own_type_uix} ON {view}(owner) WHERE type = 'profile'");
}
}
}
if ($oldversion < 2009080601) {
execute_sql("DELETE FROM {group_member_invite} WHERE \"group\" NOT IN (SELECT id FROM {group} WHERE jointype = 'invite')");
execute_sql("DELETE FROM {group_member_request} WHERE \"group\" NOT IN (SELECT id FROM {group} WHERE jointype = 'request')");
}
if ($oldversion < 2009081800) {
$event = (object) array('name' => 'creategroup');
示例2: removeblockinstance
/**
* deletes a block instance from the view
*
* @param array $values parameters for this function
* id => int id of blockinstance to remove
*/
public function removeblockinstance($values)
{
if (!array_key_exists('id', $values) || empty($values['id'])) {
throw new ParamOutOfRangeException(get_string('missingparamid', 'error'));
}
require_once get_config('docroot') . 'blocktype/lib.php';
$bi = new BlockInstance($values['id']);
// get it so we can reshuffle stuff
db_begin();
$bi->delete();
$this->shuffle_column($bi->get('column'), null, $bi->get('order'));
db_commit();
$this->dirtycolumns[$bi->get('column')] = 1;
}
示例3: removeblockinstance
/**
* deletes a block instance from the view
*
* @param array $values parameters for this function
* id => int id of blockinstance to remove
*/
public function removeblockinstance($values)
{
if (!array_key_exists('id', $values) || empty($values['id'])) {
throw new ParamOutOfRangeException(get_string('missingparamid', 'error'));
}
require_once get_config('docroot') . 'blocktype/lib.php';
$bi = new BlockInstance($values['id']);
// get it so we can reshuffle stuff
// Check if the block_instance belongs to this view
if ($bi->get('view') != $this->get('id')) {
throw new AccessDeniedException(get_string('blocknotinview', 'view', $bi->get('id')));
}
db_begin();
$bi->delete();
$this->shuffle_cell($bi->get('row'), $bi->get('column'), null, $bi->get('order'));
db_commit();
$this->dirtycolumns[$bi->get('row')][$bi->get('column')] = 1;
}
示例4: delete
/**
* Deletes a Collection
*
*/
public function delete()
{
$viewids = get_column('collection_view', 'view', 'collection', $this->id);
db_begin();
// Delete navigation blocks within the collection's views which point at this collection.
if ($viewids) {
$values = $viewids;
$values[] = 'navigation';
$navigationblocks = get_records_select_assoc('block_instance', 'view IN (' . join(',', array_fill(0, count($viewids), '?')) . ') AND blocktype = ?', $values);
if ($navigationblocks) {
safe_require('blocktype', 'navigation');
foreach ($navigationblocks as $b) {
$bi = new BlockInstance($b->id, $b);
$configdata = $bi->get('configdata');
if (isset($configdata['collection']) && $configdata['collection'] == $this->id) {
$bi->delete();
}
}
}
}
delete_records('collection_view', 'collection', $this->id);
delete_records('collection_tag', 'collection', $this->id);
delete_records('collection', 'id', $this->id);
// Secret url records belong to the collection, so remove them from the view.
// @todo: add user message to whatever calls this.
if ($viewids) {
delete_records_select('view_access', 'view IN (' . join(',', $viewids) . ') AND token IS NOT NULL');
}
db_commit();
}