This commit is contained in:
mi3ll 2013-02-01 13:41:02 -08:00
commit 5cabd5c4d8
2 changed files with 16 additions and 14 deletions

View File

@ -261,12 +261,22 @@ class GridFieldBulkImageUpload_Request extends RequestHandler {
$recordClass = $this->gridField->list->dataClass;
$recordForeignKey = $this->gridField->list->foreignKey;
$recordForeignID = $this->gridField->list->foreignID;
$isManyMany = ($this->gridField->list instanceof ManyManyList);
$record = Object::create($recordClass);
$record->setField($recordForeignKey, $recordForeignID);
if(!$isManyMany) {
$record->setField($recordForeignKey, $recordForeignID);
}
$record->write();
if($isManyMany) {
$this->gridField->list->add($record->ID);
}
$upload = new Upload();
$upload = new Upload();
$tmpfile = $request->postVar('BulkImageUploadField');
// Check if the file has been uploaded into the temporary storage.

View File

@ -187,20 +187,12 @@ class GridFieldBulkManager_Request extends RequestHandler {
public function unlink(SS_HTTPRequest $request)
{
$recordList = $this->getPOSTRecordList($request);
$recordClass = $this->gridField->list->dataClass;
$recordForeignKey = $this->gridField->list->foreignKey;
//$recordForeignID = $this->gridField->list->foreignID;
$result = array();
foreach ( $recordList as $id )
{
$record = DataObject::get_by_id($recordClass, $id);
$res = $record->setField($recordForeignKey, 0);
$record->write();
array_push($result, array($id => $res));
if($this->gridField->list instanceof RelationList) {
$this->gridField->list->removeMany($recordList);
}
$response = new SS_HTTPResponse(Convert::raw2json(array($result)));
$response = new SS_HTTPResponse(Convert::raw2json(array($recordList)));
$response->addHeader('Content-Type', 'text/plain');
return $response;
}