Use ternary operator where aplicable
| | |
| | | } |
| | | |
| | | ini_set('session.cookie_secure', $is_secure); |
| | | ini_set('session.name', $sess_name ? $sess_name : 'roundcube_sessid'); |
| | | ini_set('session.name', $sess_name ?: 'roundcube_sessid'); |
| | | ini_set('session.use_cookies', 1); |
| | | ini_set('session.use_only_cookies', 1); |
| | | ini_set('session.cookie_httponly', 1); |
| | |
| | | $attrib = array('name' => $attrib); |
| | | } |
| | | |
| | | $name = $attrib['name'] ? $attrib['name'] : ''; |
| | | $name = (string) $attrib['name']; |
| | | |
| | | // attrib contain text values: use them from now |
| | | if (($setval = $attrib[strtolower($_SESSION['language'])]) || ($setval = $attrib['en_us'])) { |
| | |
| | | */ |
| | | public function load_language($lang = null, $add = array(), $merge = array()) |
| | | { |
| | | $lang = $this->language_prop(($lang ? $lang : $_SESSION['language'])); |
| | | $lang = $this->language_prop($lang ?: $_SESSION['language']); |
| | | |
| | | // load localized texts |
| | | if (empty($this->texts) || $lang != $_SESSION['language']) { |
| | |
| | | */ |
| | | public static function log_bug($arg_arr) |
| | | { |
| | | $program = strtoupper(!empty($arg_arr['type']) ? $arg_arr['type'] : 'php'); |
| | | $program = strtoupper($arg_arr['type'] ?: 'php'); |
| | | $level = self::get_instance()->config->get('debug_level'); |
| | | |
| | | // disable errors for ajax requests, write to log instead (#1487831) |
| | |
| | | else if ($compose_mode == 1) |
| | | $fn = join(' ', array($contact['firstname'], $contact['middlename'], $contact['surname'])); |
| | | else if ($compose_mode == 0) |
| | | $fn = !empty($contact['name']) ? $contact['name'] : join(' ', array($contact['prefix'], $contact['firstname'], $contact['middlename'], $contact['surname'], $contact['suffix'])); |
| | | $fn = $contact['name'] ?: join(' ', array($contact['prefix'], $contact['firstname'], $contact['middlename'], $contact['surname'], $contact['suffix'])); |
| | | else { |
| | | $plugin = rcube::get_instance()->plugins->exec_hook('contact_listname', array('contact' => $contact)); |
| | | $fn = $plugin['fn']; |
| | |
| | | } |
| | | // ISO-8859 |
| | | else if (preg_match('/ISO8859([0-9]{0,2})/', $str, $m)) { |
| | | $iso = 'ISO-8859-' . ($m[1] ? $m[1] : 1); |
| | | $iso = 'ISO-8859-' . ($m[1] ?: 1); |
| | | // some clients sends windows-1252 text as latin1, |
| | | // it is safe to use windows-1252 for all latin1 |
| | | $result = $iso == 'ISO-8859-1' ? 'WINDOWS-1252' : $iso; |
| | |
| | | $aliases['US-ASCII'] = 'ASCII'; |
| | | } |
| | | |
| | | $mb_from = $aliases[$from] ? $aliases[$from] : $from; |
| | | $mb_to = $aliases[$to] ? $aliases[$to] : $to; |
| | | $mb_from = $aliases[$from] ?: $from; |
| | | $mb_to = $aliases[$to] ?: $to; |
| | | |
| | | // return if encoding found, string matches encoding and convert succeeded |
| | | if (in_array($mb_from, $mbstring_list) && in_array($mb_to, $mbstring_list)) { |
| | |
| | | $words = ''; |
| | | |
| | | // copy values into vcard object |
| | | $vcard = new rcube_vcard($record['vcard'] ? $record['vcard'] : $save_data['vcard'], RCUBE_CHARSET, false, $this->vcard_fieldmap); |
| | | $vcard = new rcube_vcard($record['vcard'] ?: $save_data['vcard'], RCUBE_CHARSET, false, $this->vcard_fieldmap); |
| | | $vcard->reset(); |
| | | |
| | | // don't store groups in vCard (#1490277) |
| | |
| | | } |
| | | |
| | | // process the different protocol options |
| | | $parsed['protocol'] = (!empty($proto)) ? $proto : 'tcp'; |
| | | $parsed['protocol'] = $proto ?: 'tcp'; |
| | | $proto_opts = rawurldecode($proto_opts); |
| | | if (strpos($proto_opts, ':') !== false) { |
| | | list($proto_opts, $parsed['port']) = explode(':', $proto_opts); |
| | |
| | | |
| | | do { |
| | | if ($this->eof()) { |
| | | return $line ? $line : null; |
| | | return $line ?: null; |
| | | } |
| | | |
| | | $buffer = fgets($this->fp, $size); |
| | |
| | | } |
| | | } |
| | | |
| | | return !empty($result) ? $result : false; |
| | | return $result ?: false; |
| | | } |
| | | |
| | | /** |
| | |
| | | $bind_dn = $this->prop['bind_dn']; |
| | | |
| | | $this->base_dn = $this->prop['base_dn']; |
| | | $this->groups_base_dn = ($this->prop['groups']['base_dn']) ? |
| | | $this->prop['groups']['base_dn'] : $this->base_dn; |
| | | $this->groups_base_dn = $this->prop['groups']['base_dn'] ?: $this->base_dn; |
| | | |
| | | // User specific access, generate the proper values to use. |
| | | if ($this->prop['user_specific']) { |
| | |
| | | $attrib = array_merge($attrib, array_values($this->group_types)); |
| | | $attrib[] = 'memberURL'; |
| | | |
| | | $filter = $this->prop['groups']['member_filter'] ? $this->prop['groups']['member_filter'] : '(objectclass=*)'; |
| | | $filter = $this->prop['groups']['member_filter'] ?: '(objectclass=*)'; |
| | | |
| | | for ($i=0; $i < $entry[$attr]['count']; $i++) { |
| | | if (empty($entry[$attr][$i])) |
| | |
| | | } |
| | | } |
| | | |
| | | return $newdn ? $newdn : true; |
| | | return $newdn ?: true; |
| | | } |
| | | |
| | | /** |
| | |
| | | function delete_all($with_groups = false) |
| | | { |
| | | // searching for contact entries |
| | | $dn_list = $this->ldap->list_entries($this->base_dn, $this->prop['filter'] ? $this->prop['filter'] : '(objectclass=*)'); |
| | | $dn_list = $this->ldap->list_entries($this->base_dn, $this->prop['filter'] ?: '(objectclass=*)'); |
| | | |
| | | if (!empty($dn_list)) { |
| | | foreach ($dn_list as $idx => $entry) { |
| | |
| | | if ($this->is_group_entry($rec)) { |
| | | $out['_type'] = 'group'; |
| | | $out['readonly'] = true; |
| | | $fieldmap['name'] = $this->group_data['name_attr'] ? $this->group_data['name_attr'] : $this->prop['groups']['name_attr']; |
| | | $fieldmap['name'] = $this->group_data['name_attr'] ?: $this->prop['groups']['name_attr']; |
| | | } |
| | | |
| | | // assign object type from object class mapping |
| | |
| | | $filter = $this->prop['groups']['filter']; |
| | | $scope = $this->prop['groups']['scope']; |
| | | $name_attr = $this->prop['groups']['name_attr']; |
| | | $email_attr = $this->prop['groups']['email_attr'] ? $this->prop['groups']['email_attr'] : 'mail'; |
| | | $email_attr = $this->prop['groups']['email_attr'] ?: 'mail'; |
| | | $sort_attrs = $this->prop['groups']['sort'] ? (array)$this->prop['groups']['sort'] : array($name_attr); |
| | | $sort_attr = $sort_attrs[0]; |
| | | |
| | |
| | | $new_dn = 'cn=' . rcube_ldap_generic::quote_string($group_name, true) . ',' . $this->groups_base_dn; |
| | | $new_gid = self::dn_encode($new_dn); |
| | | $member_attr = $this->get_group_member_attr(); |
| | | $name_attr = $this->prop['groups']['name_attr'] ? $this->prop['groups']['name_attr'] : 'cn'; |
| | | $name_attr = $this->prop['groups']['name_attr'] ?: 'cn'; |
| | | $new_entry = array( |
| | | 'objectClass' => $this->prop['groups']['object_classes'], |
| | | $name_attr => $group_name, |
| | |
| | | |
| | | $base_dn = $this->groups_base_dn; |
| | | $contact_dn = self::dn_decode($contact_id); |
| | | $name_attr = $this->prop['groups']['name_attr'] ? $this->prop['groups']['name_attr'] : 'cn'; |
| | | $name_attr = $this->prop['groups']['name_attr'] ?: 'cn'; |
| | | $member_attr = $this->get_group_member_attr(); |
| | | $add_filter = ''; |
| | | |
| | |
| | | */ |
| | | public static function decode_mime_string($input, $fallback = null) |
| | | { |
| | | $default_charset = !empty($fallback) ? $fallback : self::get_charset(); |
| | | $default_charset = $fallback ?: self::get_charset(); |
| | | |
| | | // rfc: all line breaks or other characters not found |
| | | // in the Base64 Alphabet must be ignored by decoding software |
| | |
| | | // load additional information from local composer.lock file |
| | | if ($lock = $composer_lock['installed'][$json['name']]) { |
| | | $info['version'] = $lock['version']; |
| | | $info['uri'] = $lock['homepage'] ? $lock['homepage'] : $lock['source']['uri']; |
| | | $info['src_uri'] = $lock['dist']['uri'] ? $lock['dist']['uri'] : $lock['source']['uri']; |
| | | $info['uri'] = $lock['homepage'] ?: $lock['source']['uri']; |
| | | $info['src_uri'] = $lock['dist']['uri'] ?: $lock['source']['uri']; |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | // let plugins alter smtp connection config |
| | | $CONFIG = $rcube->plugins->exec_hook('smtp_connect', array( |
| | | 'smtp_server' => $host ? $host : $rcube->config->get('smtp_server'), |
| | | 'smtp_port' => $port ? $port : $rcube->config->get('smtp_port', 25), |
| | | 'smtp_user' => $user ? $user : $rcube->config->get('smtp_user'), |
| | | 'smtp_pass' => $pass ? $pass : $rcube->config->get('smtp_pass'), |
| | | 'smtp_server' => $host ?: $rcube->config->get('smtp_server'), |
| | | 'smtp_port' => $port ?: $rcube->config->get('smtp_port', 25), |
| | | 'smtp_user' => $user ?: $rcube->config->get('smtp_user'), |
| | | 'smtp_pass' => $pass ?: $rcube->config->get('smtp_pass'), |
| | | 'smtp_auth_cid' => $rcube->config->get('smtp_auth_cid'), |
| | | 'smtp_auth_pw' => $rcube->config->get('smtp_auth_pw'), |
| | | 'smtp_auth_type' => $rcube->config->get('smtp_auth_type'), |
| | |
| | | |
| | | $smtp_user = str_replace('%u', $rcube->get_user_name(), $CONFIG['smtp_user']); |
| | | $smtp_pass = str_replace('%p', $rcube->get_user_password(), $CONFIG['smtp_pass']); |
| | | $smtp_auth_type = empty($CONFIG['smtp_auth_type']) ? NULL : $CONFIG['smtp_auth_type']; |
| | | $smtp_auth_type = $CONFIG['smtp_auth_type'] ?: null; |
| | | |
| | | if (!empty($CONFIG['smtp_auth_cid'])) { |
| | | $smtp_authz = $smtp_user; |
| | |
| | | if ($url) { |
| | | $a_uri = parse_url($url); |
| | | $ssl = ($a_uri['scheme'] == 'https' || $a_uri['scheme'] == 'ssl'); |
| | | $port = $a_uri['port'] ? $a_uri['port'] : ($ssl ? 443 : 80); |
| | | $port = $a_uri['port'] ?: ($ssl ? 443 : 80); |
| | | $host = ($ssl ? 'ssl://' : '') . $a_uri['host']; |
| | | $path = $a_uri['path'] . ($a_uri['query'] ? '?'.$a_uri['query'] : '') . $this->lang; |
| | | } |
| | |
| | | { |
| | | $this->rc = rcube::get_instance(); |
| | | $this->engine = $this->rc->config->get('spellcheck_engine', 'googie'); |
| | | $this->lang = $lang ? $lang : 'en'; |
| | | $this->lang = $lang ?: 'en'; |
| | | |
| | | $this->options = array( |
| | | 'ignore_syms' => $this->rc->config->get('spellcheck_ignore_syms'), |
| | |
| | | */ |
| | | function error() |
| | | { |
| | | return $this->error ? $this->error : ($this->backend ? $this->backend->error() : false); |
| | | return $this->error ?: ($this->backend ? $this->backend->error() : false); |
| | | } |
| | | |
| | | private function html2text($text) |
| | |
| | | { |
| | | $headers = $this->get_message_headers($uid); |
| | | return rcube_charset::convert($this->get_message_part($uid, $part, null), |
| | | $headers->charset ? $headers->charset : $this->default_charset); |
| | | $headers->charset ?: $this->default_charset); |
| | | } |
| | | |
| | | /** |
| | |
| | | case self::MAPI_UNICODE_STRING: |
| | | case self::MAPI_BINARY: |
| | | case self::MAPI_OBJECT: |
| | | $num_vals = ($have_mval) ? $num_mval : $this->_geti($data, 32); |
| | | $num_vals = $have_mval ? $num_mval : $this->_geti($data, 32); |
| | | for ($i = 0; $i < $num_vals; $i++) { |
| | | $length = $this->_geti($data, 32); |
| | | |
| | |
| | | |
| | | list($primary, $secondary) = explode('/', $mimetype); |
| | | |
| | | $classes = array($primary ? $primary : 'unknown'); |
| | | $classes = array($primary ?: 'unknown'); |
| | | |
| | | if ($secondary) { |
| | | $classes[] = $secondary; |
| | |
| | | // %d - domain name without first part |
| | | $d = preg_replace('/^[^\.]+\./', '', $_SERVER['HTTP_HOST']); |
| | | // %h - IMAP host |
| | | $h = $_SESSION['storage_host'] ? $_SESSION['storage_host'] : $host; |
| | | $h = $_SESSION['storage_host'] ?: $host; |
| | | // %z - IMAP domain without first part, e.g. %h=imap.domain.tld, %z=domain.tld |
| | | $z = preg_replace('/^[^\.]+\./', '', $h); |
| | | // %s - domain name after the '@' from e-mail address provided at login screen. |
| | |
| | | } |
| | | |
| | | while ($k < count($raw['type']) && ($subtype == 'internet' || $subtype == 'pref')) { |
| | | $subtype = $typemap[$raw['type'][++$k]] ? $typemap[$raw['type'][$k]] : strtolower($raw['type'][$k]); |
| | | $subtype = $typemap[$raw['type'][++$k]] ?: strtolower($raw['type'][$k]); |
| | | } |
| | | } |
| | | |
| | |
| | | && !in_array($k, array('pref','internet','voice','base64')) |
| | | ) { |
| | | $k_uc = strtoupper($k); |
| | | $subtype = $typemap[$k_uc] ? $typemap[$k_uc] : $k; |
| | | $subtype = $typemap[$k_uc] ?: $k; |
| | | break; |
| | | } |
| | | } |
| | |
| | | $this->raw[$tag][$index] = (array)$value; |
| | | if ($type) { |
| | | $typemap = array_flip($this->typemap); |
| | | $this->raw[$tag][$index]['type'] = explode(',', ($typemap[$type_uc] ? $typemap[$type_uc] : $type)); |
| | | $this->raw[$tag][$index]['type'] = explode(',', $typemap[$type_uc] ?: $type); |
| | | } |
| | | } |
| | | else { |
| | |
| | | // $entry['base64'] = true; |
| | | } |
| | | |
| | | $data = self::decode_value($data, $enc ? $enc : 'base64'); |
| | | $data = self::decode_value($data, $enc ?: 'base64'); |
| | | } |
| | | else if ($field == 'PHOTO') { |
| | | // vCard 4.0 data URI, "PHOTO:data:image/jpeg;base64,..." |