Returns an action column for each table row.

@param $canUpdate
@param $canDelete
@return Closure
178187
protected function getActionsColumn($canUpdate, $canDelete)
    {
        return function ($row) use($canUpdate, $canDelete) {
            $btns = [];
            $html = app('html');

            if ($canUpdate) {
                $url    = handles('antares::ban_management/bannedemails/edit/' . $row->id);
                $btns[] = $html->create('li', $html->link($url, trans('antares/ban_management::label.rule.edit'), ['data-icon' => 'edit']));
            }
            if ($canDelete) {
                $url    = route('bannedemails.destroy', ['id' => $row->id]);
                $btns[] = $html->create('li', $html->link($url, trans('antares/ban_management::label.rule.delete'), [
                            'data-icon'        => 'delete',
                            'class'            => 'triggerable confirm',
                            'data-title'       => trans('Are you sure?'),
                            'data-http-method' => 'DELETE',
                            'data-description' => trans('Deleting banned email') . ' ' . $row->value
                ]));
            }
            if (empty($btns)) {
                return '';
            }

            $section = $html->create('div', $html->create('section', $html->create('ul', $html->raw(implode('', $btns)))), ['class' => 'mass-actions-menu'])->get();
            return '<i class="zmdi zmdi-more"></i>' . $html->raw($section)->get();
        };
    }
1044768
public function addReference($columnName, $refTable, $refColumn,
            $onDelete = 'RESTRICT', $onUpdate = 'RESTRICT') {
        $this->addIndex($columnName);
        $this->newReferences[$columnName] = array(
            'table' => $refTable,
            'column' => $refColumn,
            'onDelete' => $onDelete,
            'onUpdate' => $onUpdate,
        );
        return $this;
    }
190298
private function foreignColumnImpl(
        string $localKey,
        string $foreignTable,
        string $foreignKey,
        string $type,
        ?int $length,
        bool $notNullable,
        bool $cascadeDelete
    ): Closure {
        return function (Table $table) use (
            $localKey,
            $foreignTable,
            $foreignKey,
            $notNullable,
            $cascadeDelete,
            $type,
            $length
        ) {
            $options = $cascadeDelete === true ? ['onDelete' => 'CASCADE'] : [];
            $column  = $table->addColumn($localKey, $type)->setNotnull($notNullable);
            $length === null ? $column->setUnsigned(true) : $column->setLength($length);
            $table->addForeignKeyConstraint($foreignTable, [$localKey], [$foreignKey], $options);
        };
    }
807695
private function build($rawString) {
        $rawString = str_replace('`, `','`,`', $rawString);
        $onDelete = '( ON DELETE (?P<onDelete>NO ACTION|RESTRICT|CASCADE|SET NULL))?';
        $onUpdate = '( ON UPDATE (?P<onUpdate>NO ACTION|RESTRICT|CASCADE|SET NULL))?';
        if(preg_match(
            '@^CONSTRAINT `(?P<name>[^`]+)` FOREIGN KEY \((?P<localColumns>[^\)]+)\) REFERENCES `(?P<remoteTable>[^`]+)` \((?P<remoteColumns>[^\)]+)\)' . $onDelete . $onUpdate . '$@',
            $rawString,
            $matches
        )) {
            $this->setName($matches['name']);
            $this->setLocalColumns(explode('`,`', trim($matches['localColumns'], '`')));
            $this->setRemoteTable($matches['remoteTable']);
            $this->setRemoteColumns(explode('`,`', trim($matches['remoteColumns'], '`')));
            if(isset($matches['onDelete'])) {
                $this->setDeleteAction($matches['onDelete']);
            }
            if(isset($matches['onUpdate'])) {
                $this->setUpdateAction($matches['onUpdate']);
            }
        }
    }
432986
protected function getDetailsActionsColumn()
    {
        return function ($row) {
            $btns    = [];
            $html    = app('html');
            $circles = [];
            foreach ([1, 2, 3] as $index) {
                array_push($circles, $html->create('i', '', ['class' => 'fa fa-circle']));
            }
            $section    = $html->create('div', $html->create('section', $html->create('ul', $html->raw(implode('', $btns)))), ['class' => 'mass-actions-menu'])->get();
            $indicators = $html->create('i', $html->raw(implode('', $circles)), ['class' => 'ma-trigger'])->get();
            return $html->raw(implode('', [$section, $indicators]))->get();
        };
    }
960286
protected function sortableUpdate()
    {
        $table = $this->getTableName();

        if (!$this->position || ($this->position && count($this->app['redbean']->find($table, 'position = ? AND id != ?', [$this->position, $this->id])))) {
            $position = $this->app['redbean']->getCell('SELECT position FROM '.$table.' ORDER BY position DESC LIMIT 1');
            $this->position = $position + 1;
        }
    }
1099451
public static function addForeignKey($table, $columns, $refTable, $refColumns, $delete = null, $update = null)
    {
        $name = static::createForeignKeyName($table, $columns, $refTable);
        return Yii::$app->db->createCommand()->addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete, $update)->execute();
    }
1080109
def fire_action_event
      return unless @list
      return unless @table_row_sorter
      require 'canis/core/include/ractionevent'
      # the header event must only be used if columns passed
      if header_row?
        # TODO we need to fire correct even for header row, including
        #alert "you are on header row: #{@columns[x]} curpos: #{@curpos}, x:#{x} "
        #aev = TextActionEvent.new self, :PRESS, @columns[x], x, @curpos
        x = _convert_curpos_to_column
        @table_row_sorter.toggle_sort_order x
        @table_row_sorter.sort
        @repaint_required = true
        aev = TextActionEvent.new self, :PRESS,:header, x, @curpos
      else
        # please check this again current_value due to _header_adjustment XXX test
        aev = TextActionEvent.new self, :PRESS, current_value(), @current_index, @curpos
      end
      fire_handler :PRESS, aev
    end
1178724
public function delete($where, $table = null)
    {
        $table = ($table) ?: $this->getTable();
        $sql = $this->getSql();
        $delete = $sql->delete($table);

        $delete->where($where);

        $statement = $sql->prepareStatementForSqlObject($delete);
        $result = $statement->execute();

        return $result->getAffectedRows();
    }
632317
public function replayTransactionLog($fromDate = null, $toDate = null)
    {
        return $this->getDataUpdater()->replayTransactionLog($fromDate, $toDate);
    }
501073
public function getUpdateSQL(Update $update)
        {
            if (!$this->query->getTable() instanceof Table) {
                throw new Exception('Trying to generate sql when no table is being used.');
            }
            $sql = $this->generateUpdateSQL($update);
            $sql .= $this->generateWhereSQL(true);

            return $sql;
        }
829526
public function addJoinColumn($columnName, $referencedColumnName, $nullable = true, $unique = false, $onDelete = null, $columnDef = null)
    {
        $this->joinColumns[] = array(
            'name' => $columnName,
            'referencedColumnName' => $referencedColumnName,
            'nullable' => $nullable,
            'unique' => $unique,
            'onDelete' => $onDelete,
            'columnDefinition' => $columnDef,
        );
        return $this;
    }
207335
protected function deleteExisting(CanResetPassword $user)
    {
        return $this->getTable()
                    ->delete($this->table)
                    ->where('email = :email')
                    ->setParameter('email', $user->getEmailForPasswordReset())
                    ->execute();
    }
913810
public function ItemEditForm() {
        $list=$this->gridField->getList();
        
        if(empty($this->record)) {
            $controller=$this->getToplevelController();
            $noActionURL=$controller->removeAction($_REQUEST['url']);
            
            $controller->getResponse()->removeHeader('Location');   //clear the existing redirect
            
            return $controller->redirect($noActionURL, 302);
        }

        $canView=$this->record->canView();
        $canEdit=$this->record->canEdit();
        $canDelete=$this->record->canDelete();
        $canCreate=$this->record->canCreate();

        if(!$canView) {
            return $this->getToplevelController()->httpError(403);
        }
        
        $actions=new FieldList();
        if($this->record->ID!==0) {
            if($canEdit) {
                $actions->push(FormAction::create('doSave', _t('GridFieldDetailForm.Save', 'Save'))
                                                ->setUseButtonTag(true)
                                                ->addExtraClass('ss-ui-action-constructive')
                                                ->setAttribute('data-icon', 'accept'));
            }
            
            if($canDelete) {
                $actions->push(FormAction::create('doDelete', _t('GridFieldDetailForm.Delete', 'Delete'))
                                                ->setUseButtonTag(true)
                                                ->addExtraClass('ss-ui-action-destructive action-delete'));
            }
        }else { // adding new record
            //Change the Save label to 'Create'
            $actions->push(FormAction::create('doSave', _t('GridFieldDetailForm.Create', 'Create'))
                                            ->setUseButtonTag(true)
                                            ->addExtraClass('ss-ui-action-constructive')
                                            ->setAttribute('data-icon', 'add'));
            
            // Add a Cancel link which is a button-like link and link back to one level up.
            $curmbs = $this->Breadcrumbs();
            if($curmbs && $curmbs->count()>=2){
                $one_level_up = $curmbs->offsetGet($curmbs->count()-2);
                $text=sprintf(
                    "<a class=\"%s\" href=\"%s\">%s</a>",
                    "crumb ss-ui-button ss-ui-action-destructive cms-panel-link ui-corner-all", // CSS classes
                    $one_level_up->Link, // url
                    _t('GridFieldDetailForm.CancelBtn', 'Cancel') // label
                );
                
                $actions->push(new LiteralField('cancelbutton', $text));
            }
        }
        
        // If we are creating a new record in a has-many list, then
        // pre-populate the record's foreign key.
        if($list instanceof HasManyList && !$this->record->isInDB()) {
            $key=$list->getForeignKey();
            $id=$list->getForeignID();
            $this->record->$key=$id;
        }
        
        $fields=$this->component->getFields();
        if(!$fields) {
            $fields=($this->record->hasMethod('getFrontEndFields') ? $this->record->getFrontEndFields():$this->record->getCMSFields());
        }
        
        // If we are creating a new record in a has-many list, then
        // Disable the form field as it has no effect.
        if($list instanceof HasManyList) {
            $key=$list->getForeignKey();
            
            if($field=$fields->dataFieldByName($key)) {
                $fields->makeFieldReadonly($field);
            }
        }
        
        // this pushes the current page ID in as a hidden field
        // this means the request will have the current page ID in it
        // rather than relying on session which can have been rewritten
        // by the user having another tab open
        // see LeftAndMain::currentPageID
        if($this->controller->hasMethod('currentPageID') && $this->controller->currentPageID()) {
            $fields->push(new HiddenField('CMSMainCurrentPageID', null, $this->controller->currentPageID()));
        }
        
        // Caution: API violation. Form expects a Controller, but we are giving it a RequestHandler instead.
        // Thanks to this however, we are able to nest GridFields, and also access the initial Controller by
        // dereferencing GridFieldDetailForm_ItemRequest->getController() multiple times. See getToplevelController
        // below.
        $form=new Form(
            $this,
            'ItemEditForm',
            $fields,
            $actions,
            $this->component->getValidator()
        );
        
        $form->loadDataFrom($this->record, ($this->record->ID==0 ? Form::MERGE_IGNORE_FALSEISH:Form::MERGE_DEFAULT));
        
        if($this->record->ID && !$canEdit) {
            // Restrict editing of existing records
            $form->makeReadonly();
            
            // Hack to re-enable delete button if user can delete
            if($canDelete) {
                $form->Actions()->fieldByName('action_doDelete')->setReadonly(false);
            }
        }else if(!$this->record->ID && !$canCreate) {
            // Restrict creation of new records
            $form->makeReadonly();
        }
        
        // Load many_many extraData for record.
        // Fields with the correct 'ManyMany' namespace need to be added manually through getCMSFields().
        if($list instanceof ManyManyList) {
            $extraData=$list->getExtraData('', $this->record->ID);
            $form->loadDataFrom(array('ManyMany' => $extraData));
        }
        
        $cb=$this->component->getItemEditFormCallback();
        if($cb) {
            $cb($form, $this);
        }
        
        $this->extend("updateItemEditForm", $form);
        return $form;
    }
96329
function update( $data ) {

        // if this is an association result or it is limited,
        // create specific result for local rows and execute

        if ( $this->parent_ || isset( $this->limitCount ) ) {

            return $this->primaryResult()->update( $data );

        }

        return $this->db->update( $this->table, $data, $this->where, $this->whereParams );

    }
743980
public function remove($action, $id = null)
    {
        /** @var $query \eZ\Publish\Core\Persistence\Database\DeleteQuery */
        $query = $this->dbHandler->createDeleteQuery();
        $query->deleteFrom(
            $this->dbHandler->quoteTable($this->table)
        )->where(
            $query->expr->eq(
                $this->dbHandler->quoteColumn('action'),
                $query->bindValue($action, null, \PDO::PARAM_STR)
            )
        );

        if ($id !== null) {
            $query->where(
                $query->expr->lAnd(
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn('is_alias'),
                        $query->bindValue(0, null, \PDO::PARAM_INT)
                    ),
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn('id'),
                        $query->bindValue($id, null, \PDO::PARAM_INT)
                    )
                )
            );
        }

        $query->prepare()->execute();
    }
396348
protected function visitSirelNodeDeleteStatement(Node\DeleteStatement $delete)
    {
        return join(' ', array_filter(array(
            "DELETE FROM " . $this->visit($delete->relation),
            
            // WHERE
            ($delete->restrictions
                ? "WHERE " . join(" AND ", $this->visitEach($delete->restrictions))
                : null
            ),

            // ORDER BY
            ($delete->orders
                ? "ORDER BY " . join(", ", $this->visitEach($delete->orders))
                : null),
            
            // LIMIT
            ($delete->limit ? $this->visit($delete->limit) : null),

            // OFFSET 
            ($delete->offset ? $this->visit($delete->offset) : null)
        ))) . ';';
    }