summaryrefslogtreecommitdiff
path: root/app/Model/File.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-04-12 18:44:42 -0400
committerFrederic Guillot <fred@kanboard.net>2015-04-12 18:44:42 -0400
commit3b403a1a4b33443ee853556e40d4fe89d3399387 (patch)
tree3b3105c3a83b00fd7bda76aeda4ddde788e9d663 /app/Model/File.php
parent2a150dd3be96692a98c034233a9ae29ff6f219ac (diff)
Add screenshot support for tasks (copy/paste images directly)
Diffstat (limited to 'app/Model/File.php')
-rw-r--r--app/Model/File.php38
1 files changed, 35 insertions, 3 deletions
diff --git a/app/Model/File.php b/app/Model/File.php
index 5da5c014..fe417d48 100644
--- a/app/Model/File.php
+++ b/app/Model/File.php
@@ -248,9 +248,9 @@ class File extends Base
* Handle file upload
*
* @access public
- * @param integer $project_id Project id
- * @param integer $task_id Task id
- * @param string $form_name File form name
+ * @param integer $project_id Project id
+ * @param integer $task_id Task id
+ * @param string $form_name File form name
* @return bool
*/
public function upload($project_id, $task_id, $form_name)
@@ -288,6 +288,38 @@ class File extends Base
}
/**
+ * Handle screenshot upload
+ *
+ * @access public
+ * @param integer $project_id Project id
+ * @param integer $task_id Task id
+ * @param string $blob Base64 encoded image
+ * @return bool
+ */
+ public function uploadScreenshot($project_id, $task_id, $blob)
+ {
+ $data = base64_decode($blob);
+
+ if (empty($data)) {
+ return false;
+ }
+
+ $original_filename = e('Screenshot taken %s', dt('%B %e, %Y at %k:%M %p', time()));
+ $destination_filename = $this->generatePath($project_id, $task_id, $original_filename);
+
+ @mkdir(FILES_DIR.dirname($destination_filename), 0755, true);
+ @file_put_contents(FILES_DIR.$destination_filename, $data);
+
+ return $this->create(
+ $task_id,
+ $original_filename,
+ $destination_filename,
+ true,
+ strlen($data)
+ );
+ }
+
+ /**
* Generate a jpeg thumbnail from an image (output directly the image)
*
* @access public