本文整理汇总了PHP中Tinebase_User::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_User::getInstance方法的具体用法?PHP Tinebase_User::getInstance怎么用?PHP Tinebase_User::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_User
的用法示例。
在下文中一共展示了Tinebase_User::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toArray
/**
* returns array with the filter settings of this filter
*
* @param bool $_valueToJson resolve value for json api?
* @return array
*/
public function toArray($_valueToJson = false)
{
$result = parent::toArray($_valueToJson);
if ($this->_userOperator && $this->_userOperator == 'inGroup') {
$result['operator'] = $this->_userOperator;
$result['value'] = $this->_userValue;
}
if ($_valueToJson == true) {
if ($this->_userOperator && $this->_userOperator == 'inGroup' && $this->_userValue) {
$result['value'] = Tinebase_Group::getInstance()->getGroupById($this->_userValue)->toArray();
} else {
switch ($this->_operator) {
case 'equals':
$result['value'] = $result['value'] ? Tinebase_User::getInstance()->getUserById($this->_value)->toArray() : $result['value'];
break;
case 'in':
$result['value'] = array();
foreach ($this->_value as $userId) {
$result['value'][] = Tinebase_User::getInstance()->getUserById($userId)->toArray();
}
break;
default:
break;
}
}
}
return $result;
}
示例2: update_1
/**
* update function (-> 3.2)
* - check all users with 'userEmailAccount' and update their accounts / preferences
*/
public function update_1()
{
// update account types for users with userEmailAccount preference
$imapConfig = Tinebase_Config::getInstance()->getConfigAsArray(Tinebase_Config::IMAP);
if (array_key_exists('host', $imapConfig)) {
$accounts = Felamimail_Controller_Account::getInstance()->getAll();
$accountBackend = new Felamimail_Backend_Account();
foreach ($accounts as $account) {
try {
if (Tinebase_Core::getPreference('Felamimail')->getValueForUser('userEmailAccount', $account->user_id)) {
$user = Tinebase_User::getInstance()->getFullUserById($account->user_id);
// account email == user->emailAddress && account->host == system account host -> type = system
if ($account->email == $user->accountEmailAddress && $account->host == $imapConfig['host']) {
$account->type = Felamimail_Model_Account::TYPE_SYSTEM;
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Switching to system account: ' . $account->name);
$accountBackend->update($account);
}
}
} catch (Exception $e) {
// do nothing
}
}
}
// rename preference
$this->_db->query('UPDATE ' . SQL_TABLE_PREFIX . "preferences SET name = 'useSystemAccount' WHERE name = 'userEmailAccount'");
$this->setApplicationVersion('Felamimail', '3.2');
}
示例3: resetSyncForUser
/**
* reset sync for user
*
* @param mixed $user
* @param array|string $classesToReset
* @return boolean
*/
public function resetSyncForUser($user, $classesToReset)
{
if (is_string($classesToReset)) {
$classesToReset = array($classesToReset);
}
if (!$user instanceof Tinebase_Model_User) {
try {
$user = Tinebase_User::getInstance()->getFullUserById($user);
} catch (Tinebase_Exception_NotFound $tenf) {
$user = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountLoginName', $user);
}
}
if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Resetting sync for user ' . $user->accountDisplayName . ' collections: ' . print_r($classesToReset, true));
}
self::initSyncrotonRegistry();
$devices = $this->_getDevicesForUser($user->getId());
foreach ($devices as $device) {
if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Resetting device' . $device->friendlyname . ' / id: ' . $device->getId());
}
foreach ($classesToReset as $class) {
$folderToReset = $this->_getFoldersForDeviceAndClass($device, $class);
if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Resetting ' . count($folderToReset) . ' folder(s) for class ' . $class);
}
foreach ($folderToReset as $folderState) {
Syncroton_Registry::getSyncStateBackend()->resetState($device->getId(), $folderState->id);
}
}
}
return true;
}
示例4: createPersonalFolder
/**
* creates the initial folder for new accounts
*
* @param mixed[int|Tinebase_Model_User] $_account the accountd object
* @return Tinebase_Record_RecordSet of subtype Tinebase_Model_Container
*/
public function createPersonalFolder($_accountId)
{
$translation = Tinebase_Translation::getTranslation('ExampleApplication');
$account = Tinebase_User::getInstance()->getUserById($_accountId);
$newContainer = new Tinebase_Model_Container(array('name' => sprintf($translation->_("%s's personal example records"), $account->accountFullName), 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'owner_id' => $_accountId, 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('ExampleApplication')->getId()));
$personalContainer = Tinebase_Container::getInstance()->addContainer($newContainer);
$container = new Tinebase_Record_RecordSet('Tinebase_Model_Container', array($personalContainer));
return $container;
}
示例5: createPersonalFolder
/**
* creates the initial folder for new accounts
*
* @param mixed[int|Tinebase_Model_User] $_account the accountd object
* @return Tinebase_Record_RecordSet of subtype Tinebase_Model_Container
*/
public function createPersonalFolder($_account)
{
$translation = Tinebase_Translation::getTranslation($this->_applicationName);
$account = Tinebase_User::getInstance()->getUserById($_account);
$newContainer = new Tinebase_Model_Container(array('name' => sprintf($translation->_("%s's personal Projects"), $account->accountFullName), 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'owner_id' => $account->getId(), 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName($this->_applicationName)->getId(), 'model' => static::$_defaultModel));
$personalContainer = Tinebase_Container::getInstance()->addContainer($newContainer);
$container = new Tinebase_Record_RecordSet('Tinebase_Model_Container', array($personalContainer));
return $container;
}
示例6: _initializeUserContacts
/**
* init/create user contacts
*/
protected function _initializeUserContacts()
{
foreach (Tinebase_User::getInstance()->getFullUsers() as $fullUser) {
$fullUser->container_id = $this->_getInternalAddressbook()->getId();
$contact = Admin_Controller_User::getInstance()->createOrUpdateContact($fullUser);
$fullUser->contact_id = $contact->getId();
Tinebase_User::getInstance()->updateUser($fullUser);
}
}
示例7: setUp
/**
* Sets up the fixture.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
$this->_backend = Tinebase_User::getInstance();
if (!array_key_exists('Tinebase_EmailUser_Imap_Cyrus', $this->_backend->getPlugins())) {
$this->markTestSkipped('Cyrus IMAP plugin not enabled');
}
$this->_config = Tinebase_Config::getInstance()->getConfigAsArray(Tinebase_Config::IMAP);
$this->objects['users'] = array();
}
示例8: setUp
/**
* Sets up the fixture.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
$this->_backend = Tinebase_User::getInstance();
if (!array_key_exists('Tinebase_EmailUser_Imap_Dbmail', $this->_backend->getPlugins())) {
$this->markTestSkipped('Dbmail MySQL plugin not enabled');
}
$this->_config = Tinebase_Config::getInstance()->get(Tinebase_Config::IMAP, new Tinebase_Config_Struct())->toArray();
$this->objects['users'] = array();
}
示例9: _setCredentials
/**
* set new password & credentials
*
* @param string $_username
* @param string $_password
*/
protected function _setCredentials($_username, $_password)
{
Tinebase_User::getInstance()->setPassword(Tinebase_Core::getUser(), $_password, true, false);
$oldCredentialCache = Tinebase_Core::get(Tinebase_Core::USERCREDENTIALCACHE);
// update credential cache
$credentialCache = Tinebase_Auth_CredentialCache::getInstance()->cacheCredentials($_username, $_password);
Tinebase_Core::set(Tinebase_Core::USERCREDENTIALCACHE, $credentialCache);
$event = new Tinebase_Event_User_ChangeCredentialCache($oldCredentialCache);
Tinebase_Event::fireEvent($event);
}
示例10: validate
/**
* validate if user is allowed to use the software in maintenance mode
*
* @return bool
*/
public function validate()
{
if (Tinebase_Core::inMaintenanceMode()) {
$currentAccount = Tinebase_User::getInstance()->getFullUserById($this->getValidData());
if (!$currentAccount->hasRight('Tinebase', Tinebase_Acl_Rights::MAINTENANCE)) {
return false;
}
}
return true;
}
示例11: _importRecord
/**
* import single record (create password if in data)
*
* @param Tinebase_Record_Abstract $_record
* @param string $_resolveStrategy
* @param array $_recordData
* @return Tinebase_Record_Interface
* @throws Tinebase_Exception_Record_Validation
*/
protected function _importRecord($_record, $_resolveStrategy = NULL, $_recordData = array())
{
if ($_record instanceof Tinebase_Model_FullUser && $this->_controller instanceof Admin_Controller_User) {
$record = $_record;
// create valid login name
if (!isset($record->accountLoginName)) {
$record->accountLoginName = Tinebase_User::getInstance()->generateUserName($record, $this->_options['userNameSchema']);
}
// add prefix to login name if given
if (!empty($this->_options['accountLoginNamePrefix'])) {
$record->accountLoginName = $this->_options['accountLoginNamePrefix'] . $record->accountLoginName;
}
// add home dir if empty and prefix is given (append login name)
if (empty($record->accountHomeDirectory) && !empty($this->_options['accountHomeDirectoryPrefix'])) {
$record->accountHomeDirectory = $this->_options['accountHomeDirectoryPrefix'] . $record->accountLoginName;
}
// create email address if accountEmailDomain if given
if (empty($record->accountEmailAddress) && !empty($this->_options['accountEmailDomain'])) {
$record->accountEmailAddress = $record->accountLoginName . '@' . $this->_options['accountEmailDomain'];
}
if (!empty($this->_options['samba'])) {
$this->_addSambaSettings($record);
}
Tinebase_Event::fireEvent(new Admin_Event_BeforeImportUser($record, $this->_options));
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($record->toArray(), true));
}
// generate passwd (use accountLoginName or password from options or password from csv in this order)
$password = $record->accountLoginName;
if (!empty($this->_options['password'])) {
$password = $this->_options['password'];
}
if (isset($_recordData['password']) && !empty($_recordData['password'])) {
$password = $_recordData['password'];
}
$this->_addEmailUser($record, $password);
//if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Adding record: ' . print_r($record->toArray(), TRUE));
// try to create record with password
if ($record->isValid()) {
if (!$this->_options['dryrun']) {
$record = $this->_controller->create($record, $password, $password);
} else {
$this->_importResult['results']->addRecord($record);
}
$this->_importResult['totalcount']++;
} else {
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Record invalid: ' . print_r($record->getValidationErrors(), TRUE));
throw new Tinebase_Exception_Record_Validation('Imported record is invalid.');
}
} else {
$record = parent::_importRecord($_record, $_resolveStrategy, $_recordData);
}
return $record;
}
示例12: setUp
/**
* Sets up the fixture.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
if (Tinebase_User::getConfiguredBackend() !== Tinebase_User::LDAP) {
$this->markTestSkipped('LDAP backend not enabled');
}
$this->_backend = Tinebase_User::getInstance();
if (!array_key_exists('Tinebase_EmailUser_Smtp_LdapMailSchema', $this->_backend->getPlugins())) {
$this->markTestSkipped('Mail LDAP plugin not enabled');
}
$this->objects['users'] = array();
}
示例13: setUp
/**
* Sets up the fixture.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
$this->_backend = Tinebase_User::getInstance();
if (!array_key_exists('Tinebase_EmailUser_Smtp_Postfix', $this->_backend->getPlugins())) {
$this->markTestSkipped('Postfix SQL plugin not enabled');
}
$this->objects['users'] = array();
$config = TestServer::getInstance()->getConfig();
if ($config->maildomain) {
$this->_mailDomain = $config->maildomain;
}
}
示例14: appendDependentRecords
protected function appendDependentRecords($record)
{
Tinebase_User::getInstance()->resolveUsers($record, 'created_by');
Tinebase_User::getInstance()->resolveUsers($record, 'last_modified_by');
//Tinebase_User::getInstance()->resolveMultipleUsers($_records, 'account_id', true);
if ($record->__get('order_id')) {
$this->appendForeignRecordToRecord($record, 'order_id', 'order_id', 'id', new Billing_Backend_Order());
$order = $record->__get('order_id');
try {
if ($order instanceof Billing_Model_Order) {
$debitorId = $order->__get('debitor_id');
} else {
$debitorId = $order->debitor_id;
}
$debitor = Billing_Controller_Debitor::getInstance()->get($debitorId);
if ($order instanceof Billing_Model_Order) {
$order->__set('debitor_id', $debitor->toArray());
} else {
$order->debitor_id = $debitor->toArray();
}
} catch (Exception $e) {
}
$record->__set('order_id', $order);
}
if ($record->__get('booking_id')) {
$this->appendForeignRecordToRecord($record, 'booking_id', 'booking_id', 'id', new Billing_Backend_Booking());
}
if ($record->__get('payment_method_id')) {
$this->appendForeignRecordToRecord($record, 'payment_method_id', 'payment_method_id', 'id', new Billing_Backend_PaymentMethod());
}
if ($record->__get('fee_group_id')) {
$this->appendForeignRecordToRecord($record, 'fee_group_id', 'fee_group_id', 'id', new Membership_Backend_FeeGroup());
}
// $rBackend = new Billing_Backend_ReceiptPosition();
// $receiptPositions = $rBackend->getByReceiptId($record->getId());
// $sumNetto = 0;
// $sumBrutto = 0;
// $count = 0;
// $totalWeight = 0;
// foreach($receiptPositions as $pos){
// $netto = $pos->__get('total_netto');
// $brutto = $pos->__get('total_brutto');
// $weight = $pos->__get('total_weight');
// $sumNetto += $netto;
// $sumBrutto += $brutto;
// $totalWeight += $weight;
// $count++;
// }
// $record->__set('total_netto', $sumNetto);
// $record->__set('total_brutto', $sumBrutto);
// $record->__set('pos_count', $count);
// $record->__set('total_weight', $totalWeight);
}
示例15: testInstallAdminAccountOptions
/**
* testInstallAdminAccountOptions
*/
public function testInstallAdminAccountOptions()
{
$this->_uninstallAllApplications();
$this->_uit->installApplications(array('Tinebase'), array('adminLoginName' => 'phpunit-admin', 'adminPassword' => 'phpunit-password'));
$adminUser = Tinebase_User::getInstance()->getFullUserByLoginName('phpunit-admin');
$this->assertTrue($adminUser instanceof Tinebase_Model_User);
$this->assertNull(Tinebase_Auth::getBackendConfiguration('adminLoginName'));
$this->assertNull(Tinebase_Auth::getBackendConfiguration('adminPassword'));
$this->assertNull(Tinebase_Auth::getBackendConfiguration('adminConfirmation'));
// cleanup
$this->_uninstallAllApplications();
}