/** * Add a paper to a lightbox. * * @param int $paper_id Use the paper ID as the identifier, this page shoudl not really bew viewed by itself. */ public function add($paper_id = NULL) { $this->breadcrumbs->add()->url(false)->title('Add Paper'); // get the current user $current = Security::instance()->get_user(); // sanity check if ($current && $current->loaded) { // make sure they sent something in -= GIGO check if ($paper_id != NULL) { // they found a paper, lets make sure it is a real one. $paper = ORM::factory('paper', $paper_id); if ($paper->loaded) { $view = new view(url::routes_area() . 'add_modal'); $view->paper = $paper; // get the users lightboxes $view->lightboxes = ORM::factory('lightbox')->where('creator_id', $current->id)->find_all(); $this->ajax['view'] = $view; } else { $this->notification->add($this->i18n['system.paper.invalid']); } } else { // user didnt send through a paper $this->notification->add($this->i18n['system.paper.invalid']); } } else { // user is not logged in, cant add a favourite if your not logged in $this->notification->add($this->i18n['system.user.invalid']); $view = new view('account/login_modal'); $view->notifications = json_encode($this->notification->get()); $this->ajax['view'] = $view; } }
/** * This will provide a =tile list of each of the industrial products * this is differnt to the paper/products */ public function index() { $this->template->title = 'Industrial Products'; $view = new View(url::location()); $this->breadcrumbs->add()->url(url::routes_area())->title('Browse'); $view->breadcrumbs = $this->breadcrumbs->cut(); $view = new view(url::location()); $view->industrials = orm::factory('industrial')->where('status', 'approved')->orderby('name', 'ASC')->find_all(); $this->template->content = $view; }
/** * add an industrial product, based up on the paper add. */ public function add() { if ($this->access->allowed('industrials', 'create')) { $this->template->title = 'Add Industrial Product'; $view = new view(url::routes_area() . 'add'); $view->styles = orm::factory('style')->find_all(); $view->availablities = orm::factory('availablity')->find_all(); $view->characteristics = orm::factory('characteristic')->find_all(); $view->environmentals = ORM::factory('environmental')->find_all(); $view->post = $this->post; $this->template->content = $view; } else { url::failed(); } }
public function view($name) { $name = url::decode($name); // check it exists and is published $campaign = orm::factory('campaign')->where('name', $name)->where('status', 'approved')->find(); if ($campaign->loaded) { $this->breadcrumbs->add()->url('campaigns')->title('Campaigns'); $this->breadcrumbs->add()->url(false)->title($campaign->name); $this->template->title = 'Campaigns › ' . $campaign->name; $view = new view(url::location()); $view->campaign = $campaign; $view->breadcrumbs = $this->breadcrumbs->cut(); $this->template->content = $view; } else { $this->notification->add($this->i18n['system.campaign.invalid']); url::redirect(url::routes_area()); } }
/** * View a Paper */ public function view($name) { $name = url::decode($name); // get the paper and populate the padded field, as we will be using to to display the gsm table. $paper = ORM::factory('paper')->where('name', $name)->where('status', 'approved')->find(); //->populate_padded_gsm(); if ($paper->loaded) { $view = new View('products/papers/view'); $this->template->title = $paper->name; $this->breadcrumbs->add()->url(url::current())->title($paper->name); $view->breadcrumbs = $this->breadcrumbs->get(); $view->finishes = $paper->finishes; $view->paper = $paper; $this->template->content = $view; } else { $this->notification->add($this->i18n['system.paper.error']); url::redirect(url::routes_area() . 'index'); } }
/<?php echo $location->image; ?> " class="icon" /></a></td> <td><a href="<?php echo url::routes_area() . 'edit/' . $location->id; ?> "><?php echo $location->name; ?> </a></td> <td class="align-center"><?php echo $location->status == 'approved' ? '<span class="icon-approved">✔</span>' : '<span class="icon-pending">✘</span>'; ?> </td> <td><a class="text-edit" href="<?php echo url::routes_area() . 'edit/' . $location->id; ?> ">Edit</a> <a class="text-delete" href="<?php echo url::routes_area() . 'delete/' . $location->id; ?> " onclick="return confirm('Do you really want to delete the article?');">Delete</a></td> </tr> <?php } ?> </tbody> </table> </div>
<td><a href="<?php echo url::routes_area() . 'edit/' . $campaign->id; ?> "><?php echo $campaign->name; ?> </a></td> <td class="align-center"><?php echo $campaign->status == 'approved' ? '<span class="icon-approved">✔</span>' : '<span class="icon-pending">✘</span>'; ?> </td> <td class="last"><a href="<?php echo url::routes_area() . 'edit/' . $campaign->id; ?> " class="text-edit"><span>Edit</span></a> <a href="<?php echo url::routes_area() . 'delete/' . $campaign->id; ?> " onclick="return confirm('Do you really want to delete this campaign?');" class="text-delete"><span>Delete</span></a></td> </tr> <?php } ?> </tbody> </table> <?php echo $pagination; ?> </div>
"/></td> <td><a href="<?php echo url::routes_area() . 'edit/' . $billboard->id; ?> "><?php echo $billboard->name; ?> </a></td> <td class="align-center"><?php echo $billboard->status == 'approved' ? '<span class="icon-approved">✔</span>' : '<span class="icon-pending">✘</span>'; ?> </td> <td><a class="text-edit" href="<?php echo url::routes_area() . 'edit/' . $billboard->id; ?> ">Edit</a> <a class="text-delete" href="<?php echo url::routes_area() . 'delete/' . $billboard->id; ?> " onclick="return confirm('Do you really want to delete the billboard?');">Delete</a></td> </tr> <?php } ?> </tbody> </table> <?php echo $pagination; ?> </div>
<legend>Billboard Image</legend> <div class="notifications"></div> <ul class="block-list"> <li id="image-upload" class="upload-single-file"> <ul id="completed-image" class="upload-single-file-list"><li class="empty"><p>No files have been uploaded</p></li></ul> <div class="upload-single-file-uploader"> <h4>Billboard (940 x 300 pixels)</h4> <input type="file" id="upload-image" class="uploadify" /> <div id="image-cover-progress" class="upload-single-file-progress"></div> </div> </li> </ul> </fieldset> <div class="button-group"> <button type="submit" name="post-action" value="<?php echo Router::$method; ?> " ><span>Save</span></button> <a href="<?php echo url::routes_area() . 'index'; ?> " class="button"><span>Cancel</span></a> </div> </form>
"><?php echo $article->name; ?> </a></td> <td><?php echo ucwords($article->group); ?> </td> <td class="align-center"><?php echo $article->status == 'approved' ? '<span class="icon-approved">✔</span>' : '<span class="icon-pending">✘</span>'; ?> </td> <td><a class="text-edit" href="<?php echo url::routes_area() . 'edit/' . $article->id; ?> ">Edit</a> <a class="text-delete" href="<?php echo url::routes_area() . 'delete/' . $article->id; ?> " onclick="return confirm('Do you really want to delete the article?');">Delete</a></td> </tr> <?php } ?> </tbody> </table> <?php echo $pagination; ?> </div>
?> " class="text long"/> </div> </li> <li> <label for="faq-content" class="column x3 first">Content <span class="required">*</span></label> <div class="column x9 last"> <textarea id="article-content" rows="8" cols="50" name="description" class="text"><?php echo $post['description']; ?> </textarea> </div> </li> </ul> </fieldset> <div class="button-group"> <button type="submit" name="post-action" value="<?php echo Router::$method; ?> " ><span>Save</span></button> <a href="<?php echo url::routes_area() . 'index/' . $group; ?> " class="button"><span>Cancel</span></a> </div> </form>
public function update() { if ($this->access->allowed('faqs', 'update')) { // @todo - add the rest of the required vars $input = Validation::factory($this->input->post())->pre_filter('trim')->add_rules('id', 'required')->add_rules('name', 'required')->add_rules('description', 'required')->add_rules('status', 'required'); if ($input->validate()) { $faq = ORM::factory('faq', $this->input->post('id')); if ($faq->loaded) { // @todo look for an existing article with the same name as the one given, need to think about whether it needs to be by faq. $faq->name = $this->input->post('name'); $faq->description = $this->input->post('description'); $faq->status = $this->input->post('status'); $faq->order = $this->input->post('order'); $faq->group = $this->input->post('group'); if ($faq->save()) { $this->notification->add($this->i18n['system.faq.success'], $faq->name); url::redirect(url::routes_area() . 'edit/' . $faq->id); } else { $this->notification->add($this->i18n['system.faq.error']); } } } else { foreach ($input->errors() as $key => $value) { $this->notification->add($this->i18n['filter.' . $key . '.' . $value]); } } } else { Kohana::log('debug', 'User failed method security check'); url::failed(); } }
public function edit($id = NULL) { if ($this->access->allowed('magazines', 'update')) { if ($id != NULL) { $magazine = orm::factory('magazine')->find($id); if ($magazine->loaded) { $view = new view(url::location()); $view->magazine = orm::factory('magazine', $id); $this->template->title = 'Stock Magazines'; $this->template->content = $view; } else { $this->notification->add($this->i18n['system.magazine.failed']); url::redirect(url::routes_area()); } } else { $this->notification->add($this->i18n['system.magazine.failed']); url::redirect(url::routes_area()); } } else { url::failed(); } }
</td> <td class="align-center"><?php echo $paper->status == 'approved' ? '<span class="icon-approved">✔</span>' : '<span class="icon-pending">✘</span>'; ?> </td> <td><a href="<?php echo url::routes_area(); ?> edit/<?php echo url::encode($paper->name); ?> " title="Edit <?php echo $paper->name; ?> " class="text-edit"><span>Edit</span></a> <a href="<?php echo url::routes_area() . 'delete/' . $paper->id; ?> " class="text-delete" title="Delete <?php echo $paper->name; ?> " onclick="return confirm('Do you really want to delete the paper item <?php echo $paper->name; ?> ?');"><span>Delete</span></a></td> </tr> <?php } ?> <?php } else { ?>
public function edit($id) { if ($this->access->allowed('campaigns', 'update')) { $campaign = orm::factory('campaign', $id); if ($campaign->loaded) { $this->template->title = 'Edit Campaign'; $this->breadcrumbs->add()->url(false)->title($campaign->name); $view = new view(url::location()); $view->campaign = $campaign; $this->template->content = $view; } else { $this->notification->add($this->i18n['system.campaign.invalid']); url::redirect(url::routes_area()); } } else { url::failed(); } }
</td> <?php foreach ($padded[$sheet->id] as $gsm => $value) { ?> <td class="align-center"><?php echo $value === TRUE ? '<span class="tick">•</span>' : ' '; ?> </td> <?php } ?> <td><a class="text-edit" href="<?php echo url::routes_area() . 'edit/' . $sheet->id; ?> ">Edit</a> <a class="text-delete" href="<?php echo url::routes_area() . 'delete/' . $sheet->id; ?> " onclick="return confirm('Do you really want to delete this sheet?');">Delete</a></td> </tr> <?php } ?> <?php } else { ?> <tr><td colspan="3">There are no sheets for this paper range.</td></tr> <?php } ?> </tbody> </table>
</fieldset> <fieldset> <legend>News Article Image</legend> <ul class="block-list"> <li id="news-image" class="upload-single-file"> <ul id="completed-news-image" class="upload-single-file-list"><li class="empty"><p>No files have been uploaded</p></li></ul> <div class="upload-single-file-uploader"> <h4>Cover</h4> <input type="file" id="upload-news-image" class="uploadify" /> <div id="news-image-cover-progress" class="upload-single-file-progress"></div> </div> </li> </ul> </fieldset> <div class="button-group"> <button type="submit" name="post-action" value="<?php echo Router::$method; ?> " ><span>Save</span></button> <a href="<?php echo url::routes_area() . 'index/' . $news->group; ?> " class="button"><span>Cancel</span></a> </div> </form>
/** * This method is used to display all of the papers with in an lightboxes * *57 * @param $name the name of the lightboxes * @param $user the created of the lightboxes, we add this as a required, as a form of security through obsuritiy. * makes it alot harder to browse through lighboxes with out having the name and creator. */ public function view_old($email, $name) { $redirect = true; // flag for redirecting on error. // readd any quotes it may have had $name = url::decode($name); if ($this->access->allowed('lightboxes', 'read')) { // get the user. $user = ORM::factory('user')->where('email', $email)->find(); if ($user->loaded) { $lightbox = ORM::factory('lightbox')->where('creator_id', $user->id)->where('name', $name)->find(); if ($lightbox->loaded) { // only show if the lightboxes is public of if the owner is the person currently logged in. if ($lightbox->status == 'approved' || $this->current && $this->current->id == $lightbox->creator_id) { $view = new view(url::routes_area() . 'view'); // add one to the views for the lightbox. $lightbox->views += 1; $lightbox->save(false); $view->lightbox = $lightbox; if ($this->current && $this->current->id == $user->id) { $view->is_owner = true; } $view->current_user = $this->current; //$view->is_owner = ($this->current && $this->current->id == $user->id); // @todo :: add check against lightbox moderator priv. $this->breadcrumbs->add()->url(url::current())->title($lightbox->name); $view->breadcrumbs = $this->breadcrumbs->get(); $this->breadcrumbs->delete(); $this->template->content = $view; $redirect = false; // dont redirect as everythign worked. } else { $this->notification->add($this->i18n['system.lightbox.status']); } } else { $this->notification->add($this->i18n['system.lightbox.invalid']); } } else { $this->notification->add($this->i18n['system.user.invalid']); } } else { $this->notification->add($this->i18n['system.lightbox.login']); } // if there was an error, redirect away. if ($redirect) { url::redirect('account'); } }
/** * Code to update an inspiration, any attached papers and files. */ public function update() { // see if they have access - currently disabled, for testing. if ($this->access->allowed('inspirations', 'update')) { // load the inspiration, make sure the person owns it. Up here for the redirect $inspiration = orm::factory('inspiration', $this->input->post('id')); // check the filter $input = Validation::factory($this->input->post())->pre_filter('trim', 'name', 'description', 'studio', 'printer'); $input->add_rules('name', 'required', 'length[4,32]'); $input->add_rules('description', 'required'); $input->add_rules('industry_id', 'required'); $input->add_rules('application_id', 'required'); if ($input->validate()) { // sanity : make sure that the id exists etc. if ($inspiration && $inspiration->loaded) { // make sure this is their inspiration if ($this->current->id == $inspiration->user_id) { if ($inspiration->status != 'approved') { $inspiration->name = $this->input->post('name'); $inspiration->description = $this->input->post('description'); $inspiration->studio = $this->input->post('studio'); $inspiration->printer = $this->input->post('printer'); $inspiration->user_id = $this->current->id; $inspiration->status = 'pending'; $inspiration->application_id = $this->input->post('application_id'); $inspiration->industry_id = $this->input->post('industry_id'); $inspiration->released = strtotime($this->input->post('released')); $pivot = orm::factory('inspirations_pigment')->where('inspiration_id', $inspiration->id)->delete_all(); if ($inspiration->save()) { $this->notification->add($this->i18n['system.inspiration.success'], $inspiration->name); $pigments = $this->input->post('pigments'); if (is_array($pigments)) { $added = 0; // var used to count the number of papers attached to the inspiration foreach ($pigments as $pigment_id => $description) { $pigment = orm::factory('pigment', $pigment_id); if ($pigment->loaded) { $pivot = orm::factory('inspirations_pigment'); $pivot->pigment_id = $pigment_id; $pivot->description = $description; $pivot->inspiration_id = $inspiration->id; if ($pivot->save()) { $added++; } else { $this->notification->add($this->i18n['system.pigment.error']); } } else { $this->notification->add($this->i18n['system.pigment.invalid']); } } if ($added) { $this->notification->add($this->i18n['system.pigment.success'], $added); } } // add the photos // check to see if any of the files have been changed $files = $this->input->post('files'); // note - if the file['edit'] is empty then delete all of the photos. foreach ($inspiration->photos as $photo) { $existing[] = $photo->id; } // check to make sure files edit has been set, if it has not, then set ti to a blank array (for when they delete all of the photos) $files['edit'] = isset($files['edit']) && is_array($files['edit']) ? $files['edit'] : array(); $existing = isset($existing) && is_array($existing) ? $existing : array(); // find out if the photos they sent in are differnt to the ones that exist $diff = array_diff($existing, $files['edit']); if (is_array($diff) && count($diff) > 0) { // @todo should prob have differnt notification if (ORM::factory('photo')->delete_all($diff)) { $this->notification->add($this->i18n['system.photo.success'], array('deleted', count($diff), $inspiration->name)); } else { $this->notification->add($this->i18n['system.photo.error'], $inspiration->name); } } // add the new files if (isset($files['add']) && count($files['add'])) { $directory = DOCROOT . 'application/' . SITE . '/media/cms/inspirations/' . $inspiration->id . ''; if (file::tree($directory)) { $added = 0; foreach ($files['add'] as $file) { if (file_exists(DOCROOT . 'upload/' . $file)) { if (rename(DOCROOT . 'upload/' . $file, $directory . '/' . $file)) { // the file has been moved, add it to the dbase. $photo = orm::factory('photo'); $photo->name = $file; $photo->description = ''; $photo->inspiration_id = $inspiration->id; if ($photo->save()) { $added++; } else { $this->notification->add($this->i18n['system.photo.error']); } } else { $this->notification->add($this->i18n['cms.file.error']); } } else { $this->notification->add($this->i18n['cms.file.error']); } } // consolidate the notifications. if ($added) { $this->notification->add($this->i18n['system.photo.success'], array('added', $added, $inspiration->name)); } } else { $this->notification->add($this->i18n['cms.folder.error']); } } url::redirect(url::routes_area() . 'edit/' . $inspiration->id); } else { // orm save on the inpiration failed - database.fail $this->notification->add($this->i18n['system.inspiration.failed'], $inspiration->name); } } else { // the inspiration is approved, we cant edit published material $this->notification->add($this->i18n['system.inspiration.approved'], $inspiration->name); } } else { $this->notification->add($this->i18n['system.access.failed']); // access denied, its not their inspiration they are trying to edit. } } else { $this->notification->add($this->i18n['system.inspiration.invalid']); // error - no such inspiration exist } } else { foreach ($input->errors() as $key => $value) { $this->notification->add($this->i18n['filter.' . $key . '.' . $value]); } } } else { url::failed(); } url::redirect(url::routes_area() . 'edit/' . $inspiration->id); }
<fieldset id="alliance-logo"> <legend>Image</legend> <div class="notifications"></div> <ul class="block-list"> <li id="image-logo" class="upload-single-file"> <ul id="completed-logo" class="upload-single-file-list"><li class="empty"><p>No files have been uploaded</p></li></ul> <div class="upload-single-file-uploader"> <h4>Logo</h4> <input type="file" id="upload-logo" class="uploadify" /> <div id="image-logo-progress" class="upload-single-file-progress"></div> </div> </li> </ul> </fieldset> <div class="button-group"> <button type="submit" name="post-action" value="<?php echo Router::$method; ?> " ><span>Save</span></button> <a href="<?php echo url::routes_area() . 'index/' . $location->group; ?> " class="button"><span>Cancel</span></a> </div> </form>
echo $inspiration->studio; ?> </span></td> <td><?php echo count($inspiration->photos); ?> </td> <td class="align-center"><?php echo $inspiration->status == 'approved' ? '<span class="icon-approved">✔</span>' : '<span class="icon-pending">✘</span>'; ?> </td> <td><a href="<?php echo url::routes_area() . 'edit/' . $inspiration->id; ?> " class="text-edit"><span>Edit</span></a> <a href="<?php echo url::routes_area() . 'delete/' . $inspiration->id; ?> " class="text-delete" onclick="return confirm('Do you really want to delete this Inspiration project?');"><span>Delete</span></a></td> </tr> <?php } ?> </tbody> </table> <?php echo $pagination; ?> </div>
<input id="sheet-grain-none" name="grain" type="radio" value="" disabled="disabled"/> <label for="sheet-grain-none">None</label> </li> </ul> </div> </li> <li> <label for="gsms" class="column x3 first">Grammage</label> <div class="column x9 last"> <input type="text" name="gsms" value="<?php echo isset($post['gsms']) ? $post['gsms'] : ''; ?> " class="text x-long"/> <div class="help">Separate each GSM value with a comma, e.g. <em>80, 120, 180, 210</em></div> </div> </li> </ul> </fieldset> <div class="button-group"> <button class="" name="post-action" value="index" type="submit"><span>Save</span></button> <a href="<?php echo url::routes_area() . 'index/' . url::encode($paper_name); ?> " class="button"><span>Cancel</span></a> </div> </form>
<li id="image-logo" class="upload-single-file"> <ul id="completed-logo" class="upload-single-file-list"><li class="empty"><p>No image set</p></li></ul> <div class="upload-single-file-uploader"> <h4>Title (172 x 96 pixels)</h4> <input type="file" id="upload-logo" class="uploadify" /> <div id="image-logo-progress" class="upload-single-file-progress"></div> </div> </li> <li id="image-icon" class="upload-single-file"> <ul id="completed-icon" class="upload-single-file-list"><li class="empty"><p>No image set</p></li></ul> <div class="upload-single-file-uploader"> <h4>Icon (50 x 50 pixels)</h4> <input type="file" id="upload-icon" class="uploadify" /> <div id="image-icon-progress" class="upload-single-file-progress"></div> </div> </li> </ul> </fieldset> <div class="button-group"> <button name="post-action" value="index" type="submit"><span>Save</span></button> <a href="<?php echo url::routes_area(); ?> " class="button"><span>Cancel</span></a> </div> </form>
public function edit($id) { if ($this->access->allowed('inspirations', 'update')) { $inspiration = orm::factory('inspiration')->find($id); $this->breadcrumbs->add()->url(FALSE)->title('Edit "' . $inspiration->name . '"'); if ($inspiration->loaded) { $this->template->title = 'Edit Inspiration'; $view = new view(url::routes_area() . 'edit'); $view->inspiration = $inspiration; $view->applications = orm::factory('application')->find_all(); $view->industries = orm::factory('industry')->find_all(); $this->template->content = $view; } else { $this->notification->add($this->i18n['system.inspiration.failed']); } } else { url::failed(); } }
?> "> <td><a href="<?php echo url::routes_area() . 'edit/' . $faq->id; ?> "><?php echo $faq->name; ?> </a></td> <td class="align-center"><?php echo $faq->status == 'approved' ? '<span class="icon-approved">✔</span>' : '<span class="icon-pending">✘</span>'; ?> </td> <td><a class="text-edit" href="<?php echo url::routes_area() . 'edit/' . $faq->id; ?> ">Edit</a> <a class="text-delete" href="<?php echo url::routes_area() . 'delete/' . $faq->id; ?> " onclick="return confirm('Do you really want to delete the article?');">Delete</a></td> </tr> <?php } ?> </tbody> </table> </div>
<?php defined('SYSPATH') or die('No direct access allowed.'); ?> <script type="text/javascript"> $(document).ready( function() { // Resort elements $('.hive-ui-resort').resort({ ajaxURL: '<?php echo url::routes_area() . 'update_order/technical/'; ?> ', switchSelector: '#reorder-list-switch' }); }); </script> <div> <div class="header"> <?php if (isset($foreign->name)) { ?> <ul class="sub-navigation"> <li> <a href="products/papers/edit/<?php echo url::encode($foreign->name); ?>
/** * delete an item from the system */ public function delete($id = NULL) { $group = ''; if ($this->access->allowed('locations', 'delete')) { if ($id != NULL) { $location = orm::factory('location')->find($id); if ($location->loaded) { $location->status = 'deleted'; if ($location->save()) { $this->notification->add($this->i18n['system.location.success'], $location->name); } else { $this->notification->add($this->i18n['system.location.error'], $location->name); } $group = $location->group; // set the group } else { $this->notification->add($this->i18n['system.location.invalid']); } } else { $this->notification->add($this->i18n['system.location.invalid']); } } else { url::failed(); } if (!request::is_ajax()) { url::redirect(url::routes_area() . 'index/' . $group); } }
" class="text long"/> </div> </li> <li> <label for="faq-content" class="column x3 first">Content <span class="required">*</span></label> <div class="column x9 last"> <textarea id="faq-content" rows="8" cols="50" name="description" class="text"><?php echo $faq->description; ?> </textarea> </div> </li> </ul> </fieldset> <div class="button-group"> <button type="submit" name="post-action" value="<?php echo Router::$method; ?> " ><span>Save</span></button> <a href="<?php echo url::routes_area() . 'index/' . $faq->group; ?> " class="button"><span>Cancel</span></a> </div> </form>
public function edit($id = NULL) { if ($this->access->allowed('billboards', 'update')) { if ($id != NULL) { $billboard = orm::factory('billboard')->find($id); if ($billboard->loaded) { $view = new view(url::location()); $view->billboard = $billboard; $this->template->title = 'Edit Billboard'; $this->template->content = $view; } else { $this->notification->add($this->i18n['system.billboard.failed']); url::redirect(url::routes_area()); } } else { $this->notification->add($this->i18n['system.billboard.failed']); url::redirect(url::routes_area()); } } else { url::failed(); } }
public function update() { if ($this->access->allowed('news', 'update')) { $input = Validation::factory($this->input->post())->pre_filter('trim')->add_rules('id', 'required')->add_rules('name', 'required')->add_rules('description', 'required')->add_rules('status', 'required')->add_rules('group', 'required'); if ($input->validate()) { $news = ORM::factory('news', $this->input->post('id')); if ($news->loaded) { // @todo look for an existing article with the same name as the one given, need to think about whether it needs to be by article. $news->name = $this->input->post('name'); $news->description = $this->input->post('description'); $news->status = $this->input->post('status'); $news->group = $this->input->post('group'); $image = $this->input->post('image'); if (isset($image)) { $magazine->image = $image; } if ($news->save()) { $this->notification->add($this->i18n['system.news.success'], $news->name); // make sure that the file location exists, if not create it $cms = DOCROOT . 'application/' . SITE . '/media/cms/magazines/' . $news->id; if (file::tree($cms)) { if (isset($image)) { // add the campaign logo $location = $image; if (file_exists(DOCROOT . 'upload/' . $location)) { //@todo change this so that the uploads folder is not part of the info sent in if (rename(DOCROOT . 'upload/' . $location, $cms . '/' . $location)) { $this->notification->add($this->i18n['cms.cover.success']); } else { $this->notification->add($this->i18n['cms.cover.error']); } } else { $this->notification->add($this->i18n['cms.cover.error']); } } } else { $this->notification->add($this->i18n['cms.folder.error']); } url::redirect(url::routes_area() . 'edit/' . $news->id); } else { $this->notification->add($this->i18n['system.news.error']); } } } else { foreach ($input->errors() as $key => $value) { $this->notification->add($this->i18n['filter.' . $key . '.' . $value]); } } } else { Kohana::log('debug', 'User failed method security check'); url::failed(); } }