Log a users action.

@param int $action
@param Model $model
@param int $id
@param string $comment
@param string $item
@return bool
@throws InvalidArgumentException
553230
public function logAction($action, Model $model = null, $id = null, $comment = null, $item = null) {
        if (!Configure::read('Admin.logActions')) {
            return false;
        }

        $log = ClassRegistry::init('Admin.ActionLog');
        $query = array(
            'user_id' => $this->Auth->user('id'),
            'action' => $action
        );

        // Validate action
        if (!$log->enum('action', $action)) {
            throw new InvalidArgumentException(__d('admin', 'Invalid log action type'));
        }

        if ($model) {
            $query['model'] = ($model->plugin ? $model->plugin . '.' : '') . $model->name;

            // Get comment from request
            if (!$comment && isset($this->Controller->request->data[$model->alias]['log_comment'])) {
                $comment = $this->Controller->request->data[$model->alias]['log_comment'];
            }

            // Get display field from data
            if (!$item) {
                if (isset($model->data[$model->alias][$model->displayField])) {
                    $item = $model->data[$model->alias][$model->displayField];
                }
            }
        }

        $query['foreign_key'] = (string) $id;
        $query['comment'] = $comment;
        $query['item'] = $item;

        return $log->logAction($query);
    }
190941
protected function eventableAction(
        /*# string */ $action,
        /*# string */ $beforeEvent,
        /*# string */ $afterEvent,
        CacheItemInterface $item = null
    )/*# : bool */ {
        $param = ['item' => $item];
        if (!$this->trigger($beforeEvent, $param)) {
            return false;
        }
        if (!$this->driverAction($action, $item)) {
            $this->copyError($this->getDriver());
            return false;
        }
        if (!$this->trigger($afterEvent, $param)) {
            return false;
        }
        return $this->flushError();
    }
1281285
function ReportUserGroupAction(Usergroup $userGroup, Enums\Action $action)
    {
        $logItem = $this->CreateLogItem(Enums\ObjectType::UserGroup(), $action);       
        if (!$action->Equals(Enums\Action::Delete()))
        {
            $logUserGroup = new LogUsergroup();
            $logUserGroup->SetLogItem($logItem);
            $logUserGroup->SetUserGroup($userGroup);
            $logUserGroup->Save();
        }
    }
916155
public function action($action, $parameters = [], $absolute = true)
    {
        if (is_null($route = $this->routes->getByAction($action = $this->formatAction($action)))) {
            throw new InvalidArgumentException("Action {$action} not defined.");
        }

        return $this->toRoute($route, $parameters, $absolute);
    }
607623
protected function updateWithAction($id, $action, $actionArg = null, $object = null, $class = null)
    {
        return $this->requestAction(RequestOps::UPDATE, $action, $id, $actionArg, $object, $class);
    }
356480
private function logEventsToDB($model)
    {
        $user = auth()->user();
        $class = get_class($model);
        $trace = debug_backtrace();
        $event = $trace[2] ? $trace[2]['function'] : "Unknown event";

        try {
            UserAction::create(
                array_merge($this->getDiff($model), [
                    'model' => $class,
                    'action' => $event,
                    'user_id' => $user ? $user->id : null,
                    'model_id' => $model->id,
                ])
            );
        } catch (\Exception $e) {
            $message = $e->getMessage();
            Log::error("Could not record user action to db: '{$message}'");
        }
    }
514296
protected function actionLink($action, $member = null)
    {
        if (!$member) {
            $member = Member::currentUser();
        }
        if (!$member) {
            return false;
        }

        /**
         * @todo: How do we handle "DataObject" instances that don't have a Link to reject/spam/delete?? This may
         * we have to make CMS a hard dependency instead.
         */
        // if (!$this->Parent()->hasMethod('Link')) {
        //     return false;
        // }

        $url = Controller::join_links(
            Director::baseURL(),
            'comments',
            $action,
            $this->ID
        );

        // Limit access for this user
        $token = $this->getSecurityToken();
        return $token->addToUrl($url, $member);
    }
495832
public function isAction($action)
    {
        $isAction = parent::isAction($action);
        if ($isAction) {
            return true;
        }

        if ($this->_isActionMapped()) {
            return true;
        }

        return false;
    }
159552
public function log(string $action, string $entity, array $dados)
    {
        if (!empty($dados['id'])) {
            $store = new Json("store/{$entity}");

            if (!empty($_SESSION['userlogin']))
                $dados['userlogin'] = $_SESSION['userlogin']['id'];

            if ($action === "delete")
                $store->delete($dados['id']);
            else
                $store->save($dados['id'], $dados);
        }
    }
1002410
public function _execute( $action, $params = array() ) 
	{
		if ( method_exists( $this, 'action_'.$action ) ) 
		{
			call_user_func( array( $this, 'action_'.$action ), $params );
		} 
		else 
		{
			CCCli::line( "There is no action {$action}.", 'red' );
		}
	}
942186
public void runAction(ActionType action) {

        m_mode = action;
        setActionFlags();
        setCommonParameters();
        m_checkinBean.clearModules();
        for (String moduleName : getSelectedModules()) {
            m_checkinBean.addModuleToExport(moduleName);
        }
        int result = m_checkinBean.checkIn();
        String log = m_checkinBean.getLogText();
        String message = null;
        boolean error = false;
        switch (action) {
            case checkIn:
                String messageToSave = m_checkinBean.getCommitMessage();
                String emailToSave = m_checkinBean.getGitUserEmail();
                String userToSave = m_checkinBean.getGitUserName();
                CmsObject cms = m_checkinBean.getCmsObject();
                CmsUser user = cms.getRequestContext().getCurrentUser();
                setUserInfo(user, ADDINFO_USER, userToSave);
                setUserInfo(user, ADDINFO_EMAIL, emailToSave);
                setUserInfo(user, ADDINFO_MESSAGE, messageToSave);
                try {
                    cms.writeUser(user);
                } catch (CmsException e) {
                    LOG.error(e.getLocalizedMessage(), e);
                }

                List<Button> resetButtons = new ArrayList<Button>();

                Button resetHead = new Button(CmsVaadinUtils.getMessageText(Messages.GUI_GIT_BUTTON_RESET_HEAD_0));
                resetHead.setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_GIT_BUTTON_RESET_HEAD_DESC_0));
                resetHead.addClickListener(new ClickListener() {

                    private static final long serialVersionUID = 1L;

                    public void buttonClick(ClickEvent event) {

                        runAction(ActionType.resetHead);
                    }
                });

                Button resetRemoteHead = new Button(
                    CmsVaadinUtils.getMessageText(Messages.GUI_GIT_BUTTON_RESET_REMOTE_HEAD_0));
                resetRemoteHead.setDescription(
                    CmsVaadinUtils.getMessageText(Messages.GUI_GIT_BUTTON_RESET_REMOTE_HEAD_DESC_0));
                resetRemoteHead.addClickListener(new ClickListener() {

                    private static final long serialVersionUID = 1L;

                    public void buttonClick(ClickEvent event) {

                        runAction(ActionType.resetRemoteHead);
                    }
                });

                if (result == 0) {
                    message = CmsVaadinUtils.getMessageText(Messages.GUI_GIT_CHECKIN_SUCCESSFUL_0);
                } else if (result == 10) {
                    message = CmsVaadinUtils.getMessageText(Messages.GUI_GIT_CHECKIN_FAILED_0);
                    error = true;
                    resetButtons.add(resetRemoteHead);
                    resetButtons.add(resetHead);
                } else {
                    message = CmsVaadinUtils.getMessageText(Messages.GUI_GIT_CHECKIN_FAILED_0);
                    error = true;
                    resetButtons.add(resetRemoteHead);
                }
                CmsGitActionResultPanel panel = new CmsGitActionResultPanel(message, log, error, resetButtons);
                addAsWindow(panel);
                break;
            case checkOut:
                if (result == 0) {
                    message = CmsVaadinUtils.getMessageText(Messages.GUI_GIT_IMPORT_SUCCESSFUL_0);
                } else {
                    message = CmsVaadinUtils.getMessageText(Messages.GUI_GIT_IMPORT_FAILED_0);
                }
                CmsGitActionResultPanel checkoutResult = new CmsGitActionResultPanel(
                    message,
                    log,
                    error,
                    new ArrayList<Button>());
                addAsWindow(checkoutResult);
                break;
            case resetHead:
                if (result == 0) {
                    message = CmsVaadinUtils.getMessageText(Messages.GUI_GIT_RESET_SUCCESSFUL_0);
                } else {
                    error = true;
                    message = CmsVaadinUtils.getMessageText(Messages.GUI_GIT_RESET_FAILED_0);
                }
                CmsGitActionResultPanel resetResult = new CmsGitActionResultPanel(
                    message,
                    log,
                    error,
                    new ArrayList<Button>());
                addAsWindow(resetResult);
                break;
            case resetRemoteHead:
                if (result == 0) {
                    message = CmsVaadinUtils.getMessageText(Messages.GUI_GIT_RESET_SUCCESSFUL_0);
                } else {
                    error = true;
                    message = CmsVaadinUtils.getMessageText(Messages.GUI_GIT_RESET_FAILED_0);
                }
                CmsGitActionResultPanel resetRemoteResult = new CmsGitActionResultPanel(
                    message,
                    log,
                    error,
                    new ArrayList<Button>());
                addAsWindow(resetRemoteResult);
                break;
            default:
                // Should never happen
        }
    }
1272931
protected function doAction($action, $stateOrRule)
    {
        if ($action == 'S') {
            $this->shift($stateOrRule);
        } elseif ($action == 'R') {
            $this->reduce($stateOrRule);
        } else {
            throw new InvalidGrammarException($this->translate(
                'Invalid grammar action "{action}" for {state}-{current}. Available actions: "F", "S", "R".',
                [
                    'action'  => $action,
                    'state'   => $this->getState(),
                    'current' => $this->current->getName()
                ]
            ));
        }
    }
790429
private function outputPageAction($name, $action)
    {
        $this->output->writeln(sprintf(
            '- <comment>%s</comment> %s %s.',
            $name,
            str_pad('.', 44 - mb_strlen($name), '.', STR_PAD_LEFT),
            $action
        ));
    }
182683
public function tags_queue($tag_info = array(), $action = null)
    {

        if( ! isset($tag_info['item_id']) ) {
            throw new NoItemException("No item id was sent");
        } else if ( ! is_numeric($tag_info['item_id']) ){
            throw new InvalidItemTypeException("The item id: {$tag_info['item_id']} is not valid it should be a number");
        }

        if( sizeof($tag_info['tags']) == 0 ) {
            throw new NoItemException("No tags received");
        }
        
        $base_info  = array(
            'action'        => $action,
            'time'          => time()
        );

        $tag_info = array_merge($base_info, $tag_info);

        $this->actions[] = $tag_info;

        return true;

    }
314189
public function getData($action, $key)
    {
        if (!is_string($action) || empty($action)) {
            throw new \InvalidArgumentException('The action name is invalid');
        }

        if (!is_string($key) || empty($key)) {
            throw new \InvalidArgumentException('The data key name is invalid');
        }

        return $this->data[$action][$key];
    }
1074174
public static function runAction($db, $model, $action)
    {
        $res = $db->getConnection()->select($action['sql'], [], false);
        if ($action['action'] === 'create_table') {
            $model->onCreate();
        }
        return $res;
    }
1169995
public function beforeAction($action)
	{
		try {
			@Yii::app()->newRelic->setTransactionName($this->id, $action->id);
		} catch (Exception $e) {} // Ignore errors if NewRelic isn't installed/configured properly

		// Force SSL for secure areas if enabled from the dashboard
		if (!Yii::app()->getRequest()->isSecureConnection && Cii::getConfig('forceSecureSSL', false))
			$this->redirect('https://' . Yii::app()->getRequest()->serverName . Yii::app()->getRequest()->requestUri);

		// If content was sent as application/x-www-form-urlencoded, use it. Otherwise, assume raw JSON was sent and convert it into
		// the $_POST variable for ease of use
		if (Yii::app()->request->rawBody != "" && empty($_POST))
		{
			// IF the rawBody is malformed, throw an HTTP 500 error. Use json_encode so that we can get json_last_error
			$_POST = json_decode(Yii::app()->request->rawBody);
			if (json_last_error() != JSON_ERROR_NONE)
			{
				header('HTTP/1.1 400 Bad Request');
				$this->status = 400;
				$this->message = Yii::t('Api.main', 'Request payload not properly formed JSON.');
				return null;
			}

			$_POST = CJSON::decode(Yii::app()->request->rawBody);
		}

		return true;
	}