Ejemplo n.º 1
0
 /**
  * Do the save for the event
  * Add the full access to the owner and Read, Write and Delete access to the user involved
  *
  * @param array                     $request       Array with the POST data.
  * @param Calendar_Models_Calendar  $model         The model to save.
  * @param Phprojekt_Date_Collection $oneDate       Date object to save.
  * @param integer                   $daysDuration  How many days are between the start and end dates.
  * @param integer                   $participantId Id of the user to save the event.
  * @param integer                   $parentId      Id of the parent event.
  *
  * @return integer The parentId.
  */
 private function _saveEvent($request, $model, $oneDate, $daysDuration, $participantId, $parentId)
 {
     $request['startDatetime'] = date("Y-m-d", $oneDate) . ' ' . $request['startTime'];
     $request['endDatetime'] = date("Y-m-d", $oneDate + $daysDuration * 24 * 60 * 60) . ' ' . $request['endTime'];
     $request['participantId'] = $participantId;
     $request['parentId'] = $parentId;
     // The save is needed?
     if ($this->_needSave($model, $request)) {
         // Add 'read, write, downlaod and delete' access to the participant
         $request = Default_Helpers_Right::allowReadWriteDownloadDelete($request, $participantId);
         // Access for the owner
         if (null !== $model->ownerId) {
             $ownerId = $model->ownerId;
         } else {
             $ownerId = Phprojekt_Auth::getUserId();
         }
         // Set the status to "Pending" if there is any change and the event is for other user
         if ($participantId != $ownerId) {
             $request['status'] = 0;
         }
         $request = Default_Helpers_Right::allowAll($request, $ownerId);
         Default_Helpers_Save::save($model, $request);
     }
     if (null === $parentId) {
         $model->parentId = $model->id;
     }
     return $model->parentId;
 }