Ejemplo n.º 1
0
 /**
  * Init training
  */
 private function initTraining()
 {
     // TODO: Cache?
     $this->ActivityContext = new Activity\Context(SharedLinker::getTrainingId(), SessionAccountHandler::getId());
     if ($this->ActivityContext->activity()->id() <= 0) {
         $this->ActivityContext = null;
     }
 }
Ejemplo n.º 2
0
 /**
  * Can find activity ID?
  * @return boolean
  */
 protected function canFindActivityID()
 {
     return Request::isOnSharedPage() && SharedLinker::getTrainingId() > 0;
 }
Ejemplo n.º 3
0
 /**
  * Get onclick-string for loading training
  * @param int $id ID of the training
  * @return string
  */
 public static function trainingLinkAsOnclick($id)
 {
     if (FrontendShared::$IS_SHOWN) {
         return 'onclick="Runalyze.Training.load(' . $id . ', \'' . SharedLinker::getUrlFor($id) . '\')"';
     }
     return 'onclick="Runalyze.Training.load(' . $id . ')"';
 }
Ejemplo n.º 4
0
 /**
  * Get the HFrest from user-table
  * @return int   HFrest
  */
 private static function calculateHFrest()
 {
     // TODO: Move to class::UserData - possible problem in loading order?
     if (SharedLinker::isOnSharedPage()) {
         $userdata = DB::getInstance()->query('SELECT `pulse_rest` FROM `' . PREFIX . 'user` WHERE `accountid`="' . SharedLinker::getUserId() . '" AND `pulse_rest` > 0 AND accountid = ' . SessionAccountHandler::getId() . ' ORDER BY `time` DESC LIMIT 1')->fetch();
     } else {
         $userdata = DB::getInstance()->query('SELECT `pulse_rest` FROM `' . PREFIX . 'user` WHERE `pulse_rest` > 0 AND accountid = ' . SessionAccountHandler::getId() . ' ORDER BY `time` DESC LIMIT 1')->fetch();
     }
     if ($userdata === false) {
         return 60;
     }
     return $userdata['pulse_rest'];
 }
Ejemplo n.º 5
0
 /**
  * Display shared menu
  */
 protected function displaySharedMenu()
 {
     $User = AccountHandler::getDataForId(SharedLinker::getUserId());
     $this->ToolbarLinks = array();
     $this->ToolbarLinks[] = SharedLinker::getStandardLinkTo($this->Context->activity()->id(), Icon::$ATTACH);
     $this->ToolbarLinks[] = '<a href="shared/' . $User['username'] . '/" target="_blank">' . Icon::$TABLE . '</a>';
     $this->displayHeaderMenu();
 }
Ejemplo n.º 6
0
 /**
  * Is the user on a shared page?
  * @return boolean
  */
 public static function isOnSharedPage()
 {
     return SharedLinker::isOnSharedPage();
 }
Ejemplo n.º 7
0
 /**
  * Get list to shared list
  * @returns tring
  */
 protected function getSharedListLink()
 {
     return SharedLinker::getListLinkForCurrentUser();
 }
 /**
  * Get ID of current user
  * @return int 
  */
 public static function getId()
 {
     // Dirty hack for 'global.cleanup.php'
     if (defined('GLOBAL_CLEANUP') && class_exists('GlobalCleanupAccount')) {
         return GlobalCleanupAccount::$ID;
     }
     if (SharedLinker::isOnSharedPage()) {
         return SharedLinker::getUserId();
     }
     if (!isset(self::$Account['id'])) {
         if (isset($_SESSION['accountid'])) {
             return $_SESSION['accountid'];
         }
         return null;
     }
     return self::$Account['id'];
 }
Ejemplo n.º 9
0
 /**
  * Get user ID
  * @return int
  */
 public static function getUserId()
 {
     if (self::$USER_ID <= 0) {
         if (strlen(Request::param('user')) > 0) {
             $Data = AccountHandler::getDataFor(Request::param('user'));
             self::$USER_ID = $Data['id'];
         } elseif (strlen(Request::param('url')) > 0) {
             DB::getInstance()->stopAddingAccountID();
             $Data = DB::getInstance()->query('SELECT `accountid` FROM `' . PREFIX . 'training` WHERE id="' . self::getTrainingId() . '" LIMIT 1')->fetch();
             DB::getInstance()->startAddingAccountID();
             self::$USER_ID = $Data['accountid'];
         } elseif (self::isOnMetaCourseForFacebook()) {
             $Data = true;
             self::$USER_ID = (int) Request::param('account');
         } else {
             $Data = false;
         }
         if ($Data === false) {
             self::$USER_ID = -1;
         }
     }
     return self::$USER_ID;
 }