Exemplo n.º 1
0
function churchcal_deleteCategory($params)
{
    global $user;
    $id = getVar('id', false, $params);
    $data = db_query("SELECT * FROM {cc_calcategory}\n                    WHERE id=:id", array(":id" => $id))->fetch();
    if (!$data) {
        return CTException(t('category.does.not.exist'));
    }
    $auth = user_access("edit category", "churchcal");
    if ($data->modified_pid != $user->id && (!$auth || !isset($auth[$id]))) {
        throw new CTNoPermission("Edit Category", "churchcal");
    }
    $c = db_query("SELECT COUNT(*) c\n                 FROM {cs_event} e, {cc_cal} cal, {cs_eventservice} es\n                 WHERE cal.id=e.cc_cal_id AND cal.category_id=:id\n                 AND es.event_id=e.id AND zugesagt_yn=1 AND es.valid_yn=1\n                 AND DATEDIFF(cal.startdate, now())>=0", array(":id" => $id))->fetch();
    if ($c->c > 0) {
        throw new CTFail(t('deleting.failed.because.of.remaining.services'));
    }
    $db = db_query("SELECT c.id FROM {cs_event} e, {cc_cal} c WHERE c.category_id=:category_id AND e.cc_cal_id = c.id", array(":category_id" => $id));
    foreach ($db as $cal) {
        churchcal_deleteEvent(array("id" => $cal->id));
    }
    db_query("DELETE FROM {cc_cal}         WHERE category_id=:id", array(":id" => $id));
    db_query("DELETE FROM {cc_calcategory} WHERE id=:id", array(":id" => $id));
    db_query("DELETE FROM {cc_domain_auth} WHERE auth_id in (403, 404) and daten_id=:id", array(":id" => $id));
}
 public function deleteEvent($params)
 {
     return churchcal_deleteEvent($params);
 }
 public function deleteEvent($params)
 {
     include_once './' . CHURCHCAL . '/churchcal_db.php';
     return churchcal_deleteEvent($params);
 }