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


PHP UserDao::getUserByUsername方法代码示例

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


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

示例1: handleForm

 public function handleForm(Context $context, $action)
 {
     if ($action == "createReservation") {
         if (isset($_POST['equip_id']) && $_POST['equip_id'] != "" && (isset($_POST['start_date']) && $_POST['start_date'] != "") && (isset($_POST['length']) && $_POST['length'] != "")) {
             $equipId = $_POST['equip_id'];
             $equip = EquipmentDao::getEquipmentByID($equipId);
             if ($equip != null) {
                 if (SessionUtil::getUserlevel() >= $equip->minUserLevel) {
                     $startDate = $_POST['start_date'];
                     $endDate = DateUtil::incrementDate($startDate, $_POST['length']);
                     $reservations = ReservationDao::getReservationsForEquipmentByDate($equipId, $startDate, $endDate);
                     if (count($reservations) == 0) {
                         $user = UserDao::getUserByUsername(SessionUtil::getUsername());
                         $reservation = ReservationDao::createReservation($user->id, $equipId, $_POST['length'], $startDate, $endDate, $_POST['user_comment']);
                         EmailUtil::sendNewReservationNotices($user, $reservation);
                     } else {
                         $context->addError("Reservations already exist during selected dates ({$startDate} and {$endDate}).");
                     }
                 } else {
                     $context->addError("Cannot reserve equipment (User Level).");
                 }
             } else {
                 $context->addError("No such equipment.");
             }
         } else {
             $context->addError("Required Field Left Blank.");
         }
     } else {
         $context->addError("Incorrect Action.");
     }
 }
开发者ID:ramielrowe,项目名称:Reservation-System-V2,代码行数:31,代码来源:PlaceReservationHandler.php

示例2: authUser

 public static function authUser($username, $password)
 {
     $user = UserDao::getUserByUsername($username);
     if ($user->password == CryptoUtil::encrypt($password)) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:ramielrowe,项目名称:Reservation-System-V2,代码行数:9,代码来源:UserDao.php

示例3: generateHTML

 function generateHTML()
 {
     $user = UserDao::getUserByUsername(SessionUtil::getUsername());
     $changePasswordRows = "";
     if (Config::login_type == LOGIN_TYPE_DB) {
         $changePasswordRows = "\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t<td class=\"centeredcellbold\">Change Password</td>\n\t\t\t\t<td class=\"centeredcellbold\">Current Password</td>\n\t\t\t\t<td class=\"centeredcellbold\">New Password</td>\n\t\t\t\t<td class=\"centeredcellbold\">Confirm Password</td>\n\t\t\n\t\t\t</tr>\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t\t<form action=\"./index.php?pageid=savepassword\" method=\"POST\"><td class=\"centeredcellbold\"><input type=\"submit\" value=\"Save Password\"></td>\n\t\t\t\t\t<td class=\"centeredcell\"><input type=\"password\" name=\"curpass\"></td>\n\t\t\t\t\t<td class=\"centeredcell\"><input type=\"password\" name=\"newpass\"></th>\n\t\t\t\t\t<td class=\"centeredcell\"><input type=\"password\" name=\"confpass\"></td></form>\n\t\t\t\n\t\t\t\t</tr>";
     }
     return "<center><h3>My Account</h3>" . $this->context->getErrorHTML() . "</center>\n\t\t\t\n\t\t\t<table class=\"myaccount\">\n\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t\t<td colspan=4 class=\"header\">Edit User Information</td>\n\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\t\n\t\t\t\t<tr>\n\t\t\n\t\t\t\t\t<td class=\"centeredcellbold\">Username</td>\n\t\t\t\t\t<td colspan=3 class=\"centeredcell\">" . $user->username . "</td>\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\n\t\t\t\t<tr>\n\t\t\n\t\t\t\t\t<td class=\"centeredcellbold\">Name</th>\n\t\t\t\t\t<td colspan=3 class=\"centeredcell\">" . $user->name . "</td>\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\n\t\t\t\t" . $changePasswordRows . "\n\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<form action=\"./index.php?pageid=saveemail\" method=\"POST\">\n\t\t\t\t\t<td colspan=1 class=\"centeredcellbold\">Email</th><td colspan=3 class=\"centeredcell\"><input type=\"text\" name=\"email\" size=30 value=\"" . $user->email . "\"><input type=\"submit\" value=\"Save Email\"></td></form>\n\t\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\n\t\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t\t<td colspan=1 class=\"centeredcellbold\">Warnings</th>\n\t\t\t\t\t<td class=\"centeredcellbold\" colspan=3><a href=\"./index.php?pageid=viewMyWarnings\">" . WarningDao::getWarningCountForUserByType($user->id, RES_WARNING_ACTIVE) . "(" . WarningDao::getWarningCountForUser($user->id) . ")</a></td>\n\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\t\t\n\t\t\t</table>";
 }
开发者ID:ramielrowe,项目名称:Reservation-System-V2,代码行数:9,代码来源:MyAccountBody.php

示例4: generateHTML

 public function generateHTML()
 {
     $username = SessionUtil::getUsername();
     $user = UserDao::getUserByUsername($username);
     $reservations = ReservationDao::getReservationsForUser($user->id, 5);
     $reservationHTML = "";
     foreach ($reservations as $res) {
         $status = $res->getModStatusString();
         $equipment = EquipmentDao::getEquipmentByID($res->equipId);
         $reservationHTML = $reservationHTML . "<tr>\n\t\t\t\n\t\t\t\t\t<td class=\"myequip" . $status . "\">" . $equipment->name . "</td>\n\t\t\t\t\t<td class=\"myequip" . $status . "\">" . $status . "</td>\n\t\t\t\t\t<td class=\"myequip" . $status . "\">" . $res->startDate . "</td>\n\t\t\t\t\t<td class=\"myequip" . $status . "\">" . $res->endDate . "</td>\n\t\t\t\t\t<td class=\"myequip" . $status . "\"><a href=\"./index.php?pageid=viewReservation&resid=" . $res->id . "\">View</a></td>\n\t\t\t\t\t\t\n\t\t\t\t</tr>";
     }
     return OfficeHourCalendar::HTML . "<h3>Your Reservations</h3>\n\t\t\n\t\t<table class=\"myequip\">\n\t\t\n\t\t\t<tr>\n\t\t\n\t\t\t\t<td class=\"header\">Equipment Name</td>\n\t\t\t\t<td class=\"header\">Status</td>\n\t\t\t\t<td class=\"header\">Check-out Date</td>\n\t\t\t\t<td class=\"header\">Due Date</td>\n\t\t\t\t<td class=\"header\">-</td>\n\t\t\t\n\t\t\t</tr>\n\t\t\t\n\t\t\t" . $reservationHTML . "\n\t\n\t\t</table>";
 }
开发者ID:ramielrowe,项目名称:Reservation-System-V2,代码行数:13,代码来源:HomeBody.php

示例5: generateHTML

 public function generateHTML()
 {
     $user = UserDao::getUserByUsername(SessionUtil::getUsername());
     $warnings = WarningDao::getAllWarningsForUser($user->id);
     $options = "";
     foreach ($warnings as $warning) {
         $options .= $warning->toOptionHTML();
     }
     $warningSelect = "You have no warnings. :)";
     if ($options != "") {
         $warningSelect = "<form action=\"./index.php\" method=\"GET\">" . "<input type=\"hidden\" name=\"pageid\" value=\"viewWarning\" />" . "<select name=\"warnid\">" . $options . "</select>" . "<input type=\"submit\" value=\"View\" />" . "</form>";
     }
     return "<center><h3>View My Warnings</h3></center>" . $warningSelect;
 }
开发者ID:ramielrowe,项目名称:Reservation-System-V2,代码行数:14,代码来源:ViewMyWarningsBody.php

示例6: generateHTML

 public function generateHTML()
 {
     $user = UserDao::getUserByUsername(SessionUtil::getUsername());
     if (WarningDao::getWarningCountForUserByType($user->id, RES_WARNING_ACTIVE) > RES_WARNING_MAX_ACTIVE) {
         $this->context->addError("You have too many Active Warnings (more than " . RES_WARNING_MAX_ACTIVE . ") on your account to place Reservations.");
         return $this->context->getErrorHTML() . $this->context->getMessagesHTML();
     }
     //TODO: do we need this?
     $allEquipment = EquipmentDao::getAllEquipment();
     $equipArray = array();
     //^^^^^^^^^^^^^^^^^^^^^^^^^^
     $page = "";
     $success = false;
     if (isset($_POST['equip_id']) && $_POST['equip_id'] != "") {
         if (count($this->context->getErrors()) == 0) {
             $page = "Successfully Created Reservation.";
             $success = true;
         } else {
             $_GET['equipid'] = $_POST['equip_id'];
         }
     }
     if (!$success && isset($_GET['equipid']) && $_GET['equipid'] != "") {
         $equip = EquipmentDao::getEquipmentByID($_GET['equipid']);
         if ($equip != null) {
             if (SessionUtil::getUserlevel() >= $equip->minUserLevel) {
                 $lengthOptions = "";
                 for ($i = 1; $i <= $equip->maxLength; $i++) {
                     if ($i > 1) {
                         $lengthOptions = $lengthOptions . "<option value=\"" . $i . "\">" . $i . " Days</option>";
                     } else {
                         $lengthOptions = $lengthOptions . "<option value=\"" . $i . "\">" . $i . " Day</option>";
                     }
                 }
                 $page = "\n\n\t\t<form name=\"reservation\" action=\"./index.php?pageid=placeReservation\" method=\"POST\" onsubmit=\"return checkDate();\">\n\t\t<input type=\"hidden\" name=\"action\" value=\"createReservation\">\n\t\t<input type=\"hidden\" name=\"equip_id\" value=\"" . $_GET['equipid'] . "\">\n\t\t<table class=\"reservation\">\n\t\t\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td colspan=4 class=\"header\">Reserve the " . $equip->name . "</td>\n\t\t\t\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td class=\"centeredcellbold\">Date (YYYY-MM-DD)</td>\n\t\t\t\t<td class=\"centeredcell\">\n\t\t\t\t\t<input type=\"text\" readonly name=\"start_date\" id=\"startdate\" class=\"date\" value=\"blah\"/>\n\t\t\t\t</td>\n\t\t\t\t<td class=\"centeredcellbold\">Length</td>\n\t\t\t\t<td class=\"centeredcell\"><select name=\"length\">" . $lengthOptions . "</select></td>\n\t\t\n\t\t\t</tr>\n\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td colspan=1 class=\"centeredcellbold\">User Comment</th>\n\t\t\t\t<td class=\"centeredcell\" colspan=3><textarea rows=5 cols=45 name=\"user_comment\"></textarea></td>\n\t\t\t\n\t\t\t</tr>\n\t\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t\t<td colspan=4 class=\"centeredcell\"><input type=\"submit\" value=\"Reserve\"></td>\n\t\t\n\t\t\t\t</tr>\n\t\t\t\t\n\t\t\t</table>\n\t\t\t</form></div>";
             } else {
                 $this->context->addError("Cannot reserve equipment (User Level).");
             }
         } else {
             $this->context->addError("No equipment with ID '" . $_GET['equipid'] . "'.");
         }
     } else {
         if (!$success) {
             $this->context->addError("No equipment selected.");
         }
     }
     return "<center><h3>Place Reservation</h3>" . $this->context->getErrorHTML() . "</center>" . $page;
 }
开发者ID:ramielrowe,项目名称:Reservation-System-V2,代码行数:47,代码来源:PlaceReservationBody.php

示例7: handleForm

 public function handleForm(Context $context, $action)
 {
     if (UserDao::getUserByUsername(SessionUtil::getUsername())->userlevel == RES_USERLEVEL_ADMIN) {
         if ($action == "deleteWarning") {
             $warning = WarningDao::getWarningByID($_POST['warnId']);
             if ($warning != null) {
                 WarningDao::deleteWarning($warning->id);
                 $context->addMessage("Successfully deleted warning.");
             } else {
                 $context->addError("No such warning.");
             }
         } else {
             $context->addError("Incorrect Action.");
         }
     } else {
         $context->addError("Not Authorized.");
     }
 }
开发者ID:ramielrowe,项目名称:Reservation-System-V2,代码行数:18,代码来源:AdminWarningHandler.php

示例8: generateHTML

 public function generateHTML()
 {
     $myuser = UserDao::getUserByUsername(SessionUtil::getUsername());
     $user = UserDao::getUserByID($_GET['userid']);
     if ($myuser->userlevel < RES_USERLEVEL_ADMIN) {
         $this->context->addError("Not Authorized.");
         return $this->context->getErrorHTML();
     }
     $warnings = WarningDao::getAllWarningsForUser($user->id);
     $options = "";
     foreach ($warnings as $warning) {
         $options .= $warning->toOptionHTML();
     }
     $warningSelect = $user . " has no warnings.";
     if ($options != "") {
         $warningSelect = "<form action=\"./index.php\" method=\"GET\">" . "<input type=\"hidden\" name=\"pageid\" value=\"viewWarning\" />" . "<select name=\"warnid\">" . $options . "</select>" . "<input type=\"submit\" value=\"View\" />" . "</form>";
     }
     return "<center><h3>View Warnings For " . $user . "</h3></center>" . $warningSelect;
 }
开发者ID:ramielrowe,项目名称:Reservation-System-V2,代码行数:19,代码来源:ViewWarningsBody.php

示例9: handleForm

 public function handleForm($context, $action)
 {
     if ($action == "login") {
         $authed = false;
         if (Config::login_type == LOGIN_TYPE_LDAP) {
             $authed = false;
             if (Config::ldap_type == LDAP_TYPE_REMOTE) {
                 $authed = RemoteLDAPUtil::auth($_POST['username'], $_POST['password']);
             } else {
                 if (Config::ldap_type == LDAP_TYPE_LOCAL) {
                     $authed = LDAPUtil::authLDAPUser($_POST['username'], $_POST['password']);
                 }
             }
         } else {
             if (Config::login_type == LOGIN_TYPE_DB) {
                 $authed = UserDao::authUser($_POST['username'], $_POST['password']);
             }
         }
         if ($authed) {
             $user = UserDao::getUserByUsername($_POST['username']);
             if ($user != null && $user instanceof User) {
                 SessionUtil::setUsername($user->username);
                 SessionUtil::setUserlevel($user->userlevel);
                 if (isset($_POST['redir']) && $_POST['redir'] != '' && !strpos($_POST['redir'], 'login') && !strpos($_POST['redir'], 'logout')) {
                     header("location: " . $_POST['redir']);
                 } else {
                     $context->setPageID("home");
                 }
             } else {
                 $context->addError("Incorrect Login");
             }
         } else {
             $context->addError("Incorrect Login");
         }
     } else {
         $context->addError("Incorrect Action.");
     }
 }
开发者ID:ramielrowe,项目名称:Reservation-System-V2,代码行数:38,代码来源:LoginHandler.php

示例10: handleForm

 public function handleForm(Context $context, $action)
 {
     if (UserDao::getUserByUsername(SessionUtil::getUsername())->userlevel == RES_USERLEVEL_ADMIN) {
         if ($action == "createWarning") {
             if (isset($_POST['userId']) && $_POST['userId'] != "" && (isset($_POST['reason']) && $_POST['reason'] != "") && (isset($_POST['type']) && $_POST['type'] != "")) {
                 $user = UserDao::getUserByID($_POST['userId']);
                 if ($user != null) {
                     $warning = WarningDao::warnUser($_POST['userId'], $_POST['reason'], $_POST['type']);
                     EmailUtil::sendWarningNoticeToUser($warning);
                     $context->addMessage("Successfully warned " . $user);
                 } else {
                     $context->addError("No such user.");
                 }
             } else {
                 $context->addError("Required field left blank.");
             }
         } else {
             $context->addError("Incorrect Action.");
         }
     } else {
         $context->addError("Not Authorized.");
     }
 }
开发者ID:ramielrowe,项目名称:Reservation-System-V2,代码行数:23,代码来源:WarnUserHandler.php

示例11: generateHTML

 public function generateHTML()
 {
     $myuser = UserDao::getUserByUsername(SessionUtil::getUsername());
     $warning = WarningDao::getWarningByID($_GET['warnid']);
     $user = UserDao::getUserByID($warning->userId);
     if ($user->id != $myuser->id && $myuser->userlevel < RES_USERLEVEL_ADMIN) {
         $this->context->addError("Not Authorized.");
         return $this->context->getErrorHTML();
     }
     $warnings = WarningDao::getAllWarningsForUser($user->id);
     $options = "";
     foreach ($warnings as $warning) {
         $options .= $warning->toOptionHTML();
     }
     $warningSelect = $user . " has no warnings.";
     if ($options != "") {
         $warningSelect = "<form action=\"./index.php\" method=\"GET\">" . "<input type=\"hidden\" name=\"pageid\" value=\"viewWarning\" />" . "<select>" . $options . "</select>" . "<input type=\"submit\" value=\"View\" />" . "</form>";
     }
     $adminRow = "";
     if ($myuser->userlevel >= RES_USERLEVEL_ADMIN) {
         $adminRow = "<tr><form action=\"./index.php?pageid=adminWarning\" method=\"POST\">" . "<td colspan=2 class=\"centeredcellbold\">" . "<input type=\"hidden\" name=\"action\" value=\"deleteWarning\" />" . "<input type=\"hidden\" name=\"warnId\" value=\"" . $warning->id . "\" />" . "<input type=\"submit\" value=\"Delete\" /></td></form></tr>";
     }
     return "<center><h3>View Warning For " . $user . "</h3></center><table class=\"warning\">\n\t\t\t\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td class=\"header\">Type</td>\n\t\t\t\t<td class=\"header\">Time</td>\n\t\t\t\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td class=\"centeredcell\">" . $warning->getTypeString() . "</td>\n\t\t\t\t<td class=\"centeredcell\">" . $warning->datetime . "</td>\n\t\t\t\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td colspan=2 class=\"header\">Warning Reason</td>\n\t\t\t\n\t\t\t</tr>\n\t\t\t\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td colspan=2 class=\"centeredcell\"><textarea cols=\"55\" rows=\"7\" readonly>" . $warning->reason . "</textarea></td>\n\t\t\t\n\t\t\t</tr>\n\t\t\t" . $adminRow . "\n\t\t\n\t\t</table>";
 }
开发者ID:ramielrowe,项目名称:Reservation-System-V2,代码行数:24,代码来源:ViewWarningBody.php


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