Example #1
0
 private function action($form)
 {
     //$session       = Application::session();
     $session = session_currentSession();
     $id = session_valueForKey('id');
     //$session->id;
     if (!empty($id)) {
         $u = new User();
         $u->initWithPrimaryKey($id);
         //$q             = phorm_query('User');
         //$q->filter('User->id = '.'"'.$id.'"');
         //$u             = $q->one();
         if (!empty($u->id)) {
             $email = array();
             $email['recipients'][] = $u->username;
             if ($this->shouldUpdateEmail) {
                 $u->username = strtolower($form->email);
                 $email['recipients'][] = strtolower($form->email);
             }
             if ($this->shouldUpdatePassword) {
                 $u->password = $form->password;
             }
             if ($this->shouldUpdatePhoto) {
                 $u->bitmap_normal = $form->photo;
                 $u->bitmap_bigger = $form->photo;
             }
             $u->save();
             $u->release();
             email_sendAccountModify($email);
             header('location:/account/settings/success');
         } else {
             header('location:/account/logout');
         }
     }
 }
Example #2
0
function user_currentUser()
{
    static $user;
    if (!$user) {
        $session = Application::session();
        if (!empty($session->id)) {
            $user = new User();
            $user->initWithPrimaryKey($session->id);
            if (empty($user->id)) {
                $user = null;
            }
        } else {
            $user = null;
        }
    }
    return $user;
}