当前位置: 首页>>代码示例>>PHP>>正文


PHP UserDAO::updateUser方法代码示例

本文整理汇总了PHP中UserDAO::updateUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserDAO::updateUser方法的具体用法?PHP UserDAO::updateUser怎么用?PHP UserDAO::updateUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserDAO的用法示例。


在下文中一共展示了UserDAO::updateUser方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execChangeProfile

function execChangeProfile($firstname, $lastname, $sex, $departmentID)
{
    if (!isValidName($firstname) || !isValidName($lastname)) {
        return "Please enter valid names!";
    }
    if (!isValidID($departmentID)) {
        return "Invalid department id!";
    }
    $departDAO = new DepartmentDAO();
    $depart = $departDAO->getDepartmentByID($departmentID);
    if ($depart === null) {
        return "Could not find the depart!";
    }
    $userDAO = new UserDAO();
    $user = $userDAO->getUserByID($_SESSION["userID"]);
    $user->setDepartment($depart);
    if ($user->getFirstName() != $firstname) {
        $user->setFirstName($firstname);
    }
    if ($user->getLastName() != $lastname) {
        $user->setLastName($lastname);
    }
    if ($user->getGender() != $sex) {
        $user->setGender($sex);
    }
    if (isset($_FILES["uploadphoto"])) {
        $ans = uploadPhoto($user, $_FILES["uploadphoto"]);
        if ($ans !== true) {
            return $ans;
        }
    }
    $userDAO->updateUser($user);
    return true;
}
开发者ID:hstonec,项目名称:discussion,代码行数:34,代码来源:ajax_change_profile.php

示例2: testUpdateUser

 function testUpdateUser()
 {
     $udao = new UserDAO($this->db, $this->logger);
     $uarr = array('id' => 2, 'user_id' => 13, 'user_name' => 'ginatrapani', 'full_name' => 'Gina Trapani', 'avatar' => 'avatar.jpg', 'location' => 'NYC', 'description' => 'Blogger', 'url' => 'http://ginatrapani.org', 'is_protected' => 0, 'follower_count' => 5000, 'tweet_count' => 1000, 'joined' => '3/6/2007');
     $u = new User($uarr, 'Test');
     $this->assertTrue($udao->updateUser($u));
 }
开发者ID:BenBtg,项目名称:thinktank,代码行数:7,代码来源:userdao_test.php

示例3: executeChange

function executeChange($currUser, $userid, $newrole)
{
    if ($newrole !== "1" && $newrole !== "2" && $newrole !== "3" && $newrole !== "4") {
        return "Invalid status!";
    }
    $userDAO = new UserDAO();
    $userChan = $userDAO->getUserByID($userid);
    $userCurr = $userDAO->getUserByID($currUser);
    //get current session user
    if ($userCurr->getRole()->getRoleID() !== "1" && $userCurr->getRole()->getRoleID() !== "2") {
        return "You have no right to change user status!";
    }
    if ($userChan === null) {
        //database
        return "Could not find this user!";
    }
    if ($userChan->getRole()->getRoleID() === $newrole) {
        //type
        return "Old status is equal to new status, don't need to change!";
    }
    if ($userCurr->getRole()->getRoleID() === "2") {
        if ($newrole === "1" || $newrole === "2") {
            return "You have no right to set an advanced user.";
        }
    }
    $roleDAO = new RoleDAO();
    $newroleObj = $roleDAO->getRoleByID($newrole);
    $userChan->setRole($newroleObj);
    $userDAO->updateUser($userChan);
    return true;
}
开发者ID:hstonec,项目名称:discussion,代码行数:31,代码来源:ajax_change_role.php

示例4: execChangePW

function execChangePW($password, $newpassword, $confirmpw)
{
    if ($password == "" || $newpassword == "" || $confirmpw == "") {
        return "Please fill all the necessary information!";
    }
    if (!isValidPassword($password) || !isValidPassword($newpassword)) {
        return "Please enter a valid password!";
    }
    if ($newpassword !== $confirmpw) {
        return "The new password and the confirmed new password must be the same!";
    }
    $userDAO = new UserDAO();
    $user = $userDAO->getUserByID($_SESSION["userID"]);
    if (!verifyPassword($password, $user->getPassword())) {
        return "The old password you entered is not correct!";
    }
    $encryptPW = encryptPassword($newpassword);
    $user->setPassword($encryptPW);
    $userDAO->updateUser($user);
    return true;
}
开发者ID:hstonec,项目名称:discussion,代码行数:21,代码来源:ajax_change_pw.php

示例5: update

 public function update()
 {
     $userId = $this->registry->request->getParam("userId");
     $name = $this->registry->request->getParam("name");
     $email = $this->registry->request->getParam("email");
     $pin = $this->registry->request->getParam("pin");
     $birthday = new DateTime($this->registry->request->getParam("birthday"));
     $updatedUser = new User($email, $pin);
     $updatedUser->setName($name);
     $updatedUser->setBirthday($birthday);
     $updatedUser->setUserId((int) $userId);
     $userDao = new UserDAO();
     try {
         $userDao->updateUser($updatedUser);
         $_SESSION[AppConstants::SESSION_USER] = $email;
         $_SESSION[AppConstants::SESSION_PASSWORD] = $pin;
         Mailman::sendNoticeOfUpdatedUser($updatedUser);
         $this->redirect("/account?success=" . MessageConfig::USER_UPDATE_SUCCESS);
     } catch (Exception $e) {
         $this->redirect("/account?error=" . $e->getMessage());
     }
 }
开发者ID:ithinkisam,项目名称:wishlist,代码行数:22,代码来源:account.controller.php

示例6: changeUserProfile

function changeUserProfile($userID, $departmentID, $firstname, $lastname, $gender)
{
    $userDAO = new UserDAO();
    $departmentDAO = new DepartmentDAO();
    $user = $userDAO->getUserByID($userID);
    $department = $departmentDAO->getDepartmentByID($departmentID);
    if (!isValidID($userID) || !isValidID($departmentID)) {
        return "Invalid ID!";
    }
    if ($department === null) {
        return "Department: " . $departmentID . " doesn't exist!";
    }
    $user->setDepartment($dept);
    if (!isValidName($firstname)) {
        return "Invalid first name!";
    }
    $user->setFirstName($firstname);
    if (!isValidName($lastname)) {
        return "Invalid last name!";
    }
    $user->setLastName($lastname);
    if ($gender !== 0 && $gender !== 1) {
        return "Please select Male or Female!";
    }
    $user->setGender($gender);
    $userDAO->updateUser($user);
}
开发者ID:hstonec,项目名称:discussion,代码行数:27,代码来源:func.php

示例7: array

    $owner = $od->getByEmail($_SESSION['user']);
    $i = $id->getByUserId($fb_user);
    if (isset($i)) {
        echo "Instance exists<br />";
        $oi = $oid->get($owner->id, $i->id);
        if ($oi == null) {
            //Instance already exists, owner instance doesn't
            $oid->insert($owner->id, $i->id, $session_key);
            //Add owner instance with session key
            echo "Created owner instance.<br />";
        }
    } else {
        //Instance does not exist
        echo "Instance does not exist<br />";
        $id->insert($fb_user, $fb_username, 'facebook');
        echo "Created instance";
        $i = $id->getByUserId($fb_user);
        $oid->insert($owner->id, $i->id, $session_key);
        echo "Created owner instance.<br />";
    }
    if (!$ud->isUserInDB($fb_user)) {
        $r = array('user_id' => $fb_user, 'user_name' => $fb_username, 'full_name' => $fb_username, 'avatar' => '', 'location' => '', 'description' => '', 'url' => '', 'is_protected' => '', 'follower_count' => 0, 'friend_count' => 0, 'post_count' => 0, 'last_updated' => '', 'last_post' => '', 'joined' => '', 'last_post_id' => '', 'network' => 'facebook');
        $u = new User($r, 'Owner info');
        $ud->updateUser($u);
    }
} else {
    echo "No session key or logged in Facebook user.";
}
# clean up
$db->closeConnection($conn);
echo '<br /> <a href="' . $THINKTANK_CFG['site_root_path'] . 'account/">Back to your account</a>.';
开发者ID:ukd1,项目名称:thinktank,代码行数:31,代码来源:fbsavesession.php

示例8: fetchFriendTweetsAndFriends

 function fetchFriendTweetsAndFriends($lurl, $fa)
 {
     $fd = new FollowDAO($this->db, $this->logger);
     $td = new TweetDAO($this->db, $this->logger);
     $ud = new UserDAO($this->db, $this->logger);
     $continue_fetching = true;
     while ($this->api->available && $this->api->available_api_calls_for_crawler > 0 && $continue_fetching) {
         $stale_friend = $fd->getStalestFriend($this->owner_object->id);
         if ($stale_friend != null) {
             $this->logger->logStatus($stale_friend->user_name . " is friend most need of update", get_class($this));
             $stale_friend_tweets = str_replace("[id]", $stale_friend->user_name, $this->api->cURL_source['user_timeline']);
             $args = array();
             $args["count"] = 200;
             if ($stale_friend->last_status_id > 0) {
                 $args['since_id'] = $stale_friend->last_status_id;
             }
             list($cURL_status, $twitter_data) = $this->api->apiRequest($stale_friend_tweets, $this->logger, $args);
             if ($cURL_status == 200) {
                 try {
                     $count = 0;
                     $tweets = $this->api->parseXML($twitter_data);
                     if (count($tweets) > 0) {
                         $stale_friend_updated_from_tweets = false;
                         foreach ($tweets as $tweet) {
                             if ($td->addTweet($tweet, $stale_friend, $this->logger) > 0) {
                                 $count++;
                                 //expand and insert links contained in tweet
                                 $this->processTweetURLs($tweet, $lurl, $fa);
                             }
                             if (!$stale_friend_updated_from_tweets) {
                                 //Update stale_friend values here
                                 $stale_friend->full_name = $tweet['full_name'];
                                 $stale_friend->avatar = $tweet['avatar'];
                                 $stale_friend->location = $tweet['location'];
                                 $stale_friend->description = $tweet['description'];
                                 $stale_friend->url = $tweet['url'];
                                 $stale_friend->is_protected = $tweet['is_protected'];
                                 $stale_friend->follower_count = $tweet['follower_count'];
                                 $stale_friend->friend_count = $tweet['friend_count'];
                                 $stale_friend->tweet_count = $tweet['tweet_count'];
                                 $stale_friend->joined = date_format(date_create($tweet['joined']), "Y-m-d H:i:s");
                                 if ($tweet['status_id'] > $stale_friend->last_status_id) {
                                     $stale_friend->last_status_id = $tweet['status_id'];
                                 }
                                 $ud->updateUser($stale_friend, $this->logger);
                                 $stale_friend_updated_from_tweets = true;
                             }
                         }
                     } else {
                         $this->fetchAndAddUser($stale_friend->id, "Friends");
                     }
                     $this->logger->logStatus(count($tweets) . " tweet(s) found for " . $stale_friend->username . " and {$count} saved", get_class($this));
                 } catch (Exception $e) {
                     $this->logger->logStatus('Could not parse friends XML for $stale_friend->username', get_class($this));
                 }
                 $this->fetchUserFriendsByIDs($stale_friend->id, $fd);
             } elseif ($cURL_status == 401 || $cURL_status == 404) {
                 try {
                     $e = $this->api->parseError($twitter_data);
                     $ued = new UserErrorDAO($this->db, $this->logger);
                     $ued->insertError($stale_friend->id, $cURL_status, $e['error'], $this->owner_object->id);
                     $this->logger->logStatus('User error saved', get_class($this));
                 } catch (Exception $e) {
                     $this->logger->logStatus('Could not parse timeline error for $stale_friend->username', get_class($this));
                 }
             }
         } else {
             $this->logger->logStatus('No friend staler than 1 day', get_class($this));
             $continue_fetching = false;
         }
     }
 }
开发者ID:nickthornley,项目名称:thinktank,代码行数:72,代码来源:class.Crawler.php

示例9: elseif

     if ($fnHash['ok']) {
         JsonResponse::sendResponse(200, $fnHash['result']);
     } else {
         JsonResponse::sendResponse(400, $fnHash['reason']);
     }
 } elseif ($_SERVER['REQUEST_METHOD'] === "POST" && User::isAdmin($_SESSION['user_type'])) {
     $logger->writeLog("Inserting: " . $request_data->email);
     $fnHash = UserDAO::insertUser($request_data->email, $request_data->password, $request_data->first_name, $request_data->last_name, $request_data->phone_nbr, $request_data->facebook_id, $request_data->twitter_id, $request_data->google_id, $request_data->tumblr_id, $request_data->instagram_id, $request_data->img_url, $request_data->img_file_path);
     if ($fnHash['ok']) {
         JsonResponse::sendResponse(200, $fnHash['reason']);
     } else {
         JsonResponse::sendResponse(400, $fnHash['reason']);
     }
 } elseif ($_SERVER['REQUEST_METHOD'] === "PUT" && User::isAdmin($_SESSION['user_type'])) {
     $logger->writeLog("Updating: " . $request_data->id);
     $fnHash = UserDAO::updateUser($request_data->id, $request_data->email, $request_data->first_name, $request_data->last_name, $request_data->phone_nbr, $request_data->facebook_id, $request_data->twitter_id, $request_data->google_id, $request_data->tumblr_id, $request_data->instagram_id, $request_data->img_url, $request_data->img_file_path);
     if ($fnHash['ok']) {
         JsonResponse::sendResponse(200, $fnHash['reason']);
     } else {
         JsonResponse::sendResponse(400, $fnHash['reason']);
     }
 } elseif ($_SERVER['REQUEST_METHOD'] === "DELETE" && User::isAdmin($_SESSION['user_type'])) {
     $user_id = $_GET['user'];
     $fnHash = UserDAO::deleteUser($user_id);
     $logger->writeLog("fnHash['ok'] = " . $fnHash['ok']);
     if ($fnHash['ok']) {
         JsonResponse::sendResponse(200, $fnHash['reason']);
     } else {
         JsonResponse::sendResponse(400, $fnHash['reason']);
     }
 } else {
开发者ID:jls14,项目名称:SpireSessions,代码行数:31,代码来源:index.php


注:本文中的UserDAO::updateUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。