/**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $invitation = Invitation::find($id);
     if (!is_null($invitation)) {
         if ($invitation->delete()) {
             return Redirect::route('admin.invitations.index')->withErrors(array('mainSuccess' => 'Поканата е успешно изтрита.'));
         } else {
             return Redirect::route('admin.invitations.index')->withErrors(array('mainError' => 'Грешка с базата данни.'));
         }
     } else {
         return Redirect::route('admin.invitations.index')->withErrors(array('mainError' => 'Поканата не е намерена.'));
     }
 }
Ejemplo n.º 2
0
 function emailChanged()
 {
     $invites = new Invitation();
     $invites->address = $this->email;
     $invites->address_type = 'email';
     if ($invites->find()) {
         while ($invites->fetch()) {
             $other = User::staticGet($invites->user_id);
             subs_subscribe_to($other, $this);
         }
     }
 }
Ejemplo n.º 3
0
 function emailChanged()
 {
     $invites = new Invitation();
     $invites->address = $this->email;
     $invites->address_type = 'email';
     if ($invites->find()) {
         while ($invites->fetch()) {
             try {
                 $other = Profile::getKV('id', $invites->user_id);
                 if (!$other instanceof Profile) {
                     // remove when getKV throws exceptions
                     continue;
                 }
                 Subscription::start($other, $this->getProfile());
             } catch (Exception $e) {
                 continue;
             }
         }
     }
 }
Ejemplo n.º 4
0
 public function bindEvent($user)
 {
     $this->loadModel('Invitation');
     $invitation = new Invitation();
     $conditions = ['Invitation.email' => $user['username']];
     $result = $invitation->find('first', compact('conditions'));
     if (!empty($result)) {
         $this->loadModel('UserEvent');
         $this->loadModel('UserEventShare');
         $userEvent = new UserEvent();
         $userEventShare = new UserEventShare();
         $event = $result['UserEvent'];
         $invitation = $result['Invitation'];
         $ueShare = array('user_id' => $user['id'], 'user_event_id' => $invitation['object_id']);
         $event['recipient_id'] = $user['id'];
         $userEvent->create();
         $userEvent->set($event);
         $userEvent->save();
         $userEventShare->create();
         $userEventShare->set($ueShare);
         $userEventShare->save();
     }
 }
Ejemplo n.º 5
0
 /**
  * @api {delete} /invitations/:id/users/:idUser/decline Decline group invitation
  * @apiName Decline group invitation
  * @apiGroup Invitation
  * @apiHeader (Header) {String} X_Authorization Authorization value.
  * @apiParam  (url Parameter) {Number} id Invitation unique ID.
  * @apiParam  (url Parameter) {Number} idUser Users unique ID.
  * 
  * @apiError 404 Not found. This will happen if the role id/user id/group id is not in our system.
  * @apiError 401 Not authorized. This will happen if the header value is not attached.
  * @apiError 409 The link expired.  
  */
 public static function declineInvite($id, $idUser)
 {
     $app = \Slim\Slim::getInstance();
     $invitation = Invitation::find($id);
     if (!$invitation) {
         $app->halt('404');
     }
     if ($invitation->receiver_id != $idUser) {
         $app->halt('401');
     }
     if ($invitation->group_jointed_at) {
         $app->halt('409', json_encode('expired'));
     }
     //self::attachUser($invitation->group_id,$invitation->receiver_id);
     $invitation->delete();
 }