repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
i-MSCP/roundcube
|
roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php
|
enigma_driver_gnupg.import
|
public function import($content, $isfile = false, $passwords = array())
{
try {
// GnuPG 2.1 requires secret key passphrases on import
foreach ($passwords as $keyid => $pass) {
$this->gpg->addPassphrase($keyid, $pass);
}
if ($isfile)
return $this->gpg->importKeyFile($content);
else
return $this->gpg->importKey($content);
}
catch (Exception $e) {
return $this->get_error_from_exception($e);
}
}
|
php
|
public function import($content, $isfile = false, $passwords = array())
{
try {
// GnuPG 2.1 requires secret key passphrases on import
foreach ($passwords as $keyid => $pass) {
$this->gpg->addPassphrase($keyid, $pass);
}
if ($isfile)
return $this->gpg->importKeyFile($content);
else
return $this->gpg->importKey($content);
}
catch (Exception $e) {
return $this->get_error_from_exception($e);
}
}
|
[
"public",
"function",
"import",
"(",
"$",
"content",
",",
"$",
"isfile",
"=",
"false",
",",
"$",
"passwords",
"=",
"array",
"(",
")",
")",
"{",
"try",
"{",
"// GnuPG 2.1 requires secret key passphrases on import",
"foreach",
"(",
"$",
"passwords",
"as",
"$",
"keyid",
"=>",
"$",
"pass",
")",
"{",
"$",
"this",
"->",
"gpg",
"->",
"addPassphrase",
"(",
"$",
"keyid",
",",
"$",
"pass",
")",
";",
"}",
"if",
"(",
"$",
"isfile",
")",
"return",
"$",
"this",
"->",
"gpg",
"->",
"importKeyFile",
"(",
"$",
"content",
")",
";",
"else",
"return",
"$",
"this",
"->",
"gpg",
"->",
"importKey",
"(",
"$",
"content",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"get_error_from_exception",
"(",
"$",
"e",
")",
";",
"}",
"}"
] |
Key file import.
@param string File name or file content
@param bolean True if first argument is a filename
@param array Optional key => password map
@return mixed Import status array or enigma_error
|
[
"Key",
"file",
"import",
"."
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php#L233-L249
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php
|
enigma_driver_gnupg.export
|
public function export($keyid, $with_private = false, $passwords = array())
{
try {
$key = $this->gpg->exportPublicKey($keyid, true);
if ($with_private) {
// GnuPG 2.1 requires secret key passphrases on export
foreach ($passwords as $_keyid => $pass) {
$this->gpg->addPassphrase($_keyid, $pass);
}
$priv = $this->gpg->exportPrivateKey($keyid, true);
$key .= $priv;
}
return $key;
}
catch (Exception $e) {
return $this->get_error_from_exception($e);
}
}
|
php
|
public function export($keyid, $with_private = false, $passwords = array())
{
try {
$key = $this->gpg->exportPublicKey($keyid, true);
if ($with_private) {
// GnuPG 2.1 requires secret key passphrases on export
foreach ($passwords as $_keyid => $pass) {
$this->gpg->addPassphrase($_keyid, $pass);
}
$priv = $this->gpg->exportPrivateKey($keyid, true);
$key .= $priv;
}
return $key;
}
catch (Exception $e) {
return $this->get_error_from_exception($e);
}
}
|
[
"public",
"function",
"export",
"(",
"$",
"keyid",
",",
"$",
"with_private",
"=",
"false",
",",
"$",
"passwords",
"=",
"array",
"(",
")",
")",
"{",
"try",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"gpg",
"->",
"exportPublicKey",
"(",
"$",
"keyid",
",",
"true",
")",
";",
"if",
"(",
"$",
"with_private",
")",
"{",
"// GnuPG 2.1 requires secret key passphrases on export",
"foreach",
"(",
"$",
"passwords",
"as",
"$",
"_keyid",
"=>",
"$",
"pass",
")",
"{",
"$",
"this",
"->",
"gpg",
"->",
"addPassphrase",
"(",
"$",
"_keyid",
",",
"$",
"pass",
")",
";",
"}",
"$",
"priv",
"=",
"$",
"this",
"->",
"gpg",
"->",
"exportPrivateKey",
"(",
"$",
"keyid",
",",
"true",
")",
";",
"$",
"key",
".=",
"$",
"priv",
";",
"}",
"return",
"$",
"key",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"get_error_from_exception",
"(",
"$",
"e",
")",
";",
"}",
"}"
] |
Key export.
@param string Key ID
@param bool Include private key
@param array Optional key => password map
@return mixed Key content or enigma_error
|
[
"Key",
"export",
"."
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php#L260-L280
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php
|
enigma_driver_gnupg.list_keys
|
public function list_keys($pattern = '')
{
try {
$keys = $this->gpg->getKeys($pattern);
$result = array();
foreach ($keys as $idx => $key) {
$result[] = $this->parse_key($key);
unset($keys[$idx]);
}
return $result;
}
catch (Exception $e) {
return $this->get_error_from_exception($e);
}
}
|
php
|
public function list_keys($pattern = '')
{
try {
$keys = $this->gpg->getKeys($pattern);
$result = array();
foreach ($keys as $idx => $key) {
$result[] = $this->parse_key($key);
unset($keys[$idx]);
}
return $result;
}
catch (Exception $e) {
return $this->get_error_from_exception($e);
}
}
|
[
"public",
"function",
"list_keys",
"(",
"$",
"pattern",
"=",
"''",
")",
"{",
"try",
"{",
"$",
"keys",
"=",
"$",
"this",
"->",
"gpg",
"->",
"getKeys",
"(",
"$",
"pattern",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"idx",
"=>",
"$",
"key",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"parse_key",
"(",
"$",
"key",
")",
";",
"unset",
"(",
"$",
"keys",
"[",
"$",
"idx",
"]",
")",
";",
"}",
"return",
"$",
"result",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"get_error_from_exception",
"(",
"$",
"e",
")",
";",
"}",
"}"
] |
Keys listing.
@param string Optional pattern for key ID, user ID or fingerprint
@return mixed Array of enigma_key objects or enigma_error
|
[
"Keys",
"listing",
"."
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php#L289-L305
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php
|
enigma_driver_gnupg.get_key
|
public function get_key($keyid)
{
$list = $this->list_keys($keyid);
if (is_array($list)) {
return $list[key($list)];
}
// error
return $list;
}
|
php
|
public function get_key($keyid)
{
$list = $this->list_keys($keyid);
if (is_array($list)) {
return $list[key($list)];
}
// error
return $list;
}
|
[
"public",
"function",
"get_key",
"(",
"$",
"keyid",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"list_keys",
"(",
"$",
"keyid",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"list",
")",
")",
"{",
"return",
"$",
"list",
"[",
"key",
"(",
"$",
"list",
")",
"]",
";",
"}",
"// error",
"return",
"$",
"list",
";",
"}"
] |
Single key information.
@param string Key ID, user ID or fingerprint
@return mixed Key (enigma_key) object or enigma_error
|
[
"Single",
"key",
"information",
"."
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php#L314-L324
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php
|
enigma_driver_gnupg.gen_key
|
public function gen_key($data)
{
try {
$debug = $this->rc->config->get('enigma_debug');
$keygen = new Crypt_GPG_KeyGenerator(array(
'homedir' => $this->homedir,
// 'binary' => '/usr/bin/gpg2',
'debug' => $debug ? array($this, 'debug') : false,
));
$key = $keygen
->setExpirationDate(0)
->setPassphrase($data['password'])
->generateKey($data['user'], $data['email']);
return $this->parse_key($key);
}
catch (Exception $e) {
return $this->get_error_from_exception($e);
}
}
|
php
|
public function gen_key($data)
{
try {
$debug = $this->rc->config->get('enigma_debug');
$keygen = new Crypt_GPG_KeyGenerator(array(
'homedir' => $this->homedir,
// 'binary' => '/usr/bin/gpg2',
'debug' => $debug ? array($this, 'debug') : false,
));
$key = $keygen
->setExpirationDate(0)
->setPassphrase($data['password'])
->generateKey($data['user'], $data['email']);
return $this->parse_key($key);
}
catch (Exception $e) {
return $this->get_error_from_exception($e);
}
}
|
[
"public",
"function",
"gen_key",
"(",
"$",
"data",
")",
"{",
"try",
"{",
"$",
"debug",
"=",
"$",
"this",
"->",
"rc",
"->",
"config",
"->",
"get",
"(",
"'enigma_debug'",
")",
";",
"$",
"keygen",
"=",
"new",
"Crypt_GPG_KeyGenerator",
"(",
"array",
"(",
"'homedir'",
"=>",
"$",
"this",
"->",
"homedir",
",",
"// 'binary' => '/usr/bin/gpg2',",
"'debug'",
"=>",
"$",
"debug",
"?",
"array",
"(",
"$",
"this",
",",
"'debug'",
")",
":",
"false",
",",
")",
")",
";",
"$",
"key",
"=",
"$",
"keygen",
"->",
"setExpirationDate",
"(",
"0",
")",
"->",
"setPassphrase",
"(",
"$",
"data",
"[",
"'password'",
"]",
")",
"->",
"generateKey",
"(",
"$",
"data",
"[",
"'user'",
"]",
",",
"$",
"data",
"[",
"'email'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"parse_key",
"(",
"$",
"key",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"get_error_from_exception",
"(",
"$",
"e",
")",
";",
"}",
"}"
] |
Key pair generation.
@param array Key/User data (user, email, password, size)
@return mixed Key (enigma_key) object or enigma_error
|
[
"Key",
"pair",
"generation",
"."
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php#L333-L353
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php
|
enigma_driver_gnupg.delete_key
|
public function delete_key($keyid)
{
// delete public key
$result = $this->delete_pubkey($keyid);
// error handling
if ($result !== true) {
$code = $result->getCode();
// if not found, delete private key
if ($code == enigma_error::KEYNOTFOUND) {
$result = $this->delete_privkey($keyid);
}
// need to delete private key first
else if ($code == enigma_error::DELKEY) {
$result = $this->delete_privkey($keyid);
if ($result === true) {
$result = $this->delete_pubkey($keyid);
}
}
}
return $result;
}
|
php
|
public function delete_key($keyid)
{
// delete public key
$result = $this->delete_pubkey($keyid);
// error handling
if ($result !== true) {
$code = $result->getCode();
// if not found, delete private key
if ($code == enigma_error::KEYNOTFOUND) {
$result = $this->delete_privkey($keyid);
}
// need to delete private key first
else if ($code == enigma_error::DELKEY) {
$result = $this->delete_privkey($keyid);
if ($result === true) {
$result = $this->delete_pubkey($keyid);
}
}
}
return $result;
}
|
[
"public",
"function",
"delete_key",
"(",
"$",
"keyid",
")",
"{",
"// delete public key",
"$",
"result",
"=",
"$",
"this",
"->",
"delete_pubkey",
"(",
"$",
"keyid",
")",
";",
"// error handling",
"if",
"(",
"$",
"result",
"!==",
"true",
")",
"{",
"$",
"code",
"=",
"$",
"result",
"->",
"getCode",
"(",
")",
";",
"// if not found, delete private key",
"if",
"(",
"$",
"code",
"==",
"enigma_error",
"::",
"KEYNOTFOUND",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"delete_privkey",
"(",
"$",
"keyid",
")",
";",
"}",
"// need to delete private key first",
"else",
"if",
"(",
"$",
"code",
"==",
"enigma_error",
"::",
"DELKEY",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"delete_privkey",
"(",
"$",
"keyid",
")",
";",
"if",
"(",
"$",
"result",
"===",
"true",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"delete_pubkey",
"(",
"$",
"keyid",
")",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Key deletion.
@param string Key ID
@return mixed True on success or enigma_error
|
[
"Key",
"deletion",
"."
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php#L362-L386
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php
|
enigma_driver_gnupg.delete_privkey
|
protected function delete_privkey($keyid)
{
try {
$this->gpg->deletePrivateKey($keyid);
return true;
}
catch (Exception $e) {
return $this->get_error_from_exception($e);
}
}
|
php
|
protected function delete_privkey($keyid)
{
try {
$this->gpg->deletePrivateKey($keyid);
return true;
}
catch (Exception $e) {
return $this->get_error_from_exception($e);
}
}
|
[
"protected",
"function",
"delete_privkey",
"(",
"$",
"keyid",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"gpg",
"->",
"deletePrivateKey",
"(",
"$",
"keyid",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"get_error_from_exception",
"(",
"$",
"e",
")",
";",
"}",
"}"
] |
Private key deletion.
|
[
"Private",
"key",
"deletion",
"."
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php#L402-L411
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php
|
enigma_driver_gnupg.delete_pubkey
|
protected function delete_pubkey($keyid)
{
try {
$this->gpg->deletePublicKey($keyid);
return true;
}
catch (Exception $e) {
return $this->get_error_from_exception($e);
}
}
|
php
|
protected function delete_pubkey($keyid)
{
try {
$this->gpg->deletePublicKey($keyid);
return true;
}
catch (Exception $e) {
return $this->get_error_from_exception($e);
}
}
|
[
"protected",
"function",
"delete_pubkey",
"(",
"$",
"keyid",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"gpg",
"->",
"deletePublicKey",
"(",
"$",
"keyid",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"get_error_from_exception",
"(",
"$",
"e",
")",
";",
"}",
"}"
] |
Public key deletion.
|
[
"Public",
"key",
"deletion",
"."
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php#L416-L425
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php
|
enigma_driver_gnupg.get_error_from_exception
|
protected function get_error_from_exception($e)
{
$data = array();
if ($e instanceof Crypt_GPG_KeyNotFoundException) {
$error = enigma_error::KEYNOTFOUND;
$data['id'] = $e->getKeyId();
}
else if ($e instanceof Crypt_GPG_BadPassphraseException) {
$error = enigma_error::BADPASS;
$data['bad'] = $e->getBadPassphrases();
$data['missing'] = $e->getMissingPassphrases();
}
else if ($e instanceof Crypt_GPG_NoDataException) {
$error = enigma_error::NODATA;
}
else if ($e instanceof Crypt_GPG_DeletePrivateKeyException) {
$error = enigma_error::DELKEY;
}
else {
$error = enigma_error::INTERNAL;
}
$msg = $e->getMessage();
return new enigma_error($error, $msg, $data);
}
|
php
|
protected function get_error_from_exception($e)
{
$data = array();
if ($e instanceof Crypt_GPG_KeyNotFoundException) {
$error = enigma_error::KEYNOTFOUND;
$data['id'] = $e->getKeyId();
}
else if ($e instanceof Crypt_GPG_BadPassphraseException) {
$error = enigma_error::BADPASS;
$data['bad'] = $e->getBadPassphrases();
$data['missing'] = $e->getMissingPassphrases();
}
else if ($e instanceof Crypt_GPG_NoDataException) {
$error = enigma_error::NODATA;
}
else if ($e instanceof Crypt_GPG_DeletePrivateKeyException) {
$error = enigma_error::DELKEY;
}
else {
$error = enigma_error::INTERNAL;
}
$msg = $e->getMessage();
return new enigma_error($error, $msg, $data);
}
|
[
"protected",
"function",
"get_error_from_exception",
"(",
"$",
"e",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"e",
"instanceof",
"Crypt_GPG_KeyNotFoundException",
")",
"{",
"$",
"error",
"=",
"enigma_error",
"::",
"KEYNOTFOUND",
";",
"$",
"data",
"[",
"'id'",
"]",
"=",
"$",
"e",
"->",
"getKeyId",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$",
"e",
"instanceof",
"Crypt_GPG_BadPassphraseException",
")",
"{",
"$",
"error",
"=",
"enigma_error",
"::",
"BADPASS",
";",
"$",
"data",
"[",
"'bad'",
"]",
"=",
"$",
"e",
"->",
"getBadPassphrases",
"(",
")",
";",
"$",
"data",
"[",
"'missing'",
"]",
"=",
"$",
"e",
"->",
"getMissingPassphrases",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$",
"e",
"instanceof",
"Crypt_GPG_NoDataException",
")",
"{",
"$",
"error",
"=",
"enigma_error",
"::",
"NODATA",
";",
"}",
"else",
"if",
"(",
"$",
"e",
"instanceof",
"Crypt_GPG_DeletePrivateKeyException",
")",
"{",
"$",
"error",
"=",
"enigma_error",
"::",
"DELKEY",
";",
"}",
"else",
"{",
"$",
"error",
"=",
"enigma_error",
"::",
"INTERNAL",
";",
"}",
"$",
"msg",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"return",
"new",
"enigma_error",
"(",
"$",
"error",
",",
"$",
"msg",
",",
"$",
"data",
")",
";",
"}"
] |
Converts Crypt_GPG exception into Enigma's error object
@param mixed Exception object
@return enigma_error Error object
|
[
"Converts",
"Crypt_GPG",
"exception",
"into",
"Enigma",
"s",
"error",
"object"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php#L434-L460
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php
|
enigma_driver_gnupg.parse_signature
|
protected function parse_signature($sig)
{
$data = new enigma_signature();
$data->id = $sig->getId() ?: $sig->getKeyId();
$data->valid = $sig->isValid();
$data->fingerprint = $sig->getKeyFingerprint();
$data->created = $sig->getCreationDate();
$data->expires = $sig->getExpirationDate();
// In case of ERRSIG user may not be set
if ($user = $sig->getUserId()) {
$data->name = $user->getName();
$data->comment = $user->getComment();
$data->email = $user->getEmail();
}
return $data;
}
|
php
|
protected function parse_signature($sig)
{
$data = new enigma_signature();
$data->id = $sig->getId() ?: $sig->getKeyId();
$data->valid = $sig->isValid();
$data->fingerprint = $sig->getKeyFingerprint();
$data->created = $sig->getCreationDate();
$data->expires = $sig->getExpirationDate();
// In case of ERRSIG user may not be set
if ($user = $sig->getUserId()) {
$data->name = $user->getName();
$data->comment = $user->getComment();
$data->email = $user->getEmail();
}
return $data;
}
|
[
"protected",
"function",
"parse_signature",
"(",
"$",
"sig",
")",
"{",
"$",
"data",
"=",
"new",
"enigma_signature",
"(",
")",
";",
"$",
"data",
"->",
"id",
"=",
"$",
"sig",
"->",
"getId",
"(",
")",
"?",
":",
"$",
"sig",
"->",
"getKeyId",
"(",
")",
";",
"$",
"data",
"->",
"valid",
"=",
"$",
"sig",
"->",
"isValid",
"(",
")",
";",
"$",
"data",
"->",
"fingerprint",
"=",
"$",
"sig",
"->",
"getKeyFingerprint",
"(",
")",
";",
"$",
"data",
"->",
"created",
"=",
"$",
"sig",
"->",
"getCreationDate",
"(",
")",
";",
"$",
"data",
"->",
"expires",
"=",
"$",
"sig",
"->",
"getExpirationDate",
"(",
")",
";",
"// In case of ERRSIG user may not be set",
"if",
"(",
"$",
"user",
"=",
"$",
"sig",
"->",
"getUserId",
"(",
")",
")",
"{",
"$",
"data",
"->",
"name",
"=",
"$",
"user",
"->",
"getName",
"(",
")",
";",
"$",
"data",
"->",
"comment",
"=",
"$",
"user",
"->",
"getComment",
"(",
")",
";",
"$",
"data",
"->",
"email",
"=",
"$",
"user",
"->",
"getEmail",
"(",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Converts Crypt_GPG_Signature object into Enigma's signature object
@param Crypt_GPG_Signature Signature object
@return enigma_signature Signature object
|
[
"Converts",
"Crypt_GPG_Signature",
"object",
"into",
"Enigma",
"s",
"signature",
"object"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php#L469-L487
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php
|
enigma_driver_gnupg.parse_key
|
protected function parse_key($key)
{
$ekey = new enigma_key();
foreach ($key->getUserIds() as $idx => $user) {
$id = new enigma_userid();
$id->name = $user->getName();
$id->comment = $user->getComment();
$id->email = $user->getEmail();
$id->valid = $user->isValid();
$id->revoked = $user->isRevoked();
$ekey->users[$idx] = $id;
}
$ekey->name = trim($ekey->users[0]->name . ' <' . $ekey->users[0]->email . '>');
// keep reference to Crypt_GPG's key for performance reasons
$ekey->reference = $key;
foreach ($key->getSubKeys() as $idx => $subkey) {
$skey = new enigma_subkey();
$skey->id = $subkey->getId();
$skey->revoked = $subkey->isRevoked();
$skey->created = $subkey->getCreationDate();
$skey->expires = $subkey->getExpirationDate();
$skey->fingerprint = $subkey->getFingerprint();
$skey->has_private = $subkey->hasPrivate();
$skey->algorithm = $subkey->getAlgorithm();
$skey->length = $subkey->getLength();
$skey->usage = $subkey->usage();
$ekey->subkeys[$idx] = $skey;
};
$ekey->id = $ekey->subkeys[0]->id;
return $ekey;
}
|
php
|
protected function parse_key($key)
{
$ekey = new enigma_key();
foreach ($key->getUserIds() as $idx => $user) {
$id = new enigma_userid();
$id->name = $user->getName();
$id->comment = $user->getComment();
$id->email = $user->getEmail();
$id->valid = $user->isValid();
$id->revoked = $user->isRevoked();
$ekey->users[$idx] = $id;
}
$ekey->name = trim($ekey->users[0]->name . ' <' . $ekey->users[0]->email . '>');
// keep reference to Crypt_GPG's key for performance reasons
$ekey->reference = $key;
foreach ($key->getSubKeys() as $idx => $subkey) {
$skey = new enigma_subkey();
$skey->id = $subkey->getId();
$skey->revoked = $subkey->isRevoked();
$skey->created = $subkey->getCreationDate();
$skey->expires = $subkey->getExpirationDate();
$skey->fingerprint = $subkey->getFingerprint();
$skey->has_private = $subkey->hasPrivate();
$skey->algorithm = $subkey->getAlgorithm();
$skey->length = $subkey->getLength();
$skey->usage = $subkey->usage();
$ekey->subkeys[$idx] = $skey;
};
$ekey->id = $ekey->subkeys[0]->id;
return $ekey;
}
|
[
"protected",
"function",
"parse_key",
"(",
"$",
"key",
")",
"{",
"$",
"ekey",
"=",
"new",
"enigma_key",
"(",
")",
";",
"foreach",
"(",
"$",
"key",
"->",
"getUserIds",
"(",
")",
"as",
"$",
"idx",
"=>",
"$",
"user",
")",
"{",
"$",
"id",
"=",
"new",
"enigma_userid",
"(",
")",
";",
"$",
"id",
"->",
"name",
"=",
"$",
"user",
"->",
"getName",
"(",
")",
";",
"$",
"id",
"->",
"comment",
"=",
"$",
"user",
"->",
"getComment",
"(",
")",
";",
"$",
"id",
"->",
"email",
"=",
"$",
"user",
"->",
"getEmail",
"(",
")",
";",
"$",
"id",
"->",
"valid",
"=",
"$",
"user",
"->",
"isValid",
"(",
")",
";",
"$",
"id",
"->",
"revoked",
"=",
"$",
"user",
"->",
"isRevoked",
"(",
")",
";",
"$",
"ekey",
"->",
"users",
"[",
"$",
"idx",
"]",
"=",
"$",
"id",
";",
"}",
"$",
"ekey",
"->",
"name",
"=",
"trim",
"(",
"$",
"ekey",
"->",
"users",
"[",
"0",
"]",
"->",
"name",
".",
"' <'",
".",
"$",
"ekey",
"->",
"users",
"[",
"0",
"]",
"->",
"email",
".",
"'>'",
")",
";",
"// keep reference to Crypt_GPG's key for performance reasons",
"$",
"ekey",
"->",
"reference",
"=",
"$",
"key",
";",
"foreach",
"(",
"$",
"key",
"->",
"getSubKeys",
"(",
")",
"as",
"$",
"idx",
"=>",
"$",
"subkey",
")",
"{",
"$",
"skey",
"=",
"new",
"enigma_subkey",
"(",
")",
";",
"$",
"skey",
"->",
"id",
"=",
"$",
"subkey",
"->",
"getId",
"(",
")",
";",
"$",
"skey",
"->",
"revoked",
"=",
"$",
"subkey",
"->",
"isRevoked",
"(",
")",
";",
"$",
"skey",
"->",
"created",
"=",
"$",
"subkey",
"->",
"getCreationDate",
"(",
")",
";",
"$",
"skey",
"->",
"expires",
"=",
"$",
"subkey",
"->",
"getExpirationDate",
"(",
")",
";",
"$",
"skey",
"->",
"fingerprint",
"=",
"$",
"subkey",
"->",
"getFingerprint",
"(",
")",
";",
"$",
"skey",
"->",
"has_private",
"=",
"$",
"subkey",
"->",
"hasPrivate",
"(",
")",
";",
"$",
"skey",
"->",
"algorithm",
"=",
"$",
"subkey",
"->",
"getAlgorithm",
"(",
")",
";",
"$",
"skey",
"->",
"length",
"=",
"$",
"subkey",
"->",
"getLength",
"(",
")",
";",
"$",
"skey",
"->",
"usage",
"=",
"$",
"subkey",
"->",
"usage",
"(",
")",
";",
"$",
"ekey",
"->",
"subkeys",
"[",
"$",
"idx",
"]",
"=",
"$",
"skey",
";",
"}",
";",
"$",
"ekey",
"->",
"id",
"=",
"$",
"ekey",
"->",
"subkeys",
"[",
"0",
"]",
"->",
"id",
";",
"return",
"$",
"ekey",
";",
"}"
] |
Converts Crypt_GPG_Key object into Enigma's key object
@param Crypt_GPG_Key Key object
@return enigma_key Key object
|
[
"Converts",
"Crypt_GPG_Key",
"object",
"into",
"Enigma",
"s",
"key",
"object"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php#L496-L534
|
train
|
netgen/NetgenInformationCollectionBundle
|
bundle/Form/Builder/FormBuilder.php
|
FormBuilder.createFormForLocation
|
public function createFormForLocation(Location $location, $useAjax = false)
{
$contentInfo = $location->contentInfo;
$contentType = $this->contentTypeService->loadContentType($contentInfo->contentTypeId);
$data = new DataWrapper(new InformationCollectionStruct(), $contentType, $location);
$formBuilder = $this->formFactory
->createBuilder(
Kernel::VERSION_ID < 20800 ?
'ezforms_information_collection' :
InformationCollectionType::class,
$data,
array(
'csrf_protection' => $this->useCsrf,
)
);
if ($useAjax) {
$formBuilder->setAction($this->router->generate('netgen_information_collection_handle_ajax', array('location' => $location->id)));
}
return $formBuilder;
}
|
php
|
public function createFormForLocation(Location $location, $useAjax = false)
{
$contentInfo = $location->contentInfo;
$contentType = $this->contentTypeService->loadContentType($contentInfo->contentTypeId);
$data = new DataWrapper(new InformationCollectionStruct(), $contentType, $location);
$formBuilder = $this->formFactory
->createBuilder(
Kernel::VERSION_ID < 20800 ?
'ezforms_information_collection' :
InformationCollectionType::class,
$data,
array(
'csrf_protection' => $this->useCsrf,
)
);
if ($useAjax) {
$formBuilder->setAction($this->router->generate('netgen_information_collection_handle_ajax', array('location' => $location->id)));
}
return $formBuilder;
}
|
[
"public",
"function",
"createFormForLocation",
"(",
"Location",
"$",
"location",
",",
"$",
"useAjax",
"=",
"false",
")",
"{",
"$",
"contentInfo",
"=",
"$",
"location",
"->",
"contentInfo",
";",
"$",
"contentType",
"=",
"$",
"this",
"->",
"contentTypeService",
"->",
"loadContentType",
"(",
"$",
"contentInfo",
"->",
"contentTypeId",
")",
";",
"$",
"data",
"=",
"new",
"DataWrapper",
"(",
"new",
"InformationCollectionStruct",
"(",
")",
",",
"$",
"contentType",
",",
"$",
"location",
")",
";",
"$",
"formBuilder",
"=",
"$",
"this",
"->",
"formFactory",
"->",
"createBuilder",
"(",
"Kernel",
"::",
"VERSION_ID",
"<",
"20800",
"?",
"'ezforms_information_collection'",
":",
"InformationCollectionType",
"::",
"class",
",",
"$",
"data",
",",
"array",
"(",
"'csrf_protection'",
"=>",
"$",
"this",
"->",
"useCsrf",
",",
")",
")",
";",
"if",
"(",
"$",
"useAjax",
")",
"{",
"$",
"formBuilder",
"->",
"setAction",
"(",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"'netgen_information_collection_handle_ajax'",
",",
"array",
"(",
"'location'",
"=>",
"$",
"location",
"->",
"id",
")",
")",
")",
";",
"}",
"return",
"$",
"formBuilder",
";",
"}"
] |
Creates Information collection Form object for given Location object.
@param Location $location
@param bool $useAjax
@return FormBuilderInterface
|
[
"Creates",
"Information",
"collection",
"Form",
"object",
"for",
"given",
"Location",
"object",
"."
] |
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
|
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Form/Builder/FormBuilder.php#L65-L89
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_session_redis.php
|
rcube_session_redis.read
|
public function read($key)
{
if ($value = $this->redis->get($key)) {
$arr = unserialize($value);
$this->changed = $arr['changed'];
$this->ip = $arr['ip'];
$this->vars = $arr['vars'];
$this->key = $key;
return !empty($this->vars) ? (string) $this->vars : '';
}
return '';
}
|
php
|
public function read($key)
{
if ($value = $this->redis->get($key)) {
$arr = unserialize($value);
$this->changed = $arr['changed'];
$this->ip = $arr['ip'];
$this->vars = $arr['vars'];
$this->key = $key;
return !empty($this->vars) ? (string) $this->vars : '';
}
return '';
}
|
[
"public",
"function",
"read",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"value",
"=",
"$",
"this",
"->",
"redis",
"->",
"get",
"(",
"$",
"key",
")",
")",
"{",
"$",
"arr",
"=",
"unserialize",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"changed",
"=",
"$",
"arr",
"[",
"'changed'",
"]",
";",
"$",
"this",
"->",
"ip",
"=",
"$",
"arr",
"[",
"'ip'",
"]",
";",
"$",
"this",
"->",
"vars",
"=",
"$",
"arr",
"[",
"'vars'",
"]",
";",
"$",
"this",
"->",
"key",
"=",
"$",
"key",
";",
"return",
"!",
"empty",
"(",
"$",
"this",
"->",
"vars",
")",
"?",
"(",
"string",
")",
"$",
"this",
"->",
"vars",
":",
"''",
";",
"}",
"return",
"''",
";",
"}"
] |
read data from redis store
@param $key
@return null
|
[
"read",
"data",
"from",
"redis",
"store"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_session_redis.php#L161-L174
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/virtuser_query/virtuser_query.php
|
virtuser_query.email2user
|
function email2user($p)
{
$dbh = $this->get_dbh();
$sql_result = $dbh->query(preg_replace('/%m/', $dbh->escape($p['email']), $this->config['user']));
if ($sql_arr = $dbh->fetch_array($sql_result)) {
$p['user'] = $sql_arr[0];
}
return $p;
}
|
php
|
function email2user($p)
{
$dbh = $this->get_dbh();
$sql_result = $dbh->query(preg_replace('/%m/', $dbh->escape($p['email']), $this->config['user']));
if ($sql_arr = $dbh->fetch_array($sql_result)) {
$p['user'] = $sql_arr[0];
}
return $p;
}
|
[
"function",
"email2user",
"(",
"$",
"p",
")",
"{",
"$",
"dbh",
"=",
"$",
"this",
"->",
"get_dbh",
"(",
")",
";",
"$",
"sql_result",
"=",
"$",
"dbh",
"->",
"query",
"(",
"preg_replace",
"(",
"'/%m/'",
",",
"$",
"dbh",
"->",
"escape",
"(",
"$",
"p",
"[",
"'email'",
"]",
")",
",",
"$",
"this",
"->",
"config",
"[",
"'user'",
"]",
")",
")",
";",
"if",
"(",
"$",
"sql_arr",
"=",
"$",
"dbh",
"->",
"fetch_array",
"(",
"$",
"sql_result",
")",
")",
"{",
"$",
"p",
"[",
"'user'",
"]",
"=",
"$",
"sql_arr",
"[",
"0",
"]",
";",
"}",
"return",
"$",
"p",
";",
"}"
] |
EMail > User
|
[
"EMail",
">",
"User"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/virtuser_query/virtuser_query.php#L99-L110
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/virtuser_query/virtuser_query.php
|
virtuser_query.get_dbh
|
function get_dbh()
{
if (!$this->db) {
if ($dsn = $this->app->config->get('virtuser_query_dsn')) {
// connect to the virtuser database
$this->db = rcube_db::factory($dsn);
$this->db->set_debug((bool)$this->app->config->get('sql_debug'));
$this->db->db_connect('r'); // connect in read mode
}
else {
$this->db = $this->app->get_dbh();
}
}
return $this->db;
}
|
php
|
function get_dbh()
{
if (!$this->db) {
if ($dsn = $this->app->config->get('virtuser_query_dsn')) {
// connect to the virtuser database
$this->db = rcube_db::factory($dsn);
$this->db->set_debug((bool)$this->app->config->get('sql_debug'));
$this->db->db_connect('r'); // connect in read mode
}
else {
$this->db = $this->app->get_dbh();
}
}
return $this->db;
}
|
[
"function",
"get_dbh",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"db",
")",
"{",
"if",
"(",
"$",
"dsn",
"=",
"$",
"this",
"->",
"app",
"->",
"config",
"->",
"get",
"(",
"'virtuser_query_dsn'",
")",
")",
"{",
"// connect to the virtuser database",
"$",
"this",
"->",
"db",
"=",
"rcube_db",
"::",
"factory",
"(",
"$",
"dsn",
")",
";",
"$",
"this",
"->",
"db",
"->",
"set_debug",
"(",
"(",
"bool",
")",
"$",
"this",
"->",
"app",
"->",
"config",
"->",
"get",
"(",
"'sql_debug'",
")",
")",
";",
"$",
"this",
"->",
"db",
"->",
"db_connect",
"(",
"'r'",
")",
";",
"// connect in read mode",
"}",
"else",
"{",
"$",
"this",
"->",
"db",
"=",
"$",
"this",
"->",
"app",
"->",
"get_dbh",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"db",
";",
"}"
] |
Initialize database handler
|
[
"Initialize",
"database",
"handler"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/virtuser_query/virtuser_query.php#L147-L162
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/password/drivers/ldap_simple.php
|
rcube_ldap_simple_password.search_userdn
|
function search_userdn($rcmail, $ds)
{
$search_user = $rcmail->config->get('password_ldap_searchDN');
$search_pass = $rcmail->config->get('password_ldap_searchPW');
$search_base = $rcmail->config->get('password_ldap_search_base');
$search_filter = $rcmail->config->get('password_ldap_search_filter');
if (empty($search_filter)) {
return false;
}
$this->_debug("C: Bind " . ($search_user ? $search_user : '[anonymous]'));
// Bind
if (!ldap_bind($ds, $search_user, $search_pass)) {
$this->_debug("S: ".ldap_error($ds));
return false;
}
$this->_debug("S: OK");
$search_base = rcube_ldap_password::substitute_vars($search_base);
$search_filter = rcube_ldap_password::substitute_vars($search_filter);
$this->_debug("C: Search $search_base for $search_filter");
// Search for the DN
if (!$sr = ldap_search($ds, $search_base, $search_filter)) {
$this->_debug("S: ".ldap_error($ds));
return false;
}
$found = ldap_count_entries($ds, $sr);
$this->_debug("S: OK [found $found records]");
// If no or more entries were found, return false
if ($found != 1) {
return false;
}
return ldap_get_dn($ds, ldap_first_entry($ds, $sr));
}
|
php
|
function search_userdn($rcmail, $ds)
{
$search_user = $rcmail->config->get('password_ldap_searchDN');
$search_pass = $rcmail->config->get('password_ldap_searchPW');
$search_base = $rcmail->config->get('password_ldap_search_base');
$search_filter = $rcmail->config->get('password_ldap_search_filter');
if (empty($search_filter)) {
return false;
}
$this->_debug("C: Bind " . ($search_user ? $search_user : '[anonymous]'));
// Bind
if (!ldap_bind($ds, $search_user, $search_pass)) {
$this->_debug("S: ".ldap_error($ds));
return false;
}
$this->_debug("S: OK");
$search_base = rcube_ldap_password::substitute_vars($search_base);
$search_filter = rcube_ldap_password::substitute_vars($search_filter);
$this->_debug("C: Search $search_base for $search_filter");
// Search for the DN
if (!$sr = ldap_search($ds, $search_base, $search_filter)) {
$this->_debug("S: ".ldap_error($ds));
return false;
}
$found = ldap_count_entries($ds, $sr);
$this->_debug("S: OK [found $found records]");
// If no or more entries were found, return false
if ($found != 1) {
return false;
}
return ldap_get_dn($ds, ldap_first_entry($ds, $sr));
}
|
[
"function",
"search_userdn",
"(",
"$",
"rcmail",
",",
"$",
"ds",
")",
"{",
"$",
"search_user",
"=",
"$",
"rcmail",
"->",
"config",
"->",
"get",
"(",
"'password_ldap_searchDN'",
")",
";",
"$",
"search_pass",
"=",
"$",
"rcmail",
"->",
"config",
"->",
"get",
"(",
"'password_ldap_searchPW'",
")",
";",
"$",
"search_base",
"=",
"$",
"rcmail",
"->",
"config",
"->",
"get",
"(",
"'password_ldap_search_base'",
")",
";",
"$",
"search_filter",
"=",
"$",
"rcmail",
"->",
"config",
"->",
"get",
"(",
"'password_ldap_search_filter'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"search_filter",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"_debug",
"(",
"\"C: Bind \"",
".",
"(",
"$",
"search_user",
"?",
"$",
"search_user",
":",
"'[anonymous]'",
")",
")",
";",
"// Bind",
"if",
"(",
"!",
"ldap_bind",
"(",
"$",
"ds",
",",
"$",
"search_user",
",",
"$",
"search_pass",
")",
")",
"{",
"$",
"this",
"->",
"_debug",
"(",
"\"S: \"",
".",
"ldap_error",
"(",
"$",
"ds",
")",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"_debug",
"(",
"\"S: OK\"",
")",
";",
"$",
"search_base",
"=",
"rcube_ldap_password",
"::",
"substitute_vars",
"(",
"$",
"search_base",
")",
";",
"$",
"search_filter",
"=",
"rcube_ldap_password",
"::",
"substitute_vars",
"(",
"$",
"search_filter",
")",
";",
"$",
"this",
"->",
"_debug",
"(",
"\"C: Search $search_base for $search_filter\"",
")",
";",
"// Search for the DN",
"if",
"(",
"!",
"$",
"sr",
"=",
"ldap_search",
"(",
"$",
"ds",
",",
"$",
"search_base",
",",
"$",
"search_filter",
")",
")",
"{",
"$",
"this",
"->",
"_debug",
"(",
"\"S: \"",
".",
"ldap_error",
"(",
"$",
"ds",
")",
")",
";",
"return",
"false",
";",
"}",
"$",
"found",
"=",
"ldap_count_entries",
"(",
"$",
"ds",
",",
"$",
"sr",
")",
";",
"$",
"this",
"->",
"_debug",
"(",
"\"S: OK [found $found records]\"",
")",
";",
"// If no or more entries were found, return false",
"if",
"(",
"$",
"found",
"!=",
"1",
")",
"{",
"return",
"false",
";",
"}",
"return",
"ldap_get_dn",
"(",
"$",
"ds",
",",
"ldap_first_entry",
"(",
"$",
"ds",
",",
"$",
"sr",
")",
")",
";",
"}"
] |
Bind with searchDN and searchPW and search for the user's DN
Use search_base and search_filter defined in config file
Return the found DN
|
[
"Bind",
"with",
"searchDN",
"and",
"searchPW",
"and",
"search",
"for",
"the",
"user",
"s",
"DN",
"Use",
"search_base",
"and",
"search_filter",
"defined",
"in",
"config",
"file",
"Return",
"the",
"found",
"DN"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/password/drivers/ldap_simple.php#L192-L234
|
train
|
netgen/NetgenInformationCollectionBundle
|
bundle/Factory/FieldDataFactory.php
|
FieldDataFactory.getLegacyValue
|
public function getLegacyValue(Value $value, FieldDefinition $fieldDefinition)
{
/** @var CustomFieldHandlerInterface $handler */
$handler = $this->registry->handle($value);
if (null === $handler) {
return new LegacyData(
$fieldDefinition->id,
0,
0,
(string)$value
);
}
if ($handler instanceof CustomLegacyFieldHandlerInterface) {
return $handler->getLegacyValue($value, $fieldDefinition);
}
return new LegacyData(
$fieldDefinition->id,
0,
0,
(string) $handler->toString($value, $fieldDefinition)
);
}
|
php
|
public function getLegacyValue(Value $value, FieldDefinition $fieldDefinition)
{
/** @var CustomFieldHandlerInterface $handler */
$handler = $this->registry->handle($value);
if (null === $handler) {
return new LegacyData(
$fieldDefinition->id,
0,
0,
(string)$value
);
}
if ($handler instanceof CustomLegacyFieldHandlerInterface) {
return $handler->getLegacyValue($value, $fieldDefinition);
}
return new LegacyData(
$fieldDefinition->id,
0,
0,
(string) $handler->toString($value, $fieldDefinition)
);
}
|
[
"public",
"function",
"getLegacyValue",
"(",
"Value",
"$",
"value",
",",
"FieldDefinition",
"$",
"fieldDefinition",
")",
"{",
"/** @var CustomFieldHandlerInterface $handler */",
"$",
"handler",
"=",
"$",
"this",
"->",
"registry",
"->",
"handle",
"(",
"$",
"value",
")",
";",
"if",
"(",
"null",
"===",
"$",
"handler",
")",
"{",
"return",
"new",
"LegacyData",
"(",
"$",
"fieldDefinition",
"->",
"id",
",",
"0",
",",
"0",
",",
"(",
"string",
")",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"handler",
"instanceof",
"CustomLegacyFieldHandlerInterface",
")",
"{",
"return",
"$",
"handler",
"->",
"getLegacyValue",
"(",
"$",
"value",
",",
"$",
"fieldDefinition",
")",
";",
"}",
"return",
"new",
"LegacyData",
"(",
"$",
"fieldDefinition",
"->",
"id",
",",
"0",
",",
"0",
",",
"(",
"string",
")",
"$",
"handler",
"->",
"toString",
"(",
"$",
"value",
",",
"$",
"fieldDefinition",
")",
")",
";",
"}"
] |
Returns value object that represents legacy value.
@param Value $value
@param FieldDefinition $fieldDefinition
@return LegacyData
|
[
"Returns",
"value",
"object",
"that",
"represents",
"legacy",
"value",
"."
] |
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
|
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Factory/FieldDataFactory.php#L37-L62
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php
|
rcube_sieve_engine.connect
|
public function connect($username, $password)
{
// Get connection parameters
$host = $this->rc->config->get('managesieve_host', 'localhost');
$port = $this->rc->config->get('managesieve_port');
$tls = $this->rc->config->get('managesieve_usetls', false);
$host = rcube_utils::parse_host($host);
$host = rcube_utils::idn_to_ascii($host);
// remove tls:// prefix, set TLS flag
if (($host = preg_replace('|^tls://|i', '', $host, 1, $cnt)) && $cnt) {
$tls = true;
}
if (empty($port)) {
$port = getservbyname('sieve', 'tcp');
if (empty($port)) {
$port = self::PORT;
}
}
$plugin = $this->rc->plugins->exec_hook('managesieve_connect', array(
'user' => $username,
'password' => $password,
'host' => $host,
'port' => $port,
'usetls' => $tls,
'auth_type' => $this->rc->config->get('managesieve_auth_type'),
'disabled' => $this->rc->config->get('managesieve_disabled_extensions'),
'debug' => $this->rc->config->get('managesieve_debug', false),
'auth_cid' => $this->rc->config->get('managesieve_auth_cid'),
'auth_pw' => $this->rc->config->get('managesieve_auth_pw'),
'socket_options' => $this->rc->config->get('managesieve_conn_options'),
));
// Handle per-host socket options
rcube_utils::parse_socket_options($plugin['socket_options'], $plugin['host']);
// try to connect to managesieve server and to fetch the script
$this->sieve = new rcube_sieve(
$plugin['user'],
$plugin['password'],
$plugin['host'],
$plugin['port'],
$plugin['auth_type'],
$plugin['usetls'],
$plugin['disabled'],
$plugin['debug'],
$plugin['auth_cid'],
$plugin['auth_pw'],
$plugin['socket_options']
);
$error = $this->sieve->error();
if ($error) {
rcube::raise_error(array(
'code' => 403,
'file' => __FILE__,
'line' => __LINE__,
'message' => "Unable to connect to managesieve on $host:$port"
), true, false);
}
return $error;
}
|
php
|
public function connect($username, $password)
{
// Get connection parameters
$host = $this->rc->config->get('managesieve_host', 'localhost');
$port = $this->rc->config->get('managesieve_port');
$tls = $this->rc->config->get('managesieve_usetls', false);
$host = rcube_utils::parse_host($host);
$host = rcube_utils::idn_to_ascii($host);
// remove tls:// prefix, set TLS flag
if (($host = preg_replace('|^tls://|i', '', $host, 1, $cnt)) && $cnt) {
$tls = true;
}
if (empty($port)) {
$port = getservbyname('sieve', 'tcp');
if (empty($port)) {
$port = self::PORT;
}
}
$plugin = $this->rc->plugins->exec_hook('managesieve_connect', array(
'user' => $username,
'password' => $password,
'host' => $host,
'port' => $port,
'usetls' => $tls,
'auth_type' => $this->rc->config->get('managesieve_auth_type'),
'disabled' => $this->rc->config->get('managesieve_disabled_extensions'),
'debug' => $this->rc->config->get('managesieve_debug', false),
'auth_cid' => $this->rc->config->get('managesieve_auth_cid'),
'auth_pw' => $this->rc->config->get('managesieve_auth_pw'),
'socket_options' => $this->rc->config->get('managesieve_conn_options'),
));
// Handle per-host socket options
rcube_utils::parse_socket_options($plugin['socket_options'], $plugin['host']);
// try to connect to managesieve server and to fetch the script
$this->sieve = new rcube_sieve(
$plugin['user'],
$plugin['password'],
$plugin['host'],
$plugin['port'],
$plugin['auth_type'],
$plugin['usetls'],
$plugin['disabled'],
$plugin['debug'],
$plugin['auth_cid'],
$plugin['auth_pw'],
$plugin['socket_options']
);
$error = $this->sieve->error();
if ($error) {
rcube::raise_error(array(
'code' => 403,
'file' => __FILE__,
'line' => __LINE__,
'message' => "Unable to connect to managesieve on $host:$port"
), true, false);
}
return $error;
}
|
[
"public",
"function",
"connect",
"(",
"$",
"username",
",",
"$",
"password",
")",
"{",
"// Get connection parameters",
"$",
"host",
"=",
"$",
"this",
"->",
"rc",
"->",
"config",
"->",
"get",
"(",
"'managesieve_host'",
",",
"'localhost'",
")",
";",
"$",
"port",
"=",
"$",
"this",
"->",
"rc",
"->",
"config",
"->",
"get",
"(",
"'managesieve_port'",
")",
";",
"$",
"tls",
"=",
"$",
"this",
"->",
"rc",
"->",
"config",
"->",
"get",
"(",
"'managesieve_usetls'",
",",
"false",
")",
";",
"$",
"host",
"=",
"rcube_utils",
"::",
"parse_host",
"(",
"$",
"host",
")",
";",
"$",
"host",
"=",
"rcube_utils",
"::",
"idn_to_ascii",
"(",
"$",
"host",
")",
";",
"// remove tls:// prefix, set TLS flag",
"if",
"(",
"(",
"$",
"host",
"=",
"preg_replace",
"(",
"'|^tls://|i'",
",",
"''",
",",
"$",
"host",
",",
"1",
",",
"$",
"cnt",
")",
")",
"&&",
"$",
"cnt",
")",
"{",
"$",
"tls",
"=",
"true",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"port",
")",
")",
"{",
"$",
"port",
"=",
"getservbyname",
"(",
"'sieve'",
",",
"'tcp'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"port",
")",
")",
"{",
"$",
"port",
"=",
"self",
"::",
"PORT",
";",
"}",
"}",
"$",
"plugin",
"=",
"$",
"this",
"->",
"rc",
"->",
"plugins",
"->",
"exec_hook",
"(",
"'managesieve_connect'",
",",
"array",
"(",
"'user'",
"=>",
"$",
"username",
",",
"'password'",
"=>",
"$",
"password",
",",
"'host'",
"=>",
"$",
"host",
",",
"'port'",
"=>",
"$",
"port",
",",
"'usetls'",
"=>",
"$",
"tls",
",",
"'auth_type'",
"=>",
"$",
"this",
"->",
"rc",
"->",
"config",
"->",
"get",
"(",
"'managesieve_auth_type'",
")",
",",
"'disabled'",
"=>",
"$",
"this",
"->",
"rc",
"->",
"config",
"->",
"get",
"(",
"'managesieve_disabled_extensions'",
")",
",",
"'debug'",
"=>",
"$",
"this",
"->",
"rc",
"->",
"config",
"->",
"get",
"(",
"'managesieve_debug'",
",",
"false",
")",
",",
"'auth_cid'",
"=>",
"$",
"this",
"->",
"rc",
"->",
"config",
"->",
"get",
"(",
"'managesieve_auth_cid'",
")",
",",
"'auth_pw'",
"=>",
"$",
"this",
"->",
"rc",
"->",
"config",
"->",
"get",
"(",
"'managesieve_auth_pw'",
")",
",",
"'socket_options'",
"=>",
"$",
"this",
"->",
"rc",
"->",
"config",
"->",
"get",
"(",
"'managesieve_conn_options'",
")",
",",
")",
")",
";",
"// Handle per-host socket options",
"rcube_utils",
"::",
"parse_socket_options",
"(",
"$",
"plugin",
"[",
"'socket_options'",
"]",
",",
"$",
"plugin",
"[",
"'host'",
"]",
")",
";",
"// try to connect to managesieve server and to fetch the script",
"$",
"this",
"->",
"sieve",
"=",
"new",
"rcube_sieve",
"(",
"$",
"plugin",
"[",
"'user'",
"]",
",",
"$",
"plugin",
"[",
"'password'",
"]",
",",
"$",
"plugin",
"[",
"'host'",
"]",
",",
"$",
"plugin",
"[",
"'port'",
"]",
",",
"$",
"plugin",
"[",
"'auth_type'",
"]",
",",
"$",
"plugin",
"[",
"'usetls'",
"]",
",",
"$",
"plugin",
"[",
"'disabled'",
"]",
",",
"$",
"plugin",
"[",
"'debug'",
"]",
",",
"$",
"plugin",
"[",
"'auth_cid'",
"]",
",",
"$",
"plugin",
"[",
"'auth_pw'",
"]",
",",
"$",
"plugin",
"[",
"'socket_options'",
"]",
")",
";",
"$",
"error",
"=",
"$",
"this",
"->",
"sieve",
"->",
"error",
"(",
")",
";",
"if",
"(",
"$",
"error",
")",
"{",
"rcube",
"::",
"raise_error",
"(",
"array",
"(",
"'code'",
"=>",
"403",
",",
"'file'",
"=>",
"__FILE__",
",",
"'line'",
"=>",
"__LINE__",
",",
"'message'",
"=>",
"\"Unable to connect to managesieve on $host:$port\"",
")",
",",
"true",
",",
"false",
")",
";",
"}",
"return",
"$",
"error",
";",
"}"
] |
Connect to configured managesieve server
@param string $username User login
@param string $password User password
@return int Connection status: 0 on success, >0 on failure
|
[
"Connect",
"to",
"configured",
"managesieve",
"server"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php#L162-L228
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php
|
rcube_sieve_engine.filters_list
|
function filters_list($attrib)
{
// add id to message list table if not specified
if (!strlen($attrib['id']))
$attrib['id'] = 'rcmfilterslist';
// define list of cols to be displayed
$a_show_cols = array('name');
$result = $this->list_rules();
// create XHTML table
$out = $this->rc->table_output($attrib, $result, $a_show_cols, 'id');
// set client env
$this->rc->output->add_gui_object('filterslist', $attrib['id']);
$this->rc->output->include_script('list.js');
// add some labels to client
$this->rc->output->add_label('managesieve.filterdeleteconfirm');
return $out;
}
|
php
|
function filters_list($attrib)
{
// add id to message list table if not specified
if (!strlen($attrib['id']))
$attrib['id'] = 'rcmfilterslist';
// define list of cols to be displayed
$a_show_cols = array('name');
$result = $this->list_rules();
// create XHTML table
$out = $this->rc->table_output($attrib, $result, $a_show_cols, 'id');
// set client env
$this->rc->output->add_gui_object('filterslist', $attrib['id']);
$this->rc->output->include_script('list.js');
// add some labels to client
$this->rc->output->add_label('managesieve.filterdeleteconfirm');
return $out;
}
|
[
"function",
"filters_list",
"(",
"$",
"attrib",
")",
"{",
"// add id to message list table if not specified",
"if",
"(",
"!",
"strlen",
"(",
"$",
"attrib",
"[",
"'id'",
"]",
")",
")",
"$",
"attrib",
"[",
"'id'",
"]",
"=",
"'rcmfilterslist'",
";",
"// define list of cols to be displayed",
"$",
"a_show_cols",
"=",
"array",
"(",
"'name'",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"list_rules",
"(",
")",
";",
"// create XHTML table",
"$",
"out",
"=",
"$",
"this",
"->",
"rc",
"->",
"table_output",
"(",
"$",
"attrib",
",",
"$",
"result",
",",
"$",
"a_show_cols",
",",
"'id'",
")",
";",
"// set client env",
"$",
"this",
"->",
"rc",
"->",
"output",
"->",
"add_gui_object",
"(",
"'filterslist'",
",",
"$",
"attrib",
"[",
"'id'",
"]",
")",
";",
"$",
"this",
"->",
"rc",
"->",
"output",
"->",
"include_script",
"(",
"'list.js'",
")",
";",
"// add some labels to client",
"$",
"this",
"->",
"rc",
"->",
"output",
"->",
"add_label",
"(",
"'managesieve.filterdeleteconfirm'",
")",
";",
"return",
"$",
"out",
";",
"}"
] |
return the filters list as HTML table
|
[
"return",
"the",
"filters",
"list",
"as",
"HTML",
"table"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php#L1203-L1225
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php
|
rcube_sieve_engine.validate_date_part
|
protected function validate_date_part($type, $value)
{
// we do simple validation of date/part format
switch ($type) {
case 'date': // yyyy-mm-dd
return preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $value);
case 'iso8601':
return preg_match('/^[0-9: .,ZWT+-]+$/', $value);
case 'std11':
return preg_match('/^((Sun|Mon|Tue|Wed|Thu|Fri|Sat),\s+)?[0-9]{1,2}\s+'
. '(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+[0-9]{2,4}\s+'
. '[0-9]{2}:[0-9]{2}(:[0-9]{2})?\s+([+-]*[0-9]{4}|[A-Z]{1,3})$', $value);
case 'julian':
return preg_match('/^[0-9]+$/', $value);
case 'time': // hh:mm:ss
return preg_match('/^[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $value);
case 'year':
return preg_match('/^[0-9]{4}$/', $value);
case 'month':
return preg_match('/^[0-9]{2}$/', $value) && $value > 0 && $value < 13;
case 'day':
return preg_match('/^[0-9]{2}$/', $value) && $value > 0 && $value < 32;
case 'hour':
return preg_match('/^[0-9]{2}$/', $value) && $value < 24;
case 'minute':
return preg_match('/^[0-9]{2}$/', $value) && $value < 60;
case 'second':
// According to RFC5260, seconds can be from 00 to 60
return preg_match('/^[0-9]{2}$/', $value) && $value < 61;
case 'weekday':
return preg_match('/^[0-9]$/', $value) && $value < 7;
case 'zone':
return preg_match('/^[+-][0-9]{4}$/', $value);
}
}
|
php
|
protected function validate_date_part($type, $value)
{
// we do simple validation of date/part format
switch ($type) {
case 'date': // yyyy-mm-dd
return preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $value);
case 'iso8601':
return preg_match('/^[0-9: .,ZWT+-]+$/', $value);
case 'std11':
return preg_match('/^((Sun|Mon|Tue|Wed|Thu|Fri|Sat),\s+)?[0-9]{1,2}\s+'
. '(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+[0-9]{2,4}\s+'
. '[0-9]{2}:[0-9]{2}(:[0-9]{2})?\s+([+-]*[0-9]{4}|[A-Z]{1,3})$', $value);
case 'julian':
return preg_match('/^[0-9]+$/', $value);
case 'time': // hh:mm:ss
return preg_match('/^[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $value);
case 'year':
return preg_match('/^[0-9]{4}$/', $value);
case 'month':
return preg_match('/^[0-9]{2}$/', $value) && $value > 0 && $value < 13;
case 'day':
return preg_match('/^[0-9]{2}$/', $value) && $value > 0 && $value < 32;
case 'hour':
return preg_match('/^[0-9]{2}$/', $value) && $value < 24;
case 'minute':
return preg_match('/^[0-9]{2}$/', $value) && $value < 60;
case 'second':
// According to RFC5260, seconds can be from 00 to 60
return preg_match('/^[0-9]{2}$/', $value) && $value < 61;
case 'weekday':
return preg_match('/^[0-9]$/', $value) && $value < 7;
case 'zone':
return preg_match('/^[+-][0-9]{4}$/', $value);
}
}
|
[
"protected",
"function",
"validate_date_part",
"(",
"$",
"type",
",",
"$",
"value",
")",
"{",
"// we do simple validation of date/part format",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'date'",
":",
"// yyyy-mm-dd",
"return",
"preg_match",
"(",
"'/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/'",
",",
"$",
"value",
")",
";",
"case",
"'iso8601'",
":",
"return",
"preg_match",
"(",
"'/^[0-9: .,ZWT+-]+$/'",
",",
"$",
"value",
")",
";",
"case",
"'std11'",
":",
"return",
"preg_match",
"(",
"'/^((Sun|Mon|Tue|Wed|Thu|Fri|Sat),\\s+)?[0-9]{1,2}\\s+'",
".",
"'(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\s+[0-9]{2,4}\\s+'",
".",
"'[0-9]{2}:[0-9]{2}(:[0-9]{2})?\\s+([+-]*[0-9]{4}|[A-Z]{1,3})$'",
",",
"$",
"value",
")",
";",
"case",
"'julian'",
":",
"return",
"preg_match",
"(",
"'/^[0-9]+$/'",
",",
"$",
"value",
")",
";",
"case",
"'time'",
":",
"// hh:mm:ss",
"return",
"preg_match",
"(",
"'/^[0-9]{2}:[0-9]{2}:[0-9]{2}$/'",
",",
"$",
"value",
")",
";",
"case",
"'year'",
":",
"return",
"preg_match",
"(",
"'/^[0-9]{4}$/'",
",",
"$",
"value",
")",
";",
"case",
"'month'",
":",
"return",
"preg_match",
"(",
"'/^[0-9]{2}$/'",
",",
"$",
"value",
")",
"&&",
"$",
"value",
">",
"0",
"&&",
"$",
"value",
"<",
"13",
";",
"case",
"'day'",
":",
"return",
"preg_match",
"(",
"'/^[0-9]{2}$/'",
",",
"$",
"value",
")",
"&&",
"$",
"value",
">",
"0",
"&&",
"$",
"value",
"<",
"32",
";",
"case",
"'hour'",
":",
"return",
"preg_match",
"(",
"'/^[0-9]{2}$/'",
",",
"$",
"value",
")",
"&&",
"$",
"value",
"<",
"24",
";",
"case",
"'minute'",
":",
"return",
"preg_match",
"(",
"'/^[0-9]{2}$/'",
",",
"$",
"value",
")",
"&&",
"$",
"value",
"<",
"60",
";",
"case",
"'second'",
":",
"// According to RFC5260, seconds can be from 00 to 60",
"return",
"preg_match",
"(",
"'/^[0-9]{2}$/'",
",",
"$",
"value",
")",
"&&",
"$",
"value",
"<",
"61",
";",
"case",
"'weekday'",
":",
"return",
"preg_match",
"(",
"'/^[0-9]$/'",
",",
"$",
"value",
")",
"&&",
"$",
"value",
"<",
"7",
";",
"case",
"'zone'",
":",
"return",
"preg_match",
"(",
"'/^[+-][0-9]{4}$/'",
",",
"$",
"value",
")",
";",
"}",
"}"
] |
Validate input for date part elements
|
[
"Validate",
"input",
"for",
"date",
"part",
"elements"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php#L2362-L2396
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php
|
rcube_sieve_engine.list_scripts
|
public function list_scripts()
{
if ($this->list !== null) {
return $this->list;
}
$this->list = $this->sieve->get_scripts();
// Handle active script(s) and list of scripts according to Kolab's KEP:14
if ($this->rc->config->get('managesieve_kolab_master')) {
// Skip protected names
foreach ((array)$this->list as $idx => $name) {
$_name = strtoupper($name);
if ($_name == 'MASTER')
$master_script = $name;
else if ($_name == 'MANAGEMENT')
$management_script = $name;
else if($_name == 'USER')
$user_script = $name;
else
continue;
unset($this->list[$idx]);
}
// get active script(s), read USER script
if ($user_script) {
$extension = $this->rc->config->get('managesieve_filename_extension', '.sieve');
$filename_regex = '/'.preg_quote($extension, '/').'$/';
$_SESSION['managesieve_user_script'] = $user_script;
$this->sieve->load($user_script);
foreach ($this->sieve->script->as_array() as $rules) {
foreach ($rules['actions'] as $action) {
if ($action['type'] == 'include' && empty($action['global'])) {
$name = preg_replace($filename_regex, '', $action['target']);
// make sure the script exist
if (in_array($name, $this->list)) {
$this->active[] = $name;
}
}
}
}
}
// create USER script if it doesn't exist
else {
$content = "# USER Management Script\n"
."#\n"
."# This script includes the various active sieve scripts\n"
."# it is AUTOMATICALLY GENERATED. DO NOT EDIT MANUALLY!\n"
."#\n"
."# For more information, see http://wiki.kolab.org/KEP:14#USER\n"
."#\n";
if ($this->sieve->save_script('USER', $content)) {
$_SESSION['managesieve_user_script'] = 'USER';
if (empty($this->master_file))
$this->sieve->activate('USER');
}
}
}
else if (!empty($this->list)) {
// Get active script name
if ($active = $this->sieve->get_active()) {
$this->active = array($active);
}
// Hide scripts from config
$exceptions = $this->rc->config->get('managesieve_filename_exceptions');
if (!empty($exceptions)) {
$this->list = array_diff($this->list, (array)$exceptions);
}
}
// reindex
if (!empty($this->list)) {
$this->list = array_values($this->list);
}
return $this->list;
}
|
php
|
public function list_scripts()
{
if ($this->list !== null) {
return $this->list;
}
$this->list = $this->sieve->get_scripts();
// Handle active script(s) and list of scripts according to Kolab's KEP:14
if ($this->rc->config->get('managesieve_kolab_master')) {
// Skip protected names
foreach ((array)$this->list as $idx => $name) {
$_name = strtoupper($name);
if ($_name == 'MASTER')
$master_script = $name;
else if ($_name == 'MANAGEMENT')
$management_script = $name;
else if($_name == 'USER')
$user_script = $name;
else
continue;
unset($this->list[$idx]);
}
// get active script(s), read USER script
if ($user_script) {
$extension = $this->rc->config->get('managesieve_filename_extension', '.sieve');
$filename_regex = '/'.preg_quote($extension, '/').'$/';
$_SESSION['managesieve_user_script'] = $user_script;
$this->sieve->load($user_script);
foreach ($this->sieve->script->as_array() as $rules) {
foreach ($rules['actions'] as $action) {
if ($action['type'] == 'include' && empty($action['global'])) {
$name = preg_replace($filename_regex, '', $action['target']);
// make sure the script exist
if (in_array($name, $this->list)) {
$this->active[] = $name;
}
}
}
}
}
// create USER script if it doesn't exist
else {
$content = "# USER Management Script\n"
."#\n"
."# This script includes the various active sieve scripts\n"
."# it is AUTOMATICALLY GENERATED. DO NOT EDIT MANUALLY!\n"
."#\n"
."# For more information, see http://wiki.kolab.org/KEP:14#USER\n"
."#\n";
if ($this->sieve->save_script('USER', $content)) {
$_SESSION['managesieve_user_script'] = 'USER';
if (empty($this->master_file))
$this->sieve->activate('USER');
}
}
}
else if (!empty($this->list)) {
// Get active script name
if ($active = $this->sieve->get_active()) {
$this->active = array($active);
}
// Hide scripts from config
$exceptions = $this->rc->config->get('managesieve_filename_exceptions');
if (!empty($exceptions)) {
$this->list = array_diff($this->list, (array)$exceptions);
}
}
// reindex
if (!empty($this->list)) {
$this->list = array_values($this->list);
}
return $this->list;
}
|
[
"public",
"function",
"list_scripts",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"list",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"list",
";",
"}",
"$",
"this",
"->",
"list",
"=",
"$",
"this",
"->",
"sieve",
"->",
"get_scripts",
"(",
")",
";",
"// Handle active script(s) and list of scripts according to Kolab's KEP:14",
"if",
"(",
"$",
"this",
"->",
"rc",
"->",
"config",
"->",
"get",
"(",
"'managesieve_kolab_master'",
")",
")",
"{",
"// Skip protected names",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"list",
"as",
"$",
"idx",
"=>",
"$",
"name",
")",
"{",
"$",
"_name",
"=",
"strtoupper",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"_name",
"==",
"'MASTER'",
")",
"$",
"master_script",
"=",
"$",
"name",
";",
"else",
"if",
"(",
"$",
"_name",
"==",
"'MANAGEMENT'",
")",
"$",
"management_script",
"=",
"$",
"name",
";",
"else",
"if",
"(",
"$",
"_name",
"==",
"'USER'",
")",
"$",
"user_script",
"=",
"$",
"name",
";",
"else",
"continue",
";",
"unset",
"(",
"$",
"this",
"->",
"list",
"[",
"$",
"idx",
"]",
")",
";",
"}",
"// get active script(s), read USER script",
"if",
"(",
"$",
"user_script",
")",
"{",
"$",
"extension",
"=",
"$",
"this",
"->",
"rc",
"->",
"config",
"->",
"get",
"(",
"'managesieve_filename_extension'",
",",
"'.sieve'",
")",
";",
"$",
"filename_regex",
"=",
"'/'",
".",
"preg_quote",
"(",
"$",
"extension",
",",
"'/'",
")",
".",
"'$/'",
";",
"$",
"_SESSION",
"[",
"'managesieve_user_script'",
"]",
"=",
"$",
"user_script",
";",
"$",
"this",
"->",
"sieve",
"->",
"load",
"(",
"$",
"user_script",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"sieve",
"->",
"script",
"->",
"as_array",
"(",
")",
"as",
"$",
"rules",
")",
"{",
"foreach",
"(",
"$",
"rules",
"[",
"'actions'",
"]",
"as",
"$",
"action",
")",
"{",
"if",
"(",
"$",
"action",
"[",
"'type'",
"]",
"==",
"'include'",
"&&",
"empty",
"(",
"$",
"action",
"[",
"'global'",
"]",
")",
")",
"{",
"$",
"name",
"=",
"preg_replace",
"(",
"$",
"filename_regex",
",",
"''",
",",
"$",
"action",
"[",
"'target'",
"]",
")",
";",
"// make sure the script exist",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"list",
")",
")",
"{",
"$",
"this",
"->",
"active",
"[",
"]",
"=",
"$",
"name",
";",
"}",
"}",
"}",
"}",
"}",
"// create USER script if it doesn't exist",
"else",
"{",
"$",
"content",
"=",
"\"# USER Management Script\\n\"",
".",
"\"#\\n\"",
".",
"\"# This script includes the various active sieve scripts\\n\"",
".",
"\"# it is AUTOMATICALLY GENERATED. DO NOT EDIT MANUALLY!\\n\"",
".",
"\"#\\n\"",
".",
"\"# For more information, see http://wiki.kolab.org/KEP:14#USER\\n\"",
".",
"\"#\\n\"",
";",
"if",
"(",
"$",
"this",
"->",
"sieve",
"->",
"save_script",
"(",
"'USER'",
",",
"$",
"content",
")",
")",
"{",
"$",
"_SESSION",
"[",
"'managesieve_user_script'",
"]",
"=",
"'USER'",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"master_file",
")",
")",
"$",
"this",
"->",
"sieve",
"->",
"activate",
"(",
"'USER'",
")",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"list",
")",
")",
"{",
"// Get active script name",
"if",
"(",
"$",
"active",
"=",
"$",
"this",
"->",
"sieve",
"->",
"get_active",
"(",
")",
")",
"{",
"$",
"this",
"->",
"active",
"=",
"array",
"(",
"$",
"active",
")",
";",
"}",
"// Hide scripts from config",
"$",
"exceptions",
"=",
"$",
"this",
"->",
"rc",
"->",
"config",
"->",
"get",
"(",
"'managesieve_filename_exceptions'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"exceptions",
")",
")",
"{",
"$",
"this",
"->",
"list",
"=",
"array_diff",
"(",
"$",
"this",
"->",
"list",
",",
"(",
"array",
")",
"$",
"exceptions",
")",
";",
"}",
"}",
"// reindex",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"list",
")",
")",
"{",
"$",
"this",
"->",
"list",
"=",
"array_values",
"(",
"$",
"this",
"->",
"list",
")",
";",
"}",
"return",
"$",
"this",
"->",
"list",
";",
"}"
] |
List sieve scripts
@return array Scripts list
|
[
"List",
"sieve",
"scripts"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php#L2432-L2512
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php
|
rcube_sieve_engine.remove_script
|
public function remove_script($name)
{
$result = $this->sieve->remove($name);
// Kolab's KEP:14
if ($result && $this->rc->config->get('managesieve_kolab_master')) {
$this->deactivate_script($name);
}
return $result;
}
|
php
|
public function remove_script($name)
{
$result = $this->sieve->remove($name);
// Kolab's KEP:14
if ($result && $this->rc->config->get('managesieve_kolab_master')) {
$this->deactivate_script($name);
}
return $result;
}
|
[
"public",
"function",
"remove_script",
"(",
"$",
"name",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"sieve",
"->",
"remove",
"(",
"$",
"name",
")",
";",
"// Kolab's KEP:14",
"if",
"(",
"$",
"result",
"&&",
"$",
"this",
"->",
"rc",
"->",
"config",
"->",
"get",
"(",
"'managesieve_kolab_master'",
")",
")",
"{",
"$",
"this",
"->",
"deactivate_script",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Removes sieve script
@param string $name Script name
@return bool True on success, False on failure
|
[
"Removes",
"sieve",
"script"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php#L2521-L2531
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php
|
rcube_sieve_engine.activate_script
|
public function activate_script($name)
{
// Kolab's KEP:14
if ($this->rc->config->get('managesieve_kolab_master')) {
$extension = $this->rc->config->get('managesieve_filename_extension', '.sieve');
$user_script = $_SESSION['managesieve_user_script'];
// if the script is not active...
if ($user_script && array_search($name, $this->active) === false) {
// ...rewrite USER file adding appropriate include command
if ($this->sieve->load($user_script)) {
$script = $this->sieve->script->as_array();
$list = array();
$regexp = '/' . preg_quote($extension, '/') . '$/';
// Create new include entry
$rule = array(
'actions' => array(
0 => array(
'target' => $name.$extension,
'type' => 'include',
'personal' => true,
)));
// get all active scripts for sorting
foreach ($script as $rid => $rules) {
foreach ($rules['actions'] as $action) {
if ($action['type'] == 'include' && empty($action['global'])) {
$target = $extension ? preg_replace($regexp, '', $action['target']) : $action['target'];
$list[] = $target;
}
}
}
$list[] = $name;
// Sort and find current script position
asort($list, SORT_LOCALE_STRING);
$list = array_values($list);
$index = array_search($name, $list);
// add rule at the end of the script
if ($index === false || $index == count($list)-1) {
$this->sieve->script->add_rule($rule);
}
// add rule at index position
else {
$script2 = array();
foreach ($script as $rid => $rules) {
if ($rid == $index) {
$script2[] = $rule;
}
$script2[] = $rules;
}
$this->sieve->script->content = $script2;
}
$result = $this->sieve->save();
if ($result) {
$this->active[] = $name;
}
}
}
}
else {
$result = $this->sieve->activate($name);
if ($result)
$this->active = array($name);
}
return $result;
}
|
php
|
public function activate_script($name)
{
// Kolab's KEP:14
if ($this->rc->config->get('managesieve_kolab_master')) {
$extension = $this->rc->config->get('managesieve_filename_extension', '.sieve');
$user_script = $_SESSION['managesieve_user_script'];
// if the script is not active...
if ($user_script && array_search($name, $this->active) === false) {
// ...rewrite USER file adding appropriate include command
if ($this->sieve->load($user_script)) {
$script = $this->sieve->script->as_array();
$list = array();
$regexp = '/' . preg_quote($extension, '/') . '$/';
// Create new include entry
$rule = array(
'actions' => array(
0 => array(
'target' => $name.$extension,
'type' => 'include',
'personal' => true,
)));
// get all active scripts for sorting
foreach ($script as $rid => $rules) {
foreach ($rules['actions'] as $action) {
if ($action['type'] == 'include' && empty($action['global'])) {
$target = $extension ? preg_replace($regexp, '', $action['target']) : $action['target'];
$list[] = $target;
}
}
}
$list[] = $name;
// Sort and find current script position
asort($list, SORT_LOCALE_STRING);
$list = array_values($list);
$index = array_search($name, $list);
// add rule at the end of the script
if ($index === false || $index == count($list)-1) {
$this->sieve->script->add_rule($rule);
}
// add rule at index position
else {
$script2 = array();
foreach ($script as $rid => $rules) {
if ($rid == $index) {
$script2[] = $rule;
}
$script2[] = $rules;
}
$this->sieve->script->content = $script2;
}
$result = $this->sieve->save();
if ($result) {
$this->active[] = $name;
}
}
}
}
else {
$result = $this->sieve->activate($name);
if ($result)
$this->active = array($name);
}
return $result;
}
|
[
"public",
"function",
"activate_script",
"(",
"$",
"name",
")",
"{",
"// Kolab's KEP:14",
"if",
"(",
"$",
"this",
"->",
"rc",
"->",
"config",
"->",
"get",
"(",
"'managesieve_kolab_master'",
")",
")",
"{",
"$",
"extension",
"=",
"$",
"this",
"->",
"rc",
"->",
"config",
"->",
"get",
"(",
"'managesieve_filename_extension'",
",",
"'.sieve'",
")",
";",
"$",
"user_script",
"=",
"$",
"_SESSION",
"[",
"'managesieve_user_script'",
"]",
";",
"// if the script is not active...",
"if",
"(",
"$",
"user_script",
"&&",
"array_search",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"active",
")",
"===",
"false",
")",
"{",
"// ...rewrite USER file adding appropriate include command",
"if",
"(",
"$",
"this",
"->",
"sieve",
"->",
"load",
"(",
"$",
"user_script",
")",
")",
"{",
"$",
"script",
"=",
"$",
"this",
"->",
"sieve",
"->",
"script",
"->",
"as_array",
"(",
")",
";",
"$",
"list",
"=",
"array",
"(",
")",
";",
"$",
"regexp",
"=",
"'/'",
".",
"preg_quote",
"(",
"$",
"extension",
",",
"'/'",
")",
".",
"'$/'",
";",
"// Create new include entry",
"$",
"rule",
"=",
"array",
"(",
"'actions'",
"=>",
"array",
"(",
"0",
"=>",
"array",
"(",
"'target'",
"=>",
"$",
"name",
".",
"$",
"extension",
",",
"'type'",
"=>",
"'include'",
",",
"'personal'",
"=>",
"true",
",",
")",
")",
")",
";",
"// get all active scripts for sorting",
"foreach",
"(",
"$",
"script",
"as",
"$",
"rid",
"=>",
"$",
"rules",
")",
"{",
"foreach",
"(",
"$",
"rules",
"[",
"'actions'",
"]",
"as",
"$",
"action",
")",
"{",
"if",
"(",
"$",
"action",
"[",
"'type'",
"]",
"==",
"'include'",
"&&",
"empty",
"(",
"$",
"action",
"[",
"'global'",
"]",
")",
")",
"{",
"$",
"target",
"=",
"$",
"extension",
"?",
"preg_replace",
"(",
"$",
"regexp",
",",
"''",
",",
"$",
"action",
"[",
"'target'",
"]",
")",
":",
"$",
"action",
"[",
"'target'",
"]",
";",
"$",
"list",
"[",
"]",
"=",
"$",
"target",
";",
"}",
"}",
"}",
"$",
"list",
"[",
"]",
"=",
"$",
"name",
";",
"// Sort and find current script position",
"asort",
"(",
"$",
"list",
",",
"SORT_LOCALE_STRING",
")",
";",
"$",
"list",
"=",
"array_values",
"(",
"$",
"list",
")",
";",
"$",
"index",
"=",
"array_search",
"(",
"$",
"name",
",",
"$",
"list",
")",
";",
"// add rule at the end of the script",
"if",
"(",
"$",
"index",
"===",
"false",
"||",
"$",
"index",
"==",
"count",
"(",
"$",
"list",
")",
"-",
"1",
")",
"{",
"$",
"this",
"->",
"sieve",
"->",
"script",
"->",
"add_rule",
"(",
"$",
"rule",
")",
";",
"}",
"// add rule at index position",
"else",
"{",
"$",
"script2",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"script",
"as",
"$",
"rid",
"=>",
"$",
"rules",
")",
"{",
"if",
"(",
"$",
"rid",
"==",
"$",
"index",
")",
"{",
"$",
"script2",
"[",
"]",
"=",
"$",
"rule",
";",
"}",
"$",
"script2",
"[",
"]",
"=",
"$",
"rules",
";",
"}",
"$",
"this",
"->",
"sieve",
"->",
"script",
"->",
"content",
"=",
"$",
"script2",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"sieve",
"->",
"save",
"(",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"active",
"[",
"]",
"=",
"$",
"name",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"sieve",
"->",
"activate",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"result",
")",
"$",
"this",
"->",
"active",
"=",
"array",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Activates sieve script
@param string $name Script name
@return bool True on success, False on failure
|
[
"Activates",
"sieve",
"script"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php#L2540-L2610
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php
|
rcube_sieve_engine.deactivate_script
|
public function deactivate_script($name)
{
// Kolab's KEP:14
if ($this->rc->config->get('managesieve_kolab_master')) {
$extension = $this->rc->config->get('managesieve_filename_extension', '.sieve');
$user_script = $_SESSION['managesieve_user_script'];
// if the script is active...
if ($user_script && ($key = array_search($name, $this->active)) !== false) {
// ...rewrite USER file removing appropriate include command
if ($this->sieve->load($user_script)) {
$script = $this->sieve->script->as_array();
$name = $name.$extension;
foreach ($script as $rid => $rules) {
foreach ($rules['actions'] as $action) {
if ($action['type'] == 'include' && empty($action['global'])
&& $action['target'] == $name
) {
break 2;
}
}
}
// Entry found
if ($rid < count($script)) {
$this->sieve->script->delete_rule($rid);
$result = $this->sieve->save();
if ($result) {
unset($this->active[$key]);
}
}
}
}
}
else {
$result = $this->sieve->deactivate();
if ($result)
$this->active = array();
}
return $result;
}
|
php
|
public function deactivate_script($name)
{
// Kolab's KEP:14
if ($this->rc->config->get('managesieve_kolab_master')) {
$extension = $this->rc->config->get('managesieve_filename_extension', '.sieve');
$user_script = $_SESSION['managesieve_user_script'];
// if the script is active...
if ($user_script && ($key = array_search($name, $this->active)) !== false) {
// ...rewrite USER file removing appropriate include command
if ($this->sieve->load($user_script)) {
$script = $this->sieve->script->as_array();
$name = $name.$extension;
foreach ($script as $rid => $rules) {
foreach ($rules['actions'] as $action) {
if ($action['type'] == 'include' && empty($action['global'])
&& $action['target'] == $name
) {
break 2;
}
}
}
// Entry found
if ($rid < count($script)) {
$this->sieve->script->delete_rule($rid);
$result = $this->sieve->save();
if ($result) {
unset($this->active[$key]);
}
}
}
}
}
else {
$result = $this->sieve->deactivate();
if ($result)
$this->active = array();
}
return $result;
}
|
[
"public",
"function",
"deactivate_script",
"(",
"$",
"name",
")",
"{",
"// Kolab's KEP:14",
"if",
"(",
"$",
"this",
"->",
"rc",
"->",
"config",
"->",
"get",
"(",
"'managesieve_kolab_master'",
")",
")",
"{",
"$",
"extension",
"=",
"$",
"this",
"->",
"rc",
"->",
"config",
"->",
"get",
"(",
"'managesieve_filename_extension'",
",",
"'.sieve'",
")",
";",
"$",
"user_script",
"=",
"$",
"_SESSION",
"[",
"'managesieve_user_script'",
"]",
";",
"// if the script is active...",
"if",
"(",
"$",
"user_script",
"&&",
"(",
"$",
"key",
"=",
"array_search",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"active",
")",
")",
"!==",
"false",
")",
"{",
"// ...rewrite USER file removing appropriate include command",
"if",
"(",
"$",
"this",
"->",
"sieve",
"->",
"load",
"(",
"$",
"user_script",
")",
")",
"{",
"$",
"script",
"=",
"$",
"this",
"->",
"sieve",
"->",
"script",
"->",
"as_array",
"(",
")",
";",
"$",
"name",
"=",
"$",
"name",
".",
"$",
"extension",
";",
"foreach",
"(",
"$",
"script",
"as",
"$",
"rid",
"=>",
"$",
"rules",
")",
"{",
"foreach",
"(",
"$",
"rules",
"[",
"'actions'",
"]",
"as",
"$",
"action",
")",
"{",
"if",
"(",
"$",
"action",
"[",
"'type'",
"]",
"==",
"'include'",
"&&",
"empty",
"(",
"$",
"action",
"[",
"'global'",
"]",
")",
"&&",
"$",
"action",
"[",
"'target'",
"]",
"==",
"$",
"name",
")",
"{",
"break",
"2",
";",
"}",
"}",
"}",
"// Entry found",
"if",
"(",
"$",
"rid",
"<",
"count",
"(",
"$",
"script",
")",
")",
"{",
"$",
"this",
"->",
"sieve",
"->",
"script",
"->",
"delete_rule",
"(",
"$",
"rid",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"sieve",
"->",
"save",
"(",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"active",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}",
"}",
"}",
"else",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"sieve",
"->",
"deactivate",
"(",
")",
";",
"if",
"(",
"$",
"result",
")",
"$",
"this",
"->",
"active",
"=",
"array",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Deactivates sieve script
@param string $name Script name
@return bool True on success, False on failure
|
[
"Deactivates",
"sieve",
"script"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php#L2619-L2661
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php
|
rcube_sieve_engine.list_rules
|
public function list_rules()
{
$result = array();
$i = 1;
foreach ($this->script as $idx => $filter) {
if (empty($filter['actions'])) {
continue;
}
$fname = $filter['name'] ?: "#$i";
$result[] = array(
'id' => $idx,
'name' => $fname,
'class' => $filter['disabled'] ? 'disabled' : '',
);
$i++;
}
return $result;
}
|
php
|
public function list_rules()
{
$result = array();
$i = 1;
foreach ($this->script as $idx => $filter) {
if (empty($filter['actions'])) {
continue;
}
$fname = $filter['name'] ?: "#$i";
$result[] = array(
'id' => $idx,
'name' => $fname,
'class' => $filter['disabled'] ? 'disabled' : '',
);
$i++;
}
return $result;
}
|
[
"public",
"function",
"list_rules",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"i",
"=",
"1",
";",
"foreach",
"(",
"$",
"this",
"->",
"script",
"as",
"$",
"idx",
"=>",
"$",
"filter",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"filter",
"[",
"'actions'",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"fname",
"=",
"$",
"filter",
"[",
"'name'",
"]",
"?",
":",
"\"#$i\"",
";",
"$",
"result",
"[",
"]",
"=",
"array",
"(",
"'id'",
"=>",
"$",
"idx",
",",
"'name'",
"=>",
"$",
"fname",
",",
"'class'",
"=>",
"$",
"filter",
"[",
"'disabled'",
"]",
"?",
"'disabled'",
":",
"''",
",",
")",
";",
"$",
"i",
"++",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns list of rules from the current script
@return array List of rules
|
[
"Returns",
"list",
"of",
"rules",
"from",
"the",
"current",
"script"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php#L2682-L2701
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php
|
rcube_sieve_engine.init_script
|
protected function init_script()
{
if (!$this->sieve->script) {
return;
}
$this->script = $this->sieve->script->as_array();
$headers = array();
$exceptions = array('date', 'currentdate', 'size', 'body');
// find common headers used in script, will be added to the list
// of available (predefined) headers (#1489271)
foreach ($this->script as $rule) {
foreach ((array) $rule['tests'] as $test) {
if ($test['test'] == 'header') {
foreach ((array) $test['arg1'] as $header) {
$lc_header = strtolower($header);
// skip special names to not confuse UI
if (in_array($lc_header, $exceptions)) {
continue;
}
if (!isset($this->headers[$lc_header]) && !isset($headers[$lc_header])) {
$headers[$lc_header] = $header;
}
}
}
}
}
ksort($headers);
$this->headers += $headers;
}
|
php
|
protected function init_script()
{
if (!$this->sieve->script) {
return;
}
$this->script = $this->sieve->script->as_array();
$headers = array();
$exceptions = array('date', 'currentdate', 'size', 'body');
// find common headers used in script, will be added to the list
// of available (predefined) headers (#1489271)
foreach ($this->script as $rule) {
foreach ((array) $rule['tests'] as $test) {
if ($test['test'] == 'header') {
foreach ((array) $test['arg1'] as $header) {
$lc_header = strtolower($header);
// skip special names to not confuse UI
if (in_array($lc_header, $exceptions)) {
continue;
}
if (!isset($this->headers[$lc_header]) && !isset($headers[$lc_header])) {
$headers[$lc_header] = $header;
}
}
}
}
}
ksort($headers);
$this->headers += $headers;
}
|
[
"protected",
"function",
"init_script",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"sieve",
"->",
"script",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"script",
"=",
"$",
"this",
"->",
"sieve",
"->",
"script",
"->",
"as_array",
"(",
")",
";",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"$",
"exceptions",
"=",
"array",
"(",
"'date'",
",",
"'currentdate'",
",",
"'size'",
",",
"'body'",
")",
";",
"// find common headers used in script, will be added to the list",
"// of available (predefined) headers (#1489271)",
"foreach",
"(",
"$",
"this",
"->",
"script",
"as",
"$",
"rule",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"rule",
"[",
"'tests'",
"]",
"as",
"$",
"test",
")",
"{",
"if",
"(",
"$",
"test",
"[",
"'test'",
"]",
"==",
"'header'",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"test",
"[",
"'arg1'",
"]",
"as",
"$",
"header",
")",
"{",
"$",
"lc_header",
"=",
"strtolower",
"(",
"$",
"header",
")",
";",
"// skip special names to not confuse UI",
"if",
"(",
"in_array",
"(",
"$",
"lc_header",
",",
"$",
"exceptions",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"headers",
"[",
"$",
"lc_header",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"headers",
"[",
"$",
"lc_header",
"]",
")",
")",
"{",
"$",
"headers",
"[",
"$",
"lc_header",
"]",
"=",
"$",
"header",
";",
"}",
"}",
"}",
"}",
"}",
"ksort",
"(",
"$",
"headers",
")",
";",
"$",
"this",
"->",
"headers",
"+=",
"$",
"headers",
";",
"}"
] |
Initializes internal script data
|
[
"Initializes",
"internal",
"script",
"data"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php#L2706-L2741
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php
|
rcube_sieve_engine.user_emails
|
protected function user_emails()
{
$addresses = $this->rc->user->list_emails();
foreach ($addresses as $idx => $email) {
$addresses[$idx] = $email['email'];
}
$addresses = array_unique($addresses);
sort($addresses);
return $addresses;
}
|
php
|
protected function user_emails()
{
$addresses = $this->rc->user->list_emails();
foreach ($addresses as $idx => $email) {
$addresses[$idx] = $email['email'];
}
$addresses = array_unique($addresses);
sort($addresses);
return $addresses;
}
|
[
"protected",
"function",
"user_emails",
"(",
")",
"{",
"$",
"addresses",
"=",
"$",
"this",
"->",
"rc",
"->",
"user",
"->",
"list_emails",
"(",
")",
";",
"foreach",
"(",
"$",
"addresses",
"as",
"$",
"idx",
"=>",
"$",
"email",
")",
"{",
"$",
"addresses",
"[",
"$",
"idx",
"]",
"=",
"$",
"email",
"[",
"'email'",
"]",
";",
"}",
"$",
"addresses",
"=",
"array_unique",
"(",
"$",
"addresses",
")",
";",
"sort",
"(",
"$",
"addresses",
")",
";",
"return",
"$",
"addresses",
";",
"}"
] |
Get all e-mail addresses of the user
|
[
"Get",
"all",
"e",
"-",
"mail",
"addresses",
"of",
"the",
"user"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php#L2746-L2758
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/include/rcmail_output_json.php
|
rcmail_output_json.set_pagetitle
|
public function set_pagetitle($title)
{
if ($this->config->get('devel_mode') && !empty($_SESSION['username'])) {
$name = $_SESSION['username'];
}
else {
$name = $this->config->get('product_name');
}
$this->command('set_pagetitle', empty($name) ? $title : $name . ' :: ' . $title);
}
|
php
|
public function set_pagetitle($title)
{
if ($this->config->get('devel_mode') && !empty($_SESSION['username'])) {
$name = $_SESSION['username'];
}
else {
$name = $this->config->get('product_name');
}
$this->command('set_pagetitle', empty($name) ? $title : $name . ' :: ' . $title);
}
|
[
"public",
"function",
"set_pagetitle",
"(",
"$",
"title",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'devel_mode'",
")",
"&&",
"!",
"empty",
"(",
"$",
"_SESSION",
"[",
"'username'",
"]",
")",
")",
"{",
"$",
"name",
"=",
"$",
"_SESSION",
"[",
"'username'",
"]",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'product_name'",
")",
";",
"}",
"$",
"this",
"->",
"command",
"(",
"'set_pagetitle'",
",",
"empty",
"(",
"$",
"name",
")",
"?",
"$",
"title",
":",
"$",
"name",
".",
"' :: '",
".",
"$",
"title",
")",
";",
"}"
] |
Issue command to set page title
@param string $title New page title
|
[
"Issue",
"command",
"to",
"set",
"page",
"title"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/include/rcmail_output_json.php#L44-L54
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/include/rcmail_output_json.php
|
rcmail_output_json.add_label
|
public function add_label()
{
$args = func_get_args();
if (count($args) == 1 && is_array($args[0])) {
$args = $args[0];
}
foreach ($args as $name) {
$this->texts[$name] = $this->app->gettext($name);
}
}
|
php
|
public function add_label()
{
$args = func_get_args();
if (count($args) == 1 && is_array($args[0])) {
$args = $args[0];
}
foreach ($args as $name) {
$this->texts[$name] = $this->app->gettext($name);
}
}
|
[
"public",
"function",
"add_label",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"args",
")",
"==",
"1",
"&&",
"is_array",
"(",
"$",
"args",
"[",
"0",
"]",
")",
")",
"{",
"$",
"args",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"}",
"foreach",
"(",
"$",
"args",
"as",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"texts",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"app",
"->",
"gettext",
"(",
"$",
"name",
")",
";",
"}",
"}"
] |
Add a localized label to the client environment
|
[
"Add",
"a",
"localized",
"label",
"to",
"the",
"client",
"environment"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/include/rcmail_output_json.php#L98-L108
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/include/rcmail_output_json.php
|
rcmail_output_json.remote_response
|
protected function remote_response($add = '')
{
static $s_header_sent = false;
if (!$s_header_sent) {
$s_header_sent = true;
$this->nocacheing_headers();
header('Content-Type: text/plain; charset=' . $this->get_charset());
}
// unset default env vars
unset($this->env['task'], $this->env['action'], $this->env['comm_path']);
$rcmail = rcmail::get_instance();
$response['action'] = $rcmail->action;
if ($unlock = rcube_utils::get_input_value('_unlock', rcube_utils::INPUT_GPC)) {
$response['unlock'] = $unlock;
}
if (!empty($this->env))
$response['env'] = $this->env;
if (!empty($this->texts))
$response['texts'] = $this->texts;
// send function calls
$response['exec'] = $this->get_js_commands() . $add;
if (!empty($this->callbacks))
$response['callbacks'] = $this->callbacks;
// trigger generic hook where plugins can put additional content to the response
$hook = $this->app->plugins->exec_hook("render_response", array('response' => $response));
// save some memory
$response = $hook['response'];
unset($hook['response']);
echo self::json_serialize($response, $this->devel_mode, false);
}
|
php
|
protected function remote_response($add = '')
{
static $s_header_sent = false;
if (!$s_header_sent) {
$s_header_sent = true;
$this->nocacheing_headers();
header('Content-Type: text/plain; charset=' . $this->get_charset());
}
// unset default env vars
unset($this->env['task'], $this->env['action'], $this->env['comm_path']);
$rcmail = rcmail::get_instance();
$response['action'] = $rcmail->action;
if ($unlock = rcube_utils::get_input_value('_unlock', rcube_utils::INPUT_GPC)) {
$response['unlock'] = $unlock;
}
if (!empty($this->env))
$response['env'] = $this->env;
if (!empty($this->texts))
$response['texts'] = $this->texts;
// send function calls
$response['exec'] = $this->get_js_commands() . $add;
if (!empty($this->callbacks))
$response['callbacks'] = $this->callbacks;
// trigger generic hook where plugins can put additional content to the response
$hook = $this->app->plugins->exec_hook("render_response", array('response' => $response));
// save some memory
$response = $hook['response'];
unset($hook['response']);
echo self::json_serialize($response, $this->devel_mode, false);
}
|
[
"protected",
"function",
"remote_response",
"(",
"$",
"add",
"=",
"''",
")",
"{",
"static",
"$",
"s_header_sent",
"=",
"false",
";",
"if",
"(",
"!",
"$",
"s_header_sent",
")",
"{",
"$",
"s_header_sent",
"=",
"true",
";",
"$",
"this",
"->",
"nocacheing_headers",
"(",
")",
";",
"header",
"(",
"'Content-Type: text/plain; charset='",
".",
"$",
"this",
"->",
"get_charset",
"(",
")",
")",
";",
"}",
"// unset default env vars",
"unset",
"(",
"$",
"this",
"->",
"env",
"[",
"'task'",
"]",
",",
"$",
"this",
"->",
"env",
"[",
"'action'",
"]",
",",
"$",
"this",
"->",
"env",
"[",
"'comm_path'",
"]",
")",
";",
"$",
"rcmail",
"=",
"rcmail",
"::",
"get_instance",
"(",
")",
";",
"$",
"response",
"[",
"'action'",
"]",
"=",
"$",
"rcmail",
"->",
"action",
";",
"if",
"(",
"$",
"unlock",
"=",
"rcube_utils",
"::",
"get_input_value",
"(",
"'_unlock'",
",",
"rcube_utils",
"::",
"INPUT_GPC",
")",
")",
"{",
"$",
"response",
"[",
"'unlock'",
"]",
"=",
"$",
"unlock",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"env",
")",
")",
"$",
"response",
"[",
"'env'",
"]",
"=",
"$",
"this",
"->",
"env",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"texts",
")",
")",
"$",
"response",
"[",
"'texts'",
"]",
"=",
"$",
"this",
"->",
"texts",
";",
"// send function calls",
"$",
"response",
"[",
"'exec'",
"]",
"=",
"$",
"this",
"->",
"get_js_commands",
"(",
")",
".",
"$",
"add",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"callbacks",
")",
")",
"$",
"response",
"[",
"'callbacks'",
"]",
"=",
"$",
"this",
"->",
"callbacks",
";",
"// trigger generic hook where plugins can put additional content to the response",
"$",
"hook",
"=",
"$",
"this",
"->",
"app",
"->",
"plugins",
"->",
"exec_hook",
"(",
"\"render_response\"",
",",
"array",
"(",
"'response'",
"=>",
"$",
"response",
")",
")",
";",
"// save some memory",
"$",
"response",
"=",
"$",
"hook",
"[",
"'response'",
"]",
";",
"unset",
"(",
"$",
"hook",
"[",
"'response'",
"]",
")",
";",
"echo",
"self",
"::",
"json_serialize",
"(",
"$",
"response",
",",
"$",
"this",
"->",
"devel_mode",
",",
"false",
")",
";",
"}"
] |
Send an AJAX response with executable JS code
@param string $add Additional JS code
|
[
"Send",
"an",
"AJAX",
"response",
"with",
"executable",
"JS",
"code"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/include/rcmail_output_json.php#L196-L236
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_charset.php
|
rcube_charset.clean
|
public static function clean($input)
{
// handle input of type array
if (is_array($input)) {
foreach ($input as $idx => $val) {
$input[$idx] = self::clean($val);
}
return $input;
}
if (!is_string($input) || $input == '') {
return $input;
}
// iconv/mbstring are much faster (especially with long strings)
if (function_exists('mb_convert_encoding')) {
$msch = mb_substitute_character();
mb_substitute_character('none');
$res = mb_convert_encoding($input, 'UTF-8', 'UTF-8');
mb_substitute_character($msch);
if ($res !== false) {
return $res;
}
}
if (function_exists('iconv')) {
if (($res = @iconv('UTF-8', 'UTF-8//IGNORE', $input)) !== false) {
return $res;
}
}
$seq = '';
$out = '';
$regexp = '/^('.
// '[\x00-\x7F]'. // UTF8-1
'|[\xC2-\xDF][\x80-\xBF]'. // UTF8-2
'|\xE0[\xA0-\xBF][\x80-\xBF]'. // UTF8-3
'|[\xE1-\xEC][\x80-\xBF][\x80-\xBF]'. // UTF8-3
'|\xED[\x80-\x9F][\x80-\xBF]'. // UTF8-3
'|[\xEE-\xEF][\x80-\xBF][\x80-\xBF]'. // UTF8-3
'|\xF0[\x90-\xBF][\x80-\xBF][\x80-\xBF]'. // UTF8-4
'|[\xF1-\xF3][\x80-\xBF][\x80-\xBF][\x80-\xBF]'.// UTF8-4
'|\xF4[\x80-\x8F][\x80-\xBF][\x80-\xBF]'. // UTF8-4
')$/';
for ($i = 0, $len = strlen($input); $i < $len; $i++) {
$chr = $input[$i];
$ord = ord($chr);
// 1-byte character
if ($ord <= 0x7F) {
if ($seq !== '') {
$out .= preg_match($regexp, $seq) ? $seq : '';
$seq = '';
}
$out .= $chr;
}
// first byte of multibyte sequence
else if ($ord >= 0xC0) {
if ($seq !== '') {
$out .= preg_match($regexp, $seq) ? $seq : '';
$seq = '';
}
$seq = $chr;
}
// next byte of multibyte sequence
else if ($seq !== '') {
$seq .= $chr;
}
}
if ($seq !== '') {
$out .= preg_match($regexp, $seq) ? $seq : '';
}
return $out;
}
|
php
|
public static function clean($input)
{
// handle input of type array
if (is_array($input)) {
foreach ($input as $idx => $val) {
$input[$idx] = self::clean($val);
}
return $input;
}
if (!is_string($input) || $input == '') {
return $input;
}
// iconv/mbstring are much faster (especially with long strings)
if (function_exists('mb_convert_encoding')) {
$msch = mb_substitute_character();
mb_substitute_character('none');
$res = mb_convert_encoding($input, 'UTF-8', 'UTF-8');
mb_substitute_character($msch);
if ($res !== false) {
return $res;
}
}
if (function_exists('iconv')) {
if (($res = @iconv('UTF-8', 'UTF-8//IGNORE', $input)) !== false) {
return $res;
}
}
$seq = '';
$out = '';
$regexp = '/^('.
// '[\x00-\x7F]'. // UTF8-1
'|[\xC2-\xDF][\x80-\xBF]'. // UTF8-2
'|\xE0[\xA0-\xBF][\x80-\xBF]'. // UTF8-3
'|[\xE1-\xEC][\x80-\xBF][\x80-\xBF]'. // UTF8-3
'|\xED[\x80-\x9F][\x80-\xBF]'. // UTF8-3
'|[\xEE-\xEF][\x80-\xBF][\x80-\xBF]'. // UTF8-3
'|\xF0[\x90-\xBF][\x80-\xBF][\x80-\xBF]'. // UTF8-4
'|[\xF1-\xF3][\x80-\xBF][\x80-\xBF][\x80-\xBF]'.// UTF8-4
'|\xF4[\x80-\x8F][\x80-\xBF][\x80-\xBF]'. // UTF8-4
')$/';
for ($i = 0, $len = strlen($input); $i < $len; $i++) {
$chr = $input[$i];
$ord = ord($chr);
// 1-byte character
if ($ord <= 0x7F) {
if ($seq !== '') {
$out .= preg_match($regexp, $seq) ? $seq : '';
$seq = '';
}
$out .= $chr;
}
// first byte of multibyte sequence
else if ($ord >= 0xC0) {
if ($seq !== '') {
$out .= preg_match($regexp, $seq) ? $seq : '';
$seq = '';
}
$seq = $chr;
}
// next byte of multibyte sequence
else if ($seq !== '') {
$seq .= $chr;
}
}
if ($seq !== '') {
$out .= preg_match($regexp, $seq) ? $seq : '';
}
return $out;
}
|
[
"public",
"static",
"function",
"clean",
"(",
"$",
"input",
")",
"{",
"// handle input of type array",
"if",
"(",
"is_array",
"(",
"$",
"input",
")",
")",
"{",
"foreach",
"(",
"$",
"input",
"as",
"$",
"idx",
"=>",
"$",
"val",
")",
"{",
"$",
"input",
"[",
"$",
"idx",
"]",
"=",
"self",
"::",
"clean",
"(",
"$",
"val",
")",
";",
"}",
"return",
"$",
"input",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"input",
")",
"||",
"$",
"input",
"==",
"''",
")",
"{",
"return",
"$",
"input",
";",
"}",
"// iconv/mbstring are much faster (especially with long strings)",
"if",
"(",
"function_exists",
"(",
"'mb_convert_encoding'",
")",
")",
"{",
"$",
"msch",
"=",
"mb_substitute_character",
"(",
")",
";",
"mb_substitute_character",
"(",
"'none'",
")",
";",
"$",
"res",
"=",
"mb_convert_encoding",
"(",
"$",
"input",
",",
"'UTF-8'",
",",
"'UTF-8'",
")",
";",
"mb_substitute_character",
"(",
"$",
"msch",
")",
";",
"if",
"(",
"$",
"res",
"!==",
"false",
")",
"{",
"return",
"$",
"res",
";",
"}",
"}",
"if",
"(",
"function_exists",
"(",
"'iconv'",
")",
")",
"{",
"if",
"(",
"(",
"$",
"res",
"=",
"@",
"iconv",
"(",
"'UTF-8'",
",",
"'UTF-8//IGNORE'",
",",
"$",
"input",
")",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"res",
";",
"}",
"}",
"$",
"seq",
"=",
"''",
";",
"$",
"out",
"=",
"''",
";",
"$",
"regexp",
"=",
"'/^('",
".",
"// '[\\x00-\\x7F]'. // UTF8-1",
"'|[\\xC2-\\xDF][\\x80-\\xBF]'",
".",
"// UTF8-2",
"'|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]'",
".",
"// UTF8-3",
"'|[\\xE1-\\xEC][\\x80-\\xBF][\\x80-\\xBF]'",
".",
"// UTF8-3",
"'|\\xED[\\x80-\\x9F][\\x80-\\xBF]'",
".",
"// UTF8-3",
"'|[\\xEE-\\xEF][\\x80-\\xBF][\\x80-\\xBF]'",
".",
"// UTF8-3",
"'|\\xF0[\\x90-\\xBF][\\x80-\\xBF][\\x80-\\xBF]'",
".",
"// UTF8-4",
"'|[\\xF1-\\xF3][\\x80-\\xBF][\\x80-\\xBF][\\x80-\\xBF]'",
".",
"// UTF8-4",
"'|\\xF4[\\x80-\\x8F][\\x80-\\xBF][\\x80-\\xBF]'",
".",
"// UTF8-4",
"')$/'",
";",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"len",
"=",
"strlen",
"(",
"$",
"input",
")",
";",
"$",
"i",
"<",
"$",
"len",
";",
"$",
"i",
"++",
")",
"{",
"$",
"chr",
"=",
"$",
"input",
"[",
"$",
"i",
"]",
";",
"$",
"ord",
"=",
"ord",
"(",
"$",
"chr",
")",
";",
"// 1-byte character",
"if",
"(",
"$",
"ord",
"<=",
"0x7F",
")",
"{",
"if",
"(",
"$",
"seq",
"!==",
"''",
")",
"{",
"$",
"out",
".=",
"preg_match",
"(",
"$",
"regexp",
",",
"$",
"seq",
")",
"?",
"$",
"seq",
":",
"''",
";",
"$",
"seq",
"=",
"''",
";",
"}",
"$",
"out",
".=",
"$",
"chr",
";",
"}",
"// first byte of multibyte sequence",
"else",
"if",
"(",
"$",
"ord",
">=",
"0xC0",
")",
"{",
"if",
"(",
"$",
"seq",
"!==",
"''",
")",
"{",
"$",
"out",
".=",
"preg_match",
"(",
"$",
"regexp",
",",
"$",
"seq",
")",
"?",
"$",
"seq",
":",
"''",
";",
"$",
"seq",
"=",
"''",
";",
"}",
"$",
"seq",
"=",
"$",
"chr",
";",
"}",
"// next byte of multibyte sequence",
"else",
"if",
"(",
"$",
"seq",
"!==",
"''",
")",
"{",
"$",
"seq",
".=",
"$",
"chr",
";",
"}",
"}",
"if",
"(",
"$",
"seq",
"!==",
"''",
")",
"{",
"$",
"out",
".=",
"preg_match",
"(",
"$",
"regexp",
",",
"$",
"seq",
")",
"?",
"$",
"seq",
":",
"''",
";",
"}",
"return",
"$",
"out",
";",
"}"
] |
Removes non-unicode characters from input.
@param mixed $input String or array.
@return mixed String or array
|
[
"Removes",
"non",
"-",
"unicode",
"characters",
"from",
"input",
"."
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_charset.php#L830-L909
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/password/password.php
|
password.check_host_login_exceptions
|
private function check_host_login_exceptions()
{
$rcmail = rcmail::get_instance();
// Host exceptions
$hosts = $rcmail->config->get('password_hosts');
if (!empty($hosts) && !in_array($_SESSION['storage_host'], (array) $hosts)) {
return false;
}
// Login exceptions
if ($exceptions = $rcmail->config->get('password_login_exceptions')) {
$exceptions = array_map('trim', (array) $exceptions);
$exceptions = array_filter($exceptions);
$username = $_SESSION['username'];
foreach ($exceptions as $ec) {
if ($username === $ec) {
return false;
}
}
}
return true;
}
|
php
|
private function check_host_login_exceptions()
{
$rcmail = rcmail::get_instance();
// Host exceptions
$hosts = $rcmail->config->get('password_hosts');
if (!empty($hosts) && !in_array($_SESSION['storage_host'], (array) $hosts)) {
return false;
}
// Login exceptions
if ($exceptions = $rcmail->config->get('password_login_exceptions')) {
$exceptions = array_map('trim', (array) $exceptions);
$exceptions = array_filter($exceptions);
$username = $_SESSION['username'];
foreach ($exceptions as $ec) {
if ($username === $ec) {
return false;
}
}
}
return true;
}
|
[
"private",
"function",
"check_host_login_exceptions",
"(",
")",
"{",
"$",
"rcmail",
"=",
"rcmail",
"::",
"get_instance",
"(",
")",
";",
"// Host exceptions",
"$",
"hosts",
"=",
"$",
"rcmail",
"->",
"config",
"->",
"get",
"(",
"'password_hosts'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"hosts",
")",
"&&",
"!",
"in_array",
"(",
"$",
"_SESSION",
"[",
"'storage_host'",
"]",
",",
"(",
"array",
")",
"$",
"hosts",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Login exceptions",
"if",
"(",
"$",
"exceptions",
"=",
"$",
"rcmail",
"->",
"config",
"->",
"get",
"(",
"'password_login_exceptions'",
")",
")",
"{",
"$",
"exceptions",
"=",
"array_map",
"(",
"'trim'",
",",
"(",
"array",
")",
"$",
"exceptions",
")",
";",
"$",
"exceptions",
"=",
"array_filter",
"(",
"$",
"exceptions",
")",
";",
"$",
"username",
"=",
"$",
"_SESSION",
"[",
"'username'",
"]",
";",
"foreach",
"(",
"$",
"exceptions",
"as",
"$",
"ec",
")",
"{",
"if",
"(",
"$",
"username",
"===",
"$",
"ec",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] |
Check if host and login is allowed to change the password, false = not allowed, true = not allowed
|
[
"Check",
"if",
"host",
"and",
"login",
"is",
"allowed",
"to",
"change",
"the",
"password",
"false",
"=",
"not",
"allowed",
"true",
"=",
"not",
"allowed"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/password/password.php#L388-L412
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/krb_authentication/krb_authentication.php
|
krb_authentication.startup
|
function startup($args)
{
if (!empty($_SERVER['REMOTE_USER']) && !empty($_SERVER['KRB5CCNAME'])) {
// handle login action
if (empty($_SESSION['user_id'])) {
$args['action'] = 'login';
$this->redirect_query = $_SERVER['QUERY_STRING'];
}
else {
$_SESSION['password'] = null;
}
}
return $args;
}
|
php
|
function startup($args)
{
if (!empty($_SERVER['REMOTE_USER']) && !empty($_SERVER['KRB5CCNAME'])) {
// handle login action
if (empty($_SESSION['user_id'])) {
$args['action'] = 'login';
$this->redirect_query = $_SERVER['QUERY_STRING'];
}
else {
$_SESSION['password'] = null;
}
}
return $args;
}
|
[
"function",
"startup",
"(",
"$",
"args",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'REMOTE_USER'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'KRB5CCNAME'",
"]",
")",
")",
"{",
"// handle login action",
"if",
"(",
"empty",
"(",
"$",
"_SESSION",
"[",
"'user_id'",
"]",
")",
")",
"{",
"$",
"args",
"[",
"'action'",
"]",
"=",
"'login'",
";",
"$",
"this",
"->",
"redirect_query",
"=",
"$",
"_SERVER",
"[",
"'QUERY_STRING'",
"]",
";",
"}",
"else",
"{",
"$",
"_SESSION",
"[",
"'password'",
"]",
"=",
"null",
";",
"}",
"}",
"return",
"$",
"args",
";",
"}"
] |
Startup hook handler
|
[
"Startup",
"hook",
"handler"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/krb_authentication/krb_authentication.php#L32-L46
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/krb_authentication/krb_authentication.php
|
krb_authentication.authenticate
|
function authenticate($args)
{
if (!empty($_SERVER['REMOTE_USER']) && !empty($_SERVER['KRB5CCNAME'])) {
// Load plugin's config file
$this->load_config();
$rcmail = rcmail::get_instance();
$host = $rcmail->config->get('krb_authentication_host');
if (is_string($host) && trim($host) !== '' && empty($args['host'])) {
$args['host'] = rcube_utils::idn_to_ascii(rcube_utils::parse_host($host));
}
if (!empty($_SERVER['REMOTE_USER'])) {
$args['user'] = $_SERVER['REMOTE_USER'];
$args['pass'] = null;
}
$args['cookiecheck'] = false;
$args['valid'] = true;
}
return $args;
}
|
php
|
function authenticate($args)
{
if (!empty($_SERVER['REMOTE_USER']) && !empty($_SERVER['KRB5CCNAME'])) {
// Load plugin's config file
$this->load_config();
$rcmail = rcmail::get_instance();
$host = $rcmail->config->get('krb_authentication_host');
if (is_string($host) && trim($host) !== '' && empty($args['host'])) {
$args['host'] = rcube_utils::idn_to_ascii(rcube_utils::parse_host($host));
}
if (!empty($_SERVER['REMOTE_USER'])) {
$args['user'] = $_SERVER['REMOTE_USER'];
$args['pass'] = null;
}
$args['cookiecheck'] = false;
$args['valid'] = true;
}
return $args;
}
|
[
"function",
"authenticate",
"(",
"$",
"args",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'REMOTE_USER'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'KRB5CCNAME'",
"]",
")",
")",
"{",
"// Load plugin's config file",
"$",
"this",
"->",
"load_config",
"(",
")",
";",
"$",
"rcmail",
"=",
"rcmail",
"::",
"get_instance",
"(",
")",
";",
"$",
"host",
"=",
"$",
"rcmail",
"->",
"config",
"->",
"get",
"(",
"'krb_authentication_host'",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"host",
")",
"&&",
"trim",
"(",
"$",
"host",
")",
"!==",
"''",
"&&",
"empty",
"(",
"$",
"args",
"[",
"'host'",
"]",
")",
")",
"{",
"$",
"args",
"[",
"'host'",
"]",
"=",
"rcube_utils",
"::",
"idn_to_ascii",
"(",
"rcube_utils",
"::",
"parse_host",
"(",
"$",
"host",
")",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'REMOTE_USER'",
"]",
")",
")",
"{",
"$",
"args",
"[",
"'user'",
"]",
"=",
"$",
"_SERVER",
"[",
"'REMOTE_USER'",
"]",
";",
"$",
"args",
"[",
"'pass'",
"]",
"=",
"null",
";",
"}",
"$",
"args",
"[",
"'cookiecheck'",
"]",
"=",
"false",
";",
"$",
"args",
"[",
"'valid'",
"]",
"=",
"true",
";",
"}",
"return",
"$",
"args",
";",
"}"
] |
Authenticate hook handler
|
[
"Authenticate",
"hook",
"handler"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/krb_authentication/krb_authentication.php#L51-L74
|
train
|
i-MSCP/roundcube
|
roundcubemail/plugins/krb_authentication/krb_authentication.php
|
krb_authentication.storage_connect
|
function storage_connect($args)
{
if (!empty($_SERVER['REMOTE_USER']) && !empty($_SERVER['KRB5CCNAME'])) {
// Load plugin's config file
$this->load_config();
$rcmail = rcmail::get_instance();
$context = $rcmail->config->get('krb_authentication_context');
$args['gssapi_context'] = $context ?: 'imap/[email protected]';
$args['gssapi_cn'] = $_SERVER['KRB5CCNAME'];
$args['auth_type'] = 'GSSAPI';
}
return $args;
}
|
php
|
function storage_connect($args)
{
if (!empty($_SERVER['REMOTE_USER']) && !empty($_SERVER['KRB5CCNAME'])) {
// Load plugin's config file
$this->load_config();
$rcmail = rcmail::get_instance();
$context = $rcmail->config->get('krb_authentication_context');
$args['gssapi_context'] = $context ?: 'imap/[email protected]';
$args['gssapi_cn'] = $_SERVER['KRB5CCNAME'];
$args['auth_type'] = 'GSSAPI';
}
return $args;
}
|
[
"function",
"storage_connect",
"(",
"$",
"args",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'REMOTE_USER'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'KRB5CCNAME'",
"]",
")",
")",
"{",
"// Load plugin's config file",
"$",
"this",
"->",
"load_config",
"(",
")",
";",
"$",
"rcmail",
"=",
"rcmail",
"::",
"get_instance",
"(",
")",
";",
"$",
"context",
"=",
"$",
"rcmail",
"->",
"config",
"->",
"get",
"(",
"'krb_authentication_context'",
")",
";",
"$",
"args",
"[",
"'gssapi_context'",
"]",
"=",
"$",
"context",
"?",
":",
"'imap/[email protected]'",
";",
"$",
"args",
"[",
"'gssapi_cn'",
"]",
"=",
"$",
"_SERVER",
"[",
"'KRB5CCNAME'",
"]",
";",
"$",
"args",
"[",
"'auth_type'",
"]",
"=",
"'GSSAPI'",
";",
"}",
"return",
"$",
"args",
";",
"}"
] |
Storage_connect hook handler
|
[
"Storage_connect",
"hook",
"handler"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/krb_authentication/krb_authentication.php#L79-L94
|
train
|
netgen/NetgenInformationCollectionBundle
|
bundle/Core/Persistence/Anonymizer/AnonymizerServiceFacade.php
|
AnonymizerServiceFacade.anonymize
|
public function anonymize($contentId, array $fields = [], DateTime $date = null)
{
$fieldsWithIds = $this->getFieldIds($contentId, $fields);
if (!empty($fields) && empty($fieldsWithIds)) {
return 0;
}
$collections = $this->getCollections($contentId, $date);
foreach ($collections as $collection) {
$this->anonymizer->anonymizeCollection($collection, $fields);
}
return count($collections);
}
|
php
|
public function anonymize($contentId, array $fields = [], DateTime $date = null)
{
$fieldsWithIds = $this->getFieldIds($contentId, $fields);
if (!empty($fields) && empty($fieldsWithIds)) {
return 0;
}
$collections = $this->getCollections($contentId, $date);
foreach ($collections as $collection) {
$this->anonymizer->anonymizeCollection($collection, $fields);
}
return count($collections);
}
|
[
"public",
"function",
"anonymize",
"(",
"$",
"contentId",
",",
"array",
"$",
"fields",
"=",
"[",
"]",
",",
"DateTime",
"$",
"date",
"=",
"null",
")",
"{",
"$",
"fieldsWithIds",
"=",
"$",
"this",
"->",
"getFieldIds",
"(",
"$",
"contentId",
",",
"$",
"fields",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"fields",
")",
"&&",
"empty",
"(",
"$",
"fieldsWithIds",
")",
")",
"{",
"return",
"0",
";",
"}",
"$",
"collections",
"=",
"$",
"this",
"->",
"getCollections",
"(",
"$",
"contentId",
",",
"$",
"date",
")",
";",
"foreach",
"(",
"$",
"collections",
"as",
"$",
"collection",
")",
"{",
"$",
"this",
"->",
"anonymizer",
"->",
"anonymizeCollection",
"(",
"$",
"collection",
",",
"$",
"fields",
")",
";",
"}",
"return",
"count",
"(",
"$",
"collections",
")",
";",
"}"
] |
Anonymize collections by content id
@param int $contentId Content id
@param array $fields Fields list
@param DateTime|null $date Anonymize collections older that this date
@return int
|
[
"Anonymize",
"collections",
"by",
"content",
"id"
] |
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
|
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Core/Persistence/Anonymizer/AnonymizerServiceFacade.php#L55-L70
|
train
|
netgen/NetgenInformationCollectionBundle
|
bundle/Core/Persistence/Anonymizer/AnonymizerServiceFacade.php
|
AnonymizerServiceFacade.getFieldIds
|
protected function getFieldIds($contentId, array $fieldIdentifiers)
{
$ids = [];
foreach ($fieldIdentifiers as $identifier) {
try {
$ids[] = $this->contentTypeUtils->getFieldId($contentId, $identifier);
} catch (OutOfBoundsException $e) {
continue;
}
}
return $ids;
}
|
php
|
protected function getFieldIds($contentId, array $fieldIdentifiers)
{
$ids = [];
foreach ($fieldIdentifiers as $identifier) {
try {
$ids[] = $this->contentTypeUtils->getFieldId($contentId, $identifier);
} catch (OutOfBoundsException $e) {
continue;
}
}
return $ids;
}
|
[
"protected",
"function",
"getFieldIds",
"(",
"$",
"contentId",
",",
"array",
"$",
"fieldIdentifiers",
")",
"{",
"$",
"ids",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fieldIdentifiers",
"as",
"$",
"identifier",
")",
"{",
"try",
"{",
"$",
"ids",
"[",
"]",
"=",
"$",
"this",
"->",
"contentTypeUtils",
"->",
"getFieldId",
"(",
"$",
"contentId",
",",
"$",
"identifier",
")",
";",
"}",
"catch",
"(",
"OutOfBoundsException",
"$",
"e",
")",
"{",
"continue",
";",
"}",
"}",
"return",
"$",
"ids",
";",
"}"
] |
Map field id's to list of field identifiers
@param int $content
@param array $fieldIdentifiers
@return array
|
[
"Map",
"field",
"id",
"s",
"to",
"list",
"of",
"field",
"identifiers"
] |
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
|
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Core/Persistence/Anonymizer/AnonymizerServiceFacade.php#L80-L92
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.close
|
public function close()
{
$this->connect_done = false;
$this->conn->closeConnection();
if ($this->mcache) {
$this->mcache->close();
}
}
|
php
|
public function close()
{
$this->connect_done = false;
$this->conn->closeConnection();
if ($this->mcache) {
$this->mcache->close();
}
}
|
[
"public",
"function",
"close",
"(",
")",
"{",
"$",
"this",
"->",
"connect_done",
"=",
"false",
";",
"$",
"this",
"->",
"conn",
"->",
"closeConnection",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"mcache",
")",
"{",
"$",
"this",
"->",
"mcache",
"->",
"close",
"(",
")",
";",
"}",
"}"
] |
Close IMAP connection.
Usually done on script shutdown
|
[
"Close",
"IMAP",
"connection",
".",
"Usually",
"done",
"on",
"script",
"shutdown"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L208-L216
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.check_connection
|
public function check_connection()
{
// Establish connection if it wasn't done yet
if (!$this->connect_done && !empty($this->options['user'])) {
return $this->connect(
$this->options['host'],
$this->options['user'],
$this->options['password'],
$this->options['port'],
$this->options['ssl']
);
}
return $this->is_connected();
}
|
php
|
public function check_connection()
{
// Establish connection if it wasn't done yet
if (!$this->connect_done && !empty($this->options['user'])) {
return $this->connect(
$this->options['host'],
$this->options['user'],
$this->options['password'],
$this->options['port'],
$this->options['ssl']
);
}
return $this->is_connected();
}
|
[
"public",
"function",
"check_connection",
"(",
")",
"{",
"// Establish connection if it wasn't done yet",
"if",
"(",
"!",
"$",
"this",
"->",
"connect_done",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"options",
"[",
"'user'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"connect",
"(",
"$",
"this",
"->",
"options",
"[",
"'host'",
"]",
",",
"$",
"this",
"->",
"options",
"[",
"'user'",
"]",
",",
"$",
"this",
"->",
"options",
"[",
"'password'",
"]",
",",
"$",
"this",
"->",
"options",
"[",
"'port'",
"]",
",",
"$",
"this",
"->",
"options",
"[",
"'ssl'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"is_connected",
"(",
")",
";",
"}"
] |
Check connection state, connect if not connected.
@return bool Connection state.
|
[
"Check",
"connection",
"state",
"connect",
"if",
"not",
"connected",
"."
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L223-L237
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.get_response_code
|
public function get_response_code()
{
switch ($this->conn->resultcode) {
case 'NOPERM':
return self::NOPERM;
case 'READ-ONLY':
return self::READONLY;
case 'TRYCREATE':
return self::TRYCREATE;
case 'INUSE':
return self::INUSE;
case 'OVERQUOTA':
return self::OVERQUOTA;
case 'ALREADYEXISTS':
return self::ALREADYEXISTS;
case 'NONEXISTENT':
return self::NONEXISTENT;
case 'CONTACTADMIN':
return self::CONTACTADMIN;
default:
return self::UNKNOWN;
}
}
|
php
|
public function get_response_code()
{
switch ($this->conn->resultcode) {
case 'NOPERM':
return self::NOPERM;
case 'READ-ONLY':
return self::READONLY;
case 'TRYCREATE':
return self::TRYCREATE;
case 'INUSE':
return self::INUSE;
case 'OVERQUOTA':
return self::OVERQUOTA;
case 'ALREADYEXISTS':
return self::ALREADYEXISTS;
case 'NONEXISTENT':
return self::NONEXISTENT;
case 'CONTACTADMIN':
return self::CONTACTADMIN;
default:
return self::UNKNOWN;
}
}
|
[
"public",
"function",
"get_response_code",
"(",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"conn",
"->",
"resultcode",
")",
"{",
"case",
"'NOPERM'",
":",
"return",
"self",
"::",
"NOPERM",
";",
"case",
"'READ-ONLY'",
":",
"return",
"self",
"::",
"READONLY",
";",
"case",
"'TRYCREATE'",
":",
"return",
"self",
"::",
"TRYCREATE",
";",
"case",
"'INUSE'",
":",
"return",
"self",
"::",
"INUSE",
";",
"case",
"'OVERQUOTA'",
":",
"return",
"self",
"::",
"OVERQUOTA",
";",
"case",
"'ALREADYEXISTS'",
":",
"return",
"self",
"::",
"ALREADYEXISTS",
";",
"case",
"'NONEXISTENT'",
":",
"return",
"self",
"::",
"NONEXISTENT",
";",
"case",
"'CONTACTADMIN'",
":",
"return",
"self",
"::",
"CONTACTADMIN",
";",
"default",
":",
"return",
"self",
"::",
"UNKNOWN",
";",
"}",
"}"
] |
Returns code of last command response
@return int Response code
|
[
"Returns",
"code",
"of",
"last",
"command",
"response"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L274-L296
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.set_search_set
|
public function set_search_set($set)
{
$set = (array)$set;
$this->search_string = $set[0];
$this->search_set = $set[1];
$this->search_charset = $set[2];
$this->search_sort_field = $set[3];
$this->search_sorted = $set[4];
$this->search_threads = is_a($this->search_set, 'rcube_result_thread');
if (is_a($this->search_set, 'rcube_result_multifolder')) {
$this->set_threading(false);
}
}
|
php
|
public function set_search_set($set)
{
$set = (array)$set;
$this->search_string = $set[0];
$this->search_set = $set[1];
$this->search_charset = $set[2];
$this->search_sort_field = $set[3];
$this->search_sorted = $set[4];
$this->search_threads = is_a($this->search_set, 'rcube_result_thread');
if (is_a($this->search_set, 'rcube_result_multifolder')) {
$this->set_threading(false);
}
}
|
[
"public",
"function",
"set_search_set",
"(",
"$",
"set",
")",
"{",
"$",
"set",
"=",
"(",
"array",
")",
"$",
"set",
";",
"$",
"this",
"->",
"search_string",
"=",
"$",
"set",
"[",
"0",
"]",
";",
"$",
"this",
"->",
"search_set",
"=",
"$",
"set",
"[",
"1",
"]",
";",
"$",
"this",
"->",
"search_charset",
"=",
"$",
"set",
"[",
"2",
"]",
";",
"$",
"this",
"->",
"search_sort_field",
"=",
"$",
"set",
"[",
"3",
"]",
";",
"$",
"this",
"->",
"search_sorted",
"=",
"$",
"set",
"[",
"4",
"]",
";",
"$",
"this",
"->",
"search_threads",
"=",
"is_a",
"(",
"$",
"this",
"->",
"search_set",
",",
"'rcube_result_thread'",
")",
";",
"if",
"(",
"is_a",
"(",
"$",
"this",
"->",
"search_set",
",",
"'rcube_result_multifolder'",
")",
")",
"{",
"$",
"this",
"->",
"set_threading",
"(",
"false",
")",
";",
"}",
"}"
] |
Save a search result for future message listing methods
@param array $set Search set, result from rcube_imap::get_search_set():
0 - searching criteria, string
1 - search result, rcube_result_index|rcube_result_thread
2 - searching character set, string
3 - sorting field, string
4 - true if sorted, bool
|
[
"Save",
"a",
"search",
"result",
"for",
"future",
"message",
"listing",
"methods"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L330-L344
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.get_search_set
|
public function get_search_set()
{
if (empty($this->search_set)) {
return null;
}
return array(
$this->search_string,
$this->search_set,
$this->search_charset,
$this->search_sort_field,
$this->search_sorted,
);
}
|
php
|
public function get_search_set()
{
if (empty($this->search_set)) {
return null;
}
return array(
$this->search_string,
$this->search_set,
$this->search_charset,
$this->search_sort_field,
$this->search_sorted,
);
}
|
[
"public",
"function",
"get_search_set",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"search_set",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"array",
"(",
"$",
"this",
"->",
"search_string",
",",
"$",
"this",
"->",
"search_set",
",",
"$",
"this",
"->",
"search_charset",
",",
"$",
"this",
"->",
"search_sort_field",
",",
"$",
"this",
"->",
"search_sorted",
",",
")",
";",
"}"
] |
Return the saved search set as hash array
@return array Search set
|
[
"Return",
"the",
"saved",
"search",
"set",
"as",
"hash",
"array"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L351-L364
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.get_capability
|
public function get_capability($cap)
{
$cap = strtoupper($cap);
$sess_key = "STORAGE_$cap";
if (!isset($_SESSION[$sess_key])) {
if (!$this->check_connection()) {
return false;
}
$_SESSION[$sess_key] = $this->conn->getCapability($cap);
}
return $_SESSION[$sess_key];
}
|
php
|
public function get_capability($cap)
{
$cap = strtoupper($cap);
$sess_key = "STORAGE_$cap";
if (!isset($_SESSION[$sess_key])) {
if (!$this->check_connection()) {
return false;
}
$_SESSION[$sess_key] = $this->conn->getCapability($cap);
}
return $_SESSION[$sess_key];
}
|
[
"public",
"function",
"get_capability",
"(",
"$",
"cap",
")",
"{",
"$",
"cap",
"=",
"strtoupper",
"(",
"$",
"cap",
")",
";",
"$",
"sess_key",
"=",
"\"STORAGE_$cap\"",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"sess_key",
"]",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"_SESSION",
"[",
"$",
"sess_key",
"]",
"=",
"$",
"this",
"->",
"conn",
"->",
"getCapability",
"(",
"$",
"cap",
")",
";",
"}",
"return",
"$",
"_SESSION",
"[",
"$",
"sess_key",
"]",
";",
"}"
] |
Returns the IMAP server's capability.
@param string $cap Capability name
@return mixed Capability value or TRUE if supported, FALSE if not
|
[
"Returns",
"the",
"IMAP",
"server",
"s",
"capability",
"."
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L373-L387
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.check_permflag
|
public function check_permflag($flag)
{
$flag = strtoupper($flag);
$perm_flags = $this->get_permflags($this->folder);
$imap_flag = $this->conn->flags[$flag];
return $imap_flag && !empty($perm_flags) && in_array_nocase($imap_flag, $perm_flags);
}
|
php
|
public function check_permflag($flag)
{
$flag = strtoupper($flag);
$perm_flags = $this->get_permflags($this->folder);
$imap_flag = $this->conn->flags[$flag];
return $imap_flag && !empty($perm_flags) && in_array_nocase($imap_flag, $perm_flags);
}
|
[
"public",
"function",
"check_permflag",
"(",
"$",
"flag",
")",
"{",
"$",
"flag",
"=",
"strtoupper",
"(",
"$",
"flag",
")",
";",
"$",
"perm_flags",
"=",
"$",
"this",
"->",
"get_permflags",
"(",
"$",
"this",
"->",
"folder",
")",
";",
"$",
"imap_flag",
"=",
"$",
"this",
"->",
"conn",
"->",
"flags",
"[",
"$",
"flag",
"]",
";",
"return",
"$",
"imap_flag",
"&&",
"!",
"empty",
"(",
"$",
"perm_flags",
")",
"&&",
"in_array_nocase",
"(",
"$",
"imap_flag",
",",
"$",
"perm_flags",
")",
";",
"}"
] |
Checks the PERMANENTFLAGS capability of the current folder
and returns true if the given flag is supported by the IMAP server
@param string $flag Permanentflag name
@return boolean True if this flag is supported
|
[
"Checks",
"the",
"PERMANENTFLAGS",
"capability",
"of",
"the",
"current",
"folder",
"and",
"returns",
"true",
"if",
"the",
"given",
"flag",
"is",
"supported",
"by",
"the",
"IMAP",
"server"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L397-L404
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.get_permflags
|
public function get_permflags($folder)
{
if (!strlen($folder)) {
return array();
}
if (!$this->check_connection()) {
return array();
}
if ($this->conn->select($folder)) {
$permflags = $this->conn->data['PERMANENTFLAGS'];
}
else {
return array();
}
if (!is_array($permflags)) {
$permflags = array();
}
return $permflags;
}
|
php
|
public function get_permflags($folder)
{
if (!strlen($folder)) {
return array();
}
if (!$this->check_connection()) {
return array();
}
if ($this->conn->select($folder)) {
$permflags = $this->conn->data['PERMANENTFLAGS'];
}
else {
return array();
}
if (!is_array($permflags)) {
$permflags = array();
}
return $permflags;
}
|
[
"public",
"function",
"get_permflags",
"(",
"$",
"folder",
")",
"{",
"if",
"(",
"!",
"strlen",
"(",
"$",
"folder",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"conn",
"->",
"select",
"(",
"$",
"folder",
")",
")",
"{",
"$",
"permflags",
"=",
"$",
"this",
"->",
"conn",
"->",
"data",
"[",
"'PERMANENTFLAGS'",
"]",
";",
"}",
"else",
"{",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"permflags",
")",
")",
"{",
"$",
"permflags",
"=",
"array",
"(",
")",
";",
"}",
"return",
"$",
"permflags",
";",
"}"
] |
Returns PERMANENTFLAGS of the specified folder
@param string $folder Folder name
@return array Flags
|
[
"Returns",
"PERMANENTFLAGS",
"of",
"the",
"specified",
"folder"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L413-L435
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.get_vendor
|
public function get_vendor()
{
if ($_SESSION['imap_vendor'] !== null) {
return $_SESSION['imap_vendor'];
}
$config = rcube::get_instance()->config;
$imap_vendor = $config->get('imap_vendor');
if ($imap_vendor) {
return $imap_vendor;
}
if (!$this->check_connection()) {
return;
}
if (($ident = $this->conn->data['ID']) === null) {
$ident = $this->conn->id(array(
'name' => 'Roundcube',
'version' => RCUBE_VERSION,
'php' => PHP_VERSION,
'os' => PHP_OS,
));
}
$vendor = (string) (!empty($ident) ? $ident['name'] : '');
$ident = strtolower($vendor . ' ' . $this->conn->data['GREETING']);
$vendors = array('cyrus', 'dovecot', 'uw-imap', 'gmail', 'hmail');
foreach ($vendors as $v) {
if (strpos($ident, $v) !== false) {
$vendor = $v;
break;
}
}
return $_SESSION['imap_vendor'] = $vendor;
}
|
php
|
public function get_vendor()
{
if ($_SESSION['imap_vendor'] !== null) {
return $_SESSION['imap_vendor'];
}
$config = rcube::get_instance()->config;
$imap_vendor = $config->get('imap_vendor');
if ($imap_vendor) {
return $imap_vendor;
}
if (!$this->check_connection()) {
return;
}
if (($ident = $this->conn->data['ID']) === null) {
$ident = $this->conn->id(array(
'name' => 'Roundcube',
'version' => RCUBE_VERSION,
'php' => PHP_VERSION,
'os' => PHP_OS,
));
}
$vendor = (string) (!empty($ident) ? $ident['name'] : '');
$ident = strtolower($vendor . ' ' . $this->conn->data['GREETING']);
$vendors = array('cyrus', 'dovecot', 'uw-imap', 'gmail', 'hmail');
foreach ($vendors as $v) {
if (strpos($ident, $v) !== false) {
$vendor = $v;
break;
}
}
return $_SESSION['imap_vendor'] = $vendor;
}
|
[
"public",
"function",
"get_vendor",
"(",
")",
"{",
"if",
"(",
"$",
"_SESSION",
"[",
"'imap_vendor'",
"]",
"!==",
"null",
")",
"{",
"return",
"$",
"_SESSION",
"[",
"'imap_vendor'",
"]",
";",
"}",
"$",
"config",
"=",
"rcube",
"::",
"get_instance",
"(",
")",
"->",
"config",
";",
"$",
"imap_vendor",
"=",
"$",
"config",
"->",
"get",
"(",
"'imap_vendor'",
")",
";",
"if",
"(",
"$",
"imap_vendor",
")",
"{",
"return",
"$",
"imap_vendor",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"(",
"$",
"ident",
"=",
"$",
"this",
"->",
"conn",
"->",
"data",
"[",
"'ID'",
"]",
")",
"===",
"null",
")",
"{",
"$",
"ident",
"=",
"$",
"this",
"->",
"conn",
"->",
"id",
"(",
"array",
"(",
"'name'",
"=>",
"'Roundcube'",
",",
"'version'",
"=>",
"RCUBE_VERSION",
",",
"'php'",
"=>",
"PHP_VERSION",
",",
"'os'",
"=>",
"PHP_OS",
",",
")",
")",
";",
"}",
"$",
"vendor",
"=",
"(",
"string",
")",
"(",
"!",
"empty",
"(",
"$",
"ident",
")",
"?",
"$",
"ident",
"[",
"'name'",
"]",
":",
"''",
")",
";",
"$",
"ident",
"=",
"strtolower",
"(",
"$",
"vendor",
".",
"' '",
".",
"$",
"this",
"->",
"conn",
"->",
"data",
"[",
"'GREETING'",
"]",
")",
";",
"$",
"vendors",
"=",
"array",
"(",
"'cyrus'",
",",
"'dovecot'",
",",
"'uw-imap'",
",",
"'gmail'",
",",
"'hmail'",
")",
";",
"foreach",
"(",
"$",
"vendors",
"as",
"$",
"v",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"ident",
",",
"$",
"v",
")",
"!==",
"false",
")",
"{",
"$",
"vendor",
"=",
"$",
"v",
";",
"break",
";",
"}",
"}",
"return",
"$",
"_SESSION",
"[",
"'imap_vendor'",
"]",
"=",
"$",
"vendor",
";",
"}"
] |
Returns IMAP server vendor name
@return string Vendor name
@since 1.2
|
[
"Returns",
"IMAP",
"server",
"vendor",
"name"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L572-L610
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.count
|
public function count($folder='', $mode='ALL', $force=false, $status=true)
{
if (!strlen($folder)) {
$folder = $this->folder;
}
return $this->countmessages($folder, $mode, $force, $status);
}
|
php
|
public function count($folder='', $mode='ALL', $force=false, $status=true)
{
if (!strlen($folder)) {
$folder = $this->folder;
}
return $this->countmessages($folder, $mode, $force, $status);
}
|
[
"public",
"function",
"count",
"(",
"$",
"folder",
"=",
"''",
",",
"$",
"mode",
"=",
"'ALL'",
",",
"$",
"force",
"=",
"false",
",",
"$",
"status",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"strlen",
"(",
"$",
"folder",
")",
")",
"{",
"$",
"folder",
"=",
"$",
"this",
"->",
"folder",
";",
"}",
"return",
"$",
"this",
"->",
"countmessages",
"(",
"$",
"folder",
",",
"$",
"mode",
",",
"$",
"force",
",",
"$",
"status",
")",
";",
"}"
] |
Get message count for a specific folder
@param string $folder Folder name
@param string $mode Mode for count [ALL|THREADS|UNSEEN|RECENT|EXISTS]
@param boolean $force Force reading from server and update cache
@param boolean $status Enables storing folder status info (max UID/count),
required for folder_status()
@return int Number of messages
|
[
"Get",
"message",
"count",
"for",
"a",
"specific",
"folder"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L623-L630
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.list_flags
|
public function list_flags($folder, $uids, $mod_seq = null)
{
if (!strlen($folder)) {
$folder = $this->folder;
}
if (!$this->check_connection()) {
return array();
}
// @TODO: when cache was synchronized in this request
// we might already have asked for flag updates, use it.
$flags = $this->conn->fetch($folder, $uids, true, array('FLAGS'), $mod_seq);
$result = array();
if (!empty($flags)) {
foreach ($flags as $message) {
$result[$message->uid] = $message->flags;
}
}
return $result;
}
|
php
|
public function list_flags($folder, $uids, $mod_seq = null)
{
if (!strlen($folder)) {
$folder = $this->folder;
}
if (!$this->check_connection()) {
return array();
}
// @TODO: when cache was synchronized in this request
// we might already have asked for flag updates, use it.
$flags = $this->conn->fetch($folder, $uids, true, array('FLAGS'), $mod_seq);
$result = array();
if (!empty($flags)) {
foreach ($flags as $message) {
$result[$message->uid] = $message->flags;
}
}
return $result;
}
|
[
"public",
"function",
"list_flags",
"(",
"$",
"folder",
",",
"$",
"uids",
",",
"$",
"mod_seq",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"strlen",
"(",
"$",
"folder",
")",
")",
"{",
"$",
"folder",
"=",
"$",
"this",
"->",
"folder",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"// @TODO: when cache was synchronized in this request",
"// we might already have asked for flag updates, use it.",
"$",
"flags",
"=",
"$",
"this",
"->",
"conn",
"->",
"fetch",
"(",
"$",
"folder",
",",
"$",
"uids",
",",
"true",
",",
"array",
"(",
"'FLAGS'",
")",
",",
"$",
"mod_seq",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"flags",
")",
")",
"{",
"foreach",
"(",
"$",
"flags",
"as",
"$",
"message",
")",
"{",
"$",
"result",
"[",
"$",
"message",
"->",
"uid",
"]",
"=",
"$",
"message",
"->",
"flags",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Public method for listing message flags
@param string $folder Folder name
@param array $uids Message UIDs
@param int $mod_seq Optional MODSEQ value (of last flag update)
@return array Indexed array with message flags
|
[
"Public",
"method",
"for",
"listing",
"message",
"flags"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L758-L781
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.list_messages
|
public function list_messages($folder='', $page=NULL, $sort_field=NULL, $sort_order=NULL, $slice=0)
{
if (!strlen($folder)) {
$folder = $this->folder;
}
return $this->_list_messages($folder, $page, $sort_field, $sort_order, $slice);
}
|
php
|
public function list_messages($folder='', $page=NULL, $sort_field=NULL, $sort_order=NULL, $slice=0)
{
if (!strlen($folder)) {
$folder = $this->folder;
}
return $this->_list_messages($folder, $page, $sort_field, $sort_order, $slice);
}
|
[
"public",
"function",
"list_messages",
"(",
"$",
"folder",
"=",
"''",
",",
"$",
"page",
"=",
"NULL",
",",
"$",
"sort_field",
"=",
"NULL",
",",
"$",
"sort_order",
"=",
"NULL",
",",
"$",
"slice",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"strlen",
"(",
"$",
"folder",
")",
")",
"{",
"$",
"folder",
"=",
"$",
"this",
"->",
"folder",
";",
"}",
"return",
"$",
"this",
"->",
"_list_messages",
"(",
"$",
"folder",
",",
"$",
"page",
",",
"$",
"sort_field",
",",
"$",
"sort_order",
",",
"$",
"slice",
")",
";",
"}"
] |
Public method for listing headers
@param string $folder Folder name
@param int $page Current page to list
@param string $sort_field Header field to sort by
@param string $sort_order Sort order [ASC|DESC]
@param int $slice Number of slice items to extract from result array
@return array Indexed array with message header objects
|
[
"Public",
"method",
"for",
"listing",
"headers"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L794-L801
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap._list_messages
|
protected function _list_messages($folder='', $page=NULL, $sort_field=NULL, $sort_order=NULL, $slice=0)
{
if (!strlen($folder)) {
return array();
}
$this->set_sort_order($sort_field, $sort_order);
$page = $page ? $page : $this->list_page;
// use saved message set
if ($this->search_string) {
return $this->list_search_messages($folder, $page, $slice);
}
if ($this->threading) {
return $this->list_thread_messages($folder, $page, $slice);
}
// get UIDs of all messages in the folder, sorted
$index = $this->index($folder, $this->sort_field, $this->sort_order);
if ($index->is_empty()) {
return array();
}
$from = ($page-1) * $this->page_size;
$to = $from + $this->page_size;
$index->slice($from, $to - $from);
if ($slice) {
$index->slice(-$slice, $slice);
}
// fetch reqested messages headers
$a_index = $index->get();
$a_msg_headers = $this->fetch_headers($folder, $a_index);
return array_values($a_msg_headers);
}
|
php
|
protected function _list_messages($folder='', $page=NULL, $sort_field=NULL, $sort_order=NULL, $slice=0)
{
if (!strlen($folder)) {
return array();
}
$this->set_sort_order($sort_field, $sort_order);
$page = $page ? $page : $this->list_page;
// use saved message set
if ($this->search_string) {
return $this->list_search_messages($folder, $page, $slice);
}
if ($this->threading) {
return $this->list_thread_messages($folder, $page, $slice);
}
// get UIDs of all messages in the folder, sorted
$index = $this->index($folder, $this->sort_field, $this->sort_order);
if ($index->is_empty()) {
return array();
}
$from = ($page-1) * $this->page_size;
$to = $from + $this->page_size;
$index->slice($from, $to - $from);
if ($slice) {
$index->slice(-$slice, $slice);
}
// fetch reqested messages headers
$a_index = $index->get();
$a_msg_headers = $this->fetch_headers($folder, $a_index);
return array_values($a_msg_headers);
}
|
[
"protected",
"function",
"_list_messages",
"(",
"$",
"folder",
"=",
"''",
",",
"$",
"page",
"=",
"NULL",
",",
"$",
"sort_field",
"=",
"NULL",
",",
"$",
"sort_order",
"=",
"NULL",
",",
"$",
"slice",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"strlen",
"(",
"$",
"folder",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"set_sort_order",
"(",
"$",
"sort_field",
",",
"$",
"sort_order",
")",
";",
"$",
"page",
"=",
"$",
"page",
"?",
"$",
"page",
":",
"$",
"this",
"->",
"list_page",
";",
"// use saved message set",
"if",
"(",
"$",
"this",
"->",
"search_string",
")",
"{",
"return",
"$",
"this",
"->",
"list_search_messages",
"(",
"$",
"folder",
",",
"$",
"page",
",",
"$",
"slice",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"threading",
")",
"{",
"return",
"$",
"this",
"->",
"list_thread_messages",
"(",
"$",
"folder",
",",
"$",
"page",
",",
"$",
"slice",
")",
";",
"}",
"// get UIDs of all messages in the folder, sorted",
"$",
"index",
"=",
"$",
"this",
"->",
"index",
"(",
"$",
"folder",
",",
"$",
"this",
"->",
"sort_field",
",",
"$",
"this",
"->",
"sort_order",
")",
";",
"if",
"(",
"$",
"index",
"->",
"is_empty",
"(",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"from",
"=",
"(",
"$",
"page",
"-",
"1",
")",
"*",
"$",
"this",
"->",
"page_size",
";",
"$",
"to",
"=",
"$",
"from",
"+",
"$",
"this",
"->",
"page_size",
";",
"$",
"index",
"->",
"slice",
"(",
"$",
"from",
",",
"$",
"to",
"-",
"$",
"from",
")",
";",
"if",
"(",
"$",
"slice",
")",
"{",
"$",
"index",
"->",
"slice",
"(",
"-",
"$",
"slice",
",",
"$",
"slice",
")",
";",
"}",
"// fetch reqested messages headers",
"$",
"a_index",
"=",
"$",
"index",
"->",
"get",
"(",
")",
";",
"$",
"a_msg_headers",
"=",
"$",
"this",
"->",
"fetch_headers",
"(",
"$",
"folder",
",",
"$",
"a_index",
")",
";",
"return",
"array_values",
"(",
"$",
"a_msg_headers",
")",
";",
"}"
] |
protected method for listing message headers
@param string $folder Folder name
@param int $page Current page to list
@param string $sort_field Header field to sort by
@param string $sort_order Sort order [ASC|DESC]
@param int $slice Number of slice items to extract from result array
@return array Indexed array with message header objects
@see rcube_imap::list_messages
|
[
"protected",
"method",
"for",
"listing",
"message",
"headers"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L815-L854
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.list_thread_messages
|
protected function list_thread_messages($folder, $page, $slice=0)
{
// get all threads (not sorted)
if ($mcache = $this->get_mcache_engine()) {
$threads = $mcache->get_thread($folder);
}
else {
$threads = $this->threads($folder);
}
return $this->fetch_thread_headers($folder, $threads, $page, $slice);
}
|
php
|
protected function list_thread_messages($folder, $page, $slice=0)
{
// get all threads (not sorted)
if ($mcache = $this->get_mcache_engine()) {
$threads = $mcache->get_thread($folder);
}
else {
$threads = $this->threads($folder);
}
return $this->fetch_thread_headers($folder, $threads, $page, $slice);
}
|
[
"protected",
"function",
"list_thread_messages",
"(",
"$",
"folder",
",",
"$",
"page",
",",
"$",
"slice",
"=",
"0",
")",
"{",
"// get all threads (not sorted)",
"if",
"(",
"$",
"mcache",
"=",
"$",
"this",
"->",
"get_mcache_engine",
"(",
")",
")",
"{",
"$",
"threads",
"=",
"$",
"mcache",
"->",
"get_thread",
"(",
"$",
"folder",
")",
";",
"}",
"else",
"{",
"$",
"threads",
"=",
"$",
"this",
"->",
"threads",
"(",
"$",
"folder",
")",
";",
"}",
"return",
"$",
"this",
"->",
"fetch_thread_headers",
"(",
"$",
"folder",
",",
"$",
"threads",
",",
"$",
"page",
",",
"$",
"slice",
")",
";",
"}"
] |
protected method for listing message headers using threads
@param string $folder Folder name
@param int $page Current page to list
@param int $slice Number of slice items to extract from result array
@return array Indexed array with message header objects
@see rcube_imap::list_messages
|
[
"protected",
"method",
"for",
"listing",
"message",
"headers",
"using",
"threads"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L866-L877
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.threads
|
function threads($folder)
{
if ($mcache = $this->get_mcache_engine()) {
// don't store in self's internal cache, cache has it's own internal cache
return $mcache->get_thread($folder);
}
if (!empty($this->icache['threads'])) {
if ($this->icache['threads']->get_parameters('MAILBOX') == $folder) {
return $this->icache['threads'];
}
}
// get all threads
$result = $this->threads_direct($folder);
// add to internal (fast) cache
return $this->icache['threads'] = $result;
}
|
php
|
function threads($folder)
{
if ($mcache = $this->get_mcache_engine()) {
// don't store in self's internal cache, cache has it's own internal cache
return $mcache->get_thread($folder);
}
if (!empty($this->icache['threads'])) {
if ($this->icache['threads']->get_parameters('MAILBOX') == $folder) {
return $this->icache['threads'];
}
}
// get all threads
$result = $this->threads_direct($folder);
// add to internal (fast) cache
return $this->icache['threads'] = $result;
}
|
[
"function",
"threads",
"(",
"$",
"folder",
")",
"{",
"if",
"(",
"$",
"mcache",
"=",
"$",
"this",
"->",
"get_mcache_engine",
"(",
")",
")",
"{",
"// don't store in self's internal cache, cache has it's own internal cache",
"return",
"$",
"mcache",
"->",
"get_thread",
"(",
"$",
"folder",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"icache",
"[",
"'threads'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"icache",
"[",
"'threads'",
"]",
"->",
"get_parameters",
"(",
"'MAILBOX'",
")",
"==",
"$",
"folder",
")",
"{",
"return",
"$",
"this",
"->",
"icache",
"[",
"'threads'",
"]",
";",
"}",
"}",
"// get all threads",
"$",
"result",
"=",
"$",
"this",
"->",
"threads_direct",
"(",
"$",
"folder",
")",
";",
"// add to internal (fast) cache",
"return",
"$",
"this",
"->",
"icache",
"[",
"'threads'",
"]",
"=",
"$",
"result",
";",
"}"
] |
Method for fetching threads data
@param string $folder Folder name
@return rcube_imap_thread Thread data object
|
[
"Method",
"for",
"fetching",
"threads",
"data"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L886-L904
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.threads_direct
|
function threads_direct($folder)
{
if (!$this->check_connection()) {
return new rcube_result_thread();
}
// get all threads
return $this->conn->thread($folder, $this->threading,
$this->options['skip_deleted'] ? 'UNDELETED' : '', true);
}
|
php
|
function threads_direct($folder)
{
if (!$this->check_connection()) {
return new rcube_result_thread();
}
// get all threads
return $this->conn->thread($folder, $this->threading,
$this->options['skip_deleted'] ? 'UNDELETED' : '', true);
}
|
[
"function",
"threads_direct",
"(",
"$",
"folder",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
"new",
"rcube_result_thread",
"(",
")",
";",
"}",
"// get all threads",
"return",
"$",
"this",
"->",
"conn",
"->",
"thread",
"(",
"$",
"folder",
",",
"$",
"this",
"->",
"threading",
",",
"$",
"this",
"->",
"options",
"[",
"'skip_deleted'",
"]",
"?",
"'UNDELETED'",
":",
"''",
",",
"true",
")",
";",
"}"
] |
Method for direct fetching of threads data
@param string $folder Folder name
@return rcube_imap_thread Thread data object
|
[
"Method",
"for",
"direct",
"fetching",
"of",
"threads",
"data"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L913-L922
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.fetch_thread_headers
|
protected function fetch_thread_headers($folder, $threads, $page, $slice=0)
{
// Sort thread structure
$this->sort_threads($threads);
$from = ($page-1) * $this->page_size;
$to = $from + $this->page_size;
$threads->slice($from, $to - $from);
if ($slice) {
$threads->slice(-$slice, $slice);
}
// Get UIDs of all messages in all threads
$a_index = $threads->get();
// fetch reqested headers from server
$a_msg_headers = $this->fetch_headers($folder, $a_index);
unset($a_index);
// Set depth, has_children and unread_children fields in headers
$this->set_thread_flags($a_msg_headers, $threads);
return array_values($a_msg_headers);
}
|
php
|
protected function fetch_thread_headers($folder, $threads, $page, $slice=0)
{
// Sort thread structure
$this->sort_threads($threads);
$from = ($page-1) * $this->page_size;
$to = $from + $this->page_size;
$threads->slice($from, $to - $from);
if ($slice) {
$threads->slice(-$slice, $slice);
}
// Get UIDs of all messages in all threads
$a_index = $threads->get();
// fetch reqested headers from server
$a_msg_headers = $this->fetch_headers($folder, $a_index);
unset($a_index);
// Set depth, has_children and unread_children fields in headers
$this->set_thread_flags($a_msg_headers, $threads);
return array_values($a_msg_headers);
}
|
[
"protected",
"function",
"fetch_thread_headers",
"(",
"$",
"folder",
",",
"$",
"threads",
",",
"$",
"page",
",",
"$",
"slice",
"=",
"0",
")",
"{",
"// Sort thread structure",
"$",
"this",
"->",
"sort_threads",
"(",
"$",
"threads",
")",
";",
"$",
"from",
"=",
"(",
"$",
"page",
"-",
"1",
")",
"*",
"$",
"this",
"->",
"page_size",
";",
"$",
"to",
"=",
"$",
"from",
"+",
"$",
"this",
"->",
"page_size",
";",
"$",
"threads",
"->",
"slice",
"(",
"$",
"from",
",",
"$",
"to",
"-",
"$",
"from",
")",
";",
"if",
"(",
"$",
"slice",
")",
"{",
"$",
"threads",
"->",
"slice",
"(",
"-",
"$",
"slice",
",",
"$",
"slice",
")",
";",
"}",
"// Get UIDs of all messages in all threads",
"$",
"a_index",
"=",
"$",
"threads",
"->",
"get",
"(",
")",
";",
"// fetch reqested headers from server",
"$",
"a_msg_headers",
"=",
"$",
"this",
"->",
"fetch_headers",
"(",
"$",
"folder",
",",
"$",
"a_index",
")",
";",
"unset",
"(",
"$",
"a_index",
")",
";",
"// Set depth, has_children and unread_children fields in headers",
"$",
"this",
"->",
"set_thread_flags",
"(",
"$",
"a_msg_headers",
",",
"$",
"threads",
")",
";",
"return",
"array_values",
"(",
"$",
"a_msg_headers",
")",
";",
"}"
] |
protected method for fetching threaded messages headers
@param string $folder Folder name
@param rcube_result_thread $threads Threads data object
@param int $page List page number
@param int $slice Number of threads to slice
@return array Messages headers
|
[
"protected",
"method",
"for",
"fetching",
"threaded",
"messages",
"headers"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L934-L960
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.index
|
public function index($folder = '', $sort_field = NULL, $sort_order = NULL,
$no_threads = false, $no_search = false
) {
if (!$no_threads && $this->threading) {
return $this->thread_index($folder, $sort_field, $sort_order);
}
$this->set_sort_order($sort_field, $sort_order);
if (!strlen($folder)) {
$folder = $this->folder;
}
// we have a saved search result, get index from there
if ($this->search_string) {
if ($this->search_set->is_empty()) {
return new rcube_result_index($folder, '* SORT');
}
if ($this->search_set instanceof rcube_result_multifolder) {
$index = $this->search_set;
$index->folder = $folder;
// TODO: handle changed sorting
}
// search result is an index with the same sorting?
else if (($this->search_set instanceof rcube_result_index)
&& ((!$this->sort_field && !$this->search_sorted) ||
($this->search_sorted && $this->search_sort_field == $this->sort_field))
) {
$index = $this->search_set;
}
// $no_search is enabled when we are not interested in
// fetching index for search result, e.g. to sort
// threaded search result we can use full mailbox index.
// This makes possible to use index from cache
else if (!$no_search) {
if (!$this->sort_field) {
// No sorting needed, just build index from the search result
// @TODO: do we need to sort by UID here?
$search = $this->search_set->get_compressed();
$index = new rcube_result_index($folder, '* ESEARCH ALL ' . $search);
}
else {
$index = $this->index_direct($folder, $this->sort_field, $this->sort_order, $this->search_set);
}
}
if (isset($index)) {
if ($this->sort_order != $index->get_parameters('ORDER')) {
$index->revert();
}
return $index;
}
}
// check local cache
if ($mcache = $this->get_mcache_engine()) {
return $mcache->get_index($folder, $this->sort_field, $this->sort_order);
}
// fetch from IMAP server
return $this->index_direct($folder, $this->sort_field, $this->sort_order);
}
|
php
|
public function index($folder = '', $sort_field = NULL, $sort_order = NULL,
$no_threads = false, $no_search = false
) {
if (!$no_threads && $this->threading) {
return $this->thread_index($folder, $sort_field, $sort_order);
}
$this->set_sort_order($sort_field, $sort_order);
if (!strlen($folder)) {
$folder = $this->folder;
}
// we have a saved search result, get index from there
if ($this->search_string) {
if ($this->search_set->is_empty()) {
return new rcube_result_index($folder, '* SORT');
}
if ($this->search_set instanceof rcube_result_multifolder) {
$index = $this->search_set;
$index->folder = $folder;
// TODO: handle changed sorting
}
// search result is an index with the same sorting?
else if (($this->search_set instanceof rcube_result_index)
&& ((!$this->sort_field && !$this->search_sorted) ||
($this->search_sorted && $this->search_sort_field == $this->sort_field))
) {
$index = $this->search_set;
}
// $no_search is enabled when we are not interested in
// fetching index for search result, e.g. to sort
// threaded search result we can use full mailbox index.
// This makes possible to use index from cache
else if (!$no_search) {
if (!$this->sort_field) {
// No sorting needed, just build index from the search result
// @TODO: do we need to sort by UID here?
$search = $this->search_set->get_compressed();
$index = new rcube_result_index($folder, '* ESEARCH ALL ' . $search);
}
else {
$index = $this->index_direct($folder, $this->sort_field, $this->sort_order, $this->search_set);
}
}
if (isset($index)) {
if ($this->sort_order != $index->get_parameters('ORDER')) {
$index->revert();
}
return $index;
}
}
// check local cache
if ($mcache = $this->get_mcache_engine()) {
return $mcache->get_index($folder, $this->sort_field, $this->sort_order);
}
// fetch from IMAP server
return $this->index_direct($folder, $this->sort_field, $this->sort_order);
}
|
[
"public",
"function",
"index",
"(",
"$",
"folder",
"=",
"''",
",",
"$",
"sort_field",
"=",
"NULL",
",",
"$",
"sort_order",
"=",
"NULL",
",",
"$",
"no_threads",
"=",
"false",
",",
"$",
"no_search",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"no_threads",
"&&",
"$",
"this",
"->",
"threading",
")",
"{",
"return",
"$",
"this",
"->",
"thread_index",
"(",
"$",
"folder",
",",
"$",
"sort_field",
",",
"$",
"sort_order",
")",
";",
"}",
"$",
"this",
"->",
"set_sort_order",
"(",
"$",
"sort_field",
",",
"$",
"sort_order",
")",
";",
"if",
"(",
"!",
"strlen",
"(",
"$",
"folder",
")",
")",
"{",
"$",
"folder",
"=",
"$",
"this",
"->",
"folder",
";",
"}",
"// we have a saved search result, get index from there",
"if",
"(",
"$",
"this",
"->",
"search_string",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"search_set",
"->",
"is_empty",
"(",
")",
")",
"{",
"return",
"new",
"rcube_result_index",
"(",
"$",
"folder",
",",
"'* SORT'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"search_set",
"instanceof",
"rcube_result_multifolder",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"search_set",
";",
"$",
"index",
"->",
"folder",
"=",
"$",
"folder",
";",
"// TODO: handle changed sorting",
"}",
"// search result is an index with the same sorting?",
"else",
"if",
"(",
"(",
"$",
"this",
"->",
"search_set",
"instanceof",
"rcube_result_index",
")",
"&&",
"(",
"(",
"!",
"$",
"this",
"->",
"sort_field",
"&&",
"!",
"$",
"this",
"->",
"search_sorted",
")",
"||",
"(",
"$",
"this",
"->",
"search_sorted",
"&&",
"$",
"this",
"->",
"search_sort_field",
"==",
"$",
"this",
"->",
"sort_field",
")",
")",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"search_set",
";",
"}",
"// $no_search is enabled when we are not interested in",
"// fetching index for search result, e.g. to sort",
"// threaded search result we can use full mailbox index.",
"// This makes possible to use index from cache",
"else",
"if",
"(",
"!",
"$",
"no_search",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"sort_field",
")",
"{",
"// No sorting needed, just build index from the search result",
"// @TODO: do we need to sort by UID here?",
"$",
"search",
"=",
"$",
"this",
"->",
"search_set",
"->",
"get_compressed",
"(",
")",
";",
"$",
"index",
"=",
"new",
"rcube_result_index",
"(",
"$",
"folder",
",",
"'* ESEARCH ALL '",
".",
"$",
"search",
")",
";",
"}",
"else",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"index_direct",
"(",
"$",
"folder",
",",
"$",
"this",
"->",
"sort_field",
",",
"$",
"this",
"->",
"sort_order",
",",
"$",
"this",
"->",
"search_set",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"index",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sort_order",
"!=",
"$",
"index",
"->",
"get_parameters",
"(",
"'ORDER'",
")",
")",
"{",
"$",
"index",
"->",
"revert",
"(",
")",
";",
"}",
"return",
"$",
"index",
";",
"}",
"}",
"// check local cache",
"if",
"(",
"$",
"mcache",
"=",
"$",
"this",
"->",
"get_mcache_engine",
"(",
")",
")",
"{",
"return",
"$",
"mcache",
"->",
"get_index",
"(",
"$",
"folder",
",",
"$",
"this",
"->",
"sort_field",
",",
"$",
"this",
"->",
"sort_order",
")",
";",
"}",
"// fetch from IMAP server",
"return",
"$",
"this",
"->",
"index_direct",
"(",
"$",
"folder",
",",
"$",
"this",
"->",
"sort_field",
",",
"$",
"this",
"->",
"sort_order",
")",
";",
"}"
] |
Return sorted list of message UIDs
@param string $folder Folder to get index from
@param string $sort_field Sort column
@param string $sort_order Sort order [ASC, DESC]
@param bool $no_threads Get not threaded index
@param bool $no_search Get index not limited to search result (optionally)
@return rcube_result_index|rcube_result_thread List of messages (UIDs)
|
[
"Return",
"sorted",
"list",
"of",
"message",
"UIDs"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L1345-L1408
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.index_direct
|
public function index_direct($folder, $sort_field = null, $sort_order = null, $search = null)
{
if (!empty($search)) {
$search = $search->get_compressed();
}
// use message index sort as default sorting
if (!$sort_field) {
// use search result from count() if possible
if (empty($search) && $this->options['skip_deleted']
&& !empty($this->icache['undeleted_idx'])
&& $this->icache['undeleted_idx']->get_parameters('ALL') !== null
&& $this->icache['undeleted_idx']->get_parameters('MAILBOX') == $folder
) {
$index = $this->icache['undeleted_idx'];
}
else if (!$this->check_connection()) {
return new rcube_result_index();
}
else {
$query = $this->options['skip_deleted'] ? 'UNDELETED' : '';
if ($search) {
$query = trim($query . ' UID ' . $search);
}
$index = $this->conn->search($folder, $query, true);
}
}
else if (!$this->check_connection()) {
return new rcube_result_index();
}
// fetch complete message index
else {
if ($this->get_capability('SORT')) {
$query = $this->options['skip_deleted'] ? 'UNDELETED' : '';
if ($search) {
$query = trim($query . ' UID ' . $search);
}
$index = $this->conn->sort($folder, $sort_field, $query, true);
}
if (empty($index) || $index->is_error()) {
$index = $this->conn->index($folder, $search ? $search : "1:*",
$sort_field, $this->options['skip_deleted'],
$search ? true : false, true);
}
}
if ($sort_order != $index->get_parameters('ORDER')) {
$index->revert();
}
return $index;
}
|
php
|
public function index_direct($folder, $sort_field = null, $sort_order = null, $search = null)
{
if (!empty($search)) {
$search = $search->get_compressed();
}
// use message index sort as default sorting
if (!$sort_field) {
// use search result from count() if possible
if (empty($search) && $this->options['skip_deleted']
&& !empty($this->icache['undeleted_idx'])
&& $this->icache['undeleted_idx']->get_parameters('ALL') !== null
&& $this->icache['undeleted_idx']->get_parameters('MAILBOX') == $folder
) {
$index = $this->icache['undeleted_idx'];
}
else if (!$this->check_connection()) {
return new rcube_result_index();
}
else {
$query = $this->options['skip_deleted'] ? 'UNDELETED' : '';
if ($search) {
$query = trim($query . ' UID ' . $search);
}
$index = $this->conn->search($folder, $query, true);
}
}
else if (!$this->check_connection()) {
return new rcube_result_index();
}
// fetch complete message index
else {
if ($this->get_capability('SORT')) {
$query = $this->options['skip_deleted'] ? 'UNDELETED' : '';
if ($search) {
$query = trim($query . ' UID ' . $search);
}
$index = $this->conn->sort($folder, $sort_field, $query, true);
}
if (empty($index) || $index->is_error()) {
$index = $this->conn->index($folder, $search ? $search : "1:*",
$sort_field, $this->options['skip_deleted'],
$search ? true : false, true);
}
}
if ($sort_order != $index->get_parameters('ORDER')) {
$index->revert();
}
return $index;
}
|
[
"public",
"function",
"index_direct",
"(",
"$",
"folder",
",",
"$",
"sort_field",
"=",
"null",
",",
"$",
"sort_order",
"=",
"null",
",",
"$",
"search",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"search",
")",
")",
"{",
"$",
"search",
"=",
"$",
"search",
"->",
"get_compressed",
"(",
")",
";",
"}",
"// use message index sort as default sorting",
"if",
"(",
"!",
"$",
"sort_field",
")",
"{",
"// use search result from count() if possible",
"if",
"(",
"empty",
"(",
"$",
"search",
")",
"&&",
"$",
"this",
"->",
"options",
"[",
"'skip_deleted'",
"]",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"icache",
"[",
"'undeleted_idx'",
"]",
")",
"&&",
"$",
"this",
"->",
"icache",
"[",
"'undeleted_idx'",
"]",
"->",
"get_parameters",
"(",
"'ALL'",
")",
"!==",
"null",
"&&",
"$",
"this",
"->",
"icache",
"[",
"'undeleted_idx'",
"]",
"->",
"get_parameters",
"(",
"'MAILBOX'",
")",
"==",
"$",
"folder",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"icache",
"[",
"'undeleted_idx'",
"]",
";",
"}",
"else",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
"new",
"rcube_result_index",
"(",
")",
";",
"}",
"else",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"options",
"[",
"'skip_deleted'",
"]",
"?",
"'UNDELETED'",
":",
"''",
";",
"if",
"(",
"$",
"search",
")",
"{",
"$",
"query",
"=",
"trim",
"(",
"$",
"query",
".",
"' UID '",
".",
"$",
"search",
")",
";",
"}",
"$",
"index",
"=",
"$",
"this",
"->",
"conn",
"->",
"search",
"(",
"$",
"folder",
",",
"$",
"query",
",",
"true",
")",
";",
"}",
"}",
"else",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
"new",
"rcube_result_index",
"(",
")",
";",
"}",
"// fetch complete message index",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"get_capability",
"(",
"'SORT'",
")",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"options",
"[",
"'skip_deleted'",
"]",
"?",
"'UNDELETED'",
":",
"''",
";",
"if",
"(",
"$",
"search",
")",
"{",
"$",
"query",
"=",
"trim",
"(",
"$",
"query",
".",
"' UID '",
".",
"$",
"search",
")",
";",
"}",
"$",
"index",
"=",
"$",
"this",
"->",
"conn",
"->",
"sort",
"(",
"$",
"folder",
",",
"$",
"sort_field",
",",
"$",
"query",
",",
"true",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"index",
")",
"||",
"$",
"index",
"->",
"is_error",
"(",
")",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"conn",
"->",
"index",
"(",
"$",
"folder",
",",
"$",
"search",
"?",
"$",
"search",
":",
"\"1:*\"",
",",
"$",
"sort_field",
",",
"$",
"this",
"->",
"options",
"[",
"'skip_deleted'",
"]",
",",
"$",
"search",
"?",
"true",
":",
"false",
",",
"true",
")",
";",
"}",
"}",
"if",
"(",
"$",
"sort_order",
"!=",
"$",
"index",
"->",
"get_parameters",
"(",
"'ORDER'",
")",
")",
"{",
"$",
"index",
"->",
"revert",
"(",
")",
";",
"}",
"return",
"$",
"index",
";",
"}"
] |
Return sorted list of message UIDs ignoring current search settings.
Doesn't uses cache by default.
@param string $folder Folder to get index from
@param string $sort_field Sort column
@param string $sort_order Sort order [ASC, DESC]
@param rcube_result_* $search Optional messages set to limit the result
@return rcube_result_index Sorted list of message UIDs
|
[
"Return",
"sorted",
"list",
"of",
"message",
"UIDs",
"ignoring",
"current",
"search",
"settings",
".",
"Doesn",
"t",
"uses",
"cache",
"by",
"default",
"."
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L1421-L1475
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.thread_index
|
public function thread_index($folder='', $sort_field=NULL, $sort_order=NULL)
{
if (!strlen($folder)) {
$folder = $this->folder;
}
// we have a saved search result, get index from there
if ($this->search_string && $this->search_threads && $folder == $this->folder) {
$threads = $this->search_set;
}
else {
// get all threads (default sort order)
$threads = $this->threads($folder);
}
$this->set_sort_order($sort_field, $sort_order);
$this->sort_threads($threads);
return $threads;
}
|
php
|
public function thread_index($folder='', $sort_field=NULL, $sort_order=NULL)
{
if (!strlen($folder)) {
$folder = $this->folder;
}
// we have a saved search result, get index from there
if ($this->search_string && $this->search_threads && $folder == $this->folder) {
$threads = $this->search_set;
}
else {
// get all threads (default sort order)
$threads = $this->threads($folder);
}
$this->set_sort_order($sort_field, $sort_order);
$this->sort_threads($threads);
return $threads;
}
|
[
"public",
"function",
"thread_index",
"(",
"$",
"folder",
"=",
"''",
",",
"$",
"sort_field",
"=",
"NULL",
",",
"$",
"sort_order",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"strlen",
"(",
"$",
"folder",
")",
")",
"{",
"$",
"folder",
"=",
"$",
"this",
"->",
"folder",
";",
"}",
"// we have a saved search result, get index from there",
"if",
"(",
"$",
"this",
"->",
"search_string",
"&&",
"$",
"this",
"->",
"search_threads",
"&&",
"$",
"folder",
"==",
"$",
"this",
"->",
"folder",
")",
"{",
"$",
"threads",
"=",
"$",
"this",
"->",
"search_set",
";",
"}",
"else",
"{",
"// get all threads (default sort order)",
"$",
"threads",
"=",
"$",
"this",
"->",
"threads",
"(",
"$",
"folder",
")",
";",
"}",
"$",
"this",
"->",
"set_sort_order",
"(",
"$",
"sort_field",
",",
"$",
"sort_order",
")",
";",
"$",
"this",
"->",
"sort_threads",
"(",
"$",
"threads",
")",
";",
"return",
"$",
"threads",
";",
"}"
] |
Return index of threaded message UIDs
@param string $folder Folder to get index from
@param string $sort_field Sort column
@param string $sort_order Sort order [ASC, DESC]
@return rcube_result_thread Message UIDs
|
[
"Return",
"index",
"of",
"threaded",
"message",
"UIDs"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L1486-L1505
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.sort_threads
|
protected function sort_threads($threads)
{
if ($threads->is_empty()) {
return;
}
// THREAD=ORDEREDSUBJECT: sorting by sent date of root message
// THREAD=REFERENCES: sorting by sent date of root message
// THREAD=REFS: sorting by the most recent date in each thread
if ($this->threading != 'REFS' || ($this->sort_field && $this->sort_field != 'date')) {
$sortby = $this->sort_field ? $this->sort_field : 'date';
$index = $this->index($this->folder, $sortby, $this->sort_order, true, true);
if (!$index->is_empty()) {
$threads->sort($index);
}
}
else if ($this->sort_order != $threads->get_parameters('ORDER')) {
$threads->revert();
}
}
|
php
|
protected function sort_threads($threads)
{
if ($threads->is_empty()) {
return;
}
// THREAD=ORDEREDSUBJECT: sorting by sent date of root message
// THREAD=REFERENCES: sorting by sent date of root message
// THREAD=REFS: sorting by the most recent date in each thread
if ($this->threading != 'REFS' || ($this->sort_field && $this->sort_field != 'date')) {
$sortby = $this->sort_field ? $this->sort_field : 'date';
$index = $this->index($this->folder, $sortby, $this->sort_order, true, true);
if (!$index->is_empty()) {
$threads->sort($index);
}
}
else if ($this->sort_order != $threads->get_parameters('ORDER')) {
$threads->revert();
}
}
|
[
"protected",
"function",
"sort_threads",
"(",
"$",
"threads",
")",
"{",
"if",
"(",
"$",
"threads",
"->",
"is_empty",
"(",
")",
")",
"{",
"return",
";",
"}",
"// THREAD=ORDEREDSUBJECT: sorting by sent date of root message",
"// THREAD=REFERENCES: sorting by sent date of root message",
"// THREAD=REFS: sorting by the most recent date in each thread",
"if",
"(",
"$",
"this",
"->",
"threading",
"!=",
"'REFS'",
"||",
"(",
"$",
"this",
"->",
"sort_field",
"&&",
"$",
"this",
"->",
"sort_field",
"!=",
"'date'",
")",
")",
"{",
"$",
"sortby",
"=",
"$",
"this",
"->",
"sort_field",
"?",
"$",
"this",
"->",
"sort_field",
":",
"'date'",
";",
"$",
"index",
"=",
"$",
"this",
"->",
"index",
"(",
"$",
"this",
"->",
"folder",
",",
"$",
"sortby",
",",
"$",
"this",
"->",
"sort_order",
",",
"true",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"index",
"->",
"is_empty",
"(",
")",
")",
"{",
"$",
"threads",
"->",
"sort",
"(",
"$",
"index",
")",
";",
"}",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"sort_order",
"!=",
"$",
"threads",
"->",
"get_parameters",
"(",
"'ORDER'",
")",
")",
"{",
"$",
"threads",
"->",
"revert",
"(",
")",
";",
"}",
"}"
] |
Sort threaded result, using THREAD=REFS method if available.
If not, use any method and re-sort the result in THREAD=REFS way.
@param rcube_result_thread $threads Threads result set
|
[
"Sort",
"threaded",
"result",
"using",
"THREAD",
"=",
"REFS",
"method",
"if",
"available",
".",
"If",
"not",
"use",
"any",
"method",
"and",
"re",
"-",
"sort",
"the",
"result",
"in",
"THREAD",
"=",
"REFS",
"way",
"."
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L1513-L1534
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.search_index
|
protected function search_index($folder, $criteria='ALL', $charset=NULL, $sort_field=NULL)
{
if (!$this->check_connection()) {
if ($this->threading) {
return new rcube_result_thread();
}
else {
return new rcube_result_index();
}
}
if ($this->options['skip_deleted'] && !preg_match('/UNDELETED/', $criteria)) {
$criteria = 'UNDELETED '.$criteria;
}
// unset CHARSET if criteria string is ASCII, this way
// SEARCH won't be re-sent after "unsupported charset" response
if ($charset && $charset != 'US-ASCII' && is_ascii($criteria)) {
$charset = 'US-ASCII';
}
if ($this->threading) {
$threads = $this->conn->thread($folder, $this->threading, $criteria, true, $charset);
// Error, try with US-ASCII (RFC5256: SORT/THREAD must support US-ASCII and UTF-8,
// but I've seen that Courier doesn't support UTF-8)
if ($threads->is_error() && $charset && $charset != 'US-ASCII') {
$threads = $this->conn->thread($folder, $this->threading,
self::convert_criteria($criteria, $charset), true, 'US-ASCII');
}
return $threads;
}
if ($sort_field && $this->get_capability('SORT')) {
$charset = $charset ? $charset : $this->default_charset;
$messages = $this->conn->sort($folder, $sort_field, $criteria, true, $charset);
// Error, try with US-ASCII (RFC5256: SORT/THREAD must support US-ASCII and UTF-8,
// but I've seen Courier with disabled UTF-8 support)
if ($messages->is_error() && $charset && $charset != 'US-ASCII') {
$messages = $this->conn->sort($folder, $sort_field,
self::convert_criteria($criteria, $charset), true, 'US-ASCII');
}
if (!$messages->is_error()) {
$this->search_sorted = true;
return $messages;
}
}
$messages = $this->conn->search($folder,
($charset && $charset != 'US-ASCII' ? "CHARSET $charset " : '') . $criteria, true);
// Error, try with US-ASCII (some servers may support only US-ASCII)
if ($messages->is_error() && $charset && $charset != 'US-ASCII') {
$messages = $this->conn->search($folder,
self::convert_criteria($criteria, $charset), true);
}
$this->search_sorted = false;
return $messages;
}
|
php
|
protected function search_index($folder, $criteria='ALL', $charset=NULL, $sort_field=NULL)
{
if (!$this->check_connection()) {
if ($this->threading) {
return new rcube_result_thread();
}
else {
return new rcube_result_index();
}
}
if ($this->options['skip_deleted'] && !preg_match('/UNDELETED/', $criteria)) {
$criteria = 'UNDELETED '.$criteria;
}
// unset CHARSET if criteria string is ASCII, this way
// SEARCH won't be re-sent after "unsupported charset" response
if ($charset && $charset != 'US-ASCII' && is_ascii($criteria)) {
$charset = 'US-ASCII';
}
if ($this->threading) {
$threads = $this->conn->thread($folder, $this->threading, $criteria, true, $charset);
// Error, try with US-ASCII (RFC5256: SORT/THREAD must support US-ASCII and UTF-8,
// but I've seen that Courier doesn't support UTF-8)
if ($threads->is_error() && $charset && $charset != 'US-ASCII') {
$threads = $this->conn->thread($folder, $this->threading,
self::convert_criteria($criteria, $charset), true, 'US-ASCII');
}
return $threads;
}
if ($sort_field && $this->get_capability('SORT')) {
$charset = $charset ? $charset : $this->default_charset;
$messages = $this->conn->sort($folder, $sort_field, $criteria, true, $charset);
// Error, try with US-ASCII (RFC5256: SORT/THREAD must support US-ASCII and UTF-8,
// but I've seen Courier with disabled UTF-8 support)
if ($messages->is_error() && $charset && $charset != 'US-ASCII') {
$messages = $this->conn->sort($folder, $sort_field,
self::convert_criteria($criteria, $charset), true, 'US-ASCII');
}
if (!$messages->is_error()) {
$this->search_sorted = true;
return $messages;
}
}
$messages = $this->conn->search($folder,
($charset && $charset != 'US-ASCII' ? "CHARSET $charset " : '') . $criteria, true);
// Error, try with US-ASCII (some servers may support only US-ASCII)
if ($messages->is_error() && $charset && $charset != 'US-ASCII') {
$messages = $this->conn->search($folder,
self::convert_criteria($criteria, $charset), true);
}
$this->search_sorted = false;
return $messages;
}
|
[
"protected",
"function",
"search_index",
"(",
"$",
"folder",
",",
"$",
"criteria",
"=",
"'ALL'",
",",
"$",
"charset",
"=",
"NULL",
",",
"$",
"sort_field",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"threading",
")",
"{",
"return",
"new",
"rcube_result_thread",
"(",
")",
";",
"}",
"else",
"{",
"return",
"new",
"rcube_result_index",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'skip_deleted'",
"]",
"&&",
"!",
"preg_match",
"(",
"'/UNDELETED/'",
",",
"$",
"criteria",
")",
")",
"{",
"$",
"criteria",
"=",
"'UNDELETED '",
".",
"$",
"criteria",
";",
"}",
"// unset CHARSET if criteria string is ASCII, this way",
"// SEARCH won't be re-sent after \"unsupported charset\" response",
"if",
"(",
"$",
"charset",
"&&",
"$",
"charset",
"!=",
"'US-ASCII'",
"&&",
"is_ascii",
"(",
"$",
"criteria",
")",
")",
"{",
"$",
"charset",
"=",
"'US-ASCII'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"threading",
")",
"{",
"$",
"threads",
"=",
"$",
"this",
"->",
"conn",
"->",
"thread",
"(",
"$",
"folder",
",",
"$",
"this",
"->",
"threading",
",",
"$",
"criteria",
",",
"true",
",",
"$",
"charset",
")",
";",
"// Error, try with US-ASCII (RFC5256: SORT/THREAD must support US-ASCII and UTF-8,",
"// but I've seen that Courier doesn't support UTF-8)",
"if",
"(",
"$",
"threads",
"->",
"is_error",
"(",
")",
"&&",
"$",
"charset",
"&&",
"$",
"charset",
"!=",
"'US-ASCII'",
")",
"{",
"$",
"threads",
"=",
"$",
"this",
"->",
"conn",
"->",
"thread",
"(",
"$",
"folder",
",",
"$",
"this",
"->",
"threading",
",",
"self",
"::",
"convert_criteria",
"(",
"$",
"criteria",
",",
"$",
"charset",
")",
",",
"true",
",",
"'US-ASCII'",
")",
";",
"}",
"return",
"$",
"threads",
";",
"}",
"if",
"(",
"$",
"sort_field",
"&&",
"$",
"this",
"->",
"get_capability",
"(",
"'SORT'",
")",
")",
"{",
"$",
"charset",
"=",
"$",
"charset",
"?",
"$",
"charset",
":",
"$",
"this",
"->",
"default_charset",
";",
"$",
"messages",
"=",
"$",
"this",
"->",
"conn",
"->",
"sort",
"(",
"$",
"folder",
",",
"$",
"sort_field",
",",
"$",
"criteria",
",",
"true",
",",
"$",
"charset",
")",
";",
"// Error, try with US-ASCII (RFC5256: SORT/THREAD must support US-ASCII and UTF-8,",
"// but I've seen Courier with disabled UTF-8 support)",
"if",
"(",
"$",
"messages",
"->",
"is_error",
"(",
")",
"&&",
"$",
"charset",
"&&",
"$",
"charset",
"!=",
"'US-ASCII'",
")",
"{",
"$",
"messages",
"=",
"$",
"this",
"->",
"conn",
"->",
"sort",
"(",
"$",
"folder",
",",
"$",
"sort_field",
",",
"self",
"::",
"convert_criteria",
"(",
"$",
"criteria",
",",
"$",
"charset",
")",
",",
"true",
",",
"'US-ASCII'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"messages",
"->",
"is_error",
"(",
")",
")",
"{",
"$",
"this",
"->",
"search_sorted",
"=",
"true",
";",
"return",
"$",
"messages",
";",
"}",
"}",
"$",
"messages",
"=",
"$",
"this",
"->",
"conn",
"->",
"search",
"(",
"$",
"folder",
",",
"(",
"$",
"charset",
"&&",
"$",
"charset",
"!=",
"'US-ASCII'",
"?",
"\"CHARSET $charset \"",
":",
"''",
")",
".",
"$",
"criteria",
",",
"true",
")",
";",
"// Error, try with US-ASCII (some servers may support only US-ASCII)",
"if",
"(",
"$",
"messages",
"->",
"is_error",
"(",
")",
"&&",
"$",
"charset",
"&&",
"$",
"charset",
"!=",
"'US-ASCII'",
")",
"{",
"$",
"messages",
"=",
"$",
"this",
"->",
"conn",
"->",
"search",
"(",
"$",
"folder",
",",
"self",
"::",
"convert_criteria",
"(",
"$",
"criteria",
",",
"$",
"charset",
")",
",",
"true",
")",
";",
"}",
"$",
"this",
"->",
"search_sorted",
"=",
"false",
";",
"return",
"$",
"messages",
";",
"}"
] |
protected search method
@param string $folder Folder name
@param string $criteria Search criteria
@param string $charset Charset
@param string $sort_field Sorting field
@return rcube_result_index|rcube_result_thread Search results (UIDs)
@see rcube_imap::search()
|
[
"protected",
"search",
"method"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L1656-L1719
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.convert_criteria
|
public static function convert_criteria($str, $charset, $dest_charset='US-ASCII')
{
// convert strings to US_ASCII
if (preg_match_all('/\{([0-9]+)\}\r\n/', $str, $matches, PREG_OFFSET_CAPTURE)) {
$last = 0; $res = '';
foreach ($matches[1] as $m) {
$string_offset = $m[1] + strlen($m[0]) + 4; // {}\r\n
$string = substr($str, $string_offset - 1, $m[0]);
$string = rcube_charset::convert($string, $charset, $dest_charset);
if ($string === false || !strlen($string)) {
continue;
}
$res .= substr($str, $last, $m[1] - $last - 1) . rcube_imap_generic::escape($string);
$last = $m[0] + $string_offset - 1;
}
if ($last < strlen($str)) {
$res .= substr($str, $last, strlen($str)-$last);
}
}
// strings for conversion not found
else {
$res = $str;
}
return $res;
}
|
php
|
public static function convert_criteria($str, $charset, $dest_charset='US-ASCII')
{
// convert strings to US_ASCII
if (preg_match_all('/\{([0-9]+)\}\r\n/', $str, $matches, PREG_OFFSET_CAPTURE)) {
$last = 0; $res = '';
foreach ($matches[1] as $m) {
$string_offset = $m[1] + strlen($m[0]) + 4; // {}\r\n
$string = substr($str, $string_offset - 1, $m[0]);
$string = rcube_charset::convert($string, $charset, $dest_charset);
if ($string === false || !strlen($string)) {
continue;
}
$res .= substr($str, $last, $m[1] - $last - 1) . rcube_imap_generic::escape($string);
$last = $m[0] + $string_offset - 1;
}
if ($last < strlen($str)) {
$res .= substr($str, $last, strlen($str)-$last);
}
}
// strings for conversion not found
else {
$res = $str;
}
return $res;
}
|
[
"public",
"static",
"function",
"convert_criteria",
"(",
"$",
"str",
",",
"$",
"charset",
",",
"$",
"dest_charset",
"=",
"'US-ASCII'",
")",
"{",
"// convert strings to US_ASCII",
"if",
"(",
"preg_match_all",
"(",
"'/\\{([0-9]+)\\}\\r\\n/'",
",",
"$",
"str",
",",
"$",
"matches",
",",
"PREG_OFFSET_CAPTURE",
")",
")",
"{",
"$",
"last",
"=",
"0",
";",
"$",
"res",
"=",
"''",
";",
"foreach",
"(",
"$",
"matches",
"[",
"1",
"]",
"as",
"$",
"m",
")",
"{",
"$",
"string_offset",
"=",
"$",
"m",
"[",
"1",
"]",
"+",
"strlen",
"(",
"$",
"m",
"[",
"0",
"]",
")",
"+",
"4",
";",
"// {}\\r\\n",
"$",
"string",
"=",
"substr",
"(",
"$",
"str",
",",
"$",
"string_offset",
"-",
"1",
",",
"$",
"m",
"[",
"0",
"]",
")",
";",
"$",
"string",
"=",
"rcube_charset",
"::",
"convert",
"(",
"$",
"string",
",",
"$",
"charset",
",",
"$",
"dest_charset",
")",
";",
"if",
"(",
"$",
"string",
"===",
"false",
"||",
"!",
"strlen",
"(",
"$",
"string",
")",
")",
"{",
"continue",
";",
"}",
"$",
"res",
".=",
"substr",
"(",
"$",
"str",
",",
"$",
"last",
",",
"$",
"m",
"[",
"1",
"]",
"-",
"$",
"last",
"-",
"1",
")",
".",
"rcube_imap_generic",
"::",
"escape",
"(",
"$",
"string",
")",
";",
"$",
"last",
"=",
"$",
"m",
"[",
"0",
"]",
"+",
"$",
"string_offset",
"-",
"1",
";",
"}",
"if",
"(",
"$",
"last",
"<",
"strlen",
"(",
"$",
"str",
")",
")",
"{",
"$",
"res",
".=",
"substr",
"(",
"$",
"str",
",",
"$",
"last",
",",
"strlen",
"(",
"$",
"str",
")",
"-",
"$",
"last",
")",
";",
"}",
"}",
"// strings for conversion not found",
"else",
"{",
"$",
"res",
"=",
"$",
"str",
";",
"}",
"return",
"$",
"res",
";",
"}"
] |
Converts charset of search criteria string
@param string $str Search string
@param string $charset Original charset
@param string $dest_charset Destination charset (default US-ASCII)
@return string Search string
|
[
"Converts",
"charset",
"of",
"search",
"criteria",
"string"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L1730-L1758
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.refresh_search
|
public function refresh_search()
{
if (!empty($this->search_string)) {
$this->search(
is_object($this->search_set) ? $this->search_set->get_parameters('MAILBOX') : '',
$this->search_string,
$this->search_charset,
$this->search_sort_field
);
}
return $this->get_search_set();
}
|
php
|
public function refresh_search()
{
if (!empty($this->search_string)) {
$this->search(
is_object($this->search_set) ? $this->search_set->get_parameters('MAILBOX') : '',
$this->search_string,
$this->search_charset,
$this->search_sort_field
);
}
return $this->get_search_set();
}
|
[
"public",
"function",
"refresh_search",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"search_string",
")",
")",
"{",
"$",
"this",
"->",
"search",
"(",
"is_object",
"(",
"$",
"this",
"->",
"search_set",
")",
"?",
"$",
"this",
"->",
"search_set",
"->",
"get_parameters",
"(",
"'MAILBOX'",
")",
":",
"''",
",",
"$",
"this",
"->",
"search_string",
",",
"$",
"this",
"->",
"search_charset",
",",
"$",
"this",
"->",
"search_sort_field",
")",
";",
"}",
"return",
"$",
"this",
"->",
"get_search_set",
"(",
")",
";",
"}"
] |
Refresh saved search set
@return array Current search set
|
[
"Refresh",
"saved",
"search",
"set"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L1765-L1777
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.get_message_headers
|
public function get_message_headers($uid, $folder = null, $force = false)
{
// decode combined UID-folder identifier
if (preg_match('/^\d+-.+/', $uid)) {
list($uid, $folder) = explode('-', $uid, 2);
}
if (!strlen($folder)) {
$folder = $this->folder;
}
// get cached headers
if (!$force && $uid && ($mcache = $this->get_mcache_engine())) {
$headers = $mcache->get_message($folder, $uid);
}
else if (!$this->check_connection()) {
$headers = false;
}
else {
$headers = $this->conn->fetchHeader(
$folder, $uid, true, true, $this->get_fetch_headers());
if (is_object($headers))
$headers->folder = $folder;
}
return $headers;
}
|
php
|
public function get_message_headers($uid, $folder = null, $force = false)
{
// decode combined UID-folder identifier
if (preg_match('/^\d+-.+/', $uid)) {
list($uid, $folder) = explode('-', $uid, 2);
}
if (!strlen($folder)) {
$folder = $this->folder;
}
// get cached headers
if (!$force && $uid && ($mcache = $this->get_mcache_engine())) {
$headers = $mcache->get_message($folder, $uid);
}
else if (!$this->check_connection()) {
$headers = false;
}
else {
$headers = $this->conn->fetchHeader(
$folder, $uid, true, true, $this->get_fetch_headers());
if (is_object($headers))
$headers->folder = $folder;
}
return $headers;
}
|
[
"public",
"function",
"get_message_headers",
"(",
"$",
"uid",
",",
"$",
"folder",
"=",
"null",
",",
"$",
"force",
"=",
"false",
")",
"{",
"// decode combined UID-folder identifier",
"if",
"(",
"preg_match",
"(",
"'/^\\d+-.+/'",
",",
"$",
"uid",
")",
")",
"{",
"list",
"(",
"$",
"uid",
",",
"$",
"folder",
")",
"=",
"explode",
"(",
"'-'",
",",
"$",
"uid",
",",
"2",
")",
";",
"}",
"if",
"(",
"!",
"strlen",
"(",
"$",
"folder",
")",
")",
"{",
"$",
"folder",
"=",
"$",
"this",
"->",
"folder",
";",
"}",
"// get cached headers",
"if",
"(",
"!",
"$",
"force",
"&&",
"$",
"uid",
"&&",
"(",
"$",
"mcache",
"=",
"$",
"this",
"->",
"get_mcache_engine",
"(",
")",
")",
")",
"{",
"$",
"headers",
"=",
"$",
"mcache",
"->",
"get_message",
"(",
"$",
"folder",
",",
"$",
"uid",
")",
";",
"}",
"else",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"$",
"headers",
"=",
"false",
";",
"}",
"else",
"{",
"$",
"headers",
"=",
"$",
"this",
"->",
"conn",
"->",
"fetchHeader",
"(",
"$",
"folder",
",",
"$",
"uid",
",",
"true",
",",
"true",
",",
"$",
"this",
"->",
"get_fetch_headers",
"(",
")",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"headers",
")",
")",
"$",
"headers",
"->",
"folder",
"=",
"$",
"folder",
";",
"}",
"return",
"$",
"headers",
";",
"}"
] |
Return message headers object of a specific message
@param int $id Message UID
@param string $folder Folder to read from
@param bool $force True to skip cache
@return rcube_message_header Message headers
|
[
"Return",
"message",
"headers",
"object",
"of",
"a",
"specific",
"message"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L1801-L1828
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.get_raw_headers
|
public function get_raw_headers($uid, $part = null)
{
if (!$this->check_connection()) {
return null;
}
return $this->conn->fetchPartHeader($this->folder, $uid, true, $part);
}
|
php
|
public function get_raw_headers($uid, $part = null)
{
if (!$this->check_connection()) {
return null;
}
return $this->conn->fetchPartHeader($this->folder, $uid, true, $part);
}
|
[
"public",
"function",
"get_raw_headers",
"(",
"$",
"uid",
",",
"$",
"part",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"conn",
"->",
"fetchPartHeader",
"(",
"$",
"this",
"->",
"folder",
",",
"$",
"uid",
",",
"true",
",",
"$",
"part",
")",
";",
"}"
] |
Returns the message headers as string
@param int $uid Message UID
@param string $part Optional message part ID
@return string Message headers string
|
[
"Returns",
"the",
"message",
"headers",
"as",
"string"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L2429-L2436
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.print_raw_body
|
public function print_raw_body($uid, $formatted = true)
{
if (!$this->check_connection()) {
return;
}
$this->conn->handlePartBody($this->folder, $uid, true, null, null, true, null, $formatted);
}
|
php
|
public function print_raw_body($uid, $formatted = true)
{
if (!$this->check_connection()) {
return;
}
$this->conn->handlePartBody($this->folder, $uid, true, null, null, true, null, $formatted);
}
|
[
"public",
"function",
"print_raw_body",
"(",
"$",
"uid",
",",
"$",
"formatted",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"conn",
"->",
"handlePartBody",
"(",
"$",
"this",
"->",
"folder",
",",
"$",
"uid",
",",
"true",
",",
"null",
",",
"null",
",",
"true",
",",
"null",
",",
"$",
"formatted",
")",
";",
"}"
] |
Sends the whole message source to stdout
@param int $uid Message UID
@param bool $formatted Enables line-ending formatting
|
[
"Sends",
"the",
"whole",
"message",
"source",
"to",
"stdout"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L2444-L2451
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.set_flag
|
public function set_flag($uids, $flag, $folder=null, $skip_cache=false)
{
if (!strlen($folder)) {
$folder = $this->folder;
}
if (!$this->check_connection()) {
return false;
}
$flag = strtoupper($flag);
list($uids, $all_mode) = $this->parse_uids($uids);
if (strpos($flag, 'UN') === 0) {
$result = $this->conn->unflag($folder, $uids, substr($flag, 2));
}
else {
$result = $this->conn->flag($folder, $uids, $flag);
}
if ($result && !$skip_cache) {
// reload message headers if cached
// update flags instead removing from cache
if ($mcache = $this->get_mcache_engine()) {
$status = strpos($flag, 'UN') !== 0;
$mflag = preg_replace('/^UN/', '', $flag);
$mcache->change_flag($folder, $all_mode ? null : explode(',', $uids),
$mflag, $status);
}
// clear cached counters
if ($flag == 'SEEN' || $flag == 'UNSEEN') {
$this->clear_messagecount($folder, array('SEEN', 'UNSEEN'));
}
else if ($flag == 'DELETED' || $flag == 'UNDELETED') {
$this->clear_messagecount($folder, array('ALL', 'THREADS'));
if ($this->options['skip_deleted']) {
// remove cached messages
$this->clear_message_cache($folder, $all_mode ? null : explode(',', $uids));
}
}
$this->set_search_dirty($folder);
}
return $result;
}
|
php
|
public function set_flag($uids, $flag, $folder=null, $skip_cache=false)
{
if (!strlen($folder)) {
$folder = $this->folder;
}
if (!$this->check_connection()) {
return false;
}
$flag = strtoupper($flag);
list($uids, $all_mode) = $this->parse_uids($uids);
if (strpos($flag, 'UN') === 0) {
$result = $this->conn->unflag($folder, $uids, substr($flag, 2));
}
else {
$result = $this->conn->flag($folder, $uids, $flag);
}
if ($result && !$skip_cache) {
// reload message headers if cached
// update flags instead removing from cache
if ($mcache = $this->get_mcache_engine()) {
$status = strpos($flag, 'UN') !== 0;
$mflag = preg_replace('/^UN/', '', $flag);
$mcache->change_flag($folder, $all_mode ? null : explode(',', $uids),
$mflag, $status);
}
// clear cached counters
if ($flag == 'SEEN' || $flag == 'UNSEEN') {
$this->clear_messagecount($folder, array('SEEN', 'UNSEEN'));
}
else if ($flag == 'DELETED' || $flag == 'UNDELETED') {
$this->clear_messagecount($folder, array('ALL', 'THREADS'));
if ($this->options['skip_deleted']) {
// remove cached messages
$this->clear_message_cache($folder, $all_mode ? null : explode(',', $uids));
}
}
$this->set_search_dirty($folder);
}
return $result;
}
|
[
"public",
"function",
"set_flag",
"(",
"$",
"uids",
",",
"$",
"flag",
",",
"$",
"folder",
"=",
"null",
",",
"$",
"skip_cache",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"strlen",
"(",
"$",
"folder",
")",
")",
"{",
"$",
"folder",
"=",
"$",
"this",
"->",
"folder",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"flag",
"=",
"strtoupper",
"(",
"$",
"flag",
")",
";",
"list",
"(",
"$",
"uids",
",",
"$",
"all_mode",
")",
"=",
"$",
"this",
"->",
"parse_uids",
"(",
"$",
"uids",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"flag",
",",
"'UN'",
")",
"===",
"0",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"conn",
"->",
"unflag",
"(",
"$",
"folder",
",",
"$",
"uids",
",",
"substr",
"(",
"$",
"flag",
",",
"2",
")",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"conn",
"->",
"flag",
"(",
"$",
"folder",
",",
"$",
"uids",
",",
"$",
"flag",
")",
";",
"}",
"if",
"(",
"$",
"result",
"&&",
"!",
"$",
"skip_cache",
")",
"{",
"// reload message headers if cached",
"// update flags instead removing from cache",
"if",
"(",
"$",
"mcache",
"=",
"$",
"this",
"->",
"get_mcache_engine",
"(",
")",
")",
"{",
"$",
"status",
"=",
"strpos",
"(",
"$",
"flag",
",",
"'UN'",
")",
"!==",
"0",
";",
"$",
"mflag",
"=",
"preg_replace",
"(",
"'/^UN/'",
",",
"''",
",",
"$",
"flag",
")",
";",
"$",
"mcache",
"->",
"change_flag",
"(",
"$",
"folder",
",",
"$",
"all_mode",
"?",
"null",
":",
"explode",
"(",
"','",
",",
"$",
"uids",
")",
",",
"$",
"mflag",
",",
"$",
"status",
")",
";",
"}",
"// clear cached counters",
"if",
"(",
"$",
"flag",
"==",
"'SEEN'",
"||",
"$",
"flag",
"==",
"'UNSEEN'",
")",
"{",
"$",
"this",
"->",
"clear_messagecount",
"(",
"$",
"folder",
",",
"array",
"(",
"'SEEN'",
",",
"'UNSEEN'",
")",
")",
";",
"}",
"else",
"if",
"(",
"$",
"flag",
"==",
"'DELETED'",
"||",
"$",
"flag",
"==",
"'UNDELETED'",
")",
"{",
"$",
"this",
"->",
"clear_messagecount",
"(",
"$",
"folder",
",",
"array",
"(",
"'ALL'",
",",
"'THREADS'",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'skip_deleted'",
"]",
")",
"{",
"// remove cached messages",
"$",
"this",
"->",
"clear_message_cache",
"(",
"$",
"folder",
",",
"$",
"all_mode",
"?",
"null",
":",
"explode",
"(",
"','",
",",
"$",
"uids",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"set_search_dirty",
"(",
"$",
"folder",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Set message flag to one or several messages
@param mixed $uids Message UIDs as array or comma-separated string, or '*'
@param string $flag Flag to set: SEEN, UNDELETED, DELETED, RECENT, ANSWERED, DRAFT, MDNSENT
@param string $folder Folder name
@param boolean $skip_cache True to skip message cache clean up
@return boolean Operation status
|
[
"Set",
"message",
"flag",
"to",
"one",
"or",
"several",
"messages"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L2463-L2509
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.move_message
|
public function move_message($uids, $to_mbox, $from_mbox='')
{
if (!strlen($from_mbox)) {
$from_mbox = $this->folder;
}
if ($to_mbox === $from_mbox) {
return false;
}
list($uids, $all_mode) = $this->parse_uids($uids);
// exit if no message uids are specified
if (empty($uids)) {
return false;
}
if (!$this->check_connection()) {
return false;
}
$config = rcube::get_instance()->config;
$to_trash = $to_mbox == $config->get('trash_mbox');
// flag messages as read before moving them
if ($to_trash && $config->get('read_when_deleted')) {
// don't flush cache (4th argument)
$this->set_flag($uids, 'SEEN', $from_mbox, true);
}
// move messages
$moved = $this->conn->move($uids, $from_mbox, $to_mbox);
// when moving to Trash we make sure the folder exists
// as it's uncommon scenario we do this when MOVE fails, not before
if (!$moved && $to_trash && $this->get_response_code() == rcube_storage::TRYCREATE) {
if ($this->create_folder($to_mbox, true, 'trash')) {
$moved = $this->conn->move($uids, $from_mbox, $to_mbox);
}
}
if ($moved) {
$this->clear_messagecount($from_mbox);
$this->clear_messagecount($to_mbox);
$this->set_search_dirty($from_mbox);
$this->set_search_dirty($to_mbox);
}
// moving failed
else if ($to_trash && $config->get('delete_always', false)) {
$moved = $this->delete_message($uids, $from_mbox);
}
if ($moved) {
// unset threads internal cache
unset($this->icache['threads']);
// remove message ids from search set
if ($this->search_set && $from_mbox == $this->folder) {
// threads are too complicated to just remove messages from set
if ($this->search_threads || $all_mode) {
$this->refresh_search();
}
else if (!$this->search_set->incomplete) {
$this->search_set->filter(explode(',', $uids), $this->folder);
}
}
// remove cached messages
// @TODO: do cache update instead of clearing it
$this->clear_message_cache($from_mbox, $all_mode ? null : explode(',', $uids));
}
return $moved;
}
|
php
|
public function move_message($uids, $to_mbox, $from_mbox='')
{
if (!strlen($from_mbox)) {
$from_mbox = $this->folder;
}
if ($to_mbox === $from_mbox) {
return false;
}
list($uids, $all_mode) = $this->parse_uids($uids);
// exit if no message uids are specified
if (empty($uids)) {
return false;
}
if (!$this->check_connection()) {
return false;
}
$config = rcube::get_instance()->config;
$to_trash = $to_mbox == $config->get('trash_mbox');
// flag messages as read before moving them
if ($to_trash && $config->get('read_when_deleted')) {
// don't flush cache (4th argument)
$this->set_flag($uids, 'SEEN', $from_mbox, true);
}
// move messages
$moved = $this->conn->move($uids, $from_mbox, $to_mbox);
// when moving to Trash we make sure the folder exists
// as it's uncommon scenario we do this when MOVE fails, not before
if (!$moved && $to_trash && $this->get_response_code() == rcube_storage::TRYCREATE) {
if ($this->create_folder($to_mbox, true, 'trash')) {
$moved = $this->conn->move($uids, $from_mbox, $to_mbox);
}
}
if ($moved) {
$this->clear_messagecount($from_mbox);
$this->clear_messagecount($to_mbox);
$this->set_search_dirty($from_mbox);
$this->set_search_dirty($to_mbox);
}
// moving failed
else if ($to_trash && $config->get('delete_always', false)) {
$moved = $this->delete_message($uids, $from_mbox);
}
if ($moved) {
// unset threads internal cache
unset($this->icache['threads']);
// remove message ids from search set
if ($this->search_set && $from_mbox == $this->folder) {
// threads are too complicated to just remove messages from set
if ($this->search_threads || $all_mode) {
$this->refresh_search();
}
else if (!$this->search_set->incomplete) {
$this->search_set->filter(explode(',', $uids), $this->folder);
}
}
// remove cached messages
// @TODO: do cache update instead of clearing it
$this->clear_message_cache($from_mbox, $all_mode ? null : explode(',', $uids));
}
return $moved;
}
|
[
"public",
"function",
"move_message",
"(",
"$",
"uids",
",",
"$",
"to_mbox",
",",
"$",
"from_mbox",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"strlen",
"(",
"$",
"from_mbox",
")",
")",
"{",
"$",
"from_mbox",
"=",
"$",
"this",
"->",
"folder",
";",
"}",
"if",
"(",
"$",
"to_mbox",
"===",
"$",
"from_mbox",
")",
"{",
"return",
"false",
";",
"}",
"list",
"(",
"$",
"uids",
",",
"$",
"all_mode",
")",
"=",
"$",
"this",
"->",
"parse_uids",
"(",
"$",
"uids",
")",
";",
"// exit if no message uids are specified",
"if",
"(",
"empty",
"(",
"$",
"uids",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"config",
"=",
"rcube",
"::",
"get_instance",
"(",
")",
"->",
"config",
";",
"$",
"to_trash",
"=",
"$",
"to_mbox",
"==",
"$",
"config",
"->",
"get",
"(",
"'trash_mbox'",
")",
";",
"// flag messages as read before moving them",
"if",
"(",
"$",
"to_trash",
"&&",
"$",
"config",
"->",
"get",
"(",
"'read_when_deleted'",
")",
")",
"{",
"// don't flush cache (4th argument)",
"$",
"this",
"->",
"set_flag",
"(",
"$",
"uids",
",",
"'SEEN'",
",",
"$",
"from_mbox",
",",
"true",
")",
";",
"}",
"// move messages",
"$",
"moved",
"=",
"$",
"this",
"->",
"conn",
"->",
"move",
"(",
"$",
"uids",
",",
"$",
"from_mbox",
",",
"$",
"to_mbox",
")",
";",
"// when moving to Trash we make sure the folder exists",
"// as it's uncommon scenario we do this when MOVE fails, not before",
"if",
"(",
"!",
"$",
"moved",
"&&",
"$",
"to_trash",
"&&",
"$",
"this",
"->",
"get_response_code",
"(",
")",
"==",
"rcube_storage",
"::",
"TRYCREATE",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"create_folder",
"(",
"$",
"to_mbox",
",",
"true",
",",
"'trash'",
")",
")",
"{",
"$",
"moved",
"=",
"$",
"this",
"->",
"conn",
"->",
"move",
"(",
"$",
"uids",
",",
"$",
"from_mbox",
",",
"$",
"to_mbox",
")",
";",
"}",
"}",
"if",
"(",
"$",
"moved",
")",
"{",
"$",
"this",
"->",
"clear_messagecount",
"(",
"$",
"from_mbox",
")",
";",
"$",
"this",
"->",
"clear_messagecount",
"(",
"$",
"to_mbox",
")",
";",
"$",
"this",
"->",
"set_search_dirty",
"(",
"$",
"from_mbox",
")",
";",
"$",
"this",
"->",
"set_search_dirty",
"(",
"$",
"to_mbox",
")",
";",
"}",
"// moving failed",
"else",
"if",
"(",
"$",
"to_trash",
"&&",
"$",
"config",
"->",
"get",
"(",
"'delete_always'",
",",
"false",
")",
")",
"{",
"$",
"moved",
"=",
"$",
"this",
"->",
"delete_message",
"(",
"$",
"uids",
",",
"$",
"from_mbox",
")",
";",
"}",
"if",
"(",
"$",
"moved",
")",
"{",
"// unset threads internal cache",
"unset",
"(",
"$",
"this",
"->",
"icache",
"[",
"'threads'",
"]",
")",
";",
"// remove message ids from search set",
"if",
"(",
"$",
"this",
"->",
"search_set",
"&&",
"$",
"from_mbox",
"==",
"$",
"this",
"->",
"folder",
")",
"{",
"// threads are too complicated to just remove messages from set",
"if",
"(",
"$",
"this",
"->",
"search_threads",
"||",
"$",
"all_mode",
")",
"{",
"$",
"this",
"->",
"refresh_search",
"(",
")",
";",
"}",
"else",
"if",
"(",
"!",
"$",
"this",
"->",
"search_set",
"->",
"incomplete",
")",
"{",
"$",
"this",
"->",
"search_set",
"->",
"filter",
"(",
"explode",
"(",
"','",
",",
"$",
"uids",
")",
",",
"$",
"this",
"->",
"folder",
")",
";",
"}",
"}",
"// remove cached messages",
"// @TODO: do cache update instead of clearing it",
"$",
"this",
"->",
"clear_message_cache",
"(",
"$",
"from_mbox",
",",
"$",
"all_mode",
"?",
"null",
":",
"explode",
"(",
"','",
",",
"$",
"uids",
")",
")",
";",
"}",
"return",
"$",
"moved",
";",
"}"
] |
Move a message from one folder to another
@param mixed $uids Message UIDs as array or comma-separated string, or '*'
@param string $to_mbox Target folder
@param string $from_mbox Source folder
@return boolean True on success, False on error
|
[
"Move",
"a",
"message",
"from",
"one",
"folder",
"to",
"another"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L2577-L2651
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.copy_message
|
public function copy_message($uids, $to_mbox, $from_mbox='')
{
if (!strlen($from_mbox)) {
$from_mbox = $this->folder;
}
list($uids, $all_mode) = $this->parse_uids($uids);
// exit if no message uids are specified
if (empty($uids)) {
return false;
}
if (!$this->check_connection()) {
return false;
}
// copy messages
$copied = $this->conn->copy($uids, $from_mbox, $to_mbox);
if ($copied) {
$this->clear_messagecount($to_mbox);
}
return $copied;
}
|
php
|
public function copy_message($uids, $to_mbox, $from_mbox='')
{
if (!strlen($from_mbox)) {
$from_mbox = $this->folder;
}
list($uids, $all_mode) = $this->parse_uids($uids);
// exit if no message uids are specified
if (empty($uids)) {
return false;
}
if (!$this->check_connection()) {
return false;
}
// copy messages
$copied = $this->conn->copy($uids, $from_mbox, $to_mbox);
if ($copied) {
$this->clear_messagecount($to_mbox);
}
return $copied;
}
|
[
"public",
"function",
"copy_message",
"(",
"$",
"uids",
",",
"$",
"to_mbox",
",",
"$",
"from_mbox",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"strlen",
"(",
"$",
"from_mbox",
")",
")",
"{",
"$",
"from_mbox",
"=",
"$",
"this",
"->",
"folder",
";",
"}",
"list",
"(",
"$",
"uids",
",",
"$",
"all_mode",
")",
"=",
"$",
"this",
"->",
"parse_uids",
"(",
"$",
"uids",
")",
";",
"// exit if no message uids are specified",
"if",
"(",
"empty",
"(",
"$",
"uids",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// copy messages",
"$",
"copied",
"=",
"$",
"this",
"->",
"conn",
"->",
"copy",
"(",
"$",
"uids",
",",
"$",
"from_mbox",
",",
"$",
"to_mbox",
")",
";",
"if",
"(",
"$",
"copied",
")",
"{",
"$",
"this",
"->",
"clear_messagecount",
"(",
"$",
"to_mbox",
")",
";",
"}",
"return",
"$",
"copied",
";",
"}"
] |
Copy a message from one folder to another
@param mixed $uids Message UIDs as array or comma-separated string, or '*'
@param string $to_mbox Target folder
@param string $from_mbox Source folder
@return boolean True on success, False on error
|
[
"Copy",
"a",
"message",
"from",
"one",
"folder",
"to",
"another"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L2662-L2687
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.delete_message
|
public function delete_message($uids, $folder='')
{
if (!strlen($folder)) {
$folder = $this->folder;
}
list($uids, $all_mode) = $this->parse_uids($uids);
// exit if no message uids are specified
if (empty($uids)) {
return false;
}
if (!$this->check_connection()) {
return false;
}
$deleted = $this->conn->flag($folder, $uids, 'DELETED');
if ($deleted) {
// send expunge command in order to have the deleted message
// really deleted from the folder
$this->expunge_message($uids, $folder, false);
$this->clear_messagecount($folder);
// unset threads internal cache
unset($this->icache['threads']);
$this->set_search_dirty($folder);
// remove message ids from search set
if ($this->search_set && $folder == $this->folder) {
// threads are too complicated to just remove messages from set
if ($this->search_threads || $all_mode) {
$this->refresh_search();
}
else if (!$this->search_set->incomplete) {
$this->search_set->filter(explode(',', $uids));
}
}
// remove cached messages
$this->clear_message_cache($folder, $all_mode ? null : explode(',', $uids));
}
return $deleted;
}
|
php
|
public function delete_message($uids, $folder='')
{
if (!strlen($folder)) {
$folder = $this->folder;
}
list($uids, $all_mode) = $this->parse_uids($uids);
// exit if no message uids are specified
if (empty($uids)) {
return false;
}
if (!$this->check_connection()) {
return false;
}
$deleted = $this->conn->flag($folder, $uids, 'DELETED');
if ($deleted) {
// send expunge command in order to have the deleted message
// really deleted from the folder
$this->expunge_message($uids, $folder, false);
$this->clear_messagecount($folder);
// unset threads internal cache
unset($this->icache['threads']);
$this->set_search_dirty($folder);
// remove message ids from search set
if ($this->search_set && $folder == $this->folder) {
// threads are too complicated to just remove messages from set
if ($this->search_threads || $all_mode) {
$this->refresh_search();
}
else if (!$this->search_set->incomplete) {
$this->search_set->filter(explode(',', $uids));
}
}
// remove cached messages
$this->clear_message_cache($folder, $all_mode ? null : explode(',', $uids));
}
return $deleted;
}
|
[
"public",
"function",
"delete_message",
"(",
"$",
"uids",
",",
"$",
"folder",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"strlen",
"(",
"$",
"folder",
")",
")",
"{",
"$",
"folder",
"=",
"$",
"this",
"->",
"folder",
";",
"}",
"list",
"(",
"$",
"uids",
",",
"$",
"all_mode",
")",
"=",
"$",
"this",
"->",
"parse_uids",
"(",
"$",
"uids",
")",
";",
"// exit if no message uids are specified",
"if",
"(",
"empty",
"(",
"$",
"uids",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"deleted",
"=",
"$",
"this",
"->",
"conn",
"->",
"flag",
"(",
"$",
"folder",
",",
"$",
"uids",
",",
"'DELETED'",
")",
";",
"if",
"(",
"$",
"deleted",
")",
"{",
"// send expunge command in order to have the deleted message",
"// really deleted from the folder",
"$",
"this",
"->",
"expunge_message",
"(",
"$",
"uids",
",",
"$",
"folder",
",",
"false",
")",
";",
"$",
"this",
"->",
"clear_messagecount",
"(",
"$",
"folder",
")",
";",
"// unset threads internal cache",
"unset",
"(",
"$",
"this",
"->",
"icache",
"[",
"'threads'",
"]",
")",
";",
"$",
"this",
"->",
"set_search_dirty",
"(",
"$",
"folder",
")",
";",
"// remove message ids from search set",
"if",
"(",
"$",
"this",
"->",
"search_set",
"&&",
"$",
"folder",
"==",
"$",
"this",
"->",
"folder",
")",
"{",
"// threads are too complicated to just remove messages from set",
"if",
"(",
"$",
"this",
"->",
"search_threads",
"||",
"$",
"all_mode",
")",
"{",
"$",
"this",
"->",
"refresh_search",
"(",
")",
";",
"}",
"else",
"if",
"(",
"!",
"$",
"this",
"->",
"search_set",
"->",
"incomplete",
")",
"{",
"$",
"this",
"->",
"search_set",
"->",
"filter",
"(",
"explode",
"(",
"','",
",",
"$",
"uids",
")",
")",
";",
"}",
"}",
"// remove cached messages",
"$",
"this",
"->",
"clear_message_cache",
"(",
"$",
"folder",
",",
"$",
"all_mode",
"?",
"null",
":",
"explode",
"(",
"','",
",",
"$",
"uids",
")",
")",
";",
"}",
"return",
"$",
"deleted",
";",
"}"
] |
Mark messages as deleted and expunge them
@param mixed $uids Message UIDs as array or comma-separated string, or '*'
@param string $folder Source folder
@return boolean True on success, False on error
|
[
"Mark",
"messages",
"as",
"deleted",
"and",
"expunge",
"them"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L2697-L2743
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.expunge_message
|
public function expunge_message($uids, $folder = null, $clear_cache = true)
{
if ($uids && $this->get_capability('UIDPLUS')) {
list($uids, $all_mode) = $this->parse_uids($uids);
}
else {
$uids = null;
}
if (!strlen($folder)) {
$folder = $this->folder;
}
if (!$this->check_connection()) {
return false;
}
// force folder selection and check if folder is writeable
// to prevent a situation when CLOSE is executed on closed
// or EXPUNGE on read-only folder
$result = $this->conn->select($folder);
if (!$result) {
return false;
}
if (!$this->conn->data['READ-WRITE']) {
$this->conn->setError(rcube_imap_generic::ERROR_READONLY, "Folder is read-only");
return false;
}
// CLOSE(+SELECT) should be faster than EXPUNGE
if (empty($uids) || $all_mode) {
$result = $this->conn->close();
}
else {
$result = $this->conn->expunge($folder, $uids);
}
if ($result && $clear_cache) {
$this->clear_message_cache($folder, $all_mode ? null : explode(',', $uids));
$this->clear_messagecount($folder);
}
return $result;
}
|
php
|
public function expunge_message($uids, $folder = null, $clear_cache = true)
{
if ($uids && $this->get_capability('UIDPLUS')) {
list($uids, $all_mode) = $this->parse_uids($uids);
}
else {
$uids = null;
}
if (!strlen($folder)) {
$folder = $this->folder;
}
if (!$this->check_connection()) {
return false;
}
// force folder selection and check if folder is writeable
// to prevent a situation when CLOSE is executed on closed
// or EXPUNGE on read-only folder
$result = $this->conn->select($folder);
if (!$result) {
return false;
}
if (!$this->conn->data['READ-WRITE']) {
$this->conn->setError(rcube_imap_generic::ERROR_READONLY, "Folder is read-only");
return false;
}
// CLOSE(+SELECT) should be faster than EXPUNGE
if (empty($uids) || $all_mode) {
$result = $this->conn->close();
}
else {
$result = $this->conn->expunge($folder, $uids);
}
if ($result && $clear_cache) {
$this->clear_message_cache($folder, $all_mode ? null : explode(',', $uids));
$this->clear_messagecount($folder);
}
return $result;
}
|
[
"public",
"function",
"expunge_message",
"(",
"$",
"uids",
",",
"$",
"folder",
"=",
"null",
",",
"$",
"clear_cache",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"uids",
"&&",
"$",
"this",
"->",
"get_capability",
"(",
"'UIDPLUS'",
")",
")",
"{",
"list",
"(",
"$",
"uids",
",",
"$",
"all_mode",
")",
"=",
"$",
"this",
"->",
"parse_uids",
"(",
"$",
"uids",
")",
";",
"}",
"else",
"{",
"$",
"uids",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"strlen",
"(",
"$",
"folder",
")",
")",
"{",
"$",
"folder",
"=",
"$",
"this",
"->",
"folder",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// force folder selection and check if folder is writeable",
"// to prevent a situation when CLOSE is executed on closed",
"// or EXPUNGE on read-only folder",
"$",
"result",
"=",
"$",
"this",
"->",
"conn",
"->",
"select",
"(",
"$",
"folder",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"conn",
"->",
"data",
"[",
"'READ-WRITE'",
"]",
")",
"{",
"$",
"this",
"->",
"conn",
"->",
"setError",
"(",
"rcube_imap_generic",
"::",
"ERROR_READONLY",
",",
"\"Folder is read-only\"",
")",
";",
"return",
"false",
";",
"}",
"// CLOSE(+SELECT) should be faster than EXPUNGE",
"if",
"(",
"empty",
"(",
"$",
"uids",
")",
"||",
"$",
"all_mode",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"conn",
"->",
"close",
"(",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"conn",
"->",
"expunge",
"(",
"$",
"folder",
",",
"$",
"uids",
")",
";",
"}",
"if",
"(",
"$",
"result",
"&&",
"$",
"clear_cache",
")",
"{",
"$",
"this",
"->",
"clear_message_cache",
"(",
"$",
"folder",
",",
"$",
"all_mode",
"?",
"null",
":",
"explode",
"(",
"','",
",",
"$",
"uids",
")",
")",
";",
"$",
"this",
"->",
"clear_messagecount",
"(",
"$",
"folder",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Send IMAP expunge command and clear cache
@param mixed $uids Message UIDs as array or comma-separated string, or '*'
@param string $folder Folder name
@param boolean $clear_cache False if cache should not be cleared
@return boolean True on success, False on failure
|
[
"Send",
"IMAP",
"expunge",
"command",
"and",
"clear",
"cache"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L2754-L2798
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.list_folders_subscribed
|
public function list_folders_subscribed($root='', $name='*', $filter=null, $rights=null, $skip_sort=false)
{
$cache_key = $root.':'.$name;
if (!empty($filter)) {
$cache_key .= ':'.(is_string($filter) ? $filter : serialize($filter));
}
$cache_key .= ':'.$rights;
$cache_key = 'mailboxes.'.md5($cache_key);
// get cached folder list
$a_mboxes = $this->get_cache($cache_key);
if (is_array($a_mboxes)) {
return $a_mboxes;
}
// Give plugins a chance to provide a list of folders
$data = $this->plugins->exec_hook('storage_folders',
array('root' => $root, 'name' => $name, 'filter' => $filter, 'mode' => 'LSUB'));
if (isset($data['folders'])) {
$a_mboxes = $data['folders'];
}
else {
$a_mboxes = $this->list_folders_subscribed_direct($root, $name);
}
if (!is_array($a_mboxes)) {
return array();
}
// filter folders list according to rights requirements
if ($rights && $this->get_capability('ACL')) {
$a_mboxes = $this->filter_rights($a_mboxes, $rights);
}
// INBOX should always be available
if (in_array_nocase($root . $name, array('*', '%', 'INBOX', 'INBOX*'))
&& (!$filter || $filter == 'mail') && !in_array('INBOX', $a_mboxes)
) {
array_unshift($a_mboxes, 'INBOX');
}
// sort folders (always sort for cache)
if (!$skip_sort || $this->cache) {
$a_mboxes = $this->sort_folder_list($a_mboxes);
}
// write folders list to cache
$this->update_cache($cache_key, $a_mboxes);
return $a_mboxes;
}
|
php
|
public function list_folders_subscribed($root='', $name='*', $filter=null, $rights=null, $skip_sort=false)
{
$cache_key = $root.':'.$name;
if (!empty($filter)) {
$cache_key .= ':'.(is_string($filter) ? $filter : serialize($filter));
}
$cache_key .= ':'.$rights;
$cache_key = 'mailboxes.'.md5($cache_key);
// get cached folder list
$a_mboxes = $this->get_cache($cache_key);
if (is_array($a_mboxes)) {
return $a_mboxes;
}
// Give plugins a chance to provide a list of folders
$data = $this->plugins->exec_hook('storage_folders',
array('root' => $root, 'name' => $name, 'filter' => $filter, 'mode' => 'LSUB'));
if (isset($data['folders'])) {
$a_mboxes = $data['folders'];
}
else {
$a_mboxes = $this->list_folders_subscribed_direct($root, $name);
}
if (!is_array($a_mboxes)) {
return array();
}
// filter folders list according to rights requirements
if ($rights && $this->get_capability('ACL')) {
$a_mboxes = $this->filter_rights($a_mboxes, $rights);
}
// INBOX should always be available
if (in_array_nocase($root . $name, array('*', '%', 'INBOX', 'INBOX*'))
&& (!$filter || $filter == 'mail') && !in_array('INBOX', $a_mboxes)
) {
array_unshift($a_mboxes, 'INBOX');
}
// sort folders (always sort for cache)
if (!$skip_sort || $this->cache) {
$a_mboxes = $this->sort_folder_list($a_mboxes);
}
// write folders list to cache
$this->update_cache($cache_key, $a_mboxes);
return $a_mboxes;
}
|
[
"public",
"function",
"list_folders_subscribed",
"(",
"$",
"root",
"=",
"''",
",",
"$",
"name",
"=",
"'*'",
",",
"$",
"filter",
"=",
"null",
",",
"$",
"rights",
"=",
"null",
",",
"$",
"skip_sort",
"=",
"false",
")",
"{",
"$",
"cache_key",
"=",
"$",
"root",
".",
"':'",
".",
"$",
"name",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"filter",
")",
")",
"{",
"$",
"cache_key",
".=",
"':'",
".",
"(",
"is_string",
"(",
"$",
"filter",
")",
"?",
"$",
"filter",
":",
"serialize",
"(",
"$",
"filter",
")",
")",
";",
"}",
"$",
"cache_key",
".=",
"':'",
".",
"$",
"rights",
";",
"$",
"cache_key",
"=",
"'mailboxes.'",
".",
"md5",
"(",
"$",
"cache_key",
")",
";",
"// get cached folder list",
"$",
"a_mboxes",
"=",
"$",
"this",
"->",
"get_cache",
"(",
"$",
"cache_key",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"a_mboxes",
")",
")",
"{",
"return",
"$",
"a_mboxes",
";",
"}",
"// Give plugins a chance to provide a list of folders",
"$",
"data",
"=",
"$",
"this",
"->",
"plugins",
"->",
"exec_hook",
"(",
"'storage_folders'",
",",
"array",
"(",
"'root'",
"=>",
"$",
"root",
",",
"'name'",
"=>",
"$",
"name",
",",
"'filter'",
"=>",
"$",
"filter",
",",
"'mode'",
"=>",
"'LSUB'",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'folders'",
"]",
")",
")",
"{",
"$",
"a_mboxes",
"=",
"$",
"data",
"[",
"'folders'",
"]",
";",
"}",
"else",
"{",
"$",
"a_mboxes",
"=",
"$",
"this",
"->",
"list_folders_subscribed_direct",
"(",
"$",
"root",
",",
"$",
"name",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"a_mboxes",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"// filter folders list according to rights requirements",
"if",
"(",
"$",
"rights",
"&&",
"$",
"this",
"->",
"get_capability",
"(",
"'ACL'",
")",
")",
"{",
"$",
"a_mboxes",
"=",
"$",
"this",
"->",
"filter_rights",
"(",
"$",
"a_mboxes",
",",
"$",
"rights",
")",
";",
"}",
"// INBOX should always be available",
"if",
"(",
"in_array_nocase",
"(",
"$",
"root",
".",
"$",
"name",
",",
"array",
"(",
"'*'",
",",
"'%'",
",",
"'INBOX'",
",",
"'INBOX*'",
")",
")",
"&&",
"(",
"!",
"$",
"filter",
"||",
"$",
"filter",
"==",
"'mail'",
")",
"&&",
"!",
"in_array",
"(",
"'INBOX'",
",",
"$",
"a_mboxes",
")",
")",
"{",
"array_unshift",
"(",
"$",
"a_mboxes",
",",
"'INBOX'",
")",
";",
"}",
"// sort folders (always sort for cache)",
"if",
"(",
"!",
"$",
"skip_sort",
"||",
"$",
"this",
"->",
"cache",
")",
"{",
"$",
"a_mboxes",
"=",
"$",
"this",
"->",
"sort_folder_list",
"(",
"$",
"a_mboxes",
")",
";",
"}",
"// write folders list to cache",
"$",
"this",
"->",
"update_cache",
"(",
"$",
"cache_key",
",",
"$",
"a_mboxes",
")",
";",
"return",
"$",
"a_mboxes",
";",
"}"
] |
Public method for listing subscribed folders.
@param string $root Optional root folder
@param string $name Optional name pattern
@param string $filter Optional filter
@param string $rights Optional ACL requirements
@param bool $skip_sort Enable to return unsorted list (for better performance)
@return array List of folders
|
[
"Public",
"method",
"for",
"listing",
"subscribed",
"folders",
"."
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L2816-L2867
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.list_folders_update
|
protected function list_folders_update(&$result, $type = null)
{
$namespace = $this->get_namespace();
$search = array();
// build list of namespace prefixes
foreach ((array)$namespace as $ns) {
if (is_array($ns)) {
foreach ($ns as $ns_data) {
if (strlen($ns_data[0])) {
$search[] = $ns_data[0];
}
}
}
}
if (!empty($search)) {
// go through all folders detecting namespace usage
foreach ($result as $folder) {
foreach ($search as $idx => $prefix) {
if (strpos($folder, $prefix) === 0) {
unset($search[$idx]);
}
}
if (empty($search)) {
break;
}
}
// get folders in hidden namespaces and add to the result
foreach ($search as $prefix) {
if ($type == 'ext-subscribed') {
$list = $this->conn->listMailboxes('', $prefix . '*', null, array('SUBSCRIBED'));
}
else if ($type == 'subscribed') {
$list = $this->conn->listSubscribed('', $prefix . '*');
}
else {
$list = $this->conn->listMailboxes('', $prefix . '*');
}
if (!empty($list)) {
$result = array_merge($result, $list);
}
}
}
}
|
php
|
protected function list_folders_update(&$result, $type = null)
{
$namespace = $this->get_namespace();
$search = array();
// build list of namespace prefixes
foreach ((array)$namespace as $ns) {
if (is_array($ns)) {
foreach ($ns as $ns_data) {
if (strlen($ns_data[0])) {
$search[] = $ns_data[0];
}
}
}
}
if (!empty($search)) {
// go through all folders detecting namespace usage
foreach ($result as $folder) {
foreach ($search as $idx => $prefix) {
if (strpos($folder, $prefix) === 0) {
unset($search[$idx]);
}
}
if (empty($search)) {
break;
}
}
// get folders in hidden namespaces and add to the result
foreach ($search as $prefix) {
if ($type == 'ext-subscribed') {
$list = $this->conn->listMailboxes('', $prefix . '*', null, array('SUBSCRIBED'));
}
else if ($type == 'subscribed') {
$list = $this->conn->listSubscribed('', $prefix . '*');
}
else {
$list = $this->conn->listMailboxes('', $prefix . '*');
}
if (!empty($list)) {
$result = array_merge($result, $list);
}
}
}
}
|
[
"protected",
"function",
"list_folders_update",
"(",
"&",
"$",
"result",
",",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"namespace",
"=",
"$",
"this",
"->",
"get_namespace",
"(",
")",
";",
"$",
"search",
"=",
"array",
"(",
")",
";",
"// build list of namespace prefixes",
"foreach",
"(",
"(",
"array",
")",
"$",
"namespace",
"as",
"$",
"ns",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"ns",
")",
")",
"{",
"foreach",
"(",
"$",
"ns",
"as",
"$",
"ns_data",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"ns_data",
"[",
"0",
"]",
")",
")",
"{",
"$",
"search",
"[",
"]",
"=",
"$",
"ns_data",
"[",
"0",
"]",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"search",
")",
")",
"{",
"// go through all folders detecting namespace usage",
"foreach",
"(",
"$",
"result",
"as",
"$",
"folder",
")",
"{",
"foreach",
"(",
"$",
"search",
"as",
"$",
"idx",
"=>",
"$",
"prefix",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"folder",
",",
"$",
"prefix",
")",
"===",
"0",
")",
"{",
"unset",
"(",
"$",
"search",
"[",
"$",
"idx",
"]",
")",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"search",
")",
")",
"{",
"break",
";",
"}",
"}",
"// get folders in hidden namespaces and add to the result",
"foreach",
"(",
"$",
"search",
"as",
"$",
"prefix",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"'ext-subscribed'",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"conn",
"->",
"listMailboxes",
"(",
"''",
",",
"$",
"prefix",
".",
"'*'",
",",
"null",
",",
"array",
"(",
"'SUBSCRIBED'",
")",
")",
";",
"}",
"else",
"if",
"(",
"$",
"type",
"==",
"'subscribed'",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"conn",
"->",
"listSubscribed",
"(",
"''",
",",
"$",
"prefix",
".",
"'*'",
")",
";",
"}",
"else",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"conn",
"->",
"listMailboxes",
"(",
"''",
",",
"$",
"prefix",
".",
"'*'",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"list",
")",
")",
"{",
"$",
"result",
"=",
"array_merge",
"(",
"$",
"result",
",",
"$",
"list",
")",
";",
"}",
"}",
"}",
"}"
] |
Fix folders list by adding folders from other namespaces.
Needed on some servers eg. Courier IMAP
@param array $result Reference to folders list
@param string $type Listing type (ext-subscribed, subscribed or all)
|
[
"Fix",
"folders",
"list",
"by",
"adding",
"folders",
"from",
"other",
"namespaces",
".",
"Needed",
"on",
"some",
"servers",
"eg",
".",
"Courier",
"IMAP"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L3060-L3106
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.filter_rights
|
protected function filter_rights($a_folders, $rights)
{
$regex = '/('.$rights.')/';
foreach ($a_folders as $idx => $folder) {
if ($this->folder_namespace($folder) == 'personal') {
continue;
}
$myrights = join('', (array)$this->my_rights($folder));
if ($myrights !== null && !preg_match($regex, $myrights)) {
unset($a_folders[$idx]);
}
}
return $a_folders;
}
|
php
|
protected function filter_rights($a_folders, $rights)
{
$regex = '/('.$rights.')/';
foreach ($a_folders as $idx => $folder) {
if ($this->folder_namespace($folder) == 'personal') {
continue;
}
$myrights = join('', (array)$this->my_rights($folder));
if ($myrights !== null && !preg_match($regex, $myrights)) {
unset($a_folders[$idx]);
}
}
return $a_folders;
}
|
[
"protected",
"function",
"filter_rights",
"(",
"$",
"a_folders",
",",
"$",
"rights",
")",
"{",
"$",
"regex",
"=",
"'/('",
".",
"$",
"rights",
".",
"')/'",
";",
"foreach",
"(",
"$",
"a_folders",
"as",
"$",
"idx",
"=>",
"$",
"folder",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"folder_namespace",
"(",
"$",
"folder",
")",
"==",
"'personal'",
")",
"{",
"continue",
";",
"}",
"$",
"myrights",
"=",
"join",
"(",
"''",
",",
"(",
"array",
")",
"$",
"this",
"->",
"my_rights",
"(",
"$",
"folder",
")",
")",
";",
"if",
"(",
"$",
"myrights",
"!==",
"null",
"&&",
"!",
"preg_match",
"(",
"$",
"regex",
",",
"$",
"myrights",
")",
")",
"{",
"unset",
"(",
"$",
"a_folders",
"[",
"$",
"idx",
"]",
")",
";",
"}",
"}",
"return",
"$",
"a_folders",
";",
"}"
] |
Filter the given list of folders according to access rights
For performance reasons we assume user has full rights
on all personal folders.
|
[
"Filter",
"the",
"given",
"list",
"of",
"folders",
"according",
"to",
"access",
"rights"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L3114-L3131
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.get_quota
|
public function get_quota($folder = null)
{
if ($this->get_capability('QUOTA') && $this->check_connection()) {
return $this->conn->getQuota($folder);
}
return false;
}
|
php
|
public function get_quota($folder = null)
{
if ($this->get_capability('QUOTA') && $this->check_connection()) {
return $this->conn->getQuota($folder);
}
return false;
}
|
[
"public",
"function",
"get_quota",
"(",
"$",
"folder",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"get_capability",
"(",
"'QUOTA'",
")",
"&&",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"conn",
"->",
"getQuota",
"(",
"$",
"folder",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Get mailbox quota information
@param string $folder Folder name
@return mixed Quota info or False if not supported
|
[
"Get",
"mailbox",
"quota",
"information"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L3140-L3147
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.create_folder
|
public function create_folder($folder, $subscribe = false, $type = null)
{
if (!$this->check_connection()) {
return false;
}
$result = $this->conn->createFolder($folder, $type ? array("\\" . ucfirst($type)) : null);
// try to subscribe it
if ($result) {
// clear cache
$this->clear_cache('mailboxes', true);
if ($subscribe) {
$this->subscribe($folder);
}
}
return $result;
}
|
php
|
public function create_folder($folder, $subscribe = false, $type = null)
{
if (!$this->check_connection()) {
return false;
}
$result = $this->conn->createFolder($folder, $type ? array("\\" . ucfirst($type)) : null);
// try to subscribe it
if ($result) {
// clear cache
$this->clear_cache('mailboxes', true);
if ($subscribe) {
$this->subscribe($folder);
}
}
return $result;
}
|
[
"public",
"function",
"create_folder",
"(",
"$",
"folder",
",",
"$",
"subscribe",
"=",
"false",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"conn",
"->",
"createFolder",
"(",
"$",
"folder",
",",
"$",
"type",
"?",
"array",
"(",
"\"\\\\\"",
".",
"ucfirst",
"(",
"$",
"type",
")",
")",
":",
"null",
")",
";",
"// try to subscribe it",
"if",
"(",
"$",
"result",
")",
"{",
"// clear cache",
"$",
"this",
"->",
"clear_cache",
"(",
"'mailboxes'",
",",
"true",
")",
";",
"if",
"(",
"$",
"subscribe",
")",
"{",
"$",
"this",
"->",
"subscribe",
"(",
"$",
"folder",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Create a new folder on the server and register it in local cache
@param string $folder New folder name
@param boolean $subscribe True if the new folder should be subscribed
@param string $type Optional folder type (junk, trash, drafts, sent, archive)
@return boolean True on success
|
[
"Create",
"a",
"new",
"folder",
"on",
"the",
"server",
"and",
"register",
"it",
"in",
"local",
"cache"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L3221-L3240
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.rename_folder
|
public function rename_folder($folder, $new_name)
{
if (!strlen($new_name)) {
return false;
}
if (!$this->check_connection()) {
return false;
}
$delm = $this->get_hierarchy_delimiter();
// get list of subscribed folders
if ((strpos($folder, '%') === false) && (strpos($folder, '*') === false)) {
$a_subscribed = $this->list_folders_subscribed('', $folder . $delm . '*');
$subscribed = $this->folder_exists($folder, true);
}
else {
$a_subscribed = $this->list_folders_subscribed();
$subscribed = in_array($folder, $a_subscribed);
}
$result = $this->conn->renameFolder($folder, $new_name);
if ($result) {
// unsubscribe the old folder, subscribe the new one
if ($subscribed) {
$this->conn->unsubscribe($folder);
$this->conn->subscribe($new_name);
}
// check if folder children are subscribed
foreach ($a_subscribed as $c_subscribed) {
if (strpos($c_subscribed, $folder.$delm) === 0) {
$this->conn->unsubscribe($c_subscribed);
$this->conn->subscribe(preg_replace('/^'.preg_quote($folder, '/').'/',
$new_name, $c_subscribed));
// clear cache
$this->clear_message_cache($c_subscribed);
}
}
// clear cache
$this->clear_message_cache($folder);
$this->clear_cache('mailboxes', true);
}
return $result;
}
|
php
|
public function rename_folder($folder, $new_name)
{
if (!strlen($new_name)) {
return false;
}
if (!$this->check_connection()) {
return false;
}
$delm = $this->get_hierarchy_delimiter();
// get list of subscribed folders
if ((strpos($folder, '%') === false) && (strpos($folder, '*') === false)) {
$a_subscribed = $this->list_folders_subscribed('', $folder . $delm . '*');
$subscribed = $this->folder_exists($folder, true);
}
else {
$a_subscribed = $this->list_folders_subscribed();
$subscribed = in_array($folder, $a_subscribed);
}
$result = $this->conn->renameFolder($folder, $new_name);
if ($result) {
// unsubscribe the old folder, subscribe the new one
if ($subscribed) {
$this->conn->unsubscribe($folder);
$this->conn->subscribe($new_name);
}
// check if folder children are subscribed
foreach ($a_subscribed as $c_subscribed) {
if (strpos($c_subscribed, $folder.$delm) === 0) {
$this->conn->unsubscribe($c_subscribed);
$this->conn->subscribe(preg_replace('/^'.preg_quote($folder, '/').'/',
$new_name, $c_subscribed));
// clear cache
$this->clear_message_cache($c_subscribed);
}
}
// clear cache
$this->clear_message_cache($folder);
$this->clear_cache('mailboxes', true);
}
return $result;
}
|
[
"public",
"function",
"rename_folder",
"(",
"$",
"folder",
",",
"$",
"new_name",
")",
"{",
"if",
"(",
"!",
"strlen",
"(",
"$",
"new_name",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"delm",
"=",
"$",
"this",
"->",
"get_hierarchy_delimiter",
"(",
")",
";",
"// get list of subscribed folders",
"if",
"(",
"(",
"strpos",
"(",
"$",
"folder",
",",
"'%'",
")",
"===",
"false",
")",
"&&",
"(",
"strpos",
"(",
"$",
"folder",
",",
"'*'",
")",
"===",
"false",
")",
")",
"{",
"$",
"a_subscribed",
"=",
"$",
"this",
"->",
"list_folders_subscribed",
"(",
"''",
",",
"$",
"folder",
".",
"$",
"delm",
".",
"'*'",
")",
";",
"$",
"subscribed",
"=",
"$",
"this",
"->",
"folder_exists",
"(",
"$",
"folder",
",",
"true",
")",
";",
"}",
"else",
"{",
"$",
"a_subscribed",
"=",
"$",
"this",
"->",
"list_folders_subscribed",
"(",
")",
";",
"$",
"subscribed",
"=",
"in_array",
"(",
"$",
"folder",
",",
"$",
"a_subscribed",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"conn",
"->",
"renameFolder",
"(",
"$",
"folder",
",",
"$",
"new_name",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"// unsubscribe the old folder, subscribe the new one",
"if",
"(",
"$",
"subscribed",
")",
"{",
"$",
"this",
"->",
"conn",
"->",
"unsubscribe",
"(",
"$",
"folder",
")",
";",
"$",
"this",
"->",
"conn",
"->",
"subscribe",
"(",
"$",
"new_name",
")",
";",
"}",
"// check if folder children are subscribed",
"foreach",
"(",
"$",
"a_subscribed",
"as",
"$",
"c_subscribed",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"c_subscribed",
",",
"$",
"folder",
".",
"$",
"delm",
")",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"conn",
"->",
"unsubscribe",
"(",
"$",
"c_subscribed",
")",
";",
"$",
"this",
"->",
"conn",
"->",
"subscribe",
"(",
"preg_replace",
"(",
"'/^'",
".",
"preg_quote",
"(",
"$",
"folder",
",",
"'/'",
")",
".",
"'/'",
",",
"$",
"new_name",
",",
"$",
"c_subscribed",
")",
")",
";",
"// clear cache",
"$",
"this",
"->",
"clear_message_cache",
"(",
"$",
"c_subscribed",
")",
";",
"}",
"}",
"// clear cache",
"$",
"this",
"->",
"clear_message_cache",
"(",
"$",
"folder",
")",
";",
"$",
"this",
"->",
"clear_cache",
"(",
"'mailboxes'",
",",
"true",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Set a new name to an existing folder
@param string $folder Folder to rename
@param string $new_name New folder name
@return boolean True on success
|
[
"Set",
"a",
"new",
"name",
"to",
"an",
"existing",
"folder"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L3250-L3299
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.get_special_folders
|
public function get_special_folders($forced = false)
{
$result = parent::get_special_folders();
$rcube = rcube::get_instance();
// Lock SPECIAL-USE after user preferences change (#4782)
if ($rcube->config->get('lock_special_folders')) {
return $result;
}
if (isset($this->icache['special-use'])) {
return array_merge($result, $this->icache['special-use']);
}
if (!$forced || !$this->get_capability('SPECIAL-USE')) {
return $result;
}
if (!$this->check_connection()) {
return $result;
}
$types = array_map(function($value) { return "\\" . ucfirst($value); }, rcube_storage::$folder_types);
$special = array();
// request \Subscribed flag in LIST response as performance improvement for folder_exists()
$folders = $this->conn->listMailboxes('', '*', array('SUBSCRIBED'), array('SPECIAL-USE'));
if (!empty($folders)) {
foreach ($folders as $folder) {
if ($flags = $this->conn->data['LIST'][$folder]) {
foreach ($types as $type) {
if (in_array($type, $flags)) {
$type = strtolower(substr($type, 1));
$special[$type] = $folder;
}
}
}
}
}
$this->icache['special-use'] = $special;
unset($this->icache['special-folders']);
return array_merge($result, $special);
}
|
php
|
public function get_special_folders($forced = false)
{
$result = parent::get_special_folders();
$rcube = rcube::get_instance();
// Lock SPECIAL-USE after user preferences change (#4782)
if ($rcube->config->get('lock_special_folders')) {
return $result;
}
if (isset($this->icache['special-use'])) {
return array_merge($result, $this->icache['special-use']);
}
if (!$forced || !$this->get_capability('SPECIAL-USE')) {
return $result;
}
if (!$this->check_connection()) {
return $result;
}
$types = array_map(function($value) { return "\\" . ucfirst($value); }, rcube_storage::$folder_types);
$special = array();
// request \Subscribed flag in LIST response as performance improvement for folder_exists()
$folders = $this->conn->listMailboxes('', '*', array('SUBSCRIBED'), array('SPECIAL-USE'));
if (!empty($folders)) {
foreach ($folders as $folder) {
if ($flags = $this->conn->data['LIST'][$folder]) {
foreach ($types as $type) {
if (in_array($type, $flags)) {
$type = strtolower(substr($type, 1));
$special[$type] = $folder;
}
}
}
}
}
$this->icache['special-use'] = $special;
unset($this->icache['special-folders']);
return array_merge($result, $special);
}
|
[
"public",
"function",
"get_special_folders",
"(",
"$",
"forced",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"parent",
"::",
"get_special_folders",
"(",
")",
";",
"$",
"rcube",
"=",
"rcube",
"::",
"get_instance",
"(",
")",
";",
"// Lock SPECIAL-USE after user preferences change (#4782)",
"if",
"(",
"$",
"rcube",
"->",
"config",
"->",
"get",
"(",
"'lock_special_folders'",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"icache",
"[",
"'special-use'",
"]",
")",
")",
"{",
"return",
"array_merge",
"(",
"$",
"result",
",",
"$",
"this",
"->",
"icache",
"[",
"'special-use'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"$",
"forced",
"||",
"!",
"$",
"this",
"->",
"get_capability",
"(",
"'SPECIAL-USE'",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"types",
"=",
"array_map",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"\"\\\\\"",
".",
"ucfirst",
"(",
"$",
"value",
")",
";",
"}",
",",
"rcube_storage",
"::",
"$",
"folder_types",
")",
";",
"$",
"special",
"=",
"array",
"(",
")",
";",
"// request \\Subscribed flag in LIST response as performance improvement for folder_exists()",
"$",
"folders",
"=",
"$",
"this",
"->",
"conn",
"->",
"listMailboxes",
"(",
"''",
",",
"'*'",
",",
"array",
"(",
"'SUBSCRIBED'",
")",
",",
"array",
"(",
"'SPECIAL-USE'",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"folders",
")",
")",
"{",
"foreach",
"(",
"$",
"folders",
"as",
"$",
"folder",
")",
"{",
"if",
"(",
"$",
"flags",
"=",
"$",
"this",
"->",
"conn",
"->",
"data",
"[",
"'LIST'",
"]",
"[",
"$",
"folder",
"]",
")",
"{",
"foreach",
"(",
"$",
"types",
"as",
"$",
"type",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"type",
",",
"$",
"flags",
")",
")",
"{",
"$",
"type",
"=",
"strtolower",
"(",
"substr",
"(",
"$",
"type",
",",
"1",
")",
")",
";",
"$",
"special",
"[",
"$",
"type",
"]",
"=",
"$",
"folder",
";",
"}",
"}",
"}",
"}",
"}",
"$",
"this",
"->",
"icache",
"[",
"'special-use'",
"]",
"=",
"$",
"special",
";",
"unset",
"(",
"$",
"this",
"->",
"icache",
"[",
"'special-folders'",
"]",
")",
";",
"return",
"array_merge",
"(",
"$",
"result",
",",
"$",
"special",
")",
";",
"}"
] |
Detect special folder associations stored in storage backend
|
[
"Detect",
"special",
"folder",
"associations",
"stored",
"in",
"storage",
"backend"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L3350-L3395
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.set_special_folders
|
public function set_special_folders($specials)
{
if (!$this->get_capability('SPECIAL-USE') || !$this->get_capability('METADATA')) {
return false;
}
if (!$this->check_connection()) {
return false;
}
$folders = $this->get_special_folders(true);
$old = (array) $this->icache['special-use'];
foreach ($specials as $type => $folder) {
if (in_array($type, rcube_storage::$folder_types)) {
$old_folder = $old[$type];
if ($old_folder !== $folder) {
// unset old-folder metadata
if ($old_folder !== null) {
$this->delete_metadata($old_folder, array('/private/specialuse'));
}
// set new folder metadata
if ($folder) {
$this->set_metadata($folder, array('/private/specialuse' => "\\" . ucfirst($type)));
}
}
}
}
$this->icache['special-use'] = $specials;
unset($this->icache['special-folders']);
return true;
}
|
php
|
public function set_special_folders($specials)
{
if (!$this->get_capability('SPECIAL-USE') || !$this->get_capability('METADATA')) {
return false;
}
if (!$this->check_connection()) {
return false;
}
$folders = $this->get_special_folders(true);
$old = (array) $this->icache['special-use'];
foreach ($specials as $type => $folder) {
if (in_array($type, rcube_storage::$folder_types)) {
$old_folder = $old[$type];
if ($old_folder !== $folder) {
// unset old-folder metadata
if ($old_folder !== null) {
$this->delete_metadata($old_folder, array('/private/specialuse'));
}
// set new folder metadata
if ($folder) {
$this->set_metadata($folder, array('/private/specialuse' => "\\" . ucfirst($type)));
}
}
}
}
$this->icache['special-use'] = $specials;
unset($this->icache['special-folders']);
return true;
}
|
[
"public",
"function",
"set_special_folders",
"(",
"$",
"specials",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"get_capability",
"(",
"'SPECIAL-USE'",
")",
"||",
"!",
"$",
"this",
"->",
"get_capability",
"(",
"'METADATA'",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"folders",
"=",
"$",
"this",
"->",
"get_special_folders",
"(",
"true",
")",
";",
"$",
"old",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"icache",
"[",
"'special-use'",
"]",
";",
"foreach",
"(",
"$",
"specials",
"as",
"$",
"type",
"=>",
"$",
"folder",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"type",
",",
"rcube_storage",
"::",
"$",
"folder_types",
")",
")",
"{",
"$",
"old_folder",
"=",
"$",
"old",
"[",
"$",
"type",
"]",
";",
"if",
"(",
"$",
"old_folder",
"!==",
"$",
"folder",
")",
"{",
"// unset old-folder metadata",
"if",
"(",
"$",
"old_folder",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"delete_metadata",
"(",
"$",
"old_folder",
",",
"array",
"(",
"'/private/specialuse'",
")",
")",
";",
"}",
"// set new folder metadata",
"if",
"(",
"$",
"folder",
")",
"{",
"$",
"this",
"->",
"set_metadata",
"(",
"$",
"folder",
",",
"array",
"(",
"'/private/specialuse'",
"=>",
"\"\\\\\"",
".",
"ucfirst",
"(",
"$",
"type",
")",
")",
")",
";",
"}",
"}",
"}",
"}",
"$",
"this",
"->",
"icache",
"[",
"'special-use'",
"]",
"=",
"$",
"specials",
";",
"unset",
"(",
"$",
"this",
"->",
"icache",
"[",
"'special-folders'",
"]",
")",
";",
"return",
"true",
";",
"}"
] |
Set special folder associations stored in storage backend
|
[
"Set",
"special",
"folder",
"associations",
"stored",
"in",
"storage",
"backend"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L3400-L3433
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.folder_exists
|
public function folder_exists($folder, $subscription = false)
{
if ($folder == 'INBOX') {
return true;
}
$key = $subscription ? 'subscribed' : 'existing';
if (is_array($this->icache[$key]) && in_array($folder, $this->icache[$key])) {
return true;
}
if (!$this->check_connection()) {
return false;
}
if ($subscription) {
// It's possible we already called LIST command, check LIST data
if (!empty($this->conn->data['LIST']) && !empty($this->conn->data['LIST'][$folder])
&& in_array_nocase('\\Subscribed', $this->conn->data['LIST'][$folder])
) {
$a_folders = array($folder);
}
else {
$a_folders = $this->conn->listSubscribed('', $folder);
}
}
else {
// It's possible we already called LIST command, check LIST data
if (!empty($this->conn->data['LIST']) && isset($this->conn->data['LIST'][$folder])) {
$a_folders = array($folder);
}
else {
$a_folders = $this->conn->listMailboxes('', $folder);
}
}
if (is_array($a_folders) && in_array($folder, $a_folders)) {
$this->icache[$key][] = $folder;
return true;
}
return false;
}
|
php
|
public function folder_exists($folder, $subscription = false)
{
if ($folder == 'INBOX') {
return true;
}
$key = $subscription ? 'subscribed' : 'existing';
if (is_array($this->icache[$key]) && in_array($folder, $this->icache[$key])) {
return true;
}
if (!$this->check_connection()) {
return false;
}
if ($subscription) {
// It's possible we already called LIST command, check LIST data
if (!empty($this->conn->data['LIST']) && !empty($this->conn->data['LIST'][$folder])
&& in_array_nocase('\\Subscribed', $this->conn->data['LIST'][$folder])
) {
$a_folders = array($folder);
}
else {
$a_folders = $this->conn->listSubscribed('', $folder);
}
}
else {
// It's possible we already called LIST command, check LIST data
if (!empty($this->conn->data['LIST']) && isset($this->conn->data['LIST'][$folder])) {
$a_folders = array($folder);
}
else {
$a_folders = $this->conn->listMailboxes('', $folder);
}
}
if (is_array($a_folders) && in_array($folder, $a_folders)) {
$this->icache[$key][] = $folder;
return true;
}
return false;
}
|
[
"public",
"function",
"folder_exists",
"(",
"$",
"folder",
",",
"$",
"subscription",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"folder",
"==",
"'INBOX'",
")",
"{",
"return",
"true",
";",
"}",
"$",
"key",
"=",
"$",
"subscription",
"?",
"'subscribed'",
":",
"'existing'",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"icache",
"[",
"$",
"key",
"]",
")",
"&&",
"in_array",
"(",
"$",
"folder",
",",
"$",
"this",
"->",
"icache",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"subscription",
")",
"{",
"// It's possible we already called LIST command, check LIST data",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"conn",
"->",
"data",
"[",
"'LIST'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"conn",
"->",
"data",
"[",
"'LIST'",
"]",
"[",
"$",
"folder",
"]",
")",
"&&",
"in_array_nocase",
"(",
"'\\\\Subscribed'",
",",
"$",
"this",
"->",
"conn",
"->",
"data",
"[",
"'LIST'",
"]",
"[",
"$",
"folder",
"]",
")",
")",
"{",
"$",
"a_folders",
"=",
"array",
"(",
"$",
"folder",
")",
";",
"}",
"else",
"{",
"$",
"a_folders",
"=",
"$",
"this",
"->",
"conn",
"->",
"listSubscribed",
"(",
"''",
",",
"$",
"folder",
")",
";",
"}",
"}",
"else",
"{",
"// It's possible we already called LIST command, check LIST data",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"conn",
"->",
"data",
"[",
"'LIST'",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"conn",
"->",
"data",
"[",
"'LIST'",
"]",
"[",
"$",
"folder",
"]",
")",
")",
"{",
"$",
"a_folders",
"=",
"array",
"(",
"$",
"folder",
")",
";",
"}",
"else",
"{",
"$",
"a_folders",
"=",
"$",
"this",
"->",
"conn",
"->",
"listMailboxes",
"(",
"''",
",",
"$",
"folder",
")",
";",
"}",
"}",
"if",
"(",
"is_array",
"(",
"$",
"a_folders",
")",
"&&",
"in_array",
"(",
"$",
"folder",
",",
"$",
"a_folders",
")",
")",
"{",
"$",
"this",
"->",
"icache",
"[",
"$",
"key",
"]",
"[",
"]",
"=",
"$",
"folder",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if folder exists and is subscribed
@param string $folder Folder name
@param boolean $subscription Enable subscription checking
@return boolean TRUE or FALSE
|
[
"Checks",
"if",
"folder",
"exists",
"and",
"is",
"subscribed"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L3443-L3486
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.folder_namespace
|
public function folder_namespace($folder)
{
if ($folder == 'INBOX') {
return 'personal';
}
foreach ($this->namespace as $type => $namespace) {
if (is_array($namespace)) {
foreach ($namespace as $ns) {
if ($len = strlen($ns[0])) {
if (($len > 1 && $folder == substr($ns[0], 0, -1))
|| strpos($folder, $ns[0]) === 0
) {
return $type;
}
}
}
}
}
return 'personal';
}
|
php
|
public function folder_namespace($folder)
{
if ($folder == 'INBOX') {
return 'personal';
}
foreach ($this->namespace as $type => $namespace) {
if (is_array($namespace)) {
foreach ($namespace as $ns) {
if ($len = strlen($ns[0])) {
if (($len > 1 && $folder == substr($ns[0], 0, -1))
|| strpos($folder, $ns[0]) === 0
) {
return $type;
}
}
}
}
}
return 'personal';
}
|
[
"public",
"function",
"folder_namespace",
"(",
"$",
"folder",
")",
"{",
"if",
"(",
"$",
"folder",
"==",
"'INBOX'",
")",
"{",
"return",
"'personal'",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"namespace",
"as",
"$",
"type",
"=>",
"$",
"namespace",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"namespace",
")",
")",
"{",
"foreach",
"(",
"$",
"namespace",
"as",
"$",
"ns",
")",
"{",
"if",
"(",
"$",
"len",
"=",
"strlen",
"(",
"$",
"ns",
"[",
"0",
"]",
")",
")",
"{",
"if",
"(",
"(",
"$",
"len",
">",
"1",
"&&",
"$",
"folder",
"==",
"substr",
"(",
"$",
"ns",
"[",
"0",
"]",
",",
"0",
",",
"-",
"1",
")",
")",
"||",
"strpos",
"(",
"$",
"folder",
",",
"$",
"ns",
"[",
"0",
"]",
")",
"===",
"0",
")",
"{",
"return",
"$",
"type",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"'personal'",
";",
"}"
] |
Returns the namespace where the folder is in
@param string $folder Folder name
@return string One of 'personal', 'other' or 'shared'
|
[
"Returns",
"the",
"namespace",
"where",
"the",
"folder",
"is",
"in"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L3495-L3516
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.mod_folder
|
public function mod_folder($folder, $mode = 'out')
{
$prefix = $this->namespace['prefix_' . $mode]; // see set_env()
if ($prefix === null || $prefix === ''
|| !($prefix_len = strlen($prefix)) || !strlen($folder)
) {
return $folder;
}
// remove prefix for output
if ($mode == 'out') {
if (substr($folder, 0, $prefix_len) === $prefix) {
return substr($folder, $prefix_len);
}
return $folder;
}
// add prefix for input (e.g. folder creation)
return $prefix . $folder;
}
|
php
|
public function mod_folder($folder, $mode = 'out')
{
$prefix = $this->namespace['prefix_' . $mode]; // see set_env()
if ($prefix === null || $prefix === ''
|| !($prefix_len = strlen($prefix)) || !strlen($folder)
) {
return $folder;
}
// remove prefix for output
if ($mode == 'out') {
if (substr($folder, 0, $prefix_len) === $prefix) {
return substr($folder, $prefix_len);
}
return $folder;
}
// add prefix for input (e.g. folder creation)
return $prefix . $folder;
}
|
[
"public",
"function",
"mod_folder",
"(",
"$",
"folder",
",",
"$",
"mode",
"=",
"'out'",
")",
"{",
"$",
"prefix",
"=",
"$",
"this",
"->",
"namespace",
"[",
"'prefix_'",
".",
"$",
"mode",
"]",
";",
"// see set_env()",
"if",
"(",
"$",
"prefix",
"===",
"null",
"||",
"$",
"prefix",
"===",
"''",
"||",
"!",
"(",
"$",
"prefix_len",
"=",
"strlen",
"(",
"$",
"prefix",
")",
")",
"||",
"!",
"strlen",
"(",
"$",
"folder",
")",
")",
"{",
"return",
"$",
"folder",
";",
"}",
"// remove prefix for output",
"if",
"(",
"$",
"mode",
"==",
"'out'",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"folder",
",",
"0",
",",
"$",
"prefix_len",
")",
"===",
"$",
"prefix",
")",
"{",
"return",
"substr",
"(",
"$",
"folder",
",",
"$",
"prefix_len",
")",
";",
"}",
"return",
"$",
"folder",
";",
"}",
"// add prefix for input (e.g. folder creation)",
"return",
"$",
"prefix",
".",
"$",
"folder",
";",
"}"
] |
Modify folder name according to personal namespace prefix.
For output it removes prefix of the personal namespace if it's possible.
For input it adds the prefix. Use it before creating a folder in root
of the folders tree.
@param string $folder Folder name
@param string $mode Mode name (out/in)
@return string Folder name
|
[
"Modify",
"folder",
"name",
"according",
"to",
"personal",
"namespace",
"prefix",
".",
"For",
"output",
"it",
"removes",
"prefix",
"of",
"the",
"personal",
"namespace",
"if",
"it",
"s",
"possible",
".",
"For",
"input",
"it",
"adds",
"the",
"prefix",
".",
"Use",
"it",
"before",
"creating",
"a",
"folder",
"in",
"root",
"of",
"the",
"folders",
"tree",
"."
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L3529-L3550
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.md2annotate
|
protected function md2annotate($entry)
{
if (substr($entry, 0, 7) == '/shared') {
return array(substr($entry, 7), 'value.shared');
}
else if (substr($entry, 0, 8) == '/private') {
return array(substr($entry, 8), 'value.priv');
}
// @TODO: log error
}
|
php
|
protected function md2annotate($entry)
{
if (substr($entry, 0, 7) == '/shared') {
return array(substr($entry, 7), 'value.shared');
}
else if (substr($entry, 0, 8) == '/private') {
return array(substr($entry, 8), 'value.priv');
}
// @TODO: log error
}
|
[
"protected",
"function",
"md2annotate",
"(",
"$",
"entry",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"entry",
",",
"0",
",",
"7",
")",
"==",
"'/shared'",
")",
"{",
"return",
"array",
"(",
"substr",
"(",
"$",
"entry",
",",
"7",
")",
",",
"'value.shared'",
")",
";",
"}",
"else",
"if",
"(",
"substr",
"(",
"$",
"entry",
",",
"0",
",",
"8",
")",
"==",
"'/private'",
")",
"{",
"return",
"array",
"(",
"substr",
"(",
"$",
"entry",
",",
"8",
")",
",",
"'value.priv'",
")",
";",
"}",
"// @TODO: log error",
"}"
] |
Converts the METADATA extension entry name into the correct
entry-attrib names for older ANNOTATEMORE version.
@param string $entry Entry name
@return array Entry-attribute list, NULL if not supported (?)
|
[
"Converts",
"the",
"METADATA",
"extension",
"entry",
"name",
"into",
"the",
"correct",
"entry",
"-",
"attrib",
"names",
"for",
"older",
"ANNOTATEMORE",
"version",
"."
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L4050-L4060
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.set_caching
|
public function set_caching($type)
{
if ($type) {
$this->caching = $type;
}
else {
if ($this->cache) {
$this->cache->close();
}
$this->cache = null;
$this->caching = false;
}
}
|
php
|
public function set_caching($type)
{
if ($type) {
$this->caching = $type;
}
else {
if ($this->cache) {
$this->cache->close();
}
$this->cache = null;
$this->caching = false;
}
}
|
[
"public",
"function",
"set_caching",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"type",
")",
"{",
"$",
"this",
"->",
"caching",
"=",
"$",
"type",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"cache",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"close",
"(",
")",
";",
"}",
"$",
"this",
"->",
"cache",
"=",
"null",
";",
"$",
"this",
"->",
"caching",
"=",
"false",
";",
"}",
"}"
] |
Enable or disable indexes caching
@param string $type Cache type (@see rcube::get_cache)
|
[
"Enable",
"or",
"disable",
"indexes",
"caching"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L4072-L4084
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.get_cache_engine
|
protected function get_cache_engine()
{
if ($this->caching && !$this->cache) {
$rcube = rcube::get_instance();
$ttl = $rcube->config->get('imap_cache_ttl', '10d');
$this->cache = $rcube->get_cache('IMAP', $this->caching, $ttl);
}
return $this->cache;
}
|
php
|
protected function get_cache_engine()
{
if ($this->caching && !$this->cache) {
$rcube = rcube::get_instance();
$ttl = $rcube->config->get('imap_cache_ttl', '10d');
$this->cache = $rcube->get_cache('IMAP', $this->caching, $ttl);
}
return $this->cache;
}
|
[
"protected",
"function",
"get_cache_engine",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"caching",
"&&",
"!",
"$",
"this",
"->",
"cache",
")",
"{",
"$",
"rcube",
"=",
"rcube",
"::",
"get_instance",
"(",
")",
";",
"$",
"ttl",
"=",
"$",
"rcube",
"->",
"config",
"->",
"get",
"(",
"'imap_cache_ttl'",
",",
"'10d'",
")",
";",
"$",
"this",
"->",
"cache",
"=",
"$",
"rcube",
"->",
"get_cache",
"(",
"'IMAP'",
",",
"$",
"this",
"->",
"caching",
",",
"$",
"ttl",
")",
";",
"}",
"return",
"$",
"this",
"->",
"cache",
";",
"}"
] |
Getter for IMAP cache object
|
[
"Getter",
"for",
"IMAP",
"cache",
"object"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L4089-L4098
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.set_messages_caching
|
public function set_messages_caching($set, $mode = null)
{
if ($set) {
$this->messages_caching = true;
if ($mode && ($cache = $this->get_mcache_engine())) {
$cache->set_mode($mode);
}
}
else {
if ($this->mcache) {
$this->mcache->close();
}
$this->mcache = null;
$this->messages_caching = false;
}
}
|
php
|
public function set_messages_caching($set, $mode = null)
{
if ($set) {
$this->messages_caching = true;
if ($mode && ($cache = $this->get_mcache_engine())) {
$cache->set_mode($mode);
}
}
else {
if ($this->mcache) {
$this->mcache->close();
}
$this->mcache = null;
$this->messages_caching = false;
}
}
|
[
"public",
"function",
"set_messages_caching",
"(",
"$",
"set",
",",
"$",
"mode",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"set",
")",
"{",
"$",
"this",
"->",
"messages_caching",
"=",
"true",
";",
"if",
"(",
"$",
"mode",
"&&",
"(",
"$",
"cache",
"=",
"$",
"this",
"->",
"get_mcache_engine",
"(",
")",
")",
")",
"{",
"$",
"cache",
"->",
"set_mode",
"(",
"$",
"mode",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"mcache",
")",
"{",
"$",
"this",
"->",
"mcache",
"->",
"close",
"(",
")",
";",
"}",
"$",
"this",
"->",
"mcache",
"=",
"null",
";",
"$",
"this",
"->",
"messages_caching",
"=",
"false",
";",
"}",
"}"
] |
Enable or disable messages caching
@param boolean $set Flag
@param int $mode Cache mode
|
[
"Enable",
"or",
"disable",
"messages",
"caching"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L4152-L4168
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.get_mcache_engine
|
protected function get_mcache_engine()
{
if ($this->messages_caching && !$this->mcache) {
$rcube = rcube::get_instance();
if (($dbh = $rcube->get_dbh()) && ($userid = $rcube->get_user_id())) {
$ttl = $rcube->config->get('messages_cache_ttl', '10d');
$threshold = $rcube->config->get('messages_cache_threshold', 50);
$this->mcache = new rcube_imap_cache(
$dbh, $this, $userid, $this->options['skip_deleted'], $ttl, $threshold);
}
}
return $this->mcache;
}
|
php
|
protected function get_mcache_engine()
{
if ($this->messages_caching && !$this->mcache) {
$rcube = rcube::get_instance();
if (($dbh = $rcube->get_dbh()) && ($userid = $rcube->get_user_id())) {
$ttl = $rcube->config->get('messages_cache_ttl', '10d');
$threshold = $rcube->config->get('messages_cache_threshold', 50);
$this->mcache = new rcube_imap_cache(
$dbh, $this, $userid, $this->options['skip_deleted'], $ttl, $threshold);
}
}
return $this->mcache;
}
|
[
"protected",
"function",
"get_mcache_engine",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"messages_caching",
"&&",
"!",
"$",
"this",
"->",
"mcache",
")",
"{",
"$",
"rcube",
"=",
"rcube",
"::",
"get_instance",
"(",
")",
";",
"if",
"(",
"(",
"$",
"dbh",
"=",
"$",
"rcube",
"->",
"get_dbh",
"(",
")",
")",
"&&",
"(",
"$",
"userid",
"=",
"$",
"rcube",
"->",
"get_user_id",
"(",
")",
")",
")",
"{",
"$",
"ttl",
"=",
"$",
"rcube",
"->",
"config",
"->",
"get",
"(",
"'messages_cache_ttl'",
",",
"'10d'",
")",
";",
"$",
"threshold",
"=",
"$",
"rcube",
"->",
"config",
"->",
"get",
"(",
"'messages_cache_threshold'",
",",
"50",
")",
";",
"$",
"this",
"->",
"mcache",
"=",
"new",
"rcube_imap_cache",
"(",
"$",
"dbh",
",",
"$",
"this",
",",
"$",
"userid",
",",
"$",
"this",
"->",
"options",
"[",
"'skip_deleted'",
"]",
",",
"$",
"ttl",
",",
"$",
"threshold",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"mcache",
";",
"}"
] |
Getter for messages cache object
|
[
"Getter",
"for",
"messages",
"cache",
"object"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L4173-L4186
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.clear_message_cache
|
protected function clear_message_cache($folder = null, $uids = null)
{
if ($mcache = $this->get_mcache_engine()) {
$mcache->clear($folder, $uids);
}
}
|
php
|
protected function clear_message_cache($folder = null, $uids = null)
{
if ($mcache = $this->get_mcache_engine()) {
$mcache->clear($folder, $uids);
}
}
|
[
"protected",
"function",
"clear_message_cache",
"(",
"$",
"folder",
"=",
"null",
",",
"$",
"uids",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"mcache",
"=",
"$",
"this",
"->",
"get_mcache_engine",
"(",
")",
")",
"{",
"$",
"mcache",
"->",
"clear",
"(",
"$",
"folder",
",",
"$",
"uids",
")",
";",
"}",
"}"
] |
Clears the messages cache.
@param string $folder Folder name
@param array $uids Optional message UIDs to remove from cache
|
[
"Clears",
"the",
"messages",
"cache",
"."
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L4194-L4199
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.set_sort_order
|
protected function set_sort_order($sort_field, $sort_order)
{
if ($sort_field != null) {
$this->sort_field = asciiwords($sort_field);
}
if ($sort_order != null) {
$this->sort_order = strtoupper($sort_order) == 'DESC' ? 'DESC' : 'ASC';
}
}
|
php
|
protected function set_sort_order($sort_field, $sort_order)
{
if ($sort_field != null) {
$this->sort_field = asciiwords($sort_field);
}
if ($sort_order != null) {
$this->sort_order = strtoupper($sort_order) == 'DESC' ? 'DESC' : 'ASC';
}
}
|
[
"protected",
"function",
"set_sort_order",
"(",
"$",
"sort_field",
",",
"$",
"sort_order",
")",
"{",
"if",
"(",
"$",
"sort_field",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"sort_field",
"=",
"asciiwords",
"(",
"$",
"sort_field",
")",
";",
"}",
"if",
"(",
"$",
"sort_order",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"sort_order",
"=",
"strtoupper",
"(",
"$",
"sort_order",
")",
"==",
"'DESC'",
"?",
"'DESC'",
":",
"'ASC'",
";",
"}",
"}"
] |
Validate the given input and save to local properties
@param string $sort_field Sort column
@param string $sort_order Sort order
|
[
"Validate",
"the",
"given",
"input",
"and",
"save",
"to",
"local",
"properties"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L4220-L4228
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.sort_folder_list
|
public function sort_folder_list($a_folders, $skip_default = false)
{
$specials = array_merge(array('INBOX'), array_values($this->get_special_folders()));
$folders = array();
// convert names to UTF-8
foreach ($a_folders as $folder) {
// for better performance skip encoding conversion
// if the string does not look like UTF7-IMAP
$folders[$folder] = strpos($folder, '&') === false ? $folder : rcube_charset::convert($folder, 'UTF7-IMAP');
}
// sort folders
// asort($folders, SORT_LOCALE_STRING) is not properly sorting case sensitive names
uasort($folders, array($this, 'sort_folder_comparator'));
$folders = array_keys($folders);
if ($skip_default) {
return $folders;
}
// force the type of folder name variable (#1485527)
$folders = array_map('strval', $folders);
$out = array();
// finally we must put special folders on top and rebuild the list
// to move their subfolders where they belong...
$specials = array_unique(array_intersect($specials, $folders));
$folders = array_merge($specials, array_diff($folders, $specials));
$this->sort_folder_specials(null, $folders, $specials, $out);
return $out;
}
|
php
|
public function sort_folder_list($a_folders, $skip_default = false)
{
$specials = array_merge(array('INBOX'), array_values($this->get_special_folders()));
$folders = array();
// convert names to UTF-8
foreach ($a_folders as $folder) {
// for better performance skip encoding conversion
// if the string does not look like UTF7-IMAP
$folders[$folder] = strpos($folder, '&') === false ? $folder : rcube_charset::convert($folder, 'UTF7-IMAP');
}
// sort folders
// asort($folders, SORT_LOCALE_STRING) is not properly sorting case sensitive names
uasort($folders, array($this, 'sort_folder_comparator'));
$folders = array_keys($folders);
if ($skip_default) {
return $folders;
}
// force the type of folder name variable (#1485527)
$folders = array_map('strval', $folders);
$out = array();
// finally we must put special folders on top and rebuild the list
// to move their subfolders where they belong...
$specials = array_unique(array_intersect($specials, $folders));
$folders = array_merge($specials, array_diff($folders, $specials));
$this->sort_folder_specials(null, $folders, $specials, $out);
return $out;
}
|
[
"public",
"function",
"sort_folder_list",
"(",
"$",
"a_folders",
",",
"$",
"skip_default",
"=",
"false",
")",
"{",
"$",
"specials",
"=",
"array_merge",
"(",
"array",
"(",
"'INBOX'",
")",
",",
"array_values",
"(",
"$",
"this",
"->",
"get_special_folders",
"(",
")",
")",
")",
";",
"$",
"folders",
"=",
"array",
"(",
")",
";",
"// convert names to UTF-8",
"foreach",
"(",
"$",
"a_folders",
"as",
"$",
"folder",
")",
"{",
"// for better performance skip encoding conversion",
"// if the string does not look like UTF7-IMAP",
"$",
"folders",
"[",
"$",
"folder",
"]",
"=",
"strpos",
"(",
"$",
"folder",
",",
"'&'",
")",
"===",
"false",
"?",
"$",
"folder",
":",
"rcube_charset",
"::",
"convert",
"(",
"$",
"folder",
",",
"'UTF7-IMAP'",
")",
";",
"}",
"// sort folders",
"// asort($folders, SORT_LOCALE_STRING) is not properly sorting case sensitive names",
"uasort",
"(",
"$",
"folders",
",",
"array",
"(",
"$",
"this",
",",
"'sort_folder_comparator'",
")",
")",
";",
"$",
"folders",
"=",
"array_keys",
"(",
"$",
"folders",
")",
";",
"if",
"(",
"$",
"skip_default",
")",
"{",
"return",
"$",
"folders",
";",
"}",
"// force the type of folder name variable (#1485527)",
"$",
"folders",
"=",
"array_map",
"(",
"'strval'",
",",
"$",
"folders",
")",
";",
"$",
"out",
"=",
"array",
"(",
")",
";",
"// finally we must put special folders on top and rebuild the list",
"// to move their subfolders where they belong...",
"$",
"specials",
"=",
"array_unique",
"(",
"array_intersect",
"(",
"$",
"specials",
",",
"$",
"folders",
")",
")",
";",
"$",
"folders",
"=",
"array_merge",
"(",
"$",
"specials",
",",
"array_diff",
"(",
"$",
"folders",
",",
"$",
"specials",
")",
")",
";",
"$",
"this",
"->",
"sort_folder_specials",
"(",
"null",
",",
"$",
"folders",
",",
"$",
"specials",
",",
"$",
"out",
")",
";",
"return",
"$",
"out",
";",
"}"
] |
Sort folders first by default folders and then in alphabethical order
@param array $a_folders Folders list
@param bool $skip_default Skip default folders handling
@return array Sorted list
|
[
"Sort",
"folders",
"first",
"by",
"default",
"folders",
"and",
"then",
"in",
"alphabethical",
"order"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L4238-L4272
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.sort_folder_specials
|
protected function sort_folder_specials($folder, &$list, &$specials, &$out)
{
foreach ($list as $key => $name) {
if ($folder === null || strpos($name, $folder.$this->delimiter) === 0) {
$out[] = $name;
unset($list[$key]);
if (!empty($specials) && ($found = array_search($name, $specials)) !== false) {
unset($specials[$found]);
$this->sort_folder_specials($name, $list, $specials, $out);
}
}
}
reset($list);
}
|
php
|
protected function sort_folder_specials($folder, &$list, &$specials, &$out)
{
foreach ($list as $key => $name) {
if ($folder === null || strpos($name, $folder.$this->delimiter) === 0) {
$out[] = $name;
unset($list[$key]);
if (!empty($specials) && ($found = array_search($name, $specials)) !== false) {
unset($specials[$found]);
$this->sort_folder_specials($name, $list, $specials, $out);
}
}
}
reset($list);
}
|
[
"protected",
"function",
"sort_folder_specials",
"(",
"$",
"folder",
",",
"&",
"$",
"list",
",",
"&",
"$",
"specials",
",",
"&",
"$",
"out",
")",
"{",
"foreach",
"(",
"$",
"list",
"as",
"$",
"key",
"=>",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"folder",
"===",
"null",
"||",
"strpos",
"(",
"$",
"name",
",",
"$",
"folder",
".",
"$",
"this",
"->",
"delimiter",
")",
"===",
"0",
")",
"{",
"$",
"out",
"[",
"]",
"=",
"$",
"name",
";",
"unset",
"(",
"$",
"list",
"[",
"$",
"key",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"specials",
")",
"&&",
"(",
"$",
"found",
"=",
"array_search",
"(",
"$",
"name",
",",
"$",
"specials",
")",
")",
"!==",
"false",
")",
"{",
"unset",
"(",
"$",
"specials",
"[",
"$",
"found",
"]",
")",
";",
"$",
"this",
"->",
"sort_folder_specials",
"(",
"$",
"name",
",",
"$",
"list",
",",
"$",
"specials",
",",
"$",
"out",
")",
";",
"}",
"}",
"}",
"reset",
"(",
"$",
"list",
")",
";",
"}"
] |
Recursive function to put subfolders of special folders in place
|
[
"Recursive",
"function",
"to",
"put",
"subfolders",
"of",
"special",
"folders",
"in",
"place"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L4277-L4292
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.id2uid
|
public function id2uid($id, $folder = null)
{
if (!strlen($folder)) {
$folder = $this->folder;
}
if (!$this->check_connection()) {
return null;
}
return $this->conn->ID2UID($folder, $id);
}
|
php
|
public function id2uid($id, $folder = null)
{
if (!strlen($folder)) {
$folder = $this->folder;
}
if (!$this->check_connection()) {
return null;
}
return $this->conn->ID2UID($folder, $id);
}
|
[
"public",
"function",
"id2uid",
"(",
"$",
"id",
",",
"$",
"folder",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"strlen",
"(",
"$",
"folder",
")",
")",
"{",
"$",
"folder",
"=",
"$",
"this",
"->",
"folder",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"check_connection",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"conn",
"->",
"ID2UID",
"(",
"$",
"folder",
",",
"$",
"id",
")",
";",
"}"
] |
Find UID of the specified message sequence ID
@param int $id Message (sequence) ID
@param string $folder Folder name
@return int Message UID
|
[
"Find",
"UID",
"of",
"the",
"specified",
"message",
"sequence",
"ID"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L4337-L4348
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_imap.php
|
rcube_imap.clear_messagecount
|
protected function clear_messagecount($folder, $mode = array())
{
$a_folder_cache = $this->get_cache('messagecount');
if (is_array($a_folder_cache[$folder])) {
if (!empty($mode)) {
foreach ((array) $mode as $key) {
unset($a_folder_cache[$folder][$key]);
}
}
else {
unset($a_folder_cache[$folder]);
}
$this->update_cache('messagecount', $a_folder_cache);
}
}
|
php
|
protected function clear_messagecount($folder, $mode = array())
{
$a_folder_cache = $this->get_cache('messagecount');
if (is_array($a_folder_cache[$folder])) {
if (!empty($mode)) {
foreach ((array) $mode as $key) {
unset($a_folder_cache[$folder][$key]);
}
}
else {
unset($a_folder_cache[$folder]);
}
$this->update_cache('messagecount', $a_folder_cache);
}
}
|
[
"protected",
"function",
"clear_messagecount",
"(",
"$",
"folder",
",",
"$",
"mode",
"=",
"array",
"(",
")",
")",
"{",
"$",
"a_folder_cache",
"=",
"$",
"this",
"->",
"get_cache",
"(",
"'messagecount'",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"a_folder_cache",
"[",
"$",
"folder",
"]",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"mode",
")",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"mode",
"as",
"$",
"key",
")",
"{",
"unset",
"(",
"$",
"a_folder_cache",
"[",
"$",
"folder",
"]",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"else",
"{",
"unset",
"(",
"$",
"a_folder_cache",
"[",
"$",
"folder",
"]",
")",
";",
"}",
"$",
"this",
"->",
"update_cache",
"(",
"'messagecount'",
",",
"$",
"a_folder_cache",
")",
";",
"}",
"}"
] |
Remove messagecount of a specific folder from cache
|
[
"Remove",
"messagecount",
"of",
"a",
"specific",
"folder",
"from",
"cache"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap.php#L4409-L4424
|
train
|
netgen/NetgenInformationCollectionBundle
|
bundle/Form/Type/InformationCollectionType.php
|
InformationCollectionType.getLanguageCode
|
protected function getLanguageCode(ContentType $contentType)
{
$contentTypeLanguages = array_keys($contentType->getNames());
foreach ($this->languages as $languageCode) {
if (in_array($languageCode, $contentTypeLanguages, true)) {
return $languageCode;
}
}
return $contentType->mainLanguageCode;
}
|
php
|
protected function getLanguageCode(ContentType $contentType)
{
$contentTypeLanguages = array_keys($contentType->getNames());
foreach ($this->languages as $languageCode) {
if (in_array($languageCode, $contentTypeLanguages, true)) {
return $languageCode;
}
}
return $contentType->mainLanguageCode;
}
|
[
"protected",
"function",
"getLanguageCode",
"(",
"ContentType",
"$",
"contentType",
")",
"{",
"$",
"contentTypeLanguages",
"=",
"array_keys",
"(",
"$",
"contentType",
"->",
"getNames",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"languages",
"as",
"$",
"languageCode",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"languageCode",
",",
"$",
"contentTypeLanguages",
",",
"true",
")",
")",
"{",
"return",
"$",
"languageCode",
";",
"}",
"}",
"return",
"$",
"contentType",
"->",
"mainLanguageCode",
";",
"}"
] |
If ContentType language code is in languages array then use it, else use first available one.
@param ContentType $contentType
@return string
|
[
"If",
"ContentType",
"language",
"code",
"is",
"in",
"languages",
"array",
"then",
"use",
"it",
"else",
"use",
"first",
"available",
"one",
"."
] |
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
|
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Form/Type/InformationCollectionType.php#L106-L117
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_db_pgsql.php
|
rcube_db_pgsql.sequence_name
|
protected function sequence_name($table)
{
// Note: we support only one sequence per table
// Note: The sequence name must be <table_name>_seq
$sequence = $table . '_seq';
// modify sequence name if prefix is configured
if ($prefix = $this->options['table_prefix']) {
return $prefix . $sequence;
}
return $sequence;
}
|
php
|
protected function sequence_name($table)
{
// Note: we support only one sequence per table
// Note: The sequence name must be <table_name>_seq
$sequence = $table . '_seq';
// modify sequence name if prefix is configured
if ($prefix = $this->options['table_prefix']) {
return $prefix . $sequence;
}
return $sequence;
}
|
[
"protected",
"function",
"sequence_name",
"(",
"$",
"table",
")",
"{",
"// Note: we support only one sequence per table",
"// Note: The sequence name must be <table_name>_seq",
"$",
"sequence",
"=",
"$",
"table",
".",
"'_seq'",
";",
"// modify sequence name if prefix is configured",
"if",
"(",
"$",
"prefix",
"=",
"$",
"this",
"->",
"options",
"[",
"'table_prefix'",
"]",
")",
"{",
"return",
"$",
"prefix",
".",
"$",
"sequence",
";",
"}",
"return",
"$",
"sequence",
";",
"}"
] |
Return correct name for a specific database sequence
@param string $table Table name
@return string Translated sequence name
|
[
"Return",
"correct",
"name",
"for",
"a",
"specific",
"database",
"sequence"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_db_pgsql.php#L87-L99
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_storage.php
|
rcube_storage.unset_flag
|
public function unset_flag($uids, $flag, $folder = null)
{
return $this->set_flag($uids, 'UN'.$flag, $folder);
}
|
php
|
public function unset_flag($uids, $flag, $folder = null)
{
return $this->set_flag($uids, 'UN'.$flag, $folder);
}
|
[
"public",
"function",
"unset_flag",
"(",
"$",
"uids",
",",
"$",
"flag",
",",
"$",
"folder",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"set_flag",
"(",
"$",
"uids",
",",
"'UN'",
".",
"$",
"flag",
",",
"$",
"folder",
")",
";",
"}"
] |
Remove message flag for one or several messages
@param mixed $uids Message UIDs as array or comma-separated string, or '*'
@param string $flag Flag to unset: SEEN, DELETED, RECENT, ANSWERED, DRAFT, MDNSENT
@param string $folder Folder name
@return bool Operation status
@see set_flag
|
[
"Remove",
"message",
"flag",
"for",
"one",
"or",
"several",
"messages"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_storage.php#L511-L514
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_storage.php
|
rcube_storage.parse_uids
|
protected function parse_uids($uids)
{
if ($uids === '*' || $uids === '1:*') {
if (empty($this->search_set)) {
$uids = '1:*';
$all = true;
}
// get UIDs from current search set
else {
$uids = join(',', $this->search_set->get());
}
}
else {
if (is_array($uids)) {
$uids = join(',', $uids);
}
else if (strpos($uids, ':')) {
$uids = join(',', rcube_imap_generic::uncompressMessageSet($uids));
}
if (preg_match('/[^0-9,]/', $uids)) {
$uids = '';
}
}
return array($uids, (bool) $all);
}
|
php
|
protected function parse_uids($uids)
{
if ($uids === '*' || $uids === '1:*') {
if (empty($this->search_set)) {
$uids = '1:*';
$all = true;
}
// get UIDs from current search set
else {
$uids = join(',', $this->search_set->get());
}
}
else {
if (is_array($uids)) {
$uids = join(',', $uids);
}
else if (strpos($uids, ':')) {
$uids = join(',', rcube_imap_generic::uncompressMessageSet($uids));
}
if (preg_match('/[^0-9,]/', $uids)) {
$uids = '';
}
}
return array($uids, (bool) $all);
}
|
[
"protected",
"function",
"parse_uids",
"(",
"$",
"uids",
")",
"{",
"if",
"(",
"$",
"uids",
"===",
"'*'",
"||",
"$",
"uids",
"===",
"'1:*'",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"search_set",
")",
")",
"{",
"$",
"uids",
"=",
"'1:*'",
";",
"$",
"all",
"=",
"true",
";",
"}",
"// get UIDs from current search set",
"else",
"{",
"$",
"uids",
"=",
"join",
"(",
"','",
",",
"$",
"this",
"->",
"search_set",
"->",
"get",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"is_array",
"(",
"$",
"uids",
")",
")",
"{",
"$",
"uids",
"=",
"join",
"(",
"','",
",",
"$",
"uids",
")",
";",
"}",
"else",
"if",
"(",
"strpos",
"(",
"$",
"uids",
",",
"':'",
")",
")",
"{",
"$",
"uids",
"=",
"join",
"(",
"','",
",",
"rcube_imap_generic",
"::",
"uncompressMessageSet",
"(",
"$",
"uids",
")",
")",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/[^0-9,]/'",
",",
"$",
"uids",
")",
")",
"{",
"$",
"uids",
"=",
"''",
";",
"}",
"}",
"return",
"array",
"(",
"$",
"uids",
",",
"(",
"bool",
")",
"$",
"all",
")",
";",
"}"
] |
Parse message UIDs input
@param mixed $uids UIDs array or comma-separated list or '*' or '1:*'
@return array Two elements array with UIDs converted to list and ALL flag
|
[
"Parse",
"message",
"UIDs",
"input"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_storage.php#L581-L607
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_storage.php
|
rcube_storage.create_default_folders
|
public function create_default_folders()
{
$rcube = rcube::get_instance();
// create default folders if they do not exist
foreach (self::$folder_types as $type) {
if ($folder = $rcube->config->get($type . '_mbox')) {
if (!$this->folder_exists($folder)) {
$this->create_folder($folder, true, $type);
}
else if (!$this->folder_exists($folder, true)) {
$this->subscribe($folder);
}
}
}
}
|
php
|
public function create_default_folders()
{
$rcube = rcube::get_instance();
// create default folders if they do not exist
foreach (self::$folder_types as $type) {
if ($folder = $rcube->config->get($type . '_mbox')) {
if (!$this->folder_exists($folder)) {
$this->create_folder($folder, true, $type);
}
else if (!$this->folder_exists($folder, true)) {
$this->subscribe($folder);
}
}
}
}
|
[
"public",
"function",
"create_default_folders",
"(",
")",
"{",
"$",
"rcube",
"=",
"rcube",
"::",
"get_instance",
"(",
")",
";",
"// create default folders if they do not exist",
"foreach",
"(",
"self",
"::",
"$",
"folder_types",
"as",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"folder",
"=",
"$",
"rcube",
"->",
"config",
"->",
"get",
"(",
"$",
"type",
".",
"'_mbox'",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"folder_exists",
"(",
"$",
"folder",
")",
")",
"{",
"$",
"this",
"->",
"create_folder",
"(",
"$",
"folder",
",",
"true",
",",
"$",
"type",
")",
";",
"}",
"else",
"if",
"(",
"!",
"$",
"this",
"->",
"folder_exists",
"(",
"$",
"folder",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"subscribe",
"(",
"$",
"folder",
")",
";",
"}",
"}",
"}",
"}"
] |
Create all folders specified as default
|
[
"Create",
"all",
"folders",
"specified",
"as",
"default"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_storage.php#L822-L837
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_storage.php
|
rcube_storage.get_special_folders
|
public function get_special_folders($forced = false)
{
// getting config might be expensive, store special folders in memory
if (!isset($this->icache['special-folders'])) {
$rcube = rcube::get_instance();
$this->icache['special-folders'] = array();
foreach (self::$folder_types as $type) {
if ($folder = $rcube->config->get($type . '_mbox')) {
$this->icache['special-folders'][$type] = $folder;
}
}
}
return $this->icache['special-folders'];
}
|
php
|
public function get_special_folders($forced = false)
{
// getting config might be expensive, store special folders in memory
if (!isset($this->icache['special-folders'])) {
$rcube = rcube::get_instance();
$this->icache['special-folders'] = array();
foreach (self::$folder_types as $type) {
if ($folder = $rcube->config->get($type . '_mbox')) {
$this->icache['special-folders'][$type] = $folder;
}
}
}
return $this->icache['special-folders'];
}
|
[
"public",
"function",
"get_special_folders",
"(",
"$",
"forced",
"=",
"false",
")",
"{",
"// getting config might be expensive, store special folders in memory",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"icache",
"[",
"'special-folders'",
"]",
")",
")",
"{",
"$",
"rcube",
"=",
"rcube",
"::",
"get_instance",
"(",
")",
";",
"$",
"this",
"->",
"icache",
"[",
"'special-folders'",
"]",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"$",
"folder_types",
"as",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"folder",
"=",
"$",
"rcube",
"->",
"config",
"->",
"get",
"(",
"$",
"type",
".",
"'_mbox'",
")",
")",
"{",
"$",
"this",
"->",
"icache",
"[",
"'special-folders'",
"]",
"[",
"$",
"type",
"]",
"=",
"$",
"folder",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"icache",
"[",
"'special-folders'",
"]",
";",
"}"
] |
Return configured special folders
|
[
"Return",
"configured",
"special",
"folders"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_storage.php#L850-L865
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_result_index.php
|
rcube_result_index.max
|
public function max()
{
if (!isset($this->meta['max'])) {
$this->meta['max'] = (int) @max($this->get());
}
return $this->meta['max'];
}
|
php
|
public function max()
{
if (!isset($this->meta['max'])) {
$this->meta['max'] = (int) @max($this->get());
}
return $this->meta['max'];
}
|
[
"public",
"function",
"max",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"meta",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"meta",
"[",
"'max'",
"]",
"=",
"(",
"int",
")",
"@",
"max",
"(",
"$",
"this",
"->",
"get",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"meta",
"[",
"'max'",
"]",
";",
"}"
] |
Returns maximal message identifier in the result
@return int Maximal message identifier
|
[
"Returns",
"maximal",
"message",
"identifier",
"in",
"the",
"result"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_result_index.php#L187-L194
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_result_index.php
|
rcube_result_index.min
|
public function min()
{
if (!isset($this->meta['min'])) {
$this->meta['min'] = (int) @min($this->get());
}
return $this->meta['min'];
}
|
php
|
public function min()
{
if (!isset($this->meta['min'])) {
$this->meta['min'] = (int) @min($this->get());
}
return $this->meta['min'];
}
|
[
"public",
"function",
"min",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"meta",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"meta",
"[",
"'min'",
"]",
"=",
"(",
"int",
")",
"@",
"min",
"(",
"$",
"this",
"->",
"get",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"meta",
"[",
"'min'",
"]",
";",
"}"
] |
Returns minimal message identifier in the result
@return int Minimal message identifier
|
[
"Returns",
"minimal",
"message",
"identifier",
"in",
"the",
"result"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_result_index.php#L201-L208
|
train
|
i-MSCP/roundcube
|
roundcubemail/program/lib/Roundcube/rcube_result_index.php
|
rcube_result_index.length
|
protected function length()
{
if (!isset($this->meta['length'])) {
$this->meta['length'] = strlen($this->raw_data);
}
return $this->meta['length'];
}
|
php
|
protected function length()
{
if (!isset($this->meta['length'])) {
$this->meta['length'] = strlen($this->raw_data);
}
return $this->meta['length'];
}
|
[
"protected",
"function",
"length",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"meta",
"[",
"'length'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"meta",
"[",
"'length'",
"]",
"=",
"strlen",
"(",
"$",
"this",
"->",
"raw_data",
")",
";",
"}",
"return",
"$",
"this",
"->",
"meta",
"[",
"'length'",
"]",
";",
"}"
] |
Returns length of internal data representation
@return int Data length
|
[
"Returns",
"length",
"of",
"internal",
"data",
"representation"
] |
141965e74cf301575198abc6bf12f207aacaa6c3
|
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_result_index.php#L411-L418
|
train
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.