本文整理汇总了PHP中Tinebase_Application类的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Application类的具体用法?PHP Tinebase_Application怎么用?PHP Tinebase_Application使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tinebase_Application类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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())));
}
示例2: testSearchByRecord
/**
* test searching records by record as a customfield type
* https://forge.tine20.org/mantisbt/view.php?id=6730
*/
public function testSearchByRecord()
{
$cf = self::getCustomField(array('application_id' => Tinebase_Application::getInstance()->getApplicationByName('Addressbook')->getId(), 'model' => 'Addressbook_Model_Contact', 'definition' => array('type' => 'record', "recordConfig" => array("value" => array("records" => "Tine.Sales.Model.Contract")))));
$this->_instance->addCustomField($cf);
$contract = Sales_Controller_Contract::getInstance()->create(new Sales_Model_Contract(array('number' => Tinebase_Record_Abstract::generateUID(10), 'title' => Tinebase_Record_Abstract::generateUID(10), 'container_id' => Tinebase_Container::getInstance()->getDefaultContainer('Sales_Model_Contract')->getId())));
// contact1 with customfield record = contract
$contact1 = new Addressbook_Model_Contact(array('n_given' => 'Rita', 'n_family' => 'Blütenrein'));
$contact1->customfields = array($cf->name => $contract->getId());
$contact1 = Addressbook_Controller_Contact::getInstance()->create($contact1, false);
// contact2 with customfield record is not set -> should act like without this record
$contact2 = new Addressbook_Model_Contact(array('n_given' => 'Rainer', 'n_family' => 'Blütenrein'));
$contact2 = Addressbook_Controller_Contact::getInstance()->create($contact2, false);
$json = new Addressbook_Frontend_Json();
$result = $json->searchContacts(array(array("condition" => "OR", "filters" => array(array("condition" => "AND", "filters" => array(array("field" => "customfield", "operator" => "equals", "value" => array("cfId" => $cf->getId(), "value" => $contract->getId()))))))), array());
$this->assertEquals(1, $result['totalcount'], 'One Record should have been found where cf-record = contract (Rita Blütenrein)');
$this->assertEquals('Rita', $result['results'][0]['n_given'], 'The Record should be Rita Blütenrein');
$result = $json->searchContacts(array(array("condition" => "OR", "filters" => array(array("condition" => "AND", "filters" => array(array("field" => "customfield", "operator" => "not", "value" => array("cfId" => $cf->getId(), "value" => $contract->getId())), array('field' => 'n_family', 'operator' => 'equals', 'value' => 'Blütenrein')))))), array());
$this->assertEquals(1, $result['totalcount'], 'One Record should have been found where cf-record is not set (Rainer Blütenrein)');
$this->assertEquals('Rainer', $result['results'][0]['n_given'], 'The Record should be Rainer Blütenrein');
// search using the same cf filter in an or - filter
$contract2 = Sales_Controller_Contract::getInstance()->create(new Sales_Model_Contract(array('number' => Tinebase_Record_Abstract::generateUID(10), 'title' => Tinebase_Record_Abstract::generateUID(10), 'container_id' => Tinebase_Container::getInstance()->getDefaultContainer('Sales_Model_Contract')->getId())));
$contact2->customfields = array($cf->name => $contract2->getId());
$contact2 = Addressbook_Controller_Contact::getInstance()->update($contact2, false);
$result = $json->searchContacts(array(array("condition" => "OR", "filters" => array(array("condition" => "AND", "filters" => array(array("field" => "customfield", "operator" => "equals", "value" => array("cfId" => $cf->getId(), "value" => $contract->getId())))), array("condition" => "AND", "filters" => array(array("field" => "customfield", "operator" => "equals", "value" => array("cfId" => $cf->getId(), "value" => $contract2->getId()))))))), array());
$this->assertEquals(2, $result['totalcount'], 'Rainer and Rita should have been found.');
$this->assertEquals('Blütenrein', $result['results'][0]['n_family'], 'Rainer and Rita should have been found.');
$this->assertEquals('Blütenrein', $result['results'][1]['n_family'], 'Rainer and Rita should have been found.');
}
示例3: fromTine20Model
/**
* convert Tasks_Model_Task to \Sabre\VObject\Component
*
* @param Tasks_Model_Task $_record
* @return \Sabre\VObject\Component
*/
public function fromTine20Model(Tinebase_Record_Abstract $_record)
{
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' event ' . print_r($_record->toArray(), true));
}
$vcalendar = new \Sabre\VObject\Component\VCalendar();
// required vcalendar fields
$version = Tinebase_Application::getInstance()->getApplicationByName('Tasks')->version;
$vcalendar->PRODID = "-//tine20.com//Tine 2.0 Tasks V{$version}//EN";
$vcalendar->VERSION = '2.0';
$vcalendar->CALSCALE = 'GREGORIAN';
// catch exceptions for unknown timezones
try {
$vcalendar->add(new Sabre_VObject_Component_VTimezone($_record->originator_tz));
} catch (Exception $e) {
if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' timezone exception ' . $e->getMessage());
}
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' timezone exception ' . $e->getTraceAsString());
}
}
$this->_convertTasksModelTask($vcalendar, $_record);
$this->_afterFromTine20Model($vcalendar);
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' card ' . $vcalendar->serialize());
}
return $vcalendar;
}
示例4: testGetApplicationById
/**
* test get application by name and id
*
* @return void
*/
public function testGetApplicationById()
{
$admin = Tinebase_Application::getInstance()->getApplicationByName('Admin');
$adminById = Tinebase_Application::getInstance()->getApplicationById($admin->getId());
$this->assertTrue($adminById instanceof Tinebase_Model_Application);
$this->assertEquals($admin, $adminById);
}
示例5: setUp
/**
* Backend
*
* @var ExampleApplication_Frontend_Json
*/
public function setUp()
{
// enable courses app
Tinebase_Application::getInstance()->setApplicationState(array(Tinebase_Application::getInstance()->getApplicationByName('ExampleApplication')->getId()), Tinebase_Application::ENABLED);
parent::setUp();
$this->_json = new ExampleApplication_Frontend_Json();
}
示例6: _initializeFavorites
/**
* init favorites
*/
protected function _initializeFavorites()
{
$pfe = new Tinebase_PersistentFilter_Backend_Sql();
$commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('SimpleFAQ')->getId(), 'model' => 'SimpleFAQ_Model_FaqFilter');
$pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => SimpleFAQ_Preference::DEFAULTPERSISTENTFILTER_NAME, 'description' => "All FAQs of my FAQ Lists", 'filters' => array(array('field' => 'container_id', 'operator' => 'equals', 'value' => '/personal/' . Tinebase_Model_User::CURRENTACCOUNT))))));
$pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Last modified by me", 'description' => "All FAQs that I have last modified", 'filters' => array(array('field' => 'last_modified_by', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT))))));
}
示例7: _initializeKeyFields
/**
* init key fields
*/
protected function _initializeKeyFields()
{
// create status config
$cb = new Tinebase_Backend_Sql(array('modelName' => 'Tinebase_Model_Config', 'tableName' => 'config'));
$statusConfig = array('name' => ExampleApplication_Config::EXAMPLE_STATUS, 'records' => array(array('id' => 'COMPLETED', 'value' => 'Completed', 'is_open' => 0, 'icon' => 'images/oxygen/16x16/actions/ok.png', 'system' => true), array('id' => 'CANCELLED', 'value' => 'Cancelled', 'is_open' => 0, 'icon' => 'images/oxygen/16x16/actions/dialog-cancel.png', 'system' => true), array('id' => 'IN-PROCESS', 'value' => 'In process', 'is_open' => 1, 'icon' => 'images/oxygen/16x16/actions/view-refresh.png', 'system' => true)));
$cb->create(new Tinebase_Model_Config(array('application_id' => Tinebase_Application::getInstance()->getApplicationByName('ExampleApplication')->getId(), 'name' => ExampleApplication_Config::EXAMPLE_STATUS, 'value' => json_encode($statusConfig))));
}
示例8: _updateLeadConfig
protected function _updateLeadConfig()
{
// get all configs for crm from DB
$crmApp = Tinebase_Application::getInstance()->getApplicationByName('Crm');
// either put default to DB or delete form DB
$cb = new Tinebase_Backend_Sql(array('modelName' => 'Tinebase_Model_Config', 'tableName' => 'config'));
$configRecords = $cb->search(new Tinebase_Model_ConfigFilter(array(array('field' => 'application_id', 'operator' => 'equals', 'value' => $crmApp->getId()))));
$appDefaults = $configRecords->filter('name', 'appdefaults')->getFirstRecord();
foreach (array('leadstate', 'leadtype', 'leadsource') as $oldValueName) {
$keyFieldName = $oldValueName . 's';
$DBconfig = $configRecords->filter('name', $keyFieldName)->getFirstRecord();
// only update if custom config is found and if it is still in old format
if ($DBconfig && strpos($DBconfig->value, $oldValueName) !== false) {
$decodedConfig = json_decode($DBconfig->value, true);
foreach ($decodedConfig as $key => $oldRecord) {
$decodedConfig[$key]['value'] = $oldRecord[$oldValueName];
unset($decodedConfig[$key][$oldValueName]);
}
// if no app defaults: use the first record as default
$default = isset($appDefaults[$keyFieldName]) ? $appDefaults[$keyFieldName] : $decodedConfig[0]['id'];
$DBconfig->value = json_encode(array('records' => $decodedConfig, 'default' => $default));
$cb->update($DBconfig);
}
}
if ($appDefaults) {
$cb->delete($appDefaults->getId());
}
}
示例9: _initializeFavorites
/**
* init the default persistentfilters
*/
protected function _initializeFavorites()
{
$pfe = Tinebase_PersistentFilter::getInstance();
$commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Inventory')->getId(), 'model' => 'Inventory_Model_InventoryItemFilter');
// default persistent filter for all records
$pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "All Inventory Items", 'description' => "All existing Inventory Items", 'filters' => array()))));
}
示例10: setUp
/**
* Sets up the fixture.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
parent::setUp();
$this->_json = new Filemanager_Frontend_Json();
$this->_fsController = Tinebase_FileSystem::getInstance();
$this->_application = Tinebase_Application::getInstance()->getApplicationByName('Filemanager');
}
示例11: update_0
/**
* update to 5.1
* @return void
*/
public function update_0()
{
$pfe = Tinebase_PersistentFilter::getInstance();
$commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Courses')->getId(), 'model' => 'Courses_Model_CourseFilter');
$pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => Courses_Preference::DEFAULTPERSISTENTFILTER_NAME, 'description' => "All courses", 'filters' => array(array('field' => 'is_deleted', 'operator' => 'equals', 'value' => '0'))))));
$this->setApplicationVersion('Courses', '5.1');
}
示例12: _initializeKeyFields
/**
* init favorites
*/
protected function _initializeKeyFields()
{
$cb = new Tinebase_Backend_Sql(array('modelName' => 'Tinebase_Model_Config', 'tableName' => 'config'));
$attendeeRolesConfig = array('name' => Calendar_Config::ATTENDEE_ROLES, 'records' => array(array('id' => 'REQ', 'value' => 'Required', 'system' => true), array('id' => 'OPT', 'value' => 'Optional', 'system' => true)));
$cb->create(new Tinebase_Model_Config(array('application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(), 'name' => Calendar_Config::ATTENDEE_ROLES, 'value' => json_encode($attendeeRolesConfig))));
$attendeeStatusConfig = array('name' => Calendar_Config::ATTENDEE_STATUS, 'records' => array(array('id' => 'NEEDS-ACTION', 'value' => 'No response', 'icon' => 'images/oxygen/16x16/actions/mail-mark-unread-new.png', 'system' => true), array('id' => 'ACCEPTED', 'value' => 'Accepted', 'icon' => 'images/oxygen/16x16/actions/ok.png', 'system' => true), array('id' => 'DECLINED', 'value' => 'Declined', 'icon' => 'images/oxygen/16x16/actions/dialog-cancel.png', 'system' => true), array('id' => 'TENTATIVE', 'value' => 'Tentative', 'icon' => 'images/calendar-response-tentative.png', 'system' => true)));
$cb->create(new Tinebase_Model_Config(array('application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(), 'name' => Calendar_Config::ATTENDEE_STATUS, 'value' => json_encode($attendeeStatusConfig))));
}
示例13: createScheduledImport
/**
* Test create a scheduled import
*/
public function createScheduledImport($source = 'http://localhost/test.ics')
{
$id = Tinebase_Record_Abstract::generateUID();
$import = new Tinebase_Model_Import(array('id' => $id, 'user_id' => $this->_originalTestUser->getId(), 'interval' => Tinebase_Model_Import::INTERVAL_HOURLY, 'model' => Calendar_Controller::getInstance()->getDefaultModel(), 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(), 'container_id' => $this->_testCalendar->getId(), 'sourcetype' => Tinebase_Model_Import::SOURCETYPE_REMOTE, 'source' => $source, 'options' => json_encode(array('forceUpdateExisting' => TRUE, 'import_defintion' => NULL, 'plugin' => 'Calendar_Import_Ical'))));
$record = $this->_uit->create($import);
$this->assertEquals(Calendar_Controller::getInstance()->getDefaultModel(), $this->_uit->get($id)->model);
return $record;
}
示例14: 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->_json = new Filemanager_Frontend_Json();
$this->_fsController = Tinebase_FileSystem::getInstance();
$this->_application = Tinebase_Application::getInstance()->getApplicationByName('Filemanager');
$this->_setupTestContainers();
}
示例15: 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';
}