|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class LinkedinIdentifier extends DataObjectDecorator |
|
|
|
|
|
|
4
|
|
|
{ |
|
5
|
|
|
public function extraStatics() |
|
6
|
|
|
{ |
|
7
|
|
|
return array( |
|
8
|
|
|
'db' => array( |
|
9
|
|
|
'LinkedinID' => 'Varchar', |
|
10
|
|
|
'LinkedinFirstName' => 'Varchar(255)', |
|
11
|
|
|
'LinkedinLastName' => 'Varchar(255)', |
|
12
|
|
|
'LinkedinPicture' => 'Text', |
|
13
|
|
|
'LinkedinEmail' => 'Varchar(255)' |
|
14
|
|
|
), |
|
15
|
|
|
'indexes' => array( |
|
16
|
|
|
'LinkedinID' => true, |
|
17
|
|
|
'LinkedinEmail' => true |
|
18
|
|
|
) |
|
19
|
|
|
); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* connect and disconnect button |
|
25
|
|
|
* @return Object (IsConnected, Link, ConnectedName, ConnectedImageURL) |
|
26
|
|
|
*/ |
|
27
|
|
|
public function getLinkedinButton($backURL = "") |
|
28
|
|
|
{ |
|
29
|
|
|
return LinkedinCallback::get_login_button($backURL, $this->owner); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* |
|
34
|
|
|
* user has logged in with facebook before? |
|
35
|
|
|
* @return Boolean |
|
36
|
|
|
*/ |
|
37
|
|
|
public function hasLinkedin() |
|
38
|
|
|
{ |
|
39
|
|
|
return (bool)$this->owner->LinkedinID; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* user is currenctly connected to Faceboo |
|
44
|
|
|
* |
|
45
|
|
|
* |
|
46
|
|
|
*/ |
|
47
|
|
|
public function isConnectedToLinkedin() |
|
48
|
|
|
{ |
|
49
|
|
|
return LinkedinCallback::get_current_user(); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* link to profile |
|
54
|
|
|
* @return String |
|
55
|
|
|
*/ |
|
56
|
|
|
public function LinkedinLink() |
|
57
|
|
|
{ |
|
58
|
|
|
if ($this->owner->LinkedinID) { |
|
59
|
|
|
return "http://www.linkedin.com/profile/view?id=".$this->owner->LinkedinID; |
|
60
|
|
|
} |
|
61
|
|
|
return ""; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
View Code Duplication |
public function onBeforeWrite() |
|
|
|
|
|
|
65
|
|
|
{ |
|
66
|
|
|
if (!$this->owner->Email) { |
|
67
|
|
|
if ($this->owner->LinkedinEmail) { |
|
68
|
|
|
$id = $this->owner->ID; |
|
69
|
|
|
if (!$id) { |
|
70
|
|
|
$id = 0; |
|
71
|
|
|
} |
|
72
|
|
|
if (!DataObject::get_one("Member", "\"Email\" = '".$this->owner->LinkedinEmail."' AND \"Member\".\"ID\" <> ".$id."")) { |
|
73
|
|
|
$this->owner->Email = $this->owner->LinkedinEmail; |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.