示例#1
0
 public function returnView($projects, $map, $cat_name)
 {
     $id = Utils::getUserID();
     $user = User::getUser($id);
     $user_number = User::getUserNumber();
     $like_number = Projects::countLikes();
     $download_number = Projects::countDownloads();
     $projects_number = Projects::countProjects();
     $cat = Projects::getAllCategory();
     $latest_projects = Projects::getLatestProjects();
     $map = $this->getMapp($map, $cat_name);
     $premium = Projects::isPremium($id);
     $notification = User::getNotification($id);
     return View::make('home')->with('details_header', $user)->with('total_users', $user_number)->with('projects', $projects)->with("category", $cat)->with("latest_pro", $latest_projects)->with("total_likes", $like_number)->with("total_downloads", $download_number)->with("total_projects", $projects_number)->with("map", $map)->with("premium", $premium)->with("notification", $notification)->with("user_id", $id)->with("success", Input::get('success'));
 }
 public function postAccount()
 {
     $data = \Input::get('data');
     try {
         $user = \User::getUser();
         if (!$user->hasAccess('admin')) {
             throw new \Exception("Not an admin account", 1);
             return;
         }
         $user->email = $data['email'];
         if ($data['password'] !== '') {
             $user->attemptResetPassword($user->getResetPasswordCode(), $data['password']);
         }
         $user->save();
         return \Response::json(['type' => 'success', 'message' => 'Account updated']);
     } catch (\Exception $e) {
         return \Response::json(['type' => 'danger', 'message' => $e->getMessage()]);
     }
 }
 public function postUpdateAvatar()
 {
     try {
         $user = \User::getUser();
         if (!$user->hasAccess('agency')) {
             throw new \Exception("Only agency can update their account information", 1);
             return;
         }
         $image = \Agency::updateAvatar($_FILES['file']);
         return \Response::json(['type' => 'success', 'message' => 'Avatar has been updated.', 'image' => asset($image->image)]);
     } catch (\Exception $e) {
         return \Response::json(['type' => 'danger', 'message' => $e->getMessage()]);
     }
 }
 public function postUpdateAvatar()
 {
     try {
         $user = \User::getUser();
         if (!$user->hasAccess('contractor')) {
             throw new \Exception("Only contractor can update their account information", 1);
             return;
         }
         $contractor = \Contractor::getContractor();
         // TODO: change to symfony request file input
         $image = \Contractor::updateAvatar($contractor, $_FILES['file']);
         return \Response::json(['type' => 'success', 'message' => 'Avatar has been updated.', 'image' => asset($image->image)]);
     } catch (\Exception $e) {
         return \Response::json(['type' => 'danger', 'message' => $e->getMessage()]);
     }
 }
 public function postSubmitExpense()
 {
     $user = \User::getUser();
     if (!$user->hasAccess('contractor')) {
         return \Response::json(['type' => 'danger', 'message' => 'Only contractors can submit a timesheet']);
     }
     $_hash = new Hash();
     $_hash = $_hash->getHasher();
     $job = \Job::findJobById($_hash->decode(trim(\Input::get('job'))));
     if (!$job) {
         return \Response::json(['type' => 'danger', 'message' => 'Sorry, that job does not longer exists in our database.']);
     }
     $data = json_decode(\Input::get('data'), true);
     $file = isset($_FILES['file']) ? $_FILES['file'] : null;
     try {
         $timesheet = \Contractor::submitExpense($job, $data, $file);
         return \Response::json(['type' => 'success', 'message' => 'Your expense data has been submitted.']);
     } catch (\Exception $e) {
         return \Response::json(['type' => 'danger', 'message' => env('APP_DEBUG') ? $e->getMessage() : 'Error, please contact webmaster.']);
     }
 }
 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);
 }