本文整理汇总了PHP中Tinebase_User类的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_User类的具体用法?PHP Tinebase_User怎么用?PHP Tinebase_User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tinebase_User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _setFromJson
/**
* fill record from json data
*
* @param array &$data
* @return void
*/
protected function _setFromJson(array &$data)
{
/************* add new relations *******************/
if (isset($data['relations'])) {
foreach ((array) $data['relations'] as $key => $relation) {
if (!isset($relation['id'])) {
$relationData = array('own_model' => 'Sales_Model_Contract', 'own_backend' => 'Sql', 'own_id' => isset($data['id']) ? $data['id'] : 0, 'own_degree' => Tinebase_Model_Relation::DEGREE_SIBLING, 'type' => $relation['type'], 'related_record' => isset($relation['related_record']) ? $relation['related_record'] : array(), 'related_id' => isset($relation['related_id']) ? $relation['related_id'] : NULL);
switch ($relation['type']) {
case self::RELATION_TYPE_ACCOUNT:
$relationData['related_model'] = 'Tinebase_Model_User';
$relationData['related_backend'] = Tinebase_User::getConfiguredBackend();
break;
case self::RELATION_TYPE_CUSTOMER:
$relationData['related_model'] = 'Addressbook_Model_Contact';
$relationData['related_backend'] = Addressbook_Backend_Factory::SQL;
break;
default:
throw new Sales_Exception_UnexpectedValue('Relation type not supported.');
}
// sanitize container id
if (isset($relation['related_record']['container_id']) && is_array($relation['related_record']['container_id'])) {
$data['related_record']['container_id'] = $relation['related_record']['container_id']['id'];
}
$data['relations'][$key] = $relationData;
}
}
}
}
示例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: 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;
}
示例4: 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;
}
示例5: testEmailsToAttendeeWithGroups
/**
* @return void
*/
public function testEmailsToAttendeeWithGroups()
{
if (Tinebase_User::getConfiguredBackend() === Tinebase_User::LDAP || Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
$this->markTestSkipped('FIXME: Does not work with LDAP/AD backend');
}
$event = $this->_getEvent();
$persistentEvent = Calendar_Controller_Event::getInstance()->create($event);
$primaryGroup = Tinebase_Group::getInstance()->getGroupById(Tinebase_Core::getUser()->accountPrimaryGroup);
$newAttendees = array(array('userType' => Calendar_Model_Attender::USERTYPE_USER, 'firstName' => $this->_originalTestUser->accountFirstName, 'lastName' => $this->_originalTestUser->accountLastName, 'partStat' => Calendar_Model_Attender::STATUS_TENTATIVE, 'role' => Calendar_Model_Attender::ROLE_REQUIRED, 'email' => $this->_originalTestUser->accountEmailAddress), array('userType' => Calendar_Model_Attender::USERTYPE_GROUP, 'displayName' => $primaryGroup->name, 'partStat' => Calendar_Model_Attender::STATUS_NEEDSACTION, 'role' => Calendar_Model_Attender::ROLE_REQUIRED, 'email' => 'foobar@example.org'));
Calendar_Model_Attender::emailsToAttendee($persistentEvent, $newAttendees, TRUE);
$persistentEvent = Calendar_Controller_Event::getInstance()->update($persistentEvent);
$attendees = clone $persistentEvent->attendee;
Calendar_Model_Attender::resolveAttendee($attendees);
$newAttendees = array();
foreach ($attendees as $attendee) {
$newAttendees[] = array('userType' => $attendee->user_type == 'group' ? Calendar_Model_Attender::USERTYPE_GROUP : Calendar_Model_Attender::USERTYPE_USER, 'partStat' => Calendar_Model_Attender::STATUS_TENTATIVE, 'role' => Calendar_Model_Attender::ROLE_REQUIRED, 'email' => $attendee->user_type == 'group' ? $attendee->user_id->getId() : $attendee->user_id->email, 'displayName' => $attendee->user_type == 'group' ? $attendee->user_id->name : $attendee->user_id->n_fileas);
}
Calendar_Model_Attender::emailsToAttendee($persistentEvent, $newAttendees, TRUE);
$persistentEvent = Calendar_Controller_Event::getInstance()->update($persistentEvent);
// print_r($persistentEvent->attendee->toArray());
// there must be more than 2 attendees the user, the group + the groupmembers
$this->assertGreaterThan(2, count($persistentEvent->attendee));
// current account must not be a groupmember
$this->assertFalse(!!Calendar_Model_Attender::getAttendee($persistentEvent->attendee, new Calendar_Model_Attender(array('user_type' => Calendar_Model_Attender::USERTYPE_GROUPMEMBER, 'user_id' => $this->_originalTestUser->contact_id))), 'found user as groupmember');
$this->assertEquals(Calendar_Model_Attender::STATUS_TENTATIVE, Calendar_Model_Attender::getOwnAttender($persistentEvent->attendee)->status);
}
示例6: update_0
/**
* update to 6.1
* - changepw config option has moved
*/
public function update_0()
{
$changepwSetting = Tinebase_User::getBackendConfiguration('changepw', TRUE);
if (!$changepwSetting) {
Tinebase_Config::getInstance()->set(Tinebase_Config::PASSWORD_CHANGE, FALSE);
}
$this->setApplicationVersion('Tinebase', '6.1');
}
示例7: 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::SQL) {
$this->markTestSkipped('SQL backend not enabled');
}
$this->_backend = Tinebase_User::factory(Tinebase_User::SQL);
parent::setUp();
}
示例8: setUp
/**
* Sets up the fixture.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
$this->_groupLDAP = Tinebase_Group::factory(Tinebase_Group::LDAP);
$this->_userLDAP = Tinebase_User::factory(Tinebase_User::LDAP);
$this->_groupSQL = Tinebase_Group::factory(Tinebase_Group::SQL);
$this->objects['initialGroup'] = new Tinebase_Model_Group(array('name' => 'tine20phpunit', 'description' => 'initial group'));
$this->objects['updatedGroup'] = new Tinebase_Model_Group(array('name' => 'tine20phpunit updated', 'description' => 'updated group'));
$this->objects['initialAccount'] = new Tinebase_Model_FullUser(array('accountLoginName' => 'tine20phpunit', 'accountStatus' => 'enabled', 'accountExpires' => NULL, 'accountPrimaryGroup' => 'must be set to valid groupid', 'accountLastName' => 'Tine 2.0', 'accountFirstName' => 'PHPUnit', 'accountEmailAddress' => 'phpunit@metaways.de'));
}
示例9: 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;
}
示例10: 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::ACTIVEDIRECTORY) {
// account email addresses are empty with AD backend
$this->markTestSkipped('skipped for ad backend');
}
Calendar_Controller_Event::getInstance()->sendNotifications(false);
Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
}
示例11: _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);
}
}
示例12: 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();
}
示例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_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();
}
示例14: 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;
}
示例15: 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;
}