コード例 #1
0
ファイル: checkmail.php プロジェクト: Rayne/phproject
         $comment = new \Model\Issue\Comment();
         $comment->user_id = $author;
         $comment->issue_id = $issue->id;
         $comment->text = html_entity_decode(strip_tags($message));
         $comment->created_date = date("Y-m-d H:i:s");
         $comment->save();
         $notification = \Helper\Notification::instance();
         $notification->issue_comment($issue->id, $comment->id);
     }
 } else {
     if (!empty($header->subject)) {
         $subject = trim(preg_replace("/^((Re|Fwd?):\\s)*/i", "", $header->subject));
         $issue->load(array('name=? AND (deleted_date IS NULL OR deleted_date = "0000-00-00 00:00:00") AND (closed_date IS NULL OR closed_date = "0000-00-00 00:00:00")', $subject));
     }
     if (!empty($issue->id)) {
         $comment = new \Model\Issue\Comment();
         $comment->user_id = $author;
         $comment->issue_id = $issue->id;
         $comment->text = html_entity_decode(strip_tags($message));
         $comment->created_date = date("Y-m-d H:i:s");
         $comment->save();
         $notification = \Helper\Notification::instance();
         $notification->issue_comment($issue->id, $comment->id);
     } else {
         $issue->name = $header->subject;
         $issue->description = html_entity_decode(strip_tags($message));
         $issue->author_id = $author;
         $issue->owner_id = $owner;
         $issue->type_id = 1;
         $issue->save();
         $log->write('Saved issue ' . $issue->id);
コード例 #2
0
ファイル: taskboard.php プロジェクト: nikkiczx/phproject
 /**
  * Update an existing task
  */
 public function edit($f3, $params)
 {
     $post = $f3->get("POST");
     $issue = new \Model\Issue();
     $issue->load($post["taskId"]);
     if (!empty($post["receiver"])) {
         if ($post["receiver"]["story"]) {
             $issue->parent_id = $post["receiver"]["story"];
         }
         $issue->status = $post["receiver"]["status"];
         $status = new \Model\Issue\Status();
         $status->load($issue->status);
         if ($status->closed) {
             if (!$issue->closed_date) {
                 $issue->closed_date = $this->now();
             }
         } else {
             $issue->closed_date = null;
         }
     } else {
         $issue->name = $post["title"];
         $issue->description = $post["description"];
         $issue->owner_id = $post["assigned"];
         $issue->hours_remaining = $post["hours"];
         $issue->hours_spent += $post["hours_spent"];
         if (!empty($post["hours_spent"]) && !empty($post["burndown"])) {
             $issue->hours_remaining -= $post["hours_spent"];
         }
         if ($issue->hours_remaining < 0) {
             $issue->hours_remaining = 0;
         }
         if (!empty($post["dueDate"])) {
             $issue->due_date = date("Y-m-d", strtotime($post["dueDate"]));
         } else {
             $issue->due_date = null;
         }
         if (!empty($post["repeat_cycle"])) {
             $issue->repeat_cycle = $post["repeat_cycle"];
         }
         $issue->priority = $post["priority"];
         if (!empty($post["storyId"])) {
             $issue->parent_id = $post["storyId"];
         }
         $issue->title = $post["title"];
     }
     if (!empty($post["comment"])) {
         $comment = new \Model\Issue\Comment();
         $comment->user_id = $this->_userId;
         $comment->issue_id = $issue->id;
         if (!empty($post["hours_spent"])) {
             $comment->text = trim($post["comment"]) . sprintf(" (%s %s spent)", $post["hours_spent"], $post["hours_spent"] == 1 ? "hour" : "hours");
         } else {
             $comment->text = $post["comment"];
         }
         $comment->created_date = $this->now();
         $comment->save();
         $issue->update_comment = $comment->id;
     }
     $issue->save();
     $this->_printJson($issue->cast() + array("taskId" => $issue->id));
 }
コード例 #3
0
ファイル: issues.php プロジェクト: Rayne/phproject
 /**
  * POST /issues/upload
  * Upload a file
  *
  * @param \Base $f3
  * @param array $params
  * @throws \Exception
  */
 public function upload($f3, $params)
 {
     $user_id = $this->_userId;
     $issue = new \Model\Issue();
     $issue->load(array("id=? AND deleted_date IS NULL", $f3->get("POST.issue_id")));
     if (!$issue->id) {
         $f3->error(404);
         return;
     }
     $web = \Web::instance();
     $f3->set("UPLOADS", "uploads/" . date("Y") . "/" . date("m") . "/");
     if (!is_dir($f3->get("UPLOADS"))) {
         mkdir($f3->get("UPLOADS"), 0777, true);
     }
     $overwrite = false;
     // set to true to overwrite an existing file; Default: false
     $slug = true;
     // rename file to filesystem-friendly version
     // Make a good name
     $orig_name = preg_replace("/[^A-Z0-9._-]/i", "_", $_FILES['attachment']['name']);
     $_FILES['attachment']['name'] = time() . "_" . $orig_name;
     $i = 0;
     $parts = pathinfo($_FILES['attachment']['name']);
     while (file_exists($f3->get("UPLOADS") . $_FILES['attachment']['name'])) {
         $i++;
         $_FILES['attachment']['name'] = $parts["filename"] . "-" . $i . "." . $parts["extension"];
     }
     $web->receive(function ($file) use($f3, $orig_name, $user_id, $issue) {
         if ($file['size'] > $f3->get("files.maxsize")) {
             return false;
         }
         $newfile = new \Model\Issue\File();
         $newfile->issue_id = $issue->id;
         $newfile->user_id = $user_id;
         $newfile->filename = $orig_name;
         $newfile->disk_filename = $file['name'];
         $newfile->disk_directory = $f3->get("UPLOADS");
         $newfile->filesize = $file['size'];
         $newfile->content_type = $file['type'];
         $newfile->digest = md5_file($file['tmp_name']);
         $newfile->created_date = date("Y-m-d H:i:s");
         $newfile->save();
         $f3->set('file_id', $newfile->id);
         return true;
         // moves file from php tmp dir to upload dir
     }, $overwrite, $slug);
     if ($f3->get("POST.text")) {
         $comment = new \Model\Issue\Comment();
         $comment->user_id = $this->_userId;
         $comment->issue_id = $issue->id;
         $comment->text = $f3->get("POST.text");
         $comment->created_date = $this->now();
         $comment->file_id = $f3->get('file_id');
         $comment->save();
         if (!!$f3->get("POST.notify")) {
             $notification = \Helper\Notification::instance();
             $notification->issue_comment($issue->id, $comment->id);
         }
     } elseif ($newfile->id && !!$f3->get("POST.notify")) {
         $notification = \Helper\Notification::instance();
         $notification->issue_file($issue->id, $f3->get("file_id"));
     }
     $f3->reroute("/issues/" . $issue->id);
 }