Example #1
0
 public function __construct(\Request $request, \Response $response)
 {
     if ($request->param('id')) {
         $this->image = new Model_Image($request->param('id'));
         if (!$this->image->loaded()) {
             throw new HTTP_Exception_404(__('This page seems to not exist.'));
         }
     }
     parent::__construct($request, $response);
 }
Example #2
0
 public function __construct(\Request $request, \Response $response)
 {
     if ($request->param('id')) {
         $this->project = new Model_Project($request->param('id'));
         if (!$this->project->loaded()) {
             throw new HTTP_Exception_404(__('This page seems to not exists.'));
         }
         $this->test_user_authorized();
     }
     parent::__construct($request, $response);
 }
Example #3
0
 public function __construct(\Request $request, \Response $response)
 {
     $this->project = Model::factory('Project')->where("share_hash", "=", $request->param('hash'))->find();
     if (!$this->project->loaded() or $this->project->visibility->name == "privat") {
         throw new HTTP_Exception_404(__('This page seems to not exists.'));
     }
     if ($this->project->visibility->name == "secure") {
         if (!$this->visitor_authorized($request->param('hash')) and $request->action() != 'authenticate') {
             $this->redirect('/share/' . $request->param('hash') . '/project/authenticate/');
         }
     }
     parent::__construct($request, $response);
 }
Example #4
0
 function upload_notification()
 {
     $files = Request::param('files');
     $project = new Project($files[0]['project_id']);
     $this->check_authorization($project);
     File::upload_notification($project, $files);
 }
Example #5
0
 public function testPostJson()
 {
     $r = new Request(['url' => 'api/tasks/12.json', 'filter' => 'all'], ['HTTP_ACCEPT' => 'application/json;q=0.8', 'REQUEST_URI' => '/api/tasks/12.json?filter=all', 'REQUEST_METHOD' => 'POST'], ['url' => 'api/tasks/12.json', 'filter' => 'all'], ['title' => 'New Title']);
     $this->assertTrue($r instanceof Request);
     $this->assertEquals(Request::POST, $r->method());
     $this->assertEquals('api/tasks/12.json', $r->url());
     $this->assertEquals('json', $r->type());
     $this->assertEquals('all', $r->param('filter'));
     $route = $r->route();
     $this->assertTrue($route instanceof Route);
     $result = $r->response();
     $this->assertTrue($result instanceof Response);
     $this->assertEquals("New Title", $r->param('title'));
     $expected = ['filter' => 'all'];
     $result = $r->query();
     $this->assertEquals($expected, $result);
 }
Example #6
0
 /**
  * Constructor
  */
 public function __construct()
 {
     $this->NumberOfTrainings = Request::param('number-of-trainings');
     $this->EditorRequested = isset($_POST['multi-edit']);
     if (!isset($_POST['training-import'])) {
         $this->NumberOfTrainings = 0;
     }
 }
Example #7
0
 public function test_basic_get_post()
 {
     $_GET["test"] = "hello";
     $_POST["test2"] = "hello";
     $this->assertEqual(Request::get("test"), "hello");
     $this->assertEqual(Request::post("test2"), "hello");
     $this->assertEqual(Request::param("test"), "hello");
     $this->assertEqual(Request::param("test2"), "hello");
 }
Example #8
0
 public function __construct(\Request $request, \Response $response)
 {
     $this->image = new Model_Image($request->param('id'));
     if (!$this->image->loaded()) {
         $exception = new HTTP_Exception_404(__('This page seems to not exists.'));
         $response->body($exception->get_response()->body());
     }
     parent::__construct($request, $response);
 }
 /**
  * Handle request
  */
 protected function handleRequest()
 {
     if (Request::param('use-calculated-value') == 'true') {
         $oldObject = clone $this->Context->activity();
         $this->Context->activity()->set(Model\Activity\Object::ELEVATION, $this->Context->route()->elevation());
         $Updater = new Model\Activity\Updater(DB::getInstance(), $this->Context->activity(), $oldObject);
         $Updater->setAccountID(SessionAccountHandler::getId());
         $Updater->update();
     }
 }
    /**
     * Init all data
     */
    private function initData()
    {
        $this->IDs = array();
        if (strlen(Request::param('ids')) > 0) {
            $this->IDs = explode(',', Request::param('ids'));
        } else {
            $this->IDs = DB::getInstance()->query('SELECT id FROM `' . PREFIX . 'training`
				ORDER BY `id` DESC
				LIMIT ' . self::NUMBER_OF_TRAININGS_TO_DISPLAY)->fetchAll(PDO::FETCH_COLUMN, 0);
        }
    }
Example #11
0
 /**
  * Auto detect the current page
  *
  * @return int Current page
  */
 protected function _detect_current_page()
 {
     switch ($this->_config->source) {
         case 'route':
             $page = $this->_request->param($this->_config->key);
             break;
         default:
             $page = $this->_request->query($this->_config->key);
             break;
     }
     return (int) $page ?: 1;
 }
 public function __construct()
 {
     $this->server = "http://" . $_SERVER['HTTP_HOST'];
     if (Request::param('warned') || Session::get('warned')) {
         Session::set('warned', 1);
         $this->warned = true;
     }
     if (substr_count($_SERVER['HTTP_USER_AGENT'], "MSIE") > 0) {
         $this->ie = true;
     }
     $cat = new CmsCategory();
     $this->all_categories = $cat->order('name ASC')->all();
 }
 public function search()
 {
     if ($query = Request::param("cmsq")) {
         $model = new CmsContent("published");
         $fields = array("title" => '1.3', 'content' => "0.6");
         $search = $query;
         $this->query = "+" . str_replace(" ", " +", $search);
         $this->cms_content = $model->search($search, $fields)->page($this->this_page, $this->per_page);
         $this->use_view = "cms_list";
     } else {
         $this->redirect_to("/");
     }
 }
 public function content_lookup($obj)
 {
     //revert to normal
     if (($preview_id = Request::param('preview')) && is_numeric($preview_id) && ($m = new $obj->cms_content_class($preview_id)) && $m && $m->primval) {
         $obj->cms_content = $m;
     } elseif ($content = $obj->content($obj->cms_stack, $obj->cms_mapping_class, $obj->cms_live_scope, $obj->cms_language_id)) {
         $obj->cms_content = $content;
     } elseif ($content = $obj->content($obj->cms_stack, $obj->cms_mapping_class, $obj->cms_live_scope, array_shift(array_keys(CMSApplication::$languages)))) {
         $obj->cms_content = $content;
     } elseif (WaxApplication::is_public_method($obj, "method_missing")) {
         return $obj->method_missing();
     } else {
         $obj->cms_throw_missing_content = true;
     }
 }
Example #15
0
 function generate_project()
 {
     $project = new Project();
     //if we don't manually set this variable, the parameters from the $_POST array will be imported. We don't want
     //those parameters because then we would also be importing the Template id, which would effectively set this
     //new project model = this template model. We will manually set the parameters from the template that we want to
     //copy
     $project->params_imported = true;
     $project->set('client_id', Request::param('client_id'));
     $project->set('name', Request::param('name'));
     $project->set('start_date', Request::param('start_date'));
     $project->set('due_date', Request::param('due_date'));
     $project->save();
     $this->project = $project;
 }
 /**
  * Constructor
  */
 public function __construct()
 {
     $this->timerStart = 1;
     if (Request::param('y') == self::LAST_6_MONTHS) {
         $this->timerEnd = 26;
     } else {
         if (Request::param('y') == self::LAST_12_MONTHS) {
             $yearEnd = date('Y') - 1;
         } else {
             $yearEnd = (int) Request::param('y');
         }
         $this->timerEnd = date("W", mktime(0, 0, 0, 12, 28, $yearEnd));
         // http://de.php.net/manual/en/function.date.php#49457
     }
     parent::__construct();
 }
Example #17
0
 /**
  * Includes the plugin-file for displaying the tool
  */
 public function display()
 {
     $this->prepareForDisplay();
     if (Request::param('wrap') != "") {
         echo '<div id="pluginTool">';
     }
     echo '<div class="panel-heading">';
     $this->displayHeader();
     echo '</div>';
     echo '<div class="panel-content">';
     $this->displayLongDescription();
     $this->displayContent();
     echo '</div>';
     if (Request::param('wrap') != "") {
         echo '</div>';
     }
 }
Example #18
0
 function send_password()
 {
     $user_id = Request::param('id');
     if (!current_user()->is('admin')) {
         Response()->not_authorized();
     }
     if (!isset($user_id)) {
         Response('Invalid user id');
     }
     $user = new User($user_id);
     $result = $user->send_password();
     if ($user->validation_passed()) {
         Response($result);
     } else {
         Response()->error($user->errors());
     }
 }
Example #19
0
    /**
     * @test
     * @group pmc
     */
    public function testPostParams()
    {
        $body = <<<RESPONSE
Server: Make-Believe
Content-Type: text/plain

Blade
RESPONSE;
        $curl = $this->_mockCurl();
        $curl->expects($this->once())->method('init')->with('http://google.com');
        $curl->expects($this->exactly(3))->method('setopt')->withConsecutive(array($this->equalTo(CURLOPT_RETURNTRANSFER), $this->equalTo(true)), array($this->equalTo(CURLOPT_HEADER), $this->equalTo(true)), array($this->equalTo(CURLOPT_POSTFIELDS), $this->equalTo(array('big' => 'tasty', 'disc' => 'man'))));
        $curl->expects($this->once())->method('exec')->will($this->returnValue($body));
        $curl->expects($this->once())->method('errno')->will($this->returnValue(0));
        $curl->expects($this->once())->method('getinfo')->will($this->returnValue(array('header_size' => 45, 'http_code' => 200)));
        $request = new Request('POST', 'http://google.com', new \Bronto\DataObject(), $curl);
        $request->param('big', 'tasty')->param('disc', 'man');
        $response = $request->respond();
    }
Example #20
0
 /**
  * Loads configuration settings into the object
  * and (re)calculates pagination if needed.
  *
  * Allows you to update config settings after a Pagination object
  * has been constructed.
  *
  * @param   array   $config  Configuration [Optional]
  * @return  object  Pagination
  */
 public function setup(array $config = array())
 {
     if (isset($config['group'])) {
         // Recursively load requested config groups
         $config += $this->config_group($config['group']);
     }
     // Overwrite the current config settings
     $this->config = $config + $this->config;
     // Only (re)calculate pagination when needed
     if (is_null($this->current_page) or isset($config['current_page']) or isset($config['total_items']) or isset($config['items_per_page'])) {
         // Retrieve the current page number
         if (!empty($this->config['current_page']['page'])) {
             // The current page number has been set manually
             $this->current_page = (int) $this->config['current_page']['page'];
         } else {
             $query_key = $this->config['current_page']['key'];
             switch ($this->config['current_page']['source']) {
                 case 'query_string':
                     $this->current_page = !is_null($this->_request->query($query_key)) ? (int) $this->_request->query($query_key) : 1;
                     break;
                 case 'cms':
                 case 'route':
                     $this->current_page = (int) $this->_request->param($query_key, 1);
                     break;
             }
         }
         // Calculate and clean all pagination variables
         $this->total_items = (int) max(0, $this->config['total_items']);
         $this->items_per_page = (int) max(1, $this->config['items_per_page']);
         $this->total_pages = (int) ceil($this->total_items / $this->items_per_page);
         $this->current_page = (int) min(max(1, $this->current_page), max(1, $this->total_pages));
         $this->current_first_item = (int) min(($this->current_page - 1) * $this->items_per_page + 1, $this->total_items);
         $this->current_last_item = (int) min($this->current_first_item + $this->items_per_page - 1, $this->total_items);
         $this->previous_page = $this->current_page > 1 ? $this->current_page - 1 : FALSE;
         $this->next_page = $this->current_page < $this->total_pages ? $this->current_page + 1 : FALSE;
         $this->first_page = $this->current_page === 1 ? FALSE : 1;
         $this->last_page = $this->current_page >= $this->total_pages ? FALSE : $this->total_pages;
         $this->offset = (int) (($this->current_page - 1) * $this->items_per_page);
     }
     return $this;
 }
/**
 * Window: user table
 * @package Runalyze\Plugins\Panels
 */
require '../../inc/class.Frontend.php';
use Runalyze\Activity\Duration;
use Runalyze\Activity\Weight;
$Frontend = new Frontend();
$Factory = new PluginFactory();
$Plugin = $Factory->newInstance('RunalyzePluginPanel_Sportler');
$Fields = array('time' => 'date', 'weight' => '', 'sleep_duration' => ' <small>h</small>');
$FieldsPulse = array('pulse_rest' => ' <small>bpm</small>', 'pulse_max' => ' <small>bpm</small>');
$FieldsFat = array('fat' => ' &#37;', 'water' => ' &#37;', 'muscles' => ' &#37;');
$Data = array_reverse(UserData::getFullArray());
if (Request::param('reload') == 'true') {
    Ajax::setReloadFlag(Ajax::$RELOAD_ALL);
    echo Ajax::getReloadCommand();
}
?>
<div class="panel-heading">
	<div class="panel-menu"><ul><li><?php 
echo $Plugin->addLink();
?>
</li></ul></div>
	<h1><?php 
_e('Body values');
?>
</h1>
</div>
<div class="panel-content">
    /**
     * Search trainings
     */
    protected function searchTrainings()
    {
        $this->TotalNumberOfTrainings = DB::getInstance()->query('SELECT COUNT(*) FROM `' . PREFIX . 'training` AS `t` ' . $this->getWhere() . $this->getOrder() . ' LIMIT 1')->fetchColumn();
        $this->Page = (int) Request::param('page');
        if (($this->Page - 1) * $this->ResultsPerPage > $this->TotalNumberOfTrainings) {
            $this->Page--;
        }
        $this->DatasetQuery->resetJoins();
        $this->Trainings = DB::getInstance()->query('SELECT DISTINCT
				`t`.`id`,
				`t`.`time`
				' . ($this->multiEditorRequested() ? '' : ', ' . $this->DatasetQuery->queryToSelectAllKeys() . ' ' . $this->DatasetQuery->queryToSelectJoinedFields()) . '
			FROM `' . PREFIX . 'training` AS `t`
			' . $this->DatasetQuery->queryToJoinTables() . '
			' . $this->getWhere() . ' ' . $this->DatasetQuery->queryToGroupByActivity() . $this->getOrder() . $this->getLimit())->fetchAll();
    }
Example #23
0
 public function deleteAdmin(\Request $req, \Response $res)
 {
     $admin = new \Model\Admin($req->param("id"));
     $admin->deleteFromDb();
     $res->Json(array("message" => "Admin successfully deleted"));
 }
 /**
  * Display course
  */
 public function displayCourse()
 {
     $this->Context = new Context(Request::sendId(), Request::param('account'));
     if (!$this->activityIsValid() || !$this->Context->hasRoute() || !$this->Context->route()->hasPositionData()) {
         die('Don\'t do that!');
     }
     $Linker = new Linker($this->Context->activity());
     echo '<meta property="og:type" content="metadata">' . NL;
     echo '<link rel="origin" href="' . $Linker->publicUrl() . '">' . NL;
     $this->RouteLoop = new Model\Route\Loop($this->Context->route());
     $this->RouteLoop->setStepSize(self::STEP_SIZE);
     $this->TrackdataLoop = new Model\Trackdata\Loop($this->Context->trackdata());
     $this->TrackdataLoop->setStepSize(self::STEP_SIZE);
     do {
         $this->displayActivityDataPoint();
     } while ($this->RouteLoop->nextStep() && $this->TrackdataLoop->nextStep());
 }
Example #25
0
 public static function price($field)
 {
     if (Request::param($field) === null) {
         return;
     }
     if (strval(floatval(Request::param($field))) != Request::param($field) || Request::param($field) >= 1000000000) {
         Request::error(lng("wrong_price_format"), $field);
     }
 }
 public function quickupload()
 {
     if ($class = Request::get('model')) {
         if ($id = Request::param("id")) {
             $this->page = new $class($id);
         }
     }
     $this->use_layout = "simple";
     $this->use_view = "upload";
 }
Example #27
0
 public function deleteProduct(\Request $req, \Response $res)
 {
     $product = new \Model\Product($req->param("id"));
     $product->deleteFromDb();
     \Response::RedirectTo("Controller\\Product::listProduct", array(), "Product '{$product->username}' deleted");
 }
Example #28
0
<?php

/**
 * Window: formular for shoes
 * @package Runalyze\Plugins\Panels
 */
require '../../inc/class.Frontend.php';
$Frontend = new Frontend();
if (Request::param('delete') == 'true') {
    DB::getInstance()->deleteByID('shoe', (int) Request::sendId());
    DB::getInstance()->query('UPDATE `' . PREFIX . 'training` SET `shoeid`=0 WHERE `shoeid`=' . (int) Request::sendId() . ' AND accountid = ' . SessionAccountHandler::getId());
    Cache::delete(ShoeFactory::CACHE_KEY);
    header('Location: window.schuhe.table.php?reload=true');
    exit;
}
if (Request::sendId() === false) {
    $Header = __('Add new shoe');
    $Mode = StandardFormular::$SUBMIT_MODE_CREATE;
    $Shoe = new Shoe(DataObject::$DEFAULT_ID);
} else {
    $Header = __('Edit shoe');
    $Mode = StandardFormular::$SUBMIT_MODE_EDIT;
    $Shoe = new Shoe(Request::sendId());
}
$Formular = new StandardFormular($Shoe, $Mode);
if ($Formular->submitSucceeded()) {
    header('Location: window.schuhe.table.php');
    ShoeFactory::clearCache();
    exit;
}
if (Request::sendId() > 0) {
 /**
  * Get base url
  * @return string
  */
 static function getBaseUrl()
 {
     return 'shared/' . Request::param('user') . '/';
 }
Example #30
0
 /**
  * Get IDs
  * @return array
  */
 public static function IDs()
 {
     if (empty(self::$IDs)) {
         if (strlen(Request::param('multi-editor-ids')) > 0) {
             self::$IDs = explode(',', Request::param('multi-editor-ids'));
         }
     }
     return self::$IDs;
 }