@@ -21,7 +21,9 @@ class UserProfile {
2121 protected $ id ;
2222 protected $ instagram_username ;
2323 protected $ phone ;
24+ protected $ reddit_username ;
2425 protected $ skype_username ;
26+ protected $ steam_id ;
2527 protected $ twitter_username ;
2628 protected $ website ;
2729
@@ -33,7 +35,9 @@ public function __construct($data) {
3335 $ this ->id = (int ) $ data ;
3436 $ this ->instagram_username = null ;
3537 $ this ->phone = null ;
38+ $ this ->reddit_username = null ;
3639 $ this ->skype_username = null ;
40+ $ this ->steam_id = null ;
3741 $ this ->twitter_username = null ;
3842 $ this ->website = null ;
3943 $ this ->refresh ();
@@ -45,7 +49,9 @@ public function __construct($data) {
4549 $ this ->id = $ data ->id ;
4650 $ this ->instagram_username = $ data ->instagram_username ;
4751 $ this ->phone = $ data ->phone ;
52+ $ this ->reddit_username = $ data ->reddit_username ;
4853 $ this ->skype_username = $ data ->skype_username ;
54+ $ this ->steam_id = $ data ->steam_id ;
4955 $ this ->twitter_username = $ data ->twitter_username ;
5056 $ this ->website = $ data ->website ;
5157 } else {
@@ -57,10 +63,18 @@ public function getBiography() {
5763 return $ this ->biography ;
5864 }
5965
66+ public function getFacebookURI () {
67+ return "https://www.facebook.com/ " . $ this ->getFacebookUsername ();
68+ }
69+
6070 public function getFacebookUsername () {
6171 return $ this ->facebook_username ;
6272 }
6373
74+ public function getGitHubURI () {
75+ return "https://github.com/ " . $ this ->getGitHubUsername ();
76+ }
77+
6478 public function getGitHubUsername () {
6579 return $ this ->github_username ;
6680 }
@@ -69,6 +83,10 @@ public function getId() {
6983 return $ this ->id ;
7084 }
7185
86+ public function getInstagramURI () {
87+ return "https://instagram.com/ " . $ this ->getInstagramUsername ();
88+ }
89+
7290 public function getInstagramUsername () {
7391 return $ this ->instagram_username ;
7492 }
@@ -77,20 +95,66 @@ public function getPhone() {
7795 return $ this ->phone ;
7896 }
7997
98+ public function getPhoneURI () {
99+ return "tel:// " . $ this ->getPhone ();
100+ }
101+
102+ public function getRedditURI () {
103+ return "https://www.reddit.com/user/ " . $ this ->getRedditUsername ();
104+ }
105+
106+ public function getRedditUsername () {
107+ return $ this ->reddit_username ;
108+ }
109+
110+ public function getSkypeURI () {
111+ return "skype: " . $ this ->getSkypeUsername () . "?chat " ;
112+ }
113+
80114 public function getSkypeUsername () {
81115 return $ this ->skype_username ;
82116 }
83117
118+ public function getSteamId () {
119+ return $ this ->steam_id ;
120+ }
121+
122+ public function getSteamURI () {
123+ return "https://steamcommunity.com/profiles/ " . $ this ->getSteamId ();
124+ }
125+
126+ public function getTwitterURI () {
127+ return "https://twitter.com/ " . $ this ->getTwitterUsername ();
128+ }
129+
84130 public function getTwitterUsername () {
85131 return $ this ->twitter_username ;
86132 }
87133
88134 public function getWebsite () {
89- return $ this ->website ;
135+ $ value = strtolower ($ this ->website );
136+ if (substr ($ value , 0 , 7 ) == "http:// " ) {
137+ return substr ($ value , 7 );
138+ } else if (substr ($ value , 0 , 8 ) == "https:// " ) {
139+ return substr ($ value , 8 );
140+ } else {
141+ return "http:// " . $ value ;
142+ }
143+ }
144+
145+ public function getWebsiteURI () {
146+ $ value = strtolower ($ this ->website );
147+ if (substr ($ value , 0 , 7 ) == "http:// "
148+ || substr ($ value , 0 , 8 ) == "https:// " ) {
149+ return $ value ;
150+ } else {
151+ return "http:// " . $ value ;
152+ }
90153 }
91154
92155 protected static function normalize (StdClass &$ data ) {
93- $ data ->user_id = (int ) $ data ->user_id ;
156+ $ data ->user_id = (int ) $ data ->user_id ;
157+ $ data ->steam_id = (int ) $ data ->steam_id ;
94158
95159 if (!is_null ($ data ->biography ))
96160 $ data ->biography = (string ) $ data ->biography ;
@@ -107,6 +171,9 @@ protected static function normalize(StdClass &$data) {
107171 if (!is_null ($ data ->phone ))
108172 $ data ->phone = (string ) $ data ->phone ;
109173
174+ if (!is_null ($ data ->reddit_username ))
175+ $ data ->reddit_username = (string ) $ data ->reddit_username ;
176+
110177 if (!is_null ($ data ->skype_username ))
111178 $ data ->skype_username = (string ) $ data ->skype_username ;
112179
@@ -129,7 +196,9 @@ public function refresh() {
129196 $ this ->github_username = $ cache_val ->github_username ;
130197 $ this ->instagram_username = $ cache_val ->instagram_username ;
131198 $ this ->phone = $ cache_val ->phone ;
199+ $ this ->reddit_username = $ cache_val ->reddit_username ;
132200 $ this ->skype_username = $ cache_val ->skype_username ;
201+ $ this ->steam_id = $ cache_val ->steam_id ;
133202 $ this ->twitter_username = $ cache_val ->twitter_username ;
134203 $ this ->website = $ cache_val ->website ;
135204 return true ;
@@ -143,11 +212,13 @@ public function refresh() {
143212 `biography`,
144213 `facebook_username`,
145214 `github_username`,
146- `user_id`,
147215 `instagram_username`,
148216 `phone`,
217+ `reddit_username`,
149218 `skype_username`,
219+ `steam_id`,
150220 `twitter_username`,
221+ `user_id`,
151222 `website`
152223 FROM `user_profiles`
153224 WHERE `user_id` = :id
@@ -167,7 +238,9 @@ public function refresh() {
167238 $ this ->github_username = $ row ->github_username ;
168239 $ this ->instagram_username = $ row ->instagram_username ;
169240 $ this ->phone = $ row ->phone ;
241+ $ this ->reddit_username = $ row ->reddit_username ;
170242 $ this ->skype_username = $ row ->skype_username ;
243+ $ this ->steam_id = $ row ->steam_id ;
171244 $ this ->twitter_username = $ row ->twitter_username ;
172245 $ this ->website = $ row ->website ;
173246 Common::$ cache ->set ($ cache_key , serialize ($ row ), 300 );
0 commit comments