-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepopulatePHPPlugin.php
61 lines (52 loc) · 2.06 KB
/
prepopulatePHPPlugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
require_once(__CA_MODELS_DIR__."/ca_objects.php");
class prepopulatePHPPlugin extends BaseApplicationPlugin {
# -------------------------------------------------------
public function __construct() {
//$this->description = "Prepopulate PHP";
parent::__construct();
}
# -------------------------------------------------------
/**
* Override checkStatus() to return true - the MMS plugin always initializes ok
*/
public function checkStatus() {
return array(
'description' => "",
'errors' => array(),
'warnings' => array(),
'available' => (bool) true
);
}
# -------------------------------------------------------
public function hookSaveItem(&$pa_params) {
$item = $pa_params["instance"];
$vs_table = get_class($item);
$type = $item->get($vs_table.".type_id");
$id = $item->get($vs_table.".object_id");
switch($vs_table) {
case "ca_occurrences":
// Pour les occurrences, exemple
// $objects = $item->getWithTemplate("<unit relativeTo='ca_objects_x_occurrences' delimiter=';'>^ca_objects.object_id</unit>");
// $item->setMode(ACCESS_WRITE);
// $objects = explode(";", $objects);
// foreach($objects as $object_id){
// $object = new ca_objects($object_id);
// $dimensions["dimensions_height"] = $object->getWithTemplate("^ca_objects.dimensions.dimensions_height");
// $dimensions["dimensions_width"] = $object->getWithTemplate("^ca_objects.dimensions.dimensions_width");
// $dimensions["dimensions_depth"] = $object->getWithTemplate("^ca_objects.dimensions.dimensions_depth");
// $dimensions["circumference"] = $object->getWithTemplate("^ca_objects.dimensions.circumference");
// $dimensions["dimensions_poids"] = $object->getWithTemplate("^ca_objects.dimensions.dimensions_poids");
// $dimensions["type_dimensions"] = $object->getWithTemplate("^ca_objects.dimensions.type_dimensions");
// $item->addAttribute($dimensions, "dimensions");
// }
// $item->update();
break;
default:
break;
}
}
static public function getRoleActionList() {
return array();
}
}