本文整理汇总了PHP中Tinebase_Core::getLogger方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Core::getLogger方法的具体用法?PHP Tinebase_Core::getLogger怎么用?PHP Tinebase_Core::getLogger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Core
的用法示例。
在下文中一共展示了Tinebase_Core::getLogger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _group2ldap
/**
* convert objects with user data to ldap data array
*
* @param Tinebase_Model_FullUser $_user
* @param array $_ldapData the data to be written to ldap
*/
protected function _group2ldap(Tinebase_Model_Group $_group, array &$_ldapData)
{
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ENCRYPT ' . print_r($_ldapData, true));
}
if (isset($_ldapData['objectclass'])) {
$_ldapData['objectclass'] = array_unique(array_merge($_ldapData['objectclass'], $this->_requiredObjectClass));
}
if (isset($_ldapData['gidnumber'])) {
$gidNumber = $_ldapData['gidnumber'];
} else {
$gidNumber = $this->_getGidNumber($_group->getId());
}
// when we try to add a group, $_group has no id which leads to Tinebase_Exception_InvalidArgument in $this->_getGroupMetaData
try {
$metaData = $this->_getGroupMetaData($_group);
} catch (Tinebase_Exception_InvalidArgument $teia) {
$metaData = array();
}
if (!isset($metaData['sambasid'])) {
$_ldapData['sambasid'] = $this->_options[Tinebase_Group_Ldap::PLUGIN_SAMBA]['sid'] . '-' . (2 * $gidNumber + 1001);
$_ldapData['sambagrouptype'] = 2;
}
$_ldapData['displayname'] = $_group->name;
}
示例2: _updateForeignKeys
/**
* update foreign key values
*
* @param string $_mode create|update
* @param Tinebase_Record_Interface $_record
*
* @todo support update mode
*/
protected function _updateForeignKeys($_mode, Tinebase_Record_Interface $_record)
{
if ($_mode == 'create') {
foreach ($this->_foreignTables as $key => $foreign) {
if (!isset($_record->{$key}) || empty($_record->{$key})) {
continue;
}
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . $key . ': ' . print_r($_record->{$key}, TRUE));
}
foreach ($_record->{$key} as $data) {
if ($key == 'flags') {
$data = array('flag' => $data, 'folder_id' => $_record->folder_id);
} else {
// need to filter input as 'name' could contain invalid chars (emojis, ...) here
foreach ($data as $field => $value) {
$data[$field] = Tinebase_Core::filterInputForDatabase($data[$field]);
}
}
$data['message_id'] = $_record->getId();
$this->_db->insert($this->_tablePrefix . $foreign['table'], $data);
}
}
}
}
示例3: __construct
/**
* Constructor
*
* @param array $options An array of arrays of IMAP options
* @param string $username
* @param string $password
*/
public function __construct(array $options = array(), $username = null, $password = null)
{
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($options, true));
}
parent::__construct($options, $username, $password);
}
示例4: factory
/**
* factory function to return a selected account/imap backend class
*
* @param string|Felamimail_Model_Account $_accountId
* @return Felamimail_Backend_ImapProxy
* @throws Felamimail_Exception_IMAPInvalidCredentials
*/
public static function factory($_accountId)
{
$accountId = $_accountId instanceof Felamimail_Model_Account ? $_accountId->getId() : $_accountId;
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Getting IMAP backend for account id ' . $accountId);
}
if (!isset(self::$_backends[$accountId])) {
// get imap config from account
$account = $_accountId instanceof Felamimail_Model_Account ? $_accountId : Felamimail_Controller_Account::getInstance()->get($_accountId);
$imapConfig = $account->getImapConfig();
// we need to instantiate a new imap backend
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Connecting to server ' . $imapConfig['host'] . ':' . $imapConfig['port'] . ' (' . (array_key_exists('ssl', $imapConfig) ? $imapConfig['ssl'] : 'none') . ')' . ' with username ' . $imapConfig['user']);
}
try {
self::$_backends[$accountId] = new Felamimail_Backend_ImapProxy($imapConfig);
Felamimail_Controller_Account::getInstance()->updateCapabilities($account, self::$_backends[$accountId]);
} catch (Felamimail_Exception_IMAPInvalidCredentials $feiic) {
// add account and username to Felamimail_Exception_IMAPInvalidCredentials
$feiic->setAccount($account)->setUsername($imapConfig['user']);
throw $feiic;
}
}
return self::$_backends[$accountId];
}
示例5: resolveTagNameToTag
/**
* converts an array of tags names to a recordSet of Tinebase_Model_Tag
*
* @param iteratable $tagNames
* @param bool $implicitAddMissingTags
* @return Tinebase_Record_RecordSet
*/
public static function resolveTagNameToTag($tagNames, $applicationName, $implicitAddMissingTags = true)
{
if (empty($tagNames)) {
return new Tinebase_Record_RecordSet('Tinebase_Model_Tag');
}
$resolvedTags = array();
foreach ((array) $tagNames as $tagName) {
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Trying to allocate tag ' . $tagName);
}
$tagName = trim($tagName);
if (empty($tagName)) {
continue;
}
$existingTags = Tinebase_Tags::getInstance()->searchTags(new Tinebase_Model_TagFilter(array('name' => $tagName, 'application' => $applicationName)), new Tinebase_Model_Pagination(array('sort' => 'type', 'dir' => 'DESC', 'limit' => 1)));
if (count($existingTags) === 1) {
//var_dump($existingTags->toArray());
$resolvedTags[] = $existingTags->getFirstRecord();
} elseif ($implicitAddMissingTags === true) {
// No tag found, lets create a personal tag
$resolvedTag = Tinebase_Tags::GetInstance()->createTag(new Tinebase_Model_Tag(array('type' => Tinebase_Model_Tag::TYPE_PERSONAL, 'name' => $tagName)));
$resolvedTags[] = $resolvedTag;
}
}
return new Tinebase_Record_RecordSet('Tinebase_Model_Tag', $resolvedTags);
}
示例6: downloadNode
/**
* download file
*
* @param string $path
*/
public function downloadNode($path)
{
try {
$splittedPath = explode('/', trim($path, '/'));
$downloadId = array_shift($splittedPath);
$download = $this->_getDownloadLink($downloadId);
$this->_setDownloadLinkOwnerAsUser($download);
$node = Filemanager_Controller_DownloadLink::getInstance()->getNode($download, $splittedPath);
if ($node->type === Tinebase_Model_Tree_Node::TYPE_FILE) {
$nodeController = Filemanager_Controller_Node::getInstance();
$nodeController->resolveMultipleTreeNodesPath($node);
$pathRecord = Tinebase_Model_Tree_Node_Path::createFromPath($nodeController->addBasePath($node->path));
Filemanager_Controller_DownloadLink::getInstance()->increaseAccessCount($download);
$this->_downloadFileNode($node, $pathRecord->streamwrapperpath);
}
} catch (Exception $e) {
if (Tinebase_Core::isLogLevel(Zend_Log::CRIT)) {
Tinebase_Core::getLogger()->crit(__METHOD__ . '::' . __LINE__ . ' exception: ' . $e->getMessage());
}
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' exception: ' . $e->getTraceAsString());
}
header('HTTP/1.0 404 Not found');
$view = new Zend_View();
$view->setScriptPath('Filemanager/views');
header('Content-Type: text/html; charset=utf-8');
die($view->render('notfound.phtml'));
}
exit;
}
示例7: handle
/**
* handler for JSON api requests
*
* @return JSON
*/
public function handle()
{
try {
// init server and request first
$server = new Zend_Json_Server();
$server->setClass('Setup_Frontend_Json', 'Setup');
$server->setClass('Tinebase_Frontend_Json', 'Tinebase');
$server->setAutoHandleExceptions(false);
$server->setAutoEmitResponse(false);
$request = new Zend_Json_Server_Request_Http();
Setup_Core::initFramework();
$method = $request->getMethod();
$jsonKey = isset($_SERVER['HTTP_X_TINE20_JSONKEY']) ? $_SERVER['HTTP_X_TINE20_JSONKEY'] : '';
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' is JSON request. method: ' . $method);
$anonymnousMethods = array('Setup.getAllRegistryData', 'Setup.login', 'Tinebase.getAvailableTranslations', 'Tinebase.getTranslations', 'Tinebase.setLocale');
if (!Setup_Core::configFileExists()) {
$anonymnousMethods = array_merge($anonymnousMethods, array('Setup.envCheck'));
}
// check json key for all methods but some exceptoins
if (!in_array($method, $anonymnousMethods) && Setup_Core::configFileExists() && (empty($jsonKey) || $jsonKey != Setup_Core::get('jsonKey') || !Setup_Core::isRegistered(Setup_Core::USER))) {
if (!Setup_Core::isRegistered(Setup_Core::USER)) {
Setup_Core::getLogger()->INFO(__METHOD__ . '::' . __LINE__ . ' Attempt to request a privileged Json-API method without authorisation from "' . $_SERVER['REMOTE_ADDR'] . '". (session timeout?)');
throw new Tinebase_Exception_AccessDenied('Not Authorised', 401);
} else {
Setup_Core::getLogger()->WARN(__METHOD__ . '::' . __LINE__ . ' Fatal: got wrong json key! (' . $jsonKey . ') Possible CSRF attempt!' . ' affected account: ' . print_r(Setup_Core::getUser(), true) . ' request: ' . print_r($_REQUEST, true));
throw new Tinebase_Exception_AccessDenied('Not Authorised', 401);
}
}
$response = $server->handle($request);
} catch (Exception $exception) {
$response = $this->_handleException($server, $request, $exception);
}
echo $response;
}
示例8: 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;
}
}
示例9: handle
/**
* handler for command line scripts
*
* @return boolean
*/
public function handle()
{
try {
$opts = new Zend_Console_Getopt(array('help|h' => 'Display this help Message', 'verbose|v' => 'Output messages', 'config|c=s' => 'Path to config.inc.php file', 'setconfig' => 'Update config. To specify the key and value, append \' -- configKey="your_key" configValue="your config value"\'
Examples:
setup.php --setconfig -- configkey=sample1 configvalue=value11
setup.php --setconfig -- configkey=sample2 configvalue=arrayKey1:Value1,arrayKey2:value2', 'check_requirements' => 'Check if all requirements are met to install and run tine20', 'create_admin' => 'Create new admin user (or reactivate if already exists)', 'install-s' => 'Install applications [All] or comma separated list;' . ' To specify the login name and login password of the admin user that is created during installation, append \' -- adminLoginName="admin" adminPassword="password"\'' . ' To add imap or smtp settings, append (for example) \' -- imap="host:mail.example.org,port:143,dbmail_host:localhost" smtp="ssl:tls"\'', 'update-s' => 'Update applications [All] or comma separated list', 'uninstall-s' => 'Uninstall application [All] or comma separated list', 'list-s' => 'List installed applications', 'sync_accounts_from_ldap' => 'Import user and groups from ldap', 'egw14import' => 'Import user and groups from egw14
Examples:
setup.php --egw14import egwdbhost egwdbuser egwdbpass egwdbname latin1
setup.php --egw14import egwdbhost egwdbuser egwdbpass egwdbname utf8'));
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo "Invalid usage: {$e->getMessage()}\n\n";
echo $e->getUsageMessage();
exit;
}
if (count($opts->toArray()) === 0 || $opts->h || empty($opts->install) && empty($opts->update) && empty($opts->uninstall) && empty($opts->list) && empty($opts->sync_accounts_from_ldap) && empty($opts->egw14import) && empty($opts->check_requirements) && empty($opts->create_admin) && empty($opts->setconfig)) {
echo $opts->getUsageMessage();
exit;
}
if ($opts->config) {
// add path to config.inc.php to include path
$path = strstr($opts->config, 'config.inc.php') !== false ? dirname($opts->config) : $opts->config;
set_include_path($path . PATH_SEPARATOR . get_include_path());
}
Setup_Core::initFramework();
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Is cli request. method: ' . (isset($opts->mode) ? $opts->mode : 'EMPTY'));
}
$setupServer = new Setup_Frontend_Cli();
#$setupServer->authenticate($opts->username, $opts->password);
return $setupServer->handle($opts);
}
示例10: 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";
}
示例11: _importRecord
protected function _importRecord($_recordData, &$_result)
{
//if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($_recordData, true));
$record = new $this->_modelName($_recordData, TRUE);
if ($record->isValid()) {
if (!$this->_options['dryrun']) {
if ($record->__get('change_sign') == 'A') {
$record = call_user_func(array($this->_controller, $this->_createMethod), $record);
} else {
try {
$record = $this->_controller->getByRecordNumber((int) trim($record->__get('record_number')));
$record->setFromArray($_recordData);
$record = $this->_controller->update($record);
} catch (Tinebase_Exception_NotFound $e) {
$record = call_user_func(array($this->_controller, $this->_createMethod), $record);
}
if ($record->__get('change_sign') == 'D') {
$this->_controller->delete($record->getId());
}
}
} else {
$_result['results']->addRecord($record);
}
$_result['totalcount']++;
} else {
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($record->toArray(), true));
}
throw new Tinebase_Exception_Record_Validation('Imported record is invalid.');
}
}
示例12: addRelation
/**
* adds a new relation
*
* @param Tinebase_Model_Relation $_relation
* @return Tinebase_Model_Relation the new relation
*
* @todo move check existance and update / modlog to controller?
*/
public function addRelation($_relation)
{
if ($_relation->getId()) {
throw new Tinebase_Exception_Record_NotAllowed('Could not add existing relation');
}
$relId = $_relation->generateUID();
$_relation->setId($relId);
// check if relation is already set (with is_deleted=1)
if ($deletedRelId = $this->_checkExistance($_relation)) {
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Removing existing relation (rel_id): ' . $deletedRelId);
$where = array($this->_db->quoteInto($this->_db->quoteIdentifier('rel_id') . ' = ?', $deletedRelId));
$this->_dbTable->delete($where);
}
$data = $_relation->toArray();
$data['rel_id'] = $data['id'];
$data['id'] = $_relation->generateUID();
unset($data['related_record']);
if (isset($data['remark']) && is_array($data['remark'])) {
$data['remark'] = Zend_Json::encode($data['remark']);
}
$this->_dbTable->insert($data);
$swappedData = $this->_swapRoles($data);
$swappedData['id'] = $_relation->generateUID();
$this->_dbTable->insert($swappedData);
return $this->getRelation($relId, $_relation['own_model'], $_relation['own_backend'], $_relation['own_id']);
}
示例13: appendFilterSql
/**
* appends sql to given select statement
*
* @param Zend_Db_Select $_select
* @param Tinebase_Backend_Sql_Abstract $_backend
*/
public function appendFilterSql($_select, $_backend)
{
$db = $_backend->getAdapter();
// prepare value
$value = $this->_value ? 1 : 0;
if ($value) {
// nothing to do -> show all contacts!
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Query all account contacts.');
}
} else {
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Only query visible and enabled account contacts.');
}
if (Tinebase_Core::getUser() instanceof Tinebase_Model_FullUser) {
$where = '/* is no user */ ' . Tinebase_Backend_Sql_Command::getIfIsNull($db, $db->quoteIdentifier('accounts.id'), 'true', 'false') . ' OR /* is user */ (' . Tinebase_Backend_Sql_Command::getIfIsNull($db, $db->quoteIdentifier('accounts.id'), 'false', 'true') . ' AND ' . $db->quoteInto($db->quoteIdentifier('accounts.status') . ' = ?', 'enabled') . " AND " . '(' . $db->quoteInto($db->quoteIdentifier('accounts.visibility') . ' = ?', 'displayed') . ' OR ' . $db->quoteInto($db->quoteIdentifier('accounts.id') . ' = ?', Tinebase_Core::getUser()->getId()) . ')' . ")";
} else {
$where = '/* is no user */ ' . Tinebase_Backend_Sql_Command::getIfIsNull($db, $db->quoteIdentifier('accounts.id'), 'true', 'false') . ' OR /* is user */ (' . Tinebase_Backend_Sql_Command::getIfIsNull($db, $db->quoteIdentifier('accounts.id'), 'false', 'true') . ' AND ' . $db->quoteInto($db->quoteIdentifier('accounts.status') . ' = ?', 'enabled') . " AND " . $db->quoteInto($db->quoteIdentifier('accounts.visibility') . ' = ?', 'displayed') . ")";
}
$_select->where($where);
$select = $_select instanceof Zend_Db_Select ? $_select : $_select->getSelect();
$select = Tinebase_Backend_Sql_Abstract::traitGroup($db, $_backend->getTablePrefix(), $select);
$_select instanceof Zend_Db_Select ? $_select = $select : $_select->setSelect($select);
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' contacts query ' . $_select->assemble());
}
}
}
示例14: getGrantsForRecords
/**
* get grants for records
*
* @param Tinebase_Record_RecordSet $records
*/
public function getGrantsForRecords(Tinebase_Record_RecordSet $records)
{
$recordIds = $records->getArrayOfIds();
if (empty($recordIds)) {
return;
}
$select = $this->_getAclSelectByRecordIds($recordIds)->group(array('record_id', 'account_type', 'account_id'));
Tinebase_Backend_Sql_Abstract::traitGroup($select);
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . $select);
}
$stmt = $this->_db->query($select);
$grantsData = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' grantsData: ' . print_r($grantsData, true));
}
foreach ($grantsData as $grantData) {
$givenGrants = explode(',', $grantData['account_grants']);
foreach ($givenGrants as $grant) {
$grantData[$grant] = TRUE;
}
$recordGrant = new $this->_modelName($grantData, true);
unset($recordGrant->account_grant);
$record = $records->getById($recordGrant->record_id);
if (!$record->grants instanceof Tinebase_Record_RecordSet) {
$record->grants = new Tinebase_Record_RecordSet($this->_modelName);
}
$record->grants->addRecord($recordGrant);
}
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Records with grants: ' . print_r($records->toArray(), true));
}
}
示例15: appendFilterSql
/**
* appends sql to given select statement
*
* @param Zend_Db_Select $_select
* @param Tinebase_Backend_Sql_Abstract $_backend
* @throws Tinebase_Exception_UnexpectedValue
*/
public function appendFilterSql($_select, $_backend)
{
// don't take empty filter into account
if (empty($this->_value) || !is_array($this->_value) || !isset($this->_value['cfId']) || empty($this->_value['cfId']) || !isset($this->_value['value'])) {
return;
} else {
if ($this->_operator == 'in') {
throw new Tinebase_Exception_UnexpectedValue('Operator "in" not supported.');
}
}
// make sure $correlationName is a string
$correlationName = Tinebase_Record_Abstract::generateUID() . $this->_value['cfId'] . 'cf';
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Adding custom field filter: ' . print_r($this->_value, true));
}
$db = Tinebase_Core::getDb();
$idProperty = $db->quoteIdentifier($this->_options['idProperty']);
// per left join we add a customfield column named as the customfield and filter this joined column
// NOTE: we name the column we join like the customfield, to be able to join multiple customfield criteria (multiple invocations of this function)
$what = array($correlationName => SQL_TABLE_PREFIX . 'customfield');
$on = $db->quoteIdentifier("{$correlationName}.record_id") . " = {$idProperty} AND " . $db->quoteIdentifier("{$correlationName}.customfield_id") . " = " . $db->quote($this->_value['cfId']);
$_select->joinLeft($what, $on, array());
$valueIdentifier = $db->quoteIdentifier("{$correlationName}.value");
if ($this->_value['value'] === '') {
$where = $db->quoteInto($valueIdentifier . ' IS NULL OR ' . $valueIdentifier . ' = ?', $this->_value['value']);
} else {
$value = $this->_replaceWildcards($this->_value['value']);
$where = $db->quoteInto($valueIdentifier . $this->_opSqlMap[$this->_operator]['sqlop'], $value);
}
$_select->where($where . ' /* add cf filter */');
}