protected function actionRename($params) { $account = \GO\Email\Model\Account::model()->findByPk($params['account_id']); $mailbox = new \GO\Email\Model\ImapMailbox($account, array("name" => $params["mailbox"])); $response['success'] = $mailbox->rename($params["name"]); if (!$response['success']) { $response['feedback'] = "Failed to rename " . $params['mailbox'] . " to " . $params['name'] . "<br /><br />" . $account->getImapConnection()->last_error(); } return $response; }
protected function actionDelete($params) { $response = array(); $account = \GO\Email\Model\Account::model()->findByPk($params['account_id']); $mailbox = new \GO\Email\Model\ImapMailbox($account, array("name" => $params["mailbox"])); if ($mailbox->isSpecial()) { throw new \Exception(\GO::t("cantDeleteSpecialFolder", "email")); } if (strpos($params['mailbox'], $account->trash) !== 0 && !empty($account->trash)) { $targetMailbox = new \GO\Email\Model\ImapMailbox($account, array("name" => $account->trash)); if ($targetMailbox->getHasChildren()) { if ($counter = $this->getCounterMailboxName($targetMailbox, $mailbox->getBaseName())) { $mailbox->rename($mailbox->getBaseName() . $counter); } } $success = $mailbox->move($targetMailbox); } else { $success = $mailbox->delete(); } $success = true; return array("success" => $success); }