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_ldap.php | rcube_ldap._map_data | private function _map_data($save_cols)
{
// flatten composite fields first
foreach ($this->coltypes as $col => $colprop) {
if (is_array($colprop['childs']) && ($values = $this->get_col_values($col, $save_cols, false))) {
foreach ($values as $subtype => $childs) {
$subtype = $subtype ? ':'.$subtype : '';
foreach ($childs as $i => $child_values) {
foreach ((array)$child_values as $childcol => $value) {
$save_cols[$childcol.$subtype][$i] = $value;
}
}
}
}
// if addresses are to be saved as serialized string, do so
if (is_array($colprop['serialized'])) {
foreach ($colprop['serialized'] as $subtype => $delim) {
$key = $col.':'.$subtype;
foreach ((array)$save_cols[$key] as $i => $val) {
$values = array($val['street'], $val['locality'], $val['zipcode'], $val['country']);
$save_cols[$key][$i] = count(array_filter($values)) ? join($delim, $values) : null;
}
}
}
}
$ldap_data = array();
foreach ($this->fieldmap as $rf => $fld) {
$val = $save_cols[$rf];
// check for value in base field (eg.g email instead of email:foo)
list($col, $subtype) = explode(':', $rf);
if (!$val && !empty($save_cols[$col])) {
$val = $save_cols[$col];
unset($save_cols[$col]); // only use this value once
}
else if (!$val && !$subtype) { // extract values from subtype cols
$val = $this->get_col_values($col, $save_cols, true);
}
if (is_array($val))
$val = array_filter($val); // remove empty entries
if ($fld && $val) {
// The field does exist, add it to the entry.
$ldap_data[$fld] = $val;
}
}
foreach ($this->formats as $fld => $format) {
if (empty($ldap_data[$fld])) {
continue;
}
switch ($format['type']) {
case 'date':
if ($dt = rcube_utils::anytodatetime($ldap_data[$fld])) {
$ldap_data[$fld] = $dt->format($format['format']);
}
break;
}
}
return $ldap_data;
} | php | private function _map_data($save_cols)
{
// flatten composite fields first
foreach ($this->coltypes as $col => $colprop) {
if (is_array($colprop['childs']) && ($values = $this->get_col_values($col, $save_cols, false))) {
foreach ($values as $subtype => $childs) {
$subtype = $subtype ? ':'.$subtype : '';
foreach ($childs as $i => $child_values) {
foreach ((array)$child_values as $childcol => $value) {
$save_cols[$childcol.$subtype][$i] = $value;
}
}
}
}
// if addresses are to be saved as serialized string, do so
if (is_array($colprop['serialized'])) {
foreach ($colprop['serialized'] as $subtype => $delim) {
$key = $col.':'.$subtype;
foreach ((array)$save_cols[$key] as $i => $val) {
$values = array($val['street'], $val['locality'], $val['zipcode'], $val['country']);
$save_cols[$key][$i] = count(array_filter($values)) ? join($delim, $values) : null;
}
}
}
}
$ldap_data = array();
foreach ($this->fieldmap as $rf => $fld) {
$val = $save_cols[$rf];
// check for value in base field (eg.g email instead of email:foo)
list($col, $subtype) = explode(':', $rf);
if (!$val && !empty($save_cols[$col])) {
$val = $save_cols[$col];
unset($save_cols[$col]); // only use this value once
}
else if (!$val && !$subtype) { // extract values from subtype cols
$val = $this->get_col_values($col, $save_cols, true);
}
if (is_array($val))
$val = array_filter($val); // remove empty entries
if ($fld && $val) {
// The field does exist, add it to the entry.
$ldap_data[$fld] = $val;
}
}
foreach ($this->formats as $fld => $format) {
if (empty($ldap_data[$fld])) {
continue;
}
switch ($format['type']) {
case 'date':
if ($dt = rcube_utils::anytodatetime($ldap_data[$fld])) {
$ldap_data[$fld] = $dt->format($format['format']);
}
break;
}
}
return $ldap_data;
} | [
"private",
"function",
"_map_data",
"(",
"$",
"save_cols",
")",
"{",
"// flatten composite fields first",
"foreach",
"(",
"$",
"this",
"->",
"coltypes",
"as",
"$",
"col",
"=>",
"$",
"colprop",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"colprop",
"[",
"'ch... | Convert a record data set into LDAP field attributes | [
"Convert",
"a",
"record",
"data",
"set",
"into",
"LDAP",
"field",
"attributes"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_ldap.php#L1572-L1636 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_ldap.php | rcube_ldap.is_group_entry | private function is_group_entry($entry)
{
$classes = array_map('strtolower', (array)$entry['objectclass']);
return count(array_intersect(array_keys($this->group_types), $classes)) > 0;
} | php | private function is_group_entry($entry)
{
$classes = array_map('strtolower', (array)$entry['objectclass']);
return count(array_intersect(array_keys($this->group_types), $classes)) > 0;
} | [
"private",
"function",
"is_group_entry",
"(",
"$",
"entry",
")",
"{",
"$",
"classes",
"=",
"array_map",
"(",
"'strtolower'",
",",
"(",
"array",
")",
"$",
"entry",
"[",
"'objectclass'",
"]",
")",
";",
"return",
"count",
"(",
"array_intersect",
"(",
"array_k... | Determines whether the given LDAP entry is a group record | [
"Determines",
"whether",
"the",
"given",
"LDAP",
"entry",
"is",
"a",
"group",
"record"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_ldap.php#L1662-L1667 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_ldap.php | rcube_ldap.set_group | function set_group($group_id)
{
if ($group_id) {
$this->group_id = $group_id;
$this->group_data = $this->get_group_entry($group_id);
}
else {
$this->group_id = 0;
$this->group_data = null;
}
} | php | function set_group($group_id)
{
if ($group_id) {
$this->group_id = $group_id;
$this->group_data = $this->get_group_entry($group_id);
}
else {
$this->group_id = 0;
$this->group_data = null;
}
} | [
"function",
"set_group",
"(",
"$",
"group_id",
")",
"{",
"if",
"(",
"$",
"group_id",
")",
"{",
"$",
"this",
"->",
"group_id",
"=",
"$",
"group_id",
";",
"$",
"this",
"->",
"group_data",
"=",
"$",
"this",
"->",
"get_group_entry",
"(",
"$",
"group_id",
... | Setter for the current group | [
"Setter",
"for",
"the",
"current",
"group"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_ldap.php#L1686-L1696 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_ldap.php | rcube_ldap.get_group_entry | private function get_group_entry($group_id)
{
$group_cache = $this->_fetch_groups();
// add group record to cache if it isn't yet there
if (!isset($group_cache[$group_id])) {
$name_attr = $this->prop['groups']['name_attr'];
$dn = self::dn_decode($group_id);
if ($list = $this->ldap->read_entries($dn, '(objectClass=*)', array('dn','objectClass','member','uniqueMember','memberURL',$name_attr,$this->fieldmap['email']))) {
$entry = $list[0];
$group_name = is_array($entry[$name_attr]) ? $entry[$name_attr][0] : $entry[$name_attr];
$group_cache[$group_id]['ID'] = $group_id;
$group_cache[$group_id]['dn'] = $dn;
$group_cache[$group_id]['name'] = $group_name;
$group_cache[$group_id]['member_attr'] = $this->get_group_member_attr($entry['objectclass']);
}
else {
$group_cache[$group_id] = false;
}
if ($this->cache) {
$this->cache->set('groups', $group_cache);
}
}
return $group_cache[$group_id];
} | php | private function get_group_entry($group_id)
{
$group_cache = $this->_fetch_groups();
// add group record to cache if it isn't yet there
if (!isset($group_cache[$group_id])) {
$name_attr = $this->prop['groups']['name_attr'];
$dn = self::dn_decode($group_id);
if ($list = $this->ldap->read_entries($dn, '(objectClass=*)', array('dn','objectClass','member','uniqueMember','memberURL',$name_attr,$this->fieldmap['email']))) {
$entry = $list[0];
$group_name = is_array($entry[$name_attr]) ? $entry[$name_attr][0] : $entry[$name_attr];
$group_cache[$group_id]['ID'] = $group_id;
$group_cache[$group_id]['dn'] = $dn;
$group_cache[$group_id]['name'] = $group_name;
$group_cache[$group_id]['member_attr'] = $this->get_group_member_attr($entry['objectclass']);
}
else {
$group_cache[$group_id] = false;
}
if ($this->cache) {
$this->cache->set('groups', $group_cache);
}
}
return $group_cache[$group_id];
} | [
"private",
"function",
"get_group_entry",
"(",
"$",
"group_id",
")",
"{",
"$",
"group_cache",
"=",
"$",
"this",
"->",
"_fetch_groups",
"(",
")",
";",
"// add group record to cache if it isn't yet there",
"if",
"(",
"!",
"isset",
"(",
"$",
"group_cache",
"[",
"$"... | Fetch a group entry from LDAP and save in local cache | [
"Fetch",
"a",
"group",
"entry",
"from",
"LDAP",
"and",
"save",
"in",
"local",
"cache"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_ldap.php#L1865-L1892 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_ldap.php | rcube_ldap.delete_group | function delete_group($group_id)
{
$group_cache = $this->_fetch_groups();
$del_dn = $group_cache[$group_id]['dn'];
if (!$this->ldap->delete_entry($del_dn)) {
$this->set_error(self::ERROR_SAVING, 'errorsaving');
return false;
}
if ($this->cache) {
unset($group_cache[$group_id]);
$this->cache->set('groups', $group_cache);
}
return true;
} | php | function delete_group($group_id)
{
$group_cache = $this->_fetch_groups();
$del_dn = $group_cache[$group_id]['dn'];
if (!$this->ldap->delete_entry($del_dn)) {
$this->set_error(self::ERROR_SAVING, 'errorsaving');
return false;
}
if ($this->cache) {
unset($group_cache[$group_id]);
$this->cache->set('groups', $group_cache);
}
return true;
} | [
"function",
"delete_group",
"(",
"$",
"group_id",
")",
"{",
"$",
"group_cache",
"=",
"$",
"this",
"->",
"_fetch_groups",
"(",
")",
";",
"$",
"del_dn",
"=",
"$",
"group_cache",
"[",
"$",
"group_id",
"]",
"[",
"'dn'",
"]",
";",
"if",
"(",
"!",
"$",
"... | Delete the given group and all linked group members
@param string Group identifier
@return boolean True on success, false if no data was changed | [
"Delete",
"the",
"given",
"group",
"and",
"all",
"linked",
"group",
"members"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_ldap.php#L1944-L1960 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_ldap.php | rcube_ldap.get_group_member_attr | private function get_group_member_attr($object_classes = array(), $default = 'member')
{
if (empty($object_classes)) {
$object_classes = $this->prop['groups']['object_classes'];
}
if (!empty($object_classes)) {
foreach ((array)$object_classes as $oc) {
if ($attr = $this->group_types[strtolower($oc)]) {
return $attr;
}
}
}
if (!empty($this->prop['groups']['member_attr'])) {
return $this->prop['groups']['member_attr'];
}
return $default;
} | php | private function get_group_member_attr($object_classes = array(), $default = 'member')
{
if (empty($object_classes)) {
$object_classes = $this->prop['groups']['object_classes'];
}
if (!empty($object_classes)) {
foreach ((array)$object_classes as $oc) {
if ($attr = $this->group_types[strtolower($oc)]) {
return $attr;
}
}
}
if (!empty($this->prop['groups']['member_attr'])) {
return $this->prop['groups']['member_attr'];
}
return $default;
} | [
"private",
"function",
"get_group_member_attr",
"(",
"$",
"object_classes",
"=",
"array",
"(",
")",
",",
"$",
"default",
"=",
"'member'",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"object_classes",
")",
")",
"{",
"$",
"object_classes",
"=",
"$",
"this",
"-... | Detects group member attribute name | [
"Detects",
"group",
"member",
"attribute",
"name"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_ldap.php#L2103-L2122 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_imap_cache.php | rcube_imap_cache.get_thread | function get_thread($mailbox)
{
if (empty($this->icache[$mailbox])) {
$this->icache[$mailbox] = array();
}
// Seek in internal cache
if (array_key_exists('thread', $this->icache[$mailbox])) {
return $this->icache[$mailbox]['thread']['object'];
}
// Get thread from DB (if DB wasn't already queried)
if (empty($this->icache[$mailbox]['thread_queried'])) {
$index = $this->get_thread_row($mailbox);
// set the flag that DB was already queried for thread
// this way we'll be able to skip one SELECT, when
// get_thread() is called more than once or after clear()
$this->icache[$mailbox]['thread_queried'] = true;
}
// Entry exist, check cache status
if (!empty($index)) {
$exists = true;
$is_valid = $this->validate($mailbox, $index, $exists);
if (!$is_valid) {
$index = null;
}
}
// Index not found or not valid, get index from IMAP server
if ($index === null) {
// Get mailbox data (UIDVALIDITY, counters, etc.) for status check
$mbox_data = $this->imap->folder_data($mailbox);
// Get THREADS result
$index['object'] = $this->get_thread_data($mailbox, $mbox_data);
// insert/update
$this->add_thread_row($mailbox, $index['object'], $mbox_data, $exists);
}
$this->icache[$mailbox]['thread'] = $index;
return $index['object'];
} | php | function get_thread($mailbox)
{
if (empty($this->icache[$mailbox])) {
$this->icache[$mailbox] = array();
}
// Seek in internal cache
if (array_key_exists('thread', $this->icache[$mailbox])) {
return $this->icache[$mailbox]['thread']['object'];
}
// Get thread from DB (if DB wasn't already queried)
if (empty($this->icache[$mailbox]['thread_queried'])) {
$index = $this->get_thread_row($mailbox);
// set the flag that DB was already queried for thread
// this way we'll be able to skip one SELECT, when
// get_thread() is called more than once or after clear()
$this->icache[$mailbox]['thread_queried'] = true;
}
// Entry exist, check cache status
if (!empty($index)) {
$exists = true;
$is_valid = $this->validate($mailbox, $index, $exists);
if (!$is_valid) {
$index = null;
}
}
// Index not found or not valid, get index from IMAP server
if ($index === null) {
// Get mailbox data (UIDVALIDITY, counters, etc.) for status check
$mbox_data = $this->imap->folder_data($mailbox);
// Get THREADS result
$index['object'] = $this->get_thread_data($mailbox, $mbox_data);
// insert/update
$this->add_thread_row($mailbox, $index['object'], $mbox_data, $exists);
}
$this->icache[$mailbox]['thread'] = $index;
return $index['object'];
} | [
"function",
"get_thread",
"(",
"$",
"mailbox",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"icache",
"[",
"$",
"mailbox",
"]",
")",
")",
"{",
"$",
"this",
"->",
"icache",
"[",
"$",
"mailbox",
"]",
"=",
"array",
"(",
")",
";",
"}",
"//... | Return messages thread.
If threaded index doesn't exist or is invalid, will be updated.
@param string $mailbox Folder name
@return array Messages threaded index | [
"Return",
"messages",
"thread",
".",
"If",
"threaded",
"index",
"doesn",
"t",
"exist",
"or",
"is",
"invalid",
"will",
"be",
"updated",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap_cache.php#L269-L314 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_imap_cache.php | rcube_imap_cache.get_message | function get_message($mailbox, $uid, $update = true, $cache = true)
{
// Check internal cache
if ($this->icache['__message']
&& $this->icache['__message']['mailbox'] == $mailbox
&& $this->icache['__message']['object']->uid == $uid
) {
return $this->icache['__message']['object'];
}
if ($this->mode & self::MODE_MESSAGE) {
$sql_result = $this->db->query(
"SELECT `flags`, `data`"
." FROM {$this->messages_table}"
." WHERE `user_id` = ?"
." AND `mailbox` = ?"
." AND `uid` = ?",
$this->userid, $mailbox, (int)$uid);
if ($sql_arr = $this->db->fetch_assoc($sql_result)) {
$message = $this->build_message($sql_arr);
$found = true;
}
}
// Get the message from IMAP server
if (empty($message) && $update) {
$message = $this->imap->get_message_headers($uid, $mailbox, true);
// cache will be updated in close(), see below
}
if (!($this->mode & self::MODE_MESSAGE)) {
return $message;
}
// Save the message in internal cache, will be written to DB in close()
// Common scenario: user opens unseen message
// - get message (SELECT)
// - set message headers/structure (INSERT or UPDATE)
// - set \Seen flag (UPDATE)
// This way we can skip one UPDATE
if (!empty($message) && $cache) {
// Save current message from internal cache
$this->save_icache();
$this->icache['__message'] = array(
'object' => $message,
'mailbox' => $mailbox,
'exists' => $found,
'md5sum' => md5(serialize($message)),
);
}
return $message;
} | php | function get_message($mailbox, $uid, $update = true, $cache = true)
{
// Check internal cache
if ($this->icache['__message']
&& $this->icache['__message']['mailbox'] == $mailbox
&& $this->icache['__message']['object']->uid == $uid
) {
return $this->icache['__message']['object'];
}
if ($this->mode & self::MODE_MESSAGE) {
$sql_result = $this->db->query(
"SELECT `flags`, `data`"
." FROM {$this->messages_table}"
." WHERE `user_id` = ?"
." AND `mailbox` = ?"
." AND `uid` = ?",
$this->userid, $mailbox, (int)$uid);
if ($sql_arr = $this->db->fetch_assoc($sql_result)) {
$message = $this->build_message($sql_arr);
$found = true;
}
}
// Get the message from IMAP server
if (empty($message) && $update) {
$message = $this->imap->get_message_headers($uid, $mailbox, true);
// cache will be updated in close(), see below
}
if (!($this->mode & self::MODE_MESSAGE)) {
return $message;
}
// Save the message in internal cache, will be written to DB in close()
// Common scenario: user opens unseen message
// - get message (SELECT)
// - set message headers/structure (INSERT or UPDATE)
// - set \Seen flag (UPDATE)
// This way we can skip one UPDATE
if (!empty($message) && $cache) {
// Save current message from internal cache
$this->save_icache();
$this->icache['__message'] = array(
'object' => $message,
'mailbox' => $mailbox,
'exists' => $found,
'md5sum' => md5(serialize($message)),
);
}
return $message;
} | [
"function",
"get_message",
"(",
"$",
"mailbox",
",",
"$",
"uid",
",",
"$",
"update",
"=",
"true",
",",
"$",
"cache",
"=",
"true",
")",
"{",
"// Check internal cache",
"if",
"(",
"$",
"this",
"->",
"icache",
"[",
"'__message'",
"]",
"&&",
"$",
"this",
... | Returns message data.
@param string $mailbox Folder name
@param int $uid Message UID
@param bool $update If message doesn't exists in cache it will be fetched
from IMAP server
@param bool $no_cache Enables internal cache usage
@return rcube_message_header Message data | [
"Returns",
"message",
"data",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap_cache.php#L391-L445 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_imap_cache.php | rcube_imap_cache.add_message | function add_message($mailbox, $message, $force = false)
{
if (!is_object($message) || empty($message->uid)) {
return;
}
if (!($this->mode & self::MODE_MESSAGE)) {
return;
}
$flags = 0;
$msg = clone $message;
if (!empty($message->flags)) {
foreach ($this->flags as $idx => $flag) {
if (!empty($message->flags[$flag])) {
$flags += $idx;
}
}
}
unset($msg->flags);
$msg = $this->db->encode($msg, true);
// update cache record (even if it exists, the update
// here will work as select, assume row exist if affected_rows=0)
if (!$force) {
$res = $this->db->query(
"UPDATE {$this->messages_table}"
." SET `flags` = ?, `data` = ?, `expires` = " . ($this->ttl ? $this->db->now($this->ttl) : 'NULL')
." WHERE `user_id` = ?"
." AND `mailbox` = ?"
." AND `uid` = ?",
$flags, $msg, $this->userid, $mailbox, (int) $message->uid);
if ($this->db->affected_rows($res)) {
return;
}
}
$this->db->set_option('ignore_key_errors', true);
// insert new record
$res = $this->db->query(
"INSERT INTO {$this->messages_table}"
." (`user_id`, `mailbox`, `uid`, `flags`, `expires`, `data`)"
." VALUES (?, ?, ?, ?, ". ($this->ttl ? $this->db->now($this->ttl) : 'NULL') . ", ?)",
$this->userid, $mailbox, (int) $message->uid, $flags, $msg);
// race-condition, insert failed so try update (#1489146)
// thanks to ignore_key_errors "duplicate row" errors will be ignored
if ($force && !$res && !$this->db->is_error($res)) {
$this->db->query(
"UPDATE {$this->messages_table}"
." SET `expires` = " . ($this->ttl ? $this->db->now($this->ttl) : 'NULL')
.", `flags` = ?, `data` = ?"
." WHERE `user_id` = ?"
." AND `mailbox` = ?"
." AND `uid` = ?",
$flags, $msg, $this->userid, $mailbox, (int) $message->uid);
}
$this->db->set_option('ignore_key_errors', false);
} | php | function add_message($mailbox, $message, $force = false)
{
if (!is_object($message) || empty($message->uid)) {
return;
}
if (!($this->mode & self::MODE_MESSAGE)) {
return;
}
$flags = 0;
$msg = clone $message;
if (!empty($message->flags)) {
foreach ($this->flags as $idx => $flag) {
if (!empty($message->flags[$flag])) {
$flags += $idx;
}
}
}
unset($msg->flags);
$msg = $this->db->encode($msg, true);
// update cache record (even if it exists, the update
// here will work as select, assume row exist if affected_rows=0)
if (!$force) {
$res = $this->db->query(
"UPDATE {$this->messages_table}"
." SET `flags` = ?, `data` = ?, `expires` = " . ($this->ttl ? $this->db->now($this->ttl) : 'NULL')
." WHERE `user_id` = ?"
." AND `mailbox` = ?"
." AND `uid` = ?",
$flags, $msg, $this->userid, $mailbox, (int) $message->uid);
if ($this->db->affected_rows($res)) {
return;
}
}
$this->db->set_option('ignore_key_errors', true);
// insert new record
$res = $this->db->query(
"INSERT INTO {$this->messages_table}"
." (`user_id`, `mailbox`, `uid`, `flags`, `expires`, `data`)"
." VALUES (?, ?, ?, ?, ". ($this->ttl ? $this->db->now($this->ttl) : 'NULL') . ", ?)",
$this->userid, $mailbox, (int) $message->uid, $flags, $msg);
// race-condition, insert failed so try update (#1489146)
// thanks to ignore_key_errors "duplicate row" errors will be ignored
if ($force && !$res && !$this->db->is_error($res)) {
$this->db->query(
"UPDATE {$this->messages_table}"
." SET `expires` = " . ($this->ttl ? $this->db->now($this->ttl) : 'NULL')
.", `flags` = ?, `data` = ?"
." WHERE `user_id` = ?"
." AND `mailbox` = ?"
." AND `uid` = ?",
$flags, $msg, $this->userid, $mailbox, (int) $message->uid);
}
$this->db->set_option('ignore_key_errors', false);
} | [
"function",
"add_message",
"(",
"$",
"mailbox",
",",
"$",
"message",
",",
"$",
"force",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"message",
")",
"||",
"empty",
"(",
"$",
"message",
"->",
"uid",
")",
")",
"{",
"return",
";",
... | Saves the message in cache.
@param string $mailbox Folder name
@param rcube_message_header $message Message data
@param bool $force Skips message in-cache existence check | [
"Saves",
"the",
"message",
"in",
"cache",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap_cache.php#L454-L517 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_imap_cache.php | rcube_imap_cache.change_flag | function change_flag($mailbox, $uids, $flag, $enabled = false)
{
if (empty($uids)) {
return;
}
if (!($this->mode & self::MODE_MESSAGE)) {
return;
}
$flag = strtoupper($flag);
$idx = (int) array_search($flag, $this->flags);
$uids = (array) $uids;
if (!$idx) {
return;
}
// Internal cache update
if (($message = $this->icache['__message'])
&& $message['mailbox'] === $mailbox
&& in_array($message['object']->uid, $uids)
) {
$message['object']->flags[$flag] = $enabled;
if (count($uids) == 1) {
return;
}
}
$binary_check = $this->db->db_provider == 'oracle' ? "BITAND(`flags`, %d)" : "(`flags` & %d)";
$this->db->query(
"UPDATE {$this->messages_table}"
." SET `expires` = ". ($this->ttl ? $this->db->now($this->ttl) : 'NULL')
.", `flags` = `flags` ".($enabled ? "+ $idx" : "- $idx")
." WHERE `user_id` = ?"
." AND `mailbox` = ?"
.(!empty($uids) ? " AND `uid` IN (".$this->db->array2list($uids, 'integer').")" : "")
." AND " . sprintf($binary_check, $idx) . ($enabled ? " = 0" : " = $idx"),
$this->userid, $mailbox);
} | php | function change_flag($mailbox, $uids, $flag, $enabled = false)
{
if (empty($uids)) {
return;
}
if (!($this->mode & self::MODE_MESSAGE)) {
return;
}
$flag = strtoupper($flag);
$idx = (int) array_search($flag, $this->flags);
$uids = (array) $uids;
if (!$idx) {
return;
}
// Internal cache update
if (($message = $this->icache['__message'])
&& $message['mailbox'] === $mailbox
&& in_array($message['object']->uid, $uids)
) {
$message['object']->flags[$flag] = $enabled;
if (count($uids) == 1) {
return;
}
}
$binary_check = $this->db->db_provider == 'oracle' ? "BITAND(`flags`, %d)" : "(`flags` & %d)";
$this->db->query(
"UPDATE {$this->messages_table}"
." SET `expires` = ". ($this->ttl ? $this->db->now($this->ttl) : 'NULL')
.", `flags` = `flags` ".($enabled ? "+ $idx" : "- $idx")
." WHERE `user_id` = ?"
." AND `mailbox` = ?"
.(!empty($uids) ? " AND `uid` IN (".$this->db->array2list($uids, 'integer').")" : "")
." AND " . sprintf($binary_check, $idx) . ($enabled ? " = 0" : " = $idx"),
$this->userid, $mailbox);
} | [
"function",
"change_flag",
"(",
"$",
"mailbox",
",",
"$",
"uids",
",",
"$",
"flag",
",",
"$",
"enabled",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"uids",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
... | Sets the flag for specified message.
@param string $mailbox Folder name
@param array $uids Message UIDs or null to change flag
of all messages in a folder
@param string $flag The name of the flag
@param bool $enabled Flag state | [
"Sets",
"the",
"flag",
"for",
"specified",
"message",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap_cache.php#L528-L569 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_imap_cache.php | rcube_imap_cache.remove_index | function remove_index($mailbox = null, $remove = false)
{
// The index should be only removed from database when
// UIDVALIDITY was detected or the mailbox is empty
// otherwise use 'valid' flag to not loose HIGHESTMODSEQ value
if ($remove) {
$this->db->query(
"DELETE FROM {$this->index_table}"
." WHERE `user_id` = ?"
.(strlen($mailbox) ? " AND `mailbox` = ".$this->db->quote($mailbox) : ""),
$this->userid
);
}
else {
$this->db->query(
"UPDATE {$this->index_table}"
." SET `valid` = 0"
." WHERE `user_id` = ?"
.(strlen($mailbox) ? " AND `mailbox` = ".$this->db->quote($mailbox) : ""),
$this->userid
);
}
if (strlen($mailbox)) {
unset($this->icache[$mailbox]['index']);
// Index removed, set flag to skip SELECT query in get_index()
$this->icache[$mailbox]['index_queried'] = true;
}
else {
$this->icache = array();
}
} | php | function remove_index($mailbox = null, $remove = false)
{
// The index should be only removed from database when
// UIDVALIDITY was detected or the mailbox is empty
// otherwise use 'valid' flag to not loose HIGHESTMODSEQ value
if ($remove) {
$this->db->query(
"DELETE FROM {$this->index_table}"
." WHERE `user_id` = ?"
.(strlen($mailbox) ? " AND `mailbox` = ".$this->db->quote($mailbox) : ""),
$this->userid
);
}
else {
$this->db->query(
"UPDATE {$this->index_table}"
." SET `valid` = 0"
." WHERE `user_id` = ?"
.(strlen($mailbox) ? " AND `mailbox` = ".$this->db->quote($mailbox) : ""),
$this->userid
);
}
if (strlen($mailbox)) {
unset($this->icache[$mailbox]['index']);
// Index removed, set flag to skip SELECT query in get_index()
$this->icache[$mailbox]['index_queried'] = true;
}
else {
$this->icache = array();
}
} | [
"function",
"remove_index",
"(",
"$",
"mailbox",
"=",
"null",
",",
"$",
"remove",
"=",
"false",
")",
"{",
"// The index should be only removed from database when",
"// UIDVALIDITY was detected or the mailbox is empty",
"// otherwise use 'valid' flag to not loose HIGHESTMODSEQ value",... | Clears index cache.
@param string $mailbox Folder name
@param bool $remove Enable to remove the DB row | [
"Clears",
"index",
"cache",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap_cache.php#L613-L644 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_imap_cache.php | rcube_imap_cache.remove_thread | function remove_thread($mailbox = null)
{
$this->db->query(
"DELETE FROM {$this->thread_table}"
." WHERE `user_id` = ?"
.(strlen($mailbox) ? " AND `mailbox` = ".$this->db->quote($mailbox) : ""),
$this->userid
);
if (strlen($mailbox)) {
unset($this->icache[$mailbox]['thread']);
// Thread data removed, set flag to skip SELECT query in get_thread()
$this->icache[$mailbox]['thread_queried'] = true;
}
else {
$this->icache = array();
}
} | php | function remove_thread($mailbox = null)
{
$this->db->query(
"DELETE FROM {$this->thread_table}"
." WHERE `user_id` = ?"
.(strlen($mailbox) ? " AND `mailbox` = ".$this->db->quote($mailbox) : ""),
$this->userid
);
if (strlen($mailbox)) {
unset($this->icache[$mailbox]['thread']);
// Thread data removed, set flag to skip SELECT query in get_thread()
$this->icache[$mailbox]['thread_queried'] = true;
}
else {
$this->icache = array();
}
} | [
"function",
"remove_thread",
"(",
"$",
"mailbox",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"\"DELETE FROM {$this->thread_table}\"",
".",
"\" WHERE `user_id` = ?\"",
".",
"(",
"strlen",
"(",
"$",
"mailbox",
")",
"?",
"\" AND `mailbox` =... | Clears thread cache.
@param string $mailbox Folder name | [
"Clears",
"thread",
"cache",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap_cache.php#L651-L668 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_imap_cache.php | rcube_imap_cache.gc | static function gc()
{
$rcube = rcube::get_instance();
$db = $rcube->get_dbh();
$now = $db->now();
$db->query("DELETE FROM " . $db->table_name('cache_messages', true)
." WHERE `expires` < $now");
$db->query("DELETE FROM " . $db->table_name('cache_index', true)
." WHERE `expires` < $now");
$db->query("DELETE FROM ".$db->table_name('cache_thread', true)
." WHERE `expires` < $now");
} | php | static function gc()
{
$rcube = rcube::get_instance();
$db = $rcube->get_dbh();
$now = $db->now();
$db->query("DELETE FROM " . $db->table_name('cache_messages', true)
." WHERE `expires` < $now");
$db->query("DELETE FROM " . $db->table_name('cache_index', true)
." WHERE `expires` < $now");
$db->query("DELETE FROM ".$db->table_name('cache_thread', true)
." WHERE `expires` < $now");
} | [
"static",
"function",
"gc",
"(",
")",
"{",
"$",
"rcube",
"=",
"rcube",
"::",
"get_instance",
"(",
")",
";",
"$",
"db",
"=",
"$",
"rcube",
"->",
"get_dbh",
"(",
")",
";",
"$",
"now",
"=",
"$",
"db",
"->",
"now",
"(",
")",
";",
"$",
"db",
"->",... | Delete expired cache entries | [
"Delete",
"expired",
"cache",
"entries"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap_cache.php#L686-L700 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_imap_cache.php | rcube_imap_cache.get_index_row | private function get_index_row($mailbox)
{
// Get index from DB
$sql_result = $this->db->query(
"SELECT `data`, `valid`"
." FROM {$this->index_table}"
." WHERE `user_id` = ?"
." AND `mailbox` = ?",
$this->userid, $mailbox);
if ($sql_arr = $this->db->fetch_assoc($sql_result)) {
$data = explode('@', $sql_arr['data']);
$index = $this->db->decode($data[0], true);
unset($data[0]);
if (empty($index)) {
$index = new rcube_result_index($mailbox);
}
return array(
'valid' => $sql_arr['valid'],
'object' => $index,
'sort_field' => $data[1],
'deleted' => $data[2],
'validity' => $data[3],
'uidnext' => $data[4],
'modseq' => $data[5],
);
}
return null;
} | php | private function get_index_row($mailbox)
{
// Get index from DB
$sql_result = $this->db->query(
"SELECT `data`, `valid`"
." FROM {$this->index_table}"
." WHERE `user_id` = ?"
." AND `mailbox` = ?",
$this->userid, $mailbox);
if ($sql_arr = $this->db->fetch_assoc($sql_result)) {
$data = explode('@', $sql_arr['data']);
$index = $this->db->decode($data[0], true);
unset($data[0]);
if (empty($index)) {
$index = new rcube_result_index($mailbox);
}
return array(
'valid' => $sql_arr['valid'],
'object' => $index,
'sort_field' => $data[1],
'deleted' => $data[2],
'validity' => $data[3],
'uidnext' => $data[4],
'modseq' => $data[5],
);
}
return null;
} | [
"private",
"function",
"get_index_row",
"(",
"$",
"mailbox",
")",
"{",
"// Get index from DB",
"$",
"sql_result",
"=",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"\"SELECT `data`, `valid`\"",
".",
"\" FROM {$this->index_table}\"",
".",
"\" WHERE `user_id` = ?\"",
".... | Fetches index data from database | [
"Fetches",
"index",
"data",
"from",
"database"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap_cache.php#L705-L736 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_imap_cache.php | rcube_imap_cache.get_thread_row | private function get_thread_row($mailbox)
{
// Get thread from DB
$sql_result = $this->db->query(
"SELECT `data`"
." FROM {$this->thread_table}"
." WHERE `user_id` = ?"
." AND `mailbox` = ?",
$this->userid, $mailbox);
if ($sql_arr = $this->db->fetch_assoc($sql_result)) {
$data = explode('@', $sql_arr['data']);
$thread = $this->db->decode($data[0], true);
unset($data[0]);
if (empty($thread)) {
$thread = new rcube_result_thread($mailbox);
}
return array(
'object' => $thread,
'deleted' => $data[1],
'validity' => $data[2],
'uidnext' => $data[3],
);
}
return null;
} | php | private function get_thread_row($mailbox)
{
// Get thread from DB
$sql_result = $this->db->query(
"SELECT `data`"
." FROM {$this->thread_table}"
." WHERE `user_id` = ?"
." AND `mailbox` = ?",
$this->userid, $mailbox);
if ($sql_arr = $this->db->fetch_assoc($sql_result)) {
$data = explode('@', $sql_arr['data']);
$thread = $this->db->decode($data[0], true);
unset($data[0]);
if (empty($thread)) {
$thread = new rcube_result_thread($mailbox);
}
return array(
'object' => $thread,
'deleted' => $data[1],
'validity' => $data[2],
'uidnext' => $data[3],
);
}
return null;
} | [
"private",
"function",
"get_thread_row",
"(",
"$",
"mailbox",
")",
"{",
"// Get thread from DB",
"$",
"sql_result",
"=",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"\"SELECT `data`\"",
".",
"\" FROM {$this->thread_table}\"",
".",
"\" WHERE `user_id` = ?\"",
".",
"... | Fetches thread data from database | [
"Fetches",
"thread",
"data",
"from",
"database"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap_cache.php#L741-L769 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_imap_cache.php | rcube_imap_cache.add_index_row | private function add_index_row($mailbox, $sort_field,
$data, $mbox_data = array(), $exists = false, $modseq = null)
{
$data = array(
$this->db->encode($data, true),
$sort_field,
(int) $this->skip_deleted,
(int) $mbox_data['UIDVALIDITY'],
(int) $mbox_data['UIDNEXT'],
$modseq ? $modseq : $mbox_data['HIGHESTMODSEQ'],
);
$data = implode('@', $data);
$expires = $this->ttl ? $this->db->now($this->ttl) : 'NULL';
if ($exists) {
$res = $this->db->query(
"UPDATE {$this->index_table}"
." SET `data` = ?, `valid` = 1, `expires` = $expires"
." WHERE `user_id` = ?"
." AND `mailbox` = ?",
$data, $this->userid, $mailbox);
if ($this->db->affected_rows($res)) {
return;
}
}
$this->db->set_option('ignore_key_errors', true);
$res = $this->db->query(
"INSERT INTO {$this->index_table}"
." (`user_id`, `mailbox`, `valid`, `expires`, `data`)"
." VALUES (?, ?, 1, $expires, ?)",
$this->userid, $mailbox, $data);
// race-condition, insert failed so try update (#1489146)
// thanks to ignore_key_errors "duplicate row" errors will be ignored
if (!$exists && !$res && !$this->db->is_error($res)) {
$res = $this->db->query(
"UPDATE {$this->index_table}"
." SET `data` = ?, `valid` = 1, `expires` = $expires"
." WHERE `user_id` = ?"
." AND `mailbox` = ?",
$data, $this->userid, $mailbox);
}
$this->db->set_option('ignore_key_errors', false);
} | php | private function add_index_row($mailbox, $sort_field,
$data, $mbox_data = array(), $exists = false, $modseq = null)
{
$data = array(
$this->db->encode($data, true),
$sort_field,
(int) $this->skip_deleted,
(int) $mbox_data['UIDVALIDITY'],
(int) $mbox_data['UIDNEXT'],
$modseq ? $modseq : $mbox_data['HIGHESTMODSEQ'],
);
$data = implode('@', $data);
$expires = $this->ttl ? $this->db->now($this->ttl) : 'NULL';
if ($exists) {
$res = $this->db->query(
"UPDATE {$this->index_table}"
." SET `data` = ?, `valid` = 1, `expires` = $expires"
." WHERE `user_id` = ?"
." AND `mailbox` = ?",
$data, $this->userid, $mailbox);
if ($this->db->affected_rows($res)) {
return;
}
}
$this->db->set_option('ignore_key_errors', true);
$res = $this->db->query(
"INSERT INTO {$this->index_table}"
." (`user_id`, `mailbox`, `valid`, `expires`, `data`)"
." VALUES (?, ?, 1, $expires, ?)",
$this->userid, $mailbox, $data);
// race-condition, insert failed so try update (#1489146)
// thanks to ignore_key_errors "duplicate row" errors will be ignored
if (!$exists && !$res && !$this->db->is_error($res)) {
$res = $this->db->query(
"UPDATE {$this->index_table}"
." SET `data` = ?, `valid` = 1, `expires` = $expires"
." WHERE `user_id` = ?"
." AND `mailbox` = ?",
$data, $this->userid, $mailbox);
}
$this->db->set_option('ignore_key_errors', false);
} | [
"private",
"function",
"add_index_row",
"(",
"$",
"mailbox",
",",
"$",
"sort_field",
",",
"$",
"data",
",",
"$",
"mbox_data",
"=",
"array",
"(",
")",
",",
"$",
"exists",
"=",
"false",
",",
"$",
"modseq",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"ar... | Saves index data into database | [
"Saves",
"index",
"data",
"into",
"database"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap_cache.php#L774-L822 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_imap_cache.php | rcube_imap_cache.build_message | private function build_message($sql_arr)
{
$message = $this->db->decode($sql_arr['data'], true);
if ($message) {
$message->flags = array();
foreach ($this->flags as $idx => $flag) {
if (($sql_arr['flags'] & $idx) == $idx) {
$message->flags[$flag] = true;
}
}
}
return $message;
} | php | private function build_message($sql_arr)
{
$message = $this->db->decode($sql_arr['data'], true);
if ($message) {
$message->flags = array();
foreach ($this->flags as $idx => $flag) {
if (($sql_arr['flags'] & $idx) == $idx) {
$message->flags[$flag] = true;
}
}
}
return $message;
} | [
"private",
"function",
"build_message",
"(",
"$",
"sql_arr",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"db",
"->",
"decode",
"(",
"$",
"sql_arr",
"[",
"'data'",
"]",
",",
"true",
")",
";",
"if",
"(",
"$",
"message",
")",
"{",
"$",
"message"... | Converts cache row into message object.
@param array $sql_arr Message row data
@return rcube_message_header Message object | [
"Converts",
"cache",
"row",
"into",
"message",
"object",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap_cache.php#L1182-L1196 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_imap_cache.php | rcube_imap_cache.save_icache | private function save_icache()
{
// Save current message from internal cache
if ($message = $this->icache['__message']) {
// clean up some object's data
$this->message_object_prepare($message['object']);
// calculate current md5 sum
$md5sum = md5(serialize($message['object']));
if ($message['md5sum'] != $md5sum) {
$this->add_message($message['mailbox'], $message['object'], !$message['exists']);
}
$this->icache['__message']['md5sum'] = $md5sum;
}
} | php | private function save_icache()
{
// Save current message from internal cache
if ($message = $this->icache['__message']) {
// clean up some object's data
$this->message_object_prepare($message['object']);
// calculate current md5 sum
$md5sum = md5(serialize($message['object']));
if ($message['md5sum'] != $md5sum) {
$this->add_message($message['mailbox'], $message['object'], !$message['exists']);
}
$this->icache['__message']['md5sum'] = $md5sum;
}
} | [
"private",
"function",
"save_icache",
"(",
")",
"{",
"// Save current message from internal cache",
"if",
"(",
"$",
"message",
"=",
"$",
"this",
"->",
"icache",
"[",
"'__message'",
"]",
")",
"{",
"// clean up some object's data",
"$",
"this",
"->",
"message_object_p... | Saves message stored in internal cache | [
"Saves",
"message",
"stored",
"in",
"internal",
"cache"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap_cache.php#L1201-L1217 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_imap_cache.php | rcube_imap_cache.message_object_prepare | private function message_object_prepare(&$msg, &$size = 0)
{
// Remove body too big
if (isset($msg->body)) {
$length = strlen($msg->body);
if ($msg->body_modified || $size + $length > $this->threshold * 1024) {
unset($msg->body);
}
else {
$size += $length;
}
}
// Fix mimetype which might be broken by some code when message is displayed
// Another solution would be to use object's copy in rcube_message class
// to prevent related issues, however I'm not sure which is better
if ($msg->mimetype) {
list($msg->ctype_primary, $msg->ctype_secondary) = explode('/', $msg->mimetype);
}
unset($msg->replaces);
if (is_object($msg->structure)) {
$this->message_object_prepare($msg->structure, $size);
}
if (is_array($msg->parts)) {
foreach ($msg->parts as $part) {
$this->message_object_prepare($part, $size);
}
}
} | php | private function message_object_prepare(&$msg, &$size = 0)
{
// Remove body too big
if (isset($msg->body)) {
$length = strlen($msg->body);
if ($msg->body_modified || $size + $length > $this->threshold * 1024) {
unset($msg->body);
}
else {
$size += $length;
}
}
// Fix mimetype which might be broken by some code when message is displayed
// Another solution would be to use object's copy in rcube_message class
// to prevent related issues, however I'm not sure which is better
if ($msg->mimetype) {
list($msg->ctype_primary, $msg->ctype_secondary) = explode('/', $msg->mimetype);
}
unset($msg->replaces);
if (is_object($msg->structure)) {
$this->message_object_prepare($msg->structure, $size);
}
if (is_array($msg->parts)) {
foreach ($msg->parts as $part) {
$this->message_object_prepare($part, $size);
}
}
} | [
"private",
"function",
"message_object_prepare",
"(",
"&",
"$",
"msg",
",",
"&",
"$",
"size",
"=",
"0",
")",
"{",
"// Remove body too big",
"if",
"(",
"isset",
"(",
"$",
"msg",
"->",
"body",
")",
")",
"{",
"$",
"length",
"=",
"strlen",
"(",
"$",
"msg... | Prepares message object to be stored in database.
@param rcube_message_header|rcube_message_part | [
"Prepares",
"message",
"object",
"to",
"be",
"stored",
"in",
"database",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap_cache.php#L1224-L1256 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_imap_cache.php | rcube_imap_cache.get_index_data | private function get_index_data($mailbox, $sort_field, $sort_order, $mbox_data = array())
{
if (empty($mbox_data)) {
$mbox_data = $this->imap->folder_data($mailbox);
}
if ($mbox_data['EXISTS']) {
// fetch sorted sequence numbers
$index = $this->imap->index_direct($mailbox, $sort_field, $sort_order);
}
else {
$index = new rcube_result_index($mailbox, '* SORT');
}
return $index;
} | php | private function get_index_data($mailbox, $sort_field, $sort_order, $mbox_data = array())
{
if (empty($mbox_data)) {
$mbox_data = $this->imap->folder_data($mailbox);
}
if ($mbox_data['EXISTS']) {
// fetch sorted sequence numbers
$index = $this->imap->index_direct($mailbox, $sort_field, $sort_order);
}
else {
$index = new rcube_result_index($mailbox, '* SORT');
}
return $index;
} | [
"private",
"function",
"get_index_data",
"(",
"$",
"mailbox",
",",
"$",
"sort_field",
",",
"$",
"sort_order",
",",
"$",
"mbox_data",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"mbox_data",
")",
")",
"{",
"$",
"mbox_data",
"=",
"$... | Fetches index data from IMAP server | [
"Fetches",
"index",
"data",
"from",
"IMAP",
"server"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap_cache.php#L1261-L1276 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_imap_cache.php | rcube_imap_cache.get_thread_data | private function get_thread_data($mailbox, $mbox_data = array())
{
if (empty($mbox_data)) {
$mbox_data = $this->imap->folder_data($mailbox);
}
if ($mbox_data['EXISTS']) {
// get all threads (default sort order)
return $this->imap->threads_direct($mailbox);
}
return new rcube_result_thread($mailbox, '* THREAD');
} | php | private function get_thread_data($mailbox, $mbox_data = array())
{
if (empty($mbox_data)) {
$mbox_data = $this->imap->folder_data($mailbox);
}
if ($mbox_data['EXISTS']) {
// get all threads (default sort order)
return $this->imap->threads_direct($mailbox);
}
return new rcube_result_thread($mailbox, '* THREAD');
} | [
"private",
"function",
"get_thread_data",
"(",
"$",
"mailbox",
",",
"$",
"mbox_data",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"mbox_data",
")",
")",
"{",
"$",
"mbox_data",
"=",
"$",
"this",
"->",
"imap",
"->",
"folder_data",
"... | Fetches thread data from IMAP server | [
"Fetches",
"thread",
"data",
"from",
"IMAP",
"server"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_imap_cache.php#L1281-L1293 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_cache.php | rcube_cache.get | function get($key)
{
if (!array_key_exists($key, $this->cache)) {
return $this->read_record($key);
}
return $this->cache[$key];
} | php | function get($key)
{
if (!array_key_exists($key, $this->cache)) {
return $this->read_record($key);
}
return $this->cache[$key];
} | [
"function",
"get",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"cache",
")",
")",
"{",
"return",
"$",
"this",
"->",
"read_record",
"(",
"$",
"key",
")",
";",
"}",
"return",
"$",
"this",
... | Returns cached value.
@param string $key Cache key name
@return mixed Cached value | [
"Returns",
"cached",
"value",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_cache.php#L101-L108 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_cache.php | rcube_cache.read | function read($key)
{
if (array_key_exists($key, $this->cache)) {
return $this->cache[$key];
}
return $this->read_record($key, true);
} | php | function read($key)
{
if (array_key_exists($key, $this->cache)) {
return $this->cache[$key];
}
return $this->read_record($key, true);
} | [
"function",
"read",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"cache",
")",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"r... | Returns cached value without storing it in internal memory.
@param string $key Cache key name
@return mixed Cached value | [
"Returns",
"cached",
"value",
"without",
"storing",
"it",
"in",
"internal",
"memory",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_cache.php#L129-L136 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_cache.php | rcube_cache.gc | static function gc()
{
$rcube = rcube::get_instance();
$db = $rcube->get_dbh();
$db->query("DELETE FROM " . $db->table_name('cache', true) . " WHERE `expires` < " . $db->now());
} | php | static function gc()
{
$rcube = rcube::get_instance();
$db = $rcube->get_dbh();
$db->query("DELETE FROM " . $db->table_name('cache', true) . " WHERE `expires` < " . $db->now());
} | [
"static",
"function",
"gc",
"(",
")",
"{",
"$",
"rcube",
"=",
"rcube",
"::",
"get_instance",
"(",
")",
";",
"$",
"db",
"=",
"$",
"rcube",
"->",
"get_dbh",
"(",
")",
";",
"$",
"db",
"->",
"query",
"(",
"\"DELETE FROM \"",
".",
"$",
"db",
"->",
"ta... | Remove expired records of all caches | [
"Remove",
"expired",
"records",
"of",
"all",
"caches"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_cache.php#L207-L213 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_cache.php | rcube_cache.close | function close()
{
foreach ($this->cache as $key => $data) {
// The key has been used
if ($this->cache_changes[$key]) {
// Make sure we're not going to write unchanged data
// by comparing current md5 sum with the sum calculated on DB read
$data = $this->serialize($data);
if (!$this->cache_sums[$key] || $this->cache_sums[$key] != md5($data)) {
$this->write_record($key, $data);
}
}
}
if ($this->index_changed) {
$this->write_index();
}
// reset internal cache index, thanks to this we can force index reload
$this->index = null;
$this->index_changed = false;
$this->cache = array();
$this->cache_sums = array();
$this->cache_changes = array();
} | php | function close()
{
foreach ($this->cache as $key => $data) {
// The key has been used
if ($this->cache_changes[$key]) {
// Make sure we're not going to write unchanged data
// by comparing current md5 sum with the sum calculated on DB read
$data = $this->serialize($data);
if (!$this->cache_sums[$key] || $this->cache_sums[$key] != md5($data)) {
$this->write_record($key, $data);
}
}
}
if ($this->index_changed) {
$this->write_index();
}
// reset internal cache index, thanks to this we can force index reload
$this->index = null;
$this->index_changed = false;
$this->cache = array();
$this->cache_sums = array();
$this->cache_changes = array();
} | [
"function",
"close",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"cache",
"as",
"$",
"key",
"=>",
"$",
"data",
")",
"{",
"// The key has been used",
"if",
"(",
"$",
"this",
"->",
"cache_changes",
"[",
"$",
"key",
"]",
")",
"{",
"// Make sure we'r... | Writes the cache back to the DB. | [
"Writes",
"the",
"cache",
"back",
"to",
"the",
"DB",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_cache.php#L218-L243 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_cache.php | rcube_cache.read_record | private function read_record($key, $nostore=false)
{
if (!$this->db) {
return null;
}
if ($this->type != 'db') {
$this->load_index();
// Consistency check (#1490390)
if (!in_array($key, $this->index)) {
// we always check if the key exist in the index
// to have data in consistent state. Keeping the index consistent
// is needed for keys delete operation when we delete all keys or by prefix.
}
else {
$ckey = $this->ckey($key);
if ($this->type == 'memcache') {
$data = $this->db->get($ckey);
}
else if ($this->type == 'apc') {
$data = apc_fetch($ckey);
}
if ($this->debug) {
$this->debug('get', $ckey, $data);
}
}
if ($data !== false) {
$md5sum = md5($data);
$data = $this->unserialize($data);
if ($nostore) {
return $data;
}
$this->cache_sums[$key] = $md5sum;
$this->cache[$key] = $data;
}
else {
$this->cache[$key] = null;
}
}
else {
$sql_result = $this->db->query(
"SELECT `data`, `cache_key` FROM {$this->table}"
. " WHERE `user_id` = ? AND `cache_key` = ?",
$this->userid, $this->prefix.'.'.$key);
if ($sql_arr = $this->db->fetch_assoc($sql_result)) {
if (strlen($sql_arr['data']) > 0) {
$md5sum = md5($sql_arr['data']);
$data = $this->unserialize($sql_arr['data']);
}
$this->db->reset();
if ($nostore) {
return $data;
}
$this->cache[$key] = $data;
$this->cache_sums[$key] = $md5sum;
}
else {
$this->cache[$key] = null;
}
}
return $this->cache[$key];
} | php | private function read_record($key, $nostore=false)
{
if (!$this->db) {
return null;
}
if ($this->type != 'db') {
$this->load_index();
// Consistency check (#1490390)
if (!in_array($key, $this->index)) {
// we always check if the key exist in the index
// to have data in consistent state. Keeping the index consistent
// is needed for keys delete operation when we delete all keys or by prefix.
}
else {
$ckey = $this->ckey($key);
if ($this->type == 'memcache') {
$data = $this->db->get($ckey);
}
else if ($this->type == 'apc') {
$data = apc_fetch($ckey);
}
if ($this->debug) {
$this->debug('get', $ckey, $data);
}
}
if ($data !== false) {
$md5sum = md5($data);
$data = $this->unserialize($data);
if ($nostore) {
return $data;
}
$this->cache_sums[$key] = $md5sum;
$this->cache[$key] = $data;
}
else {
$this->cache[$key] = null;
}
}
else {
$sql_result = $this->db->query(
"SELECT `data`, `cache_key` FROM {$this->table}"
. " WHERE `user_id` = ? AND `cache_key` = ?",
$this->userid, $this->prefix.'.'.$key);
if ($sql_arr = $this->db->fetch_assoc($sql_result)) {
if (strlen($sql_arr['data']) > 0) {
$md5sum = md5($sql_arr['data']);
$data = $this->unserialize($sql_arr['data']);
}
$this->db->reset();
if ($nostore) {
return $data;
}
$this->cache[$key] = $data;
$this->cache_sums[$key] = $md5sum;
}
else {
$this->cache[$key] = null;
}
}
return $this->cache[$key];
} | [
"private",
"function",
"read_record",
"(",
"$",
"key",
",",
"$",
"nostore",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"db",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"type",
"!=",
"'db'",
")",
"{",
"$"... | Reads cache entry.
@param string $key Cache key name
@param boolean $nostore Enable to skip in-memory store
@return mixed Cached value | [
"Reads",
"cache",
"entry",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_cache.php#L253-L325 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_cache.php | rcube_cache.write_record | private function write_record($key, $data)
{
if (!$this->db) {
return false;
}
// don't attempt to write too big data sets
if (strlen($data) > $this->max_packet_size()) {
trigger_error("rcube_cache: max_packet_size ($this->max_packet) exceeded for key $key. Tried to write " . strlen($data) . " bytes", E_USER_WARNING);
return false;
}
if ($this->type == 'memcache' || $this->type == 'apc') {
$result = $this->add_record($this->ckey($key), $data);
// make sure index will be updated
if ($result) {
if (!array_key_exists($key, $this->cache_sums)) {
$this->cache_sums[$key] = true;
}
$this->load_index();
if (!$this->index_changed && !in_array($key, $this->index)) {
$this->index_changed = true;
}
}
return $result;
}
$db_key = $this->prefix . '.' . $key;
// Remove NULL rows (here we don't need to check if the record exist)
if ($data == 'N;') {
$result = $this->db->query(
"DELETE FROM {$this->table}".
" WHERE `user_id` = ? AND `cache_key` = ?",
$this->userid, $db_key);
return !$this->db->is_error($result);
}
$key_exists = array_key_exists($key, $this->cache_sums);
$expires = $this->ttl ? $this->db->now($this->ttl) : 'NULL';
if (!$key_exists) {
// Try INSERT temporarily ignoring "duplicate key" errors
$this->db->set_option('ignore_key_errors', true);
$result = $this->db->query(
"INSERT INTO {$this->table} (`expires`, `user_id`, `cache_key`, `data`)"
. " VALUES ($expires, ?, ?, ?)",
$this->userid, $db_key, $data);
$this->db->set_option('ignore_key_errors', false);
}
// otherwise try UPDATE
if (!isset($result) || !($count = $this->db->affected_rows($result))) {
$result = $this->db->query(
"UPDATE {$this->table} SET `expires` = $expires, `data` = ?"
. " WHERE `user_id` = ? AND `cache_key` = ?",
$data, $this->userid, $db_key);
$count = $this->db->affected_rows($result);
}
return $count > 0;
} | php | private function write_record($key, $data)
{
if (!$this->db) {
return false;
}
// don't attempt to write too big data sets
if (strlen($data) > $this->max_packet_size()) {
trigger_error("rcube_cache: max_packet_size ($this->max_packet) exceeded for key $key. Tried to write " . strlen($data) . " bytes", E_USER_WARNING);
return false;
}
if ($this->type == 'memcache' || $this->type == 'apc') {
$result = $this->add_record($this->ckey($key), $data);
// make sure index will be updated
if ($result) {
if (!array_key_exists($key, $this->cache_sums)) {
$this->cache_sums[$key] = true;
}
$this->load_index();
if (!$this->index_changed && !in_array($key, $this->index)) {
$this->index_changed = true;
}
}
return $result;
}
$db_key = $this->prefix . '.' . $key;
// Remove NULL rows (here we don't need to check if the record exist)
if ($data == 'N;') {
$result = $this->db->query(
"DELETE FROM {$this->table}".
" WHERE `user_id` = ? AND `cache_key` = ?",
$this->userid, $db_key);
return !$this->db->is_error($result);
}
$key_exists = array_key_exists($key, $this->cache_sums);
$expires = $this->ttl ? $this->db->now($this->ttl) : 'NULL';
if (!$key_exists) {
// Try INSERT temporarily ignoring "duplicate key" errors
$this->db->set_option('ignore_key_errors', true);
$result = $this->db->query(
"INSERT INTO {$this->table} (`expires`, `user_id`, `cache_key`, `data`)"
. " VALUES ($expires, ?, ?, ?)",
$this->userid, $db_key, $data);
$this->db->set_option('ignore_key_errors', false);
}
// otherwise try UPDATE
if (!isset($result) || !($count = $this->db->affected_rows($result))) {
$result = $this->db->query(
"UPDATE {$this->table} SET `expires` = $expires, `data` = ?"
. " WHERE `user_id` = ? AND `cache_key` = ?",
$data, $this->userid, $db_key);
$count = $this->db->affected_rows($result);
}
return $count > 0;
} | [
"private",
"function",
"write_record",
"(",
"$",
"key",
",",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"db",
")",
"{",
"return",
"false",
";",
"}",
"// don't attempt to write too big data sets",
"if",
"(",
"strlen",
"(",
"$",
"data",
")",... | Writes single cache record into DB.
@param string $key Cache key name
@param mixed $data Serialized cache data
@param boolean True on success, False on failure | [
"Writes",
"single",
"cache",
"record",
"into",
"DB",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_cache.php#L335-L404 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_cache.php | rcube_cache.serialize | private function serialize($data)
{
if ($this->type == 'db') {
return $this->db->encode($data, $this->packed);
}
return $this->packed ? serialize($data) : $data;
} | php | private function serialize($data)
{
if ($this->type == 'db') {
return $this->db->encode($data, $this->packed);
}
return $this->packed ? serialize($data) : $data;
} | [
"private",
"function",
"serialize",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"type",
"==",
"'db'",
")",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"encode",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"packed",
")",
";",
"}",
... | Serializes data for storing | [
"Serializes",
"data",
"for",
"storing"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_cache.php#L610-L617 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_cache.php | rcube_cache.unserialize | private function unserialize($data)
{
if ($this->type == 'db') {
return $this->db->decode($data, $this->packed);
}
return $this->packed ? @unserialize($data) : $data;
} | php | private function unserialize($data)
{
if ($this->type == 'db') {
return $this->db->decode($data, $this->packed);
}
return $this->packed ? @unserialize($data) : $data;
} | [
"private",
"function",
"unserialize",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"type",
"==",
"'db'",
")",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"decode",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"packed",
")",
";",
"}",
... | Unserializes serialized data | [
"Unserializes",
"serialized",
"data"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_cache.php#L622-L629 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_cache.php | rcube_cache.max_packet_size | private function max_packet_size()
{
if ($this->max_packet < 0) {
$this->max_packet = 2097152; // default/max is 2 MB
if ($this->type == 'db') {
if ($value = $this->db->get_variable('max_allowed_packet', $this->max_packet)) {
$this->max_packet = $value;
}
$this->max_packet -= 2000;
}
else {
$max_packet = rcube::get_instance()->config->get($this->type . '_max_allowed_packet');
$this->max_packet = parse_bytes($max_packet) ?: $this->max_packet;
}
}
return $this->max_packet;
} | php | private function max_packet_size()
{
if ($this->max_packet < 0) {
$this->max_packet = 2097152; // default/max is 2 MB
if ($this->type == 'db') {
if ($value = $this->db->get_variable('max_allowed_packet', $this->max_packet)) {
$this->max_packet = $value;
}
$this->max_packet -= 2000;
}
else {
$max_packet = rcube::get_instance()->config->get($this->type . '_max_allowed_packet');
$this->max_packet = parse_bytes($max_packet) ?: $this->max_packet;
}
}
return $this->max_packet;
} | [
"private",
"function",
"max_packet_size",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"max_packet",
"<",
"0",
")",
"{",
"$",
"this",
"->",
"max_packet",
"=",
"2097152",
";",
"// default/max is 2 MB",
"if",
"(",
"$",
"this",
"->",
"type",
"==",
"'db'",
... | Determine the maximum size for cache data to be written | [
"Determine",
"the",
"maximum",
"size",
"for",
"cache",
"data",
"to",
"be",
"written"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_cache.php#L634-L652 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_session_db.php | rcube_session_db.read | public function read($key)
{
$sql_result = $this->db->query(
"SELECT `vars`, `ip`, `changed`, " . $this->db->now() . " AS ts"
. " FROM {$this->table_name} WHERE `sess_id` = ?", $key);
if ($sql_result && ($sql_arr = $this->db->fetch_assoc($sql_result))) {
$this->time_diff = time() - strtotime($sql_arr['ts']);
$this->changed = strtotime($sql_arr['changed']);
$this->ip = $sql_arr['ip'];
$this->vars = base64_decode($sql_arr['vars']);
$this->key = $key;
$this->db->reset();
return !empty($this->vars) ? (string) $this->vars : '';
}
return '';
} | php | public function read($key)
{
$sql_result = $this->db->query(
"SELECT `vars`, `ip`, `changed`, " . $this->db->now() . " AS ts"
. " FROM {$this->table_name} WHERE `sess_id` = ?", $key);
if ($sql_result && ($sql_arr = $this->db->fetch_assoc($sql_result))) {
$this->time_diff = time() - strtotime($sql_arr['ts']);
$this->changed = strtotime($sql_arr['changed']);
$this->ip = $sql_arr['ip'];
$this->vars = base64_decode($sql_arr['vars']);
$this->key = $key;
$this->db->reset();
return !empty($this->vars) ? (string) $this->vars : '';
}
return '';
} | [
"public",
"function",
"read",
"(",
"$",
"key",
")",
"{",
"$",
"sql_result",
"=",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"\"SELECT `vars`, `ip`, `changed`, \"",
".",
"$",
"this",
"->",
"db",
"->",
"now",
"(",
")",
".",
"\" AS ts\"",
".",
"\" FROM {$... | Read session data from database
@param string Session ID
@return string Session vars | [
"Read",
"session",
"data",
"from",
"database"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_session_db.php#L96-L115 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_session_db.php | rcube_session_db.write | public function write($key, $vars)
{
$now = $this->db->now();
$this->db->query("INSERT INTO {$this->table_name}"
. " (`sess_id`, `vars`, `ip`, `changed`)"
. " VALUES (?, ?, ?, $now)",
$key, base64_encode($vars), (string)$this->ip);
return true;
} | php | public function write($key, $vars)
{
$now = $this->db->now();
$this->db->query("INSERT INTO {$this->table_name}"
. " (`sess_id`, `vars`, `ip`, `changed`)"
. " VALUES (?, ?, ?, $now)",
$key, base64_encode($vars), (string)$this->ip);
return true;
} | [
"public",
"function",
"write",
"(",
"$",
"key",
",",
"$",
"vars",
")",
"{",
"$",
"now",
"=",
"$",
"this",
"->",
"db",
"->",
"now",
"(",
")",
";",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"\"INSERT INTO {$this->table_name}\"",
".",
"\" (`sess_id`, `... | insert new data into db session store
@param $key
@param $vars
@return bool | [
"insert",
"new",
"data",
"into",
"db",
"session",
"store"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_session_db.php#L124-L134 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_session_db.php | rcube_session_db.update | public function update($key, $newvars, $oldvars)
{
$now = $this->db->now();
$ts = microtime(true);
// if new and old data are not the same, update data
// else update expire timestamp only when certain conditions are met
if ($newvars !== $oldvars) {
$this->db->query("UPDATE {$this->table_name} "
. "SET `changed` = $now, `vars` = ? WHERE `sess_id` = ?",
base64_encode($newvars), $key);
}
else if ($ts - $this->changed + $this->time_diff > $this->lifetime / 2) {
$this->db->query("UPDATE {$this->table_name} SET `changed` = $now"
. " WHERE `sess_id` = ?", $key);
}
return true;
} | php | public function update($key, $newvars, $oldvars)
{
$now = $this->db->now();
$ts = microtime(true);
// if new and old data are not the same, update data
// else update expire timestamp only when certain conditions are met
if ($newvars !== $oldvars) {
$this->db->query("UPDATE {$this->table_name} "
. "SET `changed` = $now, `vars` = ? WHERE `sess_id` = ?",
base64_encode($newvars), $key);
}
else if ($ts - $this->changed + $this->time_diff > $this->lifetime / 2) {
$this->db->query("UPDATE {$this->table_name} SET `changed` = $now"
. " WHERE `sess_id` = ?", $key);
}
return true;
} | [
"public",
"function",
"update",
"(",
"$",
"key",
",",
"$",
"newvars",
",",
"$",
"oldvars",
")",
"{",
"$",
"now",
"=",
"$",
"this",
"->",
"db",
"->",
"now",
"(",
")",
";",
"$",
"ts",
"=",
"microtime",
"(",
"true",
")",
";",
"// if new and old data a... | update session data
@param $key
@param $newvars
@param $oldvars
@return bool | [
"update",
"session",
"data"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_session_db.php#L145-L163 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_session_db.php | rcube_session_db.gc_db | public function gc_db()
{
// just clean all old sessions when this GC is called
$this->db->query("DELETE FROM " . $this->db->table_name('session')
. " WHERE changed < " . $this->db->now(-$this->gc_enabled));
$this->log("Session GC (DB): remove records < "
. date('Y-m-d H:i:s', time() - $this->gc_enabled)
. '; rows = ' . intval($this->db->affected_rows()));
} | php | public function gc_db()
{
// just clean all old sessions when this GC is called
$this->db->query("DELETE FROM " . $this->db->table_name('session')
. " WHERE changed < " . $this->db->now(-$this->gc_enabled));
$this->log("Session GC (DB): remove records < "
. date('Y-m-d H:i:s', time() - $this->gc_enabled)
. '; rows = ' . intval($this->db->affected_rows()));
} | [
"public",
"function",
"gc_db",
"(",
")",
"{",
"// just clean all old sessions when this GC is called",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"\"DELETE FROM \"",
".",
"$",
"this",
"->",
"db",
"->",
"table_name",
"(",
"'session'",
")",
".",
"\" WHERE changed ... | Clean up db sessions. | [
"Clean",
"up",
"db",
"sessions",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_session_db.php#L168-L177 | train |
i-MSCP/roundcube | roundcubemail/plugins/archive/archive.php | archive.render_mailboxlist | function render_mailboxlist($p)
{
$rcmail = rcmail::get_instance();
$archive_folder = $rcmail->config->get('archive_mbox');
$show_real_name = $rcmail->config->get('show_real_foldernames');
// set localized name for the configured archive folder
if ($archive_folder && !$show_real_name) {
if (isset($p['list'][$archive_folder])) {
$p['list'][$archive_folder]['name'] = $this->gettext('archivefolder');
}
else {
// search in subfolders
$this->_mod_folder_name($p['list'], $archive_folder, $this->gettext('archivefolder'));
}
}
return $p;
} | php | function render_mailboxlist($p)
{
$rcmail = rcmail::get_instance();
$archive_folder = $rcmail->config->get('archive_mbox');
$show_real_name = $rcmail->config->get('show_real_foldernames');
// set localized name for the configured archive folder
if ($archive_folder && !$show_real_name) {
if (isset($p['list'][$archive_folder])) {
$p['list'][$archive_folder]['name'] = $this->gettext('archivefolder');
}
else {
// search in subfolders
$this->_mod_folder_name($p['list'], $archive_folder, $this->gettext('archivefolder'));
}
}
return $p;
} | [
"function",
"render_mailboxlist",
"(",
"$",
"p",
")",
"{",
"$",
"rcmail",
"=",
"rcmail",
"::",
"get_instance",
"(",
")",
";",
"$",
"archive_folder",
"=",
"$",
"rcmail",
"->",
"config",
"->",
"get",
"(",
"'archive_mbox'",
")",
";",
"$",
"show_real_name",
... | Hook to give the archive folder a localized name in the mailbox list | [
"Hook",
"to",
"give",
"the",
"archive",
"folder",
"a",
"localized",
"name",
"in",
"the",
"mailbox",
"list"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/archive/archive.php#L69-L87 | train |
i-MSCP/roundcube | roundcubemail/plugins/archive/archive.php | archive._mod_folder_name | private function _mod_folder_name(&$list, $folder, $new_name)
{
foreach ($list as $idx => $item) {
if ($item['id'] == $folder) {
$list[$idx]['name'] = $new_name;
return true;
}
else if (!empty($item['folders'])) {
if ($this->_mod_folder_name($list[$idx]['folders'], $folder, $new_name)) {
return true;
}
}
}
return false;
} | php | private function _mod_folder_name(&$list, $folder, $new_name)
{
foreach ($list as $idx => $item) {
if ($item['id'] == $folder) {
$list[$idx]['name'] = $new_name;
return true;
}
else if (!empty($item['folders'])) {
if ($this->_mod_folder_name($list[$idx]['folders'], $folder, $new_name)) {
return true;
}
}
}
return false;
} | [
"private",
"function",
"_mod_folder_name",
"(",
"&",
"$",
"list",
",",
"$",
"folder",
",",
"$",
"new_name",
")",
"{",
"foreach",
"(",
"$",
"list",
"as",
"$",
"idx",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"[",
"'id'",
"]",
"==",
"$",... | Helper method to find the archive folder in the mailbox tree | [
"Helper",
"method",
"to",
"find",
"the",
"archive",
"folder",
"in",
"the",
"mailbox",
"tree"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/archive/archive.php#L92-L107 | train |
i-MSCP/roundcube | roundcubemail/plugins/archive/archive.php | archive.move_messages_worker | private function move_messages_worker($uids, $from_mbox, $to_mbox, $read_on_move)
{
$storage = rcmail::get_instance()->get_storage();
if ($read_on_move) {
// don't flush cache (4th argument)
$storage->set_flag($uids, 'SEEN', $from_mbox, true);
}
// move message to target folder
if ($storage->move_message($uids, $to_mbox, $from_mbox)) {
if (!in_array($from_mbox, $this->result['sources'])) {
$this->result['sources'][] = $from_mbox;
}
if (!in_array($to_mbox, $this->result['destinations'])) {
$this->result['destinations'][] = $to_mbox;
}
return count($uids);
}
$this->result['error'] = true;
} | php | private function move_messages_worker($uids, $from_mbox, $to_mbox, $read_on_move)
{
$storage = rcmail::get_instance()->get_storage();
if ($read_on_move) {
// don't flush cache (4th argument)
$storage->set_flag($uids, 'SEEN', $from_mbox, true);
}
// move message to target folder
if ($storage->move_message($uids, $to_mbox, $from_mbox)) {
if (!in_array($from_mbox, $this->result['sources'])) {
$this->result['sources'][] = $from_mbox;
}
if (!in_array($to_mbox, $this->result['destinations'])) {
$this->result['destinations'][] = $to_mbox;
}
return count($uids);
}
$this->result['error'] = true;
} | [
"private",
"function",
"move_messages_worker",
"(",
"$",
"uids",
",",
"$",
"from_mbox",
",",
"$",
"to_mbox",
",",
"$",
"read_on_move",
")",
"{",
"$",
"storage",
"=",
"rcmail",
"::",
"get_instance",
"(",
")",
"->",
"get_storage",
"(",
")",
";",
"if",
"(",... | Move messages from one folder to another and mark as read if needed | [
"Move",
"messages",
"from",
"one",
"folder",
"to",
"another",
"and",
"mark",
"as",
"read",
"if",
"needed"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/archive/archive.php#L321-L343 | train |
i-MSCP/roundcube | roundcubemail/plugins/archive/archive.php | archive.subfolder_worker | private function subfolder_worker($folder)
{
$storage = rcmail::get_instance()->get_storage();
$delimiter = $storage->get_hierarchy_delimiter();
if ($this->folders === null) {
$this->folders = $storage->list_folders('', $archive_folder . '*', 'mail', null, true);
}
if (!in_array($folder, $this->folders)) {
$path = explode($delimiter, $folder);
// we'll create all folders in the path
for ($i=0; $i<count($path); $i++) {
$_folder = implode($delimiter, array_slice($path, 0, $i+1));
if (!in_array($_folder, $this->folders)) {
if ($storage->create_folder($_folder, true)) {
$this->result['reload'] = true;
$this->folders[] = $_folder;
}
}
}
}
} | php | private function subfolder_worker($folder)
{
$storage = rcmail::get_instance()->get_storage();
$delimiter = $storage->get_hierarchy_delimiter();
if ($this->folders === null) {
$this->folders = $storage->list_folders('', $archive_folder . '*', 'mail', null, true);
}
if (!in_array($folder, $this->folders)) {
$path = explode($delimiter, $folder);
// we'll create all folders in the path
for ($i=0; $i<count($path); $i++) {
$_folder = implode($delimiter, array_slice($path, 0, $i+1));
if (!in_array($_folder, $this->folders)) {
if ($storage->create_folder($_folder, true)) {
$this->result['reload'] = true;
$this->folders[] = $_folder;
}
}
}
}
} | [
"private",
"function",
"subfolder_worker",
"(",
"$",
"folder",
")",
"{",
"$",
"storage",
"=",
"rcmail",
"::",
"get_instance",
"(",
")",
"->",
"get_storage",
"(",
")",
";",
"$",
"delimiter",
"=",
"$",
"storage",
"->",
"get_hierarchy_delimiter",
"(",
")",
";... | Create archive subfolder if it doesn't yet exist | [
"Create",
"archive",
"subfolder",
"if",
"it",
"doesn",
"t",
"yet",
"exist"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/archive/archive.php#L348-L371 | train |
i-MSCP/roundcube | roundcubemail/plugins/archive/archive.php | archive.prefs_table | function prefs_table($args)
{
global $CURR_SECTION;
$this->add_texts('localization');
$rcmail = rcmail::get_instance();
$dont_override = $rcmail->config->get('dont_override', array());
if ($args['section'] == 'folders' && !in_array('archive_mbox', $dont_override)) {
$mbox = $rcmail->config->get('archive_mbox');
$type = $rcmail->config->get('archive_type');
// load folders list when needed
if ($CURR_SECTION) {
$select = $rcmail->folder_selector(array(
'noselection' => '---',
'realnames' => true,
'maxlength' => 30,
'folder_filter' => 'mail',
'folder_rights' => 'w',
'onchange' => "if ($(this).val() == 'INBOX') $(this).val('')",
));
}
else {
$select = new html_select();
}
$args['blocks']['main']['options']['archive_mbox'] = array(
'title' => $this->gettext('archivefolder'),
'content' => $select->show($mbox, array('name' => "_archive_mbox"))
);
// add option for structuring the archive folder
$archive_type = new html_select(array('name' => '_archive_type', 'id' => 'ff_archive_type'));
$archive_type->add($this->gettext('none'), '');
$archive_type->add($this->gettext('archivetypeyear'), 'year');
$archive_type->add($this->gettext('archivetypemonth'), 'month');
$archive_type->add($this->gettext('archivetypesender'), 'sender');
$archive_type->add($this->gettext('archivetypefolder'), 'folder');
$args['blocks']['archive'] = array(
'name' => rcube::Q($this->gettext('settingstitle')),
'options' => array('archive_type' => array(
'title' => $this->gettext('archivetype'),
'content' => $archive_type->show($type)
)
)
);
}
else if ($args['section'] == 'server' && !in_array('read_on_archive', $dont_override)) {
$chbox = new html_checkbox(array('name' => '_read_on_archive', 'id' => 'ff_read_on_archive', 'value' => 1));
$args['blocks']['main']['options']['read_on_archive'] = array(
'title' => $this->gettext('readonarchive'),
'content' => $chbox->show($rcmail->config->get('read_on_archive') ? 1 : 0)
);
}
return $args;
} | php | function prefs_table($args)
{
global $CURR_SECTION;
$this->add_texts('localization');
$rcmail = rcmail::get_instance();
$dont_override = $rcmail->config->get('dont_override', array());
if ($args['section'] == 'folders' && !in_array('archive_mbox', $dont_override)) {
$mbox = $rcmail->config->get('archive_mbox');
$type = $rcmail->config->get('archive_type');
// load folders list when needed
if ($CURR_SECTION) {
$select = $rcmail->folder_selector(array(
'noselection' => '---',
'realnames' => true,
'maxlength' => 30,
'folder_filter' => 'mail',
'folder_rights' => 'w',
'onchange' => "if ($(this).val() == 'INBOX') $(this).val('')",
));
}
else {
$select = new html_select();
}
$args['blocks']['main']['options']['archive_mbox'] = array(
'title' => $this->gettext('archivefolder'),
'content' => $select->show($mbox, array('name' => "_archive_mbox"))
);
// add option for structuring the archive folder
$archive_type = new html_select(array('name' => '_archive_type', 'id' => 'ff_archive_type'));
$archive_type->add($this->gettext('none'), '');
$archive_type->add($this->gettext('archivetypeyear'), 'year');
$archive_type->add($this->gettext('archivetypemonth'), 'month');
$archive_type->add($this->gettext('archivetypesender'), 'sender');
$archive_type->add($this->gettext('archivetypefolder'), 'folder');
$args['blocks']['archive'] = array(
'name' => rcube::Q($this->gettext('settingstitle')),
'options' => array('archive_type' => array(
'title' => $this->gettext('archivetype'),
'content' => $archive_type->show($type)
)
)
);
}
else if ($args['section'] == 'server' && !in_array('read_on_archive', $dont_override)) {
$chbox = new html_checkbox(array('name' => '_read_on_archive', 'id' => 'ff_read_on_archive', 'value' => 1));
$args['blocks']['main']['options']['read_on_archive'] = array(
'title' => $this->gettext('readonarchive'),
'content' => $chbox->show($rcmail->config->get('read_on_archive') ? 1 : 0)
);
}
return $args;
} | [
"function",
"prefs_table",
"(",
"$",
"args",
")",
"{",
"global",
"$",
"CURR_SECTION",
";",
"$",
"this",
"->",
"add_texts",
"(",
"'localization'",
")",
";",
"$",
"rcmail",
"=",
"rcmail",
"::",
"get_instance",
"(",
")",
";",
"$",
"dont_override",
"=",
"$",... | Hook to inject plugin-specific user settings | [
"Hook",
"to",
"inject",
"plugin",
"-",
"specific",
"user",
"settings"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/archive/archive.php#L376-L435 | train |
i-MSCP/roundcube | roundcubemail/plugins/archive/archive.php | archive.save_prefs | function save_prefs($args)
{
$rcmail = rcmail::get_instance();
$dont_override = $rcmail->config->get('dont_override', array());
if ($args['section'] == 'folders' && !in_array('archive_mbox', $dont_override)) {
$args['prefs']['archive_type'] = rcube_utils::get_input_value('_archive_type', rcube_utils::INPUT_POST);
}
else if ($args['section'] == 'server' && !in_array('read_on_archive', $dont_override)) {
$args['prefs']['read_on_archive'] = (bool) rcube_utils::get_input_value('_read_on_archive', rcube_utils::INPUT_POST);
}
return $args;
} | php | function save_prefs($args)
{
$rcmail = rcmail::get_instance();
$dont_override = $rcmail->config->get('dont_override', array());
if ($args['section'] == 'folders' && !in_array('archive_mbox', $dont_override)) {
$args['prefs']['archive_type'] = rcube_utils::get_input_value('_archive_type', rcube_utils::INPUT_POST);
}
else if ($args['section'] == 'server' && !in_array('read_on_archive', $dont_override)) {
$args['prefs']['read_on_archive'] = (bool) rcube_utils::get_input_value('_read_on_archive', rcube_utils::INPUT_POST);
}
return $args;
} | [
"function",
"save_prefs",
"(",
"$",
"args",
")",
"{",
"$",
"rcmail",
"=",
"rcmail",
"::",
"get_instance",
"(",
")",
";",
"$",
"dont_override",
"=",
"$",
"rcmail",
"->",
"config",
"->",
"get",
"(",
"'dont_override'",
",",
"array",
"(",
")",
")",
";",
... | Hook to save plugin-specific user settings | [
"Hook",
"to",
"save",
"plugin",
"-",
"specific",
"user",
"settings"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/archive/archive.php#L440-L453 | train |
netgen/NetgenInformationCollectionBundle | bundle/Core/Service/ExporterService.php | ExporterService.getCreatedDate | protected function getCreatedDate(EzInfoCollection $ezInfoCollection)
{
$date = new \DateTime();
$date->setTimestamp($ezInfoCollection->getCreated());
return $date->format('Y-m-d');
} | php | protected function getCreatedDate(EzInfoCollection $ezInfoCollection)
{
$date = new \DateTime();
$date->setTimestamp($ezInfoCollection->getCreated());
return $date->format('Y-m-d');
} | [
"protected",
"function",
"getCreatedDate",
"(",
"EzInfoCollection",
"$",
"ezInfoCollection",
")",
"{",
"$",
"date",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"date",
"->",
"setTimestamp",
"(",
"$",
"ezInfoCollection",
"->",
"getCreated",
"(",
")",
")... | Get create date from EzInfoCollection as string
@param \Netgen\Bundle\InformationCollectionBundle\Entity\EzInfoCollection $ezInfoCollection
@return string | [
"Get",
"create",
"date",
"from",
"EzInfoCollection",
"as",
"string"
] | 3ed7a2b33b1e80d3a0d9ee607eab495396044b29 | https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Core/Service/ExporterService.php#L153-L159 | train |
netgen/NetgenInformationCollectionBundle | bundle/Core/Service/ExporterService.php | ExporterService.getAttributeValue | protected function getAttributeValue($fieldId, $attributes)
{
/** @var EzInfoCollectionAttribute $attribute */
foreach ($attributes as $attribute) {
if ($fieldId === $attribute->getContentClassAttributeId()) {
$value = $attribute->getValue();
$value = str_replace('"', '""', $value);
$value = str_replace(';', ', ', $value);
$value = strip_tags($value);
return preg_replace(array( '/\r|\n/' ), array( ' ' ), $value);
}
}
return '';
} | php | protected function getAttributeValue($fieldId, $attributes)
{
/** @var EzInfoCollectionAttribute $attribute */
foreach ($attributes as $attribute) {
if ($fieldId === $attribute->getContentClassAttributeId()) {
$value = $attribute->getValue();
$value = str_replace('"', '""', $value);
$value = str_replace(';', ', ', $value);
$value = strip_tags($value);
return preg_replace(array( '/\r|\n/' ), array( ' ' ), $value);
}
}
return '';
} | [
"protected",
"function",
"getAttributeValue",
"(",
"$",
"fieldId",
",",
"$",
"attributes",
")",
"{",
"/** @var EzInfoCollectionAttribute $attribute */",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"attribute",
")",
"{",
"if",
"(",
"$",
"fieldId",
"===",
"$",
"... | Get attribute value string
@param int $fieldId
@param array $attributes
@return string | [
"Get",
"attribute",
"value",
"string"
] | 3ed7a2b33b1e80d3a0d9ee607eab495396044b29 | https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Core/Service/ExporterService.php#L169-L186 | train |
netgen/NetgenInformationCollectionBundle | bundle/Controller/Admin/TreeController.php | TreeController.getChildrenAction | public function getChildrenAction($isRoot = false)
{
$this->denyAccessUnlessGranted('ez:infocollector:read');
$result = array();
if ((bool) $isRoot) {
$result[] = $this->getRootTreeData();
} else {
$query = new Query([
'limit' => $this->getConfigResolver()->getParameter('admin.tree_limit', 'netgen_information_collection'),
]);
$objects = $this->service->getObjectsWithCollections($query);
foreach ($objects->contents as $content) {
$result[] = $this->getCollections($content, $isRoot);
}
}
return (new JsonResponse())->setData($result);
} | php | public function getChildrenAction($isRoot = false)
{
$this->denyAccessUnlessGranted('ez:infocollector:read');
$result = array();
if ((bool) $isRoot) {
$result[] = $this->getRootTreeData();
} else {
$query = new Query([
'limit' => $this->getConfigResolver()->getParameter('admin.tree_limit', 'netgen_information_collection'),
]);
$objects = $this->service->getObjectsWithCollections($query);
foreach ($objects->contents as $content) {
$result[] = $this->getCollections($content, $isRoot);
}
}
return (new JsonResponse())->setData($result);
} | [
"public",
"function",
"getChildrenAction",
"(",
"$",
"isRoot",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"denyAccessUnlessGranted",
"(",
"'ez:infocollector:read'",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"(",
"bool",
")",
"$",
"... | Get contents with collections
@param bool $isRoot
@return \Symfony\Component\HttpFoundation\JsonResponse | [
"Get",
"contents",
"with",
"collections"
] | 3ed7a2b33b1e80d3a0d9ee607eab495396044b29 | https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Controller/Admin/TreeController.php#L54-L75 | train |
netgen/NetgenInformationCollectionBundle | bundle/Controller/Admin/TreeController.php | TreeController.getCollections | protected function getCollections(Content $content, $isRoot = false)
{
$languages = $this->getConfigResolver()->getParameter('languages');
$query = new Query([
'contentId' => $content->content->id,
'limit' => Query::COUNT_QUERY,
]);
$count = $this->service->getCollections($query);
return array(
'id' => $content->content->id,
'parent' => $isRoot ? '#' : '0',
'text' => $content->contentType->getName($languages[0]) . ' (' . strval($count->count) . ')',
'children' => false,
'a_attr' => array(
'href' => $this->router->generate('netgen_information_collection.route.admin.collection_list', ['contentId' => $content->content->id]),
'rel' => $content->content->id,
),
'state' => array(
'opened' => $isRoot,
),
'data' => array(
'context_menu' => array(
array(
'name' => 'export',
'url' => $this->router->generate('netgen_information_collection.route.admin.export', ['contentId' => $content->content->id]),
'text' => $this->translator->trans('netgen_information_collection_admin_export_export', [], 'netgen_information_collection_admin'),
),
),
),
);
} | php | protected function getCollections(Content $content, $isRoot = false)
{
$languages = $this->getConfigResolver()->getParameter('languages');
$query = new Query([
'contentId' => $content->content->id,
'limit' => Query::COUNT_QUERY,
]);
$count = $this->service->getCollections($query);
return array(
'id' => $content->content->id,
'parent' => $isRoot ? '#' : '0',
'text' => $content->contentType->getName($languages[0]) . ' (' . strval($count->count) . ')',
'children' => false,
'a_attr' => array(
'href' => $this->router->generate('netgen_information_collection.route.admin.collection_list', ['contentId' => $content->content->id]),
'rel' => $content->content->id,
),
'state' => array(
'opened' => $isRoot,
),
'data' => array(
'context_menu' => array(
array(
'name' => 'export',
'url' => $this->router->generate('netgen_information_collection.route.admin.export', ['contentId' => $content->content->id]),
'text' => $this->translator->trans('netgen_information_collection_admin_export_export', [], 'netgen_information_collection_admin'),
),
),
),
);
} | [
"protected",
"function",
"getCollections",
"(",
"Content",
"$",
"content",
",",
"$",
"isRoot",
"=",
"false",
")",
"{",
"$",
"languages",
"=",
"$",
"this",
"->",
"getConfigResolver",
"(",
")",
"->",
"getParameter",
"(",
"'languages'",
")",
";",
"$",
"query"... | Creates tree structure for Content
@param \Netgen\Bundle\InformationCollectionBundle\API\Value\InformationCollection\Content $content
@param bool $isRoot
@return array | [
"Creates",
"tree",
"structure",
"for",
"Content"
] | 3ed7a2b33b1e80d3a0d9ee607eab495396044b29 | https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Controller/Admin/TreeController.php#L111-L144 | train |
i-MSCP/roundcube | roundcubemail/plugins/enigma/enigma.php | enigma.init | function init()
{
$this->rc = rcube::get_instance();
if ($this->rc->task == 'mail') {
// message parse/display hooks
$this->add_hook('message_part_structure', array($this, 'part_structure'));
$this->add_hook('message_part_body', array($this, 'part_body'));
$this->add_hook('message_body_prefix', array($this, 'status_message'));
$this->register_action('plugin.enigmaimport', array($this, 'import_file'));
$this->register_action('plugin.enigmakeys', array($this, 'preferences_ui'));
// load the Enigma plugin configuration
$this->load_config();
$enabled = $this->rc->config->get('enigma_encryption', true);
// message displaying
if ($this->rc->action == 'show' || $this->rc->action == 'preview' || $this->rc->action == 'print') {
$this->add_hook('message_load', array($this, 'message_load'));
$this->add_hook('template_object_messagebody', array($this, 'message_output'));
}
// message composing
else if ($enabled && $this->rc->action == 'compose') {
$this->add_hook('message_compose_body', array($this, 'message_compose'));
$this->load_ui();
$this->ui->init();
}
// message sending (and draft storing)
else if ($enabled && $this->rc->action == 'send') {
$this->add_hook('message_ready', array($this, 'message_ready'));
}
$this->password_handler();
}
else if ($this->rc->task == 'settings') {
// add hooks for Enigma settings
$this->add_hook('settings_actions', array($this, 'settings_actions'));
$this->add_hook('preferences_sections_list', array($this, 'preferences_sections_list'));
$this->add_hook('preferences_list', array($this, 'preferences_list'));
$this->add_hook('preferences_save', array($this, 'preferences_save'));
// register handler for keys/certs management
$this->register_action('plugin.enigmakeys', array($this, 'preferences_ui'));
// $this->register_action('plugin.enigmacerts', array($this, 'preferences_ui'));
$this->load_ui();
if (empty($_REQUEST['_framed']) || strpos($this->rc->action, 'plugin.enigma') === 0) {
$this->ui->add_css();
}
$this->password_handler();
}
else if ($this->rc->task == 'cli') {
$this->add_hook('user_delete_commit', array($this, 'user_delete'));
}
$this->add_hook('refresh', array($this, 'refresh'));
} | php | function init()
{
$this->rc = rcube::get_instance();
if ($this->rc->task == 'mail') {
// message parse/display hooks
$this->add_hook('message_part_structure', array($this, 'part_structure'));
$this->add_hook('message_part_body', array($this, 'part_body'));
$this->add_hook('message_body_prefix', array($this, 'status_message'));
$this->register_action('plugin.enigmaimport', array($this, 'import_file'));
$this->register_action('plugin.enigmakeys', array($this, 'preferences_ui'));
// load the Enigma plugin configuration
$this->load_config();
$enabled = $this->rc->config->get('enigma_encryption', true);
// message displaying
if ($this->rc->action == 'show' || $this->rc->action == 'preview' || $this->rc->action == 'print') {
$this->add_hook('message_load', array($this, 'message_load'));
$this->add_hook('template_object_messagebody', array($this, 'message_output'));
}
// message composing
else if ($enabled && $this->rc->action == 'compose') {
$this->add_hook('message_compose_body', array($this, 'message_compose'));
$this->load_ui();
$this->ui->init();
}
// message sending (and draft storing)
else if ($enabled && $this->rc->action == 'send') {
$this->add_hook('message_ready', array($this, 'message_ready'));
}
$this->password_handler();
}
else if ($this->rc->task == 'settings') {
// add hooks for Enigma settings
$this->add_hook('settings_actions', array($this, 'settings_actions'));
$this->add_hook('preferences_sections_list', array($this, 'preferences_sections_list'));
$this->add_hook('preferences_list', array($this, 'preferences_list'));
$this->add_hook('preferences_save', array($this, 'preferences_save'));
// register handler for keys/certs management
$this->register_action('plugin.enigmakeys', array($this, 'preferences_ui'));
// $this->register_action('plugin.enigmacerts', array($this, 'preferences_ui'));
$this->load_ui();
if (empty($_REQUEST['_framed']) || strpos($this->rc->action, 'plugin.enigma') === 0) {
$this->ui->add_css();
}
$this->password_handler();
}
else if ($this->rc->task == 'cli') {
$this->add_hook('user_delete_commit', array($this, 'user_delete'));
}
$this->add_hook('refresh', array($this, 'refresh'));
} | [
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"rc",
"=",
"rcube",
"::",
"get_instance",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"rc",
"->",
"task",
"==",
"'mail'",
")",
"{",
"// message parse/display hooks",
"$",
"this",
"->",
"add_hook",
... | Plugin initialization. | [
"Plugin",
"initialization",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/enigma/enigma.php#L35-L96 | train |
i-MSCP/roundcube | roundcubemail/plugins/enigma/enigma.php | enigma.load_env | function load_env()
{
if ($this->env_loaded) {
return;
}
$this->env_loaded = true;
// Add include path for Enigma classes and drivers
$include_path = $this->home . '/lib' . PATH_SEPARATOR;
$include_path .= ini_get('include_path');
set_include_path($include_path);
// load the Enigma plugin configuration
$this->load_config();
// include localization (if wasn't included before)
$this->add_texts('localization/');
} | php | function load_env()
{
if ($this->env_loaded) {
return;
}
$this->env_loaded = true;
// Add include path for Enigma classes and drivers
$include_path = $this->home . '/lib' . PATH_SEPARATOR;
$include_path .= ini_get('include_path');
set_include_path($include_path);
// load the Enigma plugin configuration
$this->load_config();
// include localization (if wasn't included before)
$this->add_texts('localization/');
} | [
"function",
"load_env",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"env_loaded",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"env_loaded",
"=",
"true",
";",
"// Add include path for Enigma classes and drivers",
"$",
"include_path",
"=",
"$",
"this",
"... | Plugin environment initialization. | [
"Plugin",
"environment",
"initialization",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/enigma/enigma.php#L101-L119 | train |
i-MSCP/roundcube | roundcubemail/plugins/enigma/enigma.php | enigma.load_ui | function load_ui($all = false)
{
if (!$this->ui) {
// load config/localization
$this->load_env();
// Load UI
$this->ui = new enigma_ui($this, $this->home);
}
if ($all) {
$this->ui->add_css();
$this->ui->add_js();
}
} | php | function load_ui($all = false)
{
if (!$this->ui) {
// load config/localization
$this->load_env();
// Load UI
$this->ui = new enigma_ui($this, $this->home);
}
if ($all) {
$this->ui->add_css();
$this->ui->add_js();
}
} | [
"function",
"load_ui",
"(",
"$",
"all",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"ui",
")",
"{",
"// load config/localization",
"$",
"this",
"->",
"load_env",
"(",
")",
";",
"// Load UI",
"$",
"this",
"->",
"ui",
"=",
"new",
"enigma... | Plugin UI initialization. | [
"Plugin",
"UI",
"initialization",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/enigma/enigma.php#L124-L138 | train |
i-MSCP/roundcube | roundcubemail/plugins/enigma/enigma.php | enigma.load_engine | function load_engine()
{
if ($this->engine) {
return $this->engine;
}
// load config/localization
$this->load_env();
return $this->engine = new enigma_engine($this);
} | php | function load_engine()
{
if ($this->engine) {
return $this->engine;
}
// load config/localization
$this->load_env();
return $this->engine = new enigma_engine($this);
} | [
"function",
"load_engine",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"engine",
")",
"{",
"return",
"$",
"this",
"->",
"engine",
";",
"}",
"// load config/localization",
"$",
"this",
"->",
"load_env",
"(",
")",
";",
"return",
"$",
"this",
"->",
"engi... | Plugin engine initialization. | [
"Plugin",
"engine",
"initialization",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/enigma/enigma.php#L143-L153 | train |
i-MSCP/roundcube | roundcubemail/plugins/enigma/enigma.php | enigma.preferences_save | function preferences_save($p)
{
if ($p['section'] == 'enigma') {
$p['prefs'] = array(
'enigma_signatures' => (bool) rcube_utils::get_input_value('_enigma_signatures', rcube_utils::INPUT_POST),
'enigma_decryption' => (bool) rcube_utils::get_input_value('_enigma_decryption', rcube_utils::INPUT_POST),
'enigma_encryption' => (bool) rcube_utils::get_input_value('_enigma_encryption', rcube_utils::INPUT_POST),
'enigma_sign_all' => (bool) rcube_utils::get_input_value('_enigma_sign_all', rcube_utils::INPUT_POST),
'enigma_encrypt_all' => (bool) rcube_utils::get_input_value('_enigma_encrypt_all', rcube_utils::INPUT_POST),
'enigma_attach_pubkey' => (bool) rcube_utils::get_input_value('_enigma_attach_pubkey', rcube_utils::INPUT_POST),
'enigma_password_time' => intval(rcube_utils::get_input_value('_enigma_password_time', rcube_utils::INPUT_POST)),
);
}
return $p;
} | php | function preferences_save($p)
{
if ($p['section'] == 'enigma') {
$p['prefs'] = array(
'enigma_signatures' => (bool) rcube_utils::get_input_value('_enigma_signatures', rcube_utils::INPUT_POST),
'enigma_decryption' => (bool) rcube_utils::get_input_value('_enigma_decryption', rcube_utils::INPUT_POST),
'enigma_encryption' => (bool) rcube_utils::get_input_value('_enigma_encryption', rcube_utils::INPUT_POST),
'enigma_sign_all' => (bool) rcube_utils::get_input_value('_enigma_sign_all', rcube_utils::INPUT_POST),
'enigma_encrypt_all' => (bool) rcube_utils::get_input_value('_enigma_encrypt_all', rcube_utils::INPUT_POST),
'enigma_attach_pubkey' => (bool) rcube_utils::get_input_value('_enigma_attach_pubkey', rcube_utils::INPUT_POST),
'enigma_password_time' => intval(rcube_utils::get_input_value('_enigma_password_time', rcube_utils::INPUT_POST)),
);
}
return $p;
} | [
"function",
"preferences_save",
"(",
"$",
"p",
")",
"{",
"if",
"(",
"$",
"p",
"[",
"'section'",
"]",
"==",
"'enigma'",
")",
"{",
"$",
"p",
"[",
"'prefs'",
"]",
"=",
"array",
"(",
"'enigma_signatures'",
"=>",
"(",
"bool",
")",
"rcube_utils",
"::",
"ge... | Handler for preferences_save hook.
Executed on Enigma settings form submit.
@param array Original parameters
@return array Modified parameters | [
"Handler",
"for",
"preferences_save",
"hook",
".",
"Executed",
"on",
"Enigma",
"settings",
"form",
"submit",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/enigma/enigma.php#L399-L414 | train |
i-MSCP/roundcube | roundcubemail/plugins/enigma/enigma.php | enigma.user_delete | function user_delete($p)
{
$this->load_engine();
$p['abort'] = $p['abort'] || !$this->engine->delete_user_data($p['username']);
return $p;
} | php | function user_delete($p)
{
$this->load_engine();
$p['abort'] = $p['abort'] || !$this->engine->delete_user_data($p['username']);
return $p;
} | [
"function",
"user_delete",
"(",
"$",
"p",
")",
"{",
"$",
"this",
"->",
"load_engine",
"(",
")",
";",
"$",
"p",
"[",
"'abort'",
"]",
"=",
"$",
"p",
"[",
"'abort'",
"]",
"||",
"!",
"$",
"this",
"->",
"engine",
"->",
"delete_user_data",
"(",
"$",
"p... | Handle delete_user_commit hook | [
"Handle",
"delete_user_commit",
"hook"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/enigma/enigma.php#L521-L528 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_spellcheck_pspell.php | rcube_spellcheck_pspell.init | private function init()
{
if (!$this->plink) {
if (!extension_loaded('pspell')) {
$this->error = "Pspell extension not available";
return;
}
$this->plink = pspell_new($this->lang, null, null, RCUBE_CHARSET, PSPELL_FAST);
}
if (!$this->plink) {
$this->error = "Unable to load Pspell engine for selected language";
}
} | php | private function init()
{
if (!$this->plink) {
if (!extension_loaded('pspell')) {
$this->error = "Pspell extension not available";
return;
}
$this->plink = pspell_new($this->lang, null, null, RCUBE_CHARSET, PSPELL_FAST);
}
if (!$this->plink) {
$this->error = "Unable to load Pspell engine for selected language";
}
} | [
"private",
"function",
"init",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"plink",
")",
"{",
"if",
"(",
"!",
"extension_loaded",
"(",
"'pspell'",
")",
")",
"{",
"$",
"this",
"->",
"error",
"=",
"\"Pspell extension not available\"",
";",
"return",
... | Initializes PSpell dictionary | [
"Initializes",
"PSpell",
"dictionary"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_spellcheck_pspell.php#L64-L78 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_config.php | rcube_config.load | private function load()
{
// Load default settings
if (!$this->load_from_file('defaults.inc.php')) {
$this->errors[] = 'defaults.inc.php was not found.';
}
// load main config file
if (!$this->load_from_file('config.inc.php')) {
// Old configuration files
if (!$this->load_from_file('main.inc.php') || !$this->load_from_file('db.inc.php')) {
$this->errors[] = 'config.inc.php was not found.';
}
else if (rand(1,100) == 10) { // log warning on every 100th request (average)
trigger_error("config.inc.php was not found. Please migrate your config by running bin/update.sh", E_USER_WARNING);
}
}
// load host-specific configuration
$this->load_host_config();
// set skin (with fallback to old 'skin_path' property)
if (empty($this->prop['skin'])) {
if (!empty($this->prop['skin_path'])) {
$this->prop['skin'] = str_replace('skins/', '', unslashify($this->prop['skin_path']));
}
else {
$this->prop['skin'] = self::DEFAULT_SKIN;
}
}
// larry is the new default skin :-)
if ($this->prop['skin'] == 'default') {
$this->prop['skin'] = self::DEFAULT_SKIN;
}
// fix paths
foreach (array('log_dir' => 'logs', 'temp_dir' => 'temp') as $key => $dir) {
foreach (array($this->prop[$key], '../' . $this->prop[$key], RCUBE_INSTALL_PATH . $dir) as $path) {
if ($path && ($realpath = realpath(unslashify($path)))) {
$this->prop[$key] = $realpath;
break;
}
}
}
// fix default imap folders encoding
foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder) {
$this->prop[$folder] = rcube_charset::convert($this->prop[$folder], RCUBE_CHARSET, 'UTF7-IMAP');
}
// set PHP error logging according to config
if ($this->prop['debug_level'] & 1) {
ini_set('log_errors', 1);
if ($this->prop['log_driver'] == 'syslog') {
ini_set('error_log', 'syslog');
}
else {
ini_set('error_log', $this->prop['log_dir'].'/errors');
}
}
// enable display_errors in 'show' level, but not for ajax requests
ini_set('display_errors', intval(empty($_REQUEST['_remote']) && ($this->prop['debug_level'] & 4)));
// remove deprecated properties
unset($this->prop['dst_active']);
// export config data
$GLOBALS['CONFIG'] = &$this->prop;
} | php | private function load()
{
// Load default settings
if (!$this->load_from_file('defaults.inc.php')) {
$this->errors[] = 'defaults.inc.php was not found.';
}
// load main config file
if (!$this->load_from_file('config.inc.php')) {
// Old configuration files
if (!$this->load_from_file('main.inc.php') || !$this->load_from_file('db.inc.php')) {
$this->errors[] = 'config.inc.php was not found.';
}
else if (rand(1,100) == 10) { // log warning on every 100th request (average)
trigger_error("config.inc.php was not found. Please migrate your config by running bin/update.sh", E_USER_WARNING);
}
}
// load host-specific configuration
$this->load_host_config();
// set skin (with fallback to old 'skin_path' property)
if (empty($this->prop['skin'])) {
if (!empty($this->prop['skin_path'])) {
$this->prop['skin'] = str_replace('skins/', '', unslashify($this->prop['skin_path']));
}
else {
$this->prop['skin'] = self::DEFAULT_SKIN;
}
}
// larry is the new default skin :-)
if ($this->prop['skin'] == 'default') {
$this->prop['skin'] = self::DEFAULT_SKIN;
}
// fix paths
foreach (array('log_dir' => 'logs', 'temp_dir' => 'temp') as $key => $dir) {
foreach (array($this->prop[$key], '../' . $this->prop[$key], RCUBE_INSTALL_PATH . $dir) as $path) {
if ($path && ($realpath = realpath(unslashify($path)))) {
$this->prop[$key] = $realpath;
break;
}
}
}
// fix default imap folders encoding
foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder) {
$this->prop[$folder] = rcube_charset::convert($this->prop[$folder], RCUBE_CHARSET, 'UTF7-IMAP');
}
// set PHP error logging according to config
if ($this->prop['debug_level'] & 1) {
ini_set('log_errors', 1);
if ($this->prop['log_driver'] == 'syslog') {
ini_set('error_log', 'syslog');
}
else {
ini_set('error_log', $this->prop['log_dir'].'/errors');
}
}
// enable display_errors in 'show' level, but not for ajax requests
ini_set('display_errors', intval(empty($_REQUEST['_remote']) && ($this->prop['debug_level'] & 4)));
// remove deprecated properties
unset($this->prop['dst_active']);
// export config data
$GLOBALS['CONFIG'] = &$this->prop;
} | [
"private",
"function",
"load",
"(",
")",
"{",
"// Load default settings",
"if",
"(",
"!",
"$",
"this",
"->",
"load_from_file",
"(",
"'defaults.inc.php'",
")",
")",
"{",
"$",
"this",
"->",
"errors",
"[",
"]",
"=",
"'defaults.inc.php was not found.'",
";",
"}",
... | Load config from local config file
@todo Remove global $CONFIG | [
"Load",
"config",
"from",
"local",
"config",
"file"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_config.php#L197-L268 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_config.php | rcube_config.load_host_config | private function load_host_config()
{
if (empty($this->prop['include_host_config'])) {
return;
}
foreach (array('HTTP_HOST', 'SERVER_NAME', 'SERVER_ADDR') as $key) {
$fname = null;
$name = $_SERVER[$key];
if (!$name) {
continue;
}
if (is_array($this->prop['include_host_config'])) {
$fname = $this->prop['include_host_config'][$name];
}
else {
$fname = preg_replace('/[^a-z0-9\.\-_]/i', '', $name) . '.inc.php';
}
if ($fname && $this->load_from_file($fname)) {
return;
}
}
} | php | private function load_host_config()
{
if (empty($this->prop['include_host_config'])) {
return;
}
foreach (array('HTTP_HOST', 'SERVER_NAME', 'SERVER_ADDR') as $key) {
$fname = null;
$name = $_SERVER[$key];
if (!$name) {
continue;
}
if (is_array($this->prop['include_host_config'])) {
$fname = $this->prop['include_host_config'][$name];
}
else {
$fname = preg_replace('/[^a-z0-9\.\-_]/i', '', $name) . '.inc.php';
}
if ($fname && $this->load_from_file($fname)) {
return;
}
}
} | [
"private",
"function",
"load_host_config",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"prop",
"[",
"'include_host_config'",
"]",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"array",
"(",
"'HTTP_HOST'",
",",
"'SERVER_NAME'",
",",
"'... | Load a host-specific config file if configured
This will merge the host specific configuration with the given one | [
"Load",
"a",
"host",
"-",
"specific",
"config",
"file",
"if",
"configured",
"This",
"will",
"merge",
"the",
"host",
"specific",
"configuration",
"with",
"the",
"given",
"one"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_config.php#L274-L299 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_config.php | rcube_config.load_from_file | public function load_from_file($file)
{
$success = false;
foreach ($this->resolve_paths($file) as $fpath) {
if ($fpath && is_file($fpath) && is_readable($fpath)) {
// use output buffering, we don't need any output here
ob_start();
include($fpath);
ob_end_clean();
if (is_array($config)) {
$this->merge($config);
$success = true;
}
// deprecated name of config variable
if (is_array($rcmail_config)) {
$this->merge($rcmail_config);
$success = true;
}
}
}
return $success;
} | php | public function load_from_file($file)
{
$success = false;
foreach ($this->resolve_paths($file) as $fpath) {
if ($fpath && is_file($fpath) && is_readable($fpath)) {
// use output buffering, we don't need any output here
ob_start();
include($fpath);
ob_end_clean();
if (is_array($config)) {
$this->merge($config);
$success = true;
}
// deprecated name of config variable
if (is_array($rcmail_config)) {
$this->merge($rcmail_config);
$success = true;
}
}
}
return $success;
} | [
"public",
"function",
"load_from_file",
"(",
"$",
"file",
")",
"{",
"$",
"success",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"resolve_paths",
"(",
"$",
"file",
")",
"as",
"$",
"fpath",
")",
"{",
"if",
"(",
"$",
"fpath",
"&&",
"is_file",
... | Read configuration from a file
and merge with the already stored config values
@param string $file Name of the config file to be loaded
@return booelan True on success, false on failure | [
"Read",
"configuration",
"from",
"a",
"file",
"and",
"merge",
"with",
"the",
"already",
"stored",
"config",
"values"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_config.php#L309-L333 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_config.php | rcube_config.resolve_paths | public function resolve_paths($file, $use_env = true)
{
$files = array();
$abs_path = rcube_utils::is_absolute_path($file);
foreach ($this->paths as $basepath) {
$realpath = $abs_path ? $file : realpath($basepath . '/' . $file);
// check if <file>-env.ini exists
if ($realpath && $use_env && !empty($this->env)) {
$envfile = preg_replace('/\.(inc.php)$/', '-' . $this->env . '.\\1', $realpath);
if (is_file($envfile)) {
$realpath = $envfile;
}
}
if ($realpath) {
$files[] = $realpath;
// no need to continue the loop if an absolute file path is given
if ($abs_path) {
break;
}
}
}
return $files;
} | php | public function resolve_paths($file, $use_env = true)
{
$files = array();
$abs_path = rcube_utils::is_absolute_path($file);
foreach ($this->paths as $basepath) {
$realpath = $abs_path ? $file : realpath($basepath . '/' . $file);
// check if <file>-env.ini exists
if ($realpath && $use_env && !empty($this->env)) {
$envfile = preg_replace('/\.(inc.php)$/', '-' . $this->env . '.\\1', $realpath);
if (is_file($envfile)) {
$realpath = $envfile;
}
}
if ($realpath) {
$files[] = $realpath;
// no need to continue the loop if an absolute file path is given
if ($abs_path) {
break;
}
}
}
return $files;
} | [
"public",
"function",
"resolve_paths",
"(",
"$",
"file",
",",
"$",
"use_env",
"=",
"true",
")",
"{",
"$",
"files",
"=",
"array",
"(",
")",
";",
"$",
"abs_path",
"=",
"rcube_utils",
"::",
"is_absolute_path",
"(",
"$",
"file",
")",
";",
"foreach",
"(",
... | Helper method to resolve absolute paths to the given config file.
This also takes the 'env' property into account.
@param string $file Filename or absolute file path
@param boolean $use_env Return -$env file path if exists
@return array List of candidates in config dir path(s) | [
"Helper",
"method",
"to",
"resolve",
"absolute",
"paths",
"to",
"the",
"given",
"config",
"file",
".",
"This",
"also",
"takes",
"the",
"env",
"property",
"into",
"account",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_config.php#L344-L371 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_config.php | rcube_config.get | public function get($name, $def = null)
{
if (isset($this->prop[$name])) {
$result = $this->prop[$name];
}
else {
$result = $def;
}
$result = $this->getenv_default('ROUNDCUBE_' . strtoupper($name), $result);
$rcube = rcube::get_instance();
if ($name == 'timezone') {
if (empty($result) || $result == 'auto') {
$result = $this->client_timezone();
}
}
else if ($name == 'client_mimetypes') {
if (!$result && !$def) {
$result = 'text/plain,text/html,text/xml'
. ',image/jpeg,image/gif,image/png,image/bmp,image/tiff,image/webp'
. ',application/x-javascript,application/pdf,application/x-shockwave-flash';
}
if ($result && is_string($result)) {
$result = explode(',', $result);
}
}
$plugin = $rcube->plugins->exec_hook('config_get', array(
'name' => $name, 'default' => $def, 'result' => $result));
return $plugin['result'];
} | php | public function get($name, $def = null)
{
if (isset($this->prop[$name])) {
$result = $this->prop[$name];
}
else {
$result = $def;
}
$result = $this->getenv_default('ROUNDCUBE_' . strtoupper($name), $result);
$rcube = rcube::get_instance();
if ($name == 'timezone') {
if (empty($result) || $result == 'auto') {
$result = $this->client_timezone();
}
}
else if ($name == 'client_mimetypes') {
if (!$result && !$def) {
$result = 'text/plain,text/html,text/xml'
. ',image/jpeg,image/gif,image/png,image/bmp,image/tiff,image/webp'
. ',application/x-javascript,application/pdf,application/x-shockwave-flash';
}
if ($result && is_string($result)) {
$result = explode(',', $result);
}
}
$plugin = $rcube->plugins->exec_hook('config_get', array(
'name' => $name, 'default' => $def, 'result' => $result));
return $plugin['result'];
} | [
"public",
"function",
"get",
"(",
"$",
"name",
",",
"$",
"def",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"prop",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"prop",
"[",
"$",
"name",
... | Getter for a specific config parameter
@param string $name Parameter name
@param mixed $def Default value if not set
@return mixed The requested config value | [
"Getter",
"for",
"a",
"specific",
"config",
"parameter"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_config.php#L381-L413 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_config.php | rcube_config.set_user_prefs | public function set_user_prefs($prefs)
{
$prefs = $this->fix_legacy_props($prefs);
// Honor the dont_override setting for any existing user preferences
$dont_override = $this->get('dont_override');
if (is_array($dont_override) && !empty($dont_override)) {
foreach ($dont_override as $key) {
unset($prefs[$key]);
}
}
// larry is the new default skin :-)
if ($prefs['skin'] == 'default') {
$prefs['skin'] = self::DEFAULT_SKIN;
}
$this->userprefs = $prefs;
$this->prop = array_merge($this->prop, $prefs);
} | php | public function set_user_prefs($prefs)
{
$prefs = $this->fix_legacy_props($prefs);
// Honor the dont_override setting for any existing user preferences
$dont_override = $this->get('dont_override');
if (is_array($dont_override) && !empty($dont_override)) {
foreach ($dont_override as $key) {
unset($prefs[$key]);
}
}
// larry is the new default skin :-)
if ($prefs['skin'] == 'default') {
$prefs['skin'] = self::DEFAULT_SKIN;
}
$this->userprefs = $prefs;
$this->prop = array_merge($this->prop, $prefs);
} | [
"public",
"function",
"set_user_prefs",
"(",
"$",
"prefs",
")",
"{",
"$",
"prefs",
"=",
"$",
"this",
"->",
"fix_legacy_props",
"(",
"$",
"prefs",
")",
";",
"// Honor the dont_override setting for any existing user preferences",
"$",
"dont_override",
"=",
"$",
"this"... | Merge the given prefs over the current config
and make sure that they survive further merging.
@param array $prefs Hash array with user prefs | [
"Merge",
"the",
"given",
"prefs",
"over",
"the",
"current",
"config",
"and",
"make",
"sure",
"that",
"they",
"survive",
"further",
"merging",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_config.php#L443-L462 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_config.php | rcube_config.all | public function all()
{
$props = $this->prop;
foreach ($props as $prop_name => $prop_value) {
$props[$prop_name] = $this->getenv_default('ROUNDCUBE_' . strtoupper($prop_name), $prop_value);
}
$rcube = rcube::get_instance();
$plugin = $rcube->plugins->exec_hook('config_get', array(
'name' => '*', 'result' => $props));
return $plugin['result'];
} | php | public function all()
{
$props = $this->prop;
foreach ($props as $prop_name => $prop_value) {
$props[$prop_name] = $this->getenv_default('ROUNDCUBE_' . strtoupper($prop_name), $prop_value);
}
$rcube = rcube::get_instance();
$plugin = $rcube->plugins->exec_hook('config_get', array(
'name' => '*', 'result' => $props));
return $plugin['result'];
} | [
"public",
"function",
"all",
"(",
")",
"{",
"$",
"props",
"=",
"$",
"this",
"->",
"prop",
";",
"foreach",
"(",
"$",
"props",
"as",
"$",
"prop_name",
"=>",
"$",
"prop_value",
")",
"{",
"$",
"props",
"[",
"$",
"prop_name",
"]",
"=",
"$",
"this",
"-... | Getter for all config options
@return array Hash array containing all config properties | [
"Getter",
"for",
"all",
"config",
"options"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_config.php#L469-L482 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_config.php | rcube_config.get_timezone | public function get_timezone()
{
if ($tz = $this->get('timezone')) {
try {
$tz = new DateTimeZone($tz);
return $tz->getOffset(new DateTime('now')) / 3600;
}
catch (Exception $e) {
}
}
return 0;
} | php | public function get_timezone()
{
if ($tz = $this->get('timezone')) {
try {
$tz = new DateTimeZone($tz);
return $tz->getOffset(new DateTime('now')) / 3600;
}
catch (Exception $e) {
}
}
return 0;
} | [
"public",
"function",
"get_timezone",
"(",
")",
"{",
"if",
"(",
"$",
"tz",
"=",
"$",
"this",
"->",
"get",
"(",
"'timezone'",
")",
")",
"{",
"try",
"{",
"$",
"tz",
"=",
"new",
"DateTimeZone",
"(",
"$",
"tz",
")",
";",
"return",
"$",
"tz",
"->",
... | Special getter for user's timezone offset including DST
@return float Timezone offset (in hours)
@deprecated | [
"Special",
"getter",
"for",
"user",
"s",
"timezone",
"offset",
"including",
"DST"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_config.php#L490-L502 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_config.php | rcube_config.get_crypto_key | public function get_crypto_key($key)
{
// Bomb out if the requested key does not exist
if (!array_key_exists($key, $this->prop) || empty($this->prop[$key])) {
rcube::raise_error(array(
'code' => 500, 'type' => 'php',
'file' => __FILE__, 'line' => __LINE__,
'message' => "Request for unconfigured crypto key \"$key\""
), true, true);
}
return $this->prop[$key];
} | php | public function get_crypto_key($key)
{
// Bomb out if the requested key does not exist
if (!array_key_exists($key, $this->prop) || empty($this->prop[$key])) {
rcube::raise_error(array(
'code' => 500, 'type' => 'php',
'file' => __FILE__, 'line' => __LINE__,
'message' => "Request for unconfigured crypto key \"$key\""
), true, true);
}
return $this->prop[$key];
} | [
"public",
"function",
"get_crypto_key",
"(",
"$",
"key",
")",
"{",
"// Bomb out if the requested key does not exist",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"prop",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"prop",
"["... | Return requested DES crypto key.
@param string $key Crypto key name
@return string Crypto key | [
"Return",
"requested",
"DES",
"crypto",
"key",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_config.php#L511-L523 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_config.php | rcube_config.header_delimiter | public function header_delimiter()
{
// use the configured delimiter for headers
if (!empty($this->prop['mail_header_delimiter'])) {
$delim = $this->prop['mail_header_delimiter'];
if ($delim == "\n" || $delim == "\r\n") {
return $delim;
}
else {
rcube::raise_error(array(
'code' => 500, 'type' => 'php',
'file' => __FILE__, 'line' => __LINE__,
'message' => "Invalid mail_header_delimiter setting"
), true, false);
}
}
$php_os = strtolower(substr(PHP_OS, 0, 3));
if ($php_os == 'win')
return "\r\n";
if ($php_os == 'mac')
return "\r\n";
return "\n";
} | php | public function header_delimiter()
{
// use the configured delimiter for headers
if (!empty($this->prop['mail_header_delimiter'])) {
$delim = $this->prop['mail_header_delimiter'];
if ($delim == "\n" || $delim == "\r\n") {
return $delim;
}
else {
rcube::raise_error(array(
'code' => 500, 'type' => 'php',
'file' => __FILE__, 'line' => __LINE__,
'message' => "Invalid mail_header_delimiter setting"
), true, false);
}
}
$php_os = strtolower(substr(PHP_OS, 0, 3));
if ($php_os == 'win')
return "\r\n";
if ($php_os == 'mac')
return "\r\n";
return "\n";
} | [
"public",
"function",
"header_delimiter",
"(",
")",
"{",
"// use the configured delimiter for headers",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"prop",
"[",
"'mail_header_delimiter'",
"]",
")",
")",
"{",
"$",
"delim",
"=",
"$",
"this",
"->",
"prop",
... | Try to autodetect operating system and find the correct line endings
@return string The appropriate mail header delimiter
@deprecated Since 1.3 we don't use mail() | [
"Try",
"to",
"autodetect",
"operating",
"system",
"and",
"find",
"the",
"correct",
"line",
"endings"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_config.php#L541-L567 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_config.php | rcube_config.mail_domain | public function mail_domain($host, $encode=true)
{
$domain = $host;
if (is_array($this->prop['mail_domain'])) {
if (isset($this->prop['mail_domain'][$host])) {
$domain = $this->prop['mail_domain'][$host];
}
}
else if (!empty($this->prop['mail_domain'])) {
$domain = rcube_utils::parse_host($this->prop['mail_domain']);
}
if ($encode) {
$domain = rcube_utils::idn_to_ascii($domain);
}
return $domain;
} | php | public function mail_domain($host, $encode=true)
{
$domain = $host;
if (is_array($this->prop['mail_domain'])) {
if (isset($this->prop['mail_domain'][$host])) {
$domain = $this->prop['mail_domain'][$host];
}
}
else if (!empty($this->prop['mail_domain'])) {
$domain = rcube_utils::parse_host($this->prop['mail_domain']);
}
if ($encode) {
$domain = rcube_utils::idn_to_ascii($domain);
}
return $domain;
} | [
"public",
"function",
"mail_domain",
"(",
"$",
"host",
",",
"$",
"encode",
"=",
"true",
")",
"{",
"$",
"domain",
"=",
"$",
"host",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"prop",
"[",
"'mail_domain'",
"]",
")",
")",
"{",
"if",
"(",
"i... | Return the mail domain configured for the given host
@param string $host IMAP host
@param boolean $encode If true, domain name will be converted to IDN ASCII
@return string Resolved SMTP host | [
"Return",
"the",
"mail",
"domain",
"configured",
"for",
"the",
"given",
"host"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_config.php#L577-L595 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_config.php | rcube_config.fix_legacy_props | private function fix_legacy_props($props)
{
foreach ($this->legacy_props as $new => $old) {
if (isset($props[$old])) {
if (!isset($props[$new])) {
$props[$new] = $props[$old];
}
unset($props[$old]);
}
}
// convert deprecated numeric timezone value
if (isset($props['timezone']) && is_numeric($props['timezone'])) {
if ($tz = self::timezone_name_from_abbr($props['timezone'])) {
$props['timezone'] = $tz;
}
else {
unset($props['timezone']);
}
}
// translate old `preview_pane` settings to `layout`
if (isset($props['preview_pane']) && !isset($props['layout'])) {
$props['layout'] = $props['preview_pane'] ? 'desktop' : 'list';
unset($props['preview_pane']);
}
return $props;
} | php | private function fix_legacy_props($props)
{
foreach ($this->legacy_props as $new => $old) {
if (isset($props[$old])) {
if (!isset($props[$new])) {
$props[$new] = $props[$old];
}
unset($props[$old]);
}
}
// convert deprecated numeric timezone value
if (isset($props['timezone']) && is_numeric($props['timezone'])) {
if ($tz = self::timezone_name_from_abbr($props['timezone'])) {
$props['timezone'] = $tz;
}
else {
unset($props['timezone']);
}
}
// translate old `preview_pane` settings to `layout`
if (isset($props['preview_pane']) && !isset($props['layout'])) {
$props['layout'] = $props['preview_pane'] ? 'desktop' : 'list';
unset($props['preview_pane']);
}
return $props;
} | [
"private",
"function",
"fix_legacy_props",
"(",
"$",
"props",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"legacy_props",
"as",
"$",
"new",
"=>",
"$",
"old",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"props",
"[",
"$",
"old",
"]",
")",
")",
"{",
"... | Convert legacy options into new ones
@param array $props Hash array with config props
@return array Converted config props | [
"Convert",
"legacy",
"options",
"into",
"new",
"ones"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_config.php#L634-L662 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_csv2vcard.php | rcube_csv2vcard.import | public function import($csv)
{
// convert to UTF-8
$head = substr($csv, 0, 4096);
$charset = rcube_charset::detect($head, RCUBE_CHARSET);
$csv = rcube_charset::convert($csv, $charset);
$csv = preg_replace(array('/^[\xFE\xFF]{2}/', '/^\xEF\xBB\xBF/', '/^\x00+/'), '', $csv); // also remove BOM
$head = '';
$prev_line = false;
$this->map = array();
$this->gmail_map = array();
// Parse file
foreach (preg_split("/[\r\n]+/", $csv) as $line) {
if (!empty($prev_line)) {
$line = '"' . $line;
}
$elements = $this->parse_line($line);
if (empty($elements)) {
continue;
}
// Parse header
if (empty($this->map)) {
$this->parse_header($elements);
if (empty($this->map)) {
break;
}
}
// Parse data row
else {
// handle multiline elements (e.g. Gmail)
if (!empty($prev_line)) {
$first = array_shift($elements);
if ($first[0] == '"') {
$prev_line[count($prev_line)-1] = '"' . $prev_line[count($prev_line)-1] . "\n" . substr($first, 1);
}
else {
$prev_line[count($prev_line)-1] .= "\n" . $first;
}
$elements = array_merge($prev_line, $elements);
}
$last_element = $elements[count($elements)-1];
if ($last_element[0] == '"') {
$elements[count($elements)-1] = substr($last_element, 1);
$prev_line = $elements;
continue;
}
$this->csv_to_vcard($elements);
$prev_line = false;
}
}
} | php | public function import($csv)
{
// convert to UTF-8
$head = substr($csv, 0, 4096);
$charset = rcube_charset::detect($head, RCUBE_CHARSET);
$csv = rcube_charset::convert($csv, $charset);
$csv = preg_replace(array('/^[\xFE\xFF]{2}/', '/^\xEF\xBB\xBF/', '/^\x00+/'), '', $csv); // also remove BOM
$head = '';
$prev_line = false;
$this->map = array();
$this->gmail_map = array();
// Parse file
foreach (preg_split("/[\r\n]+/", $csv) as $line) {
if (!empty($prev_line)) {
$line = '"' . $line;
}
$elements = $this->parse_line($line);
if (empty($elements)) {
continue;
}
// Parse header
if (empty($this->map)) {
$this->parse_header($elements);
if (empty($this->map)) {
break;
}
}
// Parse data row
else {
// handle multiline elements (e.g. Gmail)
if (!empty($prev_line)) {
$first = array_shift($elements);
if ($first[0] == '"') {
$prev_line[count($prev_line)-1] = '"' . $prev_line[count($prev_line)-1] . "\n" . substr($first, 1);
}
else {
$prev_line[count($prev_line)-1] .= "\n" . $first;
}
$elements = array_merge($prev_line, $elements);
}
$last_element = $elements[count($elements)-1];
if ($last_element[0] == '"') {
$elements[count($elements)-1] = substr($last_element, 1);
$prev_line = $elements;
continue;
}
$this->csv_to_vcard($elements);
$prev_line = false;
}
}
} | [
"public",
"function",
"import",
"(",
"$",
"csv",
")",
"{",
"// convert to UTF-8",
"$",
"head",
"=",
"substr",
"(",
"$",
"csv",
",",
"0",
",",
"4096",
")",
";",
"$",
"charset",
"=",
"rcube_charset",
"::",
"detect",
"(",
"$",
"head",
",",
"RCUBE_CHARSET"... | Import contacts from CSV file
@param string $csv Content of the CSV file | [
"Import",
"contacts",
"from",
"CSV",
"file"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_csv2vcard.php#L401-L459 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_csv2vcard.php | rcube_csv2vcard.parse_line | protected function parse_line($line)
{
$line = trim($line);
if (empty($line)) {
return null;
}
$fields = rcube_utils::explode_quoted_string(',', $line);
// remove quotes if needed
if (!empty($fields)) {
foreach ($fields as $idx => $value) {
if (($len = strlen($value)) > 1 && $value[0] == '"' && $value[$len-1] == '"') {
// remove surrounding quotes
$value = substr($value, 1, -1);
// replace doubled quotes inside the string with single quote
$value = str_replace('""', '"', $value);
$fields[$idx] = $value;
}
}
}
return $fields;
} | php | protected function parse_line($line)
{
$line = trim($line);
if (empty($line)) {
return null;
}
$fields = rcube_utils::explode_quoted_string(',', $line);
// remove quotes if needed
if (!empty($fields)) {
foreach ($fields as $idx => $value) {
if (($len = strlen($value)) > 1 && $value[0] == '"' && $value[$len-1] == '"') {
// remove surrounding quotes
$value = substr($value, 1, -1);
// replace doubled quotes inside the string with single quote
$value = str_replace('""', '"', $value);
$fields[$idx] = $value;
}
}
}
return $fields;
} | [
"protected",
"function",
"parse_line",
"(",
"$",
"line",
")",
"{",
"$",
"line",
"=",
"trim",
"(",
"$",
"line",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"line",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"fields",
"=",
"rcube_utils",
"::",
"ex... | Parse CSV file line | [
"Parse",
"CSV",
"file",
"line"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_csv2vcard.php#L474-L498 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_csv2vcard.php | rcube_csv2vcard.parse_header | protected function parse_header($elements)
{
$map1 = array();
$map2 = array();
$size = count($elements);
// check English labels
for ($i = 0; $i < $size; $i++) {
$label = $this->label_map[$elements[$i]];
if ($label && !empty($this->csv2vcard_map[$label])) {
$map1[$i] = $this->csv2vcard_map[$label];
}
}
// check localized labels
if (!empty($this->local_label_map)) {
for ($i = 0; $i < $size; $i++) {
$label = $this->local_label_map[$elements[$i]];
// special localization label
if ($label && $label[0] == '_') {
$label = substr($label, 1);
}
if ($label && !empty($this->csv2vcard_map[$label])) {
$map2[$i] = $this->csv2vcard_map[$label];
}
}
}
$this->map = count($map1) >= count($map2) ? $map1 : $map2;
// support special Gmail format
foreach ($this->gmail_label_map as $key => $items) {
$num = 1;
while (($_key = "$key $num - Type") && ($found = array_search($_key, $elements)) !== false) {
$this->gmail_map["$key:$num"] = array('_key' => $key, '_idx' => $found);
foreach (array_keys($items) as $item_key) {
$_key = "$key $num - $item_key";
if (($found = array_search($_key, $elements)) !== false) {
$this->gmail_map["$key:$num"][$item_key] = $found;
}
}
$num++;
}
}
} | php | protected function parse_header($elements)
{
$map1 = array();
$map2 = array();
$size = count($elements);
// check English labels
for ($i = 0; $i < $size; $i++) {
$label = $this->label_map[$elements[$i]];
if ($label && !empty($this->csv2vcard_map[$label])) {
$map1[$i] = $this->csv2vcard_map[$label];
}
}
// check localized labels
if (!empty($this->local_label_map)) {
for ($i = 0; $i < $size; $i++) {
$label = $this->local_label_map[$elements[$i]];
// special localization label
if ($label && $label[0] == '_') {
$label = substr($label, 1);
}
if ($label && !empty($this->csv2vcard_map[$label])) {
$map2[$i] = $this->csv2vcard_map[$label];
}
}
}
$this->map = count($map1) >= count($map2) ? $map1 : $map2;
// support special Gmail format
foreach ($this->gmail_label_map as $key => $items) {
$num = 1;
while (($_key = "$key $num - Type") && ($found = array_search($_key, $elements)) !== false) {
$this->gmail_map["$key:$num"] = array('_key' => $key, '_idx' => $found);
foreach (array_keys($items) as $item_key) {
$_key = "$key $num - $item_key";
if (($found = array_search($_key, $elements)) !== false) {
$this->gmail_map["$key:$num"][$item_key] = $found;
}
}
$num++;
}
}
} | [
"protected",
"function",
"parse_header",
"(",
"$",
"elements",
")",
"{",
"$",
"map1",
"=",
"array",
"(",
")",
";",
"$",
"map2",
"=",
"array",
"(",
")",
";",
"$",
"size",
"=",
"count",
"(",
"$",
"elements",
")",
";",
"// check English labels",
"for",
... | Parse CSV header line, detect fields mapping | [
"Parse",
"CSV",
"header",
"line",
"detect",
"fields",
"mapping"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_csv2vcard.php#L503-L550 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_plugin.php | rcube_plugin.load_config | public function load_config($fname = 'config.inc.php')
{
if (in_array($fname, $this->loaded_config)) {
return true;
}
$this->loaded_config[] = $fname;
$fpath = $this->home.'/'.$fname;
$rcube = rcube::get_instance();
if (($is_local = is_file($fpath)) && !$rcube->config->load_from_file($fpath)) {
rcube::raise_error(array(
'code' => 527, 'type' => 'php',
'file' => __FILE__, 'line' => __LINE__,
'message' => "Failed to load config from $fpath"), true, false);
return false;
}
else if (!$is_local) {
// Search plugin_name.inc.php file in any configured path
return $rcube->config->load_from_file($this->ID . '.inc.php');
}
return true;
} | php | public function load_config($fname = 'config.inc.php')
{
if (in_array($fname, $this->loaded_config)) {
return true;
}
$this->loaded_config[] = $fname;
$fpath = $this->home.'/'.$fname;
$rcube = rcube::get_instance();
if (($is_local = is_file($fpath)) && !$rcube->config->load_from_file($fpath)) {
rcube::raise_error(array(
'code' => 527, 'type' => 'php',
'file' => __FILE__, 'line' => __LINE__,
'message' => "Failed to load config from $fpath"), true, false);
return false;
}
else if (!$is_local) {
// Search plugin_name.inc.php file in any configured path
return $rcube->config->load_from_file($this->ID . '.inc.php');
}
return true;
} | [
"public",
"function",
"load_config",
"(",
"$",
"fname",
"=",
"'config.inc.php'",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"fname",
",",
"$",
"this",
"->",
"loaded_config",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"loaded_config",
... | Load local config file from plugins directory.
The loaded values are patched over the global configuration.
@param string $fname Config file name relative to the plugin's folder
@return boolean True on success, false on failure | [
"Load",
"local",
"config",
"file",
"from",
"plugins",
"directory",
".",
"The",
"loaded",
"values",
"are",
"patched",
"over",
"the",
"global",
"configuration",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_plugin.php#L143-L167 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_plugin.php | rcube_plugin.add_texts | public function add_texts($dir, $add2client = false)
{
$domain = $this->ID;
$lang = $_SESSION['language'];
$langs = array_unique(array('en_US', $lang));
$locdir = slashify(realpath(slashify($this->home) . $dir));
$texts = array();
// Language aliases used to find localization in similar lang, see below
$aliases = array(
'de_CH' => 'de_DE',
'es_AR' => 'es_ES',
'fa_AF' => 'fa_IR',
'nl_BE' => 'nl_NL',
'pt_BR' => 'pt_PT',
'zh_CN' => 'zh_TW',
);
// use buffering to handle empty lines/spaces after closing PHP tag
ob_start();
foreach ($langs as $lng) {
$fpath = $locdir . $lng . '.inc';
if (is_file($fpath) && is_readable($fpath)) {
include $fpath;
$texts = (array)$labels + (array)$messages + (array)$texts;
}
else if ($lng != 'en_US') {
// Find localization in similar language (#1488401)
$alias = null;
if (!empty($aliases[$lng])) {
$alias = $aliases[$lng];
}
else if ($key = array_search($lng, $aliases)) {
$alias = $key;
}
if (!empty($alias)) {
$fpath = $locdir . $alias . '.inc';
if (is_file($fpath) && is_readable($fpath)) {
include $fpath;
$texts = (array)$labels + (array)$messages + (array)$texts;
}
}
}
}
ob_end_clean();
// prepend domain to text keys and add to the application texts repository
if (!empty($texts)) {
$add = array();
foreach ($texts as $key => $value) {
$add[$domain.'.'.$key] = $value;
}
$rcube = rcube::get_instance();
$rcube->load_language($lang, $add);
// add labels to client
if ($add2client && method_exists($rcube->output, 'add_label')) {
if (is_array($add2client)) {
$js_labels = array_map(array($this, 'label_map_callback'), $add2client);
}
else {
$js_labels = array_keys($add);
}
$rcube->output->add_label($js_labels);
}
}
} | php | public function add_texts($dir, $add2client = false)
{
$domain = $this->ID;
$lang = $_SESSION['language'];
$langs = array_unique(array('en_US', $lang));
$locdir = slashify(realpath(slashify($this->home) . $dir));
$texts = array();
// Language aliases used to find localization in similar lang, see below
$aliases = array(
'de_CH' => 'de_DE',
'es_AR' => 'es_ES',
'fa_AF' => 'fa_IR',
'nl_BE' => 'nl_NL',
'pt_BR' => 'pt_PT',
'zh_CN' => 'zh_TW',
);
// use buffering to handle empty lines/spaces after closing PHP tag
ob_start();
foreach ($langs as $lng) {
$fpath = $locdir . $lng . '.inc';
if (is_file($fpath) && is_readable($fpath)) {
include $fpath;
$texts = (array)$labels + (array)$messages + (array)$texts;
}
else if ($lng != 'en_US') {
// Find localization in similar language (#1488401)
$alias = null;
if (!empty($aliases[$lng])) {
$alias = $aliases[$lng];
}
else if ($key = array_search($lng, $aliases)) {
$alias = $key;
}
if (!empty($alias)) {
$fpath = $locdir . $alias . '.inc';
if (is_file($fpath) && is_readable($fpath)) {
include $fpath;
$texts = (array)$labels + (array)$messages + (array)$texts;
}
}
}
}
ob_end_clean();
// prepend domain to text keys and add to the application texts repository
if (!empty($texts)) {
$add = array();
foreach ($texts as $key => $value) {
$add[$domain.'.'.$key] = $value;
}
$rcube = rcube::get_instance();
$rcube->load_language($lang, $add);
// add labels to client
if ($add2client && method_exists($rcube->output, 'add_label')) {
if (is_array($add2client)) {
$js_labels = array_map(array($this, 'label_map_callback'), $add2client);
}
else {
$js_labels = array_keys($add);
}
$rcube->output->add_label($js_labels);
}
}
} | [
"public",
"function",
"add_texts",
"(",
"$",
"dir",
",",
"$",
"add2client",
"=",
"false",
")",
"{",
"$",
"domain",
"=",
"$",
"this",
"->",
"ID",
";",
"$",
"lang",
"=",
"$",
"_SESSION",
"[",
"'language'",
"]",
";",
"$",
"langs",
"=",
"array_unique",
... | Load localized texts from the plugins dir
@param string $dir Directory to search in
@param mixed $add2client Make texts also available on the client
(array with list or true for all) | [
"Load",
"localized",
"texts",
"from",
"the",
"plugins",
"dir"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_plugin.php#L200-L270 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_plugin.php | rcube_plugin.register_action | public function register_action($action, $callback)
{
$this->api->register_action($action, $this->ID, $callback, $this->mytask);
} | php | public function register_action($action, $callback)
{
$this->api->register_action($action, $this->ID, $callback, $this->mytask);
} | [
"public",
"function",
"register_action",
"(",
"$",
"action",
",",
"$",
"callback",
")",
"{",
"$",
"this",
"->",
"api",
"->",
"register_action",
"(",
"$",
"action",
",",
"$",
"this",
"->",
"ID",
",",
"$",
"callback",
",",
"$",
"this",
"->",
"mytask",
... | Register a handler for a specific client-request action
The callback will be executed upon a request like /?_task=mail&_action=plugin.myaction
@param string $action Action name (should be unique)
@param mixed $callback Callback function as string
or array with object reference and method name | [
"Register",
"a",
"handler",
"for",
"a",
"specific",
"client",
"-",
"request",
"action"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_plugin.php#L324-L327 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_plugin.php | rcube_plugin.register_handler | public function register_handler($name, $callback)
{
$this->api->register_handler($name, $this->ID, $callback);
} | php | public function register_handler($name, $callback)
{
$this->api->register_handler($name, $this->ID, $callback);
} | [
"public",
"function",
"register_handler",
"(",
"$",
"name",
",",
"$",
"callback",
")",
"{",
"$",
"this",
"->",
"api",
"->",
"register_handler",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"ID",
",",
"$",
"callback",
")",
";",
"}"
] | Register a handler function for a template object
When parsing a template for display, tags like <roundcube:object name="plugin.myobject" />
will be replaced by the return value if the registered callback function.
@param string $name Object name (should be unique and start with 'plugin.')
@param mixed $callback Callback function as string or array with object reference
and method name | [
"Register",
"a",
"handler",
"function",
"for",
"a",
"template",
"object"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_plugin.php#L339-L342 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_plugin.php | rcube_plugin.add_button | public function add_button($p, $container)
{
if ($this->api->output->type == 'html') {
// fix relative paths
foreach (array('imagepas', 'imageact', 'imagesel') as $key) {
if ($p[$key]) {
$p[$key] = $this->api->url . $this->resource_url($p[$key]);
}
}
$this->api->add_content($this->api->output->button($p), $container);
}
} | php | public function add_button($p, $container)
{
if ($this->api->output->type == 'html') {
// fix relative paths
foreach (array('imagepas', 'imageact', 'imagesel') as $key) {
if ($p[$key]) {
$p[$key] = $this->api->url . $this->resource_url($p[$key]);
}
}
$this->api->add_content($this->api->output->button($p), $container);
}
} | [
"public",
"function",
"add_button",
"(",
"$",
"p",
",",
"$",
"container",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"api",
"->",
"output",
"->",
"type",
"==",
"'html'",
")",
"{",
"// fix relative paths",
"foreach",
"(",
"array",
"(",
"'imagepas'",
",",
"... | Append a button to a certain container
@param array $p Hash array with named parameters (as used in skin templates)
@param string $container Container name where the buttons should be added to
@see rcube_remplate::button() | [
"Append",
"a",
"button",
"to",
"a",
"certain",
"container"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_plugin.php#L372-L384 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_plugin.php | rcube_plugin.local_skin_path | public function local_skin_path()
{
$rcube = rcube::get_instance();
$skins = array_keys((array)$rcube->output->skins);
if (empty($skins)) {
$skins = (array) $rcube->config->get('skin');
}
foreach ($skins as $skin) {
$skin_path = 'skins/' . $skin;
if (is_dir(realpath(slashify($this->home) . $skin_path))) {
break;
}
}
return $skin_path;
} | php | public function local_skin_path()
{
$rcube = rcube::get_instance();
$skins = array_keys((array)$rcube->output->skins);
if (empty($skins)) {
$skins = (array) $rcube->config->get('skin');
}
foreach ($skins as $skin) {
$skin_path = 'skins/' . $skin;
if (is_dir(realpath(slashify($this->home) . $skin_path))) {
break;
}
}
return $skin_path;
} | [
"public",
"function",
"local_skin_path",
"(",
")",
"{",
"$",
"rcube",
"=",
"rcube",
"::",
"get_instance",
"(",
")",
";",
"$",
"skins",
"=",
"array_keys",
"(",
"(",
"array",
")",
"$",
"rcube",
"->",
"output",
"->",
"skins",
")",
";",
"if",
"(",
"empty... | Provide path to the currently selected skin folder within the plugin directory
with a fallback to the default skin folder.
@return string Skin path relative to plugins directory | [
"Provide",
"path",
"to",
"the",
"currently",
"selected",
"skin",
"folder",
"within",
"the",
"plugin",
"directory",
"with",
"a",
"fallback",
"to",
"the",
"default",
"skin",
"folder",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_plugin.php#L420-L435 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_plugin.php | rcube_plugin.label_map_callback | private function label_map_callback($key)
{
if (strpos($key, $this->ID.'.') === 0) {
return $key;
}
return $this->ID.'.'.$key;
} | php | private function label_map_callback($key)
{
if (strpos($key, $this->ID.'.') === 0) {
return $key;
}
return $this->ID.'.'.$key;
} | [
"private",
"function",
"label_map_callback",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"ID",
".",
"'.'",
")",
"===",
"0",
")",
"{",
"return",
"$",
"key",
";",
"}",
"return",
"$",
"this",
"->",
"ID",
... | Callback function for array_map
@param string $key Array key.
@return string | [
"Callback",
"function",
"for",
"array_map"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_plugin.php#L443-L450 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_result_multifolder.php | rcube_result_multifolder.append_result | protected function append_result($result)
{
$this->meta['count'] += $result->count();
// append UIDs to global index
$folder = $result->get_parameters('MAILBOX');
$index = array_map(function($uid) use ($folder) { return $uid . '-' . $folder; }, $result->get());
$this->index = array_merge($this->index, $index);
} | php | protected function append_result($result)
{
$this->meta['count'] += $result->count();
// append UIDs to global index
$folder = $result->get_parameters('MAILBOX');
$index = array_map(function($uid) use ($folder) { return $uid . '-' . $folder; }, $result->get());
$this->index = array_merge($this->index, $index);
} | [
"protected",
"function",
"append_result",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"meta",
"[",
"'count'",
"]",
"+=",
"$",
"result",
"->",
"count",
"(",
")",
";",
"// append UIDs to global index",
"$",
"folder",
"=",
"$",
"result",
"->",
"get_param... | Append message UIDs from the given result to our index | [
"Append",
"message",
"UIDs",
"from",
"the",
"given",
"result",
"to",
"our",
"index"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_result_multifolder.php#L71-L80 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_result_multifolder.php | rcube_result_multifolder.get_set | public function get_set($folder)
{
foreach ($this->sets as $set) {
if ($set->get_parameters('MAILBOX') == $folder) {
return $set;
}
}
return false;
} | php | public function get_set($folder)
{
foreach ($this->sets as $set) {
if ($set->get_parameters('MAILBOX') == $folder) {
return $set;
}
}
return false;
} | [
"public",
"function",
"get_set",
"(",
"$",
"folder",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"sets",
"as",
"$",
"set",
")",
"{",
"if",
"(",
"$",
"set",
"->",
"get_parameters",
"(",
"'MAILBOX'",
")",
"==",
"$",
"folder",
")",
"{",
"return",
"$"... | Returns the stored result object for a particular folder
@param string $folder Folder name
@return false|object rcube_result_* instance of false if none found | [
"Returns",
"the",
"stored",
"result",
"object",
"for",
"a",
"particular",
"folder"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_result_multifolder.php#L279-L288 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_session.php | rcube_session._fixvars | protected function _fixvars($vars, $oldvars)
{
if ($oldvars !== null) {
$a_oldvars = $this->unserialize($oldvars);
if (is_array($a_oldvars)) {
// remove unset keys on oldvars
foreach ((array)$this->unsets as $var) {
if (isset($a_oldvars[$var])) {
unset($a_oldvars[$var]);
}
else {
$path = explode('.', $var);
$k = array_pop($path);
$node = &$this->get_node($path, $a_oldvars);
unset($node[$k]);
}
}
$newvars = $this->serialize(array_merge(
(array)$a_oldvars, (array)$this->unserialize($vars)));
}
else {
$newvars = $vars;
}
}
$this->unsets = array();
return $newvars;
} | php | protected function _fixvars($vars, $oldvars)
{
if ($oldvars !== null) {
$a_oldvars = $this->unserialize($oldvars);
if (is_array($a_oldvars)) {
// remove unset keys on oldvars
foreach ((array)$this->unsets as $var) {
if (isset($a_oldvars[$var])) {
unset($a_oldvars[$var]);
}
else {
$path = explode('.', $var);
$k = array_pop($path);
$node = &$this->get_node($path, $a_oldvars);
unset($node[$k]);
}
}
$newvars = $this->serialize(array_merge(
(array)$a_oldvars, (array)$this->unserialize($vars)));
}
else {
$newvars = $vars;
}
}
$this->unsets = array();
return $newvars;
} | [
"protected",
"function",
"_fixvars",
"(",
"$",
"vars",
",",
"$",
"oldvars",
")",
"{",
"if",
"(",
"$",
"oldvars",
"!==",
"null",
")",
"{",
"$",
"a_oldvars",
"=",
"$",
"this",
"->",
"unserialize",
"(",
"$",
"oldvars",
")",
";",
"if",
"(",
"is_array",
... | Merge vars with old vars and apply unsets | [
"Merge",
"vars",
"with",
"old",
"vars",
"and",
"apply",
"unsets"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_session.php#L203-L231 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_session.php | rcube_session.register_gc_handler | public function register_gc_handler($func)
{
foreach ($this->gc_handlers as $handler) {
if ($handler == $func) {
return;
}
}
$this->gc_handlers[] = $func;
} | php | public function register_gc_handler($func)
{
foreach ($this->gc_handlers as $handler) {
if ($handler == $func) {
return;
}
}
$this->gc_handlers[] = $func;
} | [
"public",
"function",
"register_gc_handler",
"(",
"$",
"func",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"gc_handlers",
"as",
"$",
"handler",
")",
"{",
"if",
"(",
"$",
"handler",
"==",
"$",
"func",
")",
"{",
"return",
";",
"}",
"}",
"$",
"this",
... | Register additional garbage collector functions
@param mixed Callback function | [
"Register",
"additional",
"garbage",
"collector",
"functions"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_session.php#L250-L259 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_session.php | rcube_session.regenerate_id | public function regenerate_id($destroy=true)
{
session_regenerate_id($destroy);
$this->vars = null;
$this->key = session_id();
return true;
} | php | public function regenerate_id($destroy=true)
{
session_regenerate_id($destroy);
$this->vars = null;
$this->key = session_id();
return true;
} | [
"public",
"function",
"regenerate_id",
"(",
"$",
"destroy",
"=",
"true",
")",
"{",
"session_regenerate_id",
"(",
"$",
"destroy",
")",
";",
"$",
"this",
"->",
"vars",
"=",
"null",
";",
"$",
"this",
"->",
"key",
"=",
"session_id",
"(",
")",
";",
"return"... | Generate and set new session id
@param boolean $destroy If enabled the current session will be destroyed
@return bool | [
"Generate",
"and",
"set",
"new",
"session",
"id"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_session.php#L279-L287 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_session.php | rcube_session.get_cache | protected function get_cache($key)
{
// no session data in cache (read() returns false)
if (!$this->key) {
$cache = null;
}
// use internal data for fast requests (up to 0.5 sec.)
else if ($key == $this->key && (!$this->vars || microtime(true) - $this->start < 0.5)) {
$cache = $this->vars;
}
else { // else read data again
$cache = $this->read($key);
}
return $cache;
} | php | protected function get_cache($key)
{
// no session data in cache (read() returns false)
if (!$this->key) {
$cache = null;
}
// use internal data for fast requests (up to 0.5 sec.)
else if ($key == $this->key && (!$this->vars || microtime(true) - $this->start < 0.5)) {
$cache = $this->vars;
}
else { // else read data again
$cache = $this->read($key);
}
return $cache;
} | [
"protected",
"function",
"get_cache",
"(",
"$",
"key",
")",
"{",
"// no session data in cache (read() returns false)",
"if",
"(",
"!",
"$",
"this",
"->",
"key",
")",
"{",
"$",
"cache",
"=",
"null",
";",
"}",
"// use internal data for fast requests (up to 0.5 sec.)",
... | See if we have vars of this key already cached, and if so, return them.
@param string $key Session ID
@return string | [
"See",
"if",
"we",
"have",
"vars",
"of",
"this",
"key",
"already",
"cached",
"and",
"if",
"so",
"return",
"them",
"."
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_session.php#L296-L311 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_session.php | rcube_session.append | public function append($path, $key, $value)
{
// re-read session data from DB because it might be outdated
if (!$this->reloaded && microtime(true) - $this->start > 0.5) {
$this->reload();
$this->reloaded = true;
$this->start = microtime(true);
}
$node = &$this->get_node(explode('.', $path), $_SESSION);
if ($key !== null) {
$node[$key] = $value;
$path .= '.' . $key;
}
else {
$node[] = $value;
}
$this->appends[] = $path;
// when overwriting a previously unset variable
if ($this->unsets[$path]) {
unset($this->unsets[$path]);
}
} | php | public function append($path, $key, $value)
{
// re-read session data from DB because it might be outdated
if (!$this->reloaded && microtime(true) - $this->start > 0.5) {
$this->reload();
$this->reloaded = true;
$this->start = microtime(true);
}
$node = &$this->get_node(explode('.', $path), $_SESSION);
if ($key !== null) {
$node[$key] = $value;
$path .= '.' . $key;
}
else {
$node[] = $value;
}
$this->appends[] = $path;
// when overwriting a previously unset variable
if ($this->unsets[$path]) {
unset($this->unsets[$path]);
}
} | [
"public",
"function",
"append",
"(",
"$",
"path",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"// re-read session data from DB because it might be outdated",
"if",
"(",
"!",
"$",
"this",
"->",
"reloaded",
"&&",
"microtime",
"(",
"true",
")",
"-",
"$",
"thi... | Append the given value to the certain node in the session data array
Warning: Do not use if you already modified $_SESSION in the same request (#1490608)
@param string Path denoting the session variable where to append the value
@param string Key name under which to append the new value (use null for appending to an indexed list)
@param mixed Value to append to the session data array | [
"Append",
"the",
"given",
"value",
"to",
"the",
"certain",
"node",
"in",
"the",
"session",
"data",
"array"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_session.php#L322-L347 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_session.php | rcube_session.remove | public function remove($var=null)
{
if (empty($var)) {
return $this->destroy(session_id());
}
$this->unsets[] = $var;
if (isset($_SESSION[$var])) {
unset($_SESSION[$var]);
}
else {
$path = explode('.', $var);
$key = array_pop($path);
$node = &$this->get_node($path, $_SESSION);
unset($node[$key]);
}
return true;
} | php | public function remove($var=null)
{
if (empty($var)) {
return $this->destroy(session_id());
}
$this->unsets[] = $var;
if (isset($_SESSION[$var])) {
unset($_SESSION[$var]);
}
else {
$path = explode('.', $var);
$key = array_pop($path);
$node = &$this->get_node($path, $_SESSION);
unset($node[$key]);
}
return true;
} | [
"public",
"function",
"remove",
"(",
"$",
"var",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"var",
")",
")",
"{",
"return",
"$",
"this",
"->",
"destroy",
"(",
"session_id",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"unsets",
"[",
"]... | Unset a session variable
@param string Variable name (can be a path denoting a certain node in the session array, e.g. compose.attachments.5)
@return boolean True on success | [
"Unset",
"a",
"session",
"variable"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_session.php#L355-L374 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_session.php | rcube_session.kill | public function kill()
{
$this->vars = null;
$this->ip = rcube_utils::remote_addr(); // update IP (might have changed)
$this->destroy(session_id());
rcube_utils::setcookie($this->cookiename, '-del-', time() - 60);
} | php | public function kill()
{
$this->vars = null;
$this->ip = rcube_utils::remote_addr(); // update IP (might have changed)
$this->destroy(session_id());
rcube_utils::setcookie($this->cookiename, '-del-', time() - 60);
} | [
"public",
"function",
"kill",
"(",
")",
"{",
"$",
"this",
"->",
"vars",
"=",
"null",
";",
"$",
"this",
"->",
"ip",
"=",
"rcube_utils",
"::",
"remote_addr",
"(",
")",
";",
"// update IP (might have changed)",
"$",
"this",
"->",
"destroy",
"(",
"session_id",... | Kill this session | [
"Kill",
"this",
"session"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_session.php#L379-L385 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_session.php | rcube_session.reload | public function reload()
{
// collect updated data from previous appends
$merge_data = array();
foreach ((array)$this->appends as $var) {
$path = explode('.', $var);
$value = $this->get_node($path, $_SESSION);
$k = array_pop($path);
$node = &$this->get_node($path, $merge_data);
$node[$k] = $value;
}
if ($this->key) {
$data = $this->read($this->key);
}
if ($data) {
session_decode($data);
// apply appends and unsets to reloaded data
$_SESSION = array_merge_recursive($_SESSION, $merge_data);
foreach ((array)$this->unsets as $var) {
if (isset($_SESSION[$var])) {
unset($_SESSION[$var]);
}
else {
$path = explode('.', $var);
$k = array_pop($path);
$node = &$this->get_node($path, $_SESSION);
unset($node[$k]);
}
}
}
} | php | public function reload()
{
// collect updated data from previous appends
$merge_data = array();
foreach ((array)$this->appends as $var) {
$path = explode('.', $var);
$value = $this->get_node($path, $_SESSION);
$k = array_pop($path);
$node = &$this->get_node($path, $merge_data);
$node[$k] = $value;
}
if ($this->key) {
$data = $this->read($this->key);
}
if ($data) {
session_decode($data);
// apply appends and unsets to reloaded data
$_SESSION = array_merge_recursive($_SESSION, $merge_data);
foreach ((array)$this->unsets as $var) {
if (isset($_SESSION[$var])) {
unset($_SESSION[$var]);
}
else {
$path = explode('.', $var);
$k = array_pop($path);
$node = &$this->get_node($path, $_SESSION);
unset($node[$k]);
}
}
}
} | [
"public",
"function",
"reload",
"(",
")",
"{",
"// collect updated data from previous appends",
"$",
"merge_data",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"appends",
"as",
"$",
"var",
")",
"{",
"$",
"path",
"=",
... | Re-read session data from storage backend | [
"Re",
"-",
"read",
"session",
"data",
"from",
"storage",
"backend"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_session.php#L390-L424 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_session.php | rcube_session.serialize | protected function serialize($vars)
{
$data = '';
if (is_array($vars)) {
foreach ($vars as $var=>$value)
$data .= $var.'|'.serialize($value);
}
else {
$data = 'b:0;';
}
return $data;
} | php | protected function serialize($vars)
{
$data = '';
if (is_array($vars)) {
foreach ($vars as $var=>$value)
$data .= $var.'|'.serialize($value);
}
else {
$data = 'b:0;';
}
return $data;
} | [
"protected",
"function",
"serialize",
"(",
"$",
"vars",
")",
"{",
"$",
"data",
"=",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"vars",
")",
")",
"{",
"foreach",
"(",
"$",
"vars",
"as",
"$",
"var",
"=>",
"$",
"value",
")",
"$",
"data",
".=",
"$... | Serialize session data | [
"Serialize",
"session",
"data"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_session.php#L447-L459 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_session.php | rcube_session.set_lifetime | public function set_lifetime($lifetime)
{
$this->lifetime = max(120, $lifetime);
// valid time range is now - 1/2 lifetime to now + 1/2 lifetime
$now = time();
$this->now = $now - ($now % ($this->lifetime / 2));
} | php | public function set_lifetime($lifetime)
{
$this->lifetime = max(120, $lifetime);
// valid time range is now - 1/2 lifetime to now + 1/2 lifetime
$now = time();
$this->now = $now - ($now % ($this->lifetime / 2));
} | [
"public",
"function",
"set_lifetime",
"(",
"$",
"lifetime",
")",
"{",
"$",
"this",
"->",
"lifetime",
"=",
"max",
"(",
"120",
",",
"$",
"lifetime",
")",
";",
"// valid time range is now - 1/2 lifetime to now + 1/2 lifetime",
"$",
"now",
"=",
"time",
"(",
")",
"... | Setter for session lifetime | [
"Setter",
"for",
"session",
"lifetime"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_session.php#L562-L569 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_session.php | rcube_session.set_secret | function set_secret($secret = null)
{
// generate random hash and store in session
if (!$secret) {
if (!empty($_SESSION['auth_secret'])) {
$secret = $_SESSION['auth_secret'];
}
else {
$secret = rcube_utils::random_bytes(strlen($this->key));
}
}
$_SESSION['auth_secret'] = $secret;
} | php | function set_secret($secret = null)
{
// generate random hash and store in session
if (!$secret) {
if (!empty($_SESSION['auth_secret'])) {
$secret = $_SESSION['auth_secret'];
}
else {
$secret = rcube_utils::random_bytes(strlen($this->key));
}
}
$_SESSION['auth_secret'] = $secret;
} | [
"function",
"set_secret",
"(",
"$",
"secret",
"=",
"null",
")",
"{",
"// generate random hash and store in session",
"if",
"(",
"!",
"$",
"secret",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"_SESSION",
"[",
"'auth_secret'",
"]",
")",
")",
"{",
"$",
"s... | Setter for cookie encryption secret | [
"Setter",
"for",
"cookie",
"encryption",
"secret"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_session.php#L582-L595 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_session.php | rcube_session.check_auth | function check_auth()
{
$this->cookie = $_COOKIE[$this->cookiename];
$result = $this->ip_check ? rcube_utils::remote_addr() == $this->ip : true;
if (!$result) {
$this->log("IP check failed for " . $this->key . "; expected " . $this->ip . "; got " . rcube_utils::remote_addr());
}
if ($result && $this->_mkcookie($this->now) != $this->cookie) {
$this->log("Session auth check failed for " . $this->key . "; timeslot = " . date('Y-m-d H:i:s', $this->now));
$result = false;
// Check if using id from a previous time slot
for ($i = 1; $i <= 2; $i++) {
$prev = $this->now - ($this->lifetime / 2) * $i;
if ($this->_mkcookie($prev) == $this->cookie) {
$this->log("Send new auth cookie for " . $this->key . ": " . $this->cookie);
$this->set_auth_cookie();
$result = true;
}
}
}
if (!$result) {
$this->log("Session authentication failed for " . $this->key
. "; invalid auth cookie sent; timeslot = " . date('Y-m-d H:i:s', $prev));
}
return $result;
} | php | function check_auth()
{
$this->cookie = $_COOKIE[$this->cookiename];
$result = $this->ip_check ? rcube_utils::remote_addr() == $this->ip : true;
if (!$result) {
$this->log("IP check failed for " . $this->key . "; expected " . $this->ip . "; got " . rcube_utils::remote_addr());
}
if ($result && $this->_mkcookie($this->now) != $this->cookie) {
$this->log("Session auth check failed for " . $this->key . "; timeslot = " . date('Y-m-d H:i:s', $this->now));
$result = false;
// Check if using id from a previous time slot
for ($i = 1; $i <= 2; $i++) {
$prev = $this->now - ($this->lifetime / 2) * $i;
if ($this->_mkcookie($prev) == $this->cookie) {
$this->log("Send new auth cookie for " . $this->key . ": " . $this->cookie);
$this->set_auth_cookie();
$result = true;
}
}
}
if (!$result) {
$this->log("Session authentication failed for " . $this->key
. "; invalid auth cookie sent; timeslot = " . date('Y-m-d H:i:s', $prev));
}
return $result;
} | [
"function",
"check_auth",
"(",
")",
"{",
"$",
"this",
"->",
"cookie",
"=",
"$",
"_COOKIE",
"[",
"$",
"this",
"->",
"cookiename",
"]",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"ip_check",
"?",
"rcube_utils",
"::",
"remote_addr",
"(",
")",
"==",
"$"... | Check session authentication cookie
@return boolean True if valid, False if not | [
"Check",
"session",
"authentication",
"cookie"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_session.php#L620-L650 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_session.php | rcube_session.set_auth_cookie | public function set_auth_cookie()
{
$this->cookie = $this->_mkcookie($this->now);
rcube_utils::setcookie($this->cookiename, $this->cookie, 0);
$_COOKIE[$this->cookiename] = $this->cookie;
} | php | public function set_auth_cookie()
{
$this->cookie = $this->_mkcookie($this->now);
rcube_utils::setcookie($this->cookiename, $this->cookie, 0);
$_COOKIE[$this->cookiename] = $this->cookie;
} | [
"public",
"function",
"set_auth_cookie",
"(",
")",
"{",
"$",
"this",
"->",
"cookie",
"=",
"$",
"this",
"->",
"_mkcookie",
"(",
"$",
"this",
"->",
"now",
")",
";",
"rcube_utils",
"::",
"setcookie",
"(",
"$",
"this",
"->",
"cookiename",
",",
"$",
"this",... | Set session authentication cookie | [
"Set",
"session",
"authentication",
"cookie"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_session.php#L655-L660 | train |
netgen/NetgenInformationCollectionBundle | bundle/Form/DataMapper/InformationCollectionMapper.php | InformationCollectionMapper.mapFromForm | protected function mapFromForm(
FormInterface $form,
DataWrapper $data,
PropertyPathInterface $propertyPath
) {
/** @var InformationCollectionStruct $payload */
$payload = $data->payload;
/** @var ContentType $contentType */
$contentType = $data->definition;
$fieldDefinitionIdentifier = (string) $propertyPath;
$fieldDefinition = $contentType->getFieldDefinition($fieldDefinitionIdentifier);
if (null === $fieldDefinition) {
throw new RuntimeException(
"Data definition does not contain expected FieldDefinition '{$fieldDefinitionIdentifier}'"
);
}
$fieldTypeIdentifier = $fieldDefinition->fieldTypeIdentifier;
$handler = $this->fieldTypeHandlerRegistry->get($fieldTypeIdentifier);
$payload->setCollectedFieldValue(
$fieldDefinitionIdentifier,
$handler->convertFieldValueFromForm($form->getData())
);
} | php | protected function mapFromForm(
FormInterface $form,
DataWrapper $data,
PropertyPathInterface $propertyPath
) {
/** @var InformationCollectionStruct $payload */
$payload = $data->payload;
/** @var ContentType $contentType */
$contentType = $data->definition;
$fieldDefinitionIdentifier = (string) $propertyPath;
$fieldDefinition = $contentType->getFieldDefinition($fieldDefinitionIdentifier);
if (null === $fieldDefinition) {
throw new RuntimeException(
"Data definition does not contain expected FieldDefinition '{$fieldDefinitionIdentifier}'"
);
}
$fieldTypeIdentifier = $fieldDefinition->fieldTypeIdentifier;
$handler = $this->fieldTypeHandlerRegistry->get($fieldTypeIdentifier);
$payload->setCollectedFieldValue(
$fieldDefinitionIdentifier,
$handler->convertFieldValueFromForm($form->getData())
);
} | [
"protected",
"function",
"mapFromForm",
"(",
"FormInterface",
"$",
"form",
",",
"DataWrapper",
"$",
"data",
",",
"PropertyPathInterface",
"$",
"propertyPath",
")",
"{",
"/** @var InformationCollectionStruct $payload */",
"$",
"payload",
"=",
"$",
"data",
"->",
"payloa... | Maps data from form to the eZ Publish structure.
@param \Symfony\Component\Form\FormInterface $form
@param \Netgen\Bundle\EzFormsBundle\Form\DataWrapper $data
@param \Symfony\Component\PropertyAccess\PropertyPathInterface $propertyPath | [
"Maps",
"data",
"from",
"form",
"to",
"the",
"eZ",
"Publish",
"structure",
"."
] | 3ed7a2b33b1e80d3a0d9ee607eab495396044b29 | https://github.com/netgen/NetgenInformationCollectionBundle/blob/3ed7a2b33b1e80d3a0d9ee607eab495396044b29/bundle/Form/DataMapper/InformationCollectionMapper.php#L58-L84 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_output.php | rcube_output.nocacheing_headers | public function nocacheing_headers()
{
if (headers_sent()) {
return;
}
header("Expires: ".gmdate("D, d M Y H:i:s")." GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
// We need to set the following headers to make downloads work using IE in HTTPS mode.
if ($this->browser->ie && rcube_utils::https_check()) {
header('Pragma: private');
header("Cache-Control: private, must-revalidate");
}
else {
header("Cache-Control: private, no-cache, no-store, must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");
}
} | php | public function nocacheing_headers()
{
if (headers_sent()) {
return;
}
header("Expires: ".gmdate("D, d M Y H:i:s")." GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
// We need to set the following headers to make downloads work using IE in HTTPS mode.
if ($this->browser->ie && rcube_utils::https_check()) {
header('Pragma: private');
header("Cache-Control: private, must-revalidate");
}
else {
header("Cache-Control: private, no-cache, no-store, must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");
}
} | [
"public",
"function",
"nocacheing_headers",
"(",
")",
"{",
"if",
"(",
"headers_sent",
"(",
")",
")",
"{",
"return",
";",
"}",
"header",
"(",
"\"Expires: \"",
".",
"gmdate",
"(",
"\"D, d M Y H:i:s\"",
")",
".",
"\" GMT\"",
")",
";",
"header",
"(",
"\"Last-M... | Send HTTP headers to prevent caching a page | [
"Send",
"HTTP",
"headers",
"to",
"prevent",
"caching",
"a",
"page"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_output.php#L141-L159 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_output.php | rcube_output.get_edit_field | public static function get_edit_field($col, $value, $attrib, $type = 'text')
{
static $colcounts = array();
$fname = '_'.$col;
$attrib['name'] = $fname . ($attrib['array'] ? '[]' : '');
$attrib['class'] = trim($attrib['class'] . ' ff_' . $col);
if ($type == 'checkbox') {
$attrib['value'] = '1';
$input = new html_checkbox($attrib);
}
else if ($type == 'textarea') {
$attrib['cols'] = $attrib['size'];
$input = new html_textarea($attrib);
}
else if ($type == 'select') {
$input = new html_select($attrib);
$input->add('---', '');
$input->add(array_values($attrib['options']), array_keys($attrib['options']));
}
else if ($type == 'password' || $attrib['type'] == 'password') {
$input = new html_passwordfield($attrib);
}
else {
if ($attrib['type'] != 'text' && $attrib['type'] != 'hidden') {
$attrib['type'] = 'text';
}
$input = new html_inputfield($attrib);
}
// use value from post
if (isset($_POST[$fname])) {
$postvalue = rcube_utils::get_input_value($fname, rcube_utils::INPUT_POST, true);
$value = $attrib['array'] ? $postvalue[intval($colcounts[$col]++)] : $postvalue;
}
$out = $input->show($value);
return $out;
} | php | public static function get_edit_field($col, $value, $attrib, $type = 'text')
{
static $colcounts = array();
$fname = '_'.$col;
$attrib['name'] = $fname . ($attrib['array'] ? '[]' : '');
$attrib['class'] = trim($attrib['class'] . ' ff_' . $col);
if ($type == 'checkbox') {
$attrib['value'] = '1';
$input = new html_checkbox($attrib);
}
else if ($type == 'textarea') {
$attrib['cols'] = $attrib['size'];
$input = new html_textarea($attrib);
}
else if ($type == 'select') {
$input = new html_select($attrib);
$input->add('---', '');
$input->add(array_values($attrib['options']), array_keys($attrib['options']));
}
else if ($type == 'password' || $attrib['type'] == 'password') {
$input = new html_passwordfield($attrib);
}
else {
if ($attrib['type'] != 'text' && $attrib['type'] != 'hidden') {
$attrib['type'] = 'text';
}
$input = new html_inputfield($attrib);
}
// use value from post
if (isset($_POST[$fname])) {
$postvalue = rcube_utils::get_input_value($fname, rcube_utils::INPUT_POST, true);
$value = $attrib['array'] ? $postvalue[intval($colcounts[$col]++)] : $postvalue;
}
$out = $input->show($value);
return $out;
} | [
"public",
"static",
"function",
"get_edit_field",
"(",
"$",
"col",
",",
"$",
"value",
",",
"$",
"attrib",
",",
"$",
"type",
"=",
"'text'",
")",
"{",
"static",
"$",
"colcounts",
"=",
"array",
"(",
")",
";",
"$",
"fname",
"=",
"'_'",
".",
"$",
"col",... | Create an edit field for inclusion on a form
@param string $col Field name
@param string $value Field value
@param array $attrib HTML element attributes for the field
@param string $type HTML element type (default 'text')
@return string HTML field definition | [
"Create",
"an",
"edit",
"field",
"for",
"inclusion",
"on",
"a",
"form"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_output.php#L223-L263 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_output.php | rcube_output.json_serialize | public static function json_serialize($input, $pretty = false, $inline = true)
{
// The input need to be valid UTF-8 to use with json_encode()
$input = rcube_charset::clean($input);
$options = 0;
// JSON_HEX_TAG is needed for inlining JSON inside of the <script> tag
// if input contains a html tag it will cause issues (#6207)
if ($inline) {
$options |= JSON_HEX_TAG;
}
if ($pretty) {
$options |= JSON_PRETTY_PRINT;
}
// sometimes even using rcube_charset::clean() the input contains invalid UTF-8 sequences
// that's why we have @ here
return @json_encode($input, $options);
} | php | public static function json_serialize($input, $pretty = false, $inline = true)
{
// The input need to be valid UTF-8 to use with json_encode()
$input = rcube_charset::clean($input);
$options = 0;
// JSON_HEX_TAG is needed for inlining JSON inside of the <script> tag
// if input contains a html tag it will cause issues (#6207)
if ($inline) {
$options |= JSON_HEX_TAG;
}
if ($pretty) {
$options |= JSON_PRETTY_PRINT;
}
// sometimes even using rcube_charset::clean() the input contains invalid UTF-8 sequences
// that's why we have @ here
return @json_encode($input, $options);
} | [
"public",
"static",
"function",
"json_serialize",
"(",
"$",
"input",
",",
"$",
"pretty",
"=",
"false",
",",
"$",
"inline",
"=",
"true",
")",
"{",
"// The input need to be valid UTF-8 to use with json_encode()",
"$",
"input",
"=",
"rcube_charset",
"::",
"clean",
"(... | Convert a variable into a javascript object notation
@param mixed $input Input value
@param boolean $pretty Enable JSON formatting
@param boolean $inline Enable inline mode (generates output safe for use inside HTML)
@return string Serialized JSON string | [
"Convert",
"a",
"variable",
"into",
"a",
"javascript",
"object",
"notation"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_output.php#L274-L293 | train |
i-MSCP/roundcube | roundcubemail/plugins/zipdownload/zipdownload.php | zipdownload.download_menu | public function download_menu()
{
$this->include_script('zipdownload.js');
$this->add_label('download');
$rcmail = rcmail::get_instance();
$menu = array();
$ul_attr = array('role' => 'menu', 'aria-labelledby' => 'aria-label-zipdownloadmenu');
if ($rcmail->config->get('skin') != 'classic') {
$ul_attr['class'] = 'toolbarmenu';
}
foreach (array('eml', 'mbox', 'maildir') as $type) {
$menu[] = html::tag('li', null, $rcmail->output->button(array(
'command' => "download-$type",
'label' => "zipdownload.download$type",
'classact' => 'active',
)));
}
$rcmail->output->add_footer(html::div(array('id' => 'zipdownload-menu', 'class' => 'popupmenu', 'aria-hidden' => 'true'),
html::tag('h2', array('class' => 'voice', 'id' => 'aria-label-zipdownloadmenu'), "Message Download Options Menu") .
html::tag('ul', $ul_attr, implode('', $menu))));
} | php | public function download_menu()
{
$this->include_script('zipdownload.js');
$this->add_label('download');
$rcmail = rcmail::get_instance();
$menu = array();
$ul_attr = array('role' => 'menu', 'aria-labelledby' => 'aria-label-zipdownloadmenu');
if ($rcmail->config->get('skin') != 'classic') {
$ul_attr['class'] = 'toolbarmenu';
}
foreach (array('eml', 'mbox', 'maildir') as $type) {
$menu[] = html::tag('li', null, $rcmail->output->button(array(
'command' => "download-$type",
'label' => "zipdownload.download$type",
'classact' => 'active',
)));
}
$rcmail->output->add_footer(html::div(array('id' => 'zipdownload-menu', 'class' => 'popupmenu', 'aria-hidden' => 'true'),
html::tag('h2', array('class' => 'voice', 'id' => 'aria-label-zipdownloadmenu'), "Message Download Options Menu") .
html::tag('ul', $ul_attr, implode('', $menu))));
} | [
"public",
"function",
"download_menu",
"(",
")",
"{",
"$",
"this",
"->",
"include_script",
"(",
"'zipdownload.js'",
")",
";",
"$",
"this",
"->",
"add_label",
"(",
"'download'",
")",
";",
"$",
"rcmail",
"=",
"rcmail",
"::",
"get_instance",
"(",
")",
";",
... | Adds download options menu to the page | [
"Adds",
"download",
"options",
"menu",
"to",
"the",
"page"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/zipdownload/zipdownload.php#L98-L121 | train |
i-MSCP/roundcube | roundcubemail/plugins/zipdownload/zipdownload.php | zipdownload.download_attachments | public function download_attachments()
{
$rcmail = rcmail::get_instance();
// require CSRF protected request
$rcmail->request_security_check(rcube_utils::INPUT_GET);
$imap = $rcmail->get_storage();
$temp_dir = $rcmail->config->get('temp_dir');
$tmpfname = tempnam($temp_dir, 'zipdownload');
$tempfiles = array($tmpfname);
$message = new rcube_message(rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GET));
// open zip file
$zip = new ZipArchive();
$zip->open($tmpfname, ZIPARCHIVE::OVERWRITE);
foreach ($message->attachments as $part) {
$pid = $part->mime_id;
$part = $message->mime_parts[$pid];
$disp_name = $this->_create_displayname($part);
$tmpfn = tempnam($temp_dir, 'zipattach');
$tmpfp = fopen($tmpfn, 'w');
$tempfiles[] = $tmpfn;
$message->get_part_body($part->mime_id, false, 0, $tmpfp);
$zip->addFile($tmpfn, $disp_name);
fclose($tmpfp);
}
$zip->close();
$filename = ($this->_filename_from_subject($message->subject) ?: 'attachments') . '.zip';
$this->_deliver_zipfile($tmpfname, $filename);
// delete temporary files from disk
foreach ($tempfiles as $tmpfn) {
unlink($tmpfn);
}
exit;
} | php | public function download_attachments()
{
$rcmail = rcmail::get_instance();
// require CSRF protected request
$rcmail->request_security_check(rcube_utils::INPUT_GET);
$imap = $rcmail->get_storage();
$temp_dir = $rcmail->config->get('temp_dir');
$tmpfname = tempnam($temp_dir, 'zipdownload');
$tempfiles = array($tmpfname);
$message = new rcube_message(rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GET));
// open zip file
$zip = new ZipArchive();
$zip->open($tmpfname, ZIPARCHIVE::OVERWRITE);
foreach ($message->attachments as $part) {
$pid = $part->mime_id;
$part = $message->mime_parts[$pid];
$disp_name = $this->_create_displayname($part);
$tmpfn = tempnam($temp_dir, 'zipattach');
$tmpfp = fopen($tmpfn, 'w');
$tempfiles[] = $tmpfn;
$message->get_part_body($part->mime_id, false, 0, $tmpfp);
$zip->addFile($tmpfn, $disp_name);
fclose($tmpfp);
}
$zip->close();
$filename = ($this->_filename_from_subject($message->subject) ?: 'attachments') . '.zip';
$this->_deliver_zipfile($tmpfname, $filename);
// delete temporary files from disk
foreach ($tempfiles as $tmpfn) {
unlink($tmpfn);
}
exit;
} | [
"public",
"function",
"download_attachments",
"(",
")",
"{",
"$",
"rcmail",
"=",
"rcmail",
"::",
"get_instance",
"(",
")",
";",
"// require CSRF protected request",
"$",
"rcmail",
"->",
"request_security_check",
"(",
"rcube_utils",
"::",
"INPUT_GET",
")",
";",
"$"... | Handler for attachment download action | [
"Handler",
"for",
"attachment",
"download",
"action"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/zipdownload/zipdownload.php#L126-L169 | train |
i-MSCP/roundcube | roundcubemail/plugins/zipdownload/zipdownload.php | zipdownload.download_messages | public function download_messages()
{
$rcmail = rcmail::get_instance();
if ($rcmail->config->get('zipdownload_selection')) {
$messageset = rcmail::get_uids(null, null, $multi, rcube_utils::INPUT_POST);
if (count($messageset)) {
$this->_download_messages($messageset);
}
}
} | php | public function download_messages()
{
$rcmail = rcmail::get_instance();
if ($rcmail->config->get('zipdownload_selection')) {
$messageset = rcmail::get_uids(null, null, $multi, rcube_utils::INPUT_POST);
if (count($messageset)) {
$this->_download_messages($messageset);
}
}
} | [
"public",
"function",
"download_messages",
"(",
")",
"{",
"$",
"rcmail",
"=",
"rcmail",
"::",
"get_instance",
"(",
")",
";",
"if",
"(",
"$",
"rcmail",
"->",
"config",
"->",
"get",
"(",
"'zipdownload_selection'",
")",
")",
"{",
"$",
"messageset",
"=",
"rc... | Handler for message download action | [
"Handler",
"for",
"message",
"download",
"action"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/zipdownload/zipdownload.php#L174-L184 | train |
i-MSCP/roundcube | roundcubemail/plugins/zipdownload/zipdownload.php | zipdownload._create_displayname | private function _create_displayname($part)
{
$rcmail = rcmail::get_instance();
$filename = $part->filename;
if ($filename === null || $filename === '') {
$ext = (array) rcube_mime::get_mime_extensions($part->mimetype);
$ext = array_shift($ext);
$filename = $rcmail->gettext('messagepart') . ' ' . $part->mime_id;
if ($ext) {
$filename .= '.' . $ext;
}
}
$displayname = $this->_convert_filename($filename);
/**
* Adding a number before dot of extension on a name of file with same name on zip
* Ext: attach(1).txt on attach filename that has a attach.txt filename on same zip
*/
if (isset($this->names[$displayname])) {
list($filename, $ext) = preg_split("/\.(?=[^\.]*$)/", $displayname);
$displayname = $filename . '(' . ($this->names[$displayname]++) . ').' . $ext;
$this->names[$displayname] = 1;
}
else {
$this->names[$displayname] = 1;
}
return $displayname;
} | php | private function _create_displayname($part)
{
$rcmail = rcmail::get_instance();
$filename = $part->filename;
if ($filename === null || $filename === '') {
$ext = (array) rcube_mime::get_mime_extensions($part->mimetype);
$ext = array_shift($ext);
$filename = $rcmail->gettext('messagepart') . ' ' . $part->mime_id;
if ($ext) {
$filename .= '.' . $ext;
}
}
$displayname = $this->_convert_filename($filename);
/**
* Adding a number before dot of extension on a name of file with same name on zip
* Ext: attach(1).txt on attach filename that has a attach.txt filename on same zip
*/
if (isset($this->names[$displayname])) {
list($filename, $ext) = preg_split("/\.(?=[^\.]*$)/", $displayname);
$displayname = $filename . '(' . ($this->names[$displayname]++) . ').' . $ext;
$this->names[$displayname] = 1;
}
else {
$this->names[$displayname] = 1;
}
return $displayname;
} | [
"private",
"function",
"_create_displayname",
"(",
"$",
"part",
")",
"{",
"$",
"rcmail",
"=",
"rcmail",
"::",
"get_instance",
"(",
")",
";",
"$",
"filename",
"=",
"$",
"part",
"->",
"filename",
";",
"if",
"(",
"$",
"filename",
"===",
"null",
"||",
"$",... | Create and get display name of attachment part to add on zip file
@param $part stdClass Part of attachment on message
@return string Display name of attachment part | [
"Create",
"and",
"get",
"display",
"name",
"of",
"attachment",
"part",
"to",
"add",
"on",
"zip",
"file"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/zipdownload/zipdownload.php#L193-L223 | train |
i-MSCP/roundcube | roundcubemail/plugins/zipdownload/zipdownload.php | zipdownload._deliver_zipfile | private function _deliver_zipfile($tmpfname, $filename)
{
$browser = new rcube_browser;
$rcmail = rcmail::get_instance();
$rcmail->output->nocacheing_headers();
if ($browser->ie)
$filename = rawurlencode($filename);
else
$filename = addcslashes($filename, '"');
// send download headers
header("Content-Type: application/octet-stream");
if ($browser->ie) {
header("Content-Type: application/force-download");
}
// don't kill the connection if download takes more than 30 sec.
@set_time_limit(0);
header("Content-Disposition: attachment; filename=\"". $filename ."\"");
header("Content-length: " . filesize($tmpfname));
readfile($tmpfname);
} | php | private function _deliver_zipfile($tmpfname, $filename)
{
$browser = new rcube_browser;
$rcmail = rcmail::get_instance();
$rcmail->output->nocacheing_headers();
if ($browser->ie)
$filename = rawurlencode($filename);
else
$filename = addcslashes($filename, '"');
// send download headers
header("Content-Type: application/octet-stream");
if ($browser->ie) {
header("Content-Type: application/force-download");
}
// don't kill the connection if download takes more than 30 sec.
@set_time_limit(0);
header("Content-Disposition: attachment; filename=\"". $filename ."\"");
header("Content-length: " . filesize($tmpfname));
readfile($tmpfname);
} | [
"private",
"function",
"_deliver_zipfile",
"(",
"$",
"tmpfname",
",",
"$",
"filename",
")",
"{",
"$",
"browser",
"=",
"new",
"rcube_browser",
";",
"$",
"rcmail",
"=",
"rcmail",
"::",
"get_instance",
"(",
")",
";",
"$",
"rcmail",
"->",
"output",
"->",
"no... | Helper method to send the zip archive to the browser | [
"Helper",
"method",
"to",
"send",
"the",
"zip",
"archive",
"to",
"the",
"browser"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/zipdownload/zipdownload.php#L330-L353 | train |
i-MSCP/roundcube | roundcubemail/plugins/zipdownload/zipdownload.php | zipdownload._convert_filename | private function _convert_filename($str)
{
$str = strtr($str, array(':' => '', '/' => '-'));
return rcube_charset::convert($str, RCUBE_CHARSET, $this->charset);
} | php | private function _convert_filename($str)
{
$str = strtr($str, array(':' => '', '/' => '-'));
return rcube_charset::convert($str, RCUBE_CHARSET, $this->charset);
} | [
"private",
"function",
"_convert_filename",
"(",
"$",
"str",
")",
"{",
"$",
"str",
"=",
"strtr",
"(",
"$",
"str",
",",
"array",
"(",
"':'",
"=>",
"''",
",",
"'/'",
"=>",
"'-'",
")",
")",
";",
"return",
"rcube_charset",
"::",
"convert",
"(",
"$",
"s... | Helper function to convert filenames to the configured charset | [
"Helper",
"function",
"to",
"convert",
"filenames",
"to",
"the",
"configured",
"charset"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/plugins/zipdownload/zipdownload.php#L358-L363 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_vcard.php | rcube_vcard.export | public function export($folded = true)
{
$vcard = self::vcard_encode($this->raw);
return $folded ? self::rfc2425_fold($vcard) : $vcard;
} | php | public function export($folded = true)
{
$vcard = self::vcard_encode($this->raw);
return $folded ? self::rfc2425_fold($vcard) : $vcard;
} | [
"public",
"function",
"export",
"(",
"$",
"folded",
"=",
"true",
")",
"{",
"$",
"vcard",
"=",
"self",
"::",
"vcard_encode",
"(",
"$",
"this",
"->",
"raw",
")",
";",
"return",
"$",
"folded",
"?",
"self",
"::",
"rfc2425_fold",
"(",
"$",
"vcard",
")",
... | Convert the data structure into a vcard 3.0 string | [
"Convert",
"the",
"data",
"structure",
"into",
"a",
"vcard",
"3",
".",
"0",
"string"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_vcard.php#L258-L262 | train |
i-MSCP/roundcube | roundcubemail/program/lib/Roundcube/rcube_vcard.php | rcube_vcard.reset | public function reset($fields = null)
{
if (!$fields) {
$fields = array_merge(array_values(self::$fieldmap), array_keys($this->immap),
array('FN','N','ORG','NICKNAME','EMAIL','ADR','BDAY'));
}
foreach ($fields as $f) {
unset($this->raw[$f]);
}
if (!$this->raw['N']) {
$this->raw['N'] = array(array('','','','',''));
}
if (!$this->raw['FN']) {
$this->raw['FN'] = array();
}
$this->email = array();
} | php | public function reset($fields = null)
{
if (!$fields) {
$fields = array_merge(array_values(self::$fieldmap), array_keys($this->immap),
array('FN','N','ORG','NICKNAME','EMAIL','ADR','BDAY'));
}
foreach ($fields as $f) {
unset($this->raw[$f]);
}
if (!$this->raw['N']) {
$this->raw['N'] = array(array('','','','',''));
}
if (!$this->raw['FN']) {
$this->raw['FN'] = array();
}
$this->email = array();
} | [
"public",
"function",
"reset",
"(",
"$",
"fields",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"fields",
")",
"{",
"$",
"fields",
"=",
"array_merge",
"(",
"array_values",
"(",
"self",
"::",
"$",
"fieldmap",
")",
",",
"array_keys",
"(",
"$",
"this",
... | Clear the given fields in the loaded vcard data
@param array List of field names to be reset | [
"Clear",
"the",
"given",
"fields",
"in",
"the",
"loaded",
"vcard",
"data"
] | 141965e74cf301575198abc6bf12f207aacaa6c3 | https://github.com/i-MSCP/roundcube/blob/141965e74cf301575198abc6bf12f207aacaa6c3/roundcubemail/program/lib/Roundcube/rcube_vcard.php#L269-L288 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.