Esempio n. 1
0
 function Delete($CONTRACT_ID, $CHECK_RIGHTS = "Y")
 {
     $err_mess = CAdvContract_all::err_mess() . "<br>Function: Delete<br>Line: ";
     global $DB, $strError;
     $CONTRACT_ID = intval($CONTRACT_ID);
     if ($CONTRACT_ID <= 1) {
         return false;
     }
     $isAdmin = $CHECK_RIGHTS == "N" ? true : CAdvContract::IsAdmin();
     if ($isAdmin) {
         $strSql = "SELECT ID FROM b_adv_banner WHERE CONTRACT_ID = {$CONTRACT_ID}";
         $rs = $DB->Query($strSql, false, $err_mess . __LINE__);
         while ($ar = $rs->Fetch()) {
             CAdvBanner::Delete($ar["ID"], "N");
         }
         CAdvContract::DeletePageLink($CONTRACT_ID);
         CAdvContract::DeleteSiteLink($CONTRACT_ID);
         CAdvContract::DeleteTypeLink($CONTRACT_ID);
         CAdvContract::DeleteUserLink($CONTRACT_ID);
         CAdvContract::DeleteWeekdayLink($CONTRACT_ID);
         $strSql = "DELETE FROM b_adv_contract WHERE ID = {$CONTRACT_ID}";
         $DB->Query($strSql, false, $err_mess . __LINE__);
         return true;
     } else {
         $strError .= GetMessage("AD_ERROR_NOT_ENOUGH_PERMISSIONS_CONTRACT") . "<br>";
         return false;
     }
 }