Saves a package
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base
960156
public function savePackage($data) {
        $response=CodeBank_ClientAPI::responseBase();
        
        //Ensure logged in
        if(!Permission::check('CODE_BANK_ACCESS')) {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
        
            return $response;
        }
        
        
        $package=SnippetPackage::get()->byID(intval($data->packageID));
        if(!empty($package) && $package!==false && $package->ID!=0) {
            if(!empty($data->title)) {
                $package->Title=$data->title;
                $package->write();
                
                
                $response['status']='HELO';
            }else {
                $response['status']='EROR';
                $response['message']=_t('CodeBankAPI.PACKAGES_TITLE_REQUIRED', '_Packages must have a title');
            }
        }else {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.PACKAGE_NOT_FOUND', '_Package not found');
        }
        
        return $response;
    }
442729
public function save($data)
    {
        $tags = array();
        foreach ($this->_tags as $tag) {
            $tags[] = $tag->getNativeId();
        }
        $raw = serialize($data);
        $this->_getBackend()->save($raw, $this->_id, $tags, $this->_lifetime);
    }
980227
public function save(array $data)
    {
        return (bool) file_put_contents($this->file, $this->serializer->serialize($data));
    }
870376
protected function saveAudioData($data)
    {
        if ($this->no_session != true) {
            $_SESSION['securimage_code_audio'][$this->namespace] = $data;
        }

        if ($this->use_database) {
            $this->saveAudioToDatabase($data);
        }
    }
1203488
public function save(stdClass $grade, stdClass $data) {
        global $DB;

        // Save the files.
        $data = file_postupdate_standard_editor(
            $data,
            'assignfeedbackcomments',
            $this->get_editor_options(),
            $this->assignment->get_context(),
            ASSIGNFEEDBACK_COMMENTS_COMPONENT,
            ASSIGNFEEDBACK_COMMENTS_FILEAREA,
            $grade->id
        );

        $feedbackcomment = $this->get_feedback_comments($grade->id);
        if ($feedbackcomment) {
            $feedbackcomment->commenttext = $data->assignfeedbackcomments;
            $feedbackcomment->commentformat = $data->assignfeedbackcommentsformat;
            return $DB->update_record('assignfeedback_comments', $feedbackcomment);
        } else {
            $feedbackcomment = new stdClass();
            $feedbackcomment->commenttext = $data->assignfeedbackcomments;
            $feedbackcomment->commentformat = $data->assignfeedbackcommentsformat;
            $feedbackcomment->grade = $grade->id;
            $feedbackcomment->assignment = $this->assignment->get_instance()->id;
            return $DB->insert_record('assignfeedback_comments', $feedbackcomment) > 0;
        }
    }
934083
public function sendData($data)
    {
        $response = $this->gocardless->refunds()->update($data['refundId'], $data['refundData']);

        return $this->response = new RefundResponse($this, $response);
    }
1089169
public function save($data) {
        if ($data instanceof SimplePie) {
            $data = $data->data;
        }
        $response = $this->cache->set($this->name, serialize($data));
        if ($this->options['expire']) {
            $this->cache->expire($this->name, $this->options['expire']);
        }

        return $response;
    }
272914
private function saveFile($data) {
		$fileupload = \Yii::createObject(\Yii::$app->components[$this->fileupload]);
		$fileinfo = $fileupload->createFile($data['extension']);
		$file = fopen($fileinfo['tmp'], 'wb');
		fwrite($file, $data['content']);
		fclose($file);

		return $fileupload->finalFile($fileinfo);
	}
1035636
protected function prepSaveData(&$data)
    {
        if (!is_array($data)) {
            $data = [];
        }

        ksort($data);

        $data['containers'] = [];
        $data['pageContainer'] = [];

        if (empty($data['plugins'])) {
            throw new InvalidArgumentException(
                'Save Data missing plugins .
                Please make sure the data you\'re attempting to save is correctly formatted.
            '
            );
        }

        foreach ($data['plugins'] as &$plugin) {
            $this->cleanSaveData($plugin['saveData']);

            /* Patch for a Json Bug */
            if (!empty($plugin['isSitewide'])
                && $plugin['isSitewide'] != 'false'
                && $plugin['isSitewide'] != '0'
            ) {
                $plugin['isSitewide'] = 1;
            } else {
                $plugin['isSitewide'] = 0;
            }

            if (empty($plugin['sitewideName'])) {
                $plugin['sitewideName'] = null;
            }

            $plugin['rank'] = (int)$plugin['rank'];
            $plugin['rowNumber'] = (int)$plugin['rowNumber'];
            $plugin['columnClass'] = (string)$plugin['columnClass'];

            $plugin['containerName'] = $plugin['containerId'];

            if ($plugin['containerType'] == 'layout') {
                $data['containers'][$plugin['containerId']][] = &$plugin;
            } else {
                $data['pageContainer'][] = &$plugin;
            }
        }
    }
1101166
public function saveData($data)
    {

        try {
            $location1 = Order::where('order_no', $data['order_no'])->first();;
            $location1->state = isset($data['state']) ? $data['state'] : $location1->state;
            $location1->order_desc = isset($data['order_desc']) ? $data['order_desc'] : $location1->order_desc;
            $location1->full_address = isset($data['full_address']) ? $data['full_address'] : $location1->full_address;
            $location1->user_id = isset($data['user_id']) ? $data['user_id'] : $location1->user_id;
            $location1->user_name = isset($data['user_name']) ? $data['user_name'] : $location1->user_name;
            $location1->user_mobile = isset($data['user_mobile']) ? $data['user_mobile'] : $location1->user_mobile;
            $location1->merchant_id = isset($data['merchant_id']) ? $data['merchant_id'] : $location1->merchant_id;
            $location1->merchant_name = isset($data['merchant_name']) ? $data['merchant_name'] : $location1->merchant_name;
            $location1->merchant_tel = isset($data['merchant_tel']) ? $data['merchant_tel'] : $location1->merchant_tel;
            $location1->published_at = isset($data['published_at']) ? $data['published_at'] : $location1->published_at;
            $location1->user_lat = isset($data['user_lat']) ? $data['user_lat'] : $location1->user_lat;
            $location1->user_lng = isset($data['user_lng']) ? $data['user_lng'] : $location1->user_lng;
            $location1->big_cat = isset($data['big_cat']) ? $data['big_cat'] : $location1->big_cat;
            $location1->middle_cat = isset($data['middle_cat']) ? $data['middle_cat'] : $location1->middle_cat;
            $location1->small_cat = isset($data['small_cat']) ? $data['small_cat'] : $location1->small_cat;
            $location1->order_type = isset($data['order_type']) ? $data['order_type'] : $location1->order_type;
            $location1->biz_type = isset($data['biz_type']) ? $data['biz_type'] : $location1->biz_type;
            $location1->geom = new GeomPoint( $location1->user_lng,$location1->user_lat);
            return $location1->save();

        } catch (\Exception $e) {
            Log::info('c=OrderApiRepository f=saveData  msg=' . $e->getMessage());
            return false;
        }


    }
1256409
protected function saveDotEnvData( $data )
	{
		$dotEnvPath = base_path( '.env' );
		$dotEnv = "\n";
		foreach( $data as $key => $value ) {
			$dotEnv .= "{$key}={$value}\n";
		}
		file_put_contents( $dotEnvPath, $dotEnv );
	}
881847
public function save($data)
	{
		if ($this->mysql === null)
		{
			return false;
		}

		$query = $this->mysql->prepare('DELETE i, cd FROM `' . $this->options['extras']['prefix'] . 'cache_data` cd, ' .
			'`' . $this->options['extras']['prefix'] . 'items` i ' .
			'WHERE cd.id = i.feed_id ' .
			'AND cd.mtime < (unix_timestamp() - :purge_time)');
		$query->bindValue(':purge_time', $this->options['extras']['cache_purge_time']);

		if (!$query->execute())
		{
			return false;
		}

		if ($data instanceof SimplePie)
		{
			$data = clone $data;

			$prepared = self::prepare_simplepie_object_for_cache($data);

			$query = $this->mysql->prepare('SELECT COUNT(*) FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :feed');
			$query->bindValue(':feed', $this->id);
			if ($query->execute())
			{
				if ($query->fetchColumn() > 0)
				{
					$items = count($prepared[1]);
					if ($items)
					{
						$sql = 'UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `items` = :items, `data` = :data, `mtime` = :time WHERE `id` = :feed';
						$query = $this->mysql->prepare($sql);
						$query->bindValue(':items', $items);
					}
					else
					{
						$sql = 'UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `data` = :data, `mtime` = :time WHERE `id` = :feed';
						$query = $this->mysql->prepare($sql);
					}

					$query->bindValue(':data', $prepared[0]);
					$query->bindValue(':time', time());
					$query->bindValue(':feed', $this->id);
					if (!$query->execute())
					{
						return false;
					}
				}
				else
				{
					$query = $this->mysql->prepare('INSERT INTO `' . $this->options['extras']['prefix'] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(:feed, :count, :data, :time)');
					$query->bindValue(':feed', $this->id);
					$query->bindValue(':count', count($prepared[1]));
					$query->bindValue(':data', $prepared[0]);
					$query->bindValue(':time', time());
					if (!$query->execute())
					{
						return false;
					}
				}

				$ids = array_keys($prepared[1]);
				if (!empty($ids))
				{
					foreach ($ids as $id)
					{
						$database_ids[] = $this->mysql->quote($id);
					}

					$query = $this->mysql->prepare('SELECT `id` FROM `' . $this->options['extras']['prefix'] . 'items` WHERE `id` = ' . implode(' OR `id` = ', $database_ids) . ' AND `feed_id` = :feed');
					$query->bindValue(':feed', $this->id);

					if ($query->execute())
					{
						$existing_ids = array();
						while ($row = $query->fetchColumn())
						{
							$existing_ids[] = $row;
						}

						$new_ids = array_diff($ids, $existing_ids);

						foreach ($new_ids as $new_id)
						{
							if (!($date = $prepared[1][$new_id]->get_date('U')))
							{
								$date = time();
							}

							$query = $this->mysql->prepare('INSERT INTO `' . $this->options['extras']['prefix'] . 'items` (`feed_id`, `id`, `data`, `posted`) VALUES(:feed, :id, :data, :date)');
							$query->bindValue(':feed', $this->id);
							$query->bindValue(':id', $new_id);
							$query->bindValue(':data', serialize($prepared[1][$new_id]->data));
							$query->bindValue(':date', $date);
							if (!$query->execute())
							{
								return false;
							}
						}
						return true;
					}
				}
				else
				{
					return true;
				}
			}
		}
		else
		{
			$query = $this->mysql->prepare('SELECT `id` FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :feed');
			$query->bindValue(':feed', $this->id);
			if ($query->execute())
			{
				if ($query->rowCount() > 0)
				{
					$query = $this->mysql->prepare('UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `items` = 0, `data` = :data, `mtime` = :time WHERE `id` = :feed');
					$query->bindValue(':data', serialize($data));
					$query->bindValue(':time', time());
					$query->bindValue(':feed', $this->id);
					if ($this->execute())
					{
						return true;
					}
				}
				else
				{
					$query = $this->mysql->prepare('INSERT INTO `' . $this->options['extras']['prefix'] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(:id, 0, :data, :time)');
					$query->bindValue(':id', $this->id);
					$query->bindValue(':data', serialize($data));
					$query->bindValue(':time', time());
					if ($query->execute())
					{
						return true;
					}
				}
			}
		}
		return false;
	}
268066
public function addSnippetToPackage($data) {
        $response=CodeBank_ClientAPI::responseBase();
        
        //Ensure logged in
        if(!Permission::check('CODE_BANK_ACCESS')) {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
            
            return $response;
        }
        
        
        $package=SnippetPackage::get()->byID(intval($data->packageID));
        if(!empty($package) && $package!==false && $package->ID!=0) {
            $snippet=Snippet::get()->byID(intval($data->snippetID));
            if(!empty($snippet) && $snippet!==false && $snippet->ID!=0) {
                $package->Snippets()->add($snippet);
                
                
                $response['status']='HELO';
            }else {
                $response['status']='EROR';
                $response['message']=_t('CodeBankAPI.SNIPPET_NOT_FOUND', '_Snippet not found');
            }
            
            $response['status']='HELO';
        }else {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.PACKAGE_NOT_FOUND', '_Package not found');
        }
        
        
        return $response;
    }
1328809
public function getPackageInfo($data) {
        $response=CodeBank_ClientAPI::responseBase();
        
        //Ensure logged in
        if(!Permission::check('CODE_BANK_ACCESS')) {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
        
            return $response;
        }
        
        
        $package=SnippetPackage::get()->byID(intval($data->id));
        if(!empty($package) && $package!==false && $package->ID!=0) {
            $response['data']=array(
                                    'id'=>$package->ID,
                                    'title'=>$package->Title,
                                    'snippets'=>$this->overviewList($package->Snippets(), 'Title', 'ID', 'Language.Title')
                                );
            
            
            $response['status']='HELO';
        }else {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.PACKAGE_NOT_FOUND', '_Package not found');
        }
        
        return $response;
    }
328572
public function saveAndUnload($data = [])
    {
        $ras = $this->reload_after_save;
        $this->reload_after_save = false;
        $this->save($data);
        $this->unload();

        // restore original value
        $this->reload_after_save = $ras;

        return $this;
    }
309558
protected function saveImageFile($data) {
		$this->checkUploadErrors($data);

		$this->OrientationCorrection($data);

		// we need to make sure the directory for the album exists
		// @note for group albums, the photos are distributed among the users
		$dir = tp_get_img_dir($this->getContainerGUID());
		if (!file_exists($dir)) {
			mkdir($dir, 0755, true);
		}

		// move the uploaded file into album directory
		$this->setOriginalFilename($data['name']);
		$filename = $this->getFilenameOnFilestore();
		$result = move_uploaded_file($data['tmp_name'], $filename);
		if (!$result) {
			return false;
		}

		$owner = $this->getOwnerEntity();
		$owner->image_repo_size = (int)$owner->image_repo_size + $this->getSize();

		return true;
	}
1164766
public function sendData($data)
    {
        $response = $this->braintree->transaction()->releaseFromEscrow($data['transactionId']);

        return $this->createResponse($response);
    }