2014-06-10 15:18:49 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
App::uses('AppModel', 'Model');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TemplateElement Model
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class TemplateElement extends AppModel {
|
|
|
|
public $actsAs = array('Containable');
|
2014-06-25 09:56:33 +02:00
|
|
|
public $hasMany = array(
|
|
|
|
'TemplateElementAttribute' => array(
|
|
|
|
'dependent' => true
|
2016-06-04 01:10:45 +02:00
|
|
|
),
|
2014-06-25 09:56:33 +02:00
|
|
|
'TemplateElementText' => array(
|
|
|
|
'dependent' => true
|
2016-06-04 01:10:45 +02:00
|
|
|
),
|
2014-06-25 09:56:33 +02:00
|
|
|
'TemplateElementFile' => array(
|
|
|
|
'dependent' => true
|
|
|
|
)
|
|
|
|
);
|
2014-06-10 15:18:49 +02:00
|
|
|
public $belongsTo = array('Template');
|
2016-06-04 01:08:16 +02:00
|
|
|
|
2014-06-10 15:18:49 +02:00
|
|
|
public function lastPosition($template_id) {
|
|
|
|
$result = $this->find('first', array(
|
|
|
|
'fields' => array('MAX(position) AS pos', 'id', 'template_id'),
|
2016-05-29 22:36:07 +02:00
|
|
|
'conditions' => array('template_id' => $template_id),
|
2016-06-05 16:52:22 +02:00
|
|
|
'order' => array('id'),
|
|
|
|
'group' => array('id')
|
2014-06-10 15:18:49 +02:00
|
|
|
));
|
|
|
|
return $result[0]['pos'];
|
|
|
|
}
|
|
|
|
}
|