1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
//require_once "facebook.php"; |
4
|
|
|
|
5
|
|
|
class FacebookCredentials extends Page |
|
|
|
|
6
|
|
|
{ |
7
|
|
|
public static $db = array( |
8
|
|
|
'BulkTitle' => 'Varchar', |
9
|
|
|
'BulkCaption' => 'Varchar', |
10
|
|
|
'BulkCopyright' => 'Varchar', |
11
|
|
|
'BulkLicense' => 'Varchar', |
12
|
|
|
'FacebookAlbumID' => 'Varchar', |
13
|
|
|
); |
|
|
|
|
14
|
|
|
|
15
|
|
|
// facebook information |
16
|
|
|
|
17
|
|
|
// the id of the facebook application |
18
|
|
|
protected static $facebook_application_id = null; |
|
|
|
|
19
|
|
|
|
20
|
|
|
// the secret of the facebook application |
21
|
|
|
protected static $facebook_application_secret = null; |
|
|
|
|
22
|
|
|
|
23
|
|
|
// user id to search |
24
|
|
|
protected static $facebook_user_id = null; |
|
|
|
|
25
|
|
|
|
26
|
|
|
public static $has_many = array( |
27
|
|
|
'AttachedFiles' => 'ImageFile', |
28
|
|
|
); |
|
|
|
|
29
|
|
|
|
30
|
|
|
public static $has_one = array( |
31
|
|
|
'CoverPhoto' => 'Image', |
32
|
|
|
); |
|
|
|
|
33
|
|
|
|
34
|
|
|
//Uncle Cheese hack from http://silverstripe.org/data-model-questions/show/6805 << to detect multiple calls to on after write or on before write |
35
|
|
|
public static $has_written = false; |
|
|
|
|
36
|
|
|
|
37
|
|
|
public function CanUseFacebook() |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
$result = (self::$facebook_application_id != null); |
40
|
|
|
$result = $result && (self::$facebook_application_secret != null); |
41
|
|
|
$result = $result && (self::$facebook_user_id != null); |
42
|
|
|
|
43
|
|
|
return $result; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public static function setFacebookApplicationID($new_app_id) |
47
|
|
|
{ |
48
|
|
|
return self::$facebook_application_id = $new_app_id; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public static function setFacebookApplicationSecret($new_sec) |
52
|
|
|
{ |
53
|
|
|
return self::$facebook_application_secret = $new_sec; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public static function setFacebookUserID($new_user_id) |
57
|
|
|
{ |
58
|
|
|
return self::$facebook_user_id = $new_user_id; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public static function getFacebookApplicationID() |
62
|
|
|
{ |
63
|
|
|
$config = SiteConfig::current_site_config(); |
64
|
|
|
|
65
|
|
|
return $config->getOGApplicationID(); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public static function getFacebookApplicationSecret() |
69
|
|
|
{ |
70
|
|
|
return self::$facebook_application_secret; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public static function getFacebookUserID() |
74
|
|
|
{ |
75
|
|
|
$config = SiteConfig::current_site_config(); |
76
|
|
|
|
77
|
|
|
return $config->getOGAdminID(); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
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.