Beispiel #1
0
 public function __construct()
 {
     parent::__construct();
     // to view any page on on this controller the user must have at least user read access
     if ($this->access->allowed('inspirations', 'read')) {
         $this->breadcrumbs->add()->url('inspirations')->title('Inspirations');
     } else {
         Kohana::log('debug', 'User failed constructor security check');
         url::failed();
     }
 }
Beispiel #2
0
 public function placeorder()
 {
     if ($this->current) {
         $this->template->title = 'Place Order for Sample or Dummy';
         $view = new View(url::area() . 'placeorder');
         $view->user = $this->current;
         $view->breadcrumbs = $this->breadcrumbs->add()->url(false)->title('Place Order')->cut();
         $this->template->content = $view;
     } else {
         //$this->notification->add($this->i18n['security.login.fail']);
         url::failed(url::current());
     }
 }
Beispiel #3
0
 /**
  * This little method is used to update the order of the FAQ articles, 
  * it will accept an array of the new order. This has been created 
  * to be used with a drag n drop jquery script. called jquery.hive.resort
  * 
  * @var POST array 
  * 		array(2) {
  * 		  [0]=>
  * 		  array(2) {
  * 		    [0]=>
  * 		    string(1) "3"
  * 		    [1]=>
  * 		    string(1) "0"
  * 		  }
  * 		  [1]=>
  * 		  array(2) {
  * 		    [0]=>
  * 		    string(1) "2"
  * 		    [1]=>
  * 		    string(1) "1"
  *		  }
  * 
  * With first int with the e inner most array being the ID of the item
  * With the second int with in the inner most array being the ORDER
  * 
  */
 function update_order()
 {
     if ($this->access->allowed('billboards', 'update')) {
         $data = $this->input->post('data');
         $successes = 0;
         // simple counter to tell end user how many times it worked.
         foreach ($data as $info) {
             $billboard = orm::factory('billboard', $info[0]);
             // @todo does this require a find()
             $billboard->order = $info[1];
             if ($billboard->save()) {
                 $successes++;
             }
         }
         // add the error messages
         if ($successes == count($data)) {
             $this->notification->add($this->i18n['system.billboard.success']);
         } else {
             $this->notification->add($this->i18n['system.billboard.failed'], count($data) - $successes);
         }
     } else {
         url::failed();
     }
 }
Beispiel #4
0
 /**
  * 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);
     }
 }
Beispiel #5
0
 /**
  * Update the user account information.
  */
 public function update()
 {
     if ($this->access->allowed('account', 'update')) {
         $input = Validation::factory($this->input->post());
         if ($this->current && $this->current->loaded) {
             // Validate the form input
             $input->add_rules('email', 'required', 'email');
             if ($input->validate()) {
                 if ($this->current->email != $this->input->post('email')) {
                     $new_email = ORM::factory('user')->where('email', $this->input->post('email'))->find();
                     if ($new_email->loaded) {
                         $this->notification->add($this->i18n['system.email.exists']);
                         url::redirect(url::area() . 'settings');
                     } else {
                         $this->current->email = $this->input->post('email');
                         if ($this->config['unique'] == 'email') {
                             // @todo do a validation check against the email address.
                             $this->notification->add($this->i18n['system.email.success'], $this->current->email);
                         }
                     }
                 }
                 // set the new field information
                 $this->current->title = $this->input->post('title');
                 $this->current->firstname = $this->input->post('firstname');
                 $this->current->lastname = $this->input->post('lastname');
                 $this->current->company = $this->input->post('company');
                 $this->current->job = $this->input->post('job');
                 $this->current->phone = $this->input->post('phone');
                 $this->current->mobile = $this->input->post('mobile');
                 $this->current->prefered = $this->input->post('prefered');
                 $this->current->contact = $this->input->post('contact') == 'true' ? true : false;
                 $this->current->address = $this->input->post('address');
                 $this->current->postcode = $this->input->post('postcode');
                 $this->current->suburb = $this->input->post('suburb');
                 $this->current->state = $this->input->post('state');
                 if ($this->current->save()) {
                     $this->notification->add($this->i18n['system.user.success']);
                     url::redirect(url::area() . 'settings');
                 } else {
                     $this->notification->add($this->i18n['system.user.failed']);
                 }
             } else {
                 foreach ($input->errors() as $key => $value) {
                     $this->notification->add($this->i18n['filter.' . $key . '.' . $value]);
                 }
                 url::redirect(url::area() . 'settings');
             }
         } else {
             $this->notification->add($this->i18n['system.user.invalid']);
             // unable to fiund the user to update. (ie current logged in user)
         }
     } else {
         url::failed();
     }
     url::redirect(url::area() . 'settings');
 }
Beispiel #6
0
 /**
  *
  * @param $id
  */
 public function delete($lightbox, $paper)
 {
     // to delete a paper from a lightbox we require both the lightbox and the paper ids
     // also we then need to do checks to make sure that the user can delete.
     $this->breadcrumbs->add()->url(false)->title('Remove Paper');
     $lightbox = ORM::factory('lightbox', $lightbox);
     $paper = ORM::factory('paper', $paper);
     $user = $this->access->get_user();
     // first check to see whether or not the user is logged in
     if ($user && $user->loaded) {
         // now make sure that the user logged in is the creator of the lightbox
         if ($user->id == $lightbox->creator_id) {
             $lightbox->remove($paper);
             if ($lightbox->save()) {
                 $this->notification->add($this->i18n['system.paper.success'], array($paper->name, $lightbox->name));
                 // as the only peopel who can delete a paper from a lightbox is the current user,
                 // we can use that information to redirect them back to the view page.
                 url::redirect('/lightboxes/view/' . $user->email . '/' . $lightbox->name);
             } else {
                 $this->notification->add($this->i18n['system.paper.failed'], array($paper->name, $lightbox->name));
             }
         } else {
             $this->notification->add($this->i18n['system.user.failed']);
             url::failed();
         }
     }
 }
Beispiel #7
0
 public function delete($id = NULL)
 {
     if ($this->access->allowed('magazines', 'delete')) {
         if ($id != NULL) {
             $magazine = orm::factory('magazine', $id);
             if ($magazine->loaded) {
                 $magazine->status = 'deleted';
                 $name = $magazine->name;
                 if ($magazine->save()) {
                     $this->notification->add($this->i18n['system.magazine.success'], $name);
                 } else {
                     $this->notification->add($this->i18n['system.magazine.error'], $name);
                 }
             } else {
                 $this->notification->add($this->i18n['system.magazine.invlaid']);
             }
         } else {
             $this->notification->add($this->i18['system.magazine.invalid']);
         }
     } else {
         url::failed();
     }
     if (!request::is_ajax()) {
         url::redirect(url::area());
     }
 }
Beispiel #8
0
 /**
  * Will delete an inspiration, if the inspiration is owned by the current user
  *
  *
  * @todo: do not allow inspirations to be deleted if they are published.
  * @param unknown_type $id
  */
 public function delete($id = NULL)
 {
     if ($this->access->allowed('inspirations', 'delete')) {
         if ($id) {
             $inspiration = ORM::factory('inspiration', $id);
             if ($inspiration->loaded) {
                 // make sure that the current user is the owner of the inspiration.
                 if ($inspiration->user_id == $this->current->id) {
                     if ($inspiration->status != 'approved') {
                         $inspiration->status = 'deleted';
                         if ($inspiration->save()) {
                             $this->notification->add($this->i18n['system.inspiration.success'], $inspiration->name);
                         } else {
                             $this->notification->add($this->i18n['system.inspiration.failed'], $inspiration->name);
                         }
                     } else {
                         $this->notification->add($this->i18n['system.inspiration.approved'], $inspiration->name);
                     }
                 } else {
                     $this->notification($this->i18n['system.access.failed']);
                     // error you do not have access to delete someone elses inspiration.
                 }
             } else {
                 $this->notification($this->i18n['system.inspiration.invalid']);
             }
         } else {
             $this->notification($this->i18n['system.inspiration.invalid']);
         }
     } else {
         url::failed();
     }
     if (!request::is_ajax()) {
         url::redirect(url::area());
     }
 }
Beispiel #9
0
 public function delete($id = FALSE)
 {
     if ($this->access->allowed('campaigns', 'delete')) {
         if ($id) {
             $campaign = ORM::factory('campaign')->find($id);
             if ($campaign->loaded) {
                 $campaign->status = 'deleted';
                 if ($campaign->save()) {
                     $this->notification->add($this->i18n['system.campaign.success'], $campaign->name);
                 } else {
                     $this->notification($this->i18n['system.campaign.error']);
                 }
             } else {
                 $this->notification($this->i18n['system.campaign.invalid']);
             }
         } else {
             $this->notification($this->i18n['system.campaign.invalid']);
         }
     } else {
         url::failed();
     }
     if (!request::is_ajax()) {
         url::redirect(url::area());
     }
 }
Beispiel #10
0
 /**
  * Note this does not actually delete the faq but rather it just changes the status of it. 
  */
 public function delete($id = FALSE)
 {
     $group = '';
     // assign the group, so if somethign goes wrong we wont get a url redirect error
     if ($this->access->allowed('faqs', 'delete')) {
         if ($id) {
             $faq = ORM::factory('faq')->find($id);
             if ($faq->loaded) {
                 $faq->status = 'deleted';
                 if ($faq->save()) {
                     $this->notification->add($this->i18n['system.faq.success'], $faq->name);
                 } else {
                     $this->notification($this->i18n['system.faq.error']);
                 }
                 // redirect ot the group page if we have one.
                 if (!request::is_ajax()) {
                     url::redirect(url::area() . 'index/' . $faq->group);
                 }
             } else {
                 $this->notification($this->i18n['system.faq.invalid']);
             }
         } else {
             $this->notification($this->i18n['system.faq.invalid']);
         }
     } else {
         url::failed();
     }
     if (!request::is_ajax()) {
         url::redirect(url::area());
     }
 }
Beispiel #11
0
 /**
  * The method used to delete a object, redirects to index
  *
  * @param integer $id the id of the object to delete
  */
 public function delete($id = NULL)
 {
     // make sure that they are only trying to delete their own lightboxes
     if ($this->access->allowed('lightboxes', 'delete')) {
         $current = Security::instance()->get_user();
         if ($id) {
             $lightbox = ORM::factory('lightbox')->find($id);
             if ($lightbox->loaded) {
                 if ($lightbox->creator_id == $current->id) {
                     $lightbox_name = $lightbox->name;
                     if ($lightbox->delete()) {
                         $this->notification->add($this->i18n['system.lightbox.success'], $lightbox_name);
                     } else {
                         $this->notification->add($this->i18n['system.lightbox.error'], $lightbox_name);
                     }
                 } else {
                     $this->notification->add($this->i18n['system.user.invalid']);
                 }
             } else {
                 $this->notification->add($this->i18n['system.lightbox.invalid']);
             }
         } else {
             $this->notification->add($this->i18n['system.lightbox.invalid']);
         }
     } else {
         url::failed();
     }
     if (!request::is_ajax()) {
         url::redirect(url::area());
     }
 }
Beispiel #12
0
 public function delete($id = NULL)
 {
     if ($this->access->allowed('industrials', 'delete')) {
         if ($id > 0) {
             $industrial = orm::factory('industrial')->find($id);
             if ($industrial->loaded) {
                 $name = $industrial->name;
                 // for use with the notification system
                 if ($industrial->delete()) {
                     // success
                 } else {
                     // error
                 }
             } else {
                 // invalid
             }
         } else {
             // invalid
         }
     } else {
         url::failed();
     }
     if (!request::is_ajax()) {
         url::redirect(url::area());
     }
 }
Beispiel #13
0
 public function delete($id = NULL)
 {
     if ($this->access->allowed('papers', 'delete')) {
         if ($id) {
             $paper = ORM::factory('paper')->find($id);
             if ($paper->loaded) {
                 $paper_name = $paper->name;
                 $paper->status = 'deleted';
                 if ($paper->save()) {
                     $this->notification->add($this->i18n['system.paper.success'], $paper_name);
                 } else {
                     $this->notification->add($this->i18n['system.paper.error'], $paper_name);
                 }
             } else {
                 $this->notification($this->i18n['system.paper.invaild']);
             }
         } else {
             $this->notification($this->i18n['system.paper.invaild']);
         }
     } else {
         url::failed();
     }
     if (!request::is_ajax()) {
         url::redirect(url::area());
     }
 }
Beispiel #14
0
 public function delete($id = NULL)
 {
     if ($this->access->allowed('sheets', 'delete')) {
         if ($id) {
             $sheet = ORM::factory('sheet')->find($id);
             $paper_name = $sheet->pigment->collection->paper->name;
             if ($sheet->loaded) {
                 if ($sheet->delete()) {
                     $this->notification->add($this->i18n['system.sheet.success']);
                 } else {
                     $this->notification->add($this->i18n['system.sheet.error']);
                 }
             } else {
                 $this->notification->add($this->i18n['system.sheet.failed']);
             }
         } else {
             $this->notification->add($this->i18n['system.sheet.failed']);
         }
     } else {
         url::failed();
     }
     if (!request::is_ajax()) {
         url::redirect(url::routes_area() . 'index/' . url::encode($paper_name));
     }
 }
Beispiel #15
0
 /**
  * Note this does not actually delete the faq but rather it just changes the status of it. 
  */
 public function delete($id = FALSE)
 {
     $group = '';
     // assign the group, so if somethign goes wrong we wont get a url redirect error
     if ($this->access->allowed('glossaries', 'delete')) {
         if ($id) {
             $glossary = ORM::factory('glossary')->find($id);
             if ($glossary->loaded) {
                 $glossary->status = 'deleted';
                 if ($glossary->save()) {
                     $this->notification->add($this->i18n['system.glossary.success'], $glossary->name);
                 } else {
                     $this->notification($this->i18n['system.glossary.error']);
                 }
             } else {
                 $this->notification($this->i18n['system.glossary.invalid']);
             }
         } else {
             $this->notification($this->i18n['system.glossary.invalid']);
         }
     } else {
         url::failed();
     }
     if (!request::is_ajax()) {
         url::redirect(url::area());
     }
 }