function profileEdit() { // Authorize user $id = $_GET['id']; if ($this->_user['is_authorized']) { if (!($this->_user['id'] == $id)) { $this->set('authorized', false); die('You are not allowed to edit this profile!'); } else { $this->set('authorized', true); } } else { $this->set('authorized', false); die('You are not allowed to edit this profile!'); } // get all necessary user data $user = new User(); $user->createFromID($id); $email = $user->getEmail(); $language = $user->getDefaultLanguage(); $this->set('default_language', $language); // notification_interval is rewritten if any POST data is present $notification_interval = $user->getNotificationInterval(); $default_theme = $user->getDefaultTheme(); //if any POST data in - update profile $style = new Style(); $styles_list = $style->getAll(); $this->set('styles', $styles_list); $this->set('notification_interval', $notification_interval); $this->set('default_theme', $default_theme); $this->set('profile', $user); $this->set('email', $email); $this->set('page_title', "Edit User - " . $user->username); }
<div class="col-md-8"> <table class="table table-striped"> <tr> <th>Name:</th> <td><input type='text', name='name', class='form-control'></td> </tr> <tr> <th>Description:</th> <td><textarea name='description' form='new-style-form' class='form-control'></textarea></td> </tr> <tr> <th>Style:</th> <td> <select name ='style_id' class='form-control'> <?php $styles = Style::getAll(); foreach ($styles as $style) { echo "<option value={$style->id}>{$style->name}</option>"; } ?> </select> </td> </tr> <tr> <th>Brewery:</th> <td> <select name='brewery_id' class='form-control'> <?php $breweries = Brewery::getAll(); foreach ($breweries as $brewery) { echo "<option value={$brewery->id}>{$brewery->name}</option>";
<div class='container'> <p>Donec congue, tellus in malesuada fermentum, sem dui tristique diam, sit amet posuere eros metus vitae augue. Vivamus metus sem, imperdiet nec lacinia vitae, ornare non erat. Aliquam pharetra, turpis ut ornare pellentesque, lectus odio semper nibh, non tristique massa arcu id ante. Vestibulum nisi libero, tempor nec dolor nec, tempus iaculis lorem. Phasellus mauris sapien, bibendum ut convallis quis, feugiat ac nibh. Donec lacinia eget mauris eu congue. Nulla at enim eget risus molestie efficitur nec et erat. Fusce at iaculis purus. Morbi eget finibus odio. Donec ac sodales lectus, id finibus felis. Proin tempor gravida arcu ut ultrices. Aliquam quis cursus risus. Vivamus nisi augue, congue nec faucibus eu, congue eu orci. Nulla pulvinar, nisi at pellentesque tincidunt, ligula ex pellentesque tortor, a iaculis ante quam at lectus.</p> <div class='text-center ingredients'> <div class='col-md-3'><img height="150" src="assets/images/ingredients/water.jpg" width="180" /></div> <div class='col-md-3'><img height="150" src="assets/images/ingredients/malts.jpg" width="180" /></div> <div class='col-md-3'><img height="150" src="assets/images/ingredients/hops.jpg" width="180" /></div> <div class='col-md-3'><img height="150" src="assets/images/ingredients/yeasts.jpg" width="180" /></div> </div> </div> <hr> <h2 class='h2-header' id='tasted'>Already tasted</h2> <div class='container'> <ul id='tasted_list'> <div class='row'> <?php $tasted = Style::getAll(); $row = 1; foreach ($tasted as $style) { $beers = count(Style::getBeers($style->id)); echo "<div class='col-md-4'>\n\t\t\t\t\t\t\t<li><a href='" . $_SERVER['PHP_SELF'] . "?style=" . $style->id . "#tasted'>" . $style->name . "</a> <span class='badge'>" . $beers . "</span></li>\n\t\t\t\t\t\t</div>"; if ($row % 3 == 0) { echo "</div><div class='row'>"; } $row++; } ?> </div> </ul> <div class='row'> <?php
function newDeck() { // need a better access control here if (!$this->_user['is_authorized']) { $this->set('authorized', false); //die ( 'Please login in to create a new deck!' ); } else { $this->set('authorized', true); } if (isset($_POST['submit'])) { $data = $_POST['deck']; $deck = new Deck(); $deck->title = $data['title']; $deck->slug_title = $deck->sluggify($deck->title); $user = new User(); $user->createFromID($this->getCurrentUserID()); $deck->user = $user; $deck->abstract = $data['abstract']; $deck->default_theme = $data['theme']; $deck->visibility = $data['visibility']; $deck->language['id'] = $data['language_id']; $deck->language['name'] = $data['language_name']; $deck->create(); $slide_no = $data['slideNo']; //add slides $content = array(); for ($i = 1; $i < $slide_no; $i++) { $slide = new Slide(); $slide->user = $user; $slide->content = "<h2>new slide</h2>"; $slide->language['id'] = $data['language_id']; $slide->language['name'] = $data['language_name']; $slide->translation_status = 'original'; $slide->create(); $content[] = $slide; } $deck->addContent($content); $tag = new Tag(); $tag->item_type = "deck"; $tag->item_id = $deck->id; foreach (explode(',', $data['tags']) as $item) { $tag->tag = $item; $tag->save(); } header('Location:deck/' . $deck->id . '_' . $deck->slug_title); } else { $style = new Style(); $styles_list = $style->getAll(); $this->set('styles', $styles_list); $user_id = $this->getCurrentUserID(); $user = new User(); $user->id = $user_id; $default_language = $user->getDefaultLanguage(); if (!$default_language['id']) { $default_language['id'] = 'en'; $default_language['name'] = 'English'; } $this->set('default_language', $default_language); } $this->set('page_title', 'SlideWiki - Create a new deck'); }