45 public $errors = array();
100 $newaction = $action;
101 if ($newaction ==
'add') {
102 $newaction =
'create';
104 if ($newaction ==
'update') {
107 if (empty($newaction) || $newaction ==
'delete' || $newaction ==
'create_user' || $newaction ==
'presend' || $newaction ==
'send') {
125 $this->targetmodule = $module;
126 $this->canvas = $canvas;
128 $this->dirmodule = $module;
131 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $canvas, $regs)) {
132 $this->canvas = $regs[1];
133 $this->dirmodule = $regs[2];
136 if ($this->dirmodule ==
'thirdparty') {
137 $this->dirmodule =
'societe';
141 $controlclassfile =
dol_buildpath(
'/'.$this->dirmodule.
'/canvas/'.$this->canvas.
'/actions_'.$this->card.
'_'.$this->canvas.
'.class.php');
142 if (file_exists($controlclassfile)) {
144 require_once $controlclassfile;
147 $controlclassname =
'Actions'.ucfirst($this->card).ucfirst($this->canvas);
148 $this->control =
new $controlclassname($this->db, $this->dirmodule, $this->targetmodule, $this->canvas, $this->card);
152 $this->template_dir =
dol_buildpath(
'/'.$this->dirmodule.
'/canvas/'.$this->canvas.
'/tpl/');
153 if (!is_dir($this->template_dir)) {
154 $this->template_dir =
'';
173 if (is_object($this->control) && method_exists($this->control,
'assign_values')) {
174 $this->control->assign_values($action,
$id, $ref);
187 if (empty($this->template_dir)) {
191 $newaction = $action;
192 if ($action && !in_array($action, array(
'create',
'view',
'edit',
'list'))) {
196 if (file_exists($this->template_dir.(!empty($this->card) ? $this->card.
'_' :
'').$this->
_cleanaction($newaction).
'.tpl.php')) {
214 global $db,
$conf, $langs, $user, $canvas;
215 global $form, $formfile;
217 $newaction = $action;
218 if ($action && !in_array($action, array(
'create',
'view',
'edit',
'list'))) {
223 include $this->template_dir.(!empty($this->card) ? $this->card.
'_' :
'').$this->
_cleanaction($newaction).
'.tpl.php';
237 return (is_object($this->control));
253 $control = $this->control;
254 if (method_exists($control,
'doActions')) {
255 $ret = $control->doActions($action,
$id);
$id
Support class for third parties, contacts, members, users or resources.
hasActions()
Return if a canvas contains an action controller.
getCanvas($module, $card, $canvas)
Initialize properties: ->targetmodule, ->canvas, ->card, ->dirmodule, ->template_dir.
_cleanaction($action)
Return action code cleaned.
__construct($db, $actiontype='view')
Constructor.
display_canvas($action)
Display a canvas page.
doActions(&$action='view', $id=0)
Shared method for canvas to execute actions.
displayCanvasExists($action)
Return if a template exists to display as canvas (if it exists)
assign_values(&$action='view', $id=0, $ref='')
Shared method for canvas to assign values for templates.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.