本文整理汇总了PHP中rcube_utils类的典型用法代码示例。如果您正苦于以下问题:PHP rcube_utils类的具体用法?PHP rcube_utils怎么用?PHP rcube_utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了rcube_utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ham
public function ham(&$uids)
{
$rcmail = rcube::get_instance();
$storage = $rcmail->storage;
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
$new_uids = array();
foreach (explode(",", $uids) as $uid) {
$saved = false;
$message = new rcube_message($uid);
if (sizeof($message->attachments) > 0) {
foreach ($message->attachments as $part) {
if ($part->ctype_primary == 'message' && $part->ctype_secondary == 'rfc822') {
$orig_message_raw = $storage->get_message_part($message->uid, $part->mime_id, $part);
$saved = $storage->save_message($mbox, $orig_message_raw);
if ($saved !== false) {
$rcmail->output->command('rcmail_markasjunk2_move', null, $uid);
array_push($new_uids, $saved);
}
}
}
}
}
if (sizeof($new_uids) > 0) {
$uids = implode(',', $new_uids);
}
}
示例2: lookup_user_name
function lookup_user_name($args)
{
if ($this->init_ldap($args['host'])) {
$results = $this->ldap->search('*', $args['user'], true);
if (count($results->records) == 1) {
$user_name = is_array($results->records[0]['name']) ? $results->records[0]['name'][0] : $results->records[0]['name'];
$user_email = is_array($results->records[0]['email']) ? $results->records[0]['email'][0] : $results->records[0]['email'];
$args['user_name'] = $user_name;
$args['email_list'] = array();
if (!$args['user_email'] && strpos($user_email, '@')) {
$args['user_email'] = rcube_utils::idn_to_ascii($user_email);
}
foreach (array_keys($results[0]) as $key) {
if (!preg_match('/^email($|:)/', $key)) {
continue;
}
foreach ((array) $results->records[0][$key] as $alias) {
if (strpos($alias, '@')) {
$args['email_list'][] = rcube_utils::idn_to_ascii($alias);
}
}
}
}
}
return $args;
}
示例3: authenticate
function authenticate($args)
{
if (isset($_POST['_user']) && isset($_POST['_pass'])) {
$args['host'] = $this->getHost(rcube_utils::get_input_value('_user', RCUBE_INPUT_POST));
}
return $args;
}
示例4: save_prefs
function save_prefs($args)
{
if ($args['section'] == 'mailview') {
$args['prefs']['hide_blockquote_limit'] = (int) rcube_utils::get_input_value('_hide_blockquote_limit', rcube_utils::INPUT_POST);
}
return $args;
}
示例5: import
/**
*
*/
public function import($csv)
{
// convert to UTF-8
$head = substr($csv, 0, 4096);
$fallback = rcube::get_instance()->config->get('default_charset', 'ISO-8859-1');
// fallback to Latin-1?
$charset = rcube_charset::detect($head, RCMAIL_CHARSET);
$csv = rcube_charset::convert($csv, $charset);
$head = '';
$this->map = array();
// Parse file
foreach (preg_split("/[\r\n]+/", $csv) as $i => $line) {
$line = trim($line);
if (empty($line)) {
continue;
}
$elements = rcube_utils::explode_quoted_string(',', $line);
if (empty($elements)) {
continue;
}
// Parse header
if (empty($this->map)) {
$this->parse_header($elements);
if (empty($this->map)) {
break;
}
} else {
$this->csv_to_vcard($elements);
}
}
}
示例6: connect
/**
* Establish a connection to the LDAP server
*/
public function connect($host = null)
{
// Net_LDAP3 does not support IDNA yet
// also parse_host() here is very Roundcube specific
$host = rcube_utils::idn_to_ascii(rcube_utils::parse_host($host));
return parent::connect($host);
}
示例7: save_data
/**
* Handler for submitted form (ajax request)
*
* Check fields and save to default identity if valid.
* Afterwards the session flag is removed and we're done.
*/
function save_data()
{
$rcmail = rcmail::get_instance();
$identity = $rcmail->user->get_identity();
$ident_level = intval($rcmail->config->get('identities_level', 0));
$save_data = array('name' => rcube_utils::get_input_value('_name', rcube_utils::INPUT_POST), 'email' => rcube_utils::get_input_value('_email', rcube_utils::INPUT_POST), 'organization' => rcube_utils::get_input_value('_organization', rcube_utils::INPUT_POST), 'signature' => rcube_utils::get_input_value('_signature', rcube_utils::INPUT_POST));
// don't let the user alter the e-mail address if disabled by config
if (in_array($ident_level, array(1, 3, 4))) {
$save_data['email'] = $identity['email'];
}
if (empty($save_data['name']) || empty($save_data['email'])) {
$rcmail->output->show_message('formincomplete', 'error');
} else {
if (!rcube_utils::check_email($save_data['email'] = rcube_utils::idn_to_ascii($save_data['email']))) {
$rcmail->output->show_message('emailformaterror', 'error', array('email' => $save_data['email']));
} else {
// save data
$rcmail->user->update_identity($identity['identity_id'], $save_data);
$rcmail->session->remove('plugin.newuserdialog');
// hide dialog
$rcmail->output->command('new_user_dialog_close');
$rcmail->output->show_message('successfullysaved', 'confirmation');
}
}
$rcmail->output->send();
}
示例8: save_settings
function save_settings($args)
{
if ($args['section'] == 'mailbox') {
$args['prefs']['preview_pane'] = rcube_utils::get_input_value('_previewpane_layout', rcube_utils::INPUT_POST) == 'none' ? false : true;
$args['prefs']['previewpane_layout'] = rcube_utils::get_input_value('_previewpane_layout', rcube_utils::INPUT_POST) != 'none' ? rcube_utils::get_input_value('_previewpane_layout', rcube_utils::INPUT_POST) : rcube::get_instance()->config->get('previewpane_layout', 'below');
}
return $args;
}
示例9: create_identity
public function create_identity($p)
{
$rcmail = rcmail::get_instance();
// prefs are set in create_user()
if ($this->prefs) {
if ($this->prefs['full_name']) {
$p['record']['name'] = $this->prefs['full_name'];
}
if (($this->identities_level == 0 || $this->identities_level == 2) && $this->prefs['email_address']) {
$p['record']['email'] = $this->prefs['email_address'];
}
if ($this->prefs['___signature___']) {
$p['record']['signature'] = $this->prefs['___signature___'];
}
if ($this->prefs['reply_to']) {
$p['record']['reply-to'] = $this->prefs['reply_to'];
}
if (($this->identities_level == 0 || $this->identities_level == 1) && isset($this->prefs['identities']) && $this->prefs['identities'] > 1) {
for ($i = 1; $i < $this->prefs['identities']; $i++) {
unset($ident_data);
$ident_data = array('name' => '', 'email' => '');
// required data
if ($this->prefs['full_name' . $i]) {
$ident_data['name'] = $this->prefs['full_name' . $i];
}
if ($this->identities_level == 0 && $this->prefs['email_address' . $i]) {
$ident_data['email'] = $this->prefs['email_address' . $i];
} else {
$ident_data['email'] = $p['record']['email'];
}
if ($this->prefs['reply_to' . $i]) {
$ident_data['reply-to'] = $this->prefs['reply_to' . $i];
}
if ($this->prefs['___sig' . $i . '___']) {
$ident_data['signature'] = $this->prefs['___sig' . $i . '___'];
}
// insert identity
$rcmail->user->insert_identity($ident_data);
}
}
// copy address book
$contacts = $rcmail->get_address_book(null, true);
if ($contacts && count($this->abook)) {
foreach ($this->abook as $rec) {
// #1487096 handle multi-address and/or too long items
$rec['email'] = array_shift(explode(';', $rec['email']));
if (rcube_utils::check_email(rcube_utils::idn_to_ascii($rec['email']))) {
$rec['email'] = rcube_utils::idn_to_utf8($rec['email']);
$contacts->insert($rec, true);
}
}
}
// mark identity as complete for following hooks
$p['complete'] = true;
}
return $p;
}
示例10: messagecount
public function messagecount()
{
$storage = rcube::get_instance()->storage;
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
// send output
header("Content-Type: application/json; charset=" . RCUBE_CHARSET);
echo json_encode(array('messagecount' => $storage->count($mbox, 'EXISTS')));
exit;
}
示例11: mark_notjunk
function mark_notjunk()
{
$this->add_texts('localization');
$this->_set_flags();
$uids = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST);
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
if ($this->_ham($uids, $mbox, $this->ham_mbox)) {
$this->api->output->command('display_message', $this->gettext('reportedasnotjunk'), 'confirmation');
}
$this->api->output->send();
}
示例12: lookup_user_name
function lookup_user_name($args)
{
if ($this->init_ldap($args['host'])) {
$results = $this->ldap->search('*', $args['user'], true);
if (count($results->records) == 1) {
$user_name = is_array($results->records[0]['name']) ? $results->records[0]['name'][0] : $results->records[0]['name'];
$user_email = is_array($results->records[0]['email']) ? $results->records[0]['email'][0] : $results->records[0]['email'];
$args['user_name'] = $user_name;
if (!$args['user_email'] && strpos($user_email, '@')) {
$args['user_email'] = rcube_utils::idn_to_ascii($user_email);
}
}
}
return $args;
}
示例13: mailto_callback
/**
* Callback function used to build mailto: links around e-mail strings
*
* This also adds an onclick-handler to open the Rouncube compose message screen on such links
*
* @param array Matches result from preg_replace_callback
* @return int Index of saved string value
* @see rcube_string_replacer::mailto_callback()
*/
public function mailto_callback($matches)
{
$href = $matches[1];
$suffix = $this->parse_url_brackets($href);
$email = $href;
if (strpos($email, '?')) {
list($email, ) = explode('?', $email);
}
// skip invalid emails
if (!rcube_utils::check_email($email, false)) {
return $matches[1];
}
$i = $this->add(html::a(array('href' => 'mailto:' . $href, 'onclick' => "return " . rcmail_output::JS_OBJECT_NAME . ".command('compose','" . rcube::JQ($href) . "',this)"), rcube::Q($href)) . $suffix);
return $i >= 0 ? $this->get_replacement($i) : '';
}
示例14: request_action
function request_action()
{
$this->add_texts('localization');
$uids = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST);
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
$rcmail = rcmail::get_instance();
$storage = $rcmail->get_storage();
$storage->unset_flag($uids, 'NONJUNK');
$storage->set_flag($uids, 'JUNK');
if (($junk_mbox = $rcmail->config->get('junk_mbox')) && $mbox != $junk_mbox) {
$rcmail->output->command('move_messages', $junk_mbox);
}
$rcmail->output->command('display_message', $this->gettext('reportedasjunk'), 'confirmation');
$rcmail->output->send();
}
示例15: user2email
/**
* User > Email
*/
function user2email($p)
{
$r = $this->findinvirtual('/\\s' . preg_quote($p['user'], '/') . '\\s*$/');
$result = array();
for ($i = 0; $i < count($r); $i++) {
$arr = preg_split('/\\s+/', $r[$i]);
if (count($arr) > 0 && strpos($arr[0], '@')) {
$result[] = rcube_utils::idn_to_ascii(trim(str_replace('\\@', '@', $arr[0])));
if ($p['first']) {
$p['email'] = $result[0];
break;
}
}
}
$p['email'] = empty($result) ? NULL : $result;
return $p;
}