Esempio n. 1
0
 /**
  * Batch edit todo.
  * 
  * @param  string $from example:myTodo, todoBatchEdit.
  * @param  string $type 
  * @param  string $account 
  * @param  string $status 
  * @access public
  * @return void
  */
 public function batchEdit($from = '', $type = 'today', $account = '', $status = 'all')
 {
     /* Get form data for my-todo. */
     if ($from == 'myTodo') {
         /* Initialize vars. */
         $editedTodos = array();
         $todoIDList = array();
         $columns = 7;
         $showSuhosinInfo = false;
         if ($account == '') {
             $account = $this->app->user->account;
         }
         $bugs = $this->bug->getUserBugPairs($account);
         $tasks = $this->task->getUserTaskPairs($account, $status);
         $allTodos = $this->todo->getList($type, $account, $status);
         if ($this->post->todoIDList) {
             $todoIDList = $this->post->todoIDList;
         }
         /* Initialize todos whose need to edited. */
         foreach ($allTodos as $todo) {
             if (in_array($todo->id, $todoIDList)) {
                 $editedTodos[$todo->id] = $todo;
             }
         }
         foreach ($editedTodos as $todo) {
             if ($todo->type == 'task') {
                 $todo->name = $this->dao->findById($todo->idvalue)->from(TABLE_TASK)->fetch('name');
             }
             if ($todo->type == 'bug') {
                 $todo->name = $this->dao->findById($todo->idvalue)->from(TABLE_BUG)->fetch('title');
             }
             $todo->begin = str_replace(':', '', $todo->begin);
             $todo->end = str_replace(':', '', $todo->end);
         }
         /* Judge whether the edited todos is too large. */
         $showSuhosinInfo = $this->loadModel('common')->judgeSuhosinSetting(count($editedTodos), $columns);
         /* Set the sessions. */
         $this->app->session->set('showSuhosinInfo', $showSuhosinInfo);
         /* Assign. */
         $title = $this->lang->todo->common . $this->lang->colon . $this->lang->todo->batchEdit;
         $position[] = html::a($this->createLink('my', 'todo'), $this->lang->my->todo);
         $position[] = $this->lang->todo->common;
         $position[] = $this->lang->todo->batchEdit;
         if ($showSuhosinInfo) {
             $this->view->suhosinInfo = $this->lang->suhosinInfo;
         }
         $this->view->bugs = $bugs;
         $this->view->tasks = $tasks;
         $this->view->editedTodos = $editedTodos;
         $this->view->times = date::buildTimeList($this->config->todo->times->begin, $this->config->todo->times->end, $this->config->todo->times->delta);
         $this->view->time = date::now();
         $this->view->title = $title;
         $this->view->position = $position;
         $this->display();
     } elseif ($from == 'todoBatchEdit') {
         $allChanges = $this->todo->batchUpdate();
         foreach ($allChanges as $todoID => $changes) {
             if (empty($changes)) {
                 continue;
             }
             $actionID = $this->loadModel('action')->create('todo', $todoID, 'edited');
             $this->action->logHistory($actionID, $changes);
         }
         die(js::locate($this->session->todoList, 'parent'));
     }
 }
Esempio n. 2
0
 /**
  * Batch create todo
  * 
  * @param  string $date 
  * @access public
  * @return void
  */
 public function batchCreate($date = 'today')
 {
     if ($date == 'today') {
         $date = date(DT_DATE1, time());
     }
     if (!empty($_POST)) {
         $this->todo->batchCreate();
         if (dao::isError()) {
             $this->send(array('result' => 'fail', 'message' => dao::getError()));
         }
         /* Locate the browser. */
         $date = str_replace('-', '', $this->post->date);
         if ($date == '') {
             $date = 'future';
         } else {
             if ($date == date('Ymd')) {
                 $date = 'today';
             }
         }
         $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('todo', 'calendar', "date={$date}")));
     }
     $this->view->title = $this->lang->todo->common . $this->lang->colon . $this->lang->todo->batchCreate;
     $this->view->date = (int) $date == 0 ? $date : date('Y-m-d', strtotime($date));
     $this->view->times = date::buildTimeList($this->config->todo->times->begin, $this->config->todo->times->end, $this->config->todo->times->delta);
     $this->view->time = date::now();
     $this->view->users = $this->loadModel('user')->getPairs('noclosed,nodeleted');
     $this->view->modalWidth = '85%';
     $this->display();
 }