本文整理汇总了PHP中Tinebase_User::createInitialAccounts方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_User::createInitialAccounts方法的具体用法?PHP Tinebase_User::createInitialAccounts怎么用?PHP Tinebase_User::createInitialAccounts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_User
的用法示例。
在下文中一共展示了Tinebase_User::createInitialAccounts方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _initialize
/**
* Override method: Setup needs additional initialisation
*
* @see tine20/Setup/Setup_Initialize#_initialize($_application)
*/
protected function _initialize(Tinebase_Model_Application $_application, $_options = null)
{
parent::_initialize($_application, $_options);
$initialAdminUserOptions = $this->_parseInitialAdminUserOptions($_options);
if (Tinebase_User::getInstance() instanceof Tinebase_User_Interface_SyncAble) {
Tinebase_User::syncUsers(true);
} else {
Tinebase_User::createInitialAccounts($initialAdminUserOptions);
}
// set current user
$initialUser = Tinebase_User::getInstance()->getUserByProperty('accountLoginName', $initialAdminUserOptions['adminLoginName']);
Tinebase_Core::set(Tinebase_Core::USER, $initialUser);
parent::_initialize($_application, $_options);
}
示例2: _initialize
/**
* Override method: Setup needs additional initialisation
*
* @see tine20/Setup/Setup_Initialize#_initialize($_application)
*/
protected function _initialize(Tinebase_Model_Application $_application, $_options = null)
{
$initialAdminUserOptions = $this->_parseInitialAdminUserOptions($_options);
if (Tinebase_User::getInstance() instanceof Tinebase_User_Interface_SyncAble) {
Tinebase_User::syncUsers(array('syncContactData' => TRUE));
}
try {
$initialUser = Tinebase_User::getInstance()->getUserByProperty('accountLoginName', $initialAdminUserOptions['adminLoginName']);
} catch (Tinebase_Exception_NotFound $tenf) {
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . ' Could not find initial admin account in user backend. Creating new one ...');
}
Tinebase_User::createInitialAccounts($initialAdminUserOptions);
$initialUser = Tinebase_User::getInstance()->getUserByProperty('accountLoginName', $initialAdminUserOptions['adminLoginName']);
}
Tinebase_Core::set(Tinebase_Core::USER, $initialUser);
parent::_initialize($_application, $_options);
}
示例3: _createAdminUser
/**
* create admin user / activate existing user / allow to reset password
*
* @param Zend_Console_Getopt $_opts
*
* @todo check role by rights and not by name
* @todo replace echos with stdout logger
*/
protected function _createAdminUser(Zend_Console_Getopt $_opts)
{
if (!Setup_Controller::getInstance()->isInstalled('Tinebase')) {
die('Install Tinebase first.');
}
echo "Please enter a username. If the user already exists, he is reactivated and you can reset the password.\n";
$username = strtolower(Tinebase_Server_Cli::promptInput('Username'));
$tomorrow = Tinebase_DateTime::now()->addDay(1);
try {
$user = Tinebase_User::getInstance()->getFullUserByLoginName($username);
echo "User {$username} already exists.\n";
Tinebase_User::getInstance()->setStatus($user->getId(), Tinebase_Model_User::ACCOUNT_STATUS_ENABLED);
echo "Activated admin user '{$username}'.\n";
$expire = Tinebase_Server_Cli::promptInput('Should the admin user expire tomorrow (default: "no", "y" or "yes" for expiry)?');
if ($expire === 'y' or $expire === 'yes') {
Tinebase_User::getInstance()->setExpiryDate($user->getId(), $tomorrow);
echo "User expires tomorrow at {$tomorrow}.\n";
}
$resetPw = Tinebase_Server_Cli::promptInput('Do you want to reset the password (default: "no", "y" or "yes" for reset)?');
if ($resetPw === 'y' or $resetPw === 'yes') {
$password = $this->_promptPassword();
Tinebase_User::getInstance()->setPassword($user, $password);
echo "User password has been reset.\n";
}
$this->_checkAdminGroupMembership($user);
$this->_checkAdminRole($user);
} catch (Tinebase_Exception_NotFound $tenf) {
// create new admin user that expires tomorrow
$password = $this->_promptPassword();
Tinebase_User::createInitialAccounts(array('adminLoginName' => $username, 'adminPassword' => $password, 'expires' => $tomorrow));
echo "Created new admin user '{$username}' that expires tomorrow.\n";
}
}
示例4: _createAdminUser
/**
* create admin user / activate existing user / allow to reset password
*
* @param Zend_Console_Getopt $_opts
*/
protected function _createAdminUser(Zend_Console_Getopt $_opts)
{
if (!Setup_Controller::getInstance()->isInstalled('Tinebase')) {
die('Install Tinebase first.');
}
echo "Please enter a username. If the user already exists, he is reactivated and you can reset the password.\n";
$username = Tinebase_Server_Cli::promptInput('Username');
$tomorrow = Tinebase_DateTime::now()->addDay(1);
try {
$user = Tinebase_User::getInstance()->getFullUserByLoginName($username);
echo "User {$username} already exists.\n";
$user->accountExpires = $tomorrow;
$user->accountStatus = Tinebase_Model_User::ACCOUNT_STATUS_ENABLED;
Tinebase_User::getInstance()->updateUser($user);
echo "Activated admin user '{$username}' (expires tomorrow).\n";
$resetPw = Tinebase_Server_Cli::promptInput('Do you want to reset the password (default: "no", "y" or "yes" for reset)?');
if ($resetPw === 'y' or $resetPw === 'yes') {
$password = $this->_promptPassword();
Tinebase_User::getInstance()->setPassword($user, $password);
echo "User password has been reset.\n";
}
// check admin group membership
$adminGroup = Tinebase_Group::getInstance()->getDefaultAdminGroup();
$memberships = Tinebase_Group::getInstance()->getGroupMemberships($user);
if (!in_array($adminGroup->getId(), $memberships)) {
try {
Tinebase_Group::getInstance()->addGroupMember($adminGroup, $user);
echo "Added user to default admin group\n";
} catch (Zend_Ldap_Exception $zle) {
echo "Could not add user to default admin group: " . $zle->getMessage();
}
}
} catch (Tinebase_Exception_NotFound $tenf) {
if (Tinebase_User::getConfiguredBackend() === Tinebase_User::LDAP) {
die('It is not possible to create a new user with LDAP user backend here.');
}
// create new admin user that expires tomorrow
$password = $this->_promptPassword();
Tinebase_User::createInitialAccounts(array('adminLoginName' => $username, 'adminPassword' => $password, 'expires' => $tomorrow));
echo "Created new admin user '{$username}' that expires tomorrow.\n";
}
}