Exemplo n.º 1
0
get('/apply', function () {
    redirect();
});
get('/apply/:position', function ($position) {
    $p = p_item($position, true);
    if (isset($p)) {
        render('apply', array('head_title' => 'Apply', 'p' => $p));
    } else {
        render('err404', null, false);
    }
});
post('/apply/:position', function ($position) {
    if (!logged_in()) {
        redirect('/apply/' . $position . '&error=You must log in to apply#apply');
    }
    $p = p_item($position, true);
    if (isset($p)) {
        app_submit($p);
        redirect("/submitted?for={$position}");
    } else {
        render('err404', null, false);
    }
});
// Submitted List
// --------------------------------------------------------------------------------
get('/submitted', function () {
    render('submitted', array('head_title' => 'Submitted'));
});
// App List
// --------------------------------------------------------------------------------
get('/list', function () {
Exemplo n.º 2
0
function app_list($position, $label = null, $find_id = null, $find_email = null, $include_deleted = false)
{
    $_labels = app_labels();
    $p = p_item($position);
    if (!is_dir($p->pdir . 'apps/')) {
        mkdir($p->pdir . 'apps/');
        chmod($p->pdir . 'apps/', 0777);
    }
    $path = $p->pdir . 'apps/' . (empty($label) ? '' : $label);
    if (!is_dir($path)) {
        if (in_array($label, $_labels)) {
            mkdir($path);
            chmod($path, 0777);
        }
        return null;
    }
    $files = array();
    if (empty($label)) {
        foreach ($_labels as $label) {
            $tmp_dir = $p->pdir . 'apps/' . $label;
            if (!is_dir($tmp_dir)) {
                mkdir($tmp_dir);
                chmod($tmp_dir, 0777);
            }
        }
        $dirs = glob_dirs($path);
        foreach ($dirs as $dir) {
            if (!$include_deleted && (!isset($find_id) || !is_reviewer()) && strtolower(basename($dir)) == 'deleted') {
                continue;
            }
            $files = array_merge($files, rglob($dir, 'json'));
        }
    } else {
        $files = rglob($path, 'json');
    }
    $apps = array();
    $viewer_hash = sha1(user_email());
    $find_email = isset($find_email) ? sha1($find_email) : null;
    foreach ($files as $file) {
        $data = explode('-', remove_last(basename($file), '.json'), 4);
        if (isset($find_id) && $data[0] != $find_id) {
            continue;
        }
        $email_hash = $data[3];
        if (isset($find_email) && $email_hash != $find_email) {
            continue;
        }
        if (!isset($find_email) && $viewer_hash != $email_hash && !is_reviewer()) {
            continue;
        }
        $app = new stdClass();
        $app->id = $data[0];
        $app->title = urldecode($data[1]);
        $app->created = intval($data[2]);
        $app->createdt = human_timing(intval($data[2]));
        $app->label = basename(dirname($file));
        $app->path = $file;
        $app->bgclass = '';
        switch (strtolower($app->label)) {
            case 'pending':
                $app->bgclass = 'yellowbg';
                $app->labelc = 'yellow';
                break;
            case 'considering':
                $app->bgclass = 'bluebg';
                $app->labelc = 'blue';
                break;
            case 'accepted':
                $app->bgclass = 'greenbg';
                $app->labelc = 'green';
                break;
            case 'denied':
                $app->bgclass = 'redbg';
                $app->labelc = 'red';
                break;
            case 'deleted':
                $app->bgclass = 'blackbg';
                $app->labelc = 'black';
                break;
        }
        if (isset($find_id) && $app->id == $find_id) {
            return $app;
        }
        $apps[] = $app;
    }
    if (isset($find_id)) {
        return;
    }
    return $apps;
}