Exemplo n.º 1
0
/**
 * Returns project root path. The root is where composer.json is defined
 */
function findProject($filename)
{
    $filename = realpath($filename);
    if ($filename == '/') {
        return null;
    }
    if (file_exists(dirname($filename) . '/composer.json')) {
        return dirname($filename);
    }
    return findProject(dirname($filename));
}
Exemplo n.º 2
0
        showMessage(t('No Tasks were specified'), "inbox.php", 'error');
    }
}
$tasks = $PARAM['task'];
$project_for_all_tasks = i($PARAM, 'project');
$all_tasks = explode("\n", $tasks);
$default_project = $sql->getOne("SELECT default_project FROM {$config['db_prefix']}User WHERE id='{$_SESSION['user']}'");
foreach ($all_tasks as $task) {
    if (!trim($task)) {
        continue;
    }
    //Empty line
    if ($project_for_all_tasks) {
        $project_id = $project_for_all_tasks;
    } else {
        $project_id = findProject($task);
    }
    // Still no project - auto find did not get anythng.
    if (!$project_id) {
        $project_id = $default_project;
    }
    //If no project was found, give it the default project 'Misc'
    if ($task_id = $Task->create($task, $project_id)) {
        $task_count++;
        $added_tasks[] = array('task' => $task, 'task_id' => $task_id, 'project_id' => $project_id);
    }
}
$QUERY['success'] = t('%d Task(s) created', $task_count);
//This is the output for the shell
if ($layout == 'cli') {
    print t('Added Tasks') . 'n-----------\\n';