Backend\Modules\Profiles\Engine\Model::updateGroup PHP Method

updateGroup() public static method

Update a profile group.
public static updateGroup ( integer $id, array $values ) : integer
$id integer Group id.
$values array Group data.
return integer
    public static function updateGroup($id, array $values)
    {
        return (int) BackendModel::getContainer()->get('database')->update('profiles_groups', $values, 'id = ?', (int) $id);
    }

Usage Example

Example #1
0
 /**
  * Validate the form.
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // get fields
         $txtName = $this->frm->getField('name');
         // name filled in?
         if ($txtName->isFilled(BL::getError('NameIsRequired'))) {
             // name already exists?
             if (BackendProfilesModel::existsGroupName($txtName->getValue(), $this->id)) {
                 // set error
                 $txtName->addError(BL::getError('GroupNameExists'));
             }
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // build item
             $values['name'] = $txtName->getValue();
             // update values
             BackendProfilesModel::updateGroup($this->id, $values);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_edit_group', array('item' => $values));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('Groups') . '&report=group-saved&var=' . rawurlencode($values['name']) . '&highlight=row-' . $this->id);
         }
     }
 }