public static function getAllProjects() { return DB::select('select p.title as p_name, u.name as u_name, c.name as c_name, p.downloads, p.likes, l.user_id as l_user, p.project_id from Project p inner join User u on u.user_id = p.user_id inner join Category c on c.category_id =p.category_id LEFT JOIN Likes AS l ON (l.project_id = p.project_id and l.user_id = ?) order by p.upload_date DESC LIMIT 3', array(Utils::getUserID())); }
public function getUser() { $id = $_GET['i']; $prem = Projects::isPremium($id); $project = Projects::getAllProjectsById($id, Utils::getUserID()); $t = '<div class="row"> <div class="row"> <div class="col-md-12">'; if ($prem) { $t .= ' <label><input type="checkbox" value="" disabled checked> Premium</label> '; } else { $t .= ' <label><input type="checkbox" value="" disabled> Premium</label> '; } $t .= '<div class="row"> <div class="col-md-12">'; $t .= '<table id="tab2" class="table table-bordered table-striped"> <thead> <tr> <th>Emer projekti</th> <th>Kategoria</th> <th>Like</th> <th>Download</th> <th></th> </tr> </thead> <tbody>'; for ($i = 0; $i < count($project); $i++) { $t .= '<tr> <td>' . $project[$i]->p_name . '</td> <td>' . $project[$i]->c_name . '</td> <td>' . $project[$i]->l_user . '</td> <td>' . $project[$i]->p_down . '</td> <td><button type="submit" onclick="d_p(' . $project[$i]->project_id . ')" id ="delete" class="btn btn-danger">Delete</td> </tr>'; } $t .= ' </tbody> </table> </div> </div> </div> </div>'; return $t; }
public function searchProject() { $s = $_GET["s"]; $search = Projects::search($s, Utils::getUserID()); $t = ' <ul class="users-list clearfix">'; foreach ($search as $pro) { $t .= ' <div class="col-lg-4 col-xs-6" > <!-- small box --> <div class="small-box custom-bg-projects" data-id=" $pro->project_id "> <div class="inner"> <h4>' . $pro->p_name . '</h4> <p data-id="' . str_replace(" ", "-", $pro->c_name) . '" id="v_c_project">' . $pro->c_name . '</p> <p data-id="' . str_replace(" ", "-", $pro->u_name) . '" id="u_p_project">' . $pro->u_name . '</p> </div> <div class="icon"> <i class="fa fa-files-o"></i> </div> <div class="small-box-footer"> <div class="row"> <div class="col-sm-6"> <p>' . $pro->downloads . '</p>'; $t .= ' <a href="javascript: downPro(' . $pro->project_id . ')" style="text-decoration:none;color:white"><i id="d-ppp" data-id="' . $pro->project_id . ' ", class="fa fa-download"> Download</i></a> </div>'; $t .= '<div class="col-sm-6"> <p id="l-p-i' . $pro->project_id . '">' . $pro->likes . '</p>'; if ($pro->l_user) { $t .= ' <div id="like-p" onclick="likePro(' . $pro->project_id . ')" data-id="' . $pro->project_id . '"><i id="like-p-' . $pro->project_id . '" class="fa fa-thumbs-o-up">Liked</i></div>'; } else { $t .= ' <div id="like-p" onclick="likePro(' . $pro->project_id . ')" data-id="' . $pro->project_id . '"><i id="like-p-' . $pro->project_id . '" class="fa fa-thumbs-o-up">Like</i></div>'; } $t .= '</div> </div> </div> </div> </div>'; } $t .= ' </ul>'; return $t; }
public function viewUsr($usr) { Utils::isLogged(); $id = User::getUserIDByName($usr); if ($id === -1) { Utils::isLogged(); $id_h = Utils::getUserID(); $user_h = User::getUser($id_h); $pro = Projects::getProjectsProfile($id_h); return View::make("error404")->with('details_header', $user_h)->with('projects', $pro); } $id_h = Utils::getUserID(); if ($id == $id_h) { return $this->index(); } $user = User::getUser($id); $user_h = User::getUser($id_h); return $this->getView($id, $user, $user_h); }