Exemple #1
0
 private function createProfile($user, $provider, $info)
 {
     if (!$provider) {
         return;
     }
     if (!method_exists($this, $provider . "GetData")) {
         return;
     }
     //максимальная ширина и высота для генерации изображения
     $max_h = $this->params->get('imgparam', 50);
     $max_w = $this->params->get('imgparam', 50);
     $data = call_user_func_array(array($this, $provider . "GetData"), array($user, $provider, $info));
     if (isset($data->picture)) {
         $origimage = $data->picture;
         $new_image = $provider . '_' . $data->slogin_id . '.jpg';
         if ($this->createAvatar($origimage, $new_image, $max_w, $max_h)) {
             $data->avatar = $new_image;
         }
     }
     $db = JFactory::getDbo();
     $q = $db->getQuery(true);
     $q->update('#__plg_slogin_profile');
     $q->set('`current_profile` = 0');
     $q->where('`user_id` = ' . (int) $user->id);
     $db->setQuery($q);
     $db->query();
     $data->current_profile = 1;
     $table = new PlgSloginProfilesTable($db);
     $table->load();
     $table->bind($data);
     $table->store();
 }
    private function createProfile($user, $provider, $info)
    {
        if (!$provider) return;
        if(!method_exists($this, $provider."GetData")) return;

        $data = call_user_func_array(array($this, $provider."GetData"), array($user, $provider, $info));
        if (isset($data->picture)){
            $origimage = $data->picture;
            $new_image = $provider . '_' . $data->slogin_id . '.jpg';
            if ($this->createAvatar($origimage, $new_image))
            {
                $data->avatar = $new_image;
            }
        }

        $db = JFactory::getDbo();
        $q = $db->getQuery(true);
        $q->update('#__plg_slogin_profile');
        $q->set('`current_profile` = 0');
        $q->where('`user_id` = '.(int)$user->id);
        $db->setQuery($q);
        $db->query();

        $data->current_profile = 1;

        $table = new PlgSloginProfilesTable($db);
        $table->load();
        $table->bind($data);
        $table->store();
    }