/** * Unserialization. * * @param string $data Serialized data. * * @throws Exception */ public function unserialize($data) { parent::unserialize($data); $this->_init(); }
/** * Upgrade IMP 4 style virtual folders. */ protected function _upgradeVirtualFolders() { global $prefs; $use_vinbox = $prefs->getValue('use_vinbox'); $use_vtrash = $prefs->getValue('use_vtrash'); $vfolders = $prefs->getValue('vfolder'); if (!empty($vfolders)) { $vfolders = @unserialize($vfolders); } if (empty($vfolders) || !is_array($vfolders)) { return; } if ($prefs->isDefault('vfolder') || is_object(reset($vfolders))) { foreach ($vfolders as $val) { if (!is_null($use_vinbox) && $val instanceof IMP_Search_Vfolder_Vinbox) { $val->enabled = (bool) $use_vinbox; } elseif (!is_null($use_vtrash) && $val instanceof IMP_Search_Vfolder_Vtrash) { $val->enabled = (bool) $use_vtrash; if ($use_vtrash) { $prefs->setValue('trash_folder', strval($val)); } } } $prefs->setValue('vfolder', serialize($vfolders)); return; } $new_vfolders = array(); if ($use_vinbox) { $new_vfolders[] = new IMP_Search_Vfolder_Vinbox(); } if ($use_vtrash) { $vtrash = $new_vfolders[] = new IMP_Search_Vfolder_Vtrash(); $prefs->setValue('trash_folder', strval($vtrash)); } foreach ($vfolders as $vfolder) { $ui = $vfolder['uiinfo']; $or_match = $ui['match'] == 'or'; /* BC: Convert old (IMP < 4.2.1) style w/separate flag entry to * new style where flags are part of the fields to query. */ if (!empty($ui['flag'])) { $lookup = array(1 => 'seen', 2 => 'answered', 3 => 'flagged', 4 => 'deleted'); foreach ($ui['flag'] as $key => $val) { if ($val == 0 || $val == 1) { $ui['field'][] = ($val == 1 ? 'un' : '') . $lookup[$key]; } } } foreach ($ui['field'] as $key => $val) { $ob = new IMP_Search_Vfolder(array('enabled' => true, 'label' => $ui['vfolder_label'], 'mboxes' => $ui['folders'])); switch ($val) { case 'from': case 'cc': case 'bcc': case 'subject': $ob->add(new IMP_Search_Element_Header($ui['text'][$key], $val, !empty($ui['text_not'][$key]))); break; case 'to': $ob->add(new IMP_Search_Element_Recipient($val, !empty($ui['text_not'][$key]))); break; case 'body': case 'text': $ob->add(new IMP_Search_Element_Text($ui['text'][$key], $val == 'body', !empty($ui['text_not'][$key]))); break; case 'date_on': case 'date_until': case 'date_since': $d = new DateTime($ui['date'][$key]['year'] . '-' . $ui['date'][$key]['month'] . '-' . $ui['date'][$key]['day']); if ($val == 'date_on') { $ob->add(new IMP_Search_Element_Daterange($d, $d)); } elseif ($val == 'date_until') { $ob->add(new IMP_Search_Element_Daterange(null, $d)); } else { $ob->add(new IMP_Search_Element_Daterange($d, null)); } break; case 'size_smaller': case 'size_larger': $ob->add(new IMP_Search_Element_Size($ui['text'][$key], $val == 'size_larger')); break; case 'seen': case 'unseen': case 'answered': case 'unanswered': case 'flagged': case 'unflagged': case 'deleted': case 'undeleted': if (strpos($val, 'un') === false) { $ob->add(new IMP_Search_Element_Flag($val, true)); } else { $ob->add(new IMP_Search_Element_Flag(substr($val, 2), false)); } break; } if ($or_match) { $ob->add(new IMP_Search_Element_Or()); } } $new_vfolders[] = $ob; } $GLOBALS['injector']->getInstance('IMP_Search')->setVFolders($new_vfolders); }