MISP/app/Model/TemplateElement.php

36 lines
743 B
PHP
Raw Normal View History

<?php
App::uses('AppModel', '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
)
);
public $belongsTo = array('Template');
public function lastPosition($template_id) {
$result = $this->find('first', array(
'fields' => array('MAX(position) AS pos', 'id', 'template_id'),
'conditions' => array('template_id' => $template_id),
'order' => array('id'),
'group' => array('id', 'template_id')
));
if (empty($result)) {
return 0;
}
return $result[0]['pos'];
}
}