Save criteria records

@param array $params Values from the form or any other array.
347297
public function save($params = array()) {
        $badges = $params['badge_badges'];
        unset($params['badge_badges']);
        foreach ($badges as $badgeid) {
            $params["badge_{$badgeid}"] = $badgeid;
        }

        parent::save($params);
    }
493055
public function createOrder(Array $params)
    {
        $createOrderRequest = $this->getRequestParam('CreateOrderRequestParam', $params, $this->config, $this->sign);

        $formContent = $this->executeFormRequest($createOrderRequest);

        echo $formContent;
    }
865212
public function setParams(array $params = [])
    {
        if (isset($params['access_token'])) {
            $this->setAccessTokenFromParams($params['access_token']);
        }

        unset($params['access_token']);

        $params = $this->sanitizeFileParams($params);
        $this->dangerouslySetParams($params);

        return $this;
    }
385129
public function setParams( $params )
    {
        if ( $params instanceof Traversable )
        {
            $params = iterator_to_array( $params );
        }
        else if ( is_object( $params ) && ! $params instanceof ArrayAccess )
        {
            $params = (array) $params;
        }

        return parent::setParams( $params );
    }
729966
public function saveItems( \stdClass $params )
	{
		$this->checkParams( $params, array( 'site', 'items' ) );
		$this->setLocale( $params->site );

		$ids = [];
		$manager = $this->getManager();
		$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );

		foreach( $items as $entry )
		{
			$item = $manager->createItem();
			$item->fromArray( (array) $this->transformValues( $entry ) );
			$item = $manager->saveItem( $item );
			$ids[] = $item->getId();
		}

		$this->clearCache( $ids );

		$search = $manager->createSearch();
		$search->setConditions( $search->compare( '==', 'service.id', $ids ) );
		$search->setSlice( 0, count( $ids ) );
		$result = $manager->searchItems( $search );

		foreach( $result as $item ) {
			$this->checkConfig( $item );
		}

		$items = $this->toArray( $result );

		return array(
			'items' => ( !is_array( $params->items ) ? reset( $items ) : $items ),
			'success' => true,
		);
	}
974314
public function setPersParams($aParams)
    {
        $this->_aPersParam = $aParams;

        // serializing persisten info stored while ordering
        $this->oxorderarticles__oxpersparam = new \OxidEsales\Eshop\Core\Field(serialize($aParams), \OxidEsales\Eshop\Core\Field::T_RAW);
    }
617737
public function queryValue($params = array())
    {
        $this->mergeParams($params);
        $this->beginQuery();
        $rst = $this->statement->fetchColumn();
        $this->statement->closeCursor();

        return $rst;
    }
1063549
public function saveItems( stdClass $params )
	{
		$this->_checkParams( $params, array( 'site', 'items' ) );
		$this->_setLocale( $params->site );

		$ids = $refIds = $domains = array();
		$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );

		foreach( $items as $entry )
		{
			$item = $this->_createItem( (array) $entry );
			$this->_manager->saveItem( $item );

			$domains[ $item->getDomain() ] = true;
			$refIds[] = $item->getRefId();
			$ids[] = $item->getId();
		}


		if( isset( $domains['product'] ) )
		{
			$context = $this->_getContext();
			$productManager = MShop_Factory::createManager( $context, 'product' );

			$search = $productManager->createSearch();
			$search->setConditions( $search->compare( '==', 'product.id', $refIds ) );
			$search->setSlice( 0, count( $refIds ) );

			$indexManager = MShop_Factory::createManager( $context, 'catalog/index' );
			$indexManager->rebuildIndex( $productManager->searchItems( $search ) );
		}


		$search = $this->_manager->createSearch();
		$search->setConditions( $search->compare( '==', 'catalog.list.id', $ids ) );
		$search->setSlice( 0, count( $ids ) );
		$items = $this->_toArray( $this->_manager->searchItems( $search ) );

		return array(
			'items' => ( !is_array( $params->items ) ? reset( $items ) : $items ),
			'success' => true,
		);
	}
1285604
public function setSqlParameters(array $params)
    {
        $this->params = $params;

        $this->stmt = null;
        $this->rowCount = null;
    }
315399
public function saveItems( \stdClass $params )
	{
		$this->checkParams( $params, array( 'items' ) );

		$ids = [];
		$manager = $this->getManager();
		$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );

		foreach( $items as $entry )
		{
			$item = $manager->createItem();
			$item->fromArray( (array) $this->transformValues( $entry ) );
			$item = $manager->saveItem( $item );
			$ids[] = $item->getId();
		}

		return $this->getItems( $ids, $this->getPrefix() );
	}
201003
public function Save($FormPostValues) {
      // Define the primary key in this model's table.
      $this->DefineSchema();
      
      // Get data from form
      $CategoryID = ArrayValue('CategoryID', $FormPostValues);
      $NewName = ArrayValue('Name', $FormPostValues, '');
      $UrlCode = ArrayValue('UrlCode', $FormPostValues, '');
      $AllowDiscussions = ArrayValue('AllowDiscussions', $FormPostValues, '');
      $CustomPermissions = (bool)GetValue('CustomPermissions', $FormPostValues);
      $CustomPoints = GetValue('CustomPoints', $FormPostValues, NULL);
      
      // Is this a new category?
      $Insert = $CategoryID > 0 ? FALSE : TRUE;
      if ($Insert)
         $this->AddInsertFields($FormPostValues);               

      $this->AddUpdateFields($FormPostValues);
      $this->Validation->ApplyRule('UrlCode', 'Required');
      $this->Validation->ApplyRule('UrlCode', 'UrlStringRelaxed');

      // Make sure that the UrlCode is unique among categories.
      $this->SQL->Select('CategoryID')
         ->From('Category')
         ->Where('UrlCode', $UrlCode);

      if ($CategoryID)
         $this->SQL->Where('CategoryID <>', $CategoryID);

      if ($this->SQL->Get()->NumRows())
         $this->Validation->AddValidationResult('UrlCode', 'The specified url code is already in use by another category.');

		//	Prep and fire event.
		$this->EventArguments['FormPostValues'] = &$FormPostValues;
		$this->EventArguments['CategoryID'] = $CategoryID;
		$this->FireEvent('BeforeSaveCategory');
      
      // Validate the form posted values
      if ($this->Validate($FormPostValues, $Insert)) {
         $Fields = $this->Validation->SchemaValidationFields();
         $Fields = RemoveKeyFromArray($Fields, 'CategoryID');
         $AllowDiscussions = ArrayValue('AllowDiscussions', $Fields) == '1' ? TRUE : FALSE;
         $Fields['AllowDiscussions'] = $AllowDiscussions ? '1' : '0';

         if ($Insert === FALSE) {
            $OldCategory = $this->GetID($CategoryID, DATASET_TYPE_ARRAY);
            $AllowDiscussions = $OldCategory['AllowDiscussions']; // Force the allowdiscussions property
            $Fields['AllowDiscussions'] = $AllowDiscussions ? '1' : '0';
            
            // Figure out custom points.
            if ($CustomPoints !== NULL) {
               if ($CustomPoints) {
                  $Fields['PointsCategoryID'] = $CategoryID;
               } else {
                  $Parent = self::Categories(GetValue('ParentCategoryID', $Fields, $OldCategory['ParentCategoryID']));
                  $Fields['PointsCategoryID'] = GetValue('PointsCategoryID', $Parent, 0);
               }
            }
            
            $this->Update($Fields, array('CategoryID' => $CategoryID));
            
            // Check for a change in the parent category.
            if (isset($Fields['ParentCategoryID']) && $OldCategory['ParentCategoryID'] != $Fields['ParentCategoryID']) {
               $this->RebuildTree();
            } else {
               $this->SetCache($CategoryID, $Fields);
            }
         } else {
            $CategoryID = $this->Insert($Fields);

            if ($CategoryID) {
               if ($CustomPermissions) {
                  $this->SQL->Put('Category', array('PermissionCategoryID' => $CategoryID), array('CategoryID' => $CategoryID));
               }
               if ($CustomPoints) {
                  $this->SQL->Put('Category', array('PointsCategoryID' => $CategoryID), array('CategoryID' => $CategoryID));
               }
            }

            $this->RebuildTree(); // Safeguard to make sure that treeleft and treeright cols are added
         }
         
         // Save the permissions
         if ($AllowDiscussions && $CategoryID) {
            // Check to see if this category uses custom permissions.
            if ($CustomPermissions) {
               $PermissionModel = Gdn::PermissionModel();
               $Permissions = $PermissionModel->PivotPermissions(GetValue('Permission', $FormPostValues, array()), array('JunctionID' => $CategoryID));
               $PermissionModel->SaveAll($Permissions, array('JunctionID' => $CategoryID, 'JunctionTable' => 'Category'));

               if (!$Insert) {
                  // Figure out my last permission and tree info.
                  $Data = $this->SQL->Select('PermissionCategoryID, TreeLeft, TreeRight')->From('Category')->Where('CategoryID', $CategoryID)->Get()->FirstRow(DATASET_TYPE_ARRAY);

                  // Update this category's permission.
                  $this->SQL->Put('Category', array('PermissionCategoryID' => $CategoryID), array('CategoryID' => $CategoryID));

                  // Update all of my children that shared my last category permission.
                  $this->SQL->Put('Category',
                     array('PermissionCategoryID' => $CategoryID),
                     array('TreeLeft >' => $Data['TreeLeft'], 'TreeRight <' => $Data['TreeRight'], 'PermissionCategoryID' => $Data['PermissionCategoryID']));
                  
                  self::ClearCache();
               }
            } elseif (!$Insert) {
               // Figure out my parent's permission.
               $NewPermissionID = $this->SQL
                  ->Select('p.PermissionCategoryID')
                  ->From('Category c')
                  ->Join('Category p', 'c.ParentCategoryID = p.CategoryID')
                  ->Where('c.CategoryID', $CategoryID)
                  ->Get()->Value('PermissionCategoryID', 0);

               if ($NewPermissionID != $CategoryID) {
                  // Update all of my children that shared my last permission.
                  $this->SQL->Put('Category',
                     array('PermissionCategoryID' => $NewPermissionID),
                     array('PermissionCategoryID' => $CategoryID));
                  
                  self::ClearCache();
               }

               // Delete my custom permissions.
               $this->SQL->Delete('Permission',
                  array('JunctionTable' => 'Category', 'JunctionColumn' => 'PermissionCategoryID', 'JunctionID' => $CategoryID));
            }
         }
         
         // Force the user permissions to refresh.
         Gdn::UserModel()->ClearPermissions();
         
         // $this->RebuildTree();
      } else {
         $CategoryID = FALSE;
      }
      
      return $CategoryID;
   }
1360810
public function setParameters(array $params)
	{
		foreach ($params as $paramName => $paramValue)
		{
			$this->setParameter($paramName, $paramValue);
		}
	}
502585
public function prepare($params)
    {
        $this->params = !empty($params) ? $params[ 0 ] : [ ];

        // force mandatory fields
        $this->filter();
        $this->maxRecords();
    }
583079
public function save( $params = array() ) {

		$defaults = array(
			'file'   => null,
			'path'   => null,
			'attach' => false,
		);

		$params = array_merge( $defaults, $params );

		$extension = 'txt';

		if ( ! empty( $params['file'] ) ) {
			$export_file = $params['file'];

			if ( false !== strpos( $export_file, '.' ) ) {
				$extension = explode( '.', $export_file );
				$extension = end( $extension );
			}
		} else {
			if ( 'sv' === $this->type ) {
				if ( ',' === $this->delimiter ) {
					$extension = 'csv';
				} elseif ( "\t" === $this->delimiter ) {
					$extension = 'tsv';
				}
			} else {
				$extension = $this->type;
			}

			$export_file = sprintf(
				'pods_export_%s.%s',
				wp_create_nonce( date_i18n( 'm-d-Y_h-i-sa' ) ),
				$extension
			);
		}

		if ( ! empty( $params['path'] ) ) {
			$new_file = sprintf(
				'%s/%s',
				untrailingslashit( $params['path'] ),
				$export_file
			);

			$filename = $export_file;
		} else {
			$uploads = wp_upload_dir( current_time( 'mysql' ) );

			if ( ! $uploads || false !== $uploads['error'] ) {
				return pods_error( __( 'There was an issue saving the export file in your uploads folder.', 'pods' ), true );
			}

			// Generate unique file name
			$filename = wp_unique_filename( $uploads['path'], $export_file );

			// move the file to the uploads dir
			$new_file = $uploads['path'] . '/' . $filename;
		}

		file_put_contents( $new_file, $this->built );

		// Set correct file permissions
		$stat  = stat( dirname( $new_file ) );
		$perms = $stat['mode'] & 0000666;
		@chmod( $new_file, $perms );

		// Only attach if we want to and don't have a custom path.
		if ( $params['attach'] && empty( $params['path'] ) ) {
			// Get the file type
			$wp_filetype = wp_check_filetype( $filename, $this->mimes );

			// construct the attachment array
			$attachment = array(
				'post_mime_type' => 'text/' . $extension,
				'guid'           => $uploads['url'] . '/' . $filename,
				'post_parent'    => null,
				'post_title'     => 'Pods Export (' . $export_file . ')',
				'post_content'   => '',
				'post_status'    => 'private'
			);

			if ( $wp_filetype['type'] ) {
				$attachment['post_mime_type'] = $wp_filetype['type'];
			}

			// insert attachment
			$attachment_id = wp_insert_attachment( $attachment, $new_file );

			// error!
			if ( is_wp_error( $attachment_id ) ) {
				return pods_error( __( 'There was an issue saving the export file in your uploads folder.', 'pods' ), true );
			}

			$url = $attachment['guid'];
		} else {
			$url = $new_file;
		}

		return $url;

	}
1242957
public function setParams($params): void
    {
        if (!\is_array($params) && !\is_object($params)) {
            throw new EventException(
                'Event parameters must be an array or object; received `' . \gettype($params) . '`'
            );
        }

        $this->params = $params;
    }
1000866
public function save($urlParams, $form) {

		// Retrieve the record.

		$record = null;
		if (isset($urlParams['ID'])) {
			$record = ExternalContent::getDataObjectFor($urlParams['ID']);
		}
		if (!$record) {
			return parent::save($urlParams, $form);
		}

		if ($record->canEdit()) {
			// lets load the params that have been sent and set those that have an editable mapping
			if ($record->hasMethod('editableFieldMapping')) {
				$editable = $record->editableFieldMapping();
				$form->saveInto($record, array_keys($editable));
				$record->remoteWrite();
			} else {
				$form->saveInto($record);
				$record->write();
			}

			// Set the form response.

			$this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP', 'Saved.')));
		} else {
			$this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP', 'You don\'t have write access.')));
		}
		return $this->getResponseNegotiator()->respond($this->request);
	}
783835
public function layoutItemsProcFunc(array &$params)
    {
        $this->init($params['row']['pid']);
        $layoutSelectItems = $this->layoutSetup->getLayoutSelectItems(
            isset($params['row']['colPos'][0]) ? $params['row']['colPos'][0] : $params['row']['colPos'],
            $params['row']['tx_gridelements_columns'],
            $params['row']['tx_gridelements_container'],
            $this->layoutSetup->getRealPid()
        );
        $params['items'] = ArrayUtility::keepItemsInArray($layoutSelectItems, $params['items'], true);
    }