Create() public method

public Create ( )
コード例 #1
0
ファイル: Registration.php プロジェクト: ajeshgeorge22/booked
 public function Register($username, $email, $firstName, $lastName, $password, $timezone, $language, $homepageId, $additionalFields = array(), $attributeValues = array(), $groups = null)
 {
     $encryptedPassword = $this->_passwordEncryption->EncryptPassword($password);
     $attributes = new UserAttribute($additionalFields);
     if ($this->CreatePending()) {
         $user = User::CreatePending($firstName, $lastName, $email, $username, $language, $timezone, $encryptedPassword->EncryptedPassword(), $encryptedPassword->Salt(), $homepageId);
     } else {
         $user = User::Create($firstName, $lastName, $email, $username, $language, $timezone, $encryptedPassword->EncryptedPassword(), $encryptedPassword->Salt(), $homepageId);
     }
     $user->ChangeAttributes($attributes->Get(UserAttribute::Phone), $attributes->Get(UserAttribute::Organization), $attributes->Get(UserAttribute::Position));
     $user->ChangeCustomAttributes($attributeValues);
     if ($groups != null) {
         $user->WithGroups($groups);
     }
     if (Configuration::Instance()->GetKey(ConfigKeys::REGISTRATION_AUTO_SUBSCRIBE_EMAIL, new BooleanConverter())) {
         foreach (ReservationEvent::AllEvents() as $event) {
             $user->ChangeEmailPreference($event, true);
         }
     }
     $userId = $this->_userRepository->Add($user);
     $this->AutoAssignPermissions($userId);
     if (Configuration::Instance()->GetKey(ConfigKeys::REGISTRATION_NOTIFY, new BooleanConverter())) {
         ServiceLocator::GetEmailService()->Send(new AccountCreationEmail($user, ServiceLocator::GetServer()->GetUserSession()));
     }
     return $user;
 }
コード例 #2
0
 public function Register($username, $email, $firstName, $lastName, $password, $timezone, $language, $homepageId, $additionalFields = array(), $attributeValues = array())
 {
     $encryptedPassword = $this->_passwordEncryption->EncryptPassword($password);
     $attributes = new UserAttribute($additionalFields);
     if ($this->CreatePending()) {
         $user = User::CreatePending($firstName, $lastName, $email, $username, $language, $timezone, $encryptedPassword->EncryptedPassword(), $encryptedPassword->Salt(), $homepageId);
     } else {
         $user = User::Create($firstName, $lastName, $email, $username, $language, $timezone, $encryptedPassword->EncryptedPassword(), $encryptedPassword->Salt(), $homepageId);
     }
     $user->ChangeAttributes($attributes->Get(UserAttribute::Phone), $attributes->Get(UserAttribute::Organization), $attributes->Get(UserAttribute::Position));
     $user->ChangeCustomAttributes($attributeValues);
     if (Configuration::Instance()->GetKey(ConfigKeys::REGISTRATION_AUTO_SUBSCRIBE_EMAIL, new BooleanConverter())) {
         foreach (ReservationEvent::AllEvents() as $event) {
             $user->ChangeEmailPreference($event, true);
         }
     }
     $userId = $this->_userRepository->Add($user);
     $this->AutoAssignPermissions($userId);
     $addgroupname = Configuration::Instance()->GetKey(ConfigKeys::NEW_USER_GROUP);
     // Match group name to group_id
     $addgroupid_res = ServiceLocator::GetDatabase()->Query(new AdHocCommand("select group_id from groups where name = '{$addgroupname}'"));
     while ($row = $addgroupid_res->GetRow()) {
         $addgroupid = $row['group_id'];
     }
     //Add user to group
     if ($addgroupid != NULL) {
         ServiceLocator::GetDatabase()->Execute(new AdHocCommand("insert into user_groups(user_id, group_id) VALUES ({$userId}, {$addgroupid})"));
     }
     return $user;
 }
コード例 #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $validation = Validator::make($input, User::$rules);
     if ($validation->passes()) {
         User::Create($input);
         return Redirect::route('users.index');
     }
     return Redirect::route('users.create')->withInput()->withErrors($validation)->with('message', 'There ware validation errors.');
 }
コード例 #4
0
ファイル: User.php プロジェクト: paha710/test
 public static function Login($username, $password)
 {
     $password = crypt($password, $username);
     //Хорошо бы на SHA-2 заменить
     $userData = DB::Get()->Select('SELECT * FROM User WHERE email=:email AND `password`=:password', array('email' => $username, 'password' => $password));
     // echo $username.$password;
     if (isset($userData[0])) {
         Session::CreateSession($userData[0]['id']);
         return User::Create($userData[0]);
     }
     return false;
 }
コード例 #5
0
 public function Users()
 {
     //codes for data validation
     $validate = Validator::make(Input::all(), ['u_name' => 'required', 'regno' => 'required|unique:users|min:2|max:20', 'email' => 'email|required|unique:users', 'password' => 'required|confirmed', 'course' => 'required', 'nation' => 'required', 'role' => 'required']);
     if ($validate->passes()) {
         $data = Input::all();
         User::Create(array('u_name' => $data['u_name'], 'regno' => $data['regno'], 'email' => $data['email'], 'gender' => $data['gender'], 'password' => Hash::make($data['password']), 'course' => $data['course'], 'nation' => $data['nation'], 'role' => $data['role']));
         //return Redirect::to('SignUp');
         return Redirect::to('SignUp')->with('success', 'Thanks Data is successful Send');
     } else {
         return Redirect::to('SignUp')->withErrors($validate);
     }
 }
コード例 #6
0
ファイル: RegisterPage.class.php プロジェクト: nicocode/Board
 public function __construct()
 {
     $this->Infos['Title'] = Language::Get('com.sbb.page.register');
     // If logged in, redirect to start page
     if (isset($_COOKIE['sbb_Token']) || Session::Read('UserID')) {
         header("Location: index.php");
     }
     $Message = '';
     if (isset($_POST['Register'])) {
         // Captcha doesn't work
         /*if($_POST['Captcha'] != $_SESSION['Captcha']) {
         			$message = '{lang=com.sbb.captcha.wrong}';
         		}
         		else*/
         if (Register::Check($_POST)) {
             User::Create($_POST['Username'], $_POST['Password'], $_POST['Email']);
             $Message = Language::Get('com.sbb.register.success');
         } else {
             $Message = '<b>' . Language::Get('com.sbb.error') . ':</b><ul><li>' . implode('</li><li>', Register::GetError()) . '</li></ul>';
         }
     }
     // Füllt die Variablen im TPL
     SBB::Template()->Assign(array('Message' => $Message, 'Page' => 'Register'));
 }
コード例 #7
0
<?php

require dirname(__FILE__) . '/../fx.php';
while (@ob_end_clean()) {
}
$skipping = true;
$page = 1;
while ($page !== false) {
    $followers = Twitter::GetFollowers('ta_follows', $page);
    foreach ($followers as $f) {
        $exists = User::Exists($f['screen_name']);
        if ($exists or $skipping) {
            continue;
        }
        $skipping = false;
        $user = Twitter::Follow($headers['x-twittersenderscreenname']);
        if (User::Create($f)) {
            echo $f['screen_name'] . " created\n";
            Twitter::Tweet('d ' . $f['screen_name'] . ' Welcome to Follows from TwitApps. Send your email address by direct message to @ta_follows to activate this service.');
        } else {
            echo 'Failed to create user for ' . $f['screen_name'] . ': ' . mysql_error() . "\n";
        }
    }
    if (count($followers) == 100) {
        $page++;
    } else {
        $page = false;
    }
}
コード例 #8
0
ファイル: register.php プロジェクト: KmServer/CumulusClips
    if (!empty($_POST['email']) && preg_match('/^[a-z0-9][a-z0-9\\._-]+@[a-z0-9][a-z0-9\\.-]+\\.[a-z0-9]{2,4}$/i', $_POST['email'])) {
        if (!User::Exist(array('email' => $_POST['email']))) {
            View::$vars->data['email'] = htmlspecialchars(trim($_POST['email']));
        } else {
            View::$vars->errors['email'] = Language::GetText('error_email_unavailable');
        }
    } else {
        View::$vars->errors['email'] = Language::GetText('error_email');
    }
    ### Create user if no errors were found
    if (empty(View::$vars->errors)) {
        View::$vars->data['confirm_code'] = User::CreateToken();
        View::$vars->data['status'] = 'new';
        View::$vars->data['password'] = md5(View::$vars->data['password']);
        Plugin::Trigger('register.before_create');
        User::Create(View::$vars->data);
        View::$vars->message = Language::GetText('success_registered');
        View::$vars->message_type = 'success';
        $replacements = array('confirm_code' => View::$vars->data['confirm_code'], 'host' => HOST, 'sitename' => $config->sitename);
        $mail = new Mail();
        $mail->LoadTemplate('welcome', $replacements);
        $mail->Send(View::$vars->data['email']);
        Plugin::Trigger('register.create');
        unset(View::$vars->data);
    } else {
        View::$vars->message = Language::GetText('errors_below');
        View::$vars->message .= '<br /><br /> - ' . implode('<br /> - ', View::$vars->errors);
        View::$vars->message_type = 'error';
    }
}
// Output Page
コード例 #9
0
ファイル: index.php プロジェクト: andrecosta/SoccerWars
        } elseif (!$captcha) {
            throw new Exception("Captcha was not provided", 400);
        } else {
            // Validate Captcha
            $recaptcha = new \ReCaptcha\ReCaptcha(GOOGLE_RECAPTCHA_PRIVATE_KEY);
            $verify = $recaptcha->verify($captcha, $app->request->getIp());
            if (!$verify->isSuccess()) {
                throw new Exception("Humanity not confirmed", 400);
            }
            // Create user
            $user = new User();
            $user->email = $email;
            $user->name = $name;
            $user->avatar = '';
            $password = $user->createRandomPassword(6);
            if ($user_id = $user->Create()) {
                // Send email
                $message = "Greetings {$name}!\n\nYour password:\n\n" . $password;
                if (!Mail::send($email, $name, "Account created", $message)) {
                    throw new Exception("Error sending email", 500);
                }
                $app->render_json(["id" => $user_id]);
                // Create the user token for the first time
                Token::Update($user_id);
            } else {
                throw new Exception("Something went wrong!", 500);
            }
        }
    }
});
/* Delete User
コード例 #10
0
Viewer::AddData("user_name", $user_name);
Viewer::AddData("user_email", $user_email);
if (!empty($user_name) && !empty($user_email) && !empty($_POST["user_password"]) && !empty($_POST["user_password2"])) {
    if ($_POST["user_password"] != $_POST["user_password2"]) {
        $error_message = I18n::L("Passwords mismatch.");
    } else {
        if (!Support::IsEMail($user_email)) {
            $error_message = I18n::L("Wrong E-mail address.");
        } else {
            if (User::FindUser($user_name)) {
                $error_message = I18n::L("Username &laquo;%s&raquo; is already taken, please find another username.", array($user_name));
            } else {
                if (User::FindUserByEmail($user_email)) {
                    $error_message = I18n::L("This email &laquo;%s&raquo; is already regesitered, please use another email.", array($user_email));
                } else {
                    $obj = User::Add(User::Create($user_name, $user_email, $_POST["user_password"]));
                    if ($obj->user_id) {
                        Session::StartUser($obj);
                        header("Location:" . PREFIX . "/dashboard/");
                        exit;
                    } else {
                        $error_message = I18n::L("Error while registring user.");
                    }
                    //todo: add some error log
                }
            }
        }
    }
} else {
    if (!empty($_POST["register"])) {
        $error_message = I18n::L("Please fill all required fields.");
コード例 #11
0
require_once "../Classes/User.class.php";
require_once "../Classes/VerifyEmail.class.php";
$user = new User();
$VEmail = new VerifyEmail();
if (isset($PARAMS['username']) && isset($PARAMS['password']) && isset($PARAMS['email'])) {
    $user->username = $PARAMS['username'];
    $user->Find();
    if (!$user->variables) {
        $VEmail->email = $PARAMS['email'];
        $VEmail->Find();
        if (!$VEmail->variables) {
            $user->username = $PARAMS['username'];
            $user->password = md5(base64_encode($PARAMS['password']));
            $user->create_date = date("Ymd");
            $user->email = $PARAMS['email'];
            $user->Create();
            $VEmail->email = $PARAMS['email'];
            $VEmail->code = getNewCode();
            $VEmail->username = $PARAMS['username'];
            $VEmail->Create();
            sendVerificationEmail($VEmail->email, $user->username, $VEmail->code);
            $datos = array("status" => "OK");
            print_r(json_encode($datos));
        } elseif (!$VEmail->verified) {
            $datos = array("status" => "inUseNotVerified");
            print_r(json_encode($datos));
        } else {
            $datos = array("status" => "emailInUse");
            print_r(json_encode($datos));
        }
    } else {
コード例 #12
0
ファイル: signup.php プロジェクト: ryanknu/Cuber
			header("Location: welcome.php");
	}
	catch( Exception $e )
	{
		View::Obj()->Exception($e);
	}
}
else
{
	try
	{
		
		if ( isset($_POST["user"]) )
		{
			if ( @$_POST["pass"] == @$_POST["pass2"] )
				User::Create($_POST);
		}
		
		if ( !Auth::Obj()->Authenticated() )
		{
			View::Obj()->Title("Cuber - Sign up!");
			View::Obj()->MainView("signup");
		}
		else
		{
			header("Location: welcome.php");
		}
	
	}
	catch( Exception $e )
	{
コード例 #13
0
ファイル: members_add.php プロジェクト: KmServer/CumulusClips
            $website = (empty($matches[1]) ? 'http://' : '') . $website;
            $data['website'] = htmlspecialchars(trim($website));
        } else {
            $errors['website'] = 'Invalid website';
        }
    }
    // Validate about me
    if (!empty($_POST['about_me']) && !ctype_space($_POST['about_me'])) {
        $data['about_me'] = htmlspecialchars(trim($_POST['about_me']));
    }
    ### Create user if no errors were found
    if (empty($errors)) {
        // Create user
        $data['password'] = md5($data['password']);
        $data['status'] = 'new';
        $id = User::Create($data);
        $user = new User($id);
        $user->Approve('create');
        unset($data);
        // Output message
        $message = 'Member has been added.';
        $message_type = 'success';
    } else {
        $message = 'The following errors were found. Please correct them and try again.';
        $message .= '<br /><br /> - ' . implode('<br /> - ', $errors);
        $message_type = 'error';
    }
}
// Output Header
include 'header.php';
?>
コード例 #14
0
ファイル: index.php プロジェクト: xander-mbaka/momentum
 public function createUser($empid, $uname, $pass, $role)
 {
     if (User::Create($empid, $uname, $pass, $role)) {
         echo 1;
     } else {
         echo 0;
     }
 }
コード例 #15
0
ファイル: load_test.php プロジェクト: utn-frm-si/booked
require_once ROOT_DIR . 'lib/Common/Helpers/namespace.php';
echo "<h1>Booked Scheduler Data Load</h1>";
$stopWatch = new StopWatch();
$stopWatch->Start();
$numberOfResources = 10;
$numberOfUsers = 1000;
$numberOfReservations = 5000;
$numberOfAccessories = 20;
$users = array();
$resources = array();
$db = ServiceLocator::GetDatabase();
// USERS
$db->Execute(new AdHocCommand("delete from users where fname ='load' and lname = 'test'"));
$userRepo = new UserRepository();
for ($i = 0; $i < $numberOfUsers; $i++) {
    $user = User::Create("load{$i}", "test{$i}", "email {$i}", "username {$i}", "en_us", "America/Chicago", "7b6aec38ff9b7650d64d0374194307bdde711425", "3b3dbb9b");
    $userId = $userRepo->Add($user);
    $users[] = $user;
}
echo "Loaded {$numberOfUsers} users<br/>";
// RESOURCES
$db->Execute(new AdHocCommand("delete from resources where name like 'load%'"));
$resourceRepo = new ResourceRepository();
for ($i = 0; $i < $numberOfResources; $i++) {
    $resource = BookableResource::CreateNew("load{$i}", 1);
    $resourceId = $resourceRepo->Add($resource);
    $resources[] = $resource;
}
echo "Loaded {$numberOfResources} resources<br/>";
// ACCESSORIES
$db->Execute(new AdHocCommand("delete from accessories where accessory_name like 'load%'"));
コード例 #16
0
ファイル: incoming_mail.php プロジェクト: ntulip/TwitApps
<?php

if (empty($info['headers']['x-twitteremailtype']) or empty($info['headers']['x-twittersendername']) or empty($info['headers']['x-twittersenderscreenname'])) {
    mail('*****@*****.**', 'TwitApps incoming mail: Missing header(s)', $body . "\n\n========================================\n\n" . $data, 'From: TwitApps <*****@*****.**>', '*****@*****.**');
} else {
    require dirname(__FILE__) . '/../fx.php';
    switch ($info['headers']['x-twitteremailtype']) {
        case 'is_following':
            // Note that we handle the case where we're already following a user and don't try to re-create them
            $user = Twitter::Follow($info['headers']['x-twittersenderscreenname']);
            if (isset($user['error']) and stripos($user['error'], 'already on your list') === false) {
                echo 'Follow failed for "' . $info['headers']['x-twittersenderscreenname'] . '": ' . $user['error'] . "\n";
            } elseif (stripos(@$user['error'], 'already on your list') !== false or User::Create(isset($user['screen_name']) ? $user : array('screen_name' => $info['headers']['x-twittersenderscreenname']))) {
                Twitter::Tweet('d ' . $info['headers']['x-twittersenderscreenname'] . ' Welcome to Follows from TwitApps. Send your email address by direct message to @' . $_twitter['username'] . ' to activate this service.');
            } else {
                echo 'Failed to create user "' . $info['headers']['x-twittersenderscreenname'] . '": ' . mysql_error(GetDB()) . "\n";
            }
            break;
        case 'direct_message':
            // Direct message should contain a command or an email address
            $email = false;
            foreach (preg_split('/\\s/', strtolower($body)) as $word) {
                switch ($word) {
                    case 'start':
                        //echo 'Start for "'.$info['headers']['x-twittersenderscreenname'].'"'."\n";
                        $user = Twitter::GetUserDetails($info['headers']['x-twittersenderscreenname']);
                        if ($user and User::SetStatus($info['headers']['x-twittersenderscreenname'], 'active', $user->status->id)) {
                            $dm = 'Sorted! I\'ll start sending you emails again shortly.';
                        } else {
                            $dm = 'Grrr, something went wrong restarting your emails. I\'ve notified the team and they\'ll look into it ASAP.';
                            echo '  Failed to start emails for "' . $info['headers']['x-twittersenderscreenname'] . '"' . "\n\n";
コード例 #17
0
ファイル: index.php プロジェクト: ritthai/LMS
                 break;
             }
             // Fallthrough
         // Fallthrough
         case 'firstname':
             // Fallthrough
         // Fallthrough
         case 'lastname':
             // Fallthrough
         // Fallthrough
         default:
             $filtered_params[$k] = $v;
     }
 }
 if ($authorized) {
     $id = User::Create($filtered_params);
 } else {
     $id = 0;
 }
 if ($id > 0) {
     Error::generate('notice', 'Account created!');
     User::Authenticate($params['name'], $params['password'], $error);
     if (isset($_SESSION) && $_SESSION['last_rendered_page']) {
         redirect_raw($_SESSION['last_rendered_page']);
     } else {
         redirect();
     }
 } else {
     Error::generate('notice', 'Account creation failed', Error::$FLAGS['single']);
     //redirect('create');
     include "{$ROOT}/user/views/create.view.php";
コード例 #18
0
ファイル: controller.php プロジェクト: mirzavu/clothfarm
if ($_GET['action'] == 'logout') {
    session_unset();
    session_destroy();
    session_start();
}
//////////////////////////////////////////////////////////////////
// Create User
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'create') {
    if (checkAccess()) {
        if (!isset($_POST['username']) || !isset($_POST['password'])) {
            die(formatJSEND("error", "Missing username or password"));
        }
        $User->username = User::CleanUsername($_POST['username']);
        $User->password = $_POST['password'];
        $User->Create();
    }
}
//////////////////////////////////////////////////////////////////
// Delete User
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'delete') {
    if (checkAccess()) {
        if (!isset($_GET['username'])) {
            die(formatJSEND("error", "Missing username"));
        }
        $User->username = $_GET['username'];
        $User->Delete();
    }
}
//////////////////////////////////////////////////////////////////
コード例 #19
0
 public function testSynchronizeRegistersNewUser()
 {
     $username = '******';
     $email = 'em';
     $fname = 'fn';
     $lname = 'ln';
     $phone = 'ph';
     $inst = 'or';
     $title = 'title';
     $langCode = 'en_US';
     $timezone = 'UTC';
     $groups = array(new UserGroup(1, 'group1'), new UserGroup(2, 'g2'));
     $encryptedPassword = $this->fakeEncryption->_Encrypted;
     $salt = $this->fakeEncryption->_Salt;
     $user = new AuthenticatedUser($username, $email, $fname, $lname, 'password', $langCode, $timezone, $phone, $inst, $title, $groups);
     $expectedUser = User::Create($fname, $lname, $email, $username, $langCode, $timezone, $encryptedPassword, $salt, Pages::DEFAULT_HOMEPAGE_ID);
     $expectedUser->ChangeAttributes($phone, $inst, $title);
     $expectedUser->WithGroups($groups);
     $this->userRepository->expects($this->once())->method('UserExists')->with($this->equalTo($email), $this->equalTo($username))->will($this->returnValue(null));
     $this->userRepository->expects($this->once())->method('Add')->with($this->equalTo($expectedUser));
     $this->registration->Synchronize($user);
 }
コード例 #20
0
ファイル: user_actions.php プロジェクト: rajibahmed/IIMS
<?php

require_once '../../lib/defination.class.php';
require_once "../../lib/user.class.php";
$user = new User();
$fields = array('login', 'password', 'name', 'email', 'address', 'contact', 'section', 'department', 'office', 'designation', 'role', 'visible', 'level');
$errors = array();
#print_r($_POST);
$getData = "'null',";
//for the primary key
foreach ($fields as $field) {
    if ($field == 'password') {
        $getData .= "'" . md5($_POST[$field]) . "',";
    } else {
        $getData .= "'" . mysql_insertion_check($_POST[$field]) . "',";
    }
}
$getData .= 'NOW(),NOW()';
//mysql now() is for created_at and updted_at
#echo $getData;
$user->Create($getData);
//Inserts the company info
echo "Data Saved Successfully ";
include '../contents/create_user.php';
コード例 #21
0
ファイル: register.php プロジェクト: hyrmedia/pligg-cms
function register_add_user($username, $email, $password, $password2, $user_language)
{
    global $current_user;
    $user = new User();
    $user->user_language = $user_language;
    $user->username = $username;
    $user->pass = $password;
    $user->email = $email;
    if ($user->Create()) {
        $user->read('short');
        $registration_details = array('user_language' => $user_language, 'username' => $username, 'password' => $password, 'email' => $email, 'id' => $user->id);
        check_actions('register_success_pre_redirect', $registration_details);
        $current_user->Authenticate($username, $password, false);
        if ($registration_details['redirect']) {
            header('Location: ' . $registration_details['redirect']);
        } elseif (pligg_validate()) {
            header('Location: ' . my_base_url . my_pligg_base . '/register_complete.php?user='******'Location: ' . getmyurl('user', $username));
        }
        die;
    }
}
コード例 #22
0
ファイル: check_email.php プロジェクト: ntulip/TwitApps
         case 'x-twittersendername':
         case 'x-twittersenderscreenname':
             $headers[$key] = $val;
             break;
     }
 }
 if (!empty($headers['x-twitteremailtype']) and !empty($headers['x-twittersendername']) and !empty($header['x-twittersenderscreenname'])) {
     // Mark it as seen now to minimise the possibility of clashes
     $processed++;
     switch ($headers['x-twitteremailtype']) {
         case 'is_following':
             // Note that we handle the case where we're already following a user and don't try to re-create them
             $user = Twitter::Follow($headers['x-twittersenderscreenname']);
             if (isset($user['error']) and stripos($user['error'], 'already on your list') === false) {
                 echo 'Follow failed for "' . $headers['x-twittersenderscreenname'] . '": ' . $user['error'] . "\n";
             } elseif (stripos(@$user['error'], 'already on your list') !== false or User::Create($user)) {
                 Twitter::Tweet('d ' . $headers['x-twittersenderscreenname'] . ' Welcome to Replies from TwitApps. Send your email address by direct message to @' . $_twitter['username'] . ' to activate this service.');
             } else {
                 echo 'Failed to create user "' . $headers['x-twittersenderscreenname'] . '": ' . mysql_error(GetDB()) . "\n";
             }
             break;
         case 'direct_message':
             // Direct message should contain a command or an email address
             $body = imap_body($mbox, $msgid, FT_PEEK);
             $email = false;
             foreach (preg_split('/\\s/', strtolower($body)) as $word) {
                 switch ($word) {
                     case 'start':
                         //echo 'Start for "'.$headers['x-twittersenderscreenname'].'"'."\n";
                         $user = Twitter::GetUserDetails($headers['x-twittersenderscreenname']);
                         if ($user and User::SetStatus($headers['x-twittersenderscreenname'], 'active', $user->status->id)) {
コード例 #23
0
 public function testAddsUser()
 {
     $expectedId = 999;
     $firstName = 'f';
     $lastName = 'l';
     $emailAddress = 'e';
     $userName = '******';
     $language = 'la';
     $timezone = 't';
     $password = '******';
     $passwordSalt = 'ps';
     $phone = 'ph';
     $organization = 'o';
     $position = 'po';
     $scheduleId = 123232;
     $attr1 = new AttributeValue(3, 'value');
     $attr2 = new AttributeValue(4, 'value');
     $user = User::Create($firstName, $lastName, $emailAddress, $userName, $language, $timezone, $password, $passwordSalt);
     $user->ChangeAttributes($phone, $organization, $position);
     $user->ChangeCustomAttributes(array($attr1, $attr2));
     $user->ChangeEmailPreference(new ReservationApprovedEvent(), true);
     $user->EnablePublicProfile();
     $user->ChangeDefaultSchedule($scheduleId);
     $publicId = $user->GetPublicId();
     $this->db->_ExpectedInsertId = $expectedId;
     $repo = new UserRepository();
     $newId = $repo->Add($user);
     $command = new RegisterUserCommand($userName, $emailAddress, $firstName, $lastName, $password, $passwordSalt, $timezone, $language, Pages::DEFAULT_HOMEPAGE_ID, $phone, $organization, $position, AccountStatus::ACTIVE, $publicId, $scheduleId);
     $addAttr1Command = new AddAttributeValueCommand($attr1->AttributeId, $attr1->Value, $expectedId, CustomAttributeCategory::USER);
     $addAttr2Command = new AddAttributeValueCommand($attr2->AttributeId, $attr2->Value, $expectedId, CustomAttributeCategory::USER);
     $addEmailPreferenceCommand = new AddEmailPreferenceCommand($expectedId, EventCategory::Reservation, ReservationEvent::Approved);
     $this->assertTrue($this->db->ContainsCommand($command));
     $this->assertTrue($this->db->ContainsCommand($addAttr1Command));
     $this->assertTrue($this->db->ContainsCommand($addAttr2Command));
     $this->assertTrue($this->db->ContainsCommand($addEmailPreferenceCommand));
     $this->assertEquals($expectedId, $newId);
     $this->assertEquals($expectedId, $user->Id());
 }