示例#1
0
 /**
  * Update option group info
  *
  * @param      int 		$ogId Option Group ID
  * @param      array 	$fields New info
  * @return     throws exception
  */
 public function updateOptionGroup($ogId, $fields)
 {
     require_once __DIR__ . DS . 'OptionGroup.php';
     $optionGroup = new OptionGroup($ogId);
     //print_r($fields);die;
     if (isset($fields['ogName'])) {
         $optionGroup->setName($fields['ogName']);
     }
     if (isset($fields['state'])) {
         $optionGroup->setActiveStatus($fields['state']);
     }
     $optionGroup->save();
     return $optionGroup;
 }
示例#2
0
 /**
  * Remove an entry
  *
  * @return  void
  */
 public function removeTask()
 {
     // Incoming
     $step = Request::getInt('step', 1);
     $step = !$step ? 1 : $step;
     // What step are we on?
     switch ($step) {
         case 1:
             Request::setVar('hidemainmenu', 1);
             // Incoming
             $id = Request::getVar('id', array(0));
             if (!is_array($id) && !empty($id)) {
                 $id = array($id);
             }
             $this->view->ogId = $id;
             // Set any errors
             if ($this->getError()) {
                 $this->view->setError($this->getError());
             }
             // Output the HTML
             $this->view->display();
             break;
         case 2:
             // Check for request forgeries
             Request::checkToken() or jexit('Invalid Token');
             // Incoming
             $ogIds = Request::getVar('ogId', 0);
             //print_r($ogIds); die;
             // Make sure we have ID(s) to work with
             if (empty($ogIds)) {
                 App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=dispaly', false), Lang::txt('COM_STOREFRONT_NO_ID'), 'error');
                 return;
             }
             $delete = Request::getVar('delete', 0);
             $msg = "Delete canceled";
             $type = 'error';
             if ($delete) {
                 // Do the delete
                 $obj = new Archive();
                 $warnings = array();
                 foreach ($ogIds as $ogId) {
                     // Delete option group
                     try {
                         $optionGroup = new OptionGroup($ogId);
                         $optionGroup->delete();
                         // see if there are any warnings to display
                         if ($optionGroupWarnings = $optionGroup->getMessages()) {
                             foreach ($optionGroupWarnings as $optionGroupWarning) {
                                 if (!in_array($optionGroupWarning, $warnings)) {
                                     $warnings[] = $optionGroupWarning;
                                 }
                             }
                         }
                     } catch (\Exception $e) {
                         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=dispaly', false), $e->getMessage(), $type);
                         return;
                     }
                 }
                 $msg = "Option group(s) deleted";
                 $type = 'message';
             }
             // Set the redirect
             App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=dispaly', false), $msg, $type);
             if ($warnings) {
                 foreach ($warnings as $warning) {
                     \Notify::warning($warning);
                 }
             }
             break;
     }
 }