Exemplo n.º 1
0
/**
* unLink Media ID to Indi, Family, or Source ID
*
* @param  string  $mediaid Media ID to be unlinked.
* @param string $linktoid Indi, Family, or Source ID that the Media ID should be unlinked from.
* @param $linenum should be ALWAYS set to 'OBJE'.
* @param int $level Level where the Media Object reference should be removed from (not used)
* @param boolean $chan Whether or not to update/add the CHAN record
* 
* @return  bool success or failure
*/
function unlinkMedia($linktoid, $linenum, $mediaid, $level = 1, $chan = true)
{
    global $GEDCOM, $pgv_lang, $pgv_changes;
    if (empty($level)) {
        $level = 1;
    }
    if ($level != 1) {
        return false;
    }
    // Level 2 items get unlinked elsewhere (maybe ??)
    // find Indi, Family, or Source record to unlink from
    if (isset($pgv_changes[$linktoid . "_" . $GEDCOM])) {
        $gedrec = find_updated_record($linktoid);
    } else {
        $gedrec = find_gedcom_record($linktoid);
    }
    //-- when deleting/umlinking a media link
    //-- $linenum comes is an OBJE and the $mediaid to delete should be set
    if (!is_numeric($linenum)) {
        $newged = remove_subrecord($gedrec, $linenum, $mediaid);
    } else {
        $newged = remove_subline($gedrec, $linenum);
    }
    // $success = (replace_gedrec($pid, $newged));
    $success = replace_gedrec($linktoid, $newged, $chan);
    if ($success) {
        //echo "<br />".$pgv_lang["gedrec_deleted"];
        //echo '<br>';
    }
}
Exemplo n.º 2
0
     if (!empty($linenum)) {
         if ($linenum === 0) {
             if (delete_gedrec($pid)) {
                 echo $pgv_lang["gedrec_deleted"];
             }
         } else {
             $mediaid = '';
             if (isset($_REQUEST['mediaid'])) {
                 $mediaid = $_REQUEST['mediaid'];
             }
             //-- when deleting a media link
             //-- $linenum comes is an OBJE and the $mediaid to delete should be set
             if (!is_numeric($linenum)) {
                 $newged = remove_subrecord($gedrec, $linenum, $mediaid);
             } else {
                 $newged = remove_subline($gedrec, $linenum);
             }
             $success = replace_gedrec($pid, $newged, $update_CHAN);
             if ($success) {
                 echo "<br /><br />", $pgv_lang["gedrec_deleted"];
             }
         }
     }
     break;
     //------------------------------------------------------------------------------
     //-- echo a form to edit the raw gedcom record in a large textarea
 //------------------------------------------------------------------------------
 //-- echo a form to edit the raw gedcom record in a large textarea
 case 'editraw':
     if (!checkFactEdit($gedrec)) {
         echo "<br />", $pgv_lang["privacy_prevented_editing"];