コード例 #1
0
 static function deleteStockById($stockId)
 {
     $stock = StockDBUtils::getStockById($stockId);
     ImageUtils::deleteImageById($stock->image_id);
     StockDBUtils::deleteStockById($stockId);
 }
コード例 #2
0
<?php

require_once __DIR__ . '/wp-load.php';
require_once ABSPATH . WPINC . '/lib/helper/class-request-helper.php';
require_once ABSPATH . WPINC . '/lib/validator/class-child-form-validator.php';
require_once ABSPATH . WPINC . '/lib/utils/class-image-utils.php';
require_once ABSPATH . WPINC . '/lib/utils/db/class-child-db-utils.php';
require_once ABSPATH . WPINC . '/lib/utils/db/class-needy-item-settings-db-utils.php';
if (!is_user_logged_in()) {
    wp_redirect(home_url());
    exit;
}
$childInfo = RequestHelper::getChildInfoFromRequest();
if (ChildFormValidator::validateEditChildParameters($childInfo)) {
    $child = ChildDBUtils::getChildById($childInfo[Child::ID_FIELD]);
    $imageId = $child->image_id;
    if ($child && ChildFormValidator::validateChildAvatar($childInfo)) {
        $image = ImageUtils::createImageFromRequestParameters($childInfo);
        if ($image) {
            ImageUtils::deleteImageById($child->image_id);
            $imageId = $image->image_id;
        }
    }
    ChildDBUtils::updateChildById($childInfo, $imageId, $child->child_id);
    $result = NeedyItemSettingsDBUtils::updateChildSettings($child->child_id, $childInfo);
}
wp_redirect(home_url());
exit;
コード例 #3
0
<?php

require_once __DIR__ . '/wp-load.php';
require_once ABSPATH . WPINC . '/lib/helper/class-request-helper.php';
require_once ABSPATH . WPINC . '/lib/validator/class-stock-form-validator.php';
require_once ABSPATH . WPINC . '/lib/utils/class-image-utils.php';
require_once ABSPATH . WPINC . '/lib/utils/db/class-stock-db-utils.php';
if (!is_user_logged_in()) {
    wp_redirect(home_url());
    exit;
}
$stockInfo = RequestHelper::getStockInfoFromRequest();
if (StockFormValidator::validateEditStockParameters($stockInfo)) {
    $stock = StockDBUtils::getStockById($stockInfo[Stock::ID_FIELD]);
    $imageId = $stock->image_id;
    if ($stock && StockFormValidator::validateStockAvatar($stockInfo)) {
        $image = ImageUtils::createImageFromRequestParameters($stockInfo);
        if ($image) {
            ImageUtils::deleteImageById($stock->image_id);
            $imageId = $image->image_id;
        }
    }
    StockDBUtils::updateStockById($stockInfo, $imageId, $stock->stock_id);
}
wp_redirect(get_site_url() . '/stocks');
exit;
コード例 #4
0
<?php

require_once __DIR__ . '/wp-load.php';
require_once ABSPATH . WPINC . '/lib/helper/class-request-helper.php';
require_once ABSPATH . WPINC . '/lib/validator/class-orphanage-form-validator.php';
require_once ABSPATH . WPINC . '/lib/utils/class-image-utils.php';
require_once ABSPATH . WPINC . '/lib/utils/db/class-orphanage-db-utils.php';
require_once ABSPATH . WPINC . '/lib/utils/db/class-needy-item-settings-db-utils.php';
if (!is_user_logged_in()) {
    wp_redirect(home_url());
    exit;
}
$orphanageInfo = RequestHelper::getOrphanageInfoFromRequest();
if (OrphanageFormValidator::validateEditOrphanageParameters($orphanageInfo)) {
    $orphanage = OrphanageDBUtils::getOrphanageById($orphanageInfo[Orphanage::ID_FIELD]);
    $imageId = $orphanage->image_id;
    if ($orphanage && OrphanageFormValidator::validateOrphanageAvatar($orphanageInfo)) {
        $image = ImageUtils::createImageFromRequestParameters($orphanageInfo);
        if ($image) {
            ImageUtils::deleteImageById($orphanage->image_id);
            $imageId = $image->image_id;
        }
    }
    OrphanageDBUtils::updateOrphanageById($orphanageInfo, $imageId, $orphanage->orphanage_id);
    NeedyItemSettingsDBUtils::updateOrphanageSettings($orphanage->orphanage_id, $orphanageInfo);
}
wp_redirect(home_url());
exit;
コード例 #5
0
 static function deleteOrphanageById($orphanageId)
 {
     $orphanage = OrphanageDBUtils::getOrphanageById($orphanageId);
     ImageUtils::deleteImageById($orphanage->image_id);
     OrphanageDBUtils::deleteOrphanageById($orphanageId);
 }
コード例 #6
0
 static function deleteChildById($childId)
 {
     $child = ChildDBUtils::getChildById($childId);
     ImageUtils::deleteImageById($child->image_id);
     ChildDBUtils::deleteChildById($childId);
 }