本文整理汇总了PHP中FrmForm::destroy方法的典型用法代码示例。如果您正苦于以下问题:PHP FrmForm::destroy方法的具体用法?PHP FrmForm::destroy怎么用?PHP FrmForm::destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrmForm
的用法示例。
在下文中一共展示了FrmForm::destroy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_destroy
/**
* @covers FrmForm::destroy
*/
function test_destroy()
{
$forms = FrmForm::getAll();
$this->assertNotEmpty(count($forms));
foreach ($forms as $form) {
if ($form->is_template) {
continue;
}
$id = FrmForm::destroy($form->id);
$form_exists = FrmForm::getOne($form->id);
$this->assertEmpty($form_exists, 'Failed to delete form ' . $form->form_key);
$subforms_exist = FrmForm::getAll(array('parent_form_id' => $form->id));
$this->assertEmpty($subforms_exist, 'Failed to delete child forms for parent form ' . $form->form_key);
}
}
示例2: process_bulk_form_actions
public static function process_bulk_form_actions($errors)
{
if (!isset($_POST)) {
return;
}
$bulkaction = FrmAppHelper::get_param('action');
if ($bulkaction == -1) {
$bulkaction = FrmAppHelper::get_param('action2');
}
if (!empty($bulkaction) && strpos($bulkaction, 'bulk_') === 0) {
if (isset($_GET) && isset($_GET['action'])) {
$_SERVER['REQUEST_URI'] = str_replace('&action=' . $_GET['action'], '', $_SERVER['REQUEST_URI']);
}
if (isset($_GET) && isset($_GET['action2'])) {
$_SERVER['REQUEST_URI'] = str_replace('&action=' . $_GET['action2'], '', $_SERVER['REQUEST_URI']);
}
$bulkaction = str_replace('bulk_', '', $bulkaction);
} else {
$bulkaction = '-1';
if (isset($_POST['bulkaction']) && $_POST['bulkaction'] != '-1') {
$bulkaction = $_POST['bulkaction'];
} else {
if (isset($_POST['bulkaction2']) && $_POST['bulkaction2'] != '-1') {
$bulkaction = $_POST['bulkaction2'];
}
}
}
$ids = FrmAppHelper::get_param('item-action', '');
if (empty($ids)) {
$errors[] = __('No forms were specified', 'formidable');
} else {
if ($bulkaction == 'delete') {
if (!current_user_can('frm_delete_forms')) {
global $frm_settings;
$errors[] = $frm_settings->admin_permission;
} else {
if (!is_array($ids)) {
$ids = explode(',', $ids);
}
if (is_array($ids)) {
if ($bulkaction == 'delete') {
$frm_form = new FrmForm();
foreach ($ids as $form_id) {
$frm_form->destroy($form_id);
}
}
}
}
}
}
return $errors;
}
示例3: bulk_destroy
public static function bulk_destroy($ids)
{
FrmAppHelper::permission_check('frm_delete_forms');
$count = 0;
foreach ($ids as $id) {
$d = FrmForm::destroy($id);
if ($d) {
$count++;
}
}
$message = sprintf(_n('%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable'), $count);
return $message;
}
示例4: move_entries_to_parent_form
/**
* Delete entries from repeating sections and transfer first row to parent entries
*/
private static function move_entries_to_parent_form($args)
{
global $wpdb;
// get the ids of the entries saved in child fields
$items = FrmDb::get_results($wpdb->prefix . 'frm_item_metas m LEFT JOIN ' . $wpdb->prefix . 'frm_items i ON i.id=m.item_id', array('field_id' => $args['children']), 'item_id,parent_item_id', array('order_by' => 'i.created_at ASC'));
$updated_ids = array();
foreach ($items as $item) {
$child_id = $item->item_id;
$parent_id = $item->parent_item_id;
if (!in_array($parent_id, $updated_ids)) {
// Change the item_id in frm_item_metas to match the parent item ID
$wpdb->query($wpdb->prepare('UPDATE ' . $wpdb->prefix . 'frm_item_metas SET item_id = %d WHERE item_id = %d', $parent_id, $child_id));
$updated_ids[] = $parent_id;
}
// Delete the child entry
FrmEntry::destroy($child_id);
}
// delete all the metas for the repeat section
$wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id=%d', $args['field_id']));
// Delete the child form
FrmForm::destroy($args['form_id']);
}
示例5: delete_repeat_field
public static function delete_repeat_field($field)
{
if (!FrmField::is_repeating_field($field)) {
return;
}
if (isset($field->field_options['form_select']) && is_numeric($field->field_options['form_select']) && $field->field_options['form_select'] != $field->form_id) {
FrmForm::destroy($field->field_options['form_select']);
}
}