/** * Save some fields for many items. * Only edit existing items. * * OPTIONAL request parameters: * <pre> * - array <b>data</b> Array with itemId and field as index, and the value. * ($data[2]['title'] = 'new tittle') * </pre> * * The return is a string in JSON format with: * <pre> * - type => 'success' or 'error'. * - message => Success or error message. * - id => Comma separated ids of the items. * </pre> * * @return void */ public function jsonSaveMultipleAction() { $data = (array) $this->getRequest()->getParam('data'); $showId = array(); $model = new Calendar2_Models_Calendar2(); $success = true; $this->setCurrentProjectId(); $changedOccurrences = array(); foreach ($data as $id => $occurrences) { foreach ($occurrences as $recurrenceId => $fields) { if ($recurrenceId == 'undefined') { throw new Zend_Controller_Action_Exception('\'undefined\' given as recurrence id!', 400); } $model->findWithRecurrenceId($id, $recurrenceId); foreach ($fields as $key => $value) { $model->{$key} = $value; } $model->saveSingleEvent(); $model->getNotification()->saveFrontendMessage(); $model->getNotification()->send(Phprojekt_Notification::TRANSPORT_MAIL_TEXT); $showId[] = $id; $changedOccurrences[$id] = $model->occurrence; } } if ($success) { $message = Phprojekt::getInstance()->translate(self::EDIT_MULTIPLE_TRUE_TEXT); $resultType = 'success'; } else { $resultType = 'error'; } $return = array('type' => $resultType, 'message' => $message, 'id' => implode(',', $showId), 'changedOccurrences' => $changedOccurrences); Phprojekt_Converter_Json::echoConvert($return); }