Example #1
0
 function get($criteria = null)
 {
     $sql = "SELECT projects.*, clients.name AS client_name\n                FROM projects\n                LEFT JOIN clients ON projects.client_id = clients.id";
     if (is_numeric($criteria)) {
         $sql .= ' WHERE projects.id = ' . $criteria;
         $project = parent::get_one($sql);
         $this->import_parameters($project);
         return $project;
     } else {
         $sql = $this->add_criteria($sql, 'is_template = 1');
         //if the user isn't an admin, we'll need to filter for projects that this user has access to.
         $sql = $this->modify_sql_for_user_type($sql);
         $projects = Model::get($sql);
         return $projects;
         //return parent::get($sql);
     }
 }