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/program/lib/Roundcube/rcube_vcard.php
rcube_vcard.set_raw
public function set_raw($tag, $value, $append = false) { $index = $append && isset($this->raw[$tag]) ? count($this->raw[$tag]) : 0; $this->raw[$tag][$index] = (array)$value; }
php
public function set_raw($tag, $value, $append = false) { $index = $append && isset($this->raw[$tag]) ? count($this->raw[$tag]) : 0; $this->raw[$tag][$index] = (array)$value; }
[ "public", "function", "set_raw", "(", "$", "tag", ",", "$", "value", ",", "$", "append", "=", "false", ")", "{", "$", "index", "=", "$", "append", "&&", "isset", "(", "$", "this", "->", "raw", "[", "$", "tag", "]", ")", "?", "count", "(", "$", ...
Setter for individual vcard properties @param string VCard tag name @param array Value-set of this vcard property @param boolean Set to true if the value-set should be appended instead of replacing any existing value-set
[ "Setter", "for", "individual", "vcard", "properties" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_vcard.php#L406-L410
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_vcard.php
rcube_vcard.extend_fieldmap
public function extend_fieldmap($map) { if (is_array($map)) { self::$fieldmap = array_merge($map, self::$fieldmap); } }
php
public function extend_fieldmap($map) { if (is_array($map)) { self::$fieldmap = array_merge($map, self::$fieldmap); } }
[ "public", "function", "extend_fieldmap", "(", "$", "map", ")", "{", "if", "(", "is_array", "(", "$", "map", ")", ")", "{", "self", "::", "$", "fieldmap", "=", "array_merge", "(", "$", "map", ",", "self", "::", "$", "fieldmap", ")", ";", "}", "}" ]
Extends fieldmap definition
[ "Extends", "fieldmap", "definition" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_vcard.php#L458-L463
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_vcard.php
rcube_vcard.import
public static function import($data) { $out = array(); // check if charsets are specified (usually vcard version < 3.0 but this is not reliable) if (preg_match('/charset=/i', substr($data, 0, 2048))) { $charset = null; } // detect charset and convert to utf-8 else if (($charset = self::detect_encoding($data)) && $charset != RCUBE_CHARSET) { $data = rcube_charset::convert($data, $charset); $data = preg_replace(array('/^[\xFE\xFF]{2}/', '/^\xEF\xBB\xBF/', '/^\x00+/'), '', $data); // also remove BOM $charset = RCUBE_CHARSET; } $vcard_block = ''; $in_vcard_block = false; foreach (preg_split("/[\r\n]+/", $data) as $line) { if ($in_vcard_block && !empty($line)) { $vcard_block .= $line . "\n"; } $line = trim($line); if (preg_match('/^END:VCARD$/i', $line)) { // parse vcard $obj = new rcube_vcard($vcard_block, $charset, true, self::$fieldmap); // FN and N is required by vCard format (RFC 2426) // on import we can be less restrictive, let's addressbook decide if (!empty($obj->displayname) || !empty($obj->surname) || !empty($obj->firstname) || !empty($obj->email)) { $out[] = $obj; } $in_vcard_block = false; } else if (preg_match('/^BEGIN:VCARD$/i', $line)) { $vcard_block = $line . "\n"; $in_vcard_block = true; } } return $out; }
php
public static function import($data) { $out = array(); // check if charsets are specified (usually vcard version < 3.0 but this is not reliable) if (preg_match('/charset=/i', substr($data, 0, 2048))) { $charset = null; } // detect charset and convert to utf-8 else if (($charset = self::detect_encoding($data)) && $charset != RCUBE_CHARSET) { $data = rcube_charset::convert($data, $charset); $data = preg_replace(array('/^[\xFE\xFF]{2}/', '/^\xEF\xBB\xBF/', '/^\x00+/'), '', $data); // also remove BOM $charset = RCUBE_CHARSET; } $vcard_block = ''; $in_vcard_block = false; foreach (preg_split("/[\r\n]+/", $data) as $line) { if ($in_vcard_block && !empty($line)) { $vcard_block .= $line . "\n"; } $line = trim($line); if (preg_match('/^END:VCARD$/i', $line)) { // parse vcard $obj = new rcube_vcard($vcard_block, $charset, true, self::$fieldmap); // FN and N is required by vCard format (RFC 2426) // on import we can be less restrictive, let's addressbook decide if (!empty($obj->displayname) || !empty($obj->surname) || !empty($obj->firstname) || !empty($obj->email)) { $out[] = $obj; } $in_vcard_block = false; } else if (preg_match('/^BEGIN:VCARD$/i', $line)) { $vcard_block = $line . "\n"; $in_vcard_block = true; } } return $out; }
[ "public", "static", "function", "import", "(", "$", "data", ")", "{", "$", "out", "=", "array", "(", ")", ";", "// check if charsets are specified (usually vcard version < 3.0 but this is not reliable)", "if", "(", "preg_match", "(", "'/charset=/i'", ",", "substr", "(...
Factory method to import a vcard file @param string vCard file content @return array List of rcube_vcard objects
[ "Factory", "method", "to", "import", "a", "vcard", "file" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_vcard.php#L472-L515
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_vcard.php
rcube_vcard.cleanup
public static function cleanup($vcard) { // convert Apple X-ABRELATEDNAMES into X-* fields for better compatibility $vcard = preg_replace_callback( '/item(\d+)\.(X-ABRELATEDNAMES)([^:]*?):(.*?)item\1.X-ABLabel:(?:_\$!<)?([\w() -]*)(?:>!\$_)?./s', array('self', 'x_abrelatednames_callback'), $vcard); // Cleanup $vcard = preg_replace(array( // convert special types (like Skype) to normal type='skype' classes with this simple regex ;) '/item(\d+)\.(TEL|EMAIL|URL)([^:]*?):(.*?)item\1.X-ABLabel:(?:_\$!<)?([\w() -]*)(?:>!\$_)?./si', '/^item\d*\.X-AB.*$/mi', // remove cruft like item1.X-AB* '/^item\d*\./mi', // remove item1.ADR instead of ADR '/\n+/', // remove empty lines '/^(N:[^;\R]*)$/m', // if N doesn't have any semicolons, add some ), array( '\2;type=\5\3:\4', '', '', "\n", '\1;;;;', ), $vcard); // convert X-WAB-GENDER to X-GENDER if (preg_match('/X-WAB-GENDER:(\d)/', $vcard, $matches)) { $value = $matches[1] == '2' ? 'male' : 'female'; $vcard = preg_replace('/X-WAB-GENDER:\d/', 'X-GENDER:' . $value, $vcard); } return $vcard; }
php
public static function cleanup($vcard) { // convert Apple X-ABRELATEDNAMES into X-* fields for better compatibility $vcard = preg_replace_callback( '/item(\d+)\.(X-ABRELATEDNAMES)([^:]*?):(.*?)item\1.X-ABLabel:(?:_\$!<)?([\w() -]*)(?:>!\$_)?./s', array('self', 'x_abrelatednames_callback'), $vcard); // Cleanup $vcard = preg_replace(array( // convert special types (like Skype) to normal type='skype' classes with this simple regex ;) '/item(\d+)\.(TEL|EMAIL|URL)([^:]*?):(.*?)item\1.X-ABLabel:(?:_\$!<)?([\w() -]*)(?:>!\$_)?./si', '/^item\d*\.X-AB.*$/mi', // remove cruft like item1.X-AB* '/^item\d*\./mi', // remove item1.ADR instead of ADR '/\n+/', // remove empty lines '/^(N:[^;\R]*)$/m', // if N doesn't have any semicolons, add some ), array( '\2;type=\5\3:\4', '', '', "\n", '\1;;;;', ), $vcard); // convert X-WAB-GENDER to X-GENDER if (preg_match('/X-WAB-GENDER:(\d)/', $vcard, $matches)) { $value = $matches[1] == '2' ? 'male' : 'female'; $vcard = preg_replace('/X-WAB-GENDER:\d/', 'X-GENDER:' . $value, $vcard); } return $vcard; }
[ "public", "static", "function", "cleanup", "(", "$", "vcard", ")", "{", "// convert Apple X-ABRELATEDNAMES into X-* fields for better compatibility", "$", "vcard", "=", "preg_replace_callback", "(", "'/item(\\d+)\\.(X-ABRELATEDNAMES)([^:]*?):(.*?)item\\1.X-ABLabel:(?:_\\$!<)?([\\w() -]...
Normalize vcard data for better parsing @param string vCard block @return string Cleaned vcard block
[ "Normalize", "vcard", "data", "for", "better", "parsing" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_vcard.php#L524-L556
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_vcard.php
rcube_vcard.decode_value
private static function decode_value($value, $encoding) { switch (strtolower($encoding)) { case 'quoted-printable': self::$values_decoded = true; return quoted_printable_decode($value); case 'base64': case 'b': self::$values_decoded = true; return base64_decode($value); default: return $value; } }
php
private static function decode_value($value, $encoding) { switch (strtolower($encoding)) { case 'quoted-printable': self::$values_decoded = true; return quoted_printable_decode($value); case 'base64': case 'b': self::$values_decoded = true; return base64_decode($value); default: return $value; } }
[ "private", "static", "function", "decode_value", "(", "$", "value", ",", "$", "encoding", ")", "{", "switch", "(", "strtolower", "(", "$", "encoding", ")", ")", "{", "case", "'quoted-printable'", ":", "self", "::", "$", "values_decoded", "=", "true", ";", ...
Decode a given string with the encoding rule from ENCODING attributes @param string String to decode @param string Encoding type (quoted-printable and base64 supported) @return string Decoded 8bit value
[ "Decode", "a", "given", "string", "with", "the", "encoding", "rule", "from", "ENCODING", "attributes" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_vcard.php#L696-L711
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_vcard.php
rcube_vcard.vcard_quote
public static function vcard_quote($s, $sep = ';') { if (is_array($s)) { foreach ($s as $part) { $r[] = self::vcard_quote($part, $sep); } return(implode($sep, (array)$r)); } return strtr($s, array('\\' => '\\\\', "\r" => '', "\n" => '\n', $sep => '\\'.$sep)); }
php
public static function vcard_quote($s, $sep = ';') { if (is_array($s)) { foreach ($s as $part) { $r[] = self::vcard_quote($part, $sep); } return(implode($sep, (array)$r)); } return strtr($s, array('\\' => '\\\\', "\r" => '', "\n" => '\n', $sep => '\\'.$sep)); }
[ "public", "static", "function", "vcard_quote", "(", "$", "s", ",", "$", "sep", "=", "';'", ")", "{", "if", "(", "is_array", "(", "$", "s", ")", ")", "{", "foreach", "(", "$", "s", "as", "$", "part", ")", "{", "$", "r", "[", "]", "=", "self", ...
Join indexed data array to a vcard quoted string @param array Field data @param string Separator @return string Joined and quoted string
[ "Join", "indexed", "data", "array", "to", "a", "vcard", "quoted", "string" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_vcard.php#L787-L797
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_vcard.php
rcube_vcard.vcard_unquote
private static function vcard_unquote($s, $sep = ';') { // break string into parts separated by $sep if (!empty($sep)) { // Handle properly backslash escaping (#1488896) $rep1 = array("\\\\" => "\010", "\\$sep" => "\007"); $rep2 = array("\007" => "\\$sep", "\010" => "\\\\"); if (count($parts = explode($sep, strtr($s, $rep1))) > 1) { foreach ($parts as $s) { $result[] = self::vcard_unquote(strtr($s, $rep2)); } return $result; } $s = trim(strtr($s, $rep2)); } // some implementations (GMail) use non-standard backslash before colon (#1489085) // we will handle properly any backslashed character - removing dummy backslahes // return strtr($s, array("\r" => '', '\\\\' => '\\', '\n' => "\n", '\N' => "\n", '\,' => ',', '\;' => ';')); $s = str_replace("\r", '', $s); $pos = 0; while (($pos = strpos($s, '\\', $pos)) !== false) { $next = substr($s, $pos + 1, 1); if ($next == 'n' || $next == 'N') { $s = substr_replace($s, "\n", $pos, 2); } else { $s = substr_replace($s, '', $pos, 1); } $pos += 1; } return $s; }
php
private static function vcard_unquote($s, $sep = ';') { // break string into parts separated by $sep if (!empty($sep)) { // Handle properly backslash escaping (#1488896) $rep1 = array("\\\\" => "\010", "\\$sep" => "\007"); $rep2 = array("\007" => "\\$sep", "\010" => "\\\\"); if (count($parts = explode($sep, strtr($s, $rep1))) > 1) { foreach ($parts as $s) { $result[] = self::vcard_unquote(strtr($s, $rep2)); } return $result; } $s = trim(strtr($s, $rep2)); } // some implementations (GMail) use non-standard backslash before colon (#1489085) // we will handle properly any backslashed character - removing dummy backslahes // return strtr($s, array("\r" => '', '\\\\' => '\\', '\n' => "\n", '\N' => "\n", '\,' => ',', '\;' => ';')); $s = str_replace("\r", '', $s); $pos = 0; while (($pos = strpos($s, '\\', $pos)) !== false) { $next = substr($s, $pos + 1, 1); if ($next == 'n' || $next == 'N') { $s = substr_replace($s, "\n", $pos, 2); } else { $s = substr_replace($s, '', $pos, 1); } $pos += 1; } return $s; }
[ "private", "static", "function", "vcard_unquote", "(", "$", "s", ",", "$", "sep", "=", "';'", ")", "{", "// break string into parts separated by $sep", "if", "(", "!", "empty", "(", "$", "sep", ")", ")", "{", "// Handle properly backslash escaping (#1488896)", "$"...
Split quoted string @param string vCard string to split @param string Separator char/string @return array List with splited values
[ "Split", "quoted", "string" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_vcard.php#L807-L845
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_vcard.php
rcube_vcard.array_filter
private static function array_filter($arr, $values, $inverse = false) { if (!is_array($values)) { $values = explode(',', $values); } $result = array(); $keep = array_flip((array)$values); foreach ($arr as $key => $val) { if ($inverse != isset($keep[strtolower($val)])) { $result[$key] = $val; } } return $result; }
php
private static function array_filter($arr, $values, $inverse = false) { if (!is_array($values)) { $values = explode(',', $values); } $result = array(); $keep = array_flip((array)$values); foreach ($arr as $key => $val) { if ($inverse != isset($keep[strtolower($val)])) { $result[$key] = $val; } } return $result; }
[ "private", "static", "function", "array_filter", "(", "$", "arr", ",", "$", "values", ",", "$", "inverse", "=", "false", ")", "{", "if", "(", "!", "is_array", "(", "$", "values", ")", ")", "{", "$", "values", "=", "explode", "(", "','", ",", "$", ...
Extract array values by a filter @param array Array to filter @param keys Array or comma separated list of values to keep @param boolean Invert key selection: remove the listed values @return array The filtered array
[ "Extract", "array", "values", "by", "a", "filter" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_vcard.php#L875-L891
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.init
protected function init($mode = 0) { // initialize syslog if ($this->config->get('log_driver') == 'syslog') { $syslog_id = $this->config->get('syslog_id', 'roundcube'); $syslog_facility = $this->config->get('syslog_facility', LOG_USER); openlog($syslog_id, LOG_ODELAY, $syslog_facility); } // connect to database if ($mode & self::INIT_WITH_DB) { $this->get_dbh(); } // create plugin API and load plugins if ($mode & self::INIT_WITH_PLUGINS) { $this->plugins = rcube_plugin_api::get_instance(); } }
php
protected function init($mode = 0) { // initialize syslog if ($this->config->get('log_driver') == 'syslog') { $syslog_id = $this->config->get('syslog_id', 'roundcube'); $syslog_facility = $this->config->get('syslog_facility', LOG_USER); openlog($syslog_id, LOG_ODELAY, $syslog_facility); } // connect to database if ($mode & self::INIT_WITH_DB) { $this->get_dbh(); } // create plugin API and load plugins if ($mode & self::INIT_WITH_PLUGINS) { $this->plugins = rcube_plugin_api::get_instance(); } }
[ "protected", "function", "init", "(", "$", "mode", "=", "0", ")", "{", "// initialize syslog", "if", "(", "$", "this", "->", "config", "->", "get", "(", "'log_driver'", ")", "==", "'syslog'", ")", "{", "$", "syslog_id", "=", "$", "this", "->", "config"...
Initial startup function
[ "Initial", "startup", "function" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L157-L175
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.get_dbh
public function get_dbh() { if (!$this->db) { $this->db = rcube_db::factory( $this->config->get('db_dsnw'), $this->config->get('db_dsnr'), $this->config->get('db_persistent') ); $this->db->set_debug((bool)$this->config->get('sql_debug')); } return $this->db; }
php
public function get_dbh() { if (!$this->db) { $this->db = rcube_db::factory( $this->config->get('db_dsnw'), $this->config->get('db_dsnr'), $this->config->get('db_persistent') ); $this->db->set_debug((bool)$this->config->get('sql_debug')); } return $this->db; }
[ "public", "function", "get_dbh", "(", ")", "{", "if", "(", "!", "$", "this", "->", "db", ")", "{", "$", "this", "->", "db", "=", "rcube_db", "::", "factory", "(", "$", "this", "->", "config", "->", "get", "(", "'db_dsnw'", ")", ",", "$", "this", ...
Get the current database connection @return rcube_db Database object
[ "Get", "the", "current", "database", "connection" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L182-L195
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.memcache_failure
public function memcache_failure($host, $port) { static $seen = array(); // only report once if (!$seen["$host:$port"]++) { $this->mc_available--; self::raise_error(array( 'code' => 604, 'type' => 'db', 'line' => __LINE__, 'file' => __FILE__, 'message' => "Memcache failure on host $host:$port"), true, false); } }
php
public function memcache_failure($host, $port) { static $seen = array(); // only report once if (!$seen["$host:$port"]++) { $this->mc_available--; self::raise_error(array( 'code' => 604, 'type' => 'db', 'line' => __LINE__, 'file' => __FILE__, 'message' => "Memcache failure on host $host:$port"), true, false); } }
[ "public", "function", "memcache_failure", "(", "$", "host", ",", "$", "port", ")", "{", "static", "$", "seen", "=", "array", "(", ")", ";", "// only report once", "if", "(", "!", "$", "seen", "[", "\"$host:$port\"", "]", "++", ")", "{", "$", "this", ...
Callback for memcache failure
[ "Callback", "for", "memcache", "failure" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L256-L269
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.get_cache
public function get_cache($name, $type='db', $ttl=0, $packed=true) { if (!isset($this->caches[$name]) && ($userid = $this->get_user_id())) { $this->caches[$name] = new rcube_cache($type, $userid, $name, $ttl, $packed); } return $this->caches[$name]; }
php
public function get_cache($name, $type='db', $ttl=0, $packed=true) { if (!isset($this->caches[$name]) && ($userid = $this->get_user_id())) { $this->caches[$name] = new rcube_cache($type, $userid, $name, $ttl, $packed); } return $this->caches[$name]; }
[ "public", "function", "get_cache", "(", "$", "name", ",", "$", "type", "=", "'db'", ",", "$", "ttl", "=", "0", ",", "$", "packed", "=", "true", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "caches", "[", "$", "name", "]", ")", "...
Initialize and get cache object @param string $name Cache identifier @param string $type Cache type ('db', 'apc' or 'memcache') @param string $ttl Expiration time for cache items @param bool $packed Enables/disables data serialization @return rcube_cache Cache object
[ "Initialize", "and", "get", "cache", "object" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L281-L288
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.get_cache_shared
public function get_cache_shared($name, $packed=true) { $shared_name = "shared_$name"; if (!array_key_exists($shared_name, $this->caches)) { $opt = strtolower($name) . '_cache'; $type = $this->config->get($opt); $ttl = $this->config->get($opt . '_ttl'); if (!$type) { // cache is disabled return $this->caches[$shared_name] = null; } if ($ttl === null) { $ttl = $this->config->get('shared_cache_ttl', '10d'); } $this->caches[$shared_name] = new rcube_cache_shared($type, $name, $ttl, $packed); } return $this->caches[$shared_name]; }
php
public function get_cache_shared($name, $packed=true) { $shared_name = "shared_$name"; if (!array_key_exists($shared_name, $this->caches)) { $opt = strtolower($name) . '_cache'; $type = $this->config->get($opt); $ttl = $this->config->get($opt . '_ttl'); if (!$type) { // cache is disabled return $this->caches[$shared_name] = null; } if ($ttl === null) { $ttl = $this->config->get('shared_cache_ttl', '10d'); } $this->caches[$shared_name] = new rcube_cache_shared($type, $name, $ttl, $packed); } return $this->caches[$shared_name]; }
[ "public", "function", "get_cache_shared", "(", "$", "name", ",", "$", "packed", "=", "true", ")", "{", "$", "shared_name", "=", "\"shared_$name\"", ";", "if", "(", "!", "array_key_exists", "(", "$", "shared_name", ",", "$", "this", "->", "caches", ")", "...
Initialize and get shared cache object @param string $name Cache identifier @param bool $packed Enables/disables data serialization @return rcube_cache_shared Cache object
[ "Initialize", "and", "get", "shared", "cache", "object" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L298-L320
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.smtp_init
public function smtp_init($connect = false) { $this->smtp = new rcube_smtp(); if ($connect) { $this->smtp->connect(); } }
php
public function smtp_init($connect = false) { $this->smtp = new rcube_smtp(); if ($connect) { $this->smtp->connect(); } }
[ "public", "function", "smtp_init", "(", "$", "connect", "=", "false", ")", "{", "$", "this", "->", "smtp", "=", "new", "rcube_smtp", "(", ")", ";", "if", "(", "$", "connect", ")", "{", "$", "this", "->", "smtp", "->", "connect", "(", ")", ";", "}...
Create SMTP object and connect to server @param boolean $connect True if connection should be established
[ "Create", "SMTP", "object", "and", "connect", "to", "server" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L327-L334
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.storage_init
public function storage_init() { // already initialized if (is_object($this->storage)) { return; } $driver = $this->config->get('storage_driver', 'imap'); $driver_class = "rcube_{$driver}"; if (!class_exists($driver_class)) { self::raise_error(array( 'code' => 700, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Storage driver class ($driver) not found!"), true, true); } // Initialize storage object $this->storage = new $driver_class; // for backward compat. (deprecated, will be removed) $this->imap = $this->storage; // set class options $options = array( 'auth_type' => $this->config->get("{$driver}_auth_type", 'check'), 'auth_cid' => $this->config->get("{$driver}_auth_cid"), 'auth_pw' => $this->config->get("{$driver}_auth_pw"), 'debug' => (bool) $this->config->get("{$driver}_debug"), 'force_caps' => (bool) $this->config->get("{$driver}_force_caps"), 'disabled_caps' => $this->config->get("{$driver}_disabled_caps"), 'socket_options' => $this->config->get("{$driver}_conn_options"), 'timeout' => (int) $this->config->get("{$driver}_timeout"), 'skip_deleted' => (bool) $this->config->get('skip_deleted'), 'driver' => $driver, ); if (!empty($_SESSION['storage_host'])) { $options['language'] = $_SESSION['language']; $options['host'] = $_SESSION['storage_host']; $options['user'] = $_SESSION['username']; $options['port'] = $_SESSION['storage_port']; $options['ssl'] = $_SESSION['storage_ssl']; $options['password'] = $this->decrypt($_SESSION['password']); $_SESSION[$driver.'_host'] = $_SESSION['storage_host']; } $options = $this->plugins->exec_hook("storage_init", $options); // for backward compat. (deprecated, to be removed) $options = $this->plugins->exec_hook("imap_init", $options); $this->storage->set_options($options); $this->set_storage_prop(); // subscribe to 'storage_connected' hook for session logging if ($this->config->get('imap_log_session', false)) { $this->plugins->register_hook('storage_connected', array($this, 'storage_log_session')); } }
php
public function storage_init() { // already initialized if (is_object($this->storage)) { return; } $driver = $this->config->get('storage_driver', 'imap'); $driver_class = "rcube_{$driver}"; if (!class_exists($driver_class)) { self::raise_error(array( 'code' => 700, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Storage driver class ($driver) not found!"), true, true); } // Initialize storage object $this->storage = new $driver_class; // for backward compat. (deprecated, will be removed) $this->imap = $this->storage; // set class options $options = array( 'auth_type' => $this->config->get("{$driver}_auth_type", 'check'), 'auth_cid' => $this->config->get("{$driver}_auth_cid"), 'auth_pw' => $this->config->get("{$driver}_auth_pw"), 'debug' => (bool) $this->config->get("{$driver}_debug"), 'force_caps' => (bool) $this->config->get("{$driver}_force_caps"), 'disabled_caps' => $this->config->get("{$driver}_disabled_caps"), 'socket_options' => $this->config->get("{$driver}_conn_options"), 'timeout' => (int) $this->config->get("{$driver}_timeout"), 'skip_deleted' => (bool) $this->config->get('skip_deleted'), 'driver' => $driver, ); if (!empty($_SESSION['storage_host'])) { $options['language'] = $_SESSION['language']; $options['host'] = $_SESSION['storage_host']; $options['user'] = $_SESSION['username']; $options['port'] = $_SESSION['storage_port']; $options['ssl'] = $_SESSION['storage_ssl']; $options['password'] = $this->decrypt($_SESSION['password']); $_SESSION[$driver.'_host'] = $_SESSION['storage_host']; } $options = $this->plugins->exec_hook("storage_init", $options); // for backward compat. (deprecated, to be removed) $options = $this->plugins->exec_hook("imap_init", $options); $this->storage->set_options($options); $this->set_storage_prop(); // subscribe to 'storage_connected' hook for session logging if ($this->config->get('imap_log_session', false)) { $this->plugins->register_hook('storage_connected', array($this, 'storage_log_session')); } }
[ "public", "function", "storage_init", "(", ")", "{", "// already initialized", "if", "(", "is_object", "(", "$", "this", "->", "storage", ")", ")", "{", "return", ";", "}", "$", "driver", "=", "$", "this", "->", "config", "->", "get", "(", "'storage_driv...
Initialize storage object
[ "Initialize", "storage", "object" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L354-L414
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.set_storage_prop
protected function set_storage_prop() { $storage = $this->get_storage(); // set pagesize from config $pagesize = $this->config->get('mail_pagesize'); if (!$pagesize) { $pagesize = $this->config->get('pagesize', 50); } $storage->set_pagesize($pagesize); $storage->set_charset($this->config->get('default_charset', RCUBE_CHARSET)); // enable caching of mail data $driver = $this->config->get('storage_driver', 'imap'); $storage_cache = $this->config->get("{$driver}_cache"); $messages_cache = $this->config->get('messages_cache'); // for backward compatybility if ($storage_cache === null && $messages_cache === null && $this->config->get('enable_caching')) { $storage_cache = 'db'; $messages_cache = true; } if ($storage_cache) { $storage->set_caching($storage_cache); } if ($messages_cache) { $storage->set_messages_caching(true); } }
php
protected function set_storage_prop() { $storage = $this->get_storage(); // set pagesize from config $pagesize = $this->config->get('mail_pagesize'); if (!$pagesize) { $pagesize = $this->config->get('pagesize', 50); } $storage->set_pagesize($pagesize); $storage->set_charset($this->config->get('default_charset', RCUBE_CHARSET)); // enable caching of mail data $driver = $this->config->get('storage_driver', 'imap'); $storage_cache = $this->config->get("{$driver}_cache"); $messages_cache = $this->config->get('messages_cache'); // for backward compatybility if ($storage_cache === null && $messages_cache === null && $this->config->get('enable_caching')) { $storage_cache = 'db'; $messages_cache = true; } if ($storage_cache) { $storage->set_caching($storage_cache); } if ($messages_cache) { $storage->set_messages_caching(true); } }
[ "protected", "function", "set_storage_prop", "(", ")", "{", "$", "storage", "=", "$", "this", "->", "get_storage", "(", ")", ";", "// set pagesize from config", "$", "pagesize", "=", "$", "this", "->", "config", "->", "get", "(", "'mail_pagesize'", ")", ";",...
Set storage parameters.
[ "Set", "storage", "parameters", "." ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L419-L448
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.set_special_folders
protected function set_special_folders() { $storage = $this->get_storage(); $folders = $storage->get_special_folders(true); $prefs = array(); // check SPECIAL-USE flags on IMAP folders foreach ($folders as $type => $folder) { $idx = $type . '_mbox'; if ($folder !== $this->config->get($idx)) { $prefs[$idx] = $folder; } } // Some special folders differ, update user preferences if (!empty($prefs) && $this->user) { $this->user->save_prefs($prefs); } // create default folders (on login) if ($this->config->get('create_default_folders')) { $storage->create_default_folders(); } }
php
protected function set_special_folders() { $storage = $this->get_storage(); $folders = $storage->get_special_folders(true); $prefs = array(); // check SPECIAL-USE flags on IMAP folders foreach ($folders as $type => $folder) { $idx = $type . '_mbox'; if ($folder !== $this->config->get($idx)) { $prefs[$idx] = $folder; } } // Some special folders differ, update user preferences if (!empty($prefs) && $this->user) { $this->user->save_prefs($prefs); } // create default folders (on login) if ($this->config->get('create_default_folders')) { $storage->create_default_folders(); } }
[ "protected", "function", "set_special_folders", "(", ")", "{", "$", "storage", "=", "$", "this", "->", "get_storage", "(", ")", ";", "$", "folders", "=", "$", "storage", "->", "get_special_folders", "(", "true", ")", ";", "$", "prefs", "=", "array", "(",...
Set special folders type association. This must be done AFTER connecting to the server!
[ "Set", "special", "folders", "type", "association", ".", "This", "must", "be", "done", "AFTER", "connecting", "to", "the", "server!" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L454-L477
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.gc_temp
public function gc_temp() { $tmp = unslashify($this->config->get('temp_dir')); // expire in 48 hours by default $temp_dir_ttl = $this->config->get('temp_dir_ttl', '48h'); $temp_dir_ttl = get_offset_sec($temp_dir_ttl); if ($temp_dir_ttl < 6*3600) $temp_dir_ttl = 6*3600; // 6 hours sensible lower bound. $expire = time() - $temp_dir_ttl; if ($tmp && ($dir = opendir($tmp))) { while (($fname = readdir($dir)) !== false) { if ($fname[0] == '.') { continue; } if (@filemtime($tmp.'/'.$fname) < $expire) { @unlink($tmp.'/'.$fname); } } closedir($dir); } }
php
public function gc_temp() { $tmp = unslashify($this->config->get('temp_dir')); // expire in 48 hours by default $temp_dir_ttl = $this->config->get('temp_dir_ttl', '48h'); $temp_dir_ttl = get_offset_sec($temp_dir_ttl); if ($temp_dir_ttl < 6*3600) $temp_dir_ttl = 6*3600; // 6 hours sensible lower bound. $expire = time() - $temp_dir_ttl; if ($tmp && ($dir = opendir($tmp))) { while (($fname = readdir($dir)) !== false) { if ($fname[0] == '.') { continue; } if (@filemtime($tmp.'/'.$fname) < $expire) { @unlink($tmp.'/'.$fname); } } closedir($dir); } }
[ "public", "function", "gc_temp", "(", ")", "{", "$", "tmp", "=", "unslashify", "(", "$", "this", "->", "config", "->", "get", "(", "'temp_dir'", ")", ")", ";", "// expire in 48 hours by default", "$", "temp_dir_ttl", "=", "$", "this", "->", "config", "->",...
Garbage collector function for temp files. Remove temp files older than two days
[ "Garbage", "collector", "function", "for", "temp", "files", ".", "Remove", "temp", "files", "older", "than", "two", "days" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L552-L577
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.gc_run
public function gc_run() { $probability = (int) ini_get('session.gc_probability'); $divisor = (int) ini_get('session.gc_divisor'); if ($divisor > 0 && $probability > 0) { $random = mt_rand(1, $divisor); if ($random <= $probability) { $this->gc(); } } }
php
public function gc_run() { $probability = (int) ini_get('session.gc_probability'); $divisor = (int) ini_get('session.gc_divisor'); if ($divisor > 0 && $probability > 0) { $random = mt_rand(1, $divisor); if ($random <= $probability) { $this->gc(); } } }
[ "public", "function", "gc_run", "(", ")", "{", "$", "probability", "=", "(", "int", ")", "ini_get", "(", "'session.gc_probability'", ")", ";", "$", "divisor", "=", "(", "int", ")", "ini_get", "(", "'session.gc_divisor'", ")", ";", "if", "(", "$", "diviso...
Runs garbage collector with probability based on session settings. This is intended for environments without a session.
[ "Runs", "garbage", "collector", "with", "probability", "based", "on", "session", "settings", ".", "This", "is", "intended", "for", "environments", "without", "a", "session", "." ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L584-L595
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.gettext
public function gettext($attrib, $domain = null) { // load localization files if not done yet if (empty($this->texts)) { $this->load_language(); } // extract attributes if (is_string($attrib)) { $attrib = array('name' => $attrib); } $name = (string) $attrib['name']; // attrib contain text values: use them from now if (($setval = $attrib[strtolower($_SESSION['language'])]) || ($setval = $attrib['en_us'])) { $this->texts[$name] = $setval; } // check for text with domain if ($domain && ($text = $this->texts[$domain.'.'.$name])) { } // text does not exist else if (!($text = $this->texts[$name])) { return "[$name]"; } // replace vars in text if (is_array($attrib['vars'])) { foreach ($attrib['vars'] as $var_key => $var_value) { $text = str_replace($var_key[0] != '$' ? '$'.$var_key : $var_key, $var_value, $text); } } // replace \n with real line break $text = strtr($text, array('\n' => "\n")); // case folding if (($attrib['uppercase'] && strtolower($attrib['uppercase']) == 'first') || $attrib['ucfirst']) { $case_mode = MB_CASE_TITLE; } else if ($attrib['uppercase']) { $case_mode = MB_CASE_UPPER; } else if ($attrib['lowercase']) { $case_mode = MB_CASE_LOWER; } if (isset($case_mode)) { $text = mb_convert_case($text, $case_mode); } return $text; }
php
public function gettext($attrib, $domain = null) { // load localization files if not done yet if (empty($this->texts)) { $this->load_language(); } // extract attributes if (is_string($attrib)) { $attrib = array('name' => $attrib); } $name = (string) $attrib['name']; // attrib contain text values: use them from now if (($setval = $attrib[strtolower($_SESSION['language'])]) || ($setval = $attrib['en_us'])) { $this->texts[$name] = $setval; } // check for text with domain if ($domain && ($text = $this->texts[$domain.'.'.$name])) { } // text does not exist else if (!($text = $this->texts[$name])) { return "[$name]"; } // replace vars in text if (is_array($attrib['vars'])) { foreach ($attrib['vars'] as $var_key => $var_value) { $text = str_replace($var_key[0] != '$' ? '$'.$var_key : $var_key, $var_value, $text); } } // replace \n with real line break $text = strtr($text, array('\n' => "\n")); // case folding if (($attrib['uppercase'] && strtolower($attrib['uppercase']) == 'first') || $attrib['ucfirst']) { $case_mode = MB_CASE_TITLE; } else if ($attrib['uppercase']) { $case_mode = MB_CASE_UPPER; } else if ($attrib['lowercase']) { $case_mode = MB_CASE_LOWER; } if (isset($case_mode)) { $text = mb_convert_case($text, $case_mode); } return $text; }
[ "public", "function", "gettext", "(", "$", "attrib", ",", "$", "domain", "=", "null", ")", "{", "// load localization files if not done yet", "if", "(", "empty", "(", "$", "this", "->", "texts", ")", ")", "{", "$", "this", "->", "load_language", "(", ")", ...
Get localized text in the desired language @param mixed $attrib Named parameters array or label name @param string $domain Label domain (plugin) name @return string Localized text
[ "Get", "localized", "text", "in", "the", "desired", "language" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L605-L658
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.text_exists
public function text_exists($name, $domain = null, &$ref_domain = null) { // load localization files if not done yet if (empty($this->texts)) { $this->load_language(); } if (isset($this->texts[$name])) { $ref_domain = ''; return true; } // any of loaded domains (plugins) if ($domain == '*') { foreach ($this->plugins->loaded_plugins() as $domain) { if (isset($this->texts[$domain.'.'.$name])) { $ref_domain = $domain; return true; } } } // specified domain else if ($domain) { $ref_domain = $domain; return isset($this->texts[$domain.'.'.$name]); } return false; }
php
public function text_exists($name, $domain = null, &$ref_domain = null) { // load localization files if not done yet if (empty($this->texts)) { $this->load_language(); } if (isset($this->texts[$name])) { $ref_domain = ''; return true; } // any of loaded domains (plugins) if ($domain == '*') { foreach ($this->plugins->loaded_plugins() as $domain) { if (isset($this->texts[$domain.'.'.$name])) { $ref_domain = $domain; return true; } } } // specified domain else if ($domain) { $ref_domain = $domain; return isset($this->texts[$domain.'.'.$name]); } return false; }
[ "public", "function", "text_exists", "(", "$", "name", ",", "$", "domain", "=", "null", ",", "&", "$", "ref_domain", "=", "null", ")", "{", "// load localization files if not done yet", "if", "(", "empty", "(", "$", "this", "->", "texts", ")", ")", "{", ...
Check if the given text label exists @param string $name Label name @param string $domain Label domain (plugin) name or '*' for all domains @param string $ref_domain Sets domain name if label is found @return boolean True if text exists (either in the current language or in en_US)
[ "Check", "if", "the", "given", "text", "label", "exists" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L669-L697
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.load_language
public function load_language($lang = null, $add = array(), $merge = array()) { $lang = $this->language_prop($lang ?: $_SESSION['language']); // load localized texts if (empty($this->texts) || $lang != $_SESSION['language']) { $this->texts = array(); // handle empty lines after closing PHP tag in localization files ob_start(); // get english labels (these should be complete) @include(RCUBE_LOCALIZATION_DIR . 'en_US/labels.inc'); @include(RCUBE_LOCALIZATION_DIR . 'en_US/messages.inc'); if (is_array($labels)) $this->texts = $labels; if (is_array($messages)) $this->texts = array_merge($this->texts, $messages); // include user language files if ($lang != 'en' && $lang != 'en_US' && is_dir(RCUBE_LOCALIZATION_DIR . $lang)) { include_once(RCUBE_LOCALIZATION_DIR . $lang . '/labels.inc'); include_once(RCUBE_LOCALIZATION_DIR . $lang . '/messages.inc'); if (is_array($labels)) $this->texts = array_merge($this->texts, $labels); if (is_array($messages)) $this->texts = array_merge($this->texts, $messages); } ob_end_clean(); $_SESSION['language'] = $lang; } // append additional texts (from plugin) if (is_array($add) && !empty($add)) { $this->texts += $add; } // merge additional texts (from plugin) if (is_array($merge) && !empty($merge)) { $this->texts = array_merge($this->texts, $merge); } }
php
public function load_language($lang = null, $add = array(), $merge = array()) { $lang = $this->language_prop($lang ?: $_SESSION['language']); // load localized texts if (empty($this->texts) || $lang != $_SESSION['language']) { $this->texts = array(); // handle empty lines after closing PHP tag in localization files ob_start(); // get english labels (these should be complete) @include(RCUBE_LOCALIZATION_DIR . 'en_US/labels.inc'); @include(RCUBE_LOCALIZATION_DIR . 'en_US/messages.inc'); if (is_array($labels)) $this->texts = $labels; if (is_array($messages)) $this->texts = array_merge($this->texts, $messages); // include user language files if ($lang != 'en' && $lang != 'en_US' && is_dir(RCUBE_LOCALIZATION_DIR . $lang)) { include_once(RCUBE_LOCALIZATION_DIR . $lang . '/labels.inc'); include_once(RCUBE_LOCALIZATION_DIR . $lang . '/messages.inc'); if (is_array($labels)) $this->texts = array_merge($this->texts, $labels); if (is_array($messages)) $this->texts = array_merge($this->texts, $messages); } ob_end_clean(); $_SESSION['language'] = $lang; } // append additional texts (from plugin) if (is_array($add) && !empty($add)) { $this->texts += $add; } // merge additional texts (from plugin) if (is_array($merge) && !empty($merge)) { $this->texts = array_merge($this->texts, $merge); } }
[ "public", "function", "load_language", "(", "$", "lang", "=", "null", ",", "$", "add", "=", "array", "(", ")", ",", "$", "merge", "=", "array", "(", ")", ")", "{", "$", "lang", "=", "$", "this", "->", "language_prop", "(", "$", "lang", "?", ":", ...
Load a localization package @param string $lang Language ID @param array $add Additional text labels/messages @param array $merge Additional text labels/messages to merge
[ "Load", "a", "localization", "package" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L706-L751
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.language_prop
protected function language_prop($lang) { static $rcube_languages, $rcube_language_aliases; // user HTTP_ACCEPT_LANGUAGE if no language is specified if (empty($lang) || $lang == 'auto') { $accept_langs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); $lang = $accept_langs[0]; if (preg_match('/^([a-z]+)[_-]([a-z]+)$/i', $lang, $m)) { $lang = $m[1] . '_' . strtoupper($m[2]); } } if (empty($rcube_languages)) { @include(RCUBE_LOCALIZATION_DIR . 'index.inc'); } // check if we have an alias for that language if (!isset($rcube_languages[$lang]) && isset($rcube_language_aliases[$lang])) { $lang = $rcube_language_aliases[$lang]; } // try the first two chars else if (!isset($rcube_languages[$lang])) { $short = substr($lang, 0, 2); // check if we have an alias for the short language code if (!isset($rcube_languages[$short]) && isset($rcube_language_aliases[$short])) { $lang = $rcube_language_aliases[$short]; } // expand 'nn' to 'nn_NN' else if (!isset($rcube_languages[$short])) { $lang = $short.'_'.strtoupper($short); } } if (!isset($rcube_languages[$lang]) || !is_dir(RCUBE_LOCALIZATION_DIR . $lang)) { $lang = 'en_US'; } return $lang; }
php
protected function language_prop($lang) { static $rcube_languages, $rcube_language_aliases; // user HTTP_ACCEPT_LANGUAGE if no language is specified if (empty($lang) || $lang == 'auto') { $accept_langs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); $lang = $accept_langs[0]; if (preg_match('/^([a-z]+)[_-]([a-z]+)$/i', $lang, $m)) { $lang = $m[1] . '_' . strtoupper($m[2]); } } if (empty($rcube_languages)) { @include(RCUBE_LOCALIZATION_DIR . 'index.inc'); } // check if we have an alias for that language if (!isset($rcube_languages[$lang]) && isset($rcube_language_aliases[$lang])) { $lang = $rcube_language_aliases[$lang]; } // try the first two chars else if (!isset($rcube_languages[$lang])) { $short = substr($lang, 0, 2); // check if we have an alias for the short language code if (!isset($rcube_languages[$short]) && isset($rcube_language_aliases[$short])) { $lang = $rcube_language_aliases[$short]; } // expand 'nn' to 'nn_NN' else if (!isset($rcube_languages[$short])) { $lang = $short.'_'.strtoupper($short); } } if (!isset($rcube_languages[$lang]) || !is_dir(RCUBE_LOCALIZATION_DIR . $lang)) { $lang = 'en_US'; } return $lang; }
[ "protected", "function", "language_prop", "(", "$", "lang", ")", "{", "static", "$", "rcube_languages", ",", "$", "rcube_language_aliases", ";", "// user HTTP_ACCEPT_LANGUAGE if no language is specified", "if", "(", "empty", "(", "$", "lang", ")", "||", "$", "lang",...
Check the given string and return a valid language code @param string $lang Language code @return string Valid language code
[ "Check", "the", "given", "string", "and", "return", "a", "valid", "language", "code" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L760-L801
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.get_secure_url_token
public function get_secure_url_token($generate = false) { if ($len = $this->config->get('use_secure_urls')) { if (empty($_SESSION['secure_token']) && $generate) { // generate x characters long token $length = $len > 1 ? $len : 16; $token = rcube_utils::random_bytes($length); $plugin = $this->plugins->exec_hook('secure_token', array('value' => $token, 'length' => $length)); $_SESSION['secure_token'] = $plugin['value']; } return $_SESSION['secure_token']; } return false; }
php
public function get_secure_url_token($generate = false) { if ($len = $this->config->get('use_secure_urls')) { if (empty($_SESSION['secure_token']) && $generate) { // generate x characters long token $length = $len > 1 ? $len : 16; $token = rcube_utils::random_bytes($length); $plugin = $this->plugins->exec_hook('secure_token', array('value' => $token, 'length' => $length)); $_SESSION['secure_token'] = $plugin['value']; } return $_SESSION['secure_token']; } return false; }
[ "public", "function", "get_secure_url_token", "(", "$", "generate", "=", "false", ")", "{", "if", "(", "$", "len", "=", "$", "this", "->", "config", "->", "get", "(", "'use_secure_urls'", ")", ")", "{", "if", "(", "empty", "(", "$", "_SESSION", "[", ...
Returns session token for secure URLs @param bool $generate Generate token if not exists in session yet @return string|bool Token string, False when disabled
[ "Returns", "session", "token", "for", "secure", "URLs" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L896-L914
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.get_request_token
public function get_request_token() { if (empty($_SESSION['request_token'])) { $plugin = $this->plugins->exec_hook('request_token', array( 'value' => rcube_utils::random_bytes(32))); $_SESSION['request_token'] = $plugin['value']; } return $_SESSION['request_token']; }
php
public function get_request_token() { if (empty($_SESSION['request_token'])) { $plugin = $this->plugins->exec_hook('request_token', array( 'value' => rcube_utils::random_bytes(32))); $_SESSION['request_token'] = $plugin['value']; } return $_SESSION['request_token']; }
[ "public", "function", "get_request_token", "(", ")", "{", "if", "(", "empty", "(", "$", "_SESSION", "[", "'request_token'", "]", ")", ")", "{", "$", "plugin", "=", "$", "this", "->", "plugins", "->", "exec_hook", "(", "'request_token'", ",", "array", "("...
Generate a unique token to be used in a form request @return string The request token
[ "Generate", "a", "unique", "token", "to", "be", "used", "in", "a", "form", "request" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L921-L931
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.check_request
public function check_request($mode = rcube_utils::INPUT_POST) { // check secure token in URL if enabled if ($token = $this->get_secure_url_token()) { foreach (explode('/', preg_replace('/[?#&].*$/', '', $_SERVER['REQUEST_URI'])) as $tok) { if ($tok == $token) { return true; } } $this->request_status = self::REQUEST_ERROR_URL; return false; } $sess_tok = $this->get_request_token(); // ajax requests if (rcube_utils::request_header('X-Roundcube-Request') === $sess_tok) { return true; } // skip empty requests if (($mode == rcube_utils::INPUT_POST && empty($_POST)) || ($mode == rcube_utils::INPUT_GET && empty($_GET)) ) { return true; } // default method of securing requests $token = rcube_utils::get_input_value('_token', $mode); $sess_id = $_COOKIE[ini_get('session.name')]; if (empty($sess_id) || $token !== $sess_tok) { $this->request_status = self::REQUEST_ERROR_TOKEN; return false; } return true; }
php
public function check_request($mode = rcube_utils::INPUT_POST) { // check secure token in URL if enabled if ($token = $this->get_secure_url_token()) { foreach (explode('/', preg_replace('/[?#&].*$/', '', $_SERVER['REQUEST_URI'])) as $tok) { if ($tok == $token) { return true; } } $this->request_status = self::REQUEST_ERROR_URL; return false; } $sess_tok = $this->get_request_token(); // ajax requests if (rcube_utils::request_header('X-Roundcube-Request') === $sess_tok) { return true; } // skip empty requests if (($mode == rcube_utils::INPUT_POST && empty($_POST)) || ($mode == rcube_utils::INPUT_GET && empty($_GET)) ) { return true; } // default method of securing requests $token = rcube_utils::get_input_value('_token', $mode); $sess_id = $_COOKIE[ini_get('session.name')]; if (empty($sess_id) || $token !== $sess_tok) { $this->request_status = self::REQUEST_ERROR_TOKEN; return false; } return true; }
[ "public", "function", "check_request", "(", "$", "mode", "=", "rcube_utils", "::", "INPUT_POST", ")", "{", "// check secure token in URL if enabled", "if", "(", "$", "token", "=", "$", "this", "->", "get_secure_url_token", "(", ")", ")", "{", "foreach", "(", "...
Check if the current request contains a valid token. Empty requests aren't checked until use_secure_urls is set. @param int $mode Request method @return boolean True if request token is valid false if not
[ "Check", "if", "the", "current", "request", "contains", "a", "valid", "token", ".", "Empty", "requests", "aren", "t", "checked", "until", "use_secure_urls", "is", "set", "." ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L941-L980
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.console
public static function console() { $args = func_get_args(); if (class_exists('rcube', false)) { $rcube = self::get_instance(); $plugin = $rcube->plugins->exec_hook('console', array('args' => $args)); if ($plugin['abort']) { return; } $args = $plugin['args']; } $msg = array(); foreach ($args as $arg) { $msg[] = !is_string($arg) ? var_export($arg, true) : $arg; } self::write_log('console', join(";\n", $msg)); }
php
public static function console() { $args = func_get_args(); if (class_exists('rcube', false)) { $rcube = self::get_instance(); $plugin = $rcube->plugins->exec_hook('console', array('args' => $args)); if ($plugin['abort']) { return; } $args = $plugin['args']; } $msg = array(); foreach ($args as $arg) { $msg[] = !is_string($arg) ? var_export($arg, true) : $arg; } self::write_log('console', join(";\n", $msg)); }
[ "public", "static", "function", "console", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "if", "(", "class_exists", "(", "'rcube'", ",", "false", ")", ")", "{", "$", "rcube", "=", "self", "::", "get_instance", "(", ")", ";", "$", ...
Print or write debug messages @param mixed Debug message or data
[ "Print", "or", "write", "debug", "messages" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L1157-L1177
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.write_log
public static function write_log($name, $line) { if (!is_string($line)) { $line = var_export($line, true); } $date_format = $log_driver = $session_key = null; if (self::$instance) { $date_format = self::$instance->config->get('log_date_format'); $log_driver = self::$instance->config->get('log_driver'); $session_key = intval(self::$instance->config->get('log_session_id', 8)); } $date = rcube_utils::date_format($date_format); // trigger logging hook if (is_object(self::$instance) && is_object(self::$instance->plugins)) { $log = self::$instance->plugins->exec_hook('write_log', array('name' => $name, 'date' => $date, 'line' => $line)); $name = $log['name']; $line = $log['line']; $date = $log['date']; if ($log['abort']) { return true; } } // add session ID to the log if ($session_key > 0 && ($sess = session_id())) { $line = '<' . substr($sess, 0, $session_key) . '> ' . $line; } if ($log_driver == 'syslog') { $prio = $name == 'errors' ? LOG_ERR : LOG_INFO; return syslog($prio, $line); } // write message with file name when configured to log to STDOUT if ($log_driver == 'stdout') { $stdout = "php://stdout"; $line = "$name: $line"; return file_put_contents($stdout, $line, FILE_APPEND) !== false; } // log_driver == 'file' is assumed here $line = sprintf("[%s]: %s\n", $date, $line); // per-user logging is activated if (self::$instance && self::$instance->config->get('per_user_logging') && self::$instance->get_user_id()) { $log_dir = self::$instance->get_user_log_dir(); if (empty($log_dir) && !in_array($name, array('errors', 'userlogins', 'sendmail'))) { return false; } } if (empty($log_dir)) { if (!empty($log['dir'])) { $log_dir = $log['dir']; } else if (self::$instance) { $log_dir = self::$instance->config->get('log_dir'); } } if (empty($log_dir)) { $log_dir = RCUBE_INSTALL_PATH . 'logs'; } return file_put_contents("$log_dir/$name", $line, FILE_APPEND) !== false; }
php
public static function write_log($name, $line) { if (!is_string($line)) { $line = var_export($line, true); } $date_format = $log_driver = $session_key = null; if (self::$instance) { $date_format = self::$instance->config->get('log_date_format'); $log_driver = self::$instance->config->get('log_driver'); $session_key = intval(self::$instance->config->get('log_session_id', 8)); } $date = rcube_utils::date_format($date_format); // trigger logging hook if (is_object(self::$instance) && is_object(self::$instance->plugins)) { $log = self::$instance->plugins->exec_hook('write_log', array('name' => $name, 'date' => $date, 'line' => $line)); $name = $log['name']; $line = $log['line']; $date = $log['date']; if ($log['abort']) { return true; } } // add session ID to the log if ($session_key > 0 && ($sess = session_id())) { $line = '<' . substr($sess, 0, $session_key) . '> ' . $line; } if ($log_driver == 'syslog') { $prio = $name == 'errors' ? LOG_ERR : LOG_INFO; return syslog($prio, $line); } // write message with file name when configured to log to STDOUT if ($log_driver == 'stdout') { $stdout = "php://stdout"; $line = "$name: $line"; return file_put_contents($stdout, $line, FILE_APPEND) !== false; } // log_driver == 'file' is assumed here $line = sprintf("[%s]: %s\n", $date, $line); // per-user logging is activated if (self::$instance && self::$instance->config->get('per_user_logging') && self::$instance->get_user_id()) { $log_dir = self::$instance->get_user_log_dir(); if (empty($log_dir) && !in_array($name, array('errors', 'userlogins', 'sendmail'))) { return false; } } if (empty($log_dir)) { if (!empty($log['dir'])) { $log_dir = $log['dir']; } else if (self::$instance) { $log_dir = self::$instance->config->get('log_dir'); } } if (empty($log_dir)) { $log_dir = RCUBE_INSTALL_PATH . 'logs'; } return file_put_contents("$log_dir/$name", $line, FILE_APPEND) !== false; }
[ "public", "static", "function", "write_log", "(", "$", "name", ",", "$", "line", ")", "{", "if", "(", "!", "is_string", "(", "$", "line", ")", ")", "{", "$", "line", "=", "var_export", "(", "$", "line", ",", "true", ")", ";", "}", "$", "date_form...
Append a line to a logfile in the logs directory. Date will be added automatically to the line. @param string $name Name of the log file @param mixed $line Line to append @return bool True on success, False on failure
[ "Append", "a", "line", "to", "a", "logfile", "in", "the", "logs", "directory", ".", "Date", "will", "be", "added", "automatically", "to", "the", "line", "." ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L1188-L1260
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.log_bug
public static function log_bug($arg_arr) { $program = strtoupper($arg_arr['type'] ?: 'php'); $level = self::get_instance()->config->get('debug_level'); // disable errors for ajax requests, write to log instead (#1487831) if (($level & 4) && !empty($_REQUEST['_remote'])) { $level = ($level ^ 4) | 1; } // write error to local log file if (($level & 1) || !empty($arg_arr['fatal'])) { if ($_SERVER['REQUEST_METHOD'] == 'POST') { foreach (array('_task', '_action') as $arg) { if ($_POST[$arg] && !$_GET[$arg]) { $post_query[$arg] = $_POST[$arg]; } } if (!empty($post_query)) { $post_query = (strpos($_SERVER['REQUEST_URI'], '?') != false ? '&' : '?') . http_build_query($post_query, '', '&'); } } $log_entry = sprintf("%s Error: %s%s (%s %s)", $program, $arg_arr['message'], $arg_arr['file'] ? sprintf(' in %s on line %d', $arg_arr['file'], $arg_arr['line']) : '', $_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI'] . $post_query); if (!self::write_log('errors', $log_entry)) { // send error to PHPs error handler if write_log didn't succeed trigger_error($arg_arr['message'], E_USER_WARNING); } } // report the bug to the global bug reporting system if ($level & 2) { // TODO: Send error via HTTP } // show error if debug_mode is on if ($level & 4) { print "<b>$program Error"; if (!empty($arg_arr['file']) && !empty($arg_arr['line'])) { print " in $arg_arr[file] ($arg_arr[line])"; } print ':</b>&nbsp;'; print nl2br($arg_arr['message']); print '<br />'; flush(); } }
php
public static function log_bug($arg_arr) { $program = strtoupper($arg_arr['type'] ?: 'php'); $level = self::get_instance()->config->get('debug_level'); // disable errors for ajax requests, write to log instead (#1487831) if (($level & 4) && !empty($_REQUEST['_remote'])) { $level = ($level ^ 4) | 1; } // write error to local log file if (($level & 1) || !empty($arg_arr['fatal'])) { if ($_SERVER['REQUEST_METHOD'] == 'POST') { foreach (array('_task', '_action') as $arg) { if ($_POST[$arg] && !$_GET[$arg]) { $post_query[$arg] = $_POST[$arg]; } } if (!empty($post_query)) { $post_query = (strpos($_SERVER['REQUEST_URI'], '?') != false ? '&' : '?') . http_build_query($post_query, '', '&'); } } $log_entry = sprintf("%s Error: %s%s (%s %s)", $program, $arg_arr['message'], $arg_arr['file'] ? sprintf(' in %s on line %d', $arg_arr['file'], $arg_arr['line']) : '', $_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI'] . $post_query); if (!self::write_log('errors', $log_entry)) { // send error to PHPs error handler if write_log didn't succeed trigger_error($arg_arr['message'], E_USER_WARNING); } } // report the bug to the global bug reporting system if ($level & 2) { // TODO: Send error via HTTP } // show error if debug_mode is on if ($level & 4) { print "<b>$program Error"; if (!empty($arg_arr['file']) && !empty($arg_arr['line'])) { print " in $arg_arr[file] ($arg_arr[line])"; } print ':</b>&nbsp;'; print nl2br($arg_arr['message']); print '<br />'; flush(); } }
[ "public", "static", "function", "log_bug", "(", "$", "arg_arr", ")", "{", "$", "program", "=", "strtoupper", "(", "$", "arg_arr", "[", "'type'", "]", "?", ":", "'php'", ")", ";", "$", "level", "=", "self", "::", "get_instance", "(", ")", "->", "confi...
Report error according to configured debug_level @param array $arg_arr Named parameters @see self::raise_error()
[ "Report", "error", "according", "to", "configured", "debug_level" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L1330-L1386
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.debug
public static function debug($engine, $data, $result = null) { static $debug_counter; $line = '[' . (++$debug_counter[$engine]) . '] ' . $data; if (($len = strlen($line)) > self::DEBUG_LINE_LENGTH) { $diff = $len - self::DEBUG_LINE_LENGTH; $line = substr($line, 0, self::DEBUG_LINE_LENGTH) . "... [truncated $diff bytes]"; } if ($result !== null) { $line .= ' [' . ($result ? 'TRUE' : 'FALSE') . ']'; } self::write_log($engine, $line); }
php
public static function debug($engine, $data, $result = null) { static $debug_counter; $line = '[' . (++$debug_counter[$engine]) . '] ' . $data; if (($len = strlen($line)) > self::DEBUG_LINE_LENGTH) { $diff = $len - self::DEBUG_LINE_LENGTH; $line = substr($line, 0, self::DEBUG_LINE_LENGTH) . "... [truncated $diff bytes]"; } if ($result !== null) { $line .= ' [' . ($result ? 'TRUE' : 'FALSE') . ']'; } self::write_log($engine, $line); }
[ "public", "static", "function", "debug", "(", "$", "engine", ",", "$", "data", ",", "$", "result", "=", "null", ")", "{", "static", "$", "debug_counter", ";", "$", "line", "=", "'['", ".", "(", "++", "$", "debug_counter", "[", "$", "engine", "]", "...
Write debug info to the log @param string $engine Engine type - file name (memcache, apc) @param string $data Data string to log @param bool $result Operation result
[ "Write", "debug", "info", "to", "the", "log" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L1395-L1411
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.print_timer
public static function print_timer($timer, $label = 'Timer', $dest = 'console') { static $print_count = 0; $print_count++; $now = self::timer(); $diff = $now - $timer; if (empty($label)) { $label = 'Timer '.$print_count; } self::write_log($dest, sprintf("%s: %0.4f sec", $label, $diff)); }
php
public static function print_timer($timer, $label = 'Timer', $dest = 'console') { static $print_count = 0; $print_count++; $now = self::timer(); $diff = $now - $timer; if (empty($label)) { $label = 'Timer '.$print_count; } self::write_log($dest, sprintf("%s: %0.4f sec", $label, $diff)); }
[ "public", "static", "function", "print_timer", "(", "$", "timer", ",", "$", "label", "=", "'Timer'", ",", "$", "dest", "=", "'console'", ")", "{", "static", "$", "print_count", "=", "0", ";", "$", "print_count", "++", ";", "$", "now", "=", "self", ":...
Logs time difference according to provided timer @param float $timer Timer (self::timer() result) @param string $label Log line prefix @param string $dest Log file name @see self::timer()
[ "Logs", "time", "difference", "according", "to", "provided", "timer" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L1432-L1445
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.get_user_id
public function get_user_id() { if (is_object($this->user)) { return $this->user->ID; } else if (isset($_SESSION['user_id'])) { return $_SESSION['user_id']; } return null; }
php
public function get_user_id() { if (is_object($this->user)) { return $this->user->ID; } else if (isset($_SESSION['user_id'])) { return $_SESSION['user_id']; } return null; }
[ "public", "function", "get_user_id", "(", ")", "{", "if", "(", "is_object", "(", "$", "this", "->", "user", ")", ")", "{", "return", "$", "this", "->", "user", "->", "ID", ";", "}", "else", "if", "(", "isset", "(", "$", "_SESSION", "[", "'user_id'"...
Getter for logged user ID. @return mixed User identifier
[ "Getter", "for", "logged", "user", "ID", "." ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L1467-L1477
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.get_user_name
public function get_user_name() { if (is_object($this->user)) { return $this->user->get_username(); } else if (isset($_SESSION['username'])) { return $_SESSION['username']; } }
php
public function get_user_name() { if (is_object($this->user)) { return $this->user->get_username(); } else if (isset($_SESSION['username'])) { return $_SESSION['username']; } }
[ "public", "function", "get_user_name", "(", ")", "{", "if", "(", "is_object", "(", "$", "this", "->", "user", ")", ")", "{", "return", "$", "this", "->", "user", "->", "get_username", "(", ")", ";", "}", "else", "if", "(", "isset", "(", "$", "_SESS...
Getter for logged user name. @return string User name
[ "Getter", "for", "logged", "user", "name", "." ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L1484-L1492
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.get_user_log_dir
protected function get_user_log_dir() { $log_dir = $this->config->get('log_dir', RCUBE_INSTALL_PATH . 'logs'); $user_name = $this->get_user_name(); $user_log_dir = $log_dir . '/' . $user_name; return !empty($user_name) && is_writable($user_log_dir) ? $user_log_dir : false; }
php
protected function get_user_log_dir() { $log_dir = $this->config->get('log_dir', RCUBE_INSTALL_PATH . 'logs'); $user_name = $this->get_user_name(); $user_log_dir = $log_dir . '/' . $user_name; return !empty($user_name) && is_writable($user_log_dir) ? $user_log_dir : false; }
[ "protected", "function", "get_user_log_dir", "(", ")", "{", "$", "log_dir", "=", "$", "this", "->", "config", "->", "get", "(", "'log_dir'", ",", "RCUBE_INSTALL_PATH", ".", "'logs'", ")", ";", "$", "user_name", "=", "$", "this", "->", "get_user_name", "(",...
Get the per-user log directory
[ "Get", "the", "per", "-", "user", "log", "directory" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L1524-L1531
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.get_user_language
public function get_user_language() { if (is_object($this->user)) { return $this->user->language; } else if (isset($_SESSION['language'])) { return $_SESSION['language']; } }
php
public function get_user_language() { if (is_object($this->user)) { return $this->user->language; } else if (isset($_SESSION['language'])) { return $_SESSION['language']; } }
[ "public", "function", "get_user_language", "(", ")", "{", "if", "(", "is_object", "(", "$", "this", "->", "user", ")", ")", "{", "return", "$", "this", "->", "user", "->", "language", ";", "}", "else", "if", "(", "isset", "(", "$", "_SESSION", "[", ...
Getter for logged user language code. @return string User language code
[ "Getter", "for", "logged", "user", "language", "code", "." ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L1538-L1546
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube.php
rcube.gen_message_id
public function gen_message_id($sender = null) { $local_part = md5(uniqid('rcube'.mt_rand(), true)); $domain_part = ''; if ($sender && preg_match('/@([^\s]+\.[a-z0-9-]+)/', $sender, $m)) { $domain_part = $m[1]; } else { $domain_part = $this->user->get_username('domain'); } // Try to find FQDN, some spamfilters doesn't like 'localhost' (#1486924) if (!preg_match('/\.[a-z0-9-]+$/i', $domain_part)) { foreach (array($_SERVER['HTTP_HOST'], $_SERVER['SERVER_NAME']) as $host) { $host = preg_replace('/:[0-9]+$/', '', $host); if ($host && preg_match('/\.[a-z]+$/i', $host)) { $domain_part = $host; break; } } } return sprintf('<%s@%s>', $local_part, $domain_part); }
php
public function gen_message_id($sender = null) { $local_part = md5(uniqid('rcube'.mt_rand(), true)); $domain_part = ''; if ($sender && preg_match('/@([^\s]+\.[a-z0-9-]+)/', $sender, $m)) { $domain_part = $m[1]; } else { $domain_part = $this->user->get_username('domain'); } // Try to find FQDN, some spamfilters doesn't like 'localhost' (#1486924) if (!preg_match('/\.[a-z0-9-]+$/i', $domain_part)) { foreach (array($_SERVER['HTTP_HOST'], $_SERVER['SERVER_NAME']) as $host) { $host = preg_replace('/:[0-9]+$/', '', $host); if ($host && preg_match('/\.[a-z]+$/i', $host)) { $domain_part = $host; break; } } } return sprintf('<%s@%s>', $local_part, $domain_part); }
[ "public", "function", "gen_message_id", "(", "$", "sender", "=", "null", ")", "{", "$", "local_part", "=", "md5", "(", "uniqid", "(", "'rcube'", ".", "mt_rand", "(", ")", ",", "true", ")", ")", ";", "$", "domain_part", "=", "''", ";", "if", "(", "$...
Unique Message-ID generator. @param string $sender Optional sender e-mail address @return string Message-ID
[ "Unique", "Message", "-", "ID", "generator", "." ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube.php#L1555-L1579
train
i-MSCP/roundcube
roundcubemail/plugins/redundant_attachments/redundant_attachments.php
redundant_attachments._key
private function _key($args) { $uname = $args['path'] ?: $args['name']; return $args['group'] . md5(time() . $uname . $_SESSION['user_id']); }
php
private function _key($args) { $uname = $args['path'] ?: $args['name']; return $args['group'] . md5(time() . $uname . $_SESSION['user_id']); }
[ "private", "function", "_key", "(", "$", "args", ")", "{", "$", "uname", "=", "$", "args", "[", "'path'", "]", "?", ":", "$", "args", "[", "'name'", "]", ";", "return", "$", "args", "[", "'group'", "]", ".", "md5", "(", "time", "(", ")", ".", ...
Helper method to generate a unique key for the given attachment file
[ "Helper", "method", "to", "generate", "a", "unique", "key", "for", "the", "given", "attachment", "file" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/redundant_attachments/redundant_attachments.php#L91-L95
train
i-MSCP/roundcube
roundcubemail/plugins/identity_select/identity_select.php
identity_select.storage_init
function storage_init($p) { $rcmail = rcmail::get_instance(); if ($add_headers = (array)$rcmail->config->get('identity_select_headers', array())) { $p['fetch_headers'] = trim($p['fetch_headers'] . ' ' . strtoupper(join(' ', $add_headers))); } return $p; }
php
function storage_init($p) { $rcmail = rcmail::get_instance(); if ($add_headers = (array)$rcmail->config->get('identity_select_headers', array())) { $p['fetch_headers'] = trim($p['fetch_headers'] . ' ' . strtoupper(join(' ', $add_headers))); } return $p; }
[ "function", "storage_init", "(", "$", "p", ")", "{", "$", "rcmail", "=", "rcmail", "::", "get_instance", "(", ")", ";", "if", "(", "$", "add_headers", "=", "(", "array", ")", "$", "rcmail", "->", "config", "->", "get", "(", "'identity_select_headers'", ...
Adds additional headers to supported headers list
[ "Adds", "additional", "headers", "to", "supported", "headers", "list" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/identity_select/identity_select.php#L36-L45
train
i-MSCP/roundcube
roundcubemail/plugins/identity_select/identity_select.php
identity_select.get_email_from_header
protected function get_email_from_header($message, $header) { $value = $message->headers->get($header, false); if (strtolower($header) == 'received') { // find first email address in all Received headers $email = null; foreach ((array) $value as $entry) { if (preg_match('/[\s\t]+for[\s\t]+<([^>]+)>/', $entry, $matches)) { $email = $matches[1]; break; } } $value = $email; } return (array) $value; }
php
protected function get_email_from_header($message, $header) { $value = $message->headers->get($header, false); if (strtolower($header) == 'received') { // find first email address in all Received headers $email = null; foreach ((array) $value as $entry) { if (preg_match('/[\s\t]+for[\s\t]+<([^>]+)>/', $entry, $matches)) { $email = $matches[1]; break; } } $value = $email; } return (array) $value; }
[ "protected", "function", "get_email_from_header", "(", "$", "message", ",", "$", "header", ")", "{", "$", "value", "=", "$", "message", "->", "headers", "->", "get", "(", "$", "header", ",", "false", ")", ";", "if", "(", "strtolower", "(", "$", "header...
Extract email address from specified message header
[ "Extract", "email", "address", "from", "specified", "message", "header" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/identity_select/identity_select.php#L75-L93
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_ldap_generic.php
rcube_ldap_generic.get_entry
function get_entry($dn, $attributes = array()) { return parent::get_entry($dn, !empty($attributes) ? $attributes : $this->attributes); }
php
function get_entry($dn, $attributes = array()) { return parent::get_entry($dn, !empty($attributes) ? $attributes : $this->attributes); }
[ "function", "get_entry", "(", "$", "dn", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "return", "parent", "::", "get_entry", "(", "$", "dn", ",", "!", "empty", "(", "$", "attributes", ")", "?", "$", "attributes", ":", "$", "this", "->"...
Get a specific LDAP entry, identified by its DN @param string $dn Record identifier @param array $attributes Attributes to return @return array Hash array
[ "Get", "a", "specific", "LDAP", "entry", "identified", "by", "its", "DN" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_ldap_generic.php#L65-L68
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_ldap_generic.php
rcube_ldap_generic.normalize_entry
public static function normalize_entry($entry, $flat = false) { if (!isset($entry['count'])) { return $entry; } $rec = array(); for ($i=0; $i < $entry['count']; $i++) { $attr = $entry[$i]; if ($entry[$attr]['count'] == 1) { switch ($attr) { case 'objectclass': $rec[$attr] = array(strtolower($entry[$attr][0])); break; default: $rec[$attr] = $entry[$attr][0]; break; } } else { for ($j=0; $j < $entry[$attr]['count']; $j++) { $rec[$attr][$j] = $entry[$attr][$j]; } } } return $rec; }
php
public static function normalize_entry($entry, $flat = false) { if (!isset($entry['count'])) { return $entry; } $rec = array(); for ($i=0; $i < $entry['count']; $i++) { $attr = $entry[$i]; if ($entry[$attr]['count'] == 1) { switch ($attr) { case 'objectclass': $rec[$attr] = array(strtolower($entry[$attr][0])); break; default: $rec[$attr] = $entry[$attr][0]; break; } } else { for ($j=0; $j < $entry[$attr]['count']; $j++) { $rec[$attr][$j] = $entry[$attr][$j]; } } } return $rec; }
[ "public", "static", "function", "normalize_entry", "(", "$", "entry", ",", "$", "flat", "=", "false", ")", "{", "if", "(", "!", "isset", "(", "$", "entry", "[", "'count'", "]", ")", ")", "{", "return", "$", "entry", ";", "}", "$", "rec", "=", "ar...
Turn an LDAP entry into a regular PHP array with attributes as keys. @param array $entry Attributes array as retrieved from ldap_get_attributes() or ldap_get_entries() @param bool $flat Convert one-element-array values into strings (not implemented) @return array Hash array with attributes as keys
[ "Turn", "an", "LDAP", "entry", "into", "a", "regular", "PHP", "array", "with", "attributes", "as", "keys", "." ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_ldap_generic.php#L293-L321
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_ldap_generic.php
rcube_ldap_generic.fulltext_search_filter
public static function fulltext_search_filter($value, $attributes, $mode = 1) { if (empty($attributes)) { $attributes = array('cn'); } $groups = array(); $value = str_replace('*', '', $value); $words = $mode == 0 ? rcube_utils::tokenize_string($value, 1) : array($value); // set wildcards $wp = $ws = ''; if ($mode != 1) { $ws = '*'; $wp = !$mode ? '*' : ''; } // search each word in all listed attributes foreach ($words as $word) { $parts = array(); foreach ($attributes as $attr) { $parts[] = "($attr=$wp" . self::quote_string($word) . "$ws)"; } $groups[] = '(|' . join('', $parts) . ')'; } return count($groups) > 1 ? '(&' . join('', $groups) . ')' : join('', $groups); }
php
public static function fulltext_search_filter($value, $attributes, $mode = 1) { if (empty($attributes)) { $attributes = array('cn'); } $groups = array(); $value = str_replace('*', '', $value); $words = $mode == 0 ? rcube_utils::tokenize_string($value, 1) : array($value); // set wildcards $wp = $ws = ''; if ($mode != 1) { $ws = '*'; $wp = !$mode ? '*' : ''; } // search each word in all listed attributes foreach ($words as $word) { $parts = array(); foreach ($attributes as $attr) { $parts[] = "($attr=$wp" . self::quote_string($word) . "$ws)"; } $groups[] = '(|' . join('', $parts) . ')'; } return count($groups) > 1 ? '(&' . join('', $groups) . ')' : join('', $groups); }
[ "public", "static", "function", "fulltext_search_filter", "(", "$", "value", ",", "$", "attributes", ",", "$", "mode", "=", "1", ")", "{", "if", "(", "empty", "(", "$", "attributes", ")", ")", "{", "$", "attributes", "=", "array", "(", "'cn'", ")", "...
Compose an LDAP filter string matching all words from the search string in the given list of attributes. @param string $value Search value @param mixed $attrs List of LDAP attributes to search @param int $mode Matching mode: 0 - partial (*abc*), 1 - strict (=), 2 - prefix (abc*) @return string LDAP filter
[ "Compose", "an", "LDAP", "filter", "string", "matching", "all", "words", "from", "the", "search", "string", "in", "the", "given", "list", "of", "attributes", "." ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_ldap_generic.php#L335-L362
train
Billplz/Billplz-API-Class
src/API.php
API.detectMode
private function detectMode($method_name, $response, $parameter = '', $optional = '', $extra = '') { if ($response[0] === 401 && $this->connect->detect_mode) { $this->connect->detect_mode = false; $this->connect->setMode(false); if (!empty($extra)) { return $this->{$method_name}($parameter, $optional, $extra); } elseif (!empty($optional)) { return $this->{$method_name}($parameter, $optional); } elseif (!empty($parameter)) { return $this->{$method_name}($parameter); } else { return $this->{$method_name}(); } } return false; }
php
private function detectMode($method_name, $response, $parameter = '', $optional = '', $extra = '') { if ($response[0] === 401 && $this->connect->detect_mode) { $this->connect->detect_mode = false; $this->connect->setMode(false); if (!empty($extra)) { return $this->{$method_name}($parameter, $optional, $extra); } elseif (!empty($optional)) { return $this->{$method_name}($parameter, $optional); } elseif (!empty($parameter)) { return $this->{$method_name}($parameter); } else { return $this->{$method_name}(); } } return false; }
[ "private", "function", "detectMode", "(", "$", "method_name", ",", "$", "response", ",", "$", "parameter", "=", "''", ",", "$", "optional", "=", "''", ",", "$", "extra", "=", "''", ")", "{", "if", "(", "$", "response", "[", "0", "]", "===", "401", ...
This method is to change the URL to staging if failed to authenticate with production. It will recall the method that has executed previously to perform it in staging.
[ "This", "method", "is", "to", "change", "the", "URL", "to", "staging", "if", "failed", "to", "authenticate", "with", "production", ".", "It", "will", "recall", "the", "method", "that", "has", "executed", "previously", "to", "perform", "it", "in", "staging", ...
c93cf917e8b0e9bd1f2aa71c98e2dc8d99242424
https://github.com/Billplz/Billplz-API-Class/blob/c93cf917e8b0e9bd1f2aa71c98e2dc8d99242424/src/API.php#L23-L39
train
netgen/NetgenInformationCollectionBundle
bundle/Factory/EmailDataFactory.php
EmailDataFactory.resolveEmail
protected function resolveEmail(TemplateData $data, $field) { $rendered = ''; if ($data->getTemplateWrapper()->hasBlock($field)) { $rendered = $data->getTemplateWrapper()->renderBlock( $field, array( 'event' => $data->getEvent(), 'collected_fields' => $data->getEvent()->getInformationCollectionStruct()->getCollectedFields(), 'content' => $data->getContent(), ) ); $rendered = trim($rendered); } if (!empty($rendered) && filter_var($rendered, FILTER_VALIDATE_EMAIL)) { return $rendered; } $content = $data->getContent(); if (array_key_exists($field, $content->fields) && !$this->fieldHelper->isFieldEmpty($content, $field) ) { $fieldValue = $this->translationHelper->getTranslatedField($content, $field); return $fieldValue->value->email; } if (!empty($this->config[ConfigurationConstants::DEFAULT_VARIABLES][$field])) { return $this->config[ConfigurationConstants::DEFAULT_VARIABLES][$field]; } throw new MissingValueException($field); }
php
protected function resolveEmail(TemplateData $data, $field) { $rendered = ''; if ($data->getTemplateWrapper()->hasBlock($field)) { $rendered = $data->getTemplateWrapper()->renderBlock( $field, array( 'event' => $data->getEvent(), 'collected_fields' => $data->getEvent()->getInformationCollectionStruct()->getCollectedFields(), 'content' => $data->getContent(), ) ); $rendered = trim($rendered); } if (!empty($rendered) && filter_var($rendered, FILTER_VALIDATE_EMAIL)) { return $rendered; } $content = $data->getContent(); if (array_key_exists($field, $content->fields) && !$this->fieldHelper->isFieldEmpty($content, $field) ) { $fieldValue = $this->translationHelper->getTranslatedField($content, $field); return $fieldValue->value->email; } if (!empty($this->config[ConfigurationConstants::DEFAULT_VARIABLES][$field])) { return $this->config[ConfigurationConstants::DEFAULT_VARIABLES][$field]; } throw new MissingValueException($field); }
[ "protected", "function", "resolveEmail", "(", "TemplateData", "$", "data", ",", "$", "field", ")", "{", "$", "rendered", "=", "''", ";", "if", "(", "$", "data", "->", "getTemplateWrapper", "(", ")", "->", "hasBlock", "(", "$", "field", ")", ")", "{", ...
Returns resolved email parameter. @param TemplateData $data @param string $field @return string
[ "Returns", "resolved", "email", "parameter", "." ]
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Factory/EmailDataFactory.php#L152-L186
train
netgen/NetgenInformationCollectionBundle
bundle/Factory/EmailDataFactory.php
EmailDataFactory.resolveTemplate
protected function resolveTemplate($contentTypeIdentifier) { if (array_key_exists($contentTypeIdentifier, $this->config[ConfigurationConstants::TEMPLATES][ConfigurationConstants::CONTENT_TYPES])) { return $this->config[ConfigurationConstants::TEMPLATES][ConfigurationConstants::CONTENT_TYPES][$contentTypeIdentifier]; } return $this->config[ConfigurationConstants::TEMPLATES][ConfigurationConstants::SETTINGS_DEFAULT]; }
php
protected function resolveTemplate($contentTypeIdentifier) { if (array_key_exists($contentTypeIdentifier, $this->config[ConfigurationConstants::TEMPLATES][ConfigurationConstants::CONTENT_TYPES])) { return $this->config[ConfigurationConstants::TEMPLATES][ConfigurationConstants::CONTENT_TYPES][$contentTypeIdentifier]; } return $this->config[ConfigurationConstants::TEMPLATES][ConfigurationConstants::SETTINGS_DEFAULT]; }
[ "protected", "function", "resolveTemplate", "(", "$", "contentTypeIdentifier", ")", "{", "if", "(", "array_key_exists", "(", "$", "contentTypeIdentifier", ",", "$", "this", "->", "config", "[", "ConfigurationConstants", "::", "TEMPLATES", "]", "[", "ConfigurationCon...
Returns resolved template name. @param string $contentTypeIdentifier @return string
[ "Returns", "resolved", "template", "name", "." ]
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Factory/EmailDataFactory.php#L195-L202
train
netgen/NetgenInformationCollectionBundle
bundle/Factory/EmailDataFactory.php
EmailDataFactory.resolveBody
protected function resolveBody(TemplateData $data) { if ($data->getTemplateWrapper()->hasBlock(Constants::BLOCK_EMAIL)) { return $data->getTemplateWrapper() ->renderBlock( Constants::BLOCK_EMAIL, array( 'event' => $data->getEvent(), 'collected_fields' => $data->getEvent()->getInformationCollectionStruct()->getCollectedFields(), 'content' => $data->getContent(), 'default_variables' => !empty($this->config[ConfigurationConstants::DEFAULT_VARIABLES]) ? $this->config[ConfigurationConstants::DEFAULT_VARIABLES] : null, ) ); } throw new MissingEmailBlockException( $data->getTemplateWrapper()->getSourceContext()->getName(), $data->getTemplateWrapper()->getBlockNames() ); }
php
protected function resolveBody(TemplateData $data) { if ($data->getTemplateWrapper()->hasBlock(Constants::BLOCK_EMAIL)) { return $data->getTemplateWrapper() ->renderBlock( Constants::BLOCK_EMAIL, array( 'event' => $data->getEvent(), 'collected_fields' => $data->getEvent()->getInformationCollectionStruct()->getCollectedFields(), 'content' => $data->getContent(), 'default_variables' => !empty($this->config[ConfigurationConstants::DEFAULT_VARIABLES]) ? $this->config[ConfigurationConstants::DEFAULT_VARIABLES] : null, ) ); } throw new MissingEmailBlockException( $data->getTemplateWrapper()->getSourceContext()->getName(), $data->getTemplateWrapper()->getBlockNames() ); }
[ "protected", "function", "resolveBody", "(", "TemplateData", "$", "data", ")", "{", "if", "(", "$", "data", "->", "getTemplateWrapper", "(", ")", "->", "hasBlock", "(", "Constants", "::", "BLOCK_EMAIL", ")", ")", "{", "return", "$", "data", "->", "getTempl...
Renders email template. @param TemplateData $data @throws MissingEmailBlockException @return string
[ "Renders", "email", "template", "." ]
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Factory/EmailDataFactory.php#L213-L233
train
i-MSCP/roundcube
roundcubemail/plugins/password/drivers/cpanel.php
rcube_cpanel_password.setPassword
function setPassword($address, $password) { if (strpos($address, '@')) { list($data['email'], $data['domain']) = explode('@', $address); } else { list($data['email'], $data['domain']) = array($address, ''); } $data['password'] = $password; // Get the cPanel user $query = $this->xmlapi->listaccts('domain', $data['domain']); $query = json_decode($query, true); if ( $query['status'] != 1) { return false; } $cpanel_user = $query['acct'][0]['user']; $query = $this->xmlapi->api2_query($cpanel_user, 'Email', 'passwdpop', $data); $query = json_decode($query, true); $result = $query['cpanelresult']['data'][0]; if ($result['result'] == 1) { return PASSWORD_SUCCESS; } if ($result['reason']) { return array( 'code' => PASSWORD_ERROR, 'message' => $result['reason'], ); } return PASSWORD_ERROR; }
php
function setPassword($address, $password) { if (strpos($address, '@')) { list($data['email'], $data['domain']) = explode('@', $address); } else { list($data['email'], $data['domain']) = array($address, ''); } $data['password'] = $password; // Get the cPanel user $query = $this->xmlapi->listaccts('domain', $data['domain']); $query = json_decode($query, true); if ( $query['status'] != 1) { return false; } $cpanel_user = $query['acct'][0]['user']; $query = $this->xmlapi->api2_query($cpanel_user, 'Email', 'passwdpop', $data); $query = json_decode($query, true); $result = $query['cpanelresult']['data'][0]; if ($result['result'] == 1) { return PASSWORD_SUCCESS; } if ($result['reason']) { return array( 'code' => PASSWORD_ERROR, 'message' => $result['reason'], ); } return PASSWORD_ERROR; }
[ "function", "setPassword", "(", "$", "address", ",", "$", "password", ")", "{", "if", "(", "strpos", "(", "$", "address", ",", "'@'", ")", ")", "{", "list", "(", "$", "data", "[", "'email'", "]", ",", "$", "data", "[", "'domain'", "]", ")", "=", ...
Change email account password @param string $address Email address/username @param string $password Email account password @return int|array Operation status
[ "Change", "email", "account", "password" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/password/drivers/cpanel.php#L79-L114
train
netgen/NetgenInformationCollectionBundle
bundle/InformationCollectionLegacyTrait.php
InformationCollectionLegacyTrait.collectInformation
protected function collectInformation(Request $request, $locationId) { $isValid = false; $location = $this->container ->get('ezpublish.api.service.location') ->loadLocation($locationId); /** @var \Netgen\Bundle\InformationCollectionBundle\Form\Builder\FormBuilder $formBuilder */ $formBuilder = $this->container ->get('netgen_information_collection.form.builder'); $form = $formBuilder->createFormForLocation($location) ->getForm(); /** @var CaptchaValueInterface $captcha */ $captcha = $this->container ->get('netgen_information_collection.factory.captcha') ->getCaptcha($location); $form->handleRequest($request); $validCaptcha = $captcha->isValid($request); $formSubmitted = $form->isSubmitted(); if ($formSubmitted && $form->isValid() && $validCaptcha) { $isValid = true; $event = new InformationCollected($form->getData()); /** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher */ $dispatcher = $this->container ->get('event_dispatcher'); $dispatcher->dispatch(Events::INFORMATION_COLLECTED, $event); } if (true === $formSubmitted && false === $validCaptcha) { $form->addError(new FormError($this->container->get('translator')->trans('form.errors.captcha_failed', array(), 'netgen_information_collection_form_messages'))); } return array( 'is_valid' => $isValid, 'form' => $form->createView(), 'collected_fields' => $form->getData()->payload->getCollectedFields(), ); }
php
protected function collectInformation(Request $request, $locationId) { $isValid = false; $location = $this->container ->get('ezpublish.api.service.location') ->loadLocation($locationId); /** @var \Netgen\Bundle\InformationCollectionBundle\Form\Builder\FormBuilder $formBuilder */ $formBuilder = $this->container ->get('netgen_information_collection.form.builder'); $form = $formBuilder->createFormForLocation($location) ->getForm(); /** @var CaptchaValueInterface $captcha */ $captcha = $this->container ->get('netgen_information_collection.factory.captcha') ->getCaptcha($location); $form->handleRequest($request); $validCaptcha = $captcha->isValid($request); $formSubmitted = $form->isSubmitted(); if ($formSubmitted && $form->isValid() && $validCaptcha) { $isValid = true; $event = new InformationCollected($form->getData()); /** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher */ $dispatcher = $this->container ->get('event_dispatcher'); $dispatcher->dispatch(Events::INFORMATION_COLLECTED, $event); } if (true === $formSubmitted && false === $validCaptcha) { $form->addError(new FormError($this->container->get('translator')->trans('form.errors.captcha_failed', array(), 'netgen_information_collection_form_messages'))); } return array( 'is_valid' => $isValid, 'form' => $form->createView(), 'collected_fields' => $form->getData()->payload->getCollectedFields(), ); }
[ "protected", "function", "collectInformation", "(", "Request", "$", "request", ",", "$", "locationId", ")", "{", "$", "isValid", "=", "false", ";", "$", "location", "=", "$", "this", "->", "container", "->", "get", "(", "'ezpublish.api.service.location'", ")",...
Builds Form, checks if Form is valid and dispatches InformationCollected event. @param \Symfony\Component\HttpFoundation\Request $request @param int $locationId @return array
[ "Builds", "Form", "checks", "if", "Form", "is", "valid", "and", "dispatches", "InformationCollected", "event", "." ]
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/InformationCollectionLegacyTrait.php#L20-L64
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_smtp.php
rcube_smtp.disconnect
public function disconnect() { if (is_object($this->conn)) { $this->conn->disconnect(); $this->conn = null; } }
php
public function disconnect() { if (is_object($this->conn)) { $this->conn->disconnect(); $this->conn = null; } }
[ "public", "function", "disconnect", "(", ")", "{", "if", "(", "is_object", "(", "$", "this", "->", "conn", ")", ")", "{", "$", "this", "->", "conn", "->", "disconnect", "(", ")", ";", "$", "this", "->", "conn", "=", "null", ";", "}", "}" ]
Disconnect the global SMTP connection
[ "Disconnect", "the", "global", "SMTP", "connection" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_smtp.php#L334-L340
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_smtp.php
rcube_smtp.debug_handler
public function debug_handler(&$smtp, $message) { // catch AUTH commands and set anonymization flag for subsequent sends if (preg_match('/^Send: AUTH ([A-Z]+)/', $message, $m)) { $this->anonymize_log = $m[1] == 'LOGIN' ? 2 : 1; } // anonymize this log entry else if ($this->anonymize_log > 0 && strpos($message, 'Send:') === 0 && --$this->anonymize_log == 0) { $message = sprintf('Send: ****** [%d]', strlen($message) - 8); } if (($len = strlen($message)) > self::DEBUG_LINE_LENGTH) { $diff = $len - self::DEBUG_LINE_LENGTH; $message = substr($message, 0, self::DEBUG_LINE_LENGTH) . "... [truncated $diff bytes]"; } rcube::write_log('smtp', preg_replace('/\r\n$/', '', $message)); }
php
public function debug_handler(&$smtp, $message) { // catch AUTH commands and set anonymization flag for subsequent sends if (preg_match('/^Send: AUTH ([A-Z]+)/', $message, $m)) { $this->anonymize_log = $m[1] == 'LOGIN' ? 2 : 1; } // anonymize this log entry else if ($this->anonymize_log > 0 && strpos($message, 'Send:') === 0 && --$this->anonymize_log == 0) { $message = sprintf('Send: ****** [%d]', strlen($message) - 8); } if (($len = strlen($message)) > self::DEBUG_LINE_LENGTH) { $diff = $len - self::DEBUG_LINE_LENGTH; $message = substr($message, 0, self::DEBUG_LINE_LENGTH) . "... [truncated $diff bytes]"; } rcube::write_log('smtp', preg_replace('/\r\n$/', '', $message)); }
[ "public", "function", "debug_handler", "(", "&", "$", "smtp", ",", "$", "message", ")", "{", "// catch AUTH commands and set anonymization flag for subsequent sends", "if", "(", "preg_match", "(", "'/^Send: AUTH ([A-Z]+)/'", ",", "$", "message", ",", "$", "m", ")", ...
This is our own debug handler for the SMTP connection
[ "This", "is", "our", "own", "debug", "handler", "for", "the", "SMTP", "connection" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_smtp.php#L345-L363
train
netgen/NetgenInformationCollectionBundle
bundle/Core/Persistence/Gateway/DoctrineDatabase.php
DoctrineDatabase.getContentsWithCollectionsCount
public function getContentsWithCollectionsCount() { $query = $this->connection->createQueryBuilder(); $query->select( 'COUNT(DISTINCT eic.contentobject_id) AS count' ) ->from($this->connection->quoteIdentifier('ezinfocollection'), 'eic') ->innerJoin( 'eic', $this->connection->quoteIdentifier('ezcontentobject'), 'eco', $query->expr()->eq( $this->connection->quoteIdentifier('eic.contentobject_id'), $this->connection->quoteIdentifier('eco.id') ) ) ->leftJoin( 'eic', $this->connection->quoteIdentifier('ezcontentobject_tree'), 'ecot', $query->expr()->eq( $this->connection->quoteIdentifier('eic.contentobject_id'), $this->connection->quoteIdentifier('ecot.contentobject_id') ) ); $statement = $query->execute(); return (int)$statement->fetchColumn(); }
php
public function getContentsWithCollectionsCount() { $query = $this->connection->createQueryBuilder(); $query->select( 'COUNT(DISTINCT eic.contentobject_id) AS count' ) ->from($this->connection->quoteIdentifier('ezinfocollection'), 'eic') ->innerJoin( 'eic', $this->connection->quoteIdentifier('ezcontentobject'), 'eco', $query->expr()->eq( $this->connection->quoteIdentifier('eic.contentobject_id'), $this->connection->quoteIdentifier('eco.id') ) ) ->leftJoin( 'eic', $this->connection->quoteIdentifier('ezcontentobject_tree'), 'ecot', $query->expr()->eq( $this->connection->quoteIdentifier('eic.contentobject_id'), $this->connection->quoteIdentifier('ecot.contentobject_id') ) ); $statement = $query->execute(); return (int)$statement->fetchColumn(); }
[ "public", "function", "getContentsWithCollectionsCount", "(", ")", "{", "$", "query", "=", "$", "this", "->", "connection", "->", "createQueryBuilder", "(", ")", ";", "$", "query", "->", "select", "(", "'COUNT(DISTINCT eic.contentobject_id) AS count'", ")", "->", ...
Returns number of content objects that have any collection @return int @throws \Doctrine\DBAL\DBALException
[ "Returns", "number", "of", "content", "objects", "that", "have", "any", "collection" ]
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Core/Persistence/Gateway/DoctrineDatabase.php#L32-L61
train
netgen/NetgenInformationCollectionBundle
bundle/Core/Persistence/Gateway/DoctrineDatabase.php
DoctrineDatabase.getObjectsWithCollections
public function getObjectsWithCollections($limit, $offset) { $contentIdsQuery = $this->connection->createQueryBuilder(); $contentIdsQuery ->select("DISTINCT contentobject_id AS id") ->from($this->connection->quoteIdentifier('ezinfocollection')); $statement = $contentIdsQuery->execute(); $contents = []; foreach ($statement->fetchAll() as $content) { $contents[] = (int)$content['id']; } if (empty($contents)) { return []; } $query = $this->connection->createQueryBuilder(); $query ->select( "eco.id AS content_id", "ecot.main_node_id" ) ->from($this->connection->quoteIdentifier('ezcontentobject'), 'eco') ->leftJoin( 'eco', $this->connection->quoteIdentifier('ezcontentobject_tree'), 'ecot', $query->expr()->eq( $this->connection->quoteIdentifier('eco.id'), $this->connection->quoteIdentifier('ecot.contentobject_id') ) ) ->innerJoin( 'eco', $this->connection->quoteIdentifier('ezcontentclass'), 'ecc', $query->expr()->eq( $this->connection->quoteIdentifier('eco.contentclass_id'), $this->connection->quoteIdentifier('ecc.id') ) ) ->where( $query->expr()->eq('ecc.version', 0) ) ->andWhere($query->expr()->in('eco.id', $contents)) ->groupBy([ $this->connection->quoteIdentifier('ecot.main_node_id'), $this->connection->quoteIdentifier('content_id'), ]) ->setFirstResult($offset) ->setMaxResults($limit); $statement = $query->execute(); return $statement->fetchAll(PDO::FETCH_ASSOC); }
php
public function getObjectsWithCollections($limit, $offset) { $contentIdsQuery = $this->connection->createQueryBuilder(); $contentIdsQuery ->select("DISTINCT contentobject_id AS id") ->from($this->connection->quoteIdentifier('ezinfocollection')); $statement = $contentIdsQuery->execute(); $contents = []; foreach ($statement->fetchAll() as $content) { $contents[] = (int)$content['id']; } if (empty($contents)) { return []; } $query = $this->connection->createQueryBuilder(); $query ->select( "eco.id AS content_id", "ecot.main_node_id" ) ->from($this->connection->quoteIdentifier('ezcontentobject'), 'eco') ->leftJoin( 'eco', $this->connection->quoteIdentifier('ezcontentobject_tree'), 'ecot', $query->expr()->eq( $this->connection->quoteIdentifier('eco.id'), $this->connection->quoteIdentifier('ecot.contentobject_id') ) ) ->innerJoin( 'eco', $this->connection->quoteIdentifier('ezcontentclass'), 'ecc', $query->expr()->eq( $this->connection->quoteIdentifier('eco.contentclass_id'), $this->connection->quoteIdentifier('ecc.id') ) ) ->where( $query->expr()->eq('ecc.version', 0) ) ->andWhere($query->expr()->in('eco.id', $contents)) ->groupBy([ $this->connection->quoteIdentifier('ecot.main_node_id'), $this->connection->quoteIdentifier('content_id'), ]) ->setFirstResult($offset) ->setMaxResults($limit); $statement = $query->execute(); return $statement->fetchAll(PDO::FETCH_ASSOC); }
[ "public", "function", "getObjectsWithCollections", "(", "$", "limit", ",", "$", "offset", ")", "{", "$", "contentIdsQuery", "=", "$", "this", "->", "connection", "->", "createQueryBuilder", "(", ")", ";", "$", "contentIdsQuery", "->", "select", "(", "\"DISTINC...
Returns content objects with their collections @param int $limit @param int $offset @return array @throws \Doctrine\DBAL\DBALException
[ "Returns", "content", "objects", "with", "their", "collections" ]
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Core/Persistence/Gateway/DoctrineDatabase.php#L73-L130
train
netgen/NetgenInformationCollectionBundle
bundle/Core/Persistence/ContentTypeUtils.php
ContentTypeUtils.getFieldId
public function getFieldId($contentId, $fieldDefIdentifier) { $content = $this->contentService->loadContent($contentId); $contentType = $this->contentTypeService ->loadContentType($content->contentInfo->contentTypeId); $field = $contentType->getFieldDefinition($fieldDefIdentifier); if (!$field instanceof FieldDefinition) { throw new OutOfBoundsException(sprintf("ContentType does not contain field with identifier %s.", $fieldDefIdentifier)); } return $field->id; }
php
public function getFieldId($contentId, $fieldDefIdentifier) { $content = $this->contentService->loadContent($contentId); $contentType = $this->contentTypeService ->loadContentType($content->contentInfo->contentTypeId); $field = $contentType->getFieldDefinition($fieldDefIdentifier); if (!$field instanceof FieldDefinition) { throw new OutOfBoundsException(sprintf("ContentType does not contain field with identifier %s.", $fieldDefIdentifier)); } return $field->id; }
[ "public", "function", "getFieldId", "(", "$", "contentId", ",", "$", "fieldDefIdentifier", ")", "{", "$", "content", "=", "$", "this", "->", "contentService", "->", "loadContent", "(", "$", "contentId", ")", ";", "$", "contentType", "=", "$", "this", "->",...
Return field id for fiven field definition identifier @param int $contentId @param string $fieldDefIdentifier @return mixed @throws \OutOfBoundsException @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
[ "Return", "field", "id", "for", "fiven", "field", "definition", "identifier" ]
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Core/Persistence/ContentTypeUtils.php#L46-L60
train
netgen/NetgenInformationCollectionBundle
bundle/Core/Persistence/ContentTypeUtils.php
ContentTypeUtils.getInfoCollectorFields
public function getInfoCollectorFields($contentId) { $fields = []; $content = $this->contentService->loadContent($contentId); $contentType = $this->contentTypeService ->loadContentType($content->contentInfo->contentTypeId); foreach ($contentType->getFieldDefinitions() as $fieldDefinition) { if ($fieldDefinition->isInfoCollector) { $fields[$fieldDefinition->id] = $fieldDefinition->getName(); } } return $fields; }
php
public function getInfoCollectorFields($contentId) { $fields = []; $content = $this->contentService->loadContent($contentId); $contentType = $this->contentTypeService ->loadContentType($content->contentInfo->contentTypeId); foreach ($contentType->getFieldDefinitions() as $fieldDefinition) { if ($fieldDefinition->isInfoCollector) { $fields[$fieldDefinition->id] = $fieldDefinition->getName(); } } return $fields; }
[ "public", "function", "getInfoCollectorFields", "(", "$", "contentId", ")", "{", "$", "fields", "=", "[", "]", ";", "$", "content", "=", "$", "this", "->", "contentService", "->", "loadContent", "(", "$", "contentId", ")", ";", "$", "contentType", "=", "...
Returns fields that are marked as info collectors @param int $contentId @return array @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
[ "Returns", "fields", "that", "are", "marked", "as", "info", "collectors" ]
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Core/Persistence/ContentTypeUtils.php#L73-L90
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_user.php
rcube_user.get_prefs
function get_prefs() { if (isset($this->prefs)) { return $this->prefs; } $this->prefs = array(); if (!empty($this->language)) $this->prefs['language'] = $this->language; if ($this->ID) { // Preferences from session (write-master is unavailable) if (!empty($_SESSION['preferences'])) { // Check last write attempt time, try to write again (every 5 minutes) if ($_SESSION['preferences_time'] < time() - 5 * 60) { $saved_prefs = unserialize($_SESSION['preferences']); $this->rc->session->remove('preferences'); $this->rc->session->remove('preferences_time'); $this->save_prefs($saved_prefs); } else { $this->data['preferences'] = $_SESSION['preferences']; } } if ($this->data['preferences']) { $this->prefs += (array)unserialize($this->data['preferences']); } } return $this->prefs; }
php
function get_prefs() { if (isset($this->prefs)) { return $this->prefs; } $this->prefs = array(); if (!empty($this->language)) $this->prefs['language'] = $this->language; if ($this->ID) { // Preferences from session (write-master is unavailable) if (!empty($_SESSION['preferences'])) { // Check last write attempt time, try to write again (every 5 minutes) if ($_SESSION['preferences_time'] < time() - 5 * 60) { $saved_prefs = unserialize($_SESSION['preferences']); $this->rc->session->remove('preferences'); $this->rc->session->remove('preferences_time'); $this->save_prefs($saved_prefs); } else { $this->data['preferences'] = $_SESSION['preferences']; } } if ($this->data['preferences']) { $this->prefs += (array)unserialize($this->data['preferences']); } } return $this->prefs; }
[ "function", "get_prefs", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "prefs", ")", ")", "{", "return", "$", "this", "->", "prefs", ";", "}", "$", "this", "->", "prefs", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", ...
Get the preferences saved for this user @return array Hash array with prefs
[ "Get", "the", "preferences", "saved", "for", "this", "user" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_user.php#L134-L166
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_user.php
rcube_user.save_prefs
function save_prefs($a_user_prefs, $no_session = false) { if (!$this->ID) return false; $plugin = $this->rc->plugins->exec_hook('preferences_update', array( 'userid' => $this->ID, 'prefs' => $a_user_prefs, 'old' => (array)$this->get_prefs())); if (!empty($plugin['abort'])) { return; } $a_user_prefs = $plugin['prefs']; $old_prefs = $plugin['old']; $config = $this->rc->config; $defaults = $config->all(); // merge (partial) prefs array with existing settings $this->prefs = $save_prefs = $a_user_prefs + $old_prefs; unset($save_prefs['language']); // don't save prefs with default values if they haven't been changed yet // Warning: we use result of rcube_config::all() here instead of just get() (#5782) foreach ($a_user_prefs as $key => $value) { if ($value === null || (!isset($old_prefs[$key]) && $value === $defaults[$key])) { unset($save_prefs[$key]); } } $save_prefs = serialize($save_prefs); if (!$no_session) { $this->language = $_SESSION['language']; } $this->db->query( "UPDATE ".$this->db->table_name('users', true). " SET `preferences` = ?, `language` = ?". " WHERE `user_id` = ?", $save_prefs, $this->language, $this->ID); // Update success if ($this->db->affected_rows() !== false) { $this->data['preferences'] = $save_prefs; if (!$no_session) { $config->set_user_prefs($this->prefs); if (isset($_SESSION['preferences'])) { $this->rc->session->remove('preferences'); $this->rc->session->remove('preferences_time'); } } return true; } // Update error, but we are using replication (we have read-only DB connection) // and we are storing session not in the SQL database // we can store preferences in session and try to write later (see get_prefs()) else if (!$no_session && $this->db->is_replicated() && $config->get('session_storage', 'db') != 'db' ) { $_SESSION['preferences'] = $save_prefs; $_SESSION['preferences_time'] = time(); $config->set_user_prefs($this->prefs); $this->data['preferences'] = $save_prefs; } return false; }
php
function save_prefs($a_user_prefs, $no_session = false) { if (!$this->ID) return false; $plugin = $this->rc->plugins->exec_hook('preferences_update', array( 'userid' => $this->ID, 'prefs' => $a_user_prefs, 'old' => (array)$this->get_prefs())); if (!empty($plugin['abort'])) { return; } $a_user_prefs = $plugin['prefs']; $old_prefs = $plugin['old']; $config = $this->rc->config; $defaults = $config->all(); // merge (partial) prefs array with existing settings $this->prefs = $save_prefs = $a_user_prefs + $old_prefs; unset($save_prefs['language']); // don't save prefs with default values if they haven't been changed yet // Warning: we use result of rcube_config::all() here instead of just get() (#5782) foreach ($a_user_prefs as $key => $value) { if ($value === null || (!isset($old_prefs[$key]) && $value === $defaults[$key])) { unset($save_prefs[$key]); } } $save_prefs = serialize($save_prefs); if (!$no_session) { $this->language = $_SESSION['language']; } $this->db->query( "UPDATE ".$this->db->table_name('users', true). " SET `preferences` = ?, `language` = ?". " WHERE `user_id` = ?", $save_prefs, $this->language, $this->ID); // Update success if ($this->db->affected_rows() !== false) { $this->data['preferences'] = $save_prefs; if (!$no_session) { $config->set_user_prefs($this->prefs); if (isset($_SESSION['preferences'])) { $this->rc->session->remove('preferences'); $this->rc->session->remove('preferences_time'); } } return true; } // Update error, but we are using replication (we have read-only DB connection) // and we are storing session not in the SQL database // we can store preferences in session and try to write later (see get_prefs()) else if (!$no_session && $this->db->is_replicated() && $config->get('session_storage', 'db') != 'db' ) { $_SESSION['preferences'] = $save_prefs; $_SESSION['preferences_time'] = time(); $config->set_user_prefs($this->prefs); $this->data['preferences'] = $save_prefs; } return false; }
[ "function", "save_prefs", "(", "$", "a_user_prefs", ",", "$", "no_session", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "ID", ")", "return", "false", ";", "$", "plugin", "=", "$", "this", "->", "rc", "->", "plugins", "->", "exec_hook",...
Write the given user prefs to the user's record @param array $a_user_prefs User prefs to save @param bool $no_session Simplified language/preferences handling @return boolean True on success, False on failure
[ "Write", "the", "given", "user", "prefs", "to", "the", "user", "s", "record" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_user.php#L176-L246
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_user.php
rcube_user.get_hash
function get_hash() { $prefs = $this->get_prefs(); // generate a random hash and store it in user prefs if (empty($prefs['client_hash'])) { $prefs['client_hash'] = rcube_utils::random_bytes(16); $this->save_prefs(array('client_hash' => $prefs['client_hash'])); } return $prefs['client_hash']; }
php
function get_hash() { $prefs = $this->get_prefs(); // generate a random hash and store it in user prefs if (empty($prefs['client_hash'])) { $prefs['client_hash'] = rcube_utils::random_bytes(16); $this->save_prefs(array('client_hash' => $prefs['client_hash'])); } return $prefs['client_hash']; }
[ "function", "get_hash", "(", ")", "{", "$", "prefs", "=", "$", "this", "->", "get_prefs", "(", ")", ";", "// generate a random hash and store it in user prefs", "if", "(", "empty", "(", "$", "prefs", "[", "'client_hash'", "]", ")", ")", "{", "$", "prefs", ...
Generate a unique hash to identify this user whith
[ "Generate", "a", "unique", "hash", "to", "identify", "this", "user", "whith" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_user.php#L251-L262
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_user.php
rcube_user.get_identity
function get_identity($id = null) { $id = (int)$id; // cache identities for better performance if (!array_key_exists($id, $this->identities)) { $result = $this->list_identities($id ? "AND `identity_id` = $id" : ''); $this->identities[$id] = $result[0]; } return $this->identities[$id]; }
php
function get_identity($id = null) { $id = (int)$id; // cache identities for better performance if (!array_key_exists($id, $this->identities)) { $result = $this->list_identities($id ? "AND `identity_id` = $id" : ''); $this->identities[$id] = $result[0]; } return $this->identities[$id]; }
[ "function", "get_identity", "(", "$", "id", "=", "null", ")", "{", "$", "id", "=", "(", "int", ")", "$", "id", ";", "// cache identities for better performance", "if", "(", "!", "array_key_exists", "(", "$", "id", ",", "$", "this", "->", "identities", ")...
Get default identity of this user @param int $id Identity ID. If empty, the default identity is returned @return array Hash array with all cols of the identity record
[ "Get", "default", "identity", "of", "this", "user" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_user.php#L297-L307
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_user.php
rcube_user.list_identities
function list_identities($sql_add = '', $formatted = false) { $result = array(); $sql_result = $this->db->query( "SELECT * FROM ".$this->db->table_name('identities', true). " WHERE `del` <> 1 AND `user_id` = ?". ($sql_add ? " ".$sql_add : ""). " ORDER BY `standard` DESC, `name` ASC, `email` ASC, `identity_id` ASC", $this->ID); while ($sql_arr = $this->db->fetch_assoc($sql_result)) { if ($formatted) { $ascii_email = format_email($sql_arr['email']); $utf8_email = format_email(rcube_utils::idn_to_utf8($ascii_email)); $sql_arr['email_ascii'] = $ascii_email; $sql_arr['email'] = $utf8_email; $sql_arr['ident'] = format_email_recipient($ascii_email, $sql_arr['name']); } $result[] = $sql_arr; } return $result; }
php
function list_identities($sql_add = '', $formatted = false) { $result = array(); $sql_result = $this->db->query( "SELECT * FROM ".$this->db->table_name('identities', true). " WHERE `del` <> 1 AND `user_id` = ?". ($sql_add ? " ".$sql_add : ""). " ORDER BY `standard` DESC, `name` ASC, `email` ASC, `identity_id` ASC", $this->ID); while ($sql_arr = $this->db->fetch_assoc($sql_result)) { if ($formatted) { $ascii_email = format_email($sql_arr['email']); $utf8_email = format_email(rcube_utils::idn_to_utf8($ascii_email)); $sql_arr['email_ascii'] = $ascii_email; $sql_arr['email'] = $utf8_email; $sql_arr['ident'] = format_email_recipient($ascii_email, $sql_arr['name']); } $result[] = $sql_arr; } return $result; }
[ "function", "list_identities", "(", "$", "sql_add", "=", "''", ",", "$", "formatted", "=", "false", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "sql_result", "=", "$", "this", "->", "db", "->", "query", "(", "\"SELECT * FROM \"", ".", ...
Return a list of all identities linked with this user @param string $sql_add Optional WHERE clauses @param bool $formatted Format identity email and name @return array List of identities
[ "Return", "a", "list", "of", "all", "identities", "linked", "with", "this", "user" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_user.php#L317-L342
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_user.php
rcube_user.update_identity
function update_identity($iid, $data) { if (!$this->ID) return false; $query_cols = $query_params = array(); foreach ((array)$data as $col => $value) { $query_cols[] = $this->db->quote_identifier($col) . ' = ?'; $query_params[] = $value; } $query_params[] = $iid; $query_params[] = $this->ID; $sql = "UPDATE ".$this->db->table_name('identities', true). " SET `changed` = ".$this->db->now().", ".join(', ', $query_cols). " WHERE `identity_id` = ?". " AND `user_id` = ?". " AND `del` <> 1"; call_user_func_array(array($this->db, 'query'), array_merge(array($sql), $query_params)); // clear the cache $this->identities = array(); $this->emails = null; return $this->db->affected_rows(); }
php
function update_identity($iid, $data) { if (!$this->ID) return false; $query_cols = $query_params = array(); foreach ((array)$data as $col => $value) { $query_cols[] = $this->db->quote_identifier($col) . ' = ?'; $query_params[] = $value; } $query_params[] = $iid; $query_params[] = $this->ID; $sql = "UPDATE ".$this->db->table_name('identities', true). " SET `changed` = ".$this->db->now().", ".join(', ', $query_cols). " WHERE `identity_id` = ?". " AND `user_id` = ?". " AND `del` <> 1"; call_user_func_array(array($this->db, 'query'), array_merge(array($sql), $query_params)); // clear the cache $this->identities = array(); $this->emails = null; return $this->db->affected_rows(); }
[ "function", "update_identity", "(", "$", "iid", ",", "$", "data", ")", "{", "if", "(", "!", "$", "this", "->", "ID", ")", "return", "false", ";", "$", "query_cols", "=", "$", "query_params", "=", "array", "(", ")", ";", "foreach", "(", "(", "array"...
Update a specific identity record @param int $iid Identity ID @param array $data Hash array with col->value pairs to save @return boolean True if saved successfully, false if nothing changed
[ "Update", "a", "specific", "identity", "record" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_user.php#L351-L379
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_user.php
rcube_user.insert_identity
function insert_identity($data) { if (!$this->ID) return false; unset($data['user_id']); $insert_cols = array(); $insert_values = array(); foreach ((array)$data as $col => $value) { $insert_cols[] = $this->db->quote_identifier($col); $insert_values[] = $value; } $insert_cols[] = $this->db->quote_identifier('user_id'); $insert_values[] = $this->ID; $sql = "INSERT INTO ".$this->db->table_name('identities', true). " (`changed`, ".join(', ', $insert_cols).")". " VALUES (".$this->db->now().", ".join(', ', array_pad(array(), count($insert_values), '?')).")"; $insert = $this->db->query($sql, $insert_values); // clear the cache $this->identities = array(); $this->emails = null; return $this->db->insert_id('identities'); }
php
function insert_identity($data) { if (!$this->ID) return false; unset($data['user_id']); $insert_cols = array(); $insert_values = array(); foreach ((array)$data as $col => $value) { $insert_cols[] = $this->db->quote_identifier($col); $insert_values[] = $value; } $insert_cols[] = $this->db->quote_identifier('user_id'); $insert_values[] = $this->ID; $sql = "INSERT INTO ".$this->db->table_name('identities', true). " (`changed`, ".join(', ', $insert_cols).")". " VALUES (".$this->db->now().", ".join(', ', array_pad(array(), count($insert_values), '?')).")"; $insert = $this->db->query($sql, $insert_values); // clear the cache $this->identities = array(); $this->emails = null; return $this->db->insert_id('identities'); }
[ "function", "insert_identity", "(", "$", "data", ")", "{", "if", "(", "!", "$", "this", "->", "ID", ")", "return", "false", ";", "unset", "(", "$", "data", "[", "'user_id'", "]", ")", ";", "$", "insert_cols", "=", "array", "(", ")", ";", "$", "in...
Create a new identity record linked with this user @param array $data Hash array with col->value pairs to save @return int The inserted identity ID or false on error
[ "Create", "a", "new", "identity", "record", "linked", "with", "this", "user" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_user.php#L387-L416
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_user.php
rcube_user.delete_identity
function delete_identity($iid) { if (!$this->ID) return false; $sql_result = $this->db->query( "SELECT count(*) AS ident_count FROM ".$this->db->table_name('identities', true). " WHERE `user_id` = ? AND `del` <> 1", $this->ID); $sql_arr = $this->db->fetch_assoc($sql_result); // we'll not delete last identity if ($sql_arr['ident_count'] <= 1) return -1; $this->db->query( "UPDATE ".$this->db->table_name('identities', true). " SET `del` = 1, `changed` = ".$this->db->now(). " WHERE `user_id` = ?". " AND `identity_id` = ?", $this->ID, $iid); // clear the cache $this->identities = array(); $this->emails = null; return $this->db->affected_rows(); }
php
function delete_identity($iid) { if (!$this->ID) return false; $sql_result = $this->db->query( "SELECT count(*) AS ident_count FROM ".$this->db->table_name('identities', true). " WHERE `user_id` = ? AND `del` <> 1", $this->ID); $sql_arr = $this->db->fetch_assoc($sql_result); // we'll not delete last identity if ($sql_arr['ident_count'] <= 1) return -1; $this->db->query( "UPDATE ".$this->db->table_name('identities', true). " SET `del` = 1, `changed` = ".$this->db->now(). " WHERE `user_id` = ?". " AND `identity_id` = ?", $this->ID, $iid); // clear the cache $this->identities = array(); $this->emails = null; return $this->db->affected_rows(); }
[ "function", "delete_identity", "(", "$", "iid", ")", "{", "if", "(", "!", "$", "this", "->", "ID", ")", "return", "false", ";", "$", "sql_result", "=", "$", "this", "->", "db", "->", "query", "(", "\"SELECT count(*) AS ident_count FROM \"", ".", "$", "th...
Mark the given identity as deleted @param int $iid Identity ID @return boolean True if deleted successfully, false if nothing changed
[ "Mark", "the", "given", "identity", "as", "deleted" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_user.php#L424-L453
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_user.php
rcube_user.set_default
function set_default($iid) { if ($this->ID && $iid) { $this->db->query( "UPDATE ".$this->db->table_name('identities', true). " SET `standard` = '0'". " WHERE `user_id` = ? AND `identity_id` <> ?", $this->ID, $iid); unset($this->identities[0]); } }
php
function set_default($iid) { if ($this->ID && $iid) { $this->db->query( "UPDATE ".$this->db->table_name('identities', true). " SET `standard` = '0'". " WHERE `user_id` = ? AND `identity_id` <> ?", $this->ID, $iid); unset($this->identities[0]); } }
[ "function", "set_default", "(", "$", "iid", ")", "{", "if", "(", "$", "this", "->", "ID", "&&", "$", "iid", ")", "{", "$", "this", "->", "db", "->", "query", "(", "\"UPDATE \"", ".", "$", "this", "->", "db", "->", "table_name", "(", "'identities'",...
Make this identity the default one for this user @param int $iid The identity ID
[ "Make", "this", "identity", "the", "default", "one", "for", "this", "user" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_user.php#L460-L472
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_user.php
rcube_user.touch
function touch() { if ($this->ID) { $this->db->query( "UPDATE ".$this->db->table_name('users', true). " SET `last_login` = ".$this->db->now(). " WHERE `user_id` = ?", $this->ID); } }
php
function touch() { if ($this->ID) { $this->db->query( "UPDATE ".$this->db->table_name('users', true). " SET `last_login` = ".$this->db->now(). " WHERE `user_id` = ?", $this->ID); } }
[ "function", "touch", "(", ")", "{", "if", "(", "$", "this", "->", "ID", ")", "{", "$", "this", "->", "db", "->", "query", "(", "\"UPDATE \"", ".", "$", "this", "->", "db", "->", "table_name", "(", "'users'", ",", "true", ")", ".", "\" SET `last_log...
Update user's last_login timestamp
[ "Update", "user", "s", "last_login", "timestamp" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_user.php#L477-L486
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_user.php
rcube_user.failed_login
function failed_login() { if ($this->ID && ($rate = (int) $this->rc->config->get('login_rate_limit', 3))) { if (empty($this->data['failed_login'])) { $failed_login = new DateTime('now'); $counter = 1; } else { $failed_login = new DateTime($this->data['failed_login']); $threshold = new DateTime('- 60 seconds'); if ($failed_login < $threshold) { $failed_login = new DateTime('now'); $counter = 1; } } $this->db->query( "UPDATE " . $this->db->table_name('users', true) . " SET `failed_login` = ?" . ", `failed_login_counter` = " . ($counter ?: "`failed_login_counter` + 1") . " WHERE `user_id` = ?", $failed_login, $this->ID); } }
php
function failed_login() { if ($this->ID && ($rate = (int) $this->rc->config->get('login_rate_limit', 3))) { if (empty($this->data['failed_login'])) { $failed_login = new DateTime('now'); $counter = 1; } else { $failed_login = new DateTime($this->data['failed_login']); $threshold = new DateTime('- 60 seconds'); if ($failed_login < $threshold) { $failed_login = new DateTime('now'); $counter = 1; } } $this->db->query( "UPDATE " . $this->db->table_name('users', true) . " SET `failed_login` = ?" . ", `failed_login_counter` = " . ($counter ?: "`failed_login_counter` + 1") . " WHERE `user_id` = ?", $failed_login, $this->ID); } }
[ "function", "failed_login", "(", ")", "{", "if", "(", "$", "this", "->", "ID", "&&", "(", "$", "rate", "=", "(", "int", ")", "$", "this", "->", "rc", "->", "config", "->", "get", "(", "'login_rate_limit'", ",", "3", ")", ")", ")", "{", "if", "(...
Update user's failed_login timestamp and counter
[ "Update", "user", "s", "failed_login", "timestamp", "and", "counter" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_user.php#L491-L515
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_user.php
rcube_user.query
static function query($user, $host) { $dbh = rcube::get_instance()->get_dbh(); $config = rcube::get_instance()->config; // query for matching user name $sql_result = $dbh->query("SELECT * FROM " . $dbh->table_name('users', true) ." WHERE `mail_host` = ? AND `username` = ?", $host, $user); $sql_arr = $dbh->fetch_assoc($sql_result); // username not found, try aliases from identities if (empty($sql_arr) && $config->get('user_aliases') && strpos($user, '@')) { $sql_result = $dbh->limitquery("SELECT u.*" ." FROM " . $dbh->table_name('users', true) . " u" ." JOIN " . $dbh->table_name('identities', true) . " i ON (i.`user_id` = u.`user_id`)" ." WHERE `email` = ? AND `del` <> 1", 0, 1, $user); $sql_arr = $dbh->fetch_assoc($sql_result); } // user already registered -> overwrite username if ($sql_arr) { return new rcube_user($sql_arr['user_id'], $sql_arr); } return false; }
php
static function query($user, $host) { $dbh = rcube::get_instance()->get_dbh(); $config = rcube::get_instance()->config; // query for matching user name $sql_result = $dbh->query("SELECT * FROM " . $dbh->table_name('users', true) ." WHERE `mail_host` = ? AND `username` = ?", $host, $user); $sql_arr = $dbh->fetch_assoc($sql_result); // username not found, try aliases from identities if (empty($sql_arr) && $config->get('user_aliases') && strpos($user, '@')) { $sql_result = $dbh->limitquery("SELECT u.*" ." FROM " . $dbh->table_name('users', true) . " u" ." JOIN " . $dbh->table_name('identities', true) . " i ON (i.`user_id` = u.`user_id`)" ." WHERE `email` = ? AND `del` <> 1", 0, 1, $user); $sql_arr = $dbh->fetch_assoc($sql_result); } // user already registered -> overwrite username if ($sql_arr) { return new rcube_user($sql_arr['user_id'], $sql_arr); } return false; }
[ "static", "function", "query", "(", "$", "user", ",", "$", "host", ")", "{", "$", "dbh", "=", "rcube", "::", "get_instance", "(", ")", "->", "get_dbh", "(", ")", ";", "$", "config", "=", "rcube", "::", "get_instance", "(", ")", "->", "config", ";",...
Find a user record matching the given name and host @param string $user IMAP user name @param string $host IMAP host name @return rcube_user New user instance
[ "Find", "a", "user", "record", "matching", "the", "given", "name", "and", "host" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_user.php#L554-L581
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_user.php
rcube_user.email2user
static function email2user($email) { $rcube = rcube::get_instance(); $plugin = $rcube->plugins->exec_hook('email2user', array('email' => $email, 'user' => NULL)); return $plugin['user']; }
php
static function email2user($email) { $rcube = rcube::get_instance(); $plugin = $rcube->plugins->exec_hook('email2user', array('email' => $email, 'user' => NULL)); return $plugin['user']; }
[ "static", "function", "email2user", "(", "$", "email", ")", "{", "$", "rcube", "=", "rcube", "::", "get_instance", "(", ")", ";", "$", "plugin", "=", "$", "rcube", "->", "plugins", "->", "exec_hook", "(", "'email2user'", ",", "array", "(", "'email'", "...
Resolve username using a virtuser plugins @param string $email E-mail address to resolve @return string Resolved IMAP username
[ "Resolve", "username", "using", "a", "virtuser", "plugins" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_user.php#L702-L709
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_user.php
rcube_user.user2email
static function user2email($user, $first=true, $extended=false) { $rcube = rcube::get_instance(); $plugin = $rcube->plugins->exec_hook('user2email', array('email' => NULL, 'user' => $user, 'first' => $first, 'extended' => $extended)); return empty($plugin['email']) ? NULL : $plugin['email']; }
php
static function user2email($user, $first=true, $extended=false) { $rcube = rcube::get_instance(); $plugin = $rcube->plugins->exec_hook('user2email', array('email' => NULL, 'user' => $user, 'first' => $first, 'extended' => $extended)); return empty($plugin['email']) ? NULL : $plugin['email']; }
[ "static", "function", "user2email", "(", "$", "user", ",", "$", "first", "=", "true", ",", "$", "extended", "=", "false", ")", "{", "$", "rcube", "=", "rcube", "::", "get_instance", "(", ")", ";", "$", "plugin", "=", "$", "rcube", "->", "plugins", ...
Resolve e-mail address from virtuser plugins @param string $user User name @param boolean $first If true returns first found entry @param boolean $extended If true returns email as array (email and name for identity) @return mixed Resolved e-mail address string or array of strings
[ "Resolve", "e", "-", "mail", "address", "from", "virtuser", "plugins" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_user.php#L719-L727
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_user.php
rcube_user.list_searches
function list_searches($type) { $plugin = $this->rc->plugins->exec_hook('saved_search_list', array('type' => $type)); if ($plugin['abort']) { return (array) $plugin['result']; } $result = array(); $sql_result = $this->db->query( "SELECT `search_id` AS id, `name`" ." FROM ".$this->db->table_name('searches', true) ." WHERE `user_id` = ? AND `type` = ?" ." ORDER BY `name`", (int) $this->ID, (int) $type); while ($sql_arr = $this->db->fetch_assoc($sql_result)) { $sql_arr['data'] = unserialize($sql_arr['data']); $result[$sql_arr['id']] = $sql_arr; } return $result; }
php
function list_searches($type) { $plugin = $this->rc->plugins->exec_hook('saved_search_list', array('type' => $type)); if ($plugin['abort']) { return (array) $plugin['result']; } $result = array(); $sql_result = $this->db->query( "SELECT `search_id` AS id, `name`" ." FROM ".$this->db->table_name('searches', true) ." WHERE `user_id` = ? AND `type` = ?" ." ORDER BY `name`", (int) $this->ID, (int) $type); while ($sql_arr = $this->db->fetch_assoc($sql_result)) { $sql_arr['data'] = unserialize($sql_arr['data']); $result[$sql_arr['id']] = $sql_arr; } return $result; }
[ "function", "list_searches", "(", "$", "type", ")", "{", "$", "plugin", "=", "$", "this", "->", "rc", "->", "plugins", "->", "exec_hook", "(", "'saved_search_list'", ",", "array", "(", "'type'", "=>", "$", "type", ")", ")", ";", "if", "(", "$", "plug...
Return a list of saved searches linked with this user @param int $type Search type @return array List of saved searches indexed by search ID
[ "Return", "a", "list", "of", "saved", "searches", "linked", "with", "this", "user" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_user.php#L736-L759
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_user.php
rcube_user.get_search
function get_search($id) { $plugin = $this->rc->plugins->exec_hook('saved_search_get', array('id' => $id)); if ($plugin['abort']) { return $plugin['result']; } $sql_result = $this->db->query( "SELECT `name`, `data`, `type`" . " FROM ".$this->db->table_name('searches', true) . " WHERE `user_id` = ?" ." AND `search_id` = ?", (int) $this->ID, (int) $id); while ($sql_arr = $this->db->fetch_assoc($sql_result)) { return array( 'id' => $id, 'name' => $sql_arr['name'], 'type' => $sql_arr['type'], 'data' => unserialize($sql_arr['data']), ); } return null; }
php
function get_search($id) { $plugin = $this->rc->plugins->exec_hook('saved_search_get', array('id' => $id)); if ($plugin['abort']) { return $plugin['result']; } $sql_result = $this->db->query( "SELECT `name`, `data`, `type`" . " FROM ".$this->db->table_name('searches', true) . " WHERE `user_id` = ?" ." AND `search_id` = ?", (int) $this->ID, (int) $id); while ($sql_arr = $this->db->fetch_assoc($sql_result)) { return array( 'id' => $id, 'name' => $sql_arr['name'], 'type' => $sql_arr['type'], 'data' => unserialize($sql_arr['data']), ); } return null; }
[ "function", "get_search", "(", "$", "id", ")", "{", "$", "plugin", "=", "$", "this", "->", "rc", "->", "plugins", "->", "exec_hook", "(", "'saved_search_get'", ",", "array", "(", "'id'", "=>", "$", "id", ")", ")", ";", "if", "(", "$", "plugin", "["...
Return saved search data. @param int $id Row identifier @return array Data
[ "Return", "saved", "search", "data", "." ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_user.php#L768-L793
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_user.php
rcube_user.delete_search
function delete_search($sid) { if (!$this->ID) return false; $this->db->query( "DELETE FROM ".$this->db->table_name('searches', true) ." WHERE `user_id` = ?" ." AND `search_id` = ?", (int) $this->ID, $sid); return $this->db->affected_rows(); }
php
function delete_search($sid) { if (!$this->ID) return false; $this->db->query( "DELETE FROM ".$this->db->table_name('searches', true) ." WHERE `user_id` = ?" ." AND `search_id` = ?", (int) $this->ID, $sid); return $this->db->affected_rows(); }
[ "function", "delete_search", "(", "$", "sid", ")", "{", "if", "(", "!", "$", "this", "->", "ID", ")", "return", "false", ";", "$", "this", "->", "db", "->", "query", "(", "\"DELETE FROM \"", ".", "$", "this", "->", "db", "->", "table_name", "(", "'...
Deletes given saved search record @param int $sid Search ID @return boolean True if deleted successfully, false if nothing changed
[ "Deletes", "given", "saved", "search", "record" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_user.php#L802-L814
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_user.php
rcube_user.insert_search
function insert_search($data) { if (!$this->ID) return false; $insert_cols[] = 'user_id'; $insert_values[] = (int) $this->ID; $insert_cols[] = $this->db->quote_identifier('type'); $insert_values[] = (int) $data['type']; $insert_cols[] = $this->db->quote_identifier('name'); $insert_values[] = $data['name']; $insert_cols[] = $this->db->quote_identifier('data'); $insert_values[] = serialize($data['data']); $sql = "INSERT INTO ".$this->db->table_name('searches', true) ." (".join(', ', $insert_cols).")" ." VALUES (".join(', ', array_pad(array(), count($insert_values), '?')).")"; $insert = $this->db->query($sql, $insert_values); return $this->db->affected_rows($insert) ? $this->db->insert_id('searches') : false; }
php
function insert_search($data) { if (!$this->ID) return false; $insert_cols[] = 'user_id'; $insert_values[] = (int) $this->ID; $insert_cols[] = $this->db->quote_identifier('type'); $insert_values[] = (int) $data['type']; $insert_cols[] = $this->db->quote_identifier('name'); $insert_values[] = $data['name']; $insert_cols[] = $this->db->quote_identifier('data'); $insert_values[] = serialize($data['data']); $sql = "INSERT INTO ".$this->db->table_name('searches', true) ." (".join(', ', $insert_cols).")" ." VALUES (".join(', ', array_pad(array(), count($insert_values), '?')).")"; $insert = $this->db->query($sql, $insert_values); return $this->db->affected_rows($insert) ? $this->db->insert_id('searches') : false; }
[ "function", "insert_search", "(", "$", "data", ")", "{", "if", "(", "!", "$", "this", "->", "ID", ")", "return", "false", ";", "$", "insert_cols", "[", "]", "=", "'user_id'", ";", "$", "insert_values", "[", "]", "=", "(", "int", ")", "$", "this", ...
Create a new saved search record linked with this user @param array $data Hash array with col->value pairs to save @return int The inserted search ID or false on error
[ "Create", "a", "new", "saved", "search", "record", "linked", "with", "this", "user" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_user.php#L823-L844
train
i-MSCP/roundcube
roundcubemail/plugins/identicon/identicon.php
identicon.contact_photo
function contact_photo($args) { // pre-conditions, exit if photo already exists or invalid input if (!empty($args['url']) || !empty($args['data']) || (empty($args['record']) && empty($args['email'])) ) { return $args; } $rcmail = rcmail::get_instance(); // supporting edit/add action may be tricky, let's not do this if ($rcmail->action == 'show' || $rcmail->action == 'photo') { $email = $args['email']; if (!$email && $args['record']) { $addresses = rcube_addressbook::get_col_values('email', $args['record'], true); if (!empty($addresses)) { $email = $addresses[0]; } } if ($email) { require_once __DIR__ . '/identicon_engine.php'; $identicon = new identicon_engine($email); if ($rcmail->action == 'show') { // set photo URL using data-uri if (($icon = $identicon->getBinary()) && ($icon = base64_encode($icon))) { $mimetype =$identicon->getMimetype(); $args['url'] = sprintf('data:%s;base64,%s', $mimetype, $icon); } } else { // send the icon to the browser $identicon = new identicon_engine($email); if ($identicon->sendOutput()) { exit; } } } } return $args; }
php
function contact_photo($args) { // pre-conditions, exit if photo already exists or invalid input if (!empty($args['url']) || !empty($args['data']) || (empty($args['record']) && empty($args['email'])) ) { return $args; } $rcmail = rcmail::get_instance(); // supporting edit/add action may be tricky, let's not do this if ($rcmail->action == 'show' || $rcmail->action == 'photo') { $email = $args['email']; if (!$email && $args['record']) { $addresses = rcube_addressbook::get_col_values('email', $args['record'], true); if (!empty($addresses)) { $email = $addresses[0]; } } if ($email) { require_once __DIR__ . '/identicon_engine.php'; $identicon = new identicon_engine($email); if ($rcmail->action == 'show') { // set photo URL using data-uri if (($icon = $identicon->getBinary()) && ($icon = base64_encode($icon))) { $mimetype =$identicon->getMimetype(); $args['url'] = sprintf('data:%s;base64,%s', $mimetype, $icon); } } else { // send the icon to the browser $identicon = new identicon_engine($email); if ($identicon->sendOutput()) { exit; } } } } return $args; }
[ "function", "contact_photo", "(", "$", "args", ")", "{", "// pre-conditions, exit if photo already exists or invalid input", "if", "(", "!", "empty", "(", "$", "args", "[", "'url'", "]", ")", "||", "!", "empty", "(", "$", "args", "[", "'data'", "]", ")", "||...
'contact_photo' hook handler to inject an identicon image
[ "contact_photo", "hook", "handler", "to", "inject", "an", "identicon", "image" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/identicon/identicon.php#L33-L77
train
netgen/NetgenInformationCollectionBundle
bundle/Controller/Admin/AdminController.php
AdminController.overviewAction
public function overviewAction(Request $request) { $this->denyAccessUnlessGranted('ez:infocollector:read'); $adapter = new InformationCollectionContentsAdapter($this->service, Query::count()); $pager = $this->getPager($adapter, (int) $request->query->get('page')); return $this->render("NetgenInformationCollectionBundle:admin:overview.html.twig", ['objects' => $pager]); }
php
public function overviewAction(Request $request) { $this->denyAccessUnlessGranted('ez:infocollector:read'); $adapter = new InformationCollectionContentsAdapter($this->service, Query::count()); $pager = $this->getPager($adapter, (int) $request->query->get('page')); return $this->render("NetgenInformationCollectionBundle:admin:overview.html.twig", ['objects' => $pager]); }
[ "public", "function", "overviewAction", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "denyAccessUnlessGranted", "(", "'ez:infocollector:read'", ")", ";", "$", "adapter", "=", "new", "InformationCollectionContentsAdapter", "(", "$", "this", "->", "s...
Displays overview page @param \Symfony\Component\HttpFoundation\Request $request @return \Symfony\Component\HttpFoundation\Response
[ "Displays", "overview", "page" ]
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Controller/Admin/AdminController.php#L68-L76
train
netgen/NetgenInformationCollectionBundle
bundle/Controller/Admin/AdminController.php
AdminController.collectionListAction
public function collectionListAction(Request $request, $contentId) { $this->denyAccessUnlessGranted('ez:infocollector:read'); $content = $this->contentService->loadContent($contentId); $query = Query::withContent($contentId); $adapter = new InformationCollectionCollectionListAdapter($this->service, $query); $pager = $this->getPager($adapter, (int)$request->query->get('page')); return $this->render("NetgenInformationCollectionBundle:admin:collection_list.html.twig", [ 'objects' => $pager, 'content' => $content, ]); }
php
public function collectionListAction(Request $request, $contentId) { $this->denyAccessUnlessGranted('ez:infocollector:read'); $content = $this->contentService->loadContent($contentId); $query = Query::withContent($contentId); $adapter = new InformationCollectionCollectionListAdapter($this->service, $query); $pager = $this->getPager($adapter, (int)$request->query->get('page')); return $this->render("NetgenInformationCollectionBundle:admin:collection_list.html.twig", [ 'objects' => $pager, 'content' => $content, ]); }
[ "public", "function", "collectionListAction", "(", "Request", "$", "request", ",", "$", "contentId", ")", "{", "$", "this", "->", "denyAccessUnlessGranted", "(", "'ez:infocollector:read'", ")", ";", "$", "content", "=", "$", "this", "->", "contentService", "->",...
Displays list of collection for selected Content @param \Symfony\Component\HttpFoundation\Request $request @param int $contentId @return \Symfony\Component\HttpFoundation\Response
[ "Displays", "list", "of", "collection", "for", "selected", "Content" ]
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Controller/Admin/AdminController.php#L86-L99
train
netgen/NetgenInformationCollectionBundle
bundle/Controller/Admin/AdminController.php
AdminController.searchAction
public function searchAction(Request $request, $contentId) { $this->denyAccessUnlessGranted('ez:infocollector:read'); $content = $this->contentService->loadContent($contentId); $query = new Query([ 'contentId' => $contentId, 'searchText' => $request->query->get('searchText'), ]); $adapter = new InformationCollectionCollectionListSearchAdapter($this->service, $query); $pager = $this->getPager($adapter, (int)$request->query->get('page')); return $this->render("NetgenInformationCollectionBundle:admin:collection_list.html.twig", [ 'objects' => $pager, 'content' => $content, ] ); }
php
public function searchAction(Request $request, $contentId) { $this->denyAccessUnlessGranted('ez:infocollector:read'); $content = $this->contentService->loadContent($contentId); $query = new Query([ 'contentId' => $contentId, 'searchText' => $request->query->get('searchText'), ]); $adapter = new InformationCollectionCollectionListSearchAdapter($this->service, $query); $pager = $this->getPager($adapter, (int)$request->query->get('page')); return $this->render("NetgenInformationCollectionBundle:admin:collection_list.html.twig", [ 'objects' => $pager, 'content' => $content, ] ); }
[ "public", "function", "searchAction", "(", "Request", "$", "request", ",", "$", "contentId", ")", "{", "$", "this", "->", "denyAccessUnlessGranted", "(", "'ez:infocollector:read'", ")", ";", "$", "content", "=", "$", "this", "->", "contentService", "->", "load...
Handles collection search @param \Symfony\Component\HttpFoundation\Request $request @param int $contentId @return \Symfony\Component\HttpFoundation\Response
[ "Handles", "collection", "search" ]
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Controller/Admin/AdminController.php#L109-L128
train
netgen/NetgenInformationCollectionBundle
bundle/Controller/Admin/AdminController.php
AdminController.viewAction
public function viewAction($collectionId) { $this->denyAccessUnlessGranted('ez:infocollector:read'); $collection = $this->service->getCollection(new Query(['collectionId' => $collectionId])); return $this->render("NetgenInformationCollectionBundle:admin:view.html.twig", [ 'collection' => $collection, 'content' => $collection->content, ]); }
php
public function viewAction($collectionId) { $this->denyAccessUnlessGranted('ez:infocollector:read'); $collection = $this->service->getCollection(new Query(['collectionId' => $collectionId])); return $this->render("NetgenInformationCollectionBundle:admin:view.html.twig", [ 'collection' => $collection, 'content' => $collection->content, ]); }
[ "public", "function", "viewAction", "(", "$", "collectionId", ")", "{", "$", "this", "->", "denyAccessUnlessGranted", "(", "'ez:infocollector:read'", ")", ";", "$", "collection", "=", "$", "this", "->", "service", "->", "getCollection", "(", "new", "Query", "(...
Displays individual collection details @param int $collectionId @return \Symfony\Component\HttpFoundation\Response
[ "Displays", "individual", "collection", "details" ]
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Controller/Admin/AdminController.php#L137-L147
train
netgen/NetgenInformationCollectionBundle
bundle/Controller/Admin/AdminController.php
AdminController.handleContentsAction
public function handleContentsAction(Request $request) { $this->denyAccessUnlessGranted('ez:infocollector:read'); $contents = $request->request->get('ContentId', []); $count = count($contents); if (empty($contents)) { $this->addFlashMessage('errors', 'contents_not_selected'); return $this->redirectToRoute('netgen_information_collection.route.admin.overview'); } if ($request->request->has('DeleteCollectionByContentAction')) { $query = new Query([ 'contents' => $contents, ]); $this->service->deleteCollectionByContent($query); $this->addFlashMessage('success', 'content_removed', $count); return $this->redirectToRoute('netgen_information_collection.route.admin.overview'); } $this->addFlashMessage('error', 'something_went_wrong'); return $this->redirectToRoute('netgen_information_collection.route.admin.overview'); }
php
public function handleContentsAction(Request $request) { $this->denyAccessUnlessGranted('ez:infocollector:read'); $contents = $request->request->get('ContentId', []); $count = count($contents); if (empty($contents)) { $this->addFlashMessage('errors', 'contents_not_selected'); return $this->redirectToRoute('netgen_information_collection.route.admin.overview'); } if ($request->request->has('DeleteCollectionByContentAction')) { $query = new Query([ 'contents' => $contents, ]); $this->service->deleteCollectionByContent($query); $this->addFlashMessage('success', 'content_removed', $count); return $this->redirectToRoute('netgen_information_collection.route.admin.overview'); } $this->addFlashMessage('error', 'something_went_wrong'); return $this->redirectToRoute('netgen_information_collection.route.admin.overview'); }
[ "public", "function", "handleContentsAction", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "denyAccessUnlessGranted", "(", "'ez:infocollector:read'", ")", ";", "$", "contents", "=", "$", "request", "->", "request", "->", "get", "(", "'ContentId'"...
Handles actions performed on overview page @param \Symfony\Component\HttpFoundation\Request $request @return \Symfony\Component\HttpFoundation\RedirectResponse
[ "Handles", "actions", "performed", "on", "overview", "page" ]
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Controller/Admin/AdminController.php#L156-L183
train
netgen/NetgenInformationCollectionBundle
bundle/Controller/Admin/AdminController.php
AdminController.handleCollectionListAction
public function handleCollectionListAction(Request $request) { $this->denyAccessUnlessGranted('ez:infocollector:read'); $contentId = $request->request->get('ContentId'); $collections = $request->request->get('CollectionId', []); $count = count($collections); if (empty($collections)) { $this->addFlashMessage('errors', 'collections_not_selected'); return $this->redirectToRoute('netgen_information_collection.route.admin.collection_list', ['contentId' => $contentId]); } if ($request->request->has('DeleteCollectionAction')) { $query = new Query([ 'contentId' => $contentId, 'collections' => $collections, ]); $this->service->deleteCollections($query); $this->addFlashMessage('success', 'collection_removed', $count); return $this->redirectToRoute('netgen_information_collection.route.admin.collection_list', ['contentId' => $contentId]); } if ($request->request->has('AnonymizeCollectionAction')) { foreach ($collections as $collection) { $this->anonymizer->anonymizeCollection($collection); } $this->addFlashMessage('success', 'collection_anonymized', $count); return $this->redirectToRoute('netgen_information_collection.route.admin.collection_list', ['contentId' => $contentId]); } $this->addFlashMessage('error', 'something_went_wrong'); return $this->redirectToRoute('netgen_information_collection.route.admin.collection_list', ['contentId' => $contentId]); }
php
public function handleCollectionListAction(Request $request) { $this->denyAccessUnlessGranted('ez:infocollector:read'); $contentId = $request->request->get('ContentId'); $collections = $request->request->get('CollectionId', []); $count = count($collections); if (empty($collections)) { $this->addFlashMessage('errors', 'collections_not_selected'); return $this->redirectToRoute('netgen_information_collection.route.admin.collection_list', ['contentId' => $contentId]); } if ($request->request->has('DeleteCollectionAction')) { $query = new Query([ 'contentId' => $contentId, 'collections' => $collections, ]); $this->service->deleteCollections($query); $this->addFlashMessage('success', 'collection_removed', $count); return $this->redirectToRoute('netgen_information_collection.route.admin.collection_list', ['contentId' => $contentId]); } if ($request->request->has('AnonymizeCollectionAction')) { foreach ($collections as $collection) { $this->anonymizer->anonymizeCollection($collection); } $this->addFlashMessage('success', 'collection_anonymized', $count); return $this->redirectToRoute('netgen_information_collection.route.admin.collection_list', ['contentId' => $contentId]); } $this->addFlashMessage('error', 'something_went_wrong'); return $this->redirectToRoute('netgen_information_collection.route.admin.collection_list', ['contentId' => $contentId]); }
[ "public", "function", "handleCollectionListAction", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "denyAccessUnlessGranted", "(", "'ez:infocollector:read'", ")", ";", "$", "contentId", "=", "$", "request", "->", "request", "->", "get", "(", "'Cont...
Handles actions performed on collection list page @param \Symfony\Component\HttpFoundation\Request $request @return \Symfony\Component\HttpFoundation\RedirectResponse
[ "Handles", "actions", "performed", "on", "collection", "list", "page" ]
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Controller/Admin/AdminController.php#L192-L232
train
netgen/NetgenInformationCollectionBundle
bundle/Controller/Admin/AdminController.php
AdminController.handleCollectionAction
public function handleCollectionAction(Request $request) { $this->denyAccessUnlessGranted('ez:infocollector:read'); $collectionId = $request->request->get('CollectionId'); $contentId = $request->request->get('ContentId'); $fields = $request->request->get('FieldId', []); $count = count($fields); if ( ($request->request->has('AnonymizeFieldAction') || $request->request->has('DeleteFieldAction')) && empty($fields) ) { $this->addFlashMessage('errors', 'fields_not_selected'); return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]); } if ($request->request->has('DeleteFieldAction')) { $query = new Query([ 'contentId' => $contentId, 'collectionId' => $collectionId, 'fields' => $fields, ]); $this->service->deleteCollectionFields($query); $this->addFlashMessage('success', 'field_removed', $count); return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]); } if ($request->request->has('AnonymizeFieldAction')) { $this->anonymizer->anonymizeCollection($collectionId, $fields); $this->addFlashMessage('success', 'field_anonymized', $count); return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]); } if ($request->request->has('DeleteCollectionAction')) { $query = new Query([ 'contentId' => $contentId, 'collections' => [$collectionId], ]); $this->service->deleteCollections($query); $this->addFlashMessage("success", "collection_removed"); return $this->redirectToRoute('netgen_information_collection.route.admin.collection_list', ['contentId' => $contentId]); } if ($request->request->has('AnonymizeCollectionAction')) { $this->anonymizer->anonymizeCollection($collectionId); $this->addFlashMessage("success", "collection_anonymized"); return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]); } $this->addFlashMessage('error', 'something_went_wrong'); return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]); }
php
public function handleCollectionAction(Request $request) { $this->denyAccessUnlessGranted('ez:infocollector:read'); $collectionId = $request->request->get('CollectionId'); $contentId = $request->request->get('ContentId'); $fields = $request->request->get('FieldId', []); $count = count($fields); if ( ($request->request->has('AnonymizeFieldAction') || $request->request->has('DeleteFieldAction')) && empty($fields) ) { $this->addFlashMessage('errors', 'fields_not_selected'); return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]); } if ($request->request->has('DeleteFieldAction')) { $query = new Query([ 'contentId' => $contentId, 'collectionId' => $collectionId, 'fields' => $fields, ]); $this->service->deleteCollectionFields($query); $this->addFlashMessage('success', 'field_removed', $count); return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]); } if ($request->request->has('AnonymizeFieldAction')) { $this->anonymizer->anonymizeCollection($collectionId, $fields); $this->addFlashMessage('success', 'field_anonymized', $count); return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]); } if ($request->request->has('DeleteCollectionAction')) { $query = new Query([ 'contentId' => $contentId, 'collections' => [$collectionId], ]); $this->service->deleteCollections($query); $this->addFlashMessage("success", "collection_removed"); return $this->redirectToRoute('netgen_information_collection.route.admin.collection_list', ['contentId' => $contentId]); } if ($request->request->has('AnonymizeCollectionAction')) { $this->anonymizer->anonymizeCollection($collectionId); $this->addFlashMessage("success", "collection_anonymized"); return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]); } $this->addFlashMessage('error', 'something_went_wrong'); return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]); }
[ "public", "function", "handleCollectionAction", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "denyAccessUnlessGranted", "(", "'ez:infocollector:read'", ")", ";", "$", "collectionId", "=", "$", "request", "->", "request", "->", "get", "(", "'Colle...
Handles action on collection details page @param \Symfony\Component\HttpFoundation\Request $request @return \Symfony\Component\HttpFoundation\RedirectResponse
[ "Handles", "action", "on", "collection", "details", "page" ]
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Controller/Admin/AdminController.php#L241-L304
train
netgen/NetgenInformationCollectionBundle
bundle/Controller/Admin/AdminController.php
AdminController.getPager
protected function getPager(AdapterInterface $adapter, $currentPage) { $currentPage = (int) $currentPage; $pager = new Pagerfanta($adapter); $pager->setNormalizeOutOfRangePages(true); $pager->setMaxPerPage( $this->configResolver->getParameter('admin.max_per_page', 'netgen_information_collection') ); $pager->setCurrentPage($currentPage > 0 ? $currentPage : 1); return $pager; }
php
protected function getPager(AdapterInterface $adapter, $currentPage) { $currentPage = (int) $currentPage; $pager = new Pagerfanta($adapter); $pager->setNormalizeOutOfRangePages(true); $pager->setMaxPerPage( $this->configResolver->getParameter('admin.max_per_page', 'netgen_information_collection') ); $pager->setCurrentPage($currentPage > 0 ? $currentPage : 1); return $pager; }
[ "protected", "function", "getPager", "(", "AdapterInterface", "$", "adapter", ",", "$", "currentPage", ")", "{", "$", "currentPage", "=", "(", "int", ")", "$", "currentPage", ";", "$", "pager", "=", "new", "Pagerfanta", "(", "$", "adapter", ")", ";", "$"...
Returns configured instance of Pagerfanta @param \Pagerfanta\Adapter\AdapterInterface $adapter @param $currentPage @return \Pagerfanta\Pagerfanta
[ "Returns", "configured", "instance", "of", "Pagerfanta" ]
3ed7a2b33b1e80d3a0d9ee607eab495396044b29
https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Controller/Admin/AdminController.php#L335-L346
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_string_replacer.php
rcube_string_replacer.add
public function add($str) { $i = count($this->values); $this->values[$i] = $str; return $i; }
php
public function add($str) { $i = count($this->values); $this->values[$i] = $str; return $i; }
[ "public", "function", "add", "(", "$", "str", ")", "{", "$", "i", "=", "count", "(", "$", "this", "->", "values", ")", ";", "$", "this", "->", "values", "[", "$", "i", "]", "=", "$", "str", ";", "return", "$", "i", ";", "}" ]
Add a string to the internal list @param string String value @return int Index of value for retrieval
[ "Add", "a", "string", "to", "the", "internal", "list" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_string_replacer.php#L69-L74
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_string_replacer.php
rcube_string_replacer.link_callback
public function link_callback($matches) { $i = -1; $scheme = strtolower($matches[1]); if (preg_match('!^(http|ftp|file)s?://!i', $scheme)) { $url = $matches[1] . $matches[2]; } else if (preg_match("/^({$this->noword}*)(www\.)$/i", $matches[1], $m)) { $url = $m[2] . $matches[2]; $url_prefix = 'http://'; $prefix = $m[1]; } if ($url) { $suffix = $this->parse_url_brackets($url); $attrib = (array)$this->options['link_attribs']; $attrib['href'] = $url_prefix . $url; $i = $this->add(html::a($attrib, rcube::Q($url)) . $suffix); $this->urls[$i] = $attrib['href']; } // Return valid link for recognized schemes, otherwise // return the unmodified string for unrecognized schemes. return $i >= 0 ? $prefix . $this->get_replacement($i) : $matches[0]; }
php
public function link_callback($matches) { $i = -1; $scheme = strtolower($matches[1]); if (preg_match('!^(http|ftp|file)s?://!i', $scheme)) { $url = $matches[1] . $matches[2]; } else if (preg_match("/^({$this->noword}*)(www\.)$/i", $matches[1], $m)) { $url = $m[2] . $matches[2]; $url_prefix = 'http://'; $prefix = $m[1]; } if ($url) { $suffix = $this->parse_url_brackets($url); $attrib = (array)$this->options['link_attribs']; $attrib['href'] = $url_prefix . $url; $i = $this->add(html::a($attrib, rcube::Q($url)) . $suffix); $this->urls[$i] = $attrib['href']; } // Return valid link for recognized schemes, otherwise // return the unmodified string for unrecognized schemes. return $i >= 0 ? $prefix . $this->get_replacement($i) : $matches[0]; }
[ "public", "function", "link_callback", "(", "$", "matches", ")", "{", "$", "i", "=", "-", "1", ";", "$", "scheme", "=", "strtolower", "(", "$", "matches", "[", "1", "]", ")", ";", "if", "(", "preg_match", "(", "'!^(http|ftp|file)s?://!i'", ",", "$", ...
Callback function used to build HTML links around URL strings @param array Matches result from preg_replace_callback @return int Index of saved string value
[ "Callback", "function", "used", "to", "build", "HTML", "links", "around", "URL", "strings" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_string_replacer.php#L90-L116
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_string_replacer.php
rcube_string_replacer.linkref_addindex
public function linkref_addindex($matches) { $key = $matches[1]; $this->linkrefs[$key] = $this->urls[$matches[3]]; return $this->get_replacement($this->add('['.$key.']')) . $matches[2]; }
php
public function linkref_addindex($matches) { $key = $matches[1]; $this->linkrefs[$key] = $this->urls[$matches[3]]; return $this->get_replacement($this->add('['.$key.']')) . $matches[2]; }
[ "public", "function", "linkref_addindex", "(", "$", "matches", ")", "{", "$", "key", "=", "$", "matches", "[", "1", "]", ";", "$", "this", "->", "linkrefs", "[", "$", "key", "]", "=", "$", "this", "->", "urls", "[", "$", "matches", "[", "3", "]",...
Callback to add an entry to the link index
[ "Callback", "to", "add", "an", "entry", "to", "the", "link", "index" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_string_replacer.php#L121-L127
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_string_replacer.php
rcube_string_replacer.linkref_callback
public function linkref_callback($matches) { $i = 0; if ($url = $this->linkrefs[$matches[1]]) { $attrib = (array)$this->options['link_attribs']; $attrib['href'] = $url; $i = $this->add(html::a($attrib, rcube::Q($matches[1]))); } return $i > 0 ? '['.$this->get_replacement($i).']' : $matches[0]; }
php
public function linkref_callback($matches) { $i = 0; if ($url = $this->linkrefs[$matches[1]]) { $attrib = (array)$this->options['link_attribs']; $attrib['href'] = $url; $i = $this->add(html::a($attrib, rcube::Q($matches[1]))); } return $i > 0 ? '['.$this->get_replacement($i).']' : $matches[0]; }
[ "public", "function", "linkref_callback", "(", "$", "matches", ")", "{", "$", "i", "=", "0", ";", "if", "(", "$", "url", "=", "$", "this", "->", "linkrefs", "[", "$", "matches", "[", "1", "]", "]", ")", "{", "$", "attrib", "=", "(", "array", ")...
Callback to replace link references with real links
[ "Callback", "to", "replace", "link", "references", "with", "real", "links" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_string_replacer.php#L132-L142
train
i-MSCP/roundcube
roundcubemail/program/lib/Roundcube/rcube_string_replacer.php
rcube_string_replacer.parse_url_brackets
public static function parse_url_brackets(&$url) { // #1487672: special handling of square brackets, // URL regexp allows [] characters in URL, for example: // "http://example.com/?a[b]=c". However we need to handle // properly situation when a bracket is placed at the end // of the link e.g. "[http://example.com]" // Yes, this is not perfect handles correctly only paired characters // but it should work for common cases if (preg_match('/(\\[|\\])/', $url)) { $in = false; for ($i=0, $len=strlen($url); $i<$len; $i++) { if ($url[$i] == '[') { if ($in) break; $in = true; } else if ($url[$i] == ']') { if (!$in) break; $in = false; } } if ($i < $len) { $suffix = substr($url, $i); $url = substr($url, 0, $i); } } // Do the same for parentheses if (preg_match('/(\\(|\\))/', $url)) { $in = false; for ($i=0, $len=strlen($url); $i<$len; $i++) { if ($url[$i] == '(') { if ($in) break; $in = true; } else if ($url[$i] == ')') { if (!$in) break; $in = false; } } if ($i < $len) { $suffix = substr($url, $i); $url = substr($url, 0, $i); } } return $suffix; }
php
public static function parse_url_brackets(&$url) { // #1487672: special handling of square brackets, // URL regexp allows [] characters in URL, for example: // "http://example.com/?a[b]=c". However we need to handle // properly situation when a bracket is placed at the end // of the link e.g. "[http://example.com]" // Yes, this is not perfect handles correctly only paired characters // but it should work for common cases if (preg_match('/(\\[|\\])/', $url)) { $in = false; for ($i=0, $len=strlen($url); $i<$len; $i++) { if ($url[$i] == '[') { if ($in) break; $in = true; } else if ($url[$i] == ']') { if (!$in) break; $in = false; } } if ($i < $len) { $suffix = substr($url, $i); $url = substr($url, 0, $i); } } // Do the same for parentheses if (preg_match('/(\\(|\\))/', $url)) { $in = false; for ($i=0, $len=strlen($url); $i<$len; $i++) { if ($url[$i] == '(') { if ($in) break; $in = true; } else if ($url[$i] == ')') { if (!$in) break; $in = false; } } if ($i < $len) { $suffix = substr($url, $i); $url = substr($url, 0, $i); } } return $suffix; }
[ "public", "static", "function", "parse_url_brackets", "(", "&", "$", "url", ")", "{", "// #1487672: special handling of square brackets,", "// URL regexp allows [] characters in URL, for example:", "// \"http://example.com/?a[b]=c\". However we need to handle", "// properly situation when ...
Fixes bracket characters in URL handling
[ "Fixes", "bracket", "characters", "in", "URL", "handling" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_string_replacer.php#L202-L256
train
i-MSCP/roundcube
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php
rcube_sieve.save
public function save($name = null) { if (!$this->sieve) { return $this->_set_error(self::ERROR_INTERNAL); } if (!$this->script) { return $this->_set_error(self::ERROR_INTERNAL); } if (!$name) { $name = $this->current; } $script = $this->script->as_text(); if (!$script) { $script = '/* empty script */'; } $result = $this->sieve->installScript($name, $script); if (is_a($result, 'PEAR_Error')) { return $this->_set_error(self::ERROR_INSTALL); } return true; }
php
public function save($name = null) { if (!$this->sieve) { return $this->_set_error(self::ERROR_INTERNAL); } if (!$this->script) { return $this->_set_error(self::ERROR_INTERNAL); } if (!$name) { $name = $this->current; } $script = $this->script->as_text(); if (!$script) { $script = '/* empty script */'; } $result = $this->sieve->installScript($name, $script); if (is_a($result, 'PEAR_Error')) { return $this->_set_error(self::ERROR_INSTALL); } return true; }
[ "public", "function", "save", "(", "$", "name", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "sieve", ")", "{", "return", "$", "this", "->", "_set_error", "(", "self", "::", "ERROR_INTERNAL", ")", ";", "}", "if", "(", "!", "$", "this...
Saves current script into server
[ "Saves", "current", "script", "into", "server" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php#L123-L149
train
i-MSCP/roundcube
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php
rcube_sieve.save_script
public function save_script($name, $content = null) { if (!$this->sieve) { return $this->_set_error(self::ERROR_INTERNAL); } if (!$content) { $content = '/* empty script */'; } $result = $this->sieve->installScript($name, $content); if (is_a($result, 'PEAR_Error')) { $rawErrorMessage = $result->getMessage(); $errMessages = preg_split("/$name:/", $rawErrorMessage); if (count($errMessages) > 0) { foreach ($errMessages as $singleError) { $matches = array(); $res = preg_match('/line (\d+):(.*)/i', $singleError, $matches); if ($res === 1 ) { if (count($matches) > 2) { $this->errorLines[] = array("line" => $matches[1], "msg" => $matches[2]); } else { $this->errorLines[] = array("line" => $matches[1], "msg" => null); } } } } return $this->_set_error(self::ERROR_INSTALL); } return true; }
php
public function save_script($name, $content = null) { if (!$this->sieve) { return $this->_set_error(self::ERROR_INTERNAL); } if (!$content) { $content = '/* empty script */'; } $result = $this->sieve->installScript($name, $content); if (is_a($result, 'PEAR_Error')) { $rawErrorMessage = $result->getMessage(); $errMessages = preg_split("/$name:/", $rawErrorMessage); if (count($errMessages) > 0) { foreach ($errMessages as $singleError) { $matches = array(); $res = preg_match('/line (\d+):(.*)/i', $singleError, $matches); if ($res === 1 ) { if (count($matches) > 2) { $this->errorLines[] = array("line" => $matches[1], "msg" => $matches[2]); } else { $this->errorLines[] = array("line" => $matches[1], "msg" => null); } } } } return $this->_set_error(self::ERROR_INSTALL); } return true; }
[ "public", "function", "save_script", "(", "$", "name", ",", "$", "content", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "sieve", ")", "{", "return", "$", "this", "->", "_set_error", "(", "self", "::", "ERROR_INTERNAL", ")", ";", "}", ...
Saves text script into server
[ "Saves", "text", "script", "into", "server" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php#L154-L190
train
i-MSCP/roundcube
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php
rcube_sieve.activate
public function activate($name = null) { if (!$this->sieve) { return $this->_set_error(self::ERROR_INTERNAL); } if (!$name) { $name = $this->current; } $result = $this->sieve->setActive($name); if (is_a($result, 'PEAR_Error')) { return $this->_set_error(self::ERROR_ACTIVATE); } $this->active = $name; return true; }
php
public function activate($name = null) { if (!$this->sieve) { return $this->_set_error(self::ERROR_INTERNAL); } if (!$name) { $name = $this->current; } $result = $this->sieve->setActive($name); if (is_a($result, 'PEAR_Error')) { return $this->_set_error(self::ERROR_ACTIVATE); } $this->active = $name; return true; }
[ "public", "function", "activate", "(", "$", "name", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "sieve", ")", "{", "return", "$", "this", "->", "_set_error", "(", "self", "::", "ERROR_INTERNAL", ")", ";", "}", "if", "(", "!", "$", "...
Activates specified script
[ "Activates", "specified", "script" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php#L203-L222
train
i-MSCP/roundcube
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php
rcube_sieve.deactivate
public function deactivate() { if (!$this->sieve) { return $this->_set_error(self::ERROR_INTERNAL); } $result = $this->sieve->setActive(''); if (is_a($result, 'PEAR_Error')) { return $this->_set_error(self::ERROR_DEACTIVATE); } $this->active = null; return true; }
php
public function deactivate() { if (!$this->sieve) { return $this->_set_error(self::ERROR_INTERNAL); } $result = $this->sieve->setActive(''); if (is_a($result, 'PEAR_Error')) { return $this->_set_error(self::ERROR_DEACTIVATE); } $this->active = null; return true; }
[ "public", "function", "deactivate", "(", ")", "{", "if", "(", "!", "$", "this", "->", "sieve", ")", "{", "return", "$", "this", "->", "_set_error", "(", "self", "::", "ERROR_INTERNAL", ")", ";", "}", "$", "result", "=", "$", "this", "->", "sieve", ...
De-activates specified script
[ "De", "-", "activates", "specified", "script" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php#L227-L242
train
i-MSCP/roundcube
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php
rcube_sieve.remove
public function remove($name = null) { if (!$this->sieve) { return $this->_set_error(self::ERROR_INTERNAL); } if (!$name) { $name = $this->current; } // script must be deactivated first if ($name == $this->sieve->getActive()) { $result = $this->sieve->setActive(''); if (is_a($result, 'PEAR_Error')) { return $this->_set_error(self::ERROR_DELETE); } $this->active = null; } $result = $this->sieve->removeScript($name); if (is_a($result, 'PEAR_Error')) { return $this->_set_error(self::ERROR_DELETE); } if ($name == $this->current) { $this->current = null; } $this->list = null; return true; }
php
public function remove($name = null) { if (!$this->sieve) { return $this->_set_error(self::ERROR_INTERNAL); } if (!$name) { $name = $this->current; } // script must be deactivated first if ($name == $this->sieve->getActive()) { $result = $this->sieve->setActive(''); if (is_a($result, 'PEAR_Error')) { return $this->_set_error(self::ERROR_DELETE); } $this->active = null; } $result = $this->sieve->removeScript($name); if (is_a($result, 'PEAR_Error')) { return $this->_set_error(self::ERROR_DELETE); } if ($name == $this->current) { $this->current = null; } $this->list = null; return true; }
[ "public", "function", "remove", "(", "$", "name", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "sieve", ")", "{", "return", "$", "this", "->", "_set_error", "(", "self", "::", "ERROR_INTERNAL", ")", ";", "}", "if", "(", "!", "$", "na...
Removes specified script
[ "Removes", "specified", "script" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php#L247-L281
train
i-MSCP/roundcube
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php
rcube_sieve.get_extensions
public function get_extensions() { if ($this->exts) return $this->exts; if (!$this->sieve) return $this->_set_error(self::ERROR_INTERNAL); $ext = $this->sieve->getExtensions(); if (is_a($ext, 'PEAR_Error')) { return array(); } // we're working on lower-cased names $ext = array_map('strtolower', (array) $ext); if ($this->script) { $supported = $this->script->get_extensions(); foreach ($ext as $idx => $ext_name) if (!in_array($ext_name, $supported)) unset($ext[$idx]); } return array_values($ext); }
php
public function get_extensions() { if ($this->exts) return $this->exts; if (!$this->sieve) return $this->_set_error(self::ERROR_INTERNAL); $ext = $this->sieve->getExtensions(); if (is_a($ext, 'PEAR_Error')) { return array(); } // we're working on lower-cased names $ext = array_map('strtolower', (array) $ext); if ($this->script) { $supported = $this->script->get_extensions(); foreach ($ext as $idx => $ext_name) if (!in_array($ext_name, $supported)) unset($ext[$idx]); } return array_values($ext); }
[ "public", "function", "get_extensions", "(", ")", "{", "if", "(", "$", "this", "->", "exts", ")", "return", "$", "this", "->", "exts", ";", "if", "(", "!", "$", "this", "->", "sieve", ")", "return", "$", "this", "->", "_set_error", "(", "self", "::...
Gets list of supported by server Sieve extensions
[ "Gets", "list", "of", "supported", "by", "server", "Sieve", "extensions" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php#L286-L311
train
i-MSCP/roundcube
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php
rcube_sieve.get_scripts
public function get_scripts() { if (!$this->list) { if (!$this->sieve) return $this->_set_error(self::ERROR_INTERNAL); $list = $this->sieve->listScripts($active); if (is_a($list, 'PEAR_Error')) { return $this->_set_error(self::ERROR_OTHER); } $this->list = $list; $this->active = $active; } return $this->list; }
php
public function get_scripts() { if (!$this->list) { if (!$this->sieve) return $this->_set_error(self::ERROR_INTERNAL); $list = $this->sieve->listScripts($active); if (is_a($list, 'PEAR_Error')) { return $this->_set_error(self::ERROR_OTHER); } $this->list = $list; $this->active = $active; } return $this->list; }
[ "public", "function", "get_scripts", "(", ")", "{", "if", "(", "!", "$", "this", "->", "list", ")", "{", "if", "(", "!", "$", "this", "->", "sieve", ")", "return", "$", "this", "->", "_set_error", "(", "self", "::", "ERROR_INTERNAL", ")", ";", "$",...
Gets list of scripts from server
[ "Gets", "list", "of", "scripts", "from", "server" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php#L316-L334
train
i-MSCP/roundcube
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php
rcube_sieve.get_active
public function get_active() { if ($this->active !== null) { return $this->active; } if (!$this->sieve) { return $this->_set_error(self::ERROR_INTERNAL); } return $this->active = $this->sieve->getActive(); }
php
public function get_active() { if ($this->active !== null) { return $this->active; } if (!$this->sieve) { return $this->_set_error(self::ERROR_INTERNAL); } return $this->active = $this->sieve->getActive(); }
[ "public", "function", "get_active", "(", ")", "{", "if", "(", "$", "this", "->", "active", "!==", "null", ")", "{", "return", "$", "this", "->", "active", ";", "}", "if", "(", "!", "$", "this", "->", "sieve", ")", "{", "return", "$", "this", "->"...
Returns active script name
[ "Returns", "active", "script", "name" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php#L339-L350
train
i-MSCP/roundcube
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php
rcube_sieve.load
public function load($name) { if (!$this->sieve) return $this->_set_error(self::ERROR_INTERNAL); if ($this->current == $name) return true; $script = $this->sieve->getScript($name); if (is_a($script, 'PEAR_Error')) { return $this->_set_error(self::ERROR_OTHER); } // try to parse from Roundcube format $this->script = $this->_parse($script); $this->current = $name; return true; }
php
public function load($name) { if (!$this->sieve) return $this->_set_error(self::ERROR_INTERNAL); if ($this->current == $name) return true; $script = $this->sieve->getScript($name); if (is_a($script, 'PEAR_Error')) { return $this->_set_error(self::ERROR_OTHER); } // try to parse from Roundcube format $this->script = $this->_parse($script); $this->current = $name; return true; }
[ "public", "function", "load", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "sieve", ")", "return", "$", "this", "->", "_set_error", "(", "self", "::", "ERROR_INTERNAL", ")", ";", "if", "(", "$", "this", "->", "current", "==", "$",...
Loads script by name
[ "Loads", "script", "by", "name" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php#L355-L375
train
i-MSCP/roundcube
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php
rcube_sieve.load_script
public function load_script($script) { if (!$this->sieve) return $this->_set_error(self::ERROR_INTERNAL); // try to parse from Roundcube format $this->script = $this->_parse($script); }
php
public function load_script($script) { if (!$this->sieve) return $this->_set_error(self::ERROR_INTERNAL); // try to parse from Roundcube format $this->script = $this->_parse($script); }
[ "public", "function", "load_script", "(", "$", "script", ")", "{", "if", "(", "!", "$", "this", "->", "sieve", ")", "return", "$", "this", "->", "_set_error", "(", "self", "::", "ERROR_INTERNAL", ")", ";", "// try to parse from Roundcube format", "$", "this"...
Loads script from text content
[ "Loads", "script", "from", "text", "content" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php#L380-L387
train
i-MSCP/roundcube
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php
rcube_sieve._parse
private function _parse($txt) { // parse $script = new rcube_sieve_script($txt, $this->exts); // fix/convert to Roundcube format if (!empty($script->content)) { // replace all elsif with if+stop, we support only ifs foreach ($script->content as $idx => $rule) { if (empty($rule['type']) || !preg_match('/^(if|elsif|else)$/', $rule['type'])) { continue; } $script->content[$idx]['type'] = 'if'; // 'stop' not found? foreach ($rule['actions'] as $action) { if (preg_match('/^(stop|vacation)$/', $action['type'])) { continue 2; } } if (!empty($script->content[$idx+1]) && $script->content[$idx+1]['type'] != 'if') { $script->content[$idx]['actions'][] = array('type' => 'stop'); } } } return $script; }
php
private function _parse($txt) { // parse $script = new rcube_sieve_script($txt, $this->exts); // fix/convert to Roundcube format if (!empty($script->content)) { // replace all elsif with if+stop, we support only ifs foreach ($script->content as $idx => $rule) { if (empty($rule['type']) || !preg_match('/^(if|elsif|else)$/', $rule['type'])) { continue; } $script->content[$idx]['type'] = 'if'; // 'stop' not found? foreach ($rule['actions'] as $action) { if (preg_match('/^(stop|vacation)$/', $action['type'])) { continue 2; } } if (!empty($script->content[$idx+1]) && $script->content[$idx+1]['type'] != 'if') { $script->content[$idx]['actions'][] = array('type' => 'stop'); } } } return $script; }
[ "private", "function", "_parse", "(", "$", "txt", ")", "{", "// parse", "$", "script", "=", "new", "rcube_sieve_script", "(", "$", "txt", ",", "$", "this", "->", "exts", ")", ";", "// fix/convert to Roundcube format", "if", "(", "!", "empty", "(", "$", "...
Creates rcube_sieve_script object from text script
[ "Creates", "rcube_sieve_script", "object", "from", "text", "script" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php#L392-L420
train
i-MSCP/roundcube
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php
rcube_sieve.get_script
public function get_script($name) { if (!$this->sieve) return $this->_set_error(self::ERROR_INTERNAL); $content = $this->sieve->getScript($name); if (is_a($content, 'PEAR_Error')) { return $this->_set_error(self::ERROR_OTHER); } return $content; }
php
public function get_script($name) { if (!$this->sieve) return $this->_set_error(self::ERROR_INTERNAL); $content = $this->sieve->getScript($name); if (is_a($content, 'PEAR_Error')) { return $this->_set_error(self::ERROR_OTHER); } return $content; }
[ "public", "function", "get_script", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "sieve", ")", "return", "$", "this", "->", "_set_error", "(", "self", "::", "ERROR_INTERNAL", ")", ";", "$", "content", "=", "$", "this", "->", "sieve"...
Gets specified script as text
[ "Gets", "specified", "script", "as", "text" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php#L425-L437
train
i-MSCP/roundcube
roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php
rcube_sieve.copy
public function copy($name, $copy) { if (!$this->sieve) return $this->_set_error(self::ERROR_INTERNAL); if ($copy) { $content = $this->sieve->getScript($copy); if (is_a($content, 'PEAR_Error')) { return $this->_set_error(self::ERROR_OTHER); } } return $this->save_script($name, $content); }
php
public function copy($name, $copy) { if (!$this->sieve) return $this->_set_error(self::ERROR_INTERNAL); if ($copy) { $content = $this->sieve->getScript($copy); if (is_a($content, 'PEAR_Error')) { return $this->_set_error(self::ERROR_OTHER); } } return $this->save_script($name, $content); }
[ "public", "function", "copy", "(", "$", "name", ",", "$", "copy", ")", "{", "if", "(", "!", "$", "this", "->", "sieve", ")", "return", "$", "this", "->", "_set_error", "(", "self", "::", "ERROR_INTERNAL", ")", ";", "if", "(", "$", "copy", ")", "{...
Creates empty script or copy of other script
[ "Creates", "empty", "script", "or", "copy", "of", "other", "script" ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve.php#L442-L457
train
i-MSCP/roundcube
roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php
enigma_driver_gnupg.verify
function verify($text, $signature) { try { $verified = $this->gpg->verify($text, $signature); return $this->parse_signature($verified[0]); } catch (Exception $e) { return $this->get_error_from_exception($e); } }
php
function verify($text, $signature) { try { $verified = $this->gpg->verify($text, $signature); return $this->parse_signature($verified[0]); } catch (Exception $e) { return $this->get_error_from_exception($e); } }
[ "function", "verify", "(", "$", "text", ",", "$", "signature", ")", "{", "try", "{", "$", "verified", "=", "$", "this", "->", "gpg", "->", "verify", "(", "$", "text", ",", "$", "signature", ")", ";", "return", "$", "this", "->", "parse_signature", ...
Signature verification. @param string Message body @param string Signature, if message is of type PGP/MIME and body doesn't contain it @return mixed Signature information (enigma_signature) or enigma_error
[ "Signature", "verification", "." ]
141965e74cf301575198abc6bf12f207aacaa6c3
https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/enigma/lib/enigma_driver_gnupg.php#L213-L222
train