/**
  * @group internals
  * @author Chris I Powell (chris.i.powell@gmail.com)
  * @requires json_encode, dbConnection, configManager, EcProject
  * 
  */
 protected function setup()
 {
     global $db, $cfg;
     $cfg = new ConfigManager('../../ec/epicollect.ini');
     $db = new dbConnection();
     $this->projects = EcProject::getPublicProjects();
 }
 public function test_list()
 {
     $projects = EcProject::getPublicProjects();
     $this->assertInternalType('array', $projects);
     for ($i = 0; $i < count($projects); $i++) {
         $this->assertInternalType('array', $projects[$i]);
         $this->assertTrue(array_key_exists('name', $projects[$i]));
         $this->assertInternalType('string', $projects[$i]['name']);
         $this->assertTrue(array_key_exists('ttl', $projects[$i]));
         $this->assertTrue(array_key_exists('ttl24', $projects[$i]));
         $this->assertTrue(array_key_exists('listed', $projects[$i]));
         $this->assertEquals($projects[$i]['listed'], 'public');
         //$this->assertInternalType('int', $projects[0]['ttl']);
         //$this->assertInternalType('int', $projects[0]['ttl24']);
     }
 }
Exemple #3
0
function projectList()
{
    /**
     * Produce a list of all the projects on this server that are
     * 	- publically listed
     *  - if a user is logged in, owned, curated or managed by the user
     */
    global $auth;
    $qry = getValIfExists($_GET, "q");
    $lmt = getValIfExists($_GET, "limit", false);
    $prjs = EcProject::getPublicProjects($qry, $lmt);
    $usr_prjs = array();
    if ($auth->isLoggedIn()) {
        $usr_prjs = EcProject::getUserProjects($auth->getEcUserId(), true);
        $up_l = count($usr_prjs);
        for ($p = 0; $p < $up_l; $p++) {
            if ($usr_prjs[$p]["listed"] === 0) {
                array_push($prjs, $usr_prjs[$p]);
            }
        }
    }
    echo json_encode($prjs);
}