* @var bool
*/
var $htmlencoded=false;
+ /**
+ * Controls folder list limits in SMOPT_TYPE_FLDRLIST widget.
+ * See $flag argument in sqimap_mailbox_option_list() function.
+ * @var string
+ * @since 1.5.1
+ */
+ var $folder_filter='noselect';
/**
* Constructor function
$this->save_function = $save_function;
}
+ /**
+ * Set the trailing_text for this option.
+ * @param string $folder_filter
+ * @since 1.5.1
+ */
+ function setFolderFilter($folder_filter) {
+ $this->folder_filter = $folder_filter;
+ }
+
/**
* Creates fields on option pages according to option type
*
function createWidget_FolderList() {
$selected = array(strtolower($this->value));
- /* Begin the select tag. */
- $result = "<select name=\"new_$this->name\" $this->script>\n";
+ /* set initial value */
+ $result = '';
/* Add each possible value to the select list. */
foreach ($this->possible_values as $real_value => $disp_value) {
if ( is_array($disp_value) ) {
/* For folder list, we passed in the array of boxes.. */
- $new_option = sqimap_mailbox_option_list(0, $selected, 0, $disp_value);
+ $new_option = sqimap_mailbox_option_list(0, $selected, 0, $disp_value, $this->folder_filter);
} else {
/* Start the next new option string. */
$new_option = '<option value="' . htmlspecialchars($real_value) . '"';
/* And add the new option string to our select tag. */
$result .= $new_option;
}
- /* Close the select tag and return our happy result. */
- $result .= "</select>\n";
- return ($result);
+
+
+ if (empty($result)) {
+ // string is displayed when interface can't build folder selection box
+ return _("unavailable");
+ } else {
+ /* Begin the select tag. */
+ $ret = "<select name=\"new_$this->name\" $this->script>\n";
+ $ret.= $result;
+ /* Close the select tag and return our happy result. */
+ $ret.= "</select>\n";
+ return ($ret);
+ }
}
/**
$next_option->setPostScript($optset['post_script']);
}
+ /* If provided, set the folder_filter for this option. */
+ if (isset($optset['folder_filter'])) {
+ $next_option->setFolderFilter($optset['folder_filter']);
+ }
+
/* Add this option to the option array. */
$result[$grpkey]['options'][] = $next_option;
}
'caption' => _("Base Sent Folder"),
'type' => SMOPT_TYPE_FLDRLIST,
'refresh' => SMOPT_REFRESH_FOLDERLIST,
- 'posvals' => $sent_subfolders_base_values
+ 'posvals' => $sent_subfolders_base_values,
+ 'folder_filter' => 'noinferiors'
);
/* Add our option data to the global array. */
$month = date('m');
$quarter = sent_subfolder_getQuarter($month);
- /*
- Regarding the structure we've got three main possibilities.
- One sent holder. level 0.
- Multiple year holders with messages in it. level 1.
- Multiple year folders with holders in it. level 2.
- */
-/*
- if( $imap_server_type == 'uw' ) {
- $cnd_delimiter = '';
- } else {
- $cnd_delimiter = $delimiter;
- }
-*/
+ /**
+ * Regarding the structure we've got three main possibilities.
+ * One sent holder. level 0.
+ * Multiple year holders with messages in it. level 1.
+ * Multiple year folders with holders in it. level 2.
+ */
$cnd_delimiter = $delimiter;
switch ($sent_subfolders_setting) {
$sent_subfolder = $sent_subfolders_base . $cnd_delimiter
. $year
. $delimiter . $quarter;
- $year_folder = $sent_subfolders_base
+ $year_folder = $sent_subfolders_base . $cnd_delimiter
. $year;
break;
case SMPREF_SENT_SUBFOLDERS_MONTHLY:
$sent_subfolder = $sent_subfolders_base . $cnd_delimiter
. $year
. $delimiter . $month;
- $year_folder = $sent_subfolders_base . $year;
+ $year_folder = $sent_subfolders_base. $cnd_delimiter . $year;
break;
case SMPREF_SENT_SUBFOLDERS_DISABLED:
default:
/* If this folder is NOT the current sent folder, update stuff. */
if ($sent_subfolder != $sent_folder) {
- /* First, update the sent folder. */
-
+ /**
+ * $sent_subfolder should not have \noselect flag or folder should
+ * not exist.
+ * if $level=2, $year_folder should not have \noinferiors or folder
+ * should not exist.
+ *
+ * If some condition fails - sent_subfolders is misconfigured
+ */
+
+ /* Update sent_folder setting. */
setPref($data_dir, $username, 'sent_folder', $sent_subfolder);
setPref($data_dir, $username, 'move_to_sent', SMPREF_ON);
$sent_folder = $sent_subfolder;
/* Auto-create folders, if they do not yet exist. */
if ($sent_folder != 'none') {
/* Create the imap connection. */
- $ic = sqimap_login
- ($username, $key, $imapServerAddress, $imapPort, 10);
-
- /* Auto-create the year folder, if it does not yet exist. */
- if (!sqimap_mailbox_exists($ic, $year_folder)) {
- sqimap_mailbox_create($ic, $year_folder, ($level==1)?'':'noselect');
- } else if (!sqimap_mailbox_is_subscribed($ic, $year_folder)) {
- sqimap_subscribe($ic, $year_folder);
+ $ic = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10);
+
+ if ($level==2) {
+ /* Auto-create the year folder, if it does not yet exist. */
+ if (!sqimap_mailbox_exists($ic, $year_folder)) {
+ sqimap_mailbox_create($ic, $year_folder, 'noselect');
+ } else if (!sqimap_mailbox_is_subscribed($ic, $year_folder)) {
+ sqimap_subscribe($ic, $year_folder);
+ }
}
/* Auto-create the subfolder, if it does not yet exist. */
- if (!sqimap_mailbox_exists($ic, $sent_folder)) {
- sqimap_mailbox_create($ic, $sent_folder, '');
+ if (!sqimap_mailbox_exists($ic, $sent_subfolder)) {
+ sqimap_mailbox_create($ic, $sent_subfolder, '');
} else if (!sqimap_mailbox_is_subscribed($ic, $sent_subfolder)) {
sqimap_subscribe($ic, $sent_subfolder);
}
/* Close the imap connection. */
sqimap_logout($ic);
}
+
}
}
}