Changeset 2964
- Timestamp:
- 02/21/11 03:10:44 (12 years ago)
- Location:
- plugins/dcLibFoursquare
- Files:
-
- 4 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/dcLibFoursquare/_admin.php
r2955 r2964 18 18 'plugin.php?p=dcLibFoursquare','index.php?pf=dcLibFoursquare/icon.png', 19 19 preg_match('/plugin.php\?p=dcLibFoursquare(&.*)?$/',$_SERVER['REQUEST_URI']), 20 $core->auth-> check('admin',$core->blog->id)20 $core->auth->isSuperAdmin() 21 21 ); 22 22 ?> -
plugins/dcLibFoursquare/_define.php
r2958 r2964 17 17 /* Description*/ "Foursquare library for Dotclear's plugins", 18 18 /* Author */ "JC Denis", 19 /* Version */ '0. 2',19 /* Version */ '0.3', 20 20 /* Permissions */ 'admin' 21 21 ); 22 /* date */ #201102 1922 /* date */ #20110220 23 23 ?> -
plugins/dcLibFoursquare/_install.php
r2955 r2964 32 32 $s = $core->blog->settings->dcLibFoursquare; 33 33 34 $social_profil = base64_encode(serialize(array( 35 36 ))); 34 $social_profil = $social_reader = base64_encode(serialize(array())); 37 35 38 36 $s->put('soCialMe_profil',$social_profil,'string','config for soCialMe Profil',false,true); 37 $s->put('soCialMe_preader',$social_reader,'string','config for soCialMe Reader',false,true); 39 38 40 39 $s->put('oauth_admin','','string','oAuth2 app ref for admin side',false,true); -
plugins/dcLibFoursquare/inc/lib.oauth.client.2.0.foursquare.php
r2955 r2964 13 13 if (!defined('DC_RC_PATH')){return;} 14 14 15 # Config for oauth 1.0client manager15 # Config for oauth 2 client manager 16 16 class oAuthClient20Foursquare extends oAuthClient20 17 17 { -
plugins/dcLibFoursquare/inc/lib.social.profil.srv.foursquare.php
r2958 r2964 30 30 'playSmallContent' => true, 31 31 'playBigContent' => true, 32 'play MediumExtraContent' => true32 'playCardContent' => true 33 33 ); 34 35 protected $available = true;36 34 37 35 private $oauth = false; … … 44 42 # Required plugin oAuthManager 45 43 # Used name of parent plugin 46 if (!empty($oauth_settings['client_id']) && soCialMeUtils::checkPlugin('oAuthManager','0. 2-alpha1'))44 if (!empty($oauth_settings['client_id']) && soCialMeUtils::checkPlugin('oAuthManager','0.3')) 47 45 { 48 46 $this->oauth = oAuthClient::load($this->core,'foursquare', … … 127 125 public function parseContent($img) 128 126 { 129 return !$this->oauth || !$this->oauth->info('id') ? 130 null : 131 soCialMeUtils::preloadBox( 132 soCialMeUtils::easyLink( 133 'http://foursquare.com/user/'.$this->oauth->info('id'), 134 $this->name, 135 $this->url.$img, 136 'profil' 137 ) 138 ); 127 if (!$this->oauth || !$this->oauth->info('id')) return; 128 129 $record[0] = array( 130 'service' => $this->id, 131 'source_name' => $this->name, 132 'source_url' => $this->home, 133 'source_icon' => $this->icon, 134 'preload' => true, 135 'title' => sprintf(__('View my profil on %s'),$this->name), 136 'avatar' => $this->url.$img, 137 'url' => 'http://foursquare.com/user/'.$this->oauth->info('id') 138 ); 139 return $record; 139 140 } 140 141 public function playIconContent() { return $this->parseContent('pf=dcLibFoursquare/inc/icons/icon-small.png'); } … … 149 150 if (!$this->available || $this->oauth->state() != 2) return; 150 151 151 #152 # Cache for user badges153 #154 155 152 # cache filename 156 $file _user_badges = $this->core->blog->id.$this->id.'user_badges';153 $file = $this->core->blog->id.$this->id.'user_profil_and_badges'; 157 154 158 155 # check cache expiry 159 if(isset($available['MediumExtra']) && in_array($this->id,$available['MediumExtra']) 160 && soCialMeCacheFile::expired($file_user_badges,'enc',$this->cache_timeout)) 161 { 162 # call API 156 if(isset($available['Card']) && in_array($this->id,$available['Card']) 157 && soCialMeCacheFile::expired($file,'enc',$this->cache_timeout)) 158 { 159 $i = 0; 160 $records = null; 161 $this->log('Get','playServerScript','user_profil_and_badges'); 162 163 // profil 164 $rsp = foursquareUtils::api($this->oauth,'users/self'); 165 166 if ($rsp && $rsp->user) 167 { 168 $rs = $rsp->user; 169 170 $records[$i]['service'] = $this->id; 171 $records[$i]['author'] = $this->oauth->info('name'); 172 $records[$i]['source_name'] = $this->name; 173 $records[$i]['source_url'] = $this->home; 174 $records[$i]['source_icon'] = $this->icon; 175 176 $records[$i]['me'] = true; 177 $records[$i]['url'] = 'http://foursquare.com/user/'.$rs->id; 178 $records[$i]['title'] = $rs->firstName.' '.$rs->lastName; 179 $records[$i]['excerpt'] = sprintf(__('View my profil on %s'),$this->name); 180 $records[$i]['content'] = sprintf(__('%s checkins, %s badges'),$rs->checkins->count,$rs->badges->count); 181 $records[$i]['avatar'] = 'http://playfoursquare.s3.amazonaws.com/userpix_thumbs/QENPJKQ33TFQLNRS.png'; 182 $records[$i]['icon'] = 'http://playfoursquare.s3.amazonaws.com/userpix_thumbs/QENPJKQ33TFQLNRS.png'; 183 184 $i++; 185 } 186 187 // badges 163 188 $rsp = foursquareUtils::api($this->oauth,'users/self/badges'); 164 //echo '<p>rsp:</p><pre style="text-align:left;">'.print_r($rsp,true).'</pre>';exit(1); 189 165 190 if ($rsp && $rsp->badges) 166 191 { 167 192 $rs = $rsp->badges; 168 193 169 # Parse response170 $records = null;171 $i = 0;172 194 foreach($rs as $record) 173 195 { … … 185 207 $records[$i]['url'] = 'http://foursquare.com/user/'.$this->oauth->info('id').'/bagdes/'.$record->id; 186 208 $records[$i]['title'] = sprintf(__('%s has got the %s badge'),$this->oauth->info('name'),$record->name); 209 $records[$i]['excerpt'] = sprintf(__('View this badge on %s'),$this->name); 187 210 $records[$i]['content'] = $record->description; 188 211 $records[$i]['avatar'] = $record->image->prefix.$recorf->image->size[1].$record->image->name; … … 191 214 $i++; 192 215 } 193 # Create cache file 194 if (!empty($records)) { 195 soCialMeCacheFile::write($file_user_badges,'enc',soCialMeUtils::encode($records)); 196 } 197 } 198 } 199 } 200 201 # List from cache file user unlock badges on soCialMe "medium extra content" 202 public function playMediumExtraContent() 216 } 217 218 # Set cache file 219 if (empty($records)) { 220 soCialMeCacheFile::touch($file,'enc'); 221 } 222 else { 223 soCialMeCacheFile::write($file,'enc',soCialMeUtils::encode($records)); 224 } 225 } 226 } 227 228 # List from cache file user unlock badges on soCialMe "card content" 229 public function playCardContent() 203 230 { 204 231 if (!$this->available) return; 205 # cache filename 206 $file = $this->core->blog->id.$this->id.'user_badges'; 207 # Read cache content 232 233 $file = $this->core->blog->id.$this->id.'user_profil_and_badges'; 208 234 $content = soCialMeCacheFile::read($file,'enc'); 209 235 if (empty($content)) return; 210 # Parse content 211 $rs = soCialMeUtils::decode($content); 212 //echo '<p>rs:</p><pre style="text-align:left;">'.print_r($rs,true).'</pre>';exit(1); 213 if (empty($rs)) return; 214 215 $res = ''; 216 217 foreach($rs as $record) 218 { 219 $res .= 220 '<div class="foursquare-badge">'. 221 '<img src="'.$record['icon'].'" alt="'.$record['title'].'" /> '. 222 '<strong>'.$record['title'].'</strong><br />'. 223 $record['content'].'<br />'. 224 '<em>'.dt::str($this->core->blog->settings->system->date_format.', '.$this->core->blog->settings->system->time_format,$record['date']).'</em>'. 225 '</div>'; 226 } 227 return $res; 236 237 return soCialMeUtils::decode($content); 228 238 } 229 239 } -
plugins/dcLibFoursquare/inc/lib.social.reader.srv.foursquare.php
r2955 r2964 32 32 33 33 private $oauth = false; 34 private $cache_timeout = 300; //5 minutes35 34 private $chekins_returned = 20; 36 35 … … 42 41 # Required plugin oAuthManager 43 42 # Used name of parent plugin 44 if (!empty($oauth_settings['client_id']) && soCialMeUtils::checkPlugin('oAuthManager','0. 2-alpha1'))43 if (!empty($oauth_settings['client_id']) && soCialMeUtils::checkPlugin('oAuthManager','0.3')) 45 44 { 46 45 $this->oauth = oAuthClient::load($this->core,'foursquare', … … 128 127 if (!$this->available || $this->oauth->state() != 2) return; 129 128 130 #131 # Cache for user checkins132 #133 134 129 # cache filename 135 $file _user_checkins= $this->core->blog->id.$this->id.'user_checkins';130 $file = $this->core->blog->id.$this->id.'user_checkins'; 136 131 137 132 # check cache expiry 138 133 if((isset($available['Widget']) && in_array($this->id,$available['Widget']) 139 134 || isset($available['Page']) && in_array($this->id,$available['Page'])) 140 && soCialMeCacheFile::expired($file_user_checkins,'enc',$this->cache_timeout)) 141 { 135 && soCialMeCacheFile::expired($file,'enc',$this->cache_timeout)) 136 { 137 $records = null; 138 $this->log('Get','playServerScript','user_checkins'); 142 139 # call API 143 140 $params = array( … … 145 142 ); 146 143 $rsp = foursquareUtils::api($this->oauth,'users/self/checkins',$params); 147 //echo '<pre style="text-align:left;">'.print_r($rsp,true).'</pre>';exit(1);144 148 145 if ($rsp && $rsp->checkins->count) 149 146 { … … 151 148 152 149 # Parse response 153 $records = null;154 150 $i = 0; 155 151 foreach($rs as $record) … … 189 185 $i++; 190 186 } 191 # Create cache file 192 if (!empty($records)) { 193 soCialMeCacheFile::write($file_user_checkins,'enc',soCialMeUtils::encode($records)); 194 } 187 } 188 189 # Set cache file 190 if (empty($records)) { 191 soCialMeCacheFile::touch($file,'enc'); 192 } 193 else { 194 soCialMeCacheFile::write($file,'enc',soCialMeUtils::encode($records)); 195 195 } 196 196 } -
plugins/dcLibFoursquare/index.php
r2955 r2964 11 11 # -- END LICENSE BLOCK ------------------------------------ 12 12 13 // super admin must create an app with multiblog's admin url 14 // admin must create an app with blog's public url 15 16 dcPage::check('admin'); 13 dcPage::checkSuper(); 17 14 18 15 $s_oauth_admin = foursquareUtils::decodeApp('admin'); 19 if (!empty($_POST['superadminsave']) && $core->auth->isSuperAdmin())16 if (!empty($_POST['superadminsave'])) 20 17 { 21 18 $s_oauth_admin = foursquareUtils::encodeApp('admin',$_POST['oauth_admin_client_id'],$_POST['oauth_admin_client_secret'],$_POST['oauth_admin_redirect_uri']); … … 24 21 echo 25 22 '<html><head><title>'.__('Foursquare manager').'</title>'. 26 '</head><body><h2>'.__('Foursquare manager').'</h2>'; 23 '</head><body><h2>'.__('Foursquare manager').'</h2>'. 24 '<fieldset><legend>'.__('Register multiblog administration pages').'</legend>'. 25 '<form action="'.$p_url.'" method="post" id="form-superadmin">'; 27 26 28 # Super admin part (for admin pages) 29 if ($core->auth->isSuperAdmin()) 27 if (empty($s_oauth_admin['client_id'])) 30 28 { 31 echo32 '<fieldset><legend>'.__('Register multiblog administration pages').'</legend>'.33 '<form action="'.$p_url.'" method="post" id="form-superadmin">';34 35 if (empty($s_oauth_admin['client_id']))36 {37 echo38 '<p>'.__('In order to use Foursquare on your multiblog administration pages, you must first create a foursquare app.').'</p>'.39 '<ul>'.40 '<li>1) <a href="https://foursquare.com/oauth/">'.__('Go to foursquare application registration page').'</a></li>'.41 '<li>2) '.__('Enter your multiblog name as your application name').'</li>'.42 '<li>3) '.sprintf(__('Enter your multiblog administration URL as your app URL ( %s )'),DC_ADMIN_URL).'</li>'.43 '<li>4) '.__('When its done:').'</li>'.44 '<li><label>'.__('Enter your new App ID here:').' '.form::field(array('oauth_admin_client_id'),100,255,'').'</label></li>'.45 '<li><label>'.__('Enter your new App Secret here:').' '.form::field(array('oauth_admin_client_secret'),100,255,'').'</label></li>'.46 '<li><label>'.__('Confirm your redirect URL (admin URL) here:').' '.form::field(array('oauth_admin_redirect_uri'),100,255,'').'</label></li>'.47 '</ul>'.48 '<p><input type="submit" name="superadminsave" value="'.__('save').'" />';49 }50 else51 {52 echo53 '<p>'.__('You have already registered a foursquare app.').'</p>'.54 '<ul>'.55 '<li>'.sprintf(__('Application ID: %s'),$s_oauth_admin['client_id']).'</li>'.56 '<li>'.sprintf(__('Application secret: %s'),$s_oauth_admin['client_secret']).'</li>'.57 '<li>'.sprintf(__('Redirect URL: %s'),$s_oauth_admin['redirect_uri']).'</li>'.58 '</ul>'.59 form::hidden(array('oauth_admin_client_id'),'').60 form::hidden(array('oauth_admin_client_secret'),'').61 form::hidden(array('oauth_admin_redirect_uri'),'').62 '<p><input type="submit" name="superadminsave" value="'.__('delete').'" />';63 }64 29 echo 65 $core->formNonce().'</p>'. 66 '</form>'. 67 '</fieldset>'; 30 '<p>'.sprintf(__('In order to use %s on your blog, you must first create a %s app.'),'Foursquare','Foursquare').'</p>'. 31 '<ul>'. 32 '<li>1) <a href="https://foursquare.com/oauth/">'.sprintf(__('Go to %s application registration page'),'Foursquare').'</a></li>'. 33 '<li>2) '.__('Enter your multiblog name as your application name').'</li>'. 34 '<li>3) '.sprintf(__('Enter your multiblog administration URL as your app URL ( %s )'),DC_ADMIN_URL).'</li>'. 35 '<li>4) '.__('When its done:').'</li>'. 36 '<li><label>'.__('Enter your new App ID here:').' '.form::field(array('oauth_admin_client_id'),100,255,'').'</label></li>'. 37 '<li><label>'.__('Enter your new App Secret here:').' '.form::field(array('oauth_admin_client_secret'),100,255,'').'</label></li>'. 38 '<li><label>'.__('Confirm your redirect URL (admin URL) here:').' '.form::field(array('oauth_admin_redirect_uri'),100,255,'').'</label></li>'. 39 '</ul>'. 40 '<p><input type="submit" name="superadminsave" value="'.__('save').'" />'; 68 41 } 69 42 else 70 43 { 71 echo '<p>'._('This part is reserved to a super admin.').'</p>'; 44 echo 45 '<p>'.sprintf(__('You have already registered a %s app.'),'Foursquare').'</p>'. 46 '<ul>'. 47 '<li>'.sprintf(__('Application ID: %s'),$s_oauth_admin['client_id']).'</li>'. 48 '<li>'.sprintf(__('Application secret: %s'),$s_oauth_admin['client_secret']).'</li>'. 49 '<li>'.sprintf(__('Redirect URL: %s'),$s_oauth_admin['redirect_uri']).'</li>'. 50 '</ul>'. 51 form::hidden(array('oauth_admin_client_id'),''). 52 form::hidden(array('oauth_admin_client_secret'),''). 53 form::hidden(array('oauth_admin_redirect_uri'),''). 54 '<p><input type="submit" name="superadminsave" value="'.__('delete').'" />'; 72 55 } 73 74 56 echo 75 57 $core->formNonce().'</p>'. -
plugins/dcLibFoursquare/release.txt
r2955 r2964 1 0.3 20110220 2 * Followed soCialMe new system 3 * Fixed admin right 4 1 5 0.2-alpha2 20110218 2 6 * First public release of Foursquare libraries for Dotclear
Note: See TracChangeset
for help on using the changeset viewer.