Skip to content
Snippets Groups Projects
Commit f407f9cb authored by Giovannoni Laurent's avatar Giovannoni Laurent
Browse files

FEAT new method to insert res and resExt

parent 5b99fc1e
No related branches found
No related tags found
No related merge requests found
...@@ -76,7 +76,7 @@ class ContactsModelAbstract extends Apps_Table_Service ...@@ -76,7 +76,7 @@ class ContactsModelAbstract extends Apps_Table_Service
'table' => ['view_contacts'], 'table' => ['view_contacts'],
'where' => ['email = ? and enabled = ?'], 'where' => ['email = ? and enabled = ?'],
'data' => [$aArgs['email'], 'Y'], 'data' => [$aArgs['email'], 'Y'],
'order' => ['creation_date'], 'order_by' => ['creation_date'],
]); ]);
return $aReturn; return $aReturn;
......
...@@ -154,22 +154,18 @@ class ResController ...@@ -154,22 +154,18 @@ class ResController
'data' => $data, 'data' => $data,
]; ];
$resId = $this->loadIntoDb($aArgs); $this->loadIntoDb($aArgs);
var_dump($resId);
exit; $resDetails = ResModel::getByPath([
'docserverId' => $storeResult['docserver_id'],
'path' => $storeResult['destination_dir'],
'filename' => $storeResult['file_destination_name'],
'table' => $aArgs['table'],
'select' => ['res_id']
]);
$resId = $resDetails[0]['res_id'];
require_once 'core/class/class_resource.php';
$resource = new \resource();
$resId = $resource->load_into_db(
$table,
$storeResult['destination_dir'],
$storeResult['file_destination_name'],
$storeResult['path_template'],
$storeResult['docserver_id'],
$data,
$_SESSION['config']['databasetype'],
true
);
if (!is_numeric($resId)) { if (!is_numeric($resId)) {
return ['errors' => 'Pb with SQL insertion : ' .$resId]; return ['errors' => 'Pb with SQL insertion : ' .$resId];
...@@ -193,7 +189,7 @@ class ResController ...@@ -193,7 +189,7 @@ class ResController
* @param $filename string Resource file name * @param $filename string Resource file name
* @param $docserverPath string Docserver path * @param $docserverPath string Docserver path
* @param $docserverId string Docserver identifier * @param $docserverId string Docserver identifier
* @param $data array Data array * @param boolean
*/ */
public function loadIntoDb($aArgs) public function loadIntoDb($aArgs)
{ {
...@@ -302,35 +298,13 @@ class ResController ...@@ -302,35 +298,13 @@ class ResController
//VALUE //VALUE
$prepareData[$data[$i]['column']] = $data[$i]['value']; $prepareData[$data[$i]['column']] = $data[$i]['value'];
} }
var_dump($prepareData);
$resInsert = ResModel::create([ $resInsert = ResModel::create([
'table' => 'res_letterbox', 'table' => 'res_letterbox',
'data' => $prepareData 'data' => $prepareData
]); ]);
var_dump($resInsert);
exit;
if (!$this->insert($table, $data, $_SESSION['config']['databasetype'])) { return true;
if (!$calledByWs) {
$this->error = _INDEXING_INSERT_ERROR."<br/>".$this->show();
}
return false;
} else {
$db2 = new Database();
$stmt = $db2->query(
"select res_id from " . $table
. " where docserver_id = ? and path = ? and filename= ? order by res_id desc ",
array(
$docserverId,
$path,
$filename
)
);
$res = $stmt->fetchObject();
return $res->res_id;
}
} }
} }
......
...@@ -47,6 +47,38 @@ class ResModelAbstract extends \Apps_Table_Service ...@@ -47,6 +47,38 @@ class ResModelAbstract extends \Apps_Table_Service
return $aReturn; return $aReturn;
} }
/**
* Retrieve info of resId by path
* @param $docserverId string
* @param $path string
* @param $filename string
* @param $table string
* @param $select string
* @return array $res
*/
public static function getByPath(array $aArgs = [])
{
static::checkRequired($aArgs, ['docserverId']);
static::checkRequired($aArgs, ['path']);
static::checkRequired($aArgs, ['filename']);
if (!empty($aArgs['table'])) {
$table = $aArgs['table'];
} else {
$table = 'res_letterbox';
}
$aReturn = static::select([
'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
'table' => [$table],
'where' => ['docserver_id = ? and path = ? and filename = ?'],
'data' => [$aArgs['docserverId'], $aArgs['path'], $aArgs['filename']],
'order_by' => ['res_id desc'],
]);
return $aReturn;
}
/** /**
* Retrieve process_limit_date for resource in extension table if mlb * Retrieve process_limit_date for resource in extension table if mlb
* @param $resId integer * @param $resId integer
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment