当前位置: 首页>>代码示例>>PHP>>正文


PHP Tinebase_Group::getInstance方法代码示例

本文整理汇总了PHP中Tinebase_Group::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Group::getInstance方法的具体用法?PHP Tinebase_Group::getInstance怎么用?PHP Tinebase_Group::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tinebase_Group的用法示例。


在下文中一共展示了Tinebase_Group::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _recordToJson

 /**
  * returns record prepared for json transport
  *
  * @param Tinebase_Record_Interface $_record
  * @return array record data
  */
 protected function _recordToJson($_record)
 {
     switch (get_class($_record)) {
         case 'Timetracker_Model_Timesheet':
             $_record['timeaccount_id'] = $_record['timeaccount_id'] ? $this->_timeaccountController->get($_record['timeaccount_id']) : $_record['timeaccount_id'];
             $_record['timeaccount_id']['account_grants'] = Timetracker_Model_TimeaccountGrants::getGrantsOfAccount(Tinebase_Core::get('currentAccount'), $_record['timeaccount_id']);
             $_record['timeaccount_id']['account_grants'] = $this->_resolveTimesheetGrantsByTimeaccountGrants($_record['timeaccount_id']['account_grants'], $_record['account_id']);
             Tinebase_User::getInstance()->resolveUsers($_record, 'account_id');
             $recordArray = parent::_recordToJson($_record);
             break;
         case 'Timetracker_Model_Timeaccount':
             $recordArray = parent::_recordToJson($_record);
             // When editing a single TA we send _ALL_ grants to the client
             $recordArray['grants'] = Timetracker_Model_TimeaccountGrants::getTimeaccountGrants($_record)->toArray();
             foreach ($recordArray['grants'] as &$value) {
                 switch ($value['account_type']) {
                     case Tinebase_Acl_Rights::ACCOUNT_TYPE_USER:
                         $value['account_name'] = Tinebase_User::getInstance()->getUserById($value['account_id'])->toArray();
                         break;
                     case Tinebase_Acl_Rights::ACCOUNT_TYPE_GROUP:
                         $value['account_name'] = Tinebase_Group::getInstance()->getGroupById($value['account_id'])->toArray();
                         break;
                     case Tinebase_Acl_Rights::ACCOUNT_TYPE_ANYONE:
                         $value['account_name'] = array('accountDisplayName' => 'Anyone');
                         break;
                     default:
                         throw new Tinebase_Exception_InvalidArgument('Unsupported accountType.');
                         break;
                 }
             }
             break;
     }
     return $recordArray;
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:40,代码来源:Json.php

示例2: 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;
     } else {
         if ($this->_userValue === Tinebase_Model_User::CURRENTACCOUNT) {
             // switch back to CURRENTACCOUNT to make sure filter is saved and shown in client correctly
             $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;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:39,代码来源:User.php

示例3: 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);
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:29,代码来源:AttenderTests.php

示例4: _multipleRecordsToJson

 /**
  * returns multiple records prepared for json transport
  *
  * @param Tinebase_Record_RecordSet $_records
  * @param Tinebase_Model_Filter_FilterGroup $_filter
  * @param Tinebase_Model_Pagination $_pagination
  * 
  * @return array data
  */
 protected function _multipleRecordsToJson(Tinebase_Record_RecordSet $_records, $_filter = NULL, $_pagination = NULL)
 {
     $result = parent::_multipleRecordsToJson($_records, $_filter, $_pagination);
     // get groups + types (departments) and merge data
     $groupIds = $_records->group_id;
     $groups = Tinebase_Group::getInstance()->getMultiple(array_unique(array_values($groupIds)));
     $knownTypes = Tinebase_Department::getInstance()->search(new Tinebase_Model_DepartmentFilter());
     foreach ($result as &$course) {
         $groupIdx = $groups->getIndexById($course['group_id']);
         if ($groupIdx !== FALSE) {
             $group = $groups[$groupIdx]->toArray();
             unset($group['id']);
             $course = array_merge($group, $course);
         } else {
             if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
                 Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' Group with ID ' . $course['group_id'] . ' does not exist.');
             }
         }
         $typeIdx = $knownTypes->getIndexById($course['type']);
         if ($typeIdx !== FALSE) {
             //if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($knownTypes[$typeIdx]->toArray(), true));
             $course['type'] = $knownTypes[$typeIdx]->toArray();
         } else {
             if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
                 Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' Department with ID ' . $course['type'] . ' does not exist.');
             }
             $course['type'] = array('id' => $course['type'], 'name' => $course['type']);
         }
     }
     return $result;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:40,代码来源:Json.php

示例5: resetCoursesInternetAccess

 /**
  * set all courses to internet = FILTERED
  * 
  * @return integer
  */
 public function resetCoursesInternetAccess()
 {
     if (!$this->_checkAdminRight()) {
         return 2;
     }
     $config = Courses_Config::getInstance();
     if (!isset($config->{Courses_Config::INTERNET_ACCESS_GROUP_ON}) || !isset($config->{Courses_Config::INTERNET_ACCESS_GROUP_FILTERED})) {
         echo "No internet groups defined in config. Exiting\n";
         return 2;
     }
     $filter = new Courses_Model_CourseFilter(array(array('field' => 'internet', 'operator' => 'not', 'value' => 'FILTERED')));
     $count = 0;
     foreach (Courses_Controller_Course::getInstance()->search($filter) as $course) {
         $course->internet = 'FILTERED';
         $group = Tinebase_Group::getInstance()->getGroupById($course->group_id);
         $group->members = Tinebase_Group::getInstance()->getGroupMembers($group);
         try {
             Courses_Controller_Course::getInstance()->saveCourseAndGroup($course, $group);
             $count++;
         } catch (Exception $e) {
             echo 'Failed to update course: ' . $course->name . PHP_EOL;
             echo $e . PHP_EOL;
         }
     }
     echo "Updated " . $count . " Course(s)\n";
     return 0;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:32,代码来源:Cli.php

示例6: 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;
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:34,代码来源:User.php

示例7: testExpandProperty

 public function testExpandProperty()
 {
     $list = Tinebase_Group::getInstance()->getGroupById(Tinebase_Core::getUser()->accountPrimaryGroup);
     $body = '<?xml version="1.0" encoding="UTF-8"?>
             <A:expand-property xmlns:A="DAV:">
               <A:property name="expanded-group-member-set" namespace="http://calendarserver.org/ns/">
                 <A:property name="last-name" namespace="http://calendarserver.org/ns/"/>
                 <A:property name="principal-URL" namespace="DAV:"/>
                 <A:property name="calendar-user-type" namespace="urn:ietf:params:xml:ns:caldav"/>
                 <A:property name="calendar-user-address-set" namespace="urn:ietf:params:xml:ns:caldav"/>
                 <A:property name="first-name" namespace="http://calendarserver.org/ns/"/>
                 <A:property name="record-type" namespace="http://calendarserver.org/ns/"/>
                 <A:property name="displayname" namespace="DAV:"/>
               </A:property>
             </A:expand-property>';
     $request = new Sabre\HTTP\Request(array('REQUEST_METHOD' => 'REPORT', 'REQUEST_URI' => '/principals/groups/' . $list->list_id . '/'));
     $request->setBody($body);
     $this->server->httpRequest = $request;
     $this->server->exec();
     $responseDoc = new DOMDocument();
     $responseDoc->loadXML($this->response->body);
     #$responseDoc->formatOutput = true; echo $responseDoc->saveXML();
     $xpath = new DomXPath($responseDoc);
     $xpath->registerNamespace('cal', 'urn:ietf:params:xml:ns:caldav');
     $xpath->registerNamespace('cs', 'http://calendarserver.org/ns/');
     $nodes = $xpath->query('///cs:expanded-group-member-set/d:response/d:href[text()="/principals/groups/' . $list->list_id . '/"]');
     $this->assertEquals(1, $nodes->length, 'group itself (not shown by client) is missing');
     $nodes = $xpath->query('///cs:expanded-group-member-set/d:response/d:href[text()="/principals/intelligroups/' . $list->list_id . '/"]');
     $this->assertEquals(1, $nodes->length, 'intelligroup (to keep group itself) is missing');
     $nodes = $xpath->query('///cs:expanded-group-member-set/d:response/d:href[text()="/principals/users/' . Tinebase_Core::getUser()->contact_id . '/"]');
     $this->assertEquals(1, $nodes->length, 'user is missing');
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:32,代码来源:ExpandedPropertiesReportTest.php

示例8: setUp

 protected function setUp()
 {
     $this->_setGeoData = Addressbook_Controller_Contact::getInstance()->setGeoDataForContacts(FALSE);
     $appName = 'Addressbook';
     ############# TEST USER ##########
     $user = new Tinebase_Model_FullUser(array('accountLoginName' => 'tine20phpunit', 'accountDisplayName' => 'tine20phpunit', 'accountStatus' => 'enabled', 'accountExpires' => NULL, 'accountPrimaryGroup' => Tinebase_Group::getInstance()->getGroupByName('Users')->getId(), 'accountLastName' => 'Tine 2.0', 'accountFirstName' => 'PHPUnit', 'accountEmailAddress' => 'phpunit@metaways.de'));
     try {
         $user = Tinebase_User::getInstance()->getUserByLoginName($user->accountLoginName);
     } catch (Tinebase_Exception_NotFound $e) {
         $user = Tinebase_User::getInstance()->addUser($user);
     }
     $this->objects['user'] = $user;
     ############# TEST CONTACT ##########
     try {
         $containerWithSyncGrant = Tinebase_Container::getInstance()->getContainerByName($appName, 'ContainerWithSyncGrant', Tinebase_Model_Container::TYPE_PERSONAL, Tinebase_Core::getUser());
     } catch (Tinebase_Exception_NotFound $e) {
         $containerWithSyncGrant = new Tinebase_Model_Container(array('name' => 'ContainerWithSyncGrant', 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'owner_id' => Tinebase_Core::getUser(), 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName($appName)->getId()));
         $containerWithSyncGrant = Tinebase_Container::getInstance()->addContainer($containerWithSyncGrant);
     }
     $this->objects['containerWithSyncGrant'] = $containerWithSyncGrant;
     try {
         $containerWithoutSyncGrant = Tinebase_Container::getInstance()->getContainerByName($appName, 'ContainerWithoutSyncGrant', Tinebase_Model_Container::TYPE_PERSONAL, Tinebase_Core::getUser());
     } catch (Tinebase_Exception_NotFound $e) {
         $creatorGrants = array('account_id' => Tinebase_Core::getUser()->getId(), '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_ADMIN => true);
         $grants = new Tinebase_Record_RecordSet('Tinebase_Model_Grants', array($creatorGrants));
         $containerWithoutSyncGrant = new Tinebase_Model_Container(array('name' => 'ContainerWithoutSyncGrant', 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'owner_id' => Tinebase_Core::getUser(), 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName($appName)->getId()));
         $containerWithSyncGrant = Tinebase_Container::getInstance()->addContainer($containerWithoutSyncGrant, $grants);
     }
     $this->objects['containerWithoutSyncGrant'] = $containerWithoutSyncGrant;
     $contact = new Addressbook_Model_Contact(array('adr_one_countryname' => 'DE', 'adr_one_locality' => 'Hamburg', 'adr_one_postalcode' => '24xxx', 'adr_one_region' => 'Hamburg', 'adr_one_street' => 'Pickhuben 4', 'adr_one_street2' => 'no second street', 'adr_two_countryname' => 'DE', 'adr_two_locality' => 'Hamburg', 'adr_two_postalcode' => '24xxx', 'adr_two_region' => 'Hamburg', 'adr_two_street' => 'Pickhuben 4', 'adr_two_street2' => 'no second street2', 'bday' => '1975-01-02 03:00:00', 'email' => 'unittests@tine20.org', 'email_home' => 'unittests@tine20.org', 'container_id' => $this->objects['containerWithSyncGrant']->id, 'role' => 'Role', 'n_given' => 'Lars', 'n_family' => 'Kneschke', 'n_fileas' => 'Kneschke, Lars'));
     $contact = Addressbook_Controller_Contact::getInstance()->create($contact, FALSE);
     $this->objects['contact'] = $contact;
     $unSyncableContact = new Addressbook_Model_Contact(array('adr_one_countryname' => 'DE', 'adr_one_locality' => 'Hamburg', 'adr_one_postalcode' => '24xxx', 'adr_one_region' => 'Hamburg', 'adr_one_street' => 'Pickhuben 4', 'adr_one_street2' => 'no second street', 'adr_two_countryname' => 'DE', 'adr_two_locality' => 'Hamburg', 'adr_two_postalcode' => '24xxx', 'adr_two_region' => 'Hamburg', 'adr_two_street' => 'Pickhuben 4', 'adr_two_street2' => 'no second street2', 'bday' => '1975-01-02 03:00:00', 'email' => 'unittests@tine20.org', 'email_home' => 'unittests@tine20.org', 'container_id' => $this->objects['containerWithoutSyncGrant']->id, 'role' => 'Role', 'n_given' => 'Lars', 'n_family' => 'Kneschke', 'n_fileas' => 'Kneschke, Lars'));
     $unSyncableContact = Addressbook_Controller_Contact::getInstance()->create($unSyncableContact, FALSE);
     $this->objects['unSyncableContact'] = $unSyncableContact;
     ########### define test filter
     $filterBackend = new Tinebase_PersistentFilter_Backend_Sql();
     try {
         $filter = $filterBackend->getByProperty('Contacts Sync Test', 'name');
     } catch (Tinebase_Exception_NotFound $e) {
         $filter = new Tinebase_Model_PersistentFilter(array('application_id' => Tinebase_Application::getInstance()->getApplicationByName('Addressbook')->getId(), 'account_id' => Tinebase_Core::getUser()->getId(), 'model' => 'Addressbook_Model_ContactFilter', 'filters' => array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $this->objects['containerWithSyncGrant']->getId())), 'name' => 'Contacts Sync Test', 'description' => 'Created by unit test'));
         $filter = $filterBackend->create($filter);
     }
     $this->objects['filter'] = $filter;
     ########### define test devices
     $palm = ActiveSync_Backend_DeviceTests::getTestDevice(Syncope_Model_Device::TYPE_WEBOS);
     $palm->contactsfilter_id = $this->objects['filter']->getId();
     $this->objects['deviceWebOS'] = ActiveSync_Controller_Device::getInstance()->create($palm);
     $iphone = ActiveSync_Backend_DeviceTests::getTestDevice(Syncope_Model_Device::TYPE_IPHONE);
     $iphone->contactsfilter_id = $this->objects['filter']->getId();
     $this->objects['deviceIPhone'] = ActiveSync_Controller_Device::getInstance()->create($iphone);
     $htcAndroid = ActiveSync_Backend_DeviceTests::getTestDevice(Syncope_Model_Device::TYPE_ANDROID);
     $htcAndroid->contactsfilter_id = $this->objects['filter']->getId();
     $this->objects['deviceAndroid'] = ActiveSync_Controller_Device::getInstance()->create($htcAndroid);
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:55,代码来源:ContactsTests.php

示例9: _initializeGroupLists

 /**
  * create group lists
  */
 protected function _initializeGroupLists()
 {
     foreach (Tinebase_Group::getInstance()->getGroups() as $group) {
         $group->members = Tinebase_Group::getInstance()->getGroupMembers($group);
         $group->container_id = $this->_getInternalAddressbook()->getId();
         $group->visibility = Tinebase_Model_Group::VISIBILITY_DISPLAYED;
         $list = Admin_Controller_Group::getInstance()->createOrUpdateList($group);
         $group->list_id = $list->getId();
         Tinebase_Group::getInstance()->updateGroup($group);
     }
 }
开发者ID:hernot,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:14,代码来源:Initialize.php

示例10: setUp

 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     parent::setUp();
     $this->objects['application'] = Tinebase_Application::getInstance()->getApplicationByName('Crm');
     $this->objects['user'] = new Tinebase_Model_FullUser(array('accountLoginName' => 'crmtine20phpunit', 'accountDisplayName' => 'crmtine20phpunit', 'accountStatus' => 'enabled', 'accountExpires' => NULL, 'accountPrimaryGroup' => Tinebase_Group::getInstance()->getDefaultGroup()->getId(), 'accountLastName' => 'Tine 2.0', 'accountFirstName' => 'crmPHPUnit', 'accountEmailAddress' => 'crmphpunit@metaways.de'));
     $this->objects['role'] = new Tinebase_Model_Role(array('id' => 10, 'name' => 'phpunitrole', 'description' => 'test role for phpunit'));
     $this->objects['role_2'] = new Tinebase_Model_Role(array('id' => 11, 'name' => 'phpunitrole 2', 'description' => 'test role 2 for phpunit'));
     // add account for group / role member tests
     $this->objects['user'] = Tinebase_User::getInstance()->addUser($this->objects['user']);
     Tinebase_Group::getInstance()->addGroupMember($this->objects['user']->accountPrimaryGroup, $this->objects['user']);
     return;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:18,代码来源:RolesTest.php

示例11: setUp

 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->objects['initialGroup'] = new Tinebase_Model_Group(array('id' => 'test-controller-group', 'name' => 'tine20phpunit', 'description' => 'initial test group'));
     $this->objects['updatedGroup'] = new Tinebase_Model_Group(array('id' => 'test-controller-group', 'name' => 'tine20phpunit updated', 'description' => 'updated test group'));
     $this->objects['initialAccount'] = new Tinebase_Model_FullUser(array('accountId' => 'dflkjgldfgdfgd', 'accountLoginName' => 'tine20phpunit', 'accountStatus' => 'enabled', 'accountExpires' => NULL, 'accountPrimaryGroup' => Tinebase_Group::getInstance()->getGroupByName('Users')->id, 'accountLastName' => 'Tine 2.0', 'accountFirstName' => 'PHPUnit', 'accountEmailAddress' => 'phpunit@metaways.de'));
     $this->objects['updatedAccount'] = new Tinebase_Model_FullUser(array('accountLoginName' => 'tine20phpunit-updated', 'accountStatus' => 'disabled', 'accountExpires' => NULL, 'accountPrimaryGroup' => Tinebase_Group::getInstance()->getGroupByName('Users')->id, 'accountLastName' => 'Tine 2.0 Updated', 'accountFirstName' => 'PHPUnit Updated', 'accountEmailAddress' => 'phpunit@tine20.org'));
     if (Tinebase_Application::getInstance()->isInstalled('Addressbook') === true) {
         $internalAddressbook = Tinebase_Container::getInstance()->getContainerByName('Addressbook', 'Internal Contacts', Tinebase_Model_Container::TYPE_SHARED);
         $this->objects['initialGroup']->container_id = $internalAddressbook->getId();
         $this->objects['updatedGroup']->container_id = $internalAddressbook->getId();
         $this->objects['initialAccount']->container_id = $internalAddressbook->getId();
         $this->objects['updatedAccount']->container_id = $internalAddressbook->getId();
     }
     return;
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:21,代码来源:ControllerTest.php

示例12: setUp

 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->objects['application'] = Tinebase_Application::getInstance()->getApplicationByName('Crm');
     $this->objects['user'] = new Tinebase_Model_FullUser(array('accountId' => 10, 'accountLoginName' => 'tine20phpunit', 'accountDisplayName' => 'tine20phpunit', 'accountStatus' => 'enabled', 'accountExpires' => NULL, 'accountPrimaryGroup' => Tinebase_Group::getInstance()->getGroupByName('Users')->getId(), 'accountLastName' => 'Tine 2.0', 'accountFirstName' => 'PHPUnit', 'accountEmailAddress' => 'phpunit@metaways.de'));
     $this->objects['role'] = new Tinebase_Model_Role(array('id' => 10, 'name' => 'phpunitrole', 'description' => 'test role for phpunit'));
     $this->objects['role_2'] = new Tinebase_Model_Role(array('id' => 11, 'name' => 'phpunitrole 2', 'description' => 'test role 2 for phpunit'));
     $translate = Tinebase_Translation::getTranslation('Tinebase');
     // add account for group / role member tests
     try {
         $user = Tinebase_User::getInstance()->getUserById($this->objects['user']->accountId);
     } catch (Tinebase_Exception_NotFound $e) {
         $user = Tinebase_User::getInstance()->addUser($this->objects['user']);
         Tinebase_Group::getInstance()->addGroupMember($user->accountPrimaryGroup, $user);
     }
     return;
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:22,代码来源:RolesTest.php

示例13: testEmailsToAttendeeWithGroups

 /**
  * @return void
  */
 public function testEmailsToAttendeeWithGroups()
 {
     $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->_testUser->accountFirstName, 'lastName' => $this->_testUser->accountLastName, 'partStat' => Calendar_Model_Attender::STATUS_TENTATIVE, 'role' => Calendar_Model_Attender::ROLE_REQUIRED, 'email' => $this->_testUser->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);
     //var_dump($persistentEvent->attendee->toArray());
     // there must be more than 2 attendees the user, the group + the groupmembers
     $this->assertGreaterThan(2, count($persistentEvent->attendee));
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:23,代码来源:AttenderTests.php

示例14: _recordToJson

 /**
  * returns record prepared for json transport
  *
  * @param Tinebase_Record_Interface $_record
  * @return array record data
  */
 protected function _recordToJson($_record)
 {
     switch (get_class($_record)) {
         case 'Timetracker_Model_Timesheet':
             $_record['timeaccount_id'] = $_record['timeaccount_id'] ? $this->_timeaccountController->get($_record['timeaccount_id']) : $_record['timeaccount_id'];
             $_record['timeaccount_id']['account_grants'] = Timetracker_Model_TimeaccountGrants::getGrantsOfAccount(Tinebase_Core::get('currentAccount'), $_record['timeaccount_id']);
             $_record['timeaccount_id']['account_grants'] = $this->_resolveTimesheetGrantsByTimeaccountGrants($_record['timeaccount_id']['account_grants'], $_record['account_id']);
             Tinebase_User::getInstance()->resolveUsers($_record, 'account_id');
             if (Tinebase_Core::getUser()->hasRight('Sales', 'manage_invoices') && !empty($_record['invoice_id'])) {
                 try {
                     $_record['invoice_id'] = Sales_Controller_Invoice::getInstance()->get($_record['invoice_id']);
                 } catch (Tinebase_Exception_NotFound $nfe) {
                     Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Could not resolve invoice with id ' . $_record['invoice_id']);
                 }
             }
             $recordArray = parent::_recordToJson($_record);
             break;
         case 'Timetracker_Model_Timeaccount':
             $recordArray = parent::_recordToJson($_record);
             // When editing a single TA we send _ALL_ grants to the client
             $recordArray['grants'] = Timetracker_Model_TimeaccountGrants::getTimeaccountGrants($_record)->toArray();
             foreach ($recordArray['grants'] as &$value) {
                 switch ($value['account_type']) {
                     case Tinebase_Acl_Rights::ACCOUNT_TYPE_USER:
                         $value['account_name'] = Tinebase_User::getInstance()->getUserById($value['account_id'])->toArray();
                         break;
                     case Tinebase_Acl_Rights::ACCOUNT_TYPE_GROUP:
                         $value['account_name'] = Tinebase_Group::getInstance()->getGroupById($value['account_id'])->toArray();
                         break;
                     case Tinebase_Acl_Rights::ACCOUNT_TYPE_ANYONE:
                         $value['account_name'] = array('accountDisplayName' => 'Anyone');
                         break;
                     default:
                         throw new Tinebase_Exception_InvalidArgument('Unsupported accountType.');
                         break;
                 }
             }
             break;
     }
     return $recordArray;
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:47,代码来源:Json.php

示例15: applyAclSql

 /**
  * Applies the requierd params for tags acl to the given select object
  * 
  * @param  Zend_Db_Select $_select
  * @param  string         $_right      required right
  * @param  string         $_idProperty property of tag id in select statement
  * @return void
  */
 public static function applyAclSql($_select, $_right = self::VIEW_RIGHT, $_idProperty = 'id')
 {
     if (empty($_right)) {
         throw new Tinebase_Exception_InvalidArgument('right is empty');
     }
     $db = Tinebase_Core::getDb();
     if ($_idProperty == 'id') {
         $_idProperty = $db->quoteIdentifier('id');
     }
     if (!is_object(Tinebase_Core::getUser())) {
         if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
             Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Cannot apply ACL, no user object found. This might happen during setup/update.');
         }
         return;
     }
     $currentAccountId = Tinebase_Core::getUser()->getId();
     $currentGroupIds = Tinebase_Group::getInstance()->getGroupMemberships($currentAccountId);
     $groupCondition = !empty($currentGroupIds) ? ' OR (' . $db->quoteInto($db->quoteIdentifier('acl.account_type') . ' = ?', Tinebase_Acl_Rights::ACCOUNT_TYPE_GROUP) . ' AND ' . $db->quoteInto($db->quoteIdentifier('acl.account_id') . ' IN (?)', $currentGroupIds) . ' )' : '';
     $where = $db->quoteInto($db->quoteIdentifier('acl.account_type') . ' = ?', Tinebase_Acl_Rights::ACCOUNT_TYPE_ANYONE) . ' OR (' . $db->quoteInto($db->quoteIdentifier('acl.account_type') . ' = ?', Tinebase_Acl_Rights::ACCOUNT_TYPE_USER) . ' AND ' . $db->quoteInto($db->quoteIdentifier('acl.account_id') . ' = ?', $currentAccountId) . ' ) ' . $groupCondition;
     $_select->join(array('acl' => SQL_TABLE_PREFIX . 'tags_acl'), $_idProperty . ' = ' . $db->quoteIdentifier('acl.tag_id'), array())->where($where)->where($db->quoteIdentifier('acl.account_right') . ' = ?', $_right);
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:29,代码来源:TagRight.php


注:本文中的Tinebase_Group::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。