/
movieToPerson.php
113 lines (109 loc) · 3.9 KB
/
movieToPerson.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
// vim: set et ts=4 sw=4 fdm=marker:
/*
Copyright (C) 2008 Jesse Hogan <jessehogan0@gmail.com>
All rights reserverd
*/
require_once("header.php");
require_once("MoviesToPerson.php");
require_once("Movies.php");
main();
function main(){
try{
BlockIfViolation();
global $locale;
global $returnURI;
$PHP_SELF = $_SERVER['PHP_SELF'];
$post = $_POST['blnPost'];
$id = $_GET['id'];
$movID = $_GET['movID'];
$relationship = $_GET['relationship'];
$m2p = new MovieToPerson($id);
if (!$m2p->IsNew()){
$mov =& $m2p->Movie();
$person =& $m2p->Person();
}else{
$m2p->Relationship($relationship);
$person = new Person();
if ($movID == "" ) throw new Exception("Missing movID");
$mov = new Movie($movID);
}
$movID = $mov->ID();
$persons = new Persons();
$persons->LoadAll();
$persons->Sort("FirstName");
print("<h3><a href=movie.php?id=$movID>".$mov->Title()."</a></h3>\n");
$characterName = $m2p->CharacterName();
$relationship = $m2p->Relationship();
if ($post){
if ($_POST['btnDelete'] != ''){
$m2p->MarkForDeletion();
$characterName = $relationship = '';
}else{
$person = new Person($_POST['cboPersons']);
$m2p->Person($person);
$m2p->PersonID($person->ID());
$m2p->Movie($mov);
$m2p->CharacterName($_POST['txtCharacterName']);
$m2p->Relationship($_POST['txtRelationship']);
$characterName = $m2p->CharacterName();
$relationship = $m2p->Relationship();
}
if (UpdateObject($m2p)){
ReturnURI();
}
}
$firstName = $person->FirstName();
$lastName = $person->LastName();
?>
<form name=frm method=post action=<?=$PHP_SELF . "?id=$id&movID=$movID&returnURI=$returnURI"?>>
<table border=1>
<tr>
<td>
<?
print ("<select name=cboPersons>\n");
foreach($persons as $person){
$name = $person->Name();
$id = $person->ID();
if ($id == $m2p->PersonID()){
$selectTag = 'SELECTED';
}else{
$selectTag = '';
}
?>
<option value=<?=$id?> <?=$selectTag?>><?=$name?></option>
<?
}
print("</select>\n");
?>
</td>
</tr>
<?
if ($relationship == 's'){
?>
<tr>
<td><?=GetCap('capCharacterName')?></td>
<td><input type=text name=txtCharacterName value='<?=$characterName?>'></td>
</tr>
<?
}
?>
<tr>
<td><?=GetCap('capRelationship')?></td>
<td><input type=text name=txtRelationship value=<?=$relationship?>></td>
</tr>
<tr>
<td> <input type=submit name=btnSubmit value=<?=GetCap('capSubmit')?>> </td>
<td> <a href=<?="$PHP_SELF?movID=$movID"?>><?=GetCap('capNew')?></a>
</tr>
<input type=hidden name=blnPost value=1>
</table>
</form>
<?
}
catch(Exception $ex){
ProcessException($ex);
}
require_once('tailer.php');
}
?>