コード例 #1
0
 /**
  * create new file node
  * 
  * @param string $_parentId
  * @param string $_name
  * @throws Tinebase_Exception_InvalidArgument
  * @return Tinebase_Model_Tree_Node
  */
 public function createFileTreeNode($_parentId, $_name)
 {
     $parentId = $_parentId instanceof Tinebase_Model_Tree_Node ? $_parentId->getId() : $_parentId;
     $fileObject = new Tinebase_Model_Tree_FileObject(array('type' => Tinebase_Model_Tree_FileObject::TYPE_FILE, 'contentytype' => null));
     Tinebase_Timemachine_ModificationLog::setRecordMetaData($fileObject, 'create');
     $fileObject = $this->_fileObjectBackend->create($fileObject);
     $treeNode = new Tinebase_Model_Tree_Node(array('name' => $_name, 'object_id' => $fileObject->getId(), 'parent_id' => $parentId));
     $treeNode = $this->_treeNodeBackend->create($treeNode);
     return $treeNode;
 }
コード例 #2
0
 /**
  * create initial admin account
  * 
  * Method is called during Setup Initialization
  *
  * $_options may contain the following keys:
  * <code>
  * $options = array(
  *  'adminLoginName'    => 'admin',
  *  'adminPassword'     => 'lars',
  *  'adminFirstName'    => 'Tine 2.0',
  *  'adminLastName'     => 'Admin Account',
  *  'adminEmailAddress' => '*****@*****.**',
  *  'expires'            => Tinebase_DateTime object
  * );
  * </code>
  *
  * @param array $_options [hash that may contain override values for admin user name and password]
  * @return void
  * @throws Tinebase_Exception_InvalidArgument
  */
 public static function createInitialAccounts($_options)
 {
     if (!isset($_options['adminPassword']) || !isset($_options['adminLoginName'])) {
         throw new Tinebase_Exception_InvalidArgument('Admin password and login name have to be set when creating initial account.', 503);
     }
     $adminLoginName = $_options['adminLoginName'];
     $adminPassword = $_options['adminPassword'];
     $adminFirstName = isset($_options['adminFirstName']) ? $_options['adminFirstName'] : 'Tine 2.0';
     $adminLastName = isset($_options['adminLastName']) ? $_options['adminLastName'] : 'Admin Account';
     $adminEmailAddress = isset($_options['adminEmailAddress']) || array_key_exists('adminEmailAddress', $_options) ? $_options['adminEmailAddress'] : NULL;
     // get admin & user groups
     $userBackend = Tinebase_User::getInstance();
     $groupsBackend = Tinebase_Group::getInstance();
     $adminGroup = $groupsBackend->getDefaultAdminGroup();
     $userGroup = $groupsBackend->getDefaultGroup();
     Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Creating initial admin user (login: '******' / email: ' . $adminEmailAddress . ')');
     $user = new Tinebase_Model_FullUser(array('accountLoginName' => $adminLoginName, 'accountStatus' => 'enabled', 'accountPrimaryGroup' => $userGroup->getId(), 'accountLastName' => $adminLastName, 'accountDisplayName' => $adminLastName . ', ' . $adminFirstName, 'accountFirstName' => $adminFirstName, 'accountExpires' => isset($_options['expires']) ? $_options['expires'] : NULL, 'accountEmailAddress' => $adminEmailAddress));
     if ($adminEmailAddress !== NULL) {
         $user->imapUser = new Tinebase_Model_EmailUser(array('emailPassword' => $adminPassword));
         $user->smtpUser = new Tinebase_Model_EmailUser(array('emailPassword' => $adminPassword));
     }
     // update or create user in local sql backend
     try {
         $userBackend->getUserByProperty('accountLoginName', $adminLoginName);
         Tinebase_Timemachine_ModificationLog::setRecordMetaData($user, 'update');
         $user = $userBackend->updateUserInSqlBackend($user);
     } catch (Tinebase_Exception_NotFound $ten) {
         // call addUser here to make sure, sql user plugins (email, ...) are triggered
         Tinebase_Timemachine_ModificationLog::setRecordMetaData($user, 'create');
         $user = $userBackend->addUser($user);
     }
     // set the password for the account
     // empty password triggers password change dialogue during first login
     if (!empty($adminPassword)) {
         Tinebase_User::getInstance()->setPassword($user, $adminPassword);
     }
     // add the admin account to all groups
     Tinebase_Group::getInstance()->addGroupMember($adminGroup, $user);
     Tinebase_Group::getInstance()->addGroupMember($userGroup, $user);
 }
 /**
  * update node
  * 
  * @param Tinebase_Model_Tree_Node $_node
  * @return Tinebase_Model_Tree_Node
  */
 public function update(Tinebase_Model_Tree_Node $_node)
 {
     $currentNodeObject = $this->get($_node->getId());
     $fileObject = $this->_fileObjectBackend->get($currentNodeObject->object_id);
     Tinebase_Timemachine_ModificationLog::setRecordMetaData($_node, 'update', $currentNodeObject);
     Tinebase_Timemachine_ModificationLog::setRecordMetaData($fileObject, 'update', $fileObject);
     // quick hack for 2014.11 - will be resolved correctly in 2015.11-develop
     if (isset($_SERVER['HTTP_X_OC_MTIME'])) {
         $fileObject->last_modified_time = new Tinebase_DateTime($_SERVER['HTTP_X_OC_MTIME']);
         Tinebase_Server_WebDAV::getResponse()->setHeader('X-OC-MTime', 'accepted');
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " using X-OC-MTIME: {$fileObject->last_modified_time->format(Tinebase_Record_Abstract::ISO8601LONG)} for {$_node->name}");
         }
     }
     // update file object
     $fileObject->description = $_node->description;
     $this->_updateFileObject($fileObject, $_node->hash);
     return $this->_treeNodeBackend->update($_node);
 }
コード例 #4
0
ファイル: Account.php プロジェクト: rodrigofns/ExpressoLivre3
 /**
  * add system account with tine user credentials (from config.inc.php or config db) 
  *
  * @param Tinebase_Record_RecordSet $_accounts of Felamimail_Model_Account
  */
 protected function _addSystemAccount(Tinebase_Record_RecordSet $_accounts)
 {
     $userId = $this->_currentAccount->getId();
     $fullUser = Tinebase_User::getInstance()->getFullUserById($userId);
     $email = $this->_getAccountEmail($fullUser);
     // only create account if email address is set
     if ($email) {
         $systemAccount = new Felamimail_Model_Account(NULL, TRUE);
         $this->_addSystemAccountConfigValues($systemAccount);
         $systemAccount->type = Felamimail_Model_Account::TYPE_SYSTEM;
         $systemAccount->user_id = $userId;
         $this->_addUserValues($systemAccount, $fullUser, $email);
         $this->_addFolderDefaults($systemAccount, TRUE);
         // create new account and update capabilities
         Tinebase_Timemachine_ModificationLog::setRecordMetaData($systemAccount, 'create');
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($systemAccount->toArray(), TRUE));
         }
         $systemAccount = $this->_backend->create($systemAccount);
         $_accounts->addRecord($systemAccount);
         $this->_addedDefaultAccount = TRUE;
         // set as default account preference
         Tinebase_Core::getPreference($this->_applicationName)->{Felamimail_Preference::DEFAULTACCOUNT} = $systemAccount->getId();
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Created new system account "' . $systemAccount->name . '".');
     } else {
         Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' Could not create system account for user ' . $fullUser->accountLoginName . '. No email address given.');
     }
 }
コード例 #5
0
 /**
  * delete one record
  *
  * @param Tinebase_Record_Interface $_record
  * @throws Tinebase_Exception_AccessDenied
  */
 protected function _deleteRecord(Tinebase_Record_Interface $_record)
 {
     $this->_checkGrant($_record, 'delete');
     $this->_deleteLinkedObjects($_record);
     if (!$this->_purgeRecords && $_record->has('created_by')) {
         Tinebase_Timemachine_ModificationLog::setRecordMetaData($_record, 'delete', $_record);
         $this->_backend->update($_record);
     } else {
         $this->_backend->delete($_record);
     }
     $this->_increaseContainerContentSequence($_record, Tinebase_Model_ContainerContent::ACTION_DELETE);
 }
コード例 #6
0
 /**
  * create or update contact in addressbook backend
  * 
  * @param  Tinebase_Model_FullUser $_user
  * @return Addressbook_Model_Contact
  */
 public function createOrUpdateContact(Tinebase_Model_FullUser $_user)
 {
     $contactsBackend = Addressbook_Backend_Factory::factory(Addressbook_Backend_Factory::SQL);
     $contactsBackend->setGetDisabledContacts(true);
     if (empty($_user->container_id)) {
         $_user->container_id = $this->getDefaultInternalAddressbook();
     }
     try {
         if (empty($_user->contact_id)) {
             // jump to catch block
             throw new Tinebase_Exception_NotFound('contact_id is empty');
         }
         $contact = $contactsBackend->get($_user->contact_id);
         // update exisiting contact
         $contact->n_family = $_user->accountLastName;
         $contact->n_given = $_user->accountFirstName;
         $contact->n_fn = $_user->accountFullName;
         $contact->n_fileas = $_user->accountDisplayName;
         $contact->email = $_user->accountEmailAddress;
         $contact->type = Addressbook_Model_Contact::CONTACTTYPE_USER;
         $contact->container_id = $_user->container_id;
         // add modlog info
         Tinebase_Timemachine_ModificationLog::setRecordMetaData($contact, 'update');
         $contact = $contactsBackend->update($contact);
     } catch (Tinebase_Exception_NotFound $tenf) {
         // add new contact
         $contact = new Addressbook_Model_Contact(array('n_family' => $_user->accountLastName, 'n_given' => $_user->accountFirstName, 'n_fn' => $_user->accountFullName, 'n_fileas' => $_user->accountDisplayName, 'email' => $_user->accountEmailAddress, 'type' => Addressbook_Model_Contact::CONTACTTYPE_USER, 'container_id' => $_user->container_id));
         // add modlog info
         Tinebase_Timemachine_ModificationLog::setRecordMetaData($contact, 'create');
         $contact = $contactsBackend->create($contact);
     }
     return $contact;
 }
 /**
  * creates a new container
  *
  * @param   Tinebase_Model_Container $_container the new container
  * @param   Tinebase_Record_RecordSet $_grants the grants for the new folder 
  * @param   bool  $_ignoreAcl
  * @return  Tinebase_Model_Container the newly created container
  * @throws  Tinebase_Exception_Record_Validation
  * @throws  Tinebase_Exception_AccessDenied
  */
 public function addContainer(Tinebase_Model_Container $_container, $_grants = NULL, $_ignoreAcl = FALSE)
 {
     $_container->isValid(TRUE);
     if ($_ignoreAcl !== TRUE) {
         switch ($_container->type) {
             case Tinebase_Model_Container::TYPE_PERSONAL:
                 // is the user allowed to create personal container?
                 break;
             case Tinebase_Model_Container::TYPE_SHARED:
                 $application = Tinebase_Application::getInstance()->getApplicationById($_container->application_id);
                 $appName = (string) $application;
                 $manageRight = FALSE;
                 // check for MANAGE_SHARED_FOLDERS right
                 $appAclClassName = $appName . '_Acl_Rights';
                 if (@class_exists($appAclClassName)) {
                     $appAclObj = call_user_func(array($appAclClassName, 'getInstance'));
                     $allRights = $appAclObj->getAllApplicationRights();
                     if (in_array(Tinebase_Acl_Rights::MANAGE_SHARED_FOLDERS, $allRights)) {
                         $manageRight = Tinebase_Core::getUser()->hasRight($appName, Tinebase_Acl_Rights::MANAGE_SHARED_FOLDERS);
                     }
                 }
                 if (!$manageRight && !Tinebase_Core::getUser()->hasRight($appName, Tinebase_Acl_Rights::ADMIN)) {
                     throw new Tinebase_Exception_AccessDenied('Permission to add shared container denied.');
                 }
                 break;
             default:
                 throw new Tinebase_Exception_InvalidArgument('Can add personal or shared folders only when ignoring ACL.');
                 break;
         }
     }
     if (!empty($_container->owner_id)) {
         $accountId = $_container->owner_id instanceof Tinebase_Model_User ? $_container->owner_id->getId() : $_container->owner_id;
     } else {
         $accountId = is_object(Tinebase_Core::getUser()) ? Tinebase_Core::getUser()->getId() : NULL;
     }
     if ($_grants === NULL || count($_grants) == 0) {
         $creatorGrants = array('account_id' => $accountId, 'account_type' => Tinebase_Acl_Rights::ACCOUNT_TYPE_USER, Tinebase_Model_Grants::GRANT_READ => true, Tinebase_Model_Grants::GRANT_ADD => true, Tinebase_Model_Grants::GRANT_EDIT => true, Tinebase_Model_Grants::GRANT_DELETE => true, Tinebase_Model_Grants::GRANT_EXPORT => true, Tinebase_Model_Grants::GRANT_SYNC => true, Tinebase_Model_Grants::GRANT_ADMIN => true);
         if ($_container->type === Tinebase_Model_Container::TYPE_SHARED && !Tinebase_Config::getInstance()->get(Tinebase_Config::ANYONE_ACCOUNT_DISABLED)) {
             // add all grants to creator and
             // add read grants to any other user
             $grants = new Tinebase_Record_RecordSet('Tinebase_Model_Grants', array($creatorGrants, array('account_id' => '0', 'account_type' => Tinebase_Acl_Rights::ACCOUNT_TYPE_ANYONE, Tinebase_Model_Grants::GRANT_READ => true, Tinebase_Model_Grants::GRANT_EXPORT => true, Tinebase_Model_Grants::GRANT_SYNC => true)), TRUE);
         } else {
             // add all grants to creator only
             $grants = new Tinebase_Record_RecordSet('Tinebase_Model_Grants', array($creatorGrants), TRUE);
         }
     } else {
         $grants = $_grants;
     }
     $event = new Tinebase_Event_Container_BeforeCreate();
     $event->accountId = $accountId;
     $event->container = $_container;
     $event->grants = $grants;
     Tinebase_Event::fireEvent($event);
     Tinebase_Timemachine_ModificationLog::setRecordMetaData($_container, 'create');
     $container = $this->create($_container);
     $this->setGrants($container->getId(), $grants, TRUE, FALSE);
     return $container;
 }
コード例 #8
0
 /**
  * create contact in addressbook
  * 
  * @param Tinebase_Model_FullUser $user
  */
 public static function syncContact($user)
 {
     if (!Tinebase_Application::getInstance()->isInstalled('Addressbook')) {
         return;
     }
     $addressbook = Addressbook_Backend_Factory::factory(Addressbook_Backend_Factory::SQL);
     $internalAddressbook = Tinebase_Container::getInstance()->getContainerByName('Addressbook', 'Internal Contacts', Tinebase_Model_Container::TYPE_SHARED);
     $contact = new Addressbook_Model_Contact(array('n_family' => $user->accountLastName, 'n_given' => $user->accountFirstName, 'n_fn' => $user->accountFullName, 'n_fileas' => $user->accountDisplayName, 'email' => $user->accountEmailAddress, 'type' => Addressbook_Model_Contact::CONTACTTYPE_USER, 'container_id' => $internalAddressbook->getId()));
     // add modlog info
     Tinebase_Timemachine_ModificationLog::setRecordMetaData($contact, 'create');
     $contact = $addressbook->create($contact);
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Added contact " . $contact->n_given);
     }
     $user->contact_id = $contact->getId();
 }
コード例 #9
0
 /**
  * update existing group
  *
  * @param Tinebase_Model_Group $_group
  * @return Tinebase_Model_Group
  */
 public function update(Tinebase_Model_Group $_group)
 {
     $this->checkRight('MANAGE_ACCOUNTS');
     // update default user group if name has changed
     $oldGroup = Tinebase_Group::getInstance()->getGroupById($_group->getId());
     $defaultGroupName = Tinebase_User::getBackendConfiguration(Tinebase_User::DEFAULT_USER_GROUP_NAME_KEY);
     if ($oldGroup->name == $defaultGroupName && $oldGroup->name != $_group->name) {
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Updated default group name: ' . $oldGroup->name . ' -> ' . $_group->name);
         Tinebase_User::setBackendConfiguration($_group->name, Tinebase_User::DEFAULT_USER_GROUP_NAME_KEY);
         Tinebase_User::saveBackendConfiguration();
     }
     $transactionId = Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
     if (Tinebase_Application::getInstance()->isInstalled('Addressbook') === true) {
         $_group->list_id = $oldGroup->list_id;
         $list = $this->createOrUpdateList($_group);
         $_group->list_id = $list->getId();
     }
     Tinebase_Timemachine_ModificationLog::setRecordMetaData($_group, 'update', $oldGroup);
     $group = Tinebase_Group::getInstance()->updateGroup($_group);
     Tinebase_Group::getInstance()->setGroupMembers($group->getId(), $_group->members);
     Tinebase_TransactionManager::getInstance()->commitTransaction($transactionId);
     $event = new Admin_Event_UpdateGroup();
     $event->group = $group;
     Tinebase_Event::fireEvent($event);
     return $group;
 }
コード例 #10
0
 /**
  * delete container if user has the required right
  *
  * @param   int|Tinebase_Model_Container $_containerId
  * @param   boolean $_ignoreAcl
  * @param   boolean $_tryAgain
  * @throws  Tinebase_Exception_AccessDenied
  * @throws  Tinebase_Exception_InvalidArgument
  * 
  * @todo move records in deleted container to personal container?
  */
 public function deleteContainer($_containerId, $_ignoreAcl = FALSE, $_tryAgain = TRUE)
 {
     $containerId = Tinebase_Model_Container::convertContainerIdToInt($_containerId);
     $container = $_containerId instanceof Tinebase_Model_Container ? $_containerId : $this->getContainerById($containerId);
     if ($_ignoreAcl !== TRUE) {
         if (!$this->hasGrant(Tinebase_Core::getUser(), $containerId, Tinebase_Model_Grants::GRANT_ADMIN)) {
             throw new Tinebase_Exception_AccessDenied('Permission to delete container denied.');
         }
         if ($container->type !== Tinebase_Model_Container::TYPE_PERSONAL and $container->type !== Tinebase_Model_Container::TYPE_SHARED) {
             throw new Tinebase_Exception_InvalidArgument('Can delete personal or shared containers only.');
         }
     }
     //$this->delete($containerId);
     Tinebase_Timemachine_ModificationLog::setRecordMetaData($container, 'delete', $container);
     $this->update($container);
     $this->_clearCache();
     /*
     // move all contained objects to next available personal container and try again to delete container
     $app = Tinebase_Application::getApplicationById($container->application_id);
     
     // get personal containers
     $personalContainers = $this->getPersonalContainer(
         Tinebase_Core::getUser(),
         $app->name,
         $container->owner,
         Tinebase_Model_Grants::GRANT_ADD
     );
     
     //-- determine first matching personal container (or create new one)
     // $personalContainer = 
     
     //-- move all records to personal container
     
     Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ 
         . ' Moving all records from container ' . $containerId . ' to personal container ' . $personalContainer->getId()
     );
     */
 }
コード例 #11
0
 /**
  * add one record
  *
  * @param   Tinebase_Record_Interface $_record
  * @return  Tinebase_Record_Interface
  */
 public function create(Tinebase_Record_Interface $_record)
 {
     $this->_checkRight('create');
     $_record->account_grants = $this->_convertGrantsToRecordSet($_record->account_grants);
     Tinebase_Container::getInstance()->checkContainerOwner($_record);
     Tinebase_Timemachine_ModificationLog::setRecordMetaData($_record, 'create');
     $container = $this->_containerController->addContainer($_record, $_record->account_grants, TRUE);
     $container->account_grants = $this->_containerController->getGrantsOfContainer($container, TRUE);
     return $container;
 }
コード例 #12
0
 /**
  * create initial groups
  * 
  * Method is called during Setup Initialization
  */
 public static function createInitialGroups()
 {
     $defaultAdminGroupName = Tinebase_User::getBackendConfiguration(Tinebase_User::DEFAULT_ADMIN_GROUP_NAME_KEY) ? Tinebase_User::getBackendConfiguration(Tinebase_User::DEFAULT_ADMIN_GROUP_NAME_KEY) : self::DEFAULT_ADMIN_GROUP;
     $adminGroup = new Tinebase_Model_Group(array('name' => $defaultAdminGroupName, 'description' => 'Group of administrative accounts'));
     Tinebase_Timemachine_ModificationLog::setRecordMetaData($adminGroup, 'create');
     Tinebase_Group::getInstance()->addGroup($adminGroup);
     $defaultUserGroupName = Tinebase_User::getBackendConfiguration(Tinebase_User::DEFAULT_USER_GROUP_NAME_KEY) ? Tinebase_User::getBackendConfiguration(Tinebase_User::DEFAULT_USER_GROUP_NAME_KEY) : self::DEFAULT_USER_GROUP;
     $userGroup = new Tinebase_Model_Group(array('name' => $defaultUserGroupName, 'description' => 'Group of user accounts'));
     Tinebase_Timemachine_ModificationLog::setRecordMetaData($userGroup, 'create');
     Tinebase_Group::getInstance()->addGroup($userGroup);
 }
コード例 #13
0
 /**
  * delete notes
  *
  * @param Tinebase_Record_RecordSet $notes
  */
 public function deleteNotes(Tinebase_Record_RecordSet $notes)
 {
     $sqlBackend = new Tinebase_Backend_Sql(array('tableName' => $this->getTableName(), 'modelName' => 'Tinebase_Model_Note'), $this->getAdapter());
     foreach ($notes as $note) {
         Tinebase_Timemachine_ModificationLog::setRecordMetaData($note, 'delete', $note);
         $sqlBackend->update($note);
     }
 }
コード例 #14
0
 /**
  * create new list by group
  * 
  * @param Tinebase_Model_Group $group
  * @return Addressbook_Model_List
  */
 public function createByGroup($group)
 {
     $list = new Addressbook_Model_List(array('name' => $group->name, 'description' => $group->description, 'email' => $group->email, 'type' => Addressbook_Model_List::LISTTYPE_GROUP, 'container_id' => empty($group->container_id) ? $this->_getDefaultInternalAddressbook() : $group->container_id, 'members' => isset($group->members) ? $this->_getContactIds($group->members) : array()));
     // add modlog info
     Tinebase_Timemachine_ModificationLog::setRecordMetaData($list, 'create');
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Add new list ' . $group->name);
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($list->toArray(), TRUE));
     }
     $list = $this->_backend->create($list);
     return $list;
 }
コード例 #15
0
 /**
  * @see Tinebase_Setup_DemoData_Abstract
  */
 protected function _beforeCreate()
 {
     $be = new Addressbook_Backend_Sql();
     foreach ($this->_personas as $login => $fullName) {
         try {
             $user = Tinebase_User::getInstance()->getFullUserByLoginName($login);
             $contact = Addressbook_Controller_Contact::getInstance()->get($user->contact_id);
         } catch (Tinebase_Exception_NotFound $e) {
             list($given, $last) = explode(' ', $fullName);
             $group = Tinebase_Group::getInstance()->getGroupByName('Users');
             $groupId = $group->getId();
             $emailDomain = $this->_getMailDomain();
             $user = new Tinebase_Model_FullUser(array('accountLoginName' => $login, 'accountPrimaryGroup' => $groupId, 'accountDisplayName' => $fullName, 'accountLastName' => $last, 'accountFirstName' => $given, 'accountFullName' => $fullName, 'accountEmailAddress' => $login . '@' . $emailDomain));
             if (Tinebase_Application::getInstance()->isInstalled('Addressbook') === true) {
                 $internalAddressbook = Tinebase_Container::getInstance()->getContainerByName('Addressbook', 'Internal Contacts', Tinebase_Model_Container::TYPE_SHARED);
                 $user->container_id = $internalAddressbook->getId();
                 $contact = Admin_Controller_User::getInstance()->createOrUpdateContact($user);
                 $user->contact_id = $contact->getId();
             }
             Tinebase_Timemachine_ModificationLog::setRecordMetaData($user, 'create');
             $user = Tinebase_User::getInstance()->addUser($user);
             Tinebase_Group::getInstance()->addGroupMember($groupId, $user);
             if (Tinebase_Application::getInstance()->isInstalled('Addressbook') === true) {
                 $listBackend = new Addressbook_Backend_List();
                 $listBackend->addListMember($group->list_id, $user->contact_id);
             }
             $this->_setUserPassword($user);
         }
         if (Tinebase_Application::getInstance()->isInstalled('Addressbook') === true) {
             $ar = array_merge($this->_dataMapping[$login], $this->_dataMapping['default']);
             $filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'DemoData' . DIRECTORY_SEPARATOR . 'persona_' . $login . '.jpg';
             if (file_exists($filename)) {
                 $handle = fopen($filename, "r");
                 $content = fread($handle, filesize($filename));
                 fclose($handle);
                 $be->_saveImage($contact->getId(), $content);
             }
             foreach ($ar as $property => $value) {
                 $contact->{$property} = $value;
             }
             Addressbook_Controller_Contact::getInstance()->update($contact);
         }
         $this->_personas[$login] = $user;
     }
     $this->_createGroups();
     $this->_createRoles();
     $this->_createSharedTags();
 }
コード例 #16
0
 /**
  * updates a single role
  * 
  * @param  Tinebase_Model_Role $role
  * @return Tinebase_Model_Role
  */
 public function updateRole(Tinebase_Model_Role $role)
 {
     Tinebase_Timemachine_ModificationLog::setRecordMetaData($role, 'update', $this->getRoleById($role->getId()));
     $role = $this->_getRolesBackend()->update($role);
     $this->resetClassCache();
     return $role;
 }
コード例 #17
0
 /**
  * update node
  * 
  * @param Tinebase_Model_Tree_Node $_node
  * @return Tinebase_Model_Tree_Node
  */
 public function update(Tinebase_Model_Tree_Node $_node)
 {
     $currentNodeObject = $this->get($_node->getId());
     Tinebase_Timemachine_ModificationLog::setRecordMetaData($_node, 'update', $currentNodeObject);
     // update file object
     $fileObject = $this->_fileObjectBackend->get($currentNodeObject->object_id);
     $fileObject->description = $_node->description;
     $this->_updateFileObject($fileObject, $_node->hash);
     return $this->_treeNodeBackend->update($_node);
 }