Processes a single action against a category, grade_item or grade.
@param string $target eid ({type}{id}, e.g. c4 for category4)
@param string $action Which action to take (edit, delete etc...)
@param int $courseid affected course.
@return
189726
public static function do_process_action($target, $action, $courseid = null) {
        global $DB;
        // TODO: this code should be in some grade_tree static method
        $targettype = substr($target, 0, 2);
        $targetid = substr($target, 2);
        // TODO: end

        if ($targettype !== 'cg') {
            // The following code only works with categories.
            return true;
        }

        if (!$courseid) {
            debugging('Function grade_report_grader::do_process_action() now requires additional argument courseid',
                DEBUG_DEVELOPER);
            if (!$courseid = $DB->get_field('grade_categories', 'courseid', array('id' => $targetid), IGNORE_MISSING)) {
                return true;
            }
        }

        $collapsed = static::get_collapsed_preferences($courseid);

        switch ($action) {
            case 'switch_minus': // Add category to array of aggregatesonly
                if (!in_array($targetid, $collapsed['aggregatesonly'])) {
                    $collapsed['aggregatesonly'][] = $targetid;
                    static::set_collapsed_preferences($courseid, $collapsed);
                }
                break;

            case 'switch_plus': // Remove category from array of aggregatesonly, and add it to array of gradesonly
                $key = array_search($targetid, $collapsed['aggregatesonly']);
                if ($key !== false) {
                    unset($collapsed['aggregatesonly'][$key]);
                }
                if (!in_array($targetid, $collapsed['gradesonly'])) {
                    $collapsed['gradesonly'][] = $targetid;
                }
                static::set_collapsed_preferences($courseid, $collapsed);
                break;
            case 'switch_whole': // Remove the category from the array of collapsed cats
                $key = array_search($targetid, $collapsed['gradesonly']);
                if ($key !== false) {
                    unset($collapsed['gradesonly'][$key]);
                    static::set_collapsed_preferences($courseid, $collapsed);
                }

                break;
            default:
                break;
        }

        return true;
    }
274931
protected function applyBulk( $model, $column, $action, $target, $config = [] ) {

		switch( $column ) {

			case 'status': {

				switch( $action ) {

					case 'active': {

						$this->approve( $model );

						// TODO: Trigger activate email

						break;
					}
					case 'block': {

						$this->block( $model );

						// TODO: Trigger block email

						break;
					}
				}

				break;
			}
			case 'model': {

				switch( $action ) {

					case 'delete': {

						$this->delete( $model );

						break;
					}
				}

				break;
			}
		}
	}
1173362
public void delete(String targetId) throws IOException {
        startChangesIfNecessary();
        ResponseWriter writer = getWrapped();
        writer.startElement("delete", null);
        writer.writeAttribute("id", targetId, null);
        writer.endElement("delete");
    }
854037
protected function process(Action $action, EnvironmentInterface $environment)
    {
        if ($environment->getDataDefinition()->getBasicDefinition()->isEditOnlyMode()) {
            return $environment->getView()->edit($action);
        }

        $modelId      = ModelId::fromSerialized($environment->getInputProvider()->getParameter('id'));
        $dataProvider = $environment->getDataProvider($modelId->getDataProviderName());
        $translator   = $environment->getTranslator();
        $model        = $this->getModel($environment);
        $data         = $this->convertModel($model, $environment);

        $template = (new ContaoBackendViewTemplate('dcbe_general_show'))
            ->set('headline', $this->getHeadline($translator, $model))
            ->set('arrFields', $data['values'])
            ->set('arrLabels', $data['labels']);

        if ($dataProvider instanceof MultiLanguageDataProviderInterface) {
            $template
                ->set('languages', $environment->getController()->getSupportedLanguages($model->getId()))
                ->set('currentLanguage', $dataProvider->getCurrentLanguage())
                ->set('languageSubmit', $translator->translate('MSC.showSelected'))
                ->set('backBT', StringUtil::specialchars($translator->translate('MSC.backBT')));
        } else {
            $template->set('languages', null);
        }

        return $template->parse();
    }
132258
public function update($reactionId, array $data=null, array $targetFeeds=null)
    {
        $payload = [];
        if( $data !== null ){
            $payload['data'] = $data;
        }
        if( $targetFeeds !== null ){
            $payload['target_feeds'] = $targetFeeds;
        }
        $response = $this->doRequest('PUT', 'reaction/' . $reactionId . '/', $payload);
        $body = $response->getBody()->getContents();
        return json_decode($body, true);
    }
856288
public static function get_records_by_competencyid_in_course($competencyid, $courseid) {
        global $DB;

        $sql = 'SELECT cmc.*
                  FROM {' . self::TABLE . '} cmc
                  JOIN {course_modules} cm
                    ON cm.course = ?
                   AND cmc.cmid = cm.id
                 WHERE cmc.competencyid = ?
              ORDER BY cmc.sortorder ASC';
        $params = array($courseid, $competencyid);

        $results = $DB->get_recordset_sql($sql, $params);
        $instances = array();
        foreach ($results as $result) {
            $instances[$result->id] = new course_module_competency(0, $result);
        }
        $results->close();

        return $instances;
    }
849660
protected function inner_process($action){
		
		if ($this->connector->sql->is_record_transaction())
				$this->connector->sql->begin_transaction();		
		
		try{
				
			$mode = $this->status_to_mode($action->get_status());
			if (!$this->connector->access->check($mode)){
				LogMaster::log("Access control: {$mode} operation blocked");
				$action->error();
			} else {
				$check = $this->connector->event->trigger("beforeProcessing",$action);
				if (!$action->is_ready())
					$this->check_exts($action,$mode);
				if ($mode == "insert" && $action->get_status() != "error" && $action->get_status() != "invalid")
					$this->connector->sql->new_record_order($action, $this->request);

				$check = $this->connector->event->trigger("afterProcessing",$action);
			}
		
		} catch (Exception $e){
			LogMaster::log($e);
			$action->set_status("error");
			if ($action)
				$this->connector->event->trigger("onDBError", $action, $e);
		}  
		
		if ($this->connector->sql->is_record_transaction()){
			if ($action->get_status()=="error" || $action->get_status()=="invalid")
				$this->connector->sql->rollback_transaction();
			else
				$this->connector->sql->commit_transaction();
		}

		return $action;
	}
365409
public function updateTarget(Target $target): void
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->update('ngbm_rule_target')
            ->set('rule_id', ':rule_id')
            ->set('type', ':type')
            ->set('value', ':value')
            ->where(
                $query->expr()->eq('id', ':id')
            )
            ->setParameter('id', $target->id, Type::INTEGER)
            ->setParameter('rule_id', $target->ruleId, Type::INTEGER)
            ->setParameter('type', $target->type, Type::STRING)
            ->setParameter('value', $target->value, is_array($target->value) ? Type::JSON_ARRAY : Type::STRING);

        $this->applyStatusCondition($query, $target->status);

        $query->execute();
    }
714834
public function applyBulkByGroupId( $column, $action, $target, $groupId ) {

		foreach( $target as $id ) {

			$model = $this->getById( $id );

			if( isset( $model ) && !$model->isTerminated() && $model->groupId == $groupId ) {

				$this->applyBulk( $model, $column, $action, $target );
			}
		}
	}
166106
protected function process(Action $action, EnvironmentInterface $environment)
    {
        // Edit only mode, forward to edit action.
        if ($environment->getDataDefinition()->getBasicDefinition()->isEditOnlyMode()) {
            return $this->callAction($environment, 'edit', $action->getArguments());
        }

        $grouping = ViewHelpers::getGroupingMode($environment);

        Message::reset();

        // Process now.
        $collection = $this->loadCollection($environment);
        $this->handleEditAllButton($collection, $environment);
        $this->renderCollection($environment, $collection, $grouping);

        $template = $this->determineTemplate($grouping)
            ->set('collection', $collection)
            ->set('mode', ($grouping ? $grouping['mode'] : null))
            ->set('theme', Backend::getTheme());
        $this->renderTemplate($template, $environment);

        $clipboard = new ViewEvent($environment, $action, DcGeneralViews::CLIPBOARD, []);
        $environment->getEventDispatcher()->dispatch(DcGeneralEvents::VIEW, $clipboard);

        return \implode(
            "\n",
            [
                'language'  => $this->languageSwitcher($environment),
                'panel'     => $this->panel($environment),
                'buttons'   => $this->generateHeaderButtons($environment),
                'clipboard' => $clipboard->getResponse(),
                'body'      => $template->parse()
            ]
        );
    }
417777
public function use_in($courseid) {
        global $DB;
        if (!empty($this->courseid) and $courseid != $this->courseid) {
            return false;
        }

        if (!$DB->record_exists('grade_outcomes_courses', array('courseid' => $courseid, 'outcomeid' => $this->id))) {
            $goc = new stdClass();
            $goc->courseid  = $courseid;
            $goc->outcomeid = $this->id;
            $DB->insert_record('grade_outcomes_courses', $goc);
        }
        return true;
    }
813786
public function Sort($Target = '') {
      if (!Gdn::Session()->IsValid())
         throw PermissionException();
         
      if (!$this->Request->IsAuthenticatedPostBack())
         throw ForbiddenException('GET');
      
      // Get param
      $SortField = Gdn::Request()->Post('DiscussionSort');
      $SortField = 'd.'.StringBeginsWith($SortField, 'd.', TRUE, TRUE);
      
      // Use whitelist here too to keep database clean
      if (!in_array($SortField, DiscussionModel::AllowedSortFields())) {
         throw new Gdn_UserException("Unknown sort $SortField.");
      }
      
      // Set user pref
      Gdn::UserModel()->SavePreference(Gdn::Session()->UserID, 'Discussions.SortField', $SortField);
      
      if ($Target)
         Redirect($Target);
      
      // Send sorted discussions.
      $this->DeliveryMethod(DELIVERY_METHOD_JSON);
      $this->Render();
   }
1270255
public function applyBulkByTargetId( $column, $action, $target, $config = [] ) {

		foreach ( $target as $id ) {

			$model = $this->getById( $id );

			// Bulk Conditions
			if( isset( $model ) ) {

				$this->applyBulk( $model, $column, $action, $target, $config );
			}
		}
	}
1225137
protected function executeClassOrPropertyCommand($action, $class, $property = null, $type = null, $linked = null)
    {
        if ($property) {
            return $this->manageProperty($action, $class, $property, $type, $linked);
        }

        return $this->manageClass($action, $class);
    }
768171
public function getActionHandler($action_id)
    {
        $handlers = $this->getActionHandlers();
        return empty($handlers[$action_id]) ? array() : $handlers[$action_id];
    }
243961
public static function add_competency_to_course($courseid, $competencyid) {
        $params = self::validate_parameters(self::add_competency_to_course_parameters(), array(
            'courseid' => $courseid,
            'competencyid' => $competencyid,
        ));
        self::validate_context(context_course::instance($params['courseid']));
        return api::add_competency_to_course($params['courseid'], $params['competencyid']);
    }
707858
public function deleteAction($categoryId, $keywordId)
    {
        $keyword = $this->getKeywordRepository()->findById($keywordId);
        $category = $this->getCategoryRepository()->findCategoryById($categoryId);
        $this->getKeywordManager()->delete($keyword, $category);

        $this->getEntityManager()->flush();

        return $this->handleView($this->view());
    }