Пример #1
0
 /**
  * An ajax call to get the current logged-in-user's profile page when logged in.
  * Loaded via ajax so the front page can be cached easily
  * Loads a login box if the user is not logged in, and a profile
  *  box if they are
  */
 public function get_profile_box()
 {
     if (UserHelper::isLoggedIn()) {
         $this->load->view('global/_profile_box');
     } else {
         $this->load->view('global/_login_form');
     }
 }
Пример #2
0
 /**
  * Rate a package
  */
 public function rate($package_name)
 {
     $this->load->model('spark');
     $this->load->model('rating');
     $spark = Spark::getInfo($package_name);
     if (!$spark) {
         show_404();
     }
     if ($this->input->post('rating') && UserHelper::isLoggedIn()) {
         $this->load->model('rating');
         $this->rating->rate(UserHelper::getId(), $spark->id, $this->input->post('rating'));
     } else {
         $this->error("You are not logged in, or your request was invalid");
     }
     $this->success(array('ratings' => $this->rating->getRatings($spark->id)));
 }
Пример #3
0
        <td>Contributor</td>
        <td>: <a href="<?php 
echo base_url();
?>
contributors/<?php 
echo $contributor->username;
?>
/profile"><?php 
echo $contributor->username;
?>
</a></td>
    </tr>
    <tr>
        <td>Email</td>
        <td>: <?php 
echo UserHelper::isLoggedIn() ? $contributor->email : "Log in to view";
?>
</td>
    </tr>
    <tr>
        <td>Author Website</td>
        <td>: <a target="_blank" href="<?php 
echo prep_url($contributor->website);
?>
"><?php 
echo $contributor->website;
?>
</a></td>
    </tr>
    <?php 
if ($contribution->website) {
Пример #4
0
 /**
  * Show the public information page for a spark
  * @param string $package_name The package being viewed
  */
 public function show($package_name)
 {
     #UtilityHelper::tryPageCache();
     $this->load->model('spark');
     $this->load->model('rating');
     $this->load->model('contributor');
     $spark = Spark::getInfo($package_name);
     if (!$spark) {
         show_404();
     }
     $contributor = $spark->getContributor();
     if ($spark->fork_id > 0) {
         $forks = Spark::getForks($spark->fork_id);
         array_unshift($forks, Spark::getById($spark->fork_id));
     } else {
         $forks = Spark::getForks($spark->id);
     }
     // Get the stats for this Spark
     $data['stats'] = $spark->getStats($spark->id);
     $this->load->helper('google_chart');
     $data['contribution'] = $spark;
     $data['contributor'] = $contributor;
     $data['versions'] = $spark->getVersions(TRUE);
     $data['versions_unverified'] = $spark->getVersions(FALSE);
     $data['is_author'] = $contributor->id == UserHelper::getId();
     $data['current_user_rating'] = FALSE;
     $data['ratings'] = $this->rating->getRatings($spark->id);
     $data['forks'] = $forks;
     if (UserHelper::isLoggedIn()) {
         $data['current_user_rating'] = $this->rating->getUserRating(UserHelper::getId(), $spark->id);
     }
     $this->load->view('packages/show', $data);
 }