Exemplo n.º 1
0
 public function profile()
 {
     $profile['user_id'] = $this->me['id'];
     $avatar = $this->input->post("avatar_url");
     $fav_tag = $this->input->post("fav_tag");
     $profile['type'] = $this->input->post("type");
     $profile['company'] = $this->input->post("company");
     $profile['station'] = $this->input->post("station");
     $profile['school'] = $this->input->post("school");
     $profile['professional'] = $this->input->post("professional");
     if ($avatar) {
         ModelFactory::User()->edit($this->me['id'], ['avatar' => $avatar]);
     }
     $tags = explode(' ', $fav_tag);
     foreach ($tags as $tag) {
         $trim = trim($tag);
         if ($trim) {
             $tag = ModelFactory::Tag()->get_tag_withtype($tag);
             if (!$tag && $trim) {
                 ModelFactory::Tag()->add_tag($tag);
                 $tag = ModelFactory::Tag()->get_tag_withtype($tag);
             }
             $is_col = ModelFactory::Tag()->is_collect_tag($tag['id']);
             if (!$is_col) {
                 ModelFactory::Tag()->collect_tag($tag['id']);
             }
         }
     }
     if (!($pro = ModelFactory::UserProfile()->getbyuserid($this->me['id']))) {
         ModelFactory::UserProfile()->create($profile);
     } else {
         ModelFactory::UserProfile()->edit($pro['id'], $profile);
     }
     header("location: /home?home=index&uid=" . $this->me['id']);
 }
Exemplo n.º 2
0
<?php

//用户授权应用后的回调
//使用user_profiles 中的intparam2来记录用户的状态, -1来表示用户删除应用,1表示用户授权应用
include "./header.php";
$platform_id = "renren" . $renren->user;
$session_key = $renren->session_key;
$user_id = AutoIncIdGenerator::genid($platform_id);
$db = ServerConfig::getdb_by_userid($user_id);
$up = ModelFactory::UserProfile($db);
$up->find($user_id);
$up->setAttr("intparam2", 1);
$up->setAttr("intparam1", time());
$up->save();