本文整理匯總了PHP中models\User::FindUsername方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::FindUsername方法的具體用法?PHP User::FindUsername怎麽用?PHP User::FindUsername使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models\User
的用法示例。
在下文中一共展示了User::FindUsername方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: NotifyAdmins
public static function NotifyAdmins(\Models\Sickleave $sickleave)
{
$mail = self::Instance();
// Get admins
require_once ROOT_PATH . 'includes/load_admin_usernames.php';
$admins = get_admins();
// Initialize user data of people behind the sickleave entry
$userAuthor = $sickleave->getAuthor();
$userFor = $sickleave->getFor();
foreach ($admins as $admin) {
$adminUser = \Models\User::FindUsername($admin);
if ($adminUser instanceof \Models\User) {
$emailAddress = $adminUser->getEmail();
$mail->clearAllRecipients();
// Send email to this person
$mail->addAddress($emailAddress, $adminUser->getName());
$mail->Subject = sprintf('New Sick-leave for %s', $userFor->getName());
$mail->Body = String::Format('<font face="arial" size="8px">' . 'Hello {{admin_name}},<br>' . '<br>' . '<br>' . '<h2>A sick-leave has been filed for {{for_name}}</h2>' . '<br>' . '<b>For: </b>{{for_name}}<br>' . '<b>Author: </b>{{author_name}}<br>' . '<b>Target date: </b>{{date}}<br>' . '<b>Span: </b>{{span}} day/s<br>' . '<br>' . '<h2>Reason</h2>' . '<h3><i>"{{reason}}"</i></h3><br>' . 'To view this sick-leave, click the URL below: <br>' . '<a href="{{url}}">{{url}}</a><br>' . '<br>' . 'Thank you!<br>' . '<i>OpeniT YouSick system</i>' . '</font>', ['admin_name' => $adminUser->getName(), 'for_name' => $userFor->getName(), 'author_name' => $userAuthor->getName(), 'date' => $sickleave->getDate(), 'span' => $sickleave->getSpan(), 'reason' => $sickleave->getReason(), 'url' => BASE_URL . 'admin/view-sickleave?id=' . $sickleave->GetRecordID()]);
// Send mail
$mail->send();
}
}
}
示例2: die
$fileErrorMsg = $_FILES["myfile"]["error"];
//0 for false and 1 for true
if (!$fileTmpLoc) {
die(new ModelResponse(false, 'Please browse for a valid file'));
}
$destPath = "{$uploadPath}/{$fileName}";
if (move_uploaded_file($fileTmpLoc, $destPath)) {
$raw_data = CSV::Parse($destPath);
// Get initial user list
$currentUserList = new Models\UserList();
// Initialize container
$userList = new Models\UserList(false);
// proceed with creation
foreach ($raw_data as $row) {
$user = new Models\User();
if ($currentUserList->ContainsUsername($row['username'])) {
$user = \Models\User::FindUsername(strtolower(trim($row['username'])));
} else {
$user->Absorb($row);
}
$userList->add($user);
}
if (!$userList->Create()) {
die(ModelResponse::DataSaveFailed());
}
$response = new ModelResponse(true, 'Data import success!', $userList);
die($response);
} else {
die(ModelResponse::Busy());
}
}
示例3: die
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* [REST_META]
*
* username (string)
*
*/
header('Content-type: application/json');
require_once ROOT_PATH . 'includes/load_admin_usernames.php';
$expectations = ['username'];
if (!\Utilities\Requests::HasRequest($expectations)) {
die(ModelResponse::InvalidRequest());
}
$is_admin = is_admin($_REQUEST['username']);
$user = null;
if ($is_admin) {
$user = \Models\User::FindUsername($_REQUEST['username']);
die(new ModelResponse(true, 'Yes, an admin', $user));
} else {
die(new ModelResponse(false, sprintf('User \\"%s\\" is not an admin', $_REQUEST['username'])));
}
示例4: die
// Check requests
if (!\Utilities\Requests::HasRequest(['username', 'password'])) {
die(ModelResponse::InvalidRequest());
}
extract($_REQUEST, EXTR_SKIP);
$matches = array();
// Username sanitation
preg_match('/[A-Za-z0-9_\\.]+/', $username, $matches);
if (sizeof($matches) > 0) {
$username = $matches[0];
}
// end of username sanitation
if (!has_account($username)) {
die(new ModelResponse(false, 'User is not registered'));
}
// Otherwise, proceed with LDAP authentication
$ldapresource = ldap_connect("ldap://svg.openit.local", 389) or die("Unable to connect to ldap://svg.openit.local:389");
//$result = ldap_bind("svg.openit.local");
ob_start();
$bind = ldap_bind($ldapresource, sprintf("%s@svg.openit.local", $username), trim($password));
$buffer = ob_get_clean();
if ($bind == true) {
// Get user data
$user = \Models\User::FindUsername($username);
if ($user instanceof \Models\User && $user->getUsername() != null) {
Utilities\Session::LogIn($user->getUsername());
}
die(new ModelResponse(true, 'Authentication success', $user));
} else {
die(new ModelResponse(false, 'Incorrect password'));
}