Exemplo n.º 1
0
 public function edit($id = null)
 {
     if (!$id && !$this->Session->check('Workspace.id')) {
         $this->Redirect->flash('not_in_workspace', array('controller' => 'workspaces', 'action' => 'index'));
     }
     if (!empty($this->data['Event'])) {
         $this->data['Event']['starts'] = date('Y-m-d H:i:s', strtotime($this->data['Event']['starts']));
         if (isset($this->data['Event']['ends']) && $this->data['Event']['ends'] === '') {
             $this->data['Event']['ends'] = null;
         } else {
             $this->data['Event']['ends'] = date('Y-m-d H:i:s', strtotime($this->data['Event']['ends']));
             if ($this->data['Event']['ends'] < $this->data['Event']['starts']) {
                 $this->data['Event']['ends'] = $this->data['Event']['starts'];
             }
         }
     }
     $milestones = $this->Event->Milestone->find('list', array('conditions' => array('workspace_id' => $this->Session->read('Workspace.id'))));
     $this->set(compact('milestones'));
     if ($this->Session->check('Milestone.id')) {
         $stacksConditions = array('conditions' => array('milestone_id' => $this->Session->read('Milestone.id')));
     } else {
         $stacksConditions = array('conditions' => array('workspace_id' => $this->Session->read('Workspace.id')));
     }
     $stacks = $this->Event->Stack->find('list', $stacksConditions);
     $this->set(compact('stacks'));
     parent::edit($id);
 }
Exemplo n.º 2
0
 public function edit($id = null)
 {
     if (!$id && !$this->Session->check('Workspace.id')) {
         $this->Redirect->flash('not_in_workspace', array('controller' => 'workspaces', 'action' => 'index'));
     }
     if (!empty($this->data['Stack'])) {
         if (isset($this->data['Stack']['due']) && $this->data['Stack']['due'] === '') {
             $this->data['Stack']['due'] = null;
         } else {
             $this->data['Stack']['due'] = date('Y-m-d H:i:s', strtotime($this->data['Stack']['due']));
         }
         if (!empty($this->data['Stack']['id']) && !empty($this->data['Stack']['assigned_to_id'])) {
             $this->Stack->id = $this->data['Stack']['id'];
             $oldAssignedToId = $this->Stack->field('assigned_to_id');
         }
     }
     $Subscription = ClassRegistry::init('Subscription');
     $subscribers = $Subscription->findAllByClassAndForeignId('Workspace', $this->Session->read('Workspace.id'));
     $subscribers = Set::extract('/Subscription/user_id', $subscribers);
     $assignedTos = $this->Stack->User->findList(array('conditions' => array('User.id' => $subscribers), 'fields' => array('id', 'name')));
     $this->set(compact('assignedTos'));
     $milestones = $this->Stack->Milestone->find('list', array('conditions' => array('workspace_id' => $this->Session->read('Workspace.id'))));
     $this->set(compact('milestones'));
     if (parent::edit($id, false)) {
         if (!empty($this->data['Stack']['assigned_to_id'])) {
             if (!isset($oldAssignedToId) || isset($oldAssignedToId) && $oldAssignedToId !== $this->data['Stack']['assigned_to_id']) {
                 $this->Stack->notify($this->data['Stack']['assigned_to_id'], $this->Stack->id, $this->Tools->keyToId('stack_assigned', 'NotificationType'));
             }
         }
         $this->_setLevel('stack');
         $this->Redirect->flash(array('save_ok', 'Stack'), array('controller' => 'stacks', 'action' => 'index'));
     }
 }
Exemplo n.º 3
0
 public function edit($id = null)
 {
     if (!$this->Session->check('Workspace.id')) {
         $this->Redirect->flash('not_in_workspace', array('controller' => 'workspaces', 'action' => 'index'));
     }
     if (!empty($this->data['TaskGroup'])) {
         if (!empty($this->data['TaskGroup']['id']) && !empty($this->data['TaskGroup']['assigned_to_id'])) {
             $this->TaskGroup->id = $this->data['TaskGroup']['id'];
             $oldAssignedToId = $this->TaskGroup->field('assigned_to_id');
         }
     }
     $Subscription = ClassRegistry::init('Subscription');
     $subscribers = $Subscription->findAllByClassAndForeignId('Workspace', $this->Session->read('Workspace.id'));
     $subscribers = Set::extract('/Subscription/user_id', $subscribers);
     $assignedTos = $this->TaskGroup->User->findList(array('conditions' => array('User.id' => $subscribers), 'fields' => array('id', 'name')));
     $this->set(compact('assignedTos'));
     $milestones = $this->TaskGroup->Milestone->find('list', array('conditions' => array('workspace_id' => $this->Session->read('Workspace.id'))));
     $this->set(compact('milestones'));
     $stacksConditions = array();
     if ($this->Session->check('Milestone.id')) {
         $stacksConditions = array('conditions' => array('milestone_id' => $this->Session->read('Milestone.id')));
     } else {
         $stacksConditions = array('conditions' => array('workspace_id' => $this->Session->read('Workspace.id')));
     }
     $stacks = $this->TaskGroup->Stack->find('list', $stacksConditions);
     $this->set(compact('stacks'));
     parent::edit($id, array('controller' => 'tasks', 'action' => 'index'));
 }
Exemplo n.º 4
0
 public function edit()
 {
     // redirect to index after creating a new page
     parent::edit(null, array('action' => 'index'));
     if ($this->Session->check('Milestone.id')) {
         $stacksConditions = array('conditions' => array('milestone_id' => $this->Session->read('Milestone.id')));
     } else {
         $stacksConditions = array('conditions' => array('workspace_id' => $this->Session->read('Workspace.id')));
     }
     $stacks = $this->WikiPage->Stack->find('list', $stacksConditions);
     $this->set(compact('stacks'));
 }
Exemplo n.º 5
0
 public function edit($id = null)
 {
     if (parent::edit($id, false)) {
         $this->_setLevel('workspace');
         $this->Workspace->subscribe(User::get('id'), $this->Workspace->id);
         // setup our default redirect
         $redirect = array('controller' => 'workspaces', 'action' => 'index');
         // if they are just creating the workspace, load them into it
         if (empty($this->data['Workspace']['id'])) {
             $redirect = array('controller' => 'workspaces', 'action' => 'view', $this->Workspace->id);
         }
         $this->Redirect->flash(array('save_ok', 'Workspace'), $redirect);
     }
 }
Exemplo n.º 6
0
 public function edit($id = null)
 {
     if (parent::edit($id, false, false)) {
         $Model = ClassRegistry::init($this->data['Comment']['class']);
         $item = $Model->findById($this->data['Comment']['foreign_id']);
         switch ($this->data['Comment']['class']) {
             case 'Task':
                 if ($item['Task']['assigned_to_id'] != User::get('id')) {
                     $Model->notify($item['Task']['assigned_to_id'], $this->data['Comment']['foreign_id'], $this->Tools->keyToId('commented_on', 'NotificationType'));
                 }
                 break;
         }
         $this->Redirect->flash(null, $this->referer);
     }
     foreach ($this->params['named'] as $class => $foreign_id) {
         $this->data['Comment']['class'] = ucfirst(Inflector::variable($class));
         $this->data['Comment']['foreign_id'] = $foreign_id;
     }
     $this->render('edit');
 }
Exemplo n.º 7
0
 public function edit($id = null)
 {
     if (!$id && !$this->Session->check('Workspace.id')) {
         $this->Redirect->flash('not_in_workspace', array('controller' => 'workspaces', 'action' => 'index'));
     }
     // check if we are editing the active version
     if (!isset($this->data['ActiveVersion'])) {
         $milestones = $this->Upload->Milestone->find('list', array('conditions' => array('workspace_id' => $this->Session->read('Workspace.id'))));
         $this->set(compact('milestones'));
         if ($this->Session->check('Milestone.id')) {
             $stacksConditions = array('conditions' => array('milestone_id' => $this->Session->read('Milestone.id')));
         } else {
             $stacksConditions = array('conditions' => array('workspace_id' => $this->Session->read('Workspace.id')));
         }
         $stacks = $this->Upload->Stack->find('list', $stacksConditions);
         $this->set(compact('stacks'));
         parent::edit($id);
     } else {
         $this->Upload->updateAll(array('Upload.active_version_id' => $this->data['ActiveVersion']['id']), array('Upload.id' => $this->data['ActiveVersion']['upload_id'], 'Upload.workspace_id' => $this->Session->read('Workspace.id')));
         $this->redirect(array('controller' => 'uploads', 'action' => 'view', $this->data['ActiveVersion']['upload_id']));
     }
 }
Exemplo n.º 8
0
 public function edit($id = null)
 {
     if (!$id && !$this->Session->check('Workspace.id')) {
         $this->Redirect->flash('not_in_workspace', array('controller' => 'workspaces', 'action' => 'index'));
     }
     if (!empty($this->data['Milestone'])) {
         if (isset($this->data['Milestone']['due']) && $this->data['Milestone']['due'] === '') {
             $this->data['Milestone']['due'] = null;
         } else {
             $this->data['Milestone']['due'] = date('Y-m-d H:i:s', strtotime($this->data['Milestone']['due']));
         }
     }
     if (parent::edit($id, false)) {
         $this->_setLevel('milestone');
         // setup our default redirect
         $redirect = array('controller' => 'milestones', 'action' => 'index');
         // if they are just creating the milestone, load them into it
         if (empty($this->data['Milestone']['id'])) {
             $redirect = array('controller' => 'milestones', 'action' => 'view', $this->Milestone->id);
         }
         $this->Redirect->flash(array('save_ok', 'Milestone'), $redirect);
     }
 }
 function edit($id = null)
 {
     $this->set('typenliste', $this->Flugzeugtyp->find('list'));
     AppController::edit($id);
 }
Exemplo n.º 10
0
 public function edit($id = null)
 {
     $users = $this->_userConnections();
     $users = $this->Message->User->findList(array('conditions' => array('User.id' => $users)));
     if ($id) {
         $lastChild = $this->Message->getChildren($id, array('limit' => 1, 'sort' => 'desc'));
         if (!empty($lastChild[0]['Message'])) {
             $lastChild = $lastChild[0]['Message'];
             $id = $lastChild['id'];
             $rootId = $lastChild['root_id'];
         } else {
             $lastChild = $this->Message->findById($id);
             $rootMessage = $lastChild['Message'];
             $rootId = $rootMessage['root_id'];
         }
         $subscribers = $this->Message->getSubscribers($rootId);
         $subscribers = $this->Message->User->findList(array('conditions' => array('User.id' => $subscribers)));
         foreach ($subscribers as $subscriber) {
             $key = array_search($subscriber, $users);
             if ($key) {
                 unset($users[$key]);
             }
         }
         $this->set('parent_id', $id);
         $this->set(compact('subscribers'));
     }
     $this->set(compact('users'));
     if (!empty($this->data)) {
         if (!empty($this->data['Message']['parent_id'])) {
             $lastChild = $this->Message->getChildren($this->data['Message']['parent_id'], array('limit' => 1, 'sort' => 'desc'));
             if (!empty($lastChild[0]['Message'])) {
                 $lastChild = $lastChild[0]['Message'];
                 $this->data['Message']['parent_id'] = $lastChild['id'];
                 $rootMessageId = $lastChild['root_id'];
             } else {
                 $lastChild = $this->Message->findById($this->data['Message']['parent_id']);
                 $this->data['Message']['parent_id'] = $lastChild['Message']['id'];
                 $rootMessageId = $lastChild['Message']['root_id'];
             }
         } else {
             $this->data['Recipients'][] = User::get('id');
         }
         $recipients = null;
         if (!empty($this->data['Recipients'])) {
             $recipients = $this->data['Recipients'];
             unset($this->data['Recipients']);
         }
     }
     if (parent::edit($id, true, false) && !empty($this->data)) {
         if (!empty($this->data['Message']['parent_id'])) {
             $notificationKey = 'replied_to_message';
             $redirectLocation = array('action' => 'index', 'inbox');
         } else {
             $rootMessageId = $this->Message->id;
             $notificationKey = 'received_message';
             $redirectLocation = array('action' => 'index', 'inbox');
         }
         $this->Message->subscribe($recipients, $rootMessageId);
         $subscribers = $this->Message->getSubscribers($rootMessageId);
         $this->_allow($subscribers, array('Message' => array('id' => $rootMessageId)));
         $this->Message->setUnread($subscribers, $rootMessageId);
         $this->Message->notify($subscribers, $rootMessageId, $this->Tools->keyToId($notificationKey, 'NotificationType'));
         $this->Redirect->flash(array('add_ok', Inflector::humanize(strtolower($this->modelClass))), $redirectLocation);
     }
 }
Exemplo n.º 11
0
 function edit($id = null)
 {
     if (!empty($this->data)) {
         $this->addeditPost($this->data);
     }
     $this->pageTitle = 'Update ' . __('ACTIVITY_BRAND', true);
     parent::edit($this->Activity, $id, '/suppliers/home');
     $user = $this->get_CurrentUser();
     $supplier = $this->Activity->Supplier->read(null, $user['Supplier']['id']);
     $this->set('supplier', $supplier);
     $this->set('member', $user);
     $this->set('activities', $supplier['Activities']);
 }
 function edit($id = null)
 {
     AppController::edit($id);
     $this->set('Auswahlliste', array("Nein, ist kein Ablehnungsgrund", "Ja, ist Ablehnungsgrund"));
 }
 function edit($id = null)
 {
     AppController::edit($id);
     $this->set('herstellerliste', $this->Flugzeughersteller->find('list'));
 }
 function edit($id = null)
 {
     AppController::edit($id);
     $this->set('zeitzonenliste', timezone_identifiers_list());
 }