$ctype = $contacttype[$key];
 $cid = '';
 if (isset($contactinfoid[$key])) {
     $cid = $contactinfoid[$key];
 }
 if (empty($cid) && (empty($ctype) || empty($cinfo))) {
     continue 1;
 }
 try {
     if (empty($cid)) {
         $contact = new ContactInfo();
         $contact->setProperty('dataowneruserid', $dataowneruserid);
         $contact->setProperty('locationid', $locationid);
     } else {
         if (empty($cinfo)) {
             ContactInfo::deleteInfo($cid, $userid);
             continue 1;
         }
         $contact = ContactInfo::get($cid, $userid);
     }
     $contact->setProperty('contacttype', $ctype);
     $contact->setProperty('contactinfo', $cinfo, $ctype);
     $contact->setProperty('datachangebyuserid', $userid);
     $contact->save();
 } catch (Exception $e) {
     $errormessage = $e->getMessage();
     trigger_error($errormessage, E_USER_WARNING);
     $formmessage = $errormessage;
     $formmessageclass = 'red';
     break 2;
 }
     $responseuri = $_POST['responseuri'];
     if (!isset($_POST['id'])) {
         header("Location: restaurants");
         exit;
     }
     $locationid = $_POST['id'];
     try {
         $location = Location::get($locationid, $userid);
         $locationname = $location->getProperty('name');
         $bhours = $location->getHours();
         foreach ($bhours as $bhourrow) {
             BusinessHour::deleteBusinessHour($bhourrow['id'], $userid);
         }
         $contactinfo = $location->getContactInfo();
         foreach ($contactinfo as $cirow) {
             ContactInfo::deleteInfo($cirow['id'], $userid);
         }
         Location::deleteLocation($locationid, $userid);
         $formmessage = 'Location "' . $locationname . '" deleted.';
         $formmessageclass = 'green';
         break;
     } catch (Exception $e) {
         $formmessage = $e->getMessage();
         trigger_error($formmessage);
         $formmessageclass = 'red';
         break;
     }
 } else {
     header("Location: logout");
     exit;
 }