-
Notifications
You must be signed in to change notification settings - Fork 0
/
saveEditedVendor.php
115 lines (102 loc) · 3.98 KB
/
saveEditedVendor.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
113
114
115
<?
$ssid = 0;
if (isset($_REQUEST['ssid']) && ($_REQUEST['ssid'] != "0")){
$ssid=$_REQUEST['ssid'];
session_id($ssid);
$ssidLink_continuing = "&ssid=".$ssid;
$ssidLink_starting = "?ssid=".$ssid;
}
session_start();
include_once('vendorsClass.php');
include_once('scripts/validationClass/validator.php');
$vendorObj = unserialize($_REQUEST['vendorObj']);
$vpc = new vendorsClass('vendorList.xml');
$username = "";
$isAdmin = false;
$vendor = NULL;
$currentUser_id = "";
$validToEdit = false;
$saved = false;
//print_r($vendorObj);
if (isset($_SESSION['username']) && (!is_null($vendorObj))){
$username = $_SESSION['username'];
$vendor = $vpc->findVendorWithEmail($username);
if (!is_null($vendor)){
$isAdmin = $vendor->isAdmin();
$currentUser_id = $vendor->id;
}
if ($vendorObj['id'] == $currentUser_id){
$validToEdit = true;
}else{
if ($isAdmin) $validToEdit = true;
}
if (!((is_numeric($vendorObj['id'])) && ($vendorObj['id'] != "")))
$validToEdit = false;
$usingVendor = NULL;
if ($validToEdit){
$usingVendor = $vpc->getVendorByID($vendorObj['id']);
}
if (!is_null($usingVendor)){
/*if (isset($vendorObj['vendorType']))
$usingVendor->vendorType = $vendorObj['vendorType'];
if (isset($vendorObj['vendorMemberShipType']))
$usingVendor->vendorMemberShipType = $vendorObj['vendorMemberShipType'];*/
$usingVendor->name = $vendorObj['name'];
$usingVendor->email = $vendorObj['email'];
$usingVendor->website = $vendorObj['website'];
$usingVendor->address = $vendorObj['address'];
$usingVendor->facebook = $vendorObj['facebook'];
$usingVendor->showFacebook = $vendorObj['showFacebook'];
$usingVendor->instagram = $vendorObj['instagram'];
$usingVendor->showInstagram = $vendorObj['showInstagram'];
$usingVendor->twitter = $vendorObj['twitter'];
$usingVendor->showTwitter = $vendorObj['showTwitter'];
$usingVendor->pintrist = $vendorObj['pintrist'];
$usingVendor->showPintrist = $vendorObj['showPintrist'];
$usingVendor->linkedin = $vendorObj['linkedin'];
$usingVendor->showLinkedin = $vendorObj['showLinkedin'];
$usingVendor->googlePlus = $vendorObj['googlePlus'];
$usingVendor->showGooglePlus = $vendorObj['showGooglePlus'];
$usingVendor->youtube = $vendorObj['youtube'];
$usingVendor->showYoutube = $vendorObj['showYoutube'];
$usingVendor->vimeo = $vendorObj['vimeo'];
$usingVendor->showVimeo = $vendorObj['showVimeo'];
$usingVendor->introText = $vendorObj['introText'];
$usingVendor->ticketToSavings = $vendorObj['ticketToSavings'];
$usingVendor->ticketToSavingsAmount = trim($vendorObj['ticketToSavingsAmount'],"$");
$usingVendor->logo = $vendorObj['logo'];
$usingVendor->headshotImage = $vendorObj['headshotImage'];
//$usingVendor->categories = array();
/*foreach($vendorObj['categories'] as $category){
array_push($usingVendor->categories,$category);
}*/
$usingVendor->categoryArray = array();
foreach($vendorObj['categories'] as $category){
array_push($usingVendor->categoryArray,$category);
}
$usingVendor->phoneArray = array();
$aCC = new allCarriersClass();
foreach($vendorObj['phones'] as $phone){
$carrier = $aCC->findCarrierByID($phone['carrierID']);
$vPhoneObj = new vendorPhoneClass($phone['phoneNumber'],$phone['type'],$phone['allowClientsToText'],$phone['allowTeamToText'],$phone['textTypeAllowed'],$carrier);
array_push($usingVendor->phoneArray,$vPhoneObj);
}
if (count($usingVendor->phoneArray) == 0){
array_push($usingVendor->phoneArray,new vendorPhoneClass());
}
//print_r($usingVendor->phoneArray);
//echo "Vendor\n";
// print_r($usingVendor);
// echo "\n----\n";
$usingVendor->save();
/*$vpc = new vendorsClass('vendorList.xml');
$savedVendor = $vpc->getVendorByID($usingVendor->id);
echo "Vendor After Save\n";
print_r($savedVendor);
echo "\n----\n";*/
// print_r($vpc);
$saved = true;
} //end if usingVendor != null
} //end if session is set etc.
echo json_encode($saved);
?>