Example #1
0
 /**
  * Load the item data
  */
 protected function loadData()
 {
     $this->id = $this->getParameter('id', 'int', null);
     if ($this->id == null || !BackendAddressesModel::exists($this->id)) {
         $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing');
     }
     $this->record = BackendAddressesModel::get($this->id);
 }
Example #2
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendAddressesModel::exists($this->id)) {
         parent::execute();
         $this->record = (array) BackendAddressesModel::get($this->id);
         BackendAddressesModel::delete($this->id);
         BackendAddressesModel::deleteGroupsFromAddress($this->id);
         // delete the image
         \SpoonFile::delete(FRONTEND_FILES_PATH . '/Addresses/Images/Source/' . $this->record['image']);
         BackendSearchModel::removeIndex($this->getModule(), $this->id);
         BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id));
         $this->redirect(BackendModel::createURLForAction('index') . '&report=deleted&var=' . urlencode($this->record['id']));
     } else {
         $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing');
     }
 }
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     //--Get the ids and split them
     $ids = explode(',', trim(SpoonFilter::getPostValue('ids', null, '', 'string')));
     $group_id = SpoonFilter::getPostValue('group_id', null, '', 'int');
     //--Check if the id is not empty
     if (!empty($ids)) {
         //--Set the sequence to 1
         $sequence = 1;
         //--Loop the id's
         foreach ($ids as $address_id) {
             //--Set the item array
             $item = array();
             $item["sequence"] = $sequence;
             BackendAddressesModel::exists($address_id) ? BackendAddressesModel::updateSequence($address_id, $group_id, $item) : null;
             //--Add the sequence for each id
             $sequence++;
         }
     }
     // success output
     $this->output(self::OK, null, 'sequence updated');
 }