예제 #1
0
 /**
  * Deletes minutes and also all minutes items belonging to this minutes.
  *
  * REQUIRES request parameters:
  * <pre>
  *  - integer <b>id</b> id of the minute to delete.
  * </pre>
  *
  * The return is a string in JSON format with:
  * <pre>
  *  - type    => 'success' or 'error'.
  *  - message => Success or error message.
  *  - id      => id of the deleted item.
  * </pre>
  *
  * @throws Zend_Controller_Action_Exception On missing or wrong id, or on error in the action delete.
  *
  * @return void
  */
 public function jsonDeleteAction()
 {
     $id = (int) $this->getRequest()->getParam('id');
     if (empty($id)) {
         throw new Zend_Controller_Action_Exception(self::ID_REQUIRED_TEXT, 400);
     } else {
         $minutes = $this->getModelObject()->find($id);
         if (empty($minutes->id)) {
             throw new Zend_Controller_Action_Exception(self::NOT_FOUND, 404);
         }
     }
     $minutesItems = $minutes->items->fetchAll();
     $success = true;
     if ($minutes instanceof Phprojekt_ActiveRecord_Abstract) {
         foreach ($minutesItems as $item) {
             $item->setParent($id);
             $success = $success && false !== Default_Helpers_Delete::delete($item);
         }
         $success = $success && false !== Default_Helpers_Delete::delete($minutes);
         if ($success === false) {
             $message = Phprojekt::getInstance()->translate(self::DELETE_FALSE_TEXT);
             $type = 'error';
         } else {
             $message = Phprojekt::getInstance()->translate(self::DELETE_TRUE_TEXT);
             $type = 'success';
         }
         $return = array('type' => $type, 'message' => $message, 'id' => $id);
         Phprojekt_Converter_Json::echoConvert($return);
     } else {
         throw new Zend_Controller_Action_Exception(self::NOT_FOUND, 404);
     }
 }
예제 #2
0
 /**
  * Deletes a certain item.
  *
  * REQUIRES request parameters:
  * <pre>
  *  - integer <b>id</b>        The id of the item.
  *  - integer <b>minutesId</b> The id of the minutes.
  * </pre>
  *
  * The return is a string in JSON format with:
  * <pre>
  *  - type    => 'success' or 'error'.
  *  - message => Success or error message.
  *  - code    => 0.
  *  - id      => id of the deleted item.
  * </pre>
  *
  * @throws Phprojekt_PublishedException On missing or wrong id, or on error in the action delete.
  *
  * @return void
  */
 public function jsonDeleteAction()
 {
     $minutesId = (int) $this->getRequest()->getParam('minutesId');
     $id = (int) $this->getRequest()->getParam('id');
     $minutes = Phprojekt_Loader::getModel('Minutes', 'Minutes');
     $minutes->find($minutesId);
     if (empty($minutesId)) {
         throw new Phprojekt_PublishedException(self::NOT_FOUND);
     } elseif (4 == $minutes->itemStatus) {
         throw new Phprojekt_PublishedException(self::MINUTES_READ_ONLY);
     }
     if (empty($id)) {
         throw new Phprojekt_PublishedException(self::ID_REQUIRED_TEXT);
     }
     $model = Phprojekt_Loader::getModel('Minutes_SubModules_MinutesItem', 'MinutesItem')->init($minutesId)->find($id);
     if ($model instanceof Phprojekt_Model_Interface) {
         $tmp = Default_Helpers_Delete::delete($model);
         if ($tmp === false) {
             $message = Phprojekt::getInstance()->translate(self::DELETE_FALSE_TEXT);
         } else {
             $message = Phprojekt::getInstance()->translate(self::DELETE_TRUE_TEXT);
         }
         $return = array('type' => 'success', 'message' => $message, 'code' => 0, 'id' => $id);
         Phprojekt_Converter_Json::echoConvert($return);
     } else {
         throw new Phprojekt_PublishedException(self::NOT_FOUND);
     }
 }
예제 #3
0
 /**
  * Deletes a module.
  *
  * Deletes the module entries, the module itself,
  * the databasemanager entry and the table itself.
  *
  * REQUIRES request parameters:
  * <pre>
  *  - integer <b>id</b> id of the item to delete.
  * </pre>
  *
  * The return is a string in JSON format with:
  * <pre>
  *  - type    => 'success'.
  *  - message => Success message.
  *  - id      => id of the deleted item.
  * </pre>
  *
  * @throws Zend_Controller_Action_Exception On missing or wrong id, or on error in the action delete.
  *
  * @return void
  */
 public function jsonDeleteAction()
 {
     $id = (int) $this->getRequest()->getParam('id');
     if (empty($id)) {
         throw new Zend_Controller_Action_Exception(self::ID_REQUIRED_TEXT, 400);
     }
     $model = $this->getModelObject()->find($id);
     if ($model instanceof Phprojekt_ActiveRecord_Abstract) {
         if (is_dir(PHPR_CORE_PATH . $model->name)) {
             throw new Zend_Controller_Action_Exception(self::CAN_NOT_DELETE_SYSTEM_MODULE, 422);
         }
         $databaseModel = Phprojekt_Loader::getModel($model->name, $model->name);
         if ($databaseModel instanceof Phprojekt_Item_Abstract) {
             $databaseManager = new Phprojekt_DatabaseManager($databaseModel);
             if (Default_Helpers_Delete::delete($model)) {
                 $return = $databaseManager->deleteModule();
             } else {
                 $return = false;
             }
         } else {
             $return = Default_Helpers_Delete::delete($model);
         }
         if ($return === false) {
             $message = Phprojekt::getInstance()->translate('The module can not be deleted');
             $type = 'error';
         } else {
             Phprojekt::removeControllersFolders();
             $message = Phprojekt::getInstance()->translate('The module was deleted correctly');
             $type = 'success';
         }
         $return = array('type' => $type, 'message' => $message, 'id' => $id);
         Phprojekt_Converter_Json::echoConvert($return);
     } else {
         throw new Zend_Controller_Action_Exception(self::NOT_FOUND, 404);
     }
 }
예제 #4
0
 /**
  * Update only one event
  *
  * @param array   $request              Array with the POST data.
  * @param integer $id                   Id of the current event.
  * @param array   $eventDates           Array with the dates of the recurring.
  * @param integer $daysDuration         How many days are between the start and end dates.
  * @param array   $participantsList     Array with the users involved in the event.
  * @param boolean $multipleParticipants Action for multiple participants or just the logged one.
  *
  * @return void
  */
 private function _updateSingleEvent($request, $id, $eventDates, $daysDuration, $participantsList, $multipleParticipants)
 {
     $this->startDateNotif = $request['startDate'];
     $this->endDateNotif = $request['endDate'];
     $this->notifParticipants = $participantsList;
     $this->find($id);
     $oneDate = $eventDates[0];
     $this->_saveEvent($request, $this, $oneDate, $daysDuration, $this->participantId, $this->parentId);
     // Edit the rest of participants?
     if ($this->_isOwner($this) && $multipleParticipants) {
         // If notification email was requested, then send it just once
         $request['sendNotification'] = 0;
         $rootEventId = $this->getRootEventId($this);
         $where = sprintf('(parent_id = %d OR id = %d) AND DATE(start_datetime) = %s', (int) $rootEventId, (int) $rootEventId, $this->getAdapter()->quote(date("Y-m-d", $oneDate)));
         $currentParticipants = array();
         $records = $this->fetchAll($where);
         foreach ($records as $record) {
             $currentParticipants[$record->participantId] = $record->participantId;
             $currentParticipantId = $record->participantId;
             $found = false;
             foreach ($participantsList as $participantId) {
                 if ($participantId == $currentParticipantId) {
                     $found = true;
                     if ($participantId != $this->ownerId) {
                         // Update basic data
                         $this->_saveEvent($request, $record, $oneDate, $daysDuration, $participantId, $this->id);
                         break;
                     }
                 }
             }
             if (!$found) {
                 // Delete removed participant
                 $removeModel = clone $this;
                 $rootEventId = $this->getRootEventId($this);
                 $where = sprintf('(parent_id = %d OR id = %d) AND participant_id = %d ' . 'AND DATE(start_datetime) = %s', (int) $rootEventId, (int) $rootEventId, (int) $currentParticipantId, $this->getAdapter()->quote(date("Y-m-d", $oneDate)));
                 $records = $removeModel->fetchAll($where);
                 foreach ($records as $record) {
                     Default_Helpers_Delete::delete($record);
                 }
             }
         }
         // Add the new entry for a new participant
         foreach ($participantsList as $participantId) {
             $newEntry = true;
             foreach ($currentParticipants as $currentParticipantId) {
                 if ($currentParticipantId == $participantId) {
                     $newEntry = false;
                     break;
                 }
             }
             if ($newEntry) {
                 $newModel = clone $this;
                 $this->_saveEvent($request, $newModel, $oneDate, $daysDuration, $participantId, $this->getRootEventId($this));
             }
         }
     }
 }
예제 #5
0
 /**
  * Deletes many items together.
  *
  * OPTIONAL request parameters:
  * <pre>
  *  - string <b>ids</b> Comma separated ids of the item to delete.
  * </pre>
  *
  * If there is an error, the delete will return a Phprojekt_PublishedException,
  * if not, it returns a string in JSON format with:
  * <pre>
  *  - type    => 'success'.
  *  - message => Success message.
  *  - code    => 0.
  *  - id      => Comma separated ids of the items.
  * </pre>
  *
  * @throws Phprojekt_PublishedException On error in the action delete.
  *
  * @return void
  */
 public function jsonDeleteMultipleAction()
 {
     $ids = $this->getRequest()->getParam('ids');
     if (!empty($ids)) {
         $message = Phprojekt::getInstance()->translate(self::DELETE_MULTIPLE_TRUE_TEXT);
         $showId = array();
         $model = $this->getModelObject();
         $idsArray = explode(",", $ids);
         if ($model instanceof Phprojekt_ActiveRecord_Abstract) {
             foreach ($idsArray as $id) {
                 $model->find((int) $id);
                 Default_Helpers_Delete::delete($model);
                 $showId[] = $id;
             }
         }
         $return = array('type' => 'success', 'message' => $message, 'code' => 0, 'id' => implode(',', $showId));
         Phprojekt_Converter_Json::echoConvert($return);
     }
 }
예제 #6
0
 /**
  * Deletes a certain item.
  *
  * REQUIRES request parameters:
  * <pre>
  *  - integer <b>id</b>        The id of the item.
  *  - integer <b>minutesId</b> The id of the minutes.
  * </pre>
  *
  * The return is a string in JSON format with:
  * <pre>
  *  - type    => 'success' or 'error'.
  *  - message => Success or error message.
  *  - id      => id of the deleted item.
  * </pre>
  *
  * @throws Zend_Controller_Action_Exception On missing or wrong id, or on error in the action delete.
  *
  * @return void
  */
 public function jsonDeleteAction()
 {
     $id = (int) $this->getRequest()->getParam('id');
     $model = $this->getModelObject();
     if (empty($model->getParent()->id)) {
         throw new Zend_Controller_Action_Exception(self::NOT_FOUND, 404);
     } elseif (4 == $model->getParent()->itemStatus) {
         throw new Zend_Controller_Action_Exception(self::MINUTES_READ_ONLY, 403);
     }
     if (empty($id)) {
         throw new Zend_Controller_Action_Exception(self::ID_REQUIRED_TEXT, 400);
     }
     $model->find($id);
     if ($model instanceof Phprojekt_ActiveRecord_Abstract && !empty($model->id)) {
         $tmp = Default_Helpers_Delete::delete($model);
         if ($tmp === false) {
             $message = Phprojekt::getInstance()->translate(self::DELETE_FALSE_TEXT);
             $type = 'error';
         } else {
             $message = Phprojekt::getInstance()->translate(self::DELETE_TRUE_TEXT);
             $type = 'success';
         }
         $return = array('type' => $type, 'message' => $message, 'id' => $id);
         Phprojekt_Converter_Json::echoConvert($return);
     } else {
         throw new Zend_Controller_Action_Exception(self::NOT_FOUND, 404);
     }
 }
예제 #7
0
 /**
  * Deletes a module.
  *
  * Deletes the module entries, the module itself,
  * the databasemanager entry and the table itself.
  *
  * REQUIRES request parameters:
  * <pre>
  *  - integer <b>id</b> id of the item to delete.
  * </pre>
  *
  * The return is a string in JSON format with:
  * <pre>
  *  - type    => 'success'.
  *  - message => Success message.
  *  - code    => 0.
  *  - id      => id of the deleted item.
  * </pre>
  *
  * @throws Phprojekt_PublishedException On missing or wrong id, or on error in the action delete.
  *
  * @return void
  */
 public function jsonDeleteAction()
 {
     $id = (int) $this->getRequest()->getParam('id');
     if (empty($id)) {
         throw new Phprojekt_PublishedException(self::ID_REQUIRED_TEXT);
     }
     $model = $this->getModelObject()->find($id);
     if ($model instanceof Phprojekt_Model_Interface) {
         $databaseModel = Phprojekt_Loader::getModel($model->name, $model->name);
         $databaseManager = new Phprojekt_DatabaseManager($databaseModel);
         if (Default_Helpers_Delete::delete($model) === false || $databaseManager->deleteModule() === false) {
             $message = Phprojekt::getInstance()->translate('The module can not be deleted');
         } else {
             $message = Phprojekt::getInstance()->translate('The module was deleted correctly');
         }
         $return = array('type' => 'success', 'message' => $message, 'code' => 0, 'id' => $id);
         Phprojekt_Converter_Json::echoConvert($return);
     } else {
         throw new Phprojekt_PublishedException(self::NOT_FOUND);
     }
 }
예제 #8
0
 /**
  * Deletes minutes and also all minutes items belonging to this minutes.
  *
  * REQUIRES request parameters:
  * <pre>
  *  - integer <b>id</b> id of the minute to delete.
  * </pre>
  *
  * The return is a string in JSON format with:
  * <pre>
  *  - type    => 'success' or 'error'.
  *  - message => Success or error message.
  *  - code    => 0.
  *  - id      => id of the deleted item.
  * </pre>
  *
  * @throws Phprojekt_PublishedException On missing or wrong id, or on error in the action delete.
  *
  * @return void
  */
 public function jsonDeleteAction()
 {
     $id = (int) $this->getRequest()->getParam('id');
     if (empty($id)) {
         throw new Phprojekt_PublishedException(self::ID_REQUIRED_TEXT);
     }
     $minutes = $this->getModelObject()->find($id);
     $minutesItems = Phprojekt_Loader::getModel('Minutes_SubModules_MinutesItem', 'MinutesItem')->init($id)->fetchAll();
     $success = true;
     if ($minutes instanceof Phprojekt_Model_Interface) {
         foreach ($minutesItems as $item) {
             $success = $success && false !== Default_Helpers_Delete::delete($item);
         }
         $success = $success && false !== Default_Helpers_Delete::delete($minutes);
         if ($success === false) {
             $message = Phprojekt::getInstance()->translate(self::DELETE_FALSE_TEXT);
         } else {
             $message = Phprojekt::getInstance()->translate(self::DELETE_TRUE_TEXT);
         }
         $return = array('type' => 'success', 'message' => $message, 'code' => 0, 'id' => $id);
         Phprojekt_Converter_Json::echoConvert($return);
     } else {
         throw new Phprojekt_PublishedException(self::NOT_FOUND);
     }
 }