/** * Renders the user pictur and name rendering the appropriate icons * * @param Ai1ec_Facebook_Current_User $user the User currently logged into Facebook * * @return string the generated HTML */ private function render_user_pic_and_icons(Ai1ec_Facebook_Current_User $user) { $name = $user->get_name(); $id = $user->get_id(); $username = $user->get_username(); $alt_img = esc_attr__('Profile image', AI1EC_PLUGIN_NAME); $logged_in_text = esc_html__('Hi, you are signed in as:', AI1EC_PLUGIN_NAME); $type = Ai1ec_Facebook_Graph_Object_Collection::FB_USER; $cat_tag_html = $this->render_category_tag_div($user->get_category(), $user->get_tag(), $user->get_enable_comments(), $user->get_display_map()); $refresh_label = esc_attr__(' Refresh', AI1EC_PLUGIN_NAME); $remove_label = esc_attr__(' Unsubscribe', AI1EC_PLUGIN_NAME); $refresh_tip = esc_attr__('Refresh my events', AI1EC_PLUGIN_NAME); $remove_tip = esc_attr__('Unsubscribe from my events', AI1EC_PLUGIN_NAME); if (!$user->get_subscribed()) { $cat_tag_html = ''; } $html = <<<HTML <div id="profile-name">{$logged_in_text}</div> <div class="row-fluid"> \t<div class="ai1ec-facebook-subscriber ai1ec-facebook-items well pull-left" data-type="{$type}"> \t\t<img id="profile-img" class="ai1ec-facebook-pic pull-left" alt="{$alt_img}" src="https://graph.facebook.com/{$username}/picture" /> HTML; if ($user->get_subscribed()) { $html .= <<<HTML \t\t<div class="pull-right btn-group ai1ec-facebook-buttons"> \t\t\t<a class="ai1ec-facebook-refresh btn btn-mini" data-id="{$id}" title="{$refresh_tip}"><i class="icon-refresh"></i>{$refresh_label}</a> \t\t\t<a class="ai1ec-facebook-remove btn btn-mini logged" data-id="{$id}" title="{$remove_tip}"><i class="icon-remove"></i>{$remove_label}</a> \t\t</div> HTML; } $html .= <<<HTML \t\t<img src="images/wpspin_light.gif" class="ajax-loading-user hide pull-right" alt="" /> \t\t<div class="ai1ec-facebook-name"><big>{$name}</big></div> \t\t{$cat_tag_html} \t</div> </div> HTML; return $html; }
/** * Populate events variable from an ai1ec event and the posted data * * @param $post array * The posted data * * @param $event Ai1ec_Event * The event which has been saved. * */ public function populate_event_from_post_and_ai1ec_event(array $post, Ai1ec_Event $event, Ai1ec_Facebook_Current_User $current_user) { // We must set the id, that means that we would be updating later on. First we check if the // eid is set and that the event was not imported from facebook if (isset($event->facebook_eid) && $event->facebook_status !== Ai1ecFacebookConnectorPlugin::FB_IMPORTED_EVENT) { // Then we check that the eid is not 0 $this->id = (int) $event->facebook_eid === 0 ? NULL : $event->facebook_eid; } // Starting from september 2012 Facebook doesn't accept timestamps anymore. No need for conversions. if (isset($_POST['ai1ec_all_day_event'])) { $this->start_time = date('Y-m-d\\TH:i:sP', $event->start); $this->end_time = date('Y-m-d\\TH:i:sP', $event->end - 60); } else { $this->start_time = date('Y-m-d\\TH:i:sP', $event->start); $this->end_time = date('Y-m-d\\TH:i:sP', $event->end); } $this->name = $post['post_title']; $this->description = $post['content']; $this->city = $post['ai1ec_city']; $this->country = $post['ai1ec_country']; $this->state = $post['ai1ec_province']; $this->zip = $post['ai1ec_postal_code']; // Clone the address. We must clone it as we are handling a refernce and we don't want to modify this. $street = $post['ai1ec_address'] . ""; $this->street = $this->get_street_from_ai1ec_event_street($street, $post['ai1ec_postal_code'], $post['ai1ec_country'], $post['ai1ec_city']); $this->location = $post['ai1ec_venue']; if (!empty($event->facebook_user)) { $this->access_token = $this->get_facebook_page_access_token_from_id($event->facebook_user); } // let's check if the radio were present if (isset($post[Ai1ecFacebookConnectorPlugin::EXPORT_PAGE_RADIO_NAME])) { // get the id $id = (string) $post[Ai1ecFacebookConnectorPlugin::EXPORT_PAGE_RADIO_NAME]; if ((string) $current_user->get_id() !== $id) { try { $this->access_token = $this->get_facebook_page_access_token_from_id($id); } catch (Exception $e) { // no token found, do nothing for now and keep the normal flow } } } }