本文整理汇总了PHP中Tinebase_Container类的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Container类的具体用法?PHP Tinebase_Container怎么用?PHP Tinebase_Container使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tinebase_Container类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
/**
* the singleton pattern
*
* @return Tinebase_Container
*/
public static function getInstance()
{
if (self::$_instance === NULL) {
self::$_instance = new Tinebase_Container();
}
return self::$_instance;
}
示例2: testTimeaccountContractFilter
/**
* test timeaccount - sales contract filter
* also tests Tinebase_Model_Filter_ExplicitRelatedRecord
*/
public function testTimeaccountContractFilter()
{
$this->_getTimeaccount(array('title' => 'TA1', 'number' => 12345, 'description' => 'UnitTest'), true);
$ta1 = $this->_timeaccountController->get($this->_lastCreatedRecord['id']);
$this->_getTimeaccount(array('title' => 'TA2', 'number' => 12346, 'description' => 'UnitTest'), true);
$ta2 = $this->_timeaccountController->get($this->_lastCreatedRecord['id']);
$cId = Tinebase_Container::getInstance()->getDefaultContainer('Sales_Model_Contract')->getId();
$contract = Sales_Controller_Contract::getInstance()->create(new Sales_Model_Contract(array('title' => 'testRelateTimeaccount', 'number' => Tinebase_Record_Abstract::generateUID(), 'container_id' => $cId)));
$ta1->relations = array($this->_getRelation($contract, $ta1));
$this->_timeaccountController->update($ta1);
// search by contract
$f = new Timetracker_Model_TimeaccountFilter(array(array('field' => 'contract', 'operator' => 'AND', 'value' => array(array('field' => ':id', 'operator' => 'equals', 'value' => $contract->getId())))));
$filterArray = $f->toArray();
$this->assertEquals($contract->getId(), $filterArray[0]['value'][0]['value']['id']);
$result = $this->_timeaccountController->search($f);
$this->assertEquals(1, $result->count());
$this->assertEquals('TA1', $result->getFirstRecord()->title);
// test empty filter (without contract)
$f = new Timetracker_Model_TimeaccountFilter(array(array('field' => 'contract', 'operator' => 'AND', 'value' => array(array('field' => ':id', 'operator' => 'equals', 'value' => null))), array('field' => 'description', 'operator' => 'equals', 'value' => 'UnitTest')));
$result = $this->_timeaccountController->search($f);
$this->assertEquals(1, $result->count(), 'Only one record should have been found!');
$this->assertEquals('TA2', $result->getFirstRecord()->title);
// test generic relation filter
$f = new Timetracker_Model_TimeaccountFilter(array(array('field' => 'foreignRecord', 'operator' => 'AND', 'value' => array('appName' => 'Sales', 'linkType' => 'relation', 'modelName' => 'Contract', 'filters' => array('field' => 'query', 'operator' => 'contains', 'value' => 'TA1')))));
$result = $this->_timeaccountController->search($f);
$this->assertEquals(1, $result->count());
$this->assertEquals('TA1', $result->getFirstRecord()->title);
// test "not" operator
$f = new Timetracker_Model_TimeaccountFilter(array(array('field' => 'contract', 'operator' => 'AND', 'value' => array(array('field' => ':id', 'operator' => 'not', 'value' => $contract->getId()))), array('field' => 'description', 'operator' => 'equals', 'value' => 'UnitTest')));
$result = $this->_timeaccountController->search($f);
// TODO is this correct? do we expect the timaccount without contract to be missing from results?
$this->assertEquals(0, $result->count(), 'No record should be found');
}
示例3: tearDown
/**
* tear down tests
*/
protected function tearDown()
{
parent::tearDown();
if ($this->_testContainer) {
Tinebase_Container::getInstance()->deleteContainer($this->_testContainer);
}
}
示例4: setUp
/**
* Sets up the fixture.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
$GLOBALS['Addressbook_Backend_SqlTest'] = array_key_exists('Addressbook_Backend_SqlTest', $GLOBALS) ? $GLOBALS['Addressbook_Backend_SqlTest'] : array();
$this->_backend = Addressbook_Backend_Factory::factory(Addressbook_Backend_Factory::SQL);
$personalContainer = Tinebase_Container::getInstance()->getPersonalContainer(Zend_Registry::get('currentAccount'), 'Addressbook', Zend_Registry::get('currentAccount'), Tinebase_Model_Grants::GRANT_EDIT);
$container = $personalContainer[0];
$this->objects['initialContact'] = 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', 'assistent' => 'Cornelius Weiß', 'bday' => '1975-01-02 03:04:05', 'email' => 'unittests@tine20.org', 'email_home' => 'unittests@tine20.org', 'jpegphoto' => file_get_contents(dirname(__FILE__) . '/../../Tinebase/ImageHelper/phpunit-logo.gif'), 'note' => 'Bla Bla Bla', 'container_id' => $container->id, 'role' => 'Role', 'title' => 'Title', 'url' => 'http://www.tine20.org', 'url_home' => 'http://www.tine20.com', 'n_family' => 'Kneschke', 'n_fileas' => 'Kneschke, Lars', 'n_given' => 'Lars', 'n_middle' => 'no middle name', 'n_prefix' => 'no prefix', 'n_suffix' => 'no suffix', 'org_name' => 'Metaways Infosystems GmbH', 'org_unit' => 'Tine 2.0', 'tel_assistent' => '+49TELASSISTENT', 'tel_car' => '+49TELCAR', 'tel_cell' => '+49TELCELL', 'tel_cell_private' => '+49TELCELLPRIVATE', 'tel_fax' => '+49TELFAX', 'tel_fax_home' => '+49TELFAXHOME', 'tel_home' => '+49TELHOME', 'tel_pager' => '+49TELPAGER', 'tel_work' => '+49TELWORK'));
$this->objects['updatedContact'] = 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', 'assistent' => 'Cornelius Weiß', 'bday' => '1975-01-02 03:04:05', 'email' => 'unittests@tine20.org', 'email_home' => 'unittests@tine20.org', 'note' => 'Bla Bla Bla', 'container_id' => $container->id, 'role' => 'Role', 'title' => 'Title', 'url' => 'http://www.tine20.org', 'url_home' => 'http://www.tine20.com', 'n_family' => 'Kneschke', 'n_fileas' => 'Kneschke, Lars', 'n_given' => 'Lars', 'n_middle' => 'no middle name', 'n_prefix' => 'no prefix', 'n_suffix' => 'no suffix', 'org_name' => 'Metaways Infosystems GmbH', 'org_unit' => 'Tine 2.0', 'tel_assistent' => '+49TELASSISTENT', 'tel_car' => '+49TELCAR', 'tel_cell' => '+49TELCELL', 'tel_cell_private' => '+49TELCELLPRIVATE', 'tel_fax' => '+49TELFAX', 'tel_fax_home' => '+49TELFAXHOME', 'tel_home' => '+49TELHOME', 'tel_pager' => '+49TELPAGER', 'tel_work' => '+49TELWORK'));
return;
$this->expectFailure['TestRecord']['testSetId'][] = array('2', '3');
$this->expectFailure['TestRecord']['testSetId'][] = array('30000000', '3000000000000000000000000000');
$this->expectSuccess['TestRecord']['testSetId'][] = array('2', '2');
$this->expectFailure['TestRecordBypassFilters']['testSetIdBypassFilters'][] = array('2', '3');
$this->expectFailure['TestRecordBypassFilters']['testSetIdBypassFilters'][] = array('30000000', '3000000000000000000000000000');
$this->expectSuccess['TestRecordBypassFilters']['testSetIdBypassFilters'][] = array('2', '2');
$this->expectSuccess['TestRecord']['testSetFromArray'][] = array(array('test_1' => '2', 'test_2' => NULL), 'test_1');
$this->expectFailure['TestRecord']['testSetFromArrayException'][] = array('Tinebase_Exception_Record_Validation', array('test_2' => 'string'));
$this->expectFailure['TestRecord']['testSetTimezoneException'][] = array('Exception', 'UTC');
$dummy = array('test_id' => 2, 'test_2' => '', 'date_single' => $date->get(Tinebase_Record_Abstract::ISO8601LONG), 'date_multiple' => '');
$this->expectSuccess['TestRecord']['testToArray'][] = array($dummy);
$this->expectSuccess['TestRecord']['__set'][] = array('test_3', 4);
$this->expectSuccess['TestRecord']['__get'][] = array('test_3', 4);
$this->expectSuccess['TestRecord']['test__isset'][] = array('test_id');
$this->expectFailure['TestRecord']['test__isset'][] = array('string');
$this->expectFailure['TestRecord']['test__setException'][] = array('UnexpectedValueException', 'test_100');
$this->expectFailure['TestRecord']['test__getException'][] = array('UnexpectedValueException', 'test_100');
$this->expectFailure['TestRecord']['testOffsetUnset'][] = array('Tinebase_Exception_Record_NotAllowed', 'test_2');
}
示例5: initTestUsers
/**
* inits (adds) some test users
*
*/
public function initTestUsers()
{
$personas = array('jsmith' => 'John Smith', 'sclever' => 'Susan Clever', 'pwulf' => 'Paul Wulf', 'jmcblack' => 'James McBlack', 'rwright' => 'Roberta Wright');
foreach ($personas as $login => $fullName) {
try {
$user = Tinebase_User::getInstance()->getFullUserByLoginName($login);
} catch (Tinebase_Exception_NotFound $e) {
list($given, $last) = explode(' ', $fullName);
$group = Tinebase_Group::getInstance()->getGroupByName('Users');
$groupId = $group->getId();
$user = new Tinebase_Model_FullUser(array('accountLoginName' => $login, 'accountPrimaryGroup' => $groupId, 'accountDisplayName' => $fullName, 'accountLastName' => $last, 'accountFirstName' => $given, 'accountFullName' => $fullName, 'accountEmailAddress' => $login . '@tine20.org'));
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();
}
$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);
}
// give additional testusers the same password as the primary test account
Tinebase_User::getInstance()->setPassword($user, Zend_Registry::get('testConfig')->password);
}
$personas[$login] = $user;
}
Zend_Registry::set('personas', $personas);
}
示例6: repairGroups
/**
* repair groups
*
* * add missing lists
* * checks if list container has been deleted (and hides groups if that's the case)
*
* @see 0010401: add repair script for groups without list_ids
*/
public function repairGroups()
{
$count = 0;
$be = new Tinebase_Group_Sql();
$listBackend = new Addressbook_Backend_List();
$groups = $be->getGroups();
foreach ($groups as $group) {
if ($group->list_id == null) {
$list = Addressbook_Controller_List::getInstance()->createByGroup($group);
$group->list_id = $list->getId();
$group->visibility = Tinebase_Model_Group::VISIBILITY_DISPLAYED;
if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Add missing list for group ' . $group->name);
}
$be->updateGroupInSqlBackend($group);
$count++;
} else {
if ($group->visibility === Tinebase_Model_Group::VISIBILITY_DISPLAYED) {
try {
$list = $listBackend->get($group->list_id);
$listContainer = Tinebase_Container::getInstance()->get($list->container_id);
} catch (Tinebase_Exception_NotFound $tenf) {
if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Hide group ' . $group->name . ' without list / list container.');
}
$group->visibility = Tinebase_Model_Group::VISIBILITY_HIDDEN;
$be->updateGroupInSqlBackend($group);
$count++;
}
}
}
}
echo $count . " groups repaired!\n";
}
示例7: setCalendarProperties
public function setCalendarProperties(Tinebase_Model_Container $calendarContainer, array $calendar)
{
if (isset($calendar['color']) && $calendarContainer->color !== $calendar['color']) {
$calendarContainer->color = $calendar['color'];
Tinebase_Container::getInstance()->update($calendarContainer);
}
}
示例8: setUp
/**
* Sets up the fixture.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
$this->_backend = Addressbook_Backend_Factory::factory(Addressbook_Backend_Factory::SQL);
$personalContainer = Tinebase_Container::getInstance()->getPersonalContainer(Zend_Registry::get('currentAccount'), 'Addressbook', Zend_Registry::get('currentAccount'), Tinebase_Model_Grants::GRANT_EDIT);
$this->_container = $personalContainer[0];
}
示例9: setUp
/**
* Sets up the fixture.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
$_SERVER['HTTP_USER_AGENT'] = 'FooBar User Agent';
Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
Addressbook_Controller_Contact::getInstance()->setGeoDataForContacts(FALSE);
$this->objects['initialContainer'] = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array('name' => Tinebase_Record_Abstract::generateUID(), 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Addressbook')->getId())));
}
示例10: testAddFaq
/**
* try to add a faq record
*
* @return array
*/
public function testAddFaq()
{
$faq = new SimpleFAQ_Model_Faq(array('answer' => 'was geht?', 'question' => 'einiges', 'container_id' => Tinebase_Container::getInstance()->getDefaultContainer('SimpleFAQ_Model_Faq')->getId()));
$result = $this->_instance->saveFaq($faq->toArray());
$this->assertEquals($faq->question, $result['question']);
return $result;
}
示例11: setUp
/**
* Sets up the fixture.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
$this->objects['initialContainer'] = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array('name' => Tinebase_Record_Abstract::generateUID(), 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId())));
Tinebase_Container::getInstance()->addGrants($this->objects['initialContainer'], Tinebase_Acl_Rights::ACCOUNT_TYPE_GROUP, Tinebase_Core::getUser()->accountPrimaryGroup, array(Tinebase_Model_Grants::GRANT_READ));
// must be defined for Calendar/Frontend/WebDAV/Event.php
$_SERVER['REQUEST_URI'] = 'foobar';
}
示例12: testCreateDirectory
/**
* test to create a new directory
*/
public function testCreateDirectory()
{
$randomName = Tinebase_Record_Abstract::generateUID();
$collection = new Addressbook_Frontend_WebDAV(\Sabre\CardDAV\Plugin::ADDRESSBOOK_ROOT . '/' . Tinebase_Core::getUser()->contact_id, true);
$collection->createDirectory($randomName);
$container = Tinebase_Container::getInstance()->getContainerByName('Addressbook', $randomName, Tinebase_Model_Container::TYPE_PERSONAL, Tinebase_Core::getUser());
$this->assertTrue($container instanceof Tinebase_Model_Container);
}
示例13: fromTine20Model
/**
* converts Tinebase_Record_Abstract to external format
*
* @param Tinebase_Record_Abstract $_record
* @return mixed
*/
public function fromTine20Model(Tinebase_Record_Abstract $_record)
{
$jsonData = parent::fromTine20Model($_record);
if (Tinebase_Core::getUser()->hasRight('Calendar', Calendar_Acl_Rights::MANAGE_RESOURCES)) {
$jsonData['grants'] = Tinebase_Container::getInstance()->getGrantsOfContainer($_record->container_id, TRUE)->toArray();
$jsonData['grants'] = Tinebase_Frontend_Json_Container::resolveAccounts($jsonData['grants']);
}
return $jsonData;
}
示例14: setUp
/**
* Sets up the fixture.
* This method is called before a test is executed.
*/
public function setUp()
{
parent::setUp();
$this->objects['initialContainer'] = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array('name' => Tinebase_Record_Abstract::generateUID(), 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Tasks')->getId())));
$this->objects['sharedContainer'] = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array('name' => Tinebase_Record_Abstract::generateUID(), 'type' => Tinebase_Model_Container::TYPE_SHARED, 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Tasks')->getId())));
$prefs = new Tasks_Preference();
$prefs->setValue(Tasks_Preference::DEFAULTTASKLIST, $this->objects['initialContainer']->getId());
$_SERVER['REQUEST_URI'] = 'lars';
}
示例15: 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;
}