本文整理汇总了PHP中Member::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Member::exists方法的具体用法?PHP Member::exists怎么用?PHP Member::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Member
的用法示例。
在下文中一共展示了Member::exists方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUserProfile
/**
* Returns a given user's profile
*
* @param string $username Username's profile to return
* @return array
*/
public static function getUserProfile($username)
{
if (!Member::exists($username)) {
return null;
}
$content = substr(File::get(Config::getConfigPath() . "/users/" . $username . ".yaml"), 3);
$divide = strpos($content, "\n---");
$front_matter = trim(substr($content, 0, $divide));
$content_raw = trim(substr($content, $divide + 4));
$profile = YAML::parse($front_matter);
$profile['biography_raw'] = $content_raw;
$profile['biography'] = Content::transform($content_raw);
$profile['username'] = $username;
return $profile;
}
示例2: testEmptyMemberFails
public function testEmptyMemberFails()
{
$member = new Member();
$this->assertFalse($member->exists());
$this->logInWithPermission('ADMIN');
$this->assertFalse(Permission::checkMember($member, 'ADMIN'));
$this->assertFalse(Permission::checkMember($member, 'CMS_ACCESS_LeftAndMain'));
}
示例3: member__register
/**
* Target for the member:register_form form
*
* @return void
*/
public function member__register()
{
$referrer = $_SERVER['HTTP_REFERER'];
$token = filter_input(INPUT_POST, 'token', FILTER_SANITIZE_STRING);
$return = filter_input(INPUT_POST, 'return', FILTER_SANITIZE_STRING);
$auto_login = (bool) filter_input(INPUT_POST, 'auto_login', FILTER_SANITIZE_NUMBER_INT);
// validate form token
if (!$this->tokens->validate($token)) {
$this->flash->set('login_error', 'Invalid token.');
URL::redirect($referrer);
}
// is user logged in?
if (Auth::isLoggedIn()) {
URL::redirect($return);
}
// get configurations
$allowed_fields = array_get($this->loadConfigFile('fields'), 'fields', array());
// get username
$username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
// set up iterators and flags
$submission = array('username' => $username);
// create member object
$member = new Member(array());
// adjust allowed fields to include username and password
if (!isset($allowed_fields['username'])) {
$allowed_fields['username'] = array();
}
if (!isset($allowed_fields['password'])) {
$allowed_fields['password'] = array();
}
// loop through allowed fields, validating and storing
foreach ($allowed_fields as $field => $options) {
if (!isset($_POST[$field])) {
// field wasn't set, skip it
continue;
}
// set value
$value = filter_input(INPUT_POST, $field, FILTER_SANITIZE_STRING);
// don't store this value if `save_value` is set to `false`
if (array_get($options, 'save_value', true)) {
$member->set($field, $value);
}
// add to submissions, including non-save_value fields because this
// is the list that will be validated
$submission[$field] = $value;
}
// ensure UID
$member->ensureUID(false);
// user-defined validation
$errors = $this->tasks->validate($submission);
// built-in validation
// --------------------------------------------------------------------
// username
if (!$username) {
$errors['username'] = 'Username is required.';
} elseif (!Member::isValidUsername($username)) {
$errors['username'] = 'Username entered is not valid.';
} elseif (Member::exists($username)) {
$errors['username'] = 'Username is already in use.';
}
// password
$password = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_STRING);
$password_confirm = filter_input(INPUT_POST, 'password_confirmation', FILTER_SANITIZE_STRING);
if (empty($password)) {
$errors['password'] = 'Password is required';
}
if (!isset($errors['password']) && !is_null($password_confirm) && $password !== $password_confirm) {
$errors['password_confirmation'] = 'Passwords did not match.';
}
if (count($errors)) {
// errors were found, set a flash message and redirect
$this->flash->set('register_error', 'Member not created.');
$this->flash->set('register_field_errors', $errors);
// remove password and password_confirm from submission
if (isset($submission['password'])) {
unset($submission['password']);
}
if (isset($submission['password_confirmation'])) {
unset($submission['password_confirmation']);
}
$this->flash->set('register_old_values', $submission);
// redirect back to the form
URL::redirect($referrer);
} else {
// set new member roles
$member->set('roles', Helper::ensureArray($this->fetchConfig('new_member_roles', array(), null, false, false)));
if ($this->runHook('pre_process', 'replace', true, $member)) {
// save member
$member->save();
// trigger a hook
$this->runHook('register', 'call', null, $member);
// user saved
$this->flash->set('register_success', 'Member created.');
if ($auto_login) {
Auth::login($username, $password);
//.........这里部分代码省略.........
示例4: getFields
/**
* @param Member $member
* @return FieldList
**/
public function getFields(Member $member = null)
{
$fields = parent::getEcommerceFields();
$fields->push(new HeaderField('BillingDetails', _t('OrderAddress.BILLINGDETAILS', 'Billing Address'), 3));
$fields->push(new TextField('Phone', _t('OrderAddress.PHONE', 'Phone')));
$billingFields = new CompositeField();
$hasPreviousAddresses = false;
if ($member) {
if ($member->exists() && !$member->IsShopAdmin()) {
$this->FillWithLastAddressFromMember($member, true);
$addresses = $member->previousOrderAddresses($this->baseClassLinkingToOrder(), $this->ID, $onlyLastRecord = false, $keepDoubles = false);
//we want MORE than one here not just one.
if ($addresses->count() > 1) {
$fields->push(SelectOrderAddressField::create('SelectBillingAddressField', _t('OrderAddress.SELECTBILLINGADDRESS', 'Select Billing Address'), $addresses));
$hasPreviousAddresses = true;
}
}
}
//$billingFields->push(new TextField('MobilePhone', _t('OrderAddress.MOBILEPHONE','Mobile Phone')));
$mappingArray = $this->Config()->get("fields_to_google_geocode_conversion");
if (is_array($mappingArray) && count($mappingArray)) {
if (!class_exists("GoogleAddressField")) {
user_error("You must install the Sunny Side Up google_address_field module OR remove entries from: BillingAddress.fields_to_google_geocode_conversion");
}
$billingFields->push($billingEcommerceGeocodingField = new GoogleAddressField('BillingEcommerceGeocodingField', _t('OrderAddress.FIND_ADDRESS', 'Find address'), Session::get("BillingEcommerceGeocodingFieldValue")));
$billingEcommerceGeocodingField->setFieldMap($mappingArray);
//$billingFields->push(new HiddenField('Address2', "NOT SET", "NOT SET"));
//$billingFields->push(new HiddenField('City', "NOT SET", "NOT SET"));
}
//$billingFields->push(new TextField('Prefix', _t('OrderAddress.PREFIX','Title (e.g. Ms)')));
$billingFields->push(new TextField('Address', _t('OrderAddress.ADDRESS', 'Address')));
$billingFields->push(new TextField('Address2', _t('OrderAddress.ADDRESS2', '')));
$billingFields->push(new TextField('City', _t('OrderAddress.CITY', 'Town')));
$billingFields->push($this->getPostalCodeField("PostalCode"));
$billingFields->push($this->getRegionField("RegionID", "RegionCode"));
$billingFields->push($this->getCountryField("Country"));
$billingFields->addExtraClass('billingFields');
$billingFields->addExtraClass("orderAddressHolder");
$this->makeSelectedFieldsReadOnly($billingFields->FieldList());
$fields->push($billingFields);
$this->extend('augmentEcommerceBillingAddressFields', $fields);
return $fields;
}
示例5: isAuthor
/**
* Determine if the given member is an author of this post.
*
* @param null|Member $member
*
* @return bool
*/
public function isAuthor($member = null)
{
if (!$member || !$member->exists()) {
return false;
}
$list = $this->Authors();
if ($list instanceof UnsavedRelationList) {
return in_array($member->ID, $list->getIDList());
}
return $list->byID($member->ID) !== null;
}
示例6: isMemberOf
/**
* Determine if the given member belongs to the given relation.
*
* @param Member $member
* @param DataList $relation
*
* @return bool
*/
protected function isMemberOf($member, $relation)
{
if (!$member || !$member->exists()) {
return false;
}
if ($relation instanceof UnsavedRelationList) {
return in_array($member->ID, $relation->getIDList());
}
return $relation->byID($member->ID) !== null;
}
示例7: clear
/**
* Deletes existing tokens for this member
* if logout_across_devices is true, all tokens are deleted, otherwise
* only the token for the provided device ID will be removed
*/
public static function clear(Member $member, $alcDevice = null)
{
if (!$member->exists()) {
return;
}
$filter = array('MemberID' => $member->ID);
if (Config::inst()->get('RememberLoginHash', 'logout_across_devices') == false && $alcDevice) {
$filter['DeviceID'] = $alcDevice;
}
RememberLoginHash::get()->filter($filter)->removeAll();
}
示例8: getFields
/**
* Puts together the fields for the Order Form (and other front-end purposes).
* @param Member $member
* @return FieldList
**/
public function getFields(Member $member = null)
{
$fields = parent::getEcommerceFields();
$hasPreviousAddresses = false;
if (EcommerceConfig::get("OrderAddress", "use_separate_shipping_address")) {
$shippingFieldsHeader = new CompositeField(new HeaderField('SendGoodsToADifferentAddress', _t('OrderAddress.SENDGOODSTODIFFERENTADDRESS', 'Send goods to different address'), 3), new LiteralField('ShippingNote', '<p class="message warning">' . _t('OrderAddress.SHIPPINGNOTE', 'Your goods will be sent to the address below.') . '</p>'));
if ($member) {
if ($member->exists() && !$member->IsShopAdmin()) {
$this->FillWithLastAddressFromMember($member, true);
$addresses = $member->previousOrderAddresses($this->baseClassLinkingToOrder(), $this->ID, $onlyLastRecord = false, $keepDoubles = false);
//we want MORE than one here not just one.
if ($addresses->count() > 1) {
$hasPreviousAddresses = true;
$shippingFieldsHeader->push(SelectOrderAddressField::create('SelectShippingAddressField', _t('OrderAddress.SELECTBILLINGADDRESS', 'Select Shipping Address'), $addresses));
}
}
$shippingFields = new CompositeField(new TextField('ShippingFirstName', _t('OrderAddress.FIRSTNAME', 'First Name')), new TextField('ShippingSurname', _t('OrderAddress.SURNAME', 'Surname')));
} else {
$shippingFields = new CompositeField(new TextField('ShippingFirstName', _t('OrderAddress.FIRSTNAME', 'First Name')), new TextField('ShippingSurname', _t('OrderAddress.SURNAME', 'Surname')));
}
$shippingFields->push(new TextField('ShippingPhone', _t('OrderAddress.PHONE', 'Phone')));
//$shippingFields->push(new TextField('ShippingMobilePhone', _t('OrderAddress.MOBILEPHONE','Mobile Phone')));
$mappingArray = $this->Config()->get("fields_to_google_geocode_conversion");
if (is_array($mappingArray) && count($mappingArray)) {
if (!class_exists("GoogleAddressField")) {
user_error("You must install the Sunny Side Up google_address_field module OR remove entries from: ShippingAddress.fields_to_google_geocode_conversion");
}
$shippingFields->push($shippingEcommerceGeocodingField = new GoogleAddressField('ShippingEcommerceGeocodingField', _t('OrderAddress.Find_Address', 'Find address'), Session::get("ShippingEcommerceGeocodingFieldValue")));
$shippingEcommerceGeocodingField->setFieldMap($mappingArray);
//$shippingFields->push(new HiddenField('ShippingAddress2'));
//$shippingFields->push(new HiddenField('ShippingCity'));
} else {
}
//$shippingFields->push(new TextField('ShippingPrefix', _t('OrderAddress.PREFIX','Title (e.g. Ms)')));
$shippingFields->push(new TextField('ShippingAddress', _t('OrderAddress.ADDRESS', 'Address')));
$shippingFields->push(new TextField('ShippingAddress2', _t('OrderAddress.ADDRESS2', '')));
$shippingFields->push(new TextField('ShippingCity', _t('OrderAddress.CITY', 'Town')));
$shippingFields->push($this->getRegionField("ShippingRegionID", "ShippingRegionCode"));
$shippingFields->push($this->getPostalCodeField("ShippingPostalCode"));
$shippingFields->push($this->getCountryField("ShippingCountry"));
$this->makeSelectedFieldsReadOnly($shippingFields);
$shippingFieldsHeader->addExtraClass("shippingFieldsHeader");
$shippingFields->addExtraClass("orderAddressHolder");
$fields->push($shippingFieldsHeader);
$shippingFields->addExtraClass('shippingFields');
$fields->push($shippingFields);
}
$this->extend('augmentEcommerceShippingAddressFields', $fields);
return $fields;
}
示例9: array
}
$template_list = array("member");
// check for flash data
$errors = Session::getFlash('member_errors', array());
$old_values = Session::getFlash('member_old_values', array());
// merge
$data = $old_values + $data + array('_errors' => $errors, 'new' => $new);
Statamic_View::set_templates(array_reverse($template_list));
$admin_app->render(null, array('route' => 'members', 'app' => $admin_app) + $data);
})->name('member');
// GET: DELETE MEMBER
$admin_app->get('/deletemember', function () use($admin_app) {
authenticateForRole('admin');
doStatamicVersionCheck($admin_app);
$name = $admin_app->request()->get('name');
if (Member::exists($name)) {
$user = Auth::getMember($name);
$user->delete();
}
// Redirect
$admin_app->flash('info', Localization::fetch('member_deleted'));
$url = $admin_app->urlFor('members');
$admin_app->redirect($url);
})->name('deletemember');
// Account
// --------------------------------------------------------
$admin_app->get('/account', function () use($admin_app) {
authenticateForRole('admin');
doStatamicVersionCheck($admin_app);
$user = Auth::getCurrentMember();
$username = $user->get('username');
示例10: user_exists
/**
* Checks if a user exists
*
* @deprecated
* @param string $username Username to check
* @return boolean
*/
public static function user_exists($username)
{
// deprecation warning
Log::warn("Use of `user_exists` is deprecated. Use `Member::exists` instead.", "core", "auth");
// return it
return Member::exists($username);
}
示例11: _doAddMember
public static function _doAddMember()
{
$user = User::find(intval($_SESSION['userid']));
$member = Member::find(intval($_SESSION['memberid']));
$division = Division::findById($member->game_id);
$platoon_id = $user->role >= 3 || User::isDev() ? $_POST['platoon_id'] : $member->platoon_id;
$squad_id = $user->role >= 2 || User::isDev() ? $_POST['squad_id'] : Squad::mySquadId($member->id) ?: 0;
$recruiter = $member->member_id;
$position_id = 6;
// provide params for brand new members
$params = array('member_id' => $_POST['member_id'], 'forum_name' => trim($_POST['forum_name']), 'recruiter' => $recruiter, 'game_id' => $_POST['game_id'], 'status_id' => 999, 'join_date' => date("Y-m-d H:i:s"), 'last_forum_login' => date("Y-m-d H:i:s"), 'last_activity' => date("Y-m-d H:i:s"), 'last_forum_post' => date("Y-m-d H:i:s"), 'last_promotion' => date("Y-m-d H:i:s"), 'rank_id' => 1, 'platoon_id' => $platoon_id, 'squad_id' => $squad_id, 'position_id' => $position_id);
if (Member::exists($_POST['member_id'])) {
// update existing record
$existing_member_id = Member::findId($_POST['member_id']);
$params = array_merge($params, array('id' => $existing_member_id));
$affected_rows = Member::modify($params);
if ($affected_rows > 0) {
UserAction::create(array('type_id' => 10, 'date' => date("Y-m-d H:i:s"), 'user_id' => $member->member_id, 'target_id' => $params['member_id']));
$data = array('success' => true, 'message' => "Existing member successfully updated!");
} else {
$data = array('success' => false, 'message' => "Existing member could not be updated.");
}
} else {
// member doesn't exist
$insert_id = Member::create($params);
if ($insert_id != 0) {
UserAction::create(array('type_id' => 1, 'date' => date("Y-m-d H:i:s"), 'user_id' => $member->member_id, 'target_id' => $params['member_id']));
$data = array('success' => true, 'message' => "Member successfully added!");
} else {
$data = array('success' => false, 'message' => "Member could not be added.");
}
}
if ($insert_id != 0) {
if (isset($_POST['played_games'])) {
$games = $_POST['played_games'];
foreach ($games as $game) {
$memberGame = new stdClass();
$memberGame->member_id = $insert_id;
$memberGame->game_id = $game;
MemberGame::add($memberGame);
}
}
if (isset($_POST['ingame_name'])) {
$ingame_name = trim($_POST['ingame_name']);
$handle = new stdClass();
$handle->member_id = $insert_id;
$handle->handle_type = $division->primary_handle;
$handle->handle_value = $ingame_name;
$handle->handle_account_id = '0';
$handle->invalid = '0';
$handle->invalid_date = '0000-00-00';
MemberHandle::add($handle);
}
}
echo json_encode($data);
}
示例12: FillWithLastAddressFromMember
/**
*@todo: are there times when the Shipping rather than the Billing address should be linked?
* Copies the last address used by the member.
*
* @param Object (Member) $member
* @param Boolean $write - should the address be written
* @return DataObject (OrderAddress / ShippingAddress / BillingAddress)
**/
public function FillWithLastAddressFromMember(Member $member, $write = false)
{
$excludedFields = array("ID", "OrderID");
$fieldPrefix = $this->fieldPrefix();
if ($member && $member->exists()) {
$oldAddress = $member->previousOrderAddress($this->baseClassLinkingToOrder(), $this->ID);
if ($oldAddress) {
$fieldNameArray = $this->getFieldNameArray($fieldPrefix);
foreach ($fieldNameArray as $field) {
if (in_array($field, $excludedFields)) {
//do nothing
} elseif ($this->{$field}) {
//do nothing
} elseif (isset($oldAddress->{$field})) {
$this->{$field} = $oldAddress->{$field};
}
}
}
//copy data from member
if (is_a($this, Object::getCustomClass("BillingAddress"))) {
$this->Email = $member->Email;
}
$fieldNameArray = array("FirstName" => $fieldPrefix . "FirstName", "Surname" => $fieldPrefix . "Surname");
foreach ($fieldNameArray as $memberField => $fieldName) {
//NOTE, we always override the Billing Address (which does not have a fieldPrefix)
if (!$this->{$fieldName} || is_a($this, Object::getCustomClass("BillingAddress"))) {
$this->{$fieldName} = $member->{$memberField};
}
}
}
if ($write) {
$this->write();
}
return $this;
}
示例13: array
} else {
$err = "Email ou mot de passe incorrect.";
$app->render('login.php', array('err' => $err));
}
})->name('login');
$app->get('/signin', function () use($app) {
$app->render('signin.php');
})->name('signin');
$app->post('/signin', function () use($app) {
$post = $app->request->post();
$err = array();
$member = new Member();
$user = new User($app->request->post());
$user->id_type = 1;
// Vérifie le numéro de licence
if ($member->exists($post['licence_num']) != false) {
$err[] = "Votre numéro de licence est incorrect.";
} else {
// Vérifie de l'email
if ($user->exists($post['mail']) != false) {
$err[] = "Cette adresse email est ddéjà prise.";
}
}
// Vérifie si les mdp sont identiques
if ($post['password'] != $post['password_confirm']) {
$err[] = "Vos mots de passe ne sont pas identiques.";
}
// Vérifie si y'a des erreurs
if (empty($err)) {
$user = $user->save();
$note = new Note();