Esempio n. 1
0
function churchcal_deleteEvent($params, $source = null)
{
    $id = $params["id"];
    if (!churchcal_isAllowedToEditEvent($id)) {
        throw new CTNoPermission("AllowToEditEvent", "churchcal");
    }
    // BENACHRICHTIGE ANDERE MODULE
    if ($source == null || $source != "churchresource") {
        include_once CHURCHRESOURCE . '/churchresource_db.php';
        if ($source == null) {
            $source = "churchcal";
        }
        $params["cal_id"] = $params["id"];
        churchresource_deleteResourcesFromChurchCal($params, $source);
    }
    if ($source == null || $source != "churchservice") {
        include_once CHURCHSERVICE . '/churchservice_db.php';
        $cs_params = array_merge(array(), $params);
        $cs_params["cal_id"] = $params["id"];
        $cs_params["informDeleteEvent"] = 1;
        $cs_params["deleteCalEntry"] = 1;
        if ($source == null) {
            $source = "churchcal";
        }
        $db = db_query("select * from {cs_event} where cc_cal_id=:cal_id", array(":cal_id" => $cs_params["cal_id"]));
        foreach ($db as $cs) {
            $cs_params["id"] = $cs->id;
            churchservice_deleteEvent($cs_params, $source);
        }
    }
    db_query("delete from {cc_cal_except} where cal_id=:id", array(":id" => $id));
    db_query("delete from {cc_cal_add} where cal_id=:id", array(":id" => $id));
    db_query("delete from {cc_cal} where id=:id", array(":id" => $id));
}
Esempio n. 2
0
/**
 * delete cal event
 * @param array $params
 * @param string $source; default: null
 * @throws CTNoPermission
 */
function churchcal_deleteEvent($params, $source = null)
{
    global $user;
    $id = $params["id"];
    $logger = db_query("SELECT * FROM {cc_cal} WHERE id=:id", array(":id" => $params["id"]))->fetch();
    if (!$logger) {
        return;
    }
    if (!churchcal_isAllowedToEditEvent($id)) {
        throw new CTNoPermission("AllowToEditEvent", "churchcal");
    }
    // inform other modules
    if (!$source || $source != "churchresource") {
        include_once CHURCHRESOURCE . '/churchresource_db.php';
        if (!$source) {
            $source = "churchcal";
        }
        $params["cal_id"] = $params["id"];
        churchresource_deleteResourcesFromChurchCal($params, $source);
    }
    if (!$source || $source != "churchservice") {
        include_once CHURCHSERVICE . '/churchservice_db.php';
        $cs_params = array_merge(array(), $params);
        $cs_params["cal_id"] = $params["id"];
        $cs_params["informDeleteEvent"] = 1;
        $cs_params["deleteCalEntry"] = 1;
        if (!$source) {
            $source = "churchcal";
        }
        $db = db_query("SELECT * FROM {cs_event}\n                    WHERE cc_cal_id=:cal_id", array(":cal_id" => $cs_params["cal_id"]));
        foreach ($db as $cs) {
            $cs_params["id"] = $cs->id;
            churchservice_deleteEvent($cs_params, $source);
        }
    }
    db_query("DELETE FROM {cc_meetingrequest} WHERE cal_id=:id", array(":id" => $id));
    db_query("DELETE FROM {cc_cal_except} WHERE cal_id=:id", array(":id" => $id));
    db_query("DELETE FROM {cc_cal_add}    WHERE cal_id=:id", array(":id" => $id));
    db_query("DELETE FROM {cc_cal}        WHERE id=:id", array(":id" => $id));
    $data = db_query("select * from {cc_calcategory} where id=:id", array(":id" => $logger->category_id))->fetch();
    $txt = $user->vorname . " " . $user->name . " hat in Kalender ";
    if ($data != false) {
        $txt .= $data->bezeichnung;
    } else {
        $txt .= $logger->category_id;
    }
    $txt .= " einen Termin gel&ouml;scht: <br>";
    $txt .= churchcore_CCEventData2String($logger);
    ct_notify("category", $logger->category_id, $txt);
}