Esempio n. 1
0
 /**
  * Show the vkontakte form
  *
  * @author	Matt Mecham
  * @param	string		Any inline message to show
  * @return	string		Processed HTML
  */
 public function formVkontakte($inlineMsg = '')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     if (!IPSLib::vkontakte_enabled()) {
         $this->registry->getClass('output')->showError('twitter_disabled', 1005.1);
     }
     //-----------------------------------------
     // Twitter user logged in?
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/vkontakte/connect.php', 'vkontakte_connect');
     $vkontakte = new $classToLoad($this->registry, $this->memberData['vk_token'], $this->memberData['vk_uid']);
     //-----------------------------------------
     // Thaw bitfield options
     //-----------------------------------------
     $bwOptions = IPSBWOptions::thaw($this->memberData['vk_bwoptions'], 'vkontakte');
     //-----------------------------------------
     // Merge..
     //-----------------------------------------
     if (is_array($bwOptions)) {
         foreach ($bwOptions as $k => $v) {
             $this->memberData[$k] = $v;
         }
     }
     $this->hide_form_and_save_button = 1;
     $userData = $vkontakte->fetchUserData();
     if (isset($userData['status']['text'])) {
         if (IPS_DOC_CHAR_SET != 'UTF-8') {
             $userData['status']['text'] = IPSText::utf8ToEntities($userData['status']['text']);
         }
     }
     return $this->registry->getClass('output')->getTemplate('vkontakte')->membersVkontakteConnect($this->memberData['vk_uid'], $userData);
 }
Esempio n. 2
0
 /**
  * Fetch a user's vkontakte picture
  * 
  * @param mixed $member	INT OR ARRAY
  */
 public function setVkontaktePicture($member)
 {
     /* Fetch member details */
     if (is_integer($member)) {
         $member = IPSMember::load($member, 'all');
     } else {
         if (isset($member['member_id']) && !isset($member['pp_photo_type'])) {
             $member = IPSMember::load($member['member_id'], 'all');
         }
     }
     /* Fix up upload directory */
     $paths = $this->_getProfileUploadPaths();
     $upload_path = $paths['path'];
     $upload_dir = $paths['dir'];
     /* Vkontakte enabled? */
     if (IPSLib::vkontakte_enabled() && $member['vk_token'] && $member['vk_uid']) {
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/vkontakte/connect.php', 'vkontakte_connect');
         $vkontakte = new $classToLoad($this->registry, $member['vk_token'], $member['vk_uid']);
         $userData = $vkontakte->fetchUserData();
         if ($userData['photo']) {
             $img = $userData['photo'];
             $ext = IPSText::getFileExtension($img);
             $file = 'photo-' . $member['member_id'] . '.' . $ext;
             $mokay = false;
             $content = @file_get_contents($img);
             /* Try http wrappers first. Would be rude not to */
             if ($content) {
                 if (file_put_contents($upload_path . '/' . $file, $content)) {
                     $mokay = true;
                     return $this->buildSizedPhotos($file, $member['member_id']);
                 }
             }
             /* Back up */
             if ($mokay === false) {
                 return array('final_location' => $userData['profile_image_url'], 'final_width' => 50, 'final_height' => 50, 't_final_location' => $userData['profile_image_url'], 't_final_width' => 50, 't_final_height' => 50);
             }
         }
     } else {
         return array();
     }
 }