本文整理汇总了PHP中Tinebase_Exception类的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Exception类的具体用法?PHP Tinebase_Exception怎么用?PHP Tinebase_Exception使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tinebase_Exception类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
public function validate($username, $password)
{
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Options: ' . print_r($this->_options, true));
}
$url = isset($this->_options['url']) ? $this->_options['url'] : 'https://localhost/validate/check';
$adapter = new Zend_Http_Client_Adapter_Socket();
$adapter->setStreamContext($this->_options = array('ssl' => array('verify_peer' => isset($this->_options['ignorePeerName']) ? false : true, 'allow_self_signed' => isset($this->_options['allowSelfSigned']) ? true : false)));
$client = new Zend_Http_Client($url, array('maxredirects' => 0, 'timeout' => 30));
$client->setAdapter($adapter);
$params = array('user' => $username, 'pass' => $password);
$client->setParameterPost($params);
try {
$response = $client->request(Zend_Http_Client::POST);
} catch (Zend_Http_Client_Adapter_Exception $zhcae) {
Tinebase_Exception::log($zhcae);
return Tinebase_Auth::FAILURE;
}
$body = $response->getBody();
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Request: ' . $client->getLastRequest());
}
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Response: ' . $body);
}
if ($response->getStatus() !== 200) {
return Tinebase_Auth::FAILURE;
}
$result = Tinebase_Helper::jsonDecode($body);
if (isset($result['result']) && $result['result']['status'] === true && $result['result']['value'] === true) {
return Tinebase_Auth::SUCCESS;
} else {
return Tinebase_Auth::FAILURE;
}
}
示例2: getCoreData
public function getCoreData()
{
try {
$result = CoreData_Controller::getInstance()->getCoreData()->toArray();
} catch (Exception $e) {
Tinebase_Exception::log($e);
$result = array();
}
return array('results' => $result, 'totalcount' => count($result));
}
示例3: update_1
/**
* update to 7.2
* - add uid field
*/
public function update_1()
{
$this->validateTableVersion('tasks', 6);
// first add with notnull == false ...
$declaration = new Setup_Backend_Schema_Field_Xml('
<field>
<name>uid</name>
<type>text</type>
<length>255</length>
<notnull>false</notnull>
</field>
');
try {
$this->_backend->addCol('tasks', $declaration);
} catch (Exception $e) {
Tinebase_Exception::log($e);
}
$tasksBackend = new Tinebase_Backend_Sql(array('modelName' => 'Tasks_Model_Task', 'tableName' => 'tasks'));
$allTasks = $tasksBackend->getAll();
// add uid to all tasks
foreach ($allTasks as $task) {
$task->uid = $task->id;
if (empty($task->status)) {
$task->status = 'UNKNOWN';
}
$tasksBackend->update($task);
}
// ... now set notnull to true
$declaration = new Setup_Backend_Schema_Field_Xml('
<field>
<name>uid</name>
<type>text</type>
<length>255</length>
<notnull>true</notnull>
</field>
');
$this->_backend->alterCol('tasks', $declaration);
$declaration = new Setup_Backend_Schema_Index_Xml('
<index>
<name>uid--id</name>
<field>
<name>uid</name>
</field>
<field>
<name>id</name>
</field>
</index>
');
$this->_backend->addIndex('tasks', $declaration);
$this->setTableVersion('tasks', 7);
$this->setApplicationVersion('Tasks', '7.2');
}
示例4: _createGroups
/**
* creates the groups if not created already
*/
protected function _createGroups()
{
$fe = new Admin_Frontend_Json();
$internalAddressbook = Tinebase_Container::getInstance()->getContainerByName('Addressbook', 'Internal Contacts', Tinebase_Model_Container::TYPE_SHARED);
foreach ($this->_groups as $groupArray) {
$groupArray['container_id'] = $internalAddressbook->getId();
$members = array();
foreach ($groupArray['groupMembers'] as $member) {
$members[] = $this->_personas[$member]->getId();
}
try {
$this->_groups[$groupArray['groupData']['name']] = $fe->saveGroup($groupArray['groupData'], $members);
} catch (Exception $e) {
Tinebase_Exception::log($e);
echo 'Group "' . $groupArray['groupData']['name'] . '" already exists. Skipping...' . PHP_EOL;
$gr = Tinebase_Group::getInstance()->getGroupByName($groupArray['groupData']['name']);
$this->_groups[$groupArray['groupData']['name']] = $fe->getGroup($gr->getId());
}
}
}
示例5: fromTine20RecordSet
/**
* convert Tinebase_Record_RecordSet to Sabre\VObject\Component
*
* @param Tinebase_Record_RecordSet $_records
* @return Sabre\VObject\Component
*/
public function fromTine20RecordSet(Tinebase_Record_RecordSet $_records)
{
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Events: ' . print_r($_records->toArray(), true));
}
// required vcalendar fields
$version = Tinebase_Application::getInstance()->getApplicationByName('Calendar')->version;
$vcalendar = new \Sabre\VObject\Component\VCalendar(array('PRODID' => "-//tine20.com//Tine 2.0 Calendar V{$version}//EN", 'VERSION' => '2.0', 'CALSCALE' => 'GREGORIAN'));
if (isset($this->_method)) {
$vcalendar->add('METHOD', $this->_method);
}
$originatorTz = $_records->getFirstRecord() ? $_records->getFirstRecord()->originator_tz : NULL;
if (empty($originatorTz)) {
throw new Tinebase_Exception_Record_Validation('originator_tz needed for conversion to Sabre\\VObject\\Component');
}
try {
$vcalendar->add(new Sabre_VObject_Component_VTimezone($originatorTz));
} catch (Exception $e) {
Tinebase_Exception::log($e);
throw new Tinebase_Exception_Record_Validation('Bad Timezone: ' . $originatorTz);
}
foreach ($_records as $_record) {
$this->_convertCalendarModelEvent($vcalendar, $_record);
if ($_record->exdate instanceof Tinebase_Record_RecordSet) {
$_record->exdate->addIndices(array('is_deleted'));
$eventExceptions = $_record->exdate->filter('is_deleted', false);
foreach ($eventExceptions as $eventException) {
$this->_convertCalendarModelEvent($vcalendar, $eventException, $_record);
}
}
}
$this->_afterFromTine20Model($vcalendar);
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' card ' . $vcalendar->serialize());
}
return $vcalendar;
}
示例6: handle
/**
* (non-PHPdoc)
* @see Tinebase_Server_Interface::handle()
*/
public function handle(\Zend\Http\Request $request = null, $body = null)
{
$this->_request = $request instanceof \Zend\Http\Request ? $request : Tinebase_Core::get(Tinebase_Core::REQUEST);
$this->_body = $this->_getBody($body);
try {
list($loginName, $password) = $this->_getAuthData($this->_request);
} catch (Tinebase_Exception_NotFound $tenf) {
header('WWW-Authenticate: Basic realm="ActiveSync for Tine 2.0"');
header('HTTP/1.1 401 Unauthorized');
return;
}
if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' is ActiveSync request.');
}
Tinebase_Core::initFramework();
try {
$authResult = $this->_authenticate($loginName, $password, $this->_request);
} catch (Exception $e) {
Tinebase_Exception::log($e);
$authResult = false;
}
if ($authResult !== true) {
header('WWW-Authenticate: Basic realm="ActiveSync for Tine 2.0"');
header('HTTP/1.1 401 Unauthorized');
return;
}
if (!$this->_checkUserPermissions($loginName)) {
return;
}
$this->_initializeRegistry();
$request = new Zend_Controller_Request_Http();
$request->setRequestUri($this->_request->getRequestUri());
$syncFrontend = new Syncroton_Server(Tinebase_Core::getUser()->accountId, $request, $this->_body);
$syncFrontend->handle();
Tinebase_Controller::getInstance()->logout();
}
示例7: _createSetupuser
/**
* create new setupuser
*
* @return Tinebase_Model_FullUser|null
*/
protected function _createSetupuser()
{
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Creating new setupuser.');
}
$adminGroup = Tinebase_Group::getInstance()->getDefaultAdminGroup();
$setupUser = new Tinebase_Model_FullUser(array('accountLoginName' => 'setupuser', 'accountStatus' => Tinebase_Model_User::ACCOUNT_STATUS_DISABLED, 'visibility' => Tinebase_Model_FullUser::VISIBILITY_HIDDEN, 'accountPrimaryGroup' => $adminGroup->getId(), 'accountLastName' => 'setupuser', 'accountDisplayName' => 'setupuser', 'accountExpires' => NULL));
try {
$setupUser = Tinebase_User::getInstance()->addUser($setupUser);
Tinebase_Group::getInstance()->addGroupMember($setupUser->accountPrimaryGroup, $setupUser->getId());
} catch (Exception $e) {
// no setup user could be created
// TODO we should try to fetch an admin user here (see Sales_Setup_Update_Release8::_updateContractsFields)
Tinebase_Exception::log($e);
$setupUser = null;
}
return $setupUser;
}
示例8: sendPendingAlarms
/**
* send pending alarms
*
* @param mixed $_eventName
* @return void
*
* @todo sort alarms (by model/...)?
* @todo what to do about Tinebase_Model_Alarm::STATUS_FAILURE alarms?
*/
public function sendPendingAlarms($_eventName)
{
$eventName = is_array($_eventName) ? $_eventName['eventName'] : $_eventName;
$job = Tinebase_AsyncJob::getInstance()->startJob($eventName);
if (!$job) {
return;
}
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' No ' . $eventName . ' is running. Starting new one.');
}
try {
// get all pending alarms
$filter = new Tinebase_Model_AlarmFilter(array(array('field' => 'alarm_time', 'operator' => 'before', 'value' => Tinebase_DateTime::now()->subMinute(1)->get(Tinebase_Record_Abstract::ISO8601LONG)), array('field' => 'sent_status', 'operator' => 'equals', 'value' => Tinebase_Model_Alarm::STATUS_PENDING)));
$limit = Tinebase_Config::getInstance()->get(Tinebase_Config::ALARMS_EACH_JOB, 100);
$pagination = $limit > 0 ? new Tinebase_Model_Pagination(array('limit' => $limit)) : null;
$alarms = $this->_backend->search($filter, $pagination);
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Sending ' . count($alarms) . ' alarms (limit: ' . $limit . ').');
}
// loop alarms and call sendAlarm in controllers
foreach ($alarms as $alarm) {
list($appName, $i, $itemName) = explode('_', $alarm->model);
$appController = Tinebase_Core::getApplicationInstance($appName, $itemName);
if ($appController instanceof Tinebase_Controller_Alarm_Interface) {
$alarm->sent_time = Tinebase_DateTime::now();
try {
// NOTE: we set the status here, so controller can adopt the status itself
$alarm->sent_status = Tinebase_Model_Alarm::STATUS_SUCCESS;
$appController->sendAlarm($alarm);
} catch (Exception $e) {
Tinebase_Exception::log($e);
$alarm->sent_message = $e->getMessage();
$alarm->sent_status = Tinebase_Model_Alarm::STATUS_FAILURE;
}
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Updating alarm status: ' . $alarm->sent_status);
}
$this->update($alarm);
}
}
$job = Tinebase_AsyncJob::getInstance()->finishJob($job);
} catch (Exception $e) {
// save new status 'failure'
$job = Tinebase_AsyncJob::getInstance()->finishJob($job, Tinebase_Model_AsyncJob::STATUS_FAILURE, $e->getMessage());
if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Job failed: ' . $e->getMessage());
}
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . $e->getTraceAsString());
}
}
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Job ' . $eventName . ' finished.');
}
}
示例9: _getImportDefinitionRegistryData
/**
* fetch import definition data
*
* @return array
*/
protected function _getImportDefinitionRegistryData()
{
$definitionConverter = new Tinebase_Convert_ImportExportDefinition_Json();
$importDefinitions = $this->_getImportDefinitions();
$defaultDefinition = $this->_getDefaultImportDefinition($importDefinitions);
try {
$defaultDefinitionArray = $definitionConverter->fromTine20Model($defaultDefinition);
} catch (Exception $e) {
Tinebase_Exception::log($e);
$defaultDefinitionArray = array();
}
try {
$definitionsArray = $definitionConverter->fromTine20RecordSet($importDefinitions);
} catch (Exception $e) {
Tinebase_Exception::log($e);
$definitionsArray = array();
}
$definitionData = array('defaultImportDefinition' => $defaultDefinitionArray, 'importDefinitions' => array('results' => $definitionsArray, 'totalcount' => count($definitionsArray)));
return $definitionData;
}
示例10: testDuplicateException
/**
* Tests the duplicate check
*/
public function testDuplicateException()
{
$e = $this->_getEmployee();
$e->contracts = array($this->_getContract()->toArray());
$savedEmployee = $this->_json->saveEmployee($e->toArray());
$exception = new Tinebase_Exception();
try {
$e = $this->_getEmployee();
$e->contracts = array($this->_getContract()->toArray());
$savedEmployee = $this->_json->saveEmployee($e->toArray());
} catch (Tinebase_Exception_Duplicate $exception) {
}
$this->assertEquals($exception->getCode(), 629);
}
示例11: _addEmailNote
/**
* add email notes to contacts with email addresses in $_recipients
*
* @param array $_recipients
* @param string $_subject
*
* @todo add email home (when we have OR filters)
* @todo add link to message in sent folder?
*/
protected function _addEmailNote($_recipients, $_subject, $_body)
{
$filter = new Addressbook_Model_ContactFilter(array(array('field' => 'email', 'operator' => 'in', 'value' => $_recipients)));
$contacts = Addressbook_Controller_Contact::getInstance()->search($filter);
if (count($contacts)) {
$translate = Tinebase_Translation::getTranslation($this->_applicationName);
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Adding email notes to ' . count($contacts) . ' contacts.');
$truncatedBody = extension_loaded('mbstring') ? mb_substr($_body, 0, 4096, 'UTF-8') : substr($_body, 0, 4096);
$noteText = $translate->_('Subject') . ':' . $_subject . "\n\n" . $translate->_('Body') . ': ' . $truncatedBody;
try {
foreach ($contacts as $contact) {
$note = new Tinebase_Model_Note(array('note_type_id' => Tinebase_Notes::getInstance()->getNoteTypeByName('email')->getId(), 'note' => $noteText, 'record_id' => $contact->getId(), 'record_model' => 'Addressbook_Model_Contact'));
Tinebase_Notes::getInstance()->addNote($note);
}
} catch (Zend_Db_Statement_Exception $zdse) {
Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . ' Saving note failed: ' . $noteText);
Tinebase_Exception::log($zdse);
}
} else {
Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' Found no contacts to add notes to.');
}
}
示例12: _installApplication
/**
* install given application
*
* @param SimpleXMLElement $_xml
* @param array | optional $_options
* @return void
* @throws Tinebase_Exception_Backend_Database
*/
protected function _installApplication(SimpleXMLElement $_xml, $_options = null)
{
if ($this->_backend === NULL) {
throw new Tinebase_Exception_Backend_Database('Need configured and working database backend for install.');
}
try {
if (Setup_Core::isLogLevel(Zend_Log::INFO)) {
Setup_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Installing application: ' . $_xml->name);
}
$createdTables = array();
// traditional xml declaration
if (isset($_xml->tables)) {
foreach ($_xml->tables[0] as $tableXML) {
$table = Setup_Backend_Schema_Table_Factory::factory('Xml', $tableXML);
$this->_createTable($table);
$createdTables[] = $table;
}
} else {
$application = Setup_Core::getApplicationInstance($_xml->name, '', true);
$models = $application->getModels(true);
if (count($models) > 0) {
// create tables using doctrine 2
Setup_SchemaTool::createSchema($_xml->name, $models);
// adopt to old workflow
foreach ($models as $model) {
$modelConfiguration = $model::getConfiguration();
$createdTables[] = (object) array('name' => Tinebase_Helper::array_value('name', $modelConfiguration->getTable()), 'version' => $modelConfiguration->getVersion());
}
}
}
$application = new Tinebase_Model_Application(array('name' => (string) $_xml->name, 'status' => $_xml->status ? (string) $_xml->status : Tinebase_Application::ENABLED, 'order' => $_xml->order ? (string) $_xml->order : 99, 'version' => (string) $_xml->version));
$application = Tinebase_Application::getInstance()->addApplication($application);
// keep track of tables belonging to this application
foreach ($createdTables as $table) {
Tinebase_Application::getInstance()->addApplicationTable($application, (string) $table->name, (int) $table->version);
}
// insert default records
if (isset($_xml->defaultRecords)) {
foreach ($_xml->defaultRecords[0] as $record) {
$this->_backend->execInsertStatement($record);
}
}
// look for import definitions and put them into the db
$this->createImportExportDefinitions($application);
Setup_Initialize::initialize($application, $_options);
} catch (Exception $e) {
Tinebase_Exception::log($e, false);
throw $e;
}
}
示例13: _setFlagsOnCache
/**
* set flags on cache if different
*
* @param array $flags
* @param Felamimail_Model_Folder $_folderId
* @param Tinebase_Record_RecordSet $messages
* @param boolean $checkDiff
*/
protected function _setFlagsOnCache($flags, $folder, $messages, $checkDiff = true)
{
$transactionId = Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
$supportedFlags = array_keys(Felamimail_Controller_Message_Flags::getInstance()->getSupportedFlags(FALSE));
$updateCount = 0;
foreach ($messages as $cachedMessage) {
if (isset($flags[$cachedMessage->messageuid]) || array_key_exists($cachedMessage->messageuid, $flags)) {
$newFlags = array_intersect($flags[$cachedMessage->messageuid]['flags'], $supportedFlags);
if ($checkDiff) {
$cachedFlags = array_intersect($cachedMessage->flags, $supportedFlags);
$diff1 = array_diff($cachedFlags, $newFlags);
$diff2 = array_diff($newFlags, $cachedFlags);
}
if (!$checkDiff || count($diff1) > 0 || count($diff2) > 0) {
try {
$this->_backend->setFlags(array($cachedMessage->getId()), $newFlags, $folder->getId());
$updateCount++;
} catch (Zend_Db_Statement_Exception $zdse) {
if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' Could not update flags, maybe message was deleted or is not in the cache yet.');
}
Tinebase_Exception::log($zdse);
}
}
}
}
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Updated ' . $updateCount . ' messages.');
}
Tinebase_TransactionManager::getInstance()->commitTransaction($transactionId);
}
示例14: deleteGroups
/**
* delete groups
*
* @param mixed $_groupId
* @throws Tinebase_Exception_Backend
*/
public function deleteGroups($_groupId)
{
$groupIds = array();
if (is_array($_groupId) or $_groupId instanceof Tinebase_Record_RecordSet) {
foreach ($_groupId as $groupId) {
$groupIds[] = Tinebase_Model_Group::convertGroupIdToInt($groupId);
}
} else {
$groupIds[] = Tinebase_Model_Group::convertGroupIdToInt($_groupId);
}
try {
$transactionId = Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
$this->deleteGroupsInSqlBackend($groupIds);
if ($this instanceof Tinebase_Group_Interface_SyncAble) {
$this->deleteGroupsInSyncBackend($groupIds);
}
Tinebase_TransactionManager::getInstance()->commitTransaction($transactionId);
} catch (Exception $e) {
Tinebase_TransactionManager::getInstance()->rollBack();
Tinebase_Exception::log($e);
throw new Tinebase_Exception_Backend($e->getMessage());
}
}
示例15: _getCustomAppRegistry
/**
* get registry data from application frontend json class
*
* @param Tinebase_Model_Application $application
* @return array
* @throws Tinebase_Exception_InvalidArgument
*/
protected function _getCustomAppRegistry(Tinebase_Model_Application $application)
{
$jsonAppName = $application->name . '_Frontend_Json';
if (!class_exists($jsonAppName)) {
return array();
}
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Getting registry data for app ' . $application->name);
}
try {
$applicationJson = new $jsonAppName();
$registryData = $applicationJson->getRegistryData();
} catch (Exception $e) {
Tinebase_Exception::log($e);
if (!$e instanceof Tinebase_Exception_AccessDenied && !in_array($application->name, array('Tinebase', 'Addressbook', 'Admin'))) {
Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Disabling ' . $application->name . ': ' . $e);
Tinebase_Application::getInstance()->setApplicationState(array($application->getId()), Tinebase_Application::DISABLED);
}
return array();
}
// TODO get this from app controller / modelconfig
foreach ($applicationJson->getRelatableModels() as $relModel) {
$registryData[$relModel['ownApp']]['relatableModels'][] = $relModel;
}
$registryData['models'] = $applicationJson->getModelsConfiguration();
$registryData['defaultModel'] = $applicationJson->getDefaultModel();
return $registryData;
}