Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 690

Přidáno uživatelem Michal Kliment před více než 14 roky(ů)

Dodelany pristupove prava u hlasovacih sablon a typu.

Zobrazit rozdíly:

freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php
'approval template item has been successfully added' => 'Položka hlasovací šablony byla úspěšně přidána.',
'approval template item has been successfully deleted' => 'Položka hlasovací šablony byla úspěšně smazána.',
'approval template item has been successfully updated' => 'Položka hlasovací šablony byla úspěšně aktualizována.',
'approval template still contains some items' => 'Hlasovací šablona obsahuje ještě některé položky.',
'approval templates' => 'Hlasovací šablony',
'approval type' => 'Hlasovací typ',
'approval type has been successfully added' => 'Hlasovací typ byl úspěšně přidán.',
freenetis/trunk/kohana/application/models/approval_template.php
<?php
class Approval_template_Model extends ORM {
/**
*
* @author Michal Kliment
* @copyright (c) 2010 Kliment Michal
* @license GNU GPLv3
* @license http://www.gnu.org/licenses/gpl.txt
*/
class Approval_template_Model extends ORM
{
protected $has_many = array('approval_template_items');
//protected $belongs_to = array('aro_group');
/*public static $templates = array(
1 => 'test'
);*/
/**
* @author Michal Kliment
* Function to return all approval templates
* @param number $limit_from
* @param number $limit_results
* @param string $order_by
* @param string $order_by_direction
* @param array $filter_values
* @return Mysql_Result object
*/
public function get_all_approval_templates($limit_from = 0, $limit_results = 50, $order_by = 'id', $order_by_direction = 'ASC', $filter_values = array())
{
return self::$db->query('SELECT at.id, at.name, at.comment, count(ati.id) AS types_count FROM approval_templates at
......
ORDER BY `'.$order_by.'` '.$order_by_direction.' LIMIT '.$limit_from.', '.$limit_results);
}
/**
* @author Michal Kliment
* Function to count all approval templates
* @return number
*/
public function count_all_approval_templates()
{
return count(self::$db->query("SELECT at.id FROM approval_templates at"));
freenetis/trunk/kohana/application/models/approval_type.php
<?php
class Approval_type_Model extends ORM {
/**
*
* @author Michal Kliment
* @copyright (c) 2010 Kliment Michal
* @license GNU GPLv3
* @license http://www.gnu.org/licenses/gpl.txt
*/
class Approval_type_Model extends ORM
{
protected $belongs_to = array('aro_group');
public static $types = array(
1 => 'test'
);
/**
* @author Michal Kliment
* Function to return all aproval types
* @param number $limit_from
* @param number $limit_results
* @param string $order_by
* @param string $order_by_direction
* @param array $filter_values
* @return Mysql_Result object
*/
public function get_all_approval_types($limit_from = 0, $limit_results = 50, $order_by = 'id', $order_by_direction = 'ASC', $filter_values = array())
{
return self::$db->query('SELECT at.id, at.name, at.comment, at.type, at.interval, at.min_suggest_amount, ag.id as group_id, ag.name as group_name FROM approval_types at
......
ORDER BY `'.$order_by.'` '.$order_by_direction.' LIMIT '.$limit_from.', '.$limit_results);
}
/**
* @author Michal Kliment
* Function to count all approval types
* @return number
*/
public function count_all_approval_types()
{
return count(self::$db->query("SELECT at.id FROM approval_types at"));
freenetis/trunk/kohana/application/models/approval_template_item.php
<?php
class Approval_template_item_Model extends ORM {
/**
*
* @author Michal Kliment
* @copyright (c) 2010 Kliment Michal
* @license GNU GPLv3
* @license http://www.gnu.org/licenses/gpl.txt
*/
class Approval_template_item_Model extends ORM
{
protected $belongs_to = array('approval_template', 'approval_type');
/**
* @author Michal Kliment
* Function to return all approval template items belongs to approval template
* @param number $template_id
* @return Mysql_Result object
*/
public function get_all_items_by_template_id ($template_id)
{
return self::$db->query('SELECT i.*, t.id AS type_id, t.name, ag.id AS group_id, ag.name AS group_name, t.type, t.interval, t.min_suggest_amount
return self::$db->query('SELECT i.id as item_id, i.priority, i.approval_template_id, t.id, t.name, ag.id AS group_id, ag.name AS group_name, t.type, t.interval, t.min_suggest_amount
FROM approval_template_items i
LEFT JOIN approval_types t ON t.id = i.approval_type_id
LEFT JOIN aro_groups ag ON t.aro_group_id = ag.id
......
ORDER BY i.priority');
}
/**
* @author Michal Kliment
* Function to return the lowest priority of approval template
* @param number $template_id
* @return number
*/
public function get_lowest_priority_of_template($template_id)
{
$query = self::$db->query('SELECT min(priority) AS min FROM approval_template_items GROUP BY approval_template_id HAVING approval_template_id = '.$template_id);
......
return $query->current()->min;
}
/**
* @author Michal Kliment
* Function to return the highest priority of approval template
* @param number $template_id
* @return number
*/
public function get_highest_priority_of_template($template_id)
{
$query = self::$db->query('SELECT max(priority) AS max FROM approval_template_items GROUP BY approval_template_id HAVING approval_template_id = '.$template_id);
freenetis/trunk/kohana/application/controllers/approval.php
<?php
/**
* Approval controller.
*
* @author Michal Kliment
* @copyright (c) 2010 Kliment Michal
* @license GNU GPLv3
* @license http://www.gnu.org/licenses/gpl.txt
*/
class Approval_Controller extends Controller
{
public function index()
{
url::redirect(url_lang::base().'approval/templates');
}
public function templates()
{
$view = new View('main');
$view->title = url_lang::lang('texts.Approval');
$view->content = new View('approval');
$view->content->grid = '';
$view->render(TRUE);
}
}
freenetis/trunk/kohana/application/controllers/approval_templates.php
url::redirect(url_lang::base().'approval_templates/show_all');
}
/**
* @author Michal Kliment
* Function to show all approval templates
* @param number $limit_results
* @param string $order_by
* @param string $order_by_direction
* @param string $page_word
* @param number $page
*/
public function show_all($limit_results = 100, $order_by = 'id', $order_by_direction = 'ASC', $page_word = null, $page = 1)
{
//access control
if (!$this->acl_check_view('approval', 'templates'))
Controller::error(ACCESS);
// gets new selector
if (is_numeric($this->input->get('record_per_page')))
$limit_results = (int) $this->input->get('record_per_page');
......
$view->render(TRUE);
}
/**
* @author Michal Kliment
* Function to show approval template
* @param number $approval_template_id
*/
public function show($approval_template_id = NULL)
{
// access control
if (!$this->acl_check_view('approval', 'templates'))
Controller::error('ACCESS');
// bad parameter
if (!$approval_template_id || !is_numeric($approval_template_id))
Controller::warning(PARAMETER);
$this->approval_template = new Approval_template_Model($approval_template_id);
// record doesn't exist
if (!$this->approval_template->id)
Controller::error(RECORD);
......
'total_items' => count ($approval_template_items)
));
$items_grid->add_new_button(url_lang::base().'approval_template_items/add/'.$this->approval_template->id, url_lang::lang('texts.Add new approval template item'));
// access control
if ($this->acl_check_new('approval', 'templates'))
$items_grid->add_new_button(url_lang::base().'approval_template_items/add/'.$this->approval_template->id, url_lang::lang('texts.Add new approval template item'));
$items_grid->field('type_id')->label(url_lang::lang('texts.Id'));
$items_grid->field('id')->label(url_lang::lang('texts.Id'));
$items_grid->callback_field('name')->label(url_lang::lang('texts.Name'))->callback('Approval_types_Controller::name_field');
$items_grid->callback_field('group_id')->label(url_lang::lang('texts.Group'))->callback('Approval_types_Controller::group_field');
$items_grid->callback_field('type')->label(url_lang::lang('texts.Type'))->callback('Approval_types_Controller::type_field');
......
$items_grid->callback_field('min_suggest_amount')->label(url_lang::lang('texts.Minimal suggest amount'))->callback('Approval_types_Controller::min_suggest_amount_field');
$items_grid->callback_field('priority')->label(url_lang::lang('texts.Priority'))->callback('Approval_templates_Controller::priority_field');
$items_grid->action_field('id')->label(url_lang::lang('texts.Item'))->url(url_lang::base().'approval_template_items/edit')->action(url_lang::lang('texts.Edit'))->class('center');
$items_grid->action_field('id')->label(url_lang::lang('texts.Item'))->url(url_lang::base().'approval_template_items/delete')->action(url_lang::lang('texts.Delete'))->class('delete_link center');
// access control
if ($this->acl_check_edit('approval', 'templates'))
$items_grid->action_field('item_id')->label(url_lang::lang('texts.Item'))->url(url_lang::base().'approval_template_items/edit')->action(url_lang::lang('texts.Edit'))->class('center');
// access control
if ($this->acl_check_delete('approval', 'templates'))
$items_grid->action_field('item_id')->label(url_lang::lang('texts.Item'))->url(url_lang::base().'approval_template_items/delete')->action(url_lang::lang('texts.Delete'))->class('delete_link center');
$items_grid->datasource($approval_template_items);
$view = new View('main');
......
$view->render(TRUE);
}
/**
* @author Michal Kliment
* Function to add new approval template
*/
public function add()
{
// access control
if (!$this->acl_check_new('approval', 'templates'))
Controller::error(ACCESS);
// creates form
$form = new Forge(url_lang::base().'approval_templates/add', '', 'POST', array('id' => 'article_form'));
......
$form->submit('submit')->value(url_lang::lang('texts.Save'));
special::required_forge_style($form, ' *', 'required');
// form is validate
if ($form->validate())
{
$form_data = $form->as_array();
......
$view->render(TRUE);
}
/**
* @author Michal Kliment
* Function to edit approval template
* @param number $approval_template_id
*/
public function edit($approval_template_id = NULL)
{
// access control
if (!$this->acl_check_edit('approval', 'templates'))
Controller::error(ACCESS);
// bad parameter
if (!$approval_template_id || !is_numeric($approval_template_id))
Controller::warning(PARAMETER);
$approval_template = new Approval_template_Model($approval_template_id);
// record doesn't exist
if (!$approval_template->id)
Controller::error(RECORD);
......
$form->submit('submit')->value(url_lang::lang('texts.Save'));
special::required_forge_style($form, ' *', 'required');
// form is validate
if ($form->validate())
{
$form_data = $form->as_array();
......
$view->render(TRUE);
}
/**
* @author Michal Kliment
* Function to delete approval template (it have to empthy - without any items)
* @param number $approval_template_id
*/
public function delete($approval_template_id = NULL)
{
// access control
if (!$this->acl_check_delete('approval', 'templates'))
Controller::error(ACCESS);
// bad parameter
if (!$approval_template_id || !is_numeric($approval_template_id))
Controller::warning(PARAMETER);
$approval_template = new Approval_template_Model($approval_template_id);
// record doesn't exist
if (!$approval_template->id)
Controller::error(RECORD);
// finding all items belong to template
$approval_template_item_model = new Approval_template_item_Model();
$approval_template_items = $approval_template_item_model->where('approval_template_id', $approval_template->id)->find_all();
// template is not empthy
if (count($approval_template_items))
{
// approval template still contains some items
$this->session->set_flash('message', url_lang::lang('texts.Approval template still contains some items.'));
url::redirect(url_lang::base().'approval_templates/show/'.$approval_template->id);
}
else
{
// template is empthy - delete it
$approval_template->delete();
$this->session->set_flash('message', url_lang::lang('texts.Approval template has been successfully deleted.'));
url::redirect(url_lang::base().'approval_templates/show_all');
}
}
/** CALLBACK FUNCTIONS **/
/**
* @author Michal Kliment
* Callback function to return name of template as link
* @param <type> $item
* @param <type> $name
*/
public static function name_field($item, $name)
{
echo html::anchor(url_lang::base().'approval_templates/show/'.$item->id, $item->name, array('title' => url_lang::lang('texts.Show approval template')));
}
/**
* @author Michal Kliment
* Callback function to return substring of comment
* @param <type> $item
* @param <type> $name
*/
public static function comment_field($item, $name)
{
echo $item->comment;
echo (strlen($item->comment)==100) ? substr($item->comment,0,100).'...' : $item->comment;
}
/**
* @author Michal Kliment
* Callback function to return priority with up/down arrows to increase/decrease of priority
* @param <type> $item
* @param <type> $name
*/
public static function priority_field($item, $name)
{
echo $item->priority;
echo '&nbsp;&nbsp;';
$approval_template_item_model = new Approval_template_item_Model();
// the lowest priority can not more decrease
if ($item->priority > $approval_template_item_model->get_lowest_priority_of_template($item->approval_template_id))
echo html::anchor(url_lang::base().'approval_template_items/move_up/'.$item->id, html::image(url::base().'media/images/uparrow.png'));
echo html::anchor(url_lang::base().'approval_template_items/move_up/'.$item->item_id, html::image(url::base().'media/images/uparrow.png'));
echo '&nbsp';
// the highest priority can not more increase
if ($item->priority < $approval_template_item_model->get_highest_priority_of_template($item->approval_template_id))
echo html::anchor(url_lang::base().'approval_template_items/move_down/'.$item->id, html::image(url::base().'media/images/downarrow.png'));
echo html::anchor(url_lang::base().'approval_template_items/move_down/'.$item->item_id, html::image(url::base().'media/images/downarrow.png'));
}
}
freenetis/trunk/kohana/application/controllers/approval_types.php
url::redirect(url_lang::base().'approval_types/show_all');
}
/**
* @author Michal Kliment
* Function to show all approval types
* @param number $limit_results
* @param string $order_by
* @param string $order_by_direction
* @param string $page_word
* @param number $page
*/
public function show_all($limit_results = 100, $order_by = 'id', $order_by_direction = 'ASC', $page_word = null, $page = 1)
{
//access control
if (!$this->acl_check_view('approval', 'types'))
Controller::error(ACCESS);
// gets new selector
if (is_numeric($this->input->get('record_per_page')))
$limit_results = (int) $this->input->get('record_per_page');
......
$view->render(TRUE);
}
/**
* @author Michal Kliment
* Function to show approval type
* @param number $approval_type_id
*/
public function show($approval_type_id = NULL)
{
// access control
if (!$this->acl_check_view('approval', 'types'))
Controller::error('ACCESS');
// bad parameter
if (!$approval_type_id || !is_numeric($approval_type_id))
Controller::warning(PARAMETER);
$approval_type = new Approval_type_Model($approval_type_id);
// record doesn't exist
if (!$approval_type->id)
Controller::error(RECORD);
......
$view->render(TRUE);
}
/**
* @author Michal Kliment
* Function to add new approval type
*/
public function add()
{
// access control
if (!$this->acl_check_new('approval', 'types'))
Controller::error('ACCESS');
$aro_group_model = new Aro_group_Model();
$aro_groups = $aro_group_model->get_traverz_tree();
......
$form->submit('submit')->value(url_lang::lang('texts.Save'));
special::required_forge_style($form, ' *', 'required');
// form is validate
if ($form->validate())
{
$form_data = $form->as_array();
......
echo "self.close();";
echo "</script>";
}
// classic addijng
// classic adding
else
url::redirect(url_lang::base().'approval_types/show/'.$approval_type->id);
}
......
$view->render(TRUE);
}
/**
* @author Michal Kliment
* Function to edit approval type
* @param <type> $approval_type_id
*/
public function edit($approval_type_id = NULL)
{
// access control
if (!$this->acl_check_edit('approval', 'types'))
Controller::error('ACCESS');
// bad parameter
if (!$approval_type_id || !is_numeric($approval_type_id))
Controller::warning(PARAMETER);
$approval_type = new Approval_type_Model($approval_type_id);
// record doesn't exist
if (!$approval_type->id)
Controller::error(RECORD);
......
$form->submit('submit')->value(url_lang::lang('texts.Save'));
special::required_forge_style($form, ' *', 'required');
// form is validate
if ($form->validate())
{
$form_data = $form->as_array();
......
$view->render(TRUE);
}
/**
* @author Michal Kliment
* Function to delete approval type
* @param number $approval_type_id
*/
public function delete($approval_type_id = NULL)
{
// access control
if (!$this->acl_check_delete('approval', 'types'))
Controller::error('ACCESS');
// bad parameter
if (!$approval_type_id || !is_numeric($approval_type_id))
Controller::warning(PARAMETER);
$approval_type = new Approval_type_Model($approval_type_id);
// record doesn't exist
if (!$approval_type->id)
Controller::error(RECORD);
......
url::redirect(url_lang::base().'approval_types/show_all');
}
/** CALLBACK FUNCTIONS **/
/**
* @author Michal Kliment
* Callback function to return name as link
* @param <type> $item
* @param <type> $name
*/
public static function name_field($item, $name)
{
echo html::anchor(url_lang::base().'approval_types/show/'.$item->id, $item->name, array('title' => url_lang::lang('texts.Show approval type')));
}
/**
* @author Michal Kliment
* Callback function to return type as text
* @param <type> $item
* @param <type> $name
*/
public static function type_field($item, $name)
{
echo Approval_type_Model::$types[$item->type];
}
/**
* @author Michal Kliment
* Callback function to return group as text
* @param <type> $item
* @param <type> $name
*/
public static function group_field($item, $name)
{
if ($item->group_id)
......
}
}
/**
* @author Michal Kliment
* Callback function to return interval as number
* @param <type> $item
* @param <type> $name
*/
public static function interval_field($item, $name)
{
if (!$item->interval)
......
echo date::interval($item->interval).' '.strtolower(url_lang::lang('texts.hours'));
}
/**
* @author Michal Kliment
* Callback function to return minimal suggest amount with system currency
* @param <type> $item
* @param <type> $name
*/
public static function min_suggest_amount_field($item, $name)
{
if (!$item->min_suggest_amount)
freenetis/trunk/kohana/application/controllers/approval_template_items.php
class Approval_template_items_Controller extends Controller
{
// private attributes, used in callback functions
private $approval_template = NULL;
private $approval_template_item = NULL;
public function index()
{
url::redirect(url_lang::base().'approval_template_items/show_all');
url::redirect(url_lang::base().'approval_templates/show_all');
}
/**
* @author Michal Kliment
* Function to add new approval template item to approval template
* @param number $approval_template_id
*/
public function add($approval_template_id = NULL)
{
// access control
if (!$this->acl_check_new('approval', 'template_items'))
Controller::error(ACCESS);
// bad parameter
if (!$approval_template_id || !is_numeric($approval_template_id))
Controller::warning(PARAMETER);
$this->approval_template = new Approval_template_Model($approval_template_id);
// record doesn't exist
if (!$this->approval_template->id)
Controller::error(RECORD);
......
$form->submit('submit')->value(url_lang::lang('texts.Save'));
special::required_forge_style($form, ' *', 'required');
// form is validate
if ($form->validate())
{
$form_data = $form->as_array();
......
$view->render(TRUE);
}
/**
* @author Michal Kliment
* Function to edit approval template item
* @param number $approval_template_item_id
*/
public function edit($approval_template_item_id = NULL)
{
// access control
if (!$this->acl_check_edit('approval', 'template_items'))
Controller::error(ACCESS);
// bad parameter
if (!$approval_template_item_id || !is_numeric($approval_template_item_id))
Controller::warning(PARAMETER);
$this->approval_template_item = new Approval_template_item_Model($approval_template_item_id);
// record doesn't exist
if (!$this->approval_template_item->id)
Controller::error(RECORD);
......
$form->submit('submit')->value(url_lang::lang('texts.Save'));
special::required_forge_style($form, ' *', 'required');
// form is validate
if ($form->validate())
{
$form_data = $form->as_array();
......
$view->render(TRUE);
}
/**
* @author Michal Kliment
* Function to move up with approval template item (decrease priority)
* @param number $approval_template_item_id
*/
public function move_up($approval_template_item_id = NULL)
{
$this->move($approval_template_item_id, 'up');
}
/**
* @author Michal Kliment
* Function to move down with approval template item (increase priority)
* @param number $approval_template_item_id
*/
public function move_down($approval_template_item_id = NULL)
{
$this->move($approval_template_item_id, 'down');
}
/**
* @author Michal Kliment
* Function move with approval template item (decrease/increase priority)
* @param number $approval_template_item_id
* @param string $direction
*/
private function move($approval_template_item_id, $direction)
{
// access control
if (!$this->acl_check_edit('approval', 'template_items'))
Controller::error(ACCESS);
// bad parameter
if (!$approval_template_item_id || !is_numeric($approval_template_item_id))
Controller::warning(PARAMETER);
$approval_template_item = new Approval_template_item_Model($approval_template_item_id);
// record doesn't exist
if (!$approval_template_item->id)
Controller::error(RECORD);
......
else
$approval_template_items = $approval_template_item->where('approval_template_id',$approval_template_item->approval_template_id)->where('priority > ',$approval_template_item->priority)->orderby('priority','asc')->find_all();
// priority is not the lowest/highest
if (count($approval_template_items))
{
// find first one with lower/higher priority
$second_approval_template_item = $approval_template_items->current();
// and change priorities
$priority = $second_approval_template_item->priority;
$second_approval_template_item->priority = $approval_template_item->priority;
$approval_template_item->priority = $priority;
......
url::redirect(url_lang::base().'approval_templates/show/'.$approval_template_item->approval_template_id);
}
/**
* @author Michal Kliment
* Function to delete approval template item
* @param number $approval_template_item_id
*/
public function delete($approval_template_item_id = NULL)
{
// access control
if (!$this->acl_check_delete('approval', 'template_items'))
Controller::error(ACCESS);
// bad parameter
if (!$approval_template_item_id || !is_numeric($approval_template_item_id))
Controller::warning(PARAMETER);
$approval_template_item = new Approval_template_item_Model($approval_template_item_id);
// record doesn't exist
if (!$approval_template_item->id)
Controller::error(RECORD);
......
url::redirect(url_lang::base().'approval_templates/show/'.$approval_template_id);
}
/** CALLBACK FUNCTIONS **/
/**
* @author Michal Kliment
* Callback function to validate approval type of approval template item
* @param <type> $input
*/
public function valid_approval_type($input)
{
$approval_type_id = $input->value;
$approval_template_item_model = new Approval_template_item_Model();
// check if exist approval template item belongs to same approval template with same approval type
$approval_template_item = $approval_template_item_model->where('approval_template_id', $this->approval_template->id)->where('approval_type_id', $approval_type_id)->find();
if ($approval_template_item && $approval_template_item->id && (!$this->approval_template_item || $approval_template_item->id != $this->approval_template_item->id))
......
}
/**
* @author Michal Kliment
* Callback function to validate priority of approval template item
* @param <type> $input
*/
public function valid_priority($input)
{
$priority = $input->value;
$approval_template_item_model = new Approval_template_item_Model();
// check if exist approval template item belongs to same approval template with same priority
$approval_template_item = $approval_template_item_model->where('approval_template_id', $this->approval_template->id)->where('priority', $priority)->find();
if ($approval_template_item && $approval_template_item->id && (!$this->approval_template_item || $approval_template_item->id != $this->approval_template_item->id))
freenetis/trunk/kohana/application/upgrade_sql/upgrade_sql.php
// array of sql queries that upgrade database
$upgrade_sql[get_SVN_rev()] = array(
"CREATE TABLE IF NOT EXISTS `approval_types` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_czech_ci NOT NULL,
`comment` mediumtext COLLATE utf8_czech_ci NOT NULL,
`type` int(11) NOT NULL,
`aro_group_id` int(11) NOT NULL,
`interval` datetime NOT NULL,
`min_suggest_amount` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;",
"INSERT INTO `axo` (`id`, `section_value`, `value`, `order_value`, `name`, `hidden`) VALUES
(160, 'approval', 'templates', 0, 'Approval templates', 0),
(161, 'approval', 'template_items', 0, 'Approval template items', 0),
(162, 'approval', 'types', 0, 'Approval types', 0);",
"CREATE TABLE IF NOT EXISTS `approval_templates` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_czech_ci NOT NULL,
`comment` mediumtext COLLATE utf8_czech_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;",
"CREATE TABLE IF NOT EXISTS `approval_template_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`approval_template_id` int(11) NOT NULL,
`approval_type_id` int(11) NOT NULL,
`priority` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;"
"INSERT INTO `axo_map` (`acl_id`, `section_value`, `value`) VALUES
(38, 'approval', 'template_items'),
(38, 'approval', 'templates'),
(38, 'approval', 'types');"
);
?>
freenetis/trunk/kohana/application/upgrade_sql/upgrade_sql_685.php
<?php
// array of sql queries that upgrade database
$upgrade_sql[685] = array(
"CREATE TABLE IF NOT EXISTS `approval_types` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_czech_ci NOT NULL,
`comment` mediumtext COLLATE utf8_czech_ci NOT NULL,
`type` int(11) NOT NULL,
`aro_group_id` int(11) NOT NULL,
`interval` datetime NOT NULL,
`min_suggest_amount` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;",
"CREATE TABLE IF NOT EXISTS `approval_templates` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_czech_ci NOT NULL,
`comment` mediumtext COLLATE utf8_czech_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;",
"CREATE TABLE IF NOT EXISTS `approval_template_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`approval_template_id` int(11) NOT NULL,
`approval_type_id` int(11) NOT NULL,
`priority` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;"
);
?>

Také k dispozici: Unified diff