本文整理汇总了PHP中MemberModel::findBy方法的典型用法代码示例。如果您正苦于以下问题:PHP MemberModel::findBy方法的具体用法?PHP MemberModel::findBy怎么用?PHP MemberModel::findBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemberModel
的用法示例。
在下文中一共展示了MemberModel::findBy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* Store Login Module ID in Session, required by LdapAuth (Module config)
* @return string
*/
public function generate()
{
// Login
if (\Input::post('FORM_SUBMIT') == 'tl_login') {
if (\Input::post('username', true) && \Input::post('password', true)) {
$objMember = \MemberModel::findBy('username', \Input::post('username', true));
if ($objMember !== null) {
// always reset the password to a random value, otherwise checkCredentialsHook will never be triggered
LdapMember::resetPassword($objMember, \Input::post('username', true));
}
}
// validate email
if ($GLOBALS['TL_CONFIG']['ldap_uid'] == 'mail' && !\Validator::isEmail(\Input::post('username', true))) {
\Message::addError($GLOBALS['TL_LANG']['ERR']['email']);
$this->reload();
}
}
$strParent = parent::generate();
return $strParent;
}
示例2: run
public function run()
{
$arrJobs = array();
$objTemplate = new \BackendTemplate('be_rename_avatars');
$objTemplate->isActive = $this->isActive();
// Confirmation message
if ($_SESSION['RENAME_AVATARS_CONFIRM'] != '') {
$objTemplate->message = sprintf('<p class="tl_confirm">%s</p>' . "\n", $_SESSION['RENAME_AVATARS_CONFIRM']);
$_SESSION['RENAME_AVATARS_CONFIRM'] = '';
}
// Add potential error messages
if (!empty($_SESSION['TL_ERROR']) && is_array($_SESSION['TL_ERROR'])) {
foreach ($_SESSION['TL_ERROR'] as $message) {
$objTemplate->message .= sprintf('<p class="tl_error">%s</p>' . "\n", $message);
}
$_SESSION['TL_ERROR'] = array();
}
// Run the jobs
if (\Input::post('FORM_SUBMIT') == 'tl_rename_avatars') {
/**
* @var \Files $files
*/
$files = \Files::getInstance();
/**
* @var string $uploadDir
*/
$uploadDir = \FilesModel::findByPk($GLOBALS['TL_CONFIG']['avatar_dir']);
if ($uploadDir) {
$uploadDir = $uploadDir->path;
} else {
$_SESSION['TL_ERROR'][] = 'Upload dir is invalid!';
$this->reload();
}
/**
* @var \MemberModel $member
*/
$member = \MemberModel::findBy(array('avatar!=?'), '');
$count = 0;
while ($member->next()) {
$avatarRecord = \FilesModel::findByUuid($member->avatar);
if ($avatarRecord) {
$avatar = $avatarRecord->path;
} else {
$_SESSION['TL_ERROR'][] = sprintf('Avatar for user ID %d is invalid', $member->id);
continue;
}
$pathinfo = pathinfo($avatar);
$newName = standardize(\String::parseSimpleTokens($GLOBALS['TL_CONFIG']['avatar_name'], $member->row()));
if ($pathinfo['filename'] != $newName) {
$newPath = $uploadDir . '/' . $newName . '.' . $pathinfo['extension'];
$n = 1;
while (file_exists(TL_ROOT . '/' . $newPath)) {
$newPath = $uploadDir . '/' . $newName . '__' . $n++ . '.' . $pathinfo['extension'];
}
$files->rename($avatar, $newPath);
$avatarRecord->path = $newPath;
$avatarRecord->name = $newName;
$avatarRecord->save();
$count++;
}
}
$_SESSION['RENAME_AVATARS_CONFIRM'] = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['avatarsRenamed'], $count);
$this->reload();
}
$objTemplate->action = ampersand(\Environment::get('request'));
$objTemplate->headline = $GLOBALS['TL_LANG']['tl_maintenance']['renameAvatars'];
$objTemplate->submit = specialchars($GLOBALS['TL_LANG']['tl_maintenance']['doRenameAvatars']);
$objTemplate->help = $GLOBALS['TL_LANG']['tl_maintenance']['renameAvatarsHelp'];
return $objTemplate->parse();
}
示例3: updateMembers
public static function updateMembers($arrSelectedLdapMemberGroups)
{
// ldap members
$objLdapMembers = LdapMemberModel::getLdapMembers();
if (!$objLdapMembers) {
return false;
}
// add/update new members
$foundLdapMemberUids = array();
// search filter for mail wildcard and store domain
preg_match('#@(?P<domain>[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5})#is', $GLOBALS['TL_CONFIG']['ldap_filter_person'], $matches);
$mailDomain = $matches['domain'];
foreach ($objLdapMembers as $k => $v) {
if (isset($v[$GLOBALS['TL_CONFIG']['ldap_uid']]) && isset($v[$GLOBALS['TL_CONFIG']['ldap_uid']][0])) {
$uid = $v['uid'][0];
$mail = $v['mail'][0];
$uidMail = $v[$GLOBALS['TL_CONFIG']['ldap_uid']][0];
// multiple emails found
if ($v['mail']['count'] > 1 && !empty($mailDomain)) {
$arrMailFilter = preg_grep("#(.*){$mailDomain}#", $v['mail']);
// perform maildomain rgxp against $mailDomain
$mail = current($arrMailFilter);
// take first mail, that fits domain regxp
$uidMail = $mail;
}
$firstname = $v['givenname'][0];
$lastname = $v['sn'][0];
$foundLdapMemberUids[] = $uid;
$objMember = \MemberModel::findBy(array("email = '{$mail}' OR ldapUid = '{$uid}'"), array());
if ($objMember === null) {
static::doImportMember($uidMail, $arrSelectedLdapMemberGroups);
} else {
static::doUpdateMember($objMember, $uid, $mail, $firstname, $lastname, $arrSelectedLdapMemberGroups);
}
}
}
// mark remotely non existing local ldap members as disabled
$objLocalMembers = \MemberModel::findAll();
if ($objLocalMembers !== null) {
while ($objLocalMembers->next()) {
if ($objLocalMembers->ldapUid && !in_array($objLocalMembers->ldapUid, $foundLdapMemberUids)) {
$objLocalMembers->disable = true;
$objLocalMembers->save();
} else {
$objLocalMembers->disable = false;
$objLocalMembers->save();
}
}
}
}