示例#1
0
 public function read()
 {
     $tasks = file('static/task.txt');
     foreach ($tasks as $str) {
         $tasks1[$str] = substr($str, 2);
     }
     \Models\Task::addTask($tasks1);
     $redirect = $_SERVER['HTTP_REFERER'];
     \Core\Route::redirectTo($redirect);
 }
示例#2
0
 public function perfomer($id)
 {
     if (isset($_POST['member'])) {
         \Models\Task::setPerfomer($id, $_POST['member']);
         $redirect = $_SERVER['HTTP_REFERER'];
         \Core\Route::redirectTo($redirect);
     } else {
         $redirect = $_SERVER['HTTP_REFERER'];
         \Core\Route::redirectTo($redirect);
     }
 }
示例#3
0
 public static function uploadTask($data)
 {
     $uploaddir = 'static/';
     $extension = strrchr(basename($data['name']), ".");
     $name = 'task';
     $task_name = $name . $extension;
     $uploadfile = $uploaddir . $task_name;
     if (!move_uploaded_file($data['tmp_name'], $uploadfile)) {
         return false;
     } else {
         $tasks = file('static/task.txt');
         $tasks1 = [];
         foreach ($tasks as $str) {
             $tasks1[$str] = substr($str, 2);
         }
         \Models\Task::addTask($tasks1);
         $redirect = $_SERVER['HTTP_REFERER'];
         \Core\Route::redirectTo($redirect);
     }
 }
示例#4
0
文件: Work.php 项目: Victopia/prefw
 /**
  * @protected
  *
  * Takes care of tasks and settings.
  */
 function beforeSave(array &$errors = array())
 {
     // packUuid
     if ($this->isCreate()) {
         // note; loop until we find a unique uuid
         do {
             $this->identity(Database::fetchField("SELECT UNHEX(REPLACE(UUID(), '-', ''))"));
         } while ($this->find(array($this->primaryKey() => $this->identity())));
     } else {
         if (isset($this->uuid)) {
             $this->uuid = util::packUuid($this->uuid);
         }
     }
     parent::beforeSave($errors);
     if (!$errors) {
         if (empty($this->tasks)) {
             unset($this->tasks);
         } else {
             // Only take task identity and settings
             $this->tasks = array_reduce($this->tasks, function ($result, $task) {
                 $taskModel = new Task($task);
                 $taskModel->load($taskModel->identity());
                 if ($taskModel->identity()) {
                     $result[] = array_filter(array('name' => $taskModel->name, 'version' => $taskModel->version, 'settings' => @$task['settings']));
                 }
                 return $result;
             }, array());
             \core\Log::info('Tasks', $this->tasks);
         }
     }
     return $this;
 }