True,
'add' => True,
'edit' => True,
'delete' => True,
'register_all_hooks' => True
);
var $bo;
var $nextmatchs;
function uiapplications()
{
$this->bo =& CreateObject('admin.boapplications');
$this->nextmatchs =& CreateObject('phpgwapi.nextmatchs');
}
function get_list()
{
if ($GLOBALS['egw']->acl->check('applications_access',1,'admin'))
{
$GLOBALS['egw']->redirect_link('/index.php');
}
$can_add = !$GLOBALS['egw']->acl->check('applications_access',2,'admin');
$can_edit = !$GLOBALS['egw']->acl->check('applications_access',4,'admin');
$can_delete = !$GLOBALS['egw']->acl->check('applications_access',8,'admin');
$GLOBALS['egw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Installed applications');
$GLOBALS['egw']->js->validate_file('jscode','openwindow','admin');
$GLOBALS['egw']->common->egw_header();
echo parse_navbar();
$GLOBALS['egw']->template->set_file(array('applications' => 'applications.tpl'));
$GLOBALS['egw']->template->set_block('applications','list','list');
$GLOBALS['egw']->template->set_block('applications','row','row');
$GLOBALS['egw']->template->set_block('applications','add','add');
$start = get_var('start',array('POST','GET'));
$sort = $_GET['sort'];
$order = $_GET['order'];
$offset = $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'];
$apps = $this->bo->get_list();
$total = count($apps);
$sort = $sort ? $sort : 'ASC';
uasort($apps,create_function('$a,$b','return strcasecmp($a[\'title\'],$b[\'title\'])'.($sort != 'ASC' ? '* -1' : '').';'));
if ($start && $offset)
{
$limit = $start + $offset;
}
elseif ($start && !$offset)
{
$limit = $start;
}
elseif(!$start && !$offset)
{
$limit = $total;
}
else
{
$start = 0;
$limit = $offset;
}
if ($limit > $total)
{
$limit = $total;
}
$i = 0;
$applications = array();
while(list($app,$data) = @each($apps))
{
if($i >= $start && $i< $limit)
{
$applications[$app] = $data;
}
$i++;
}
$GLOBALS['egw']->template->set_var('bg_color',$GLOBALS['egw_info']['theme']['bg_color']);
$GLOBALS['egw']->template->set_var('th_bg',$GLOBALS['egw_info']['theme']['th_bg']);
$GLOBALS['egw']->template->set_var('sort_title',$this->nextmatchs->show_sort_order($sort,'title','title','/index.php',lang('Title'),'&menuaction=admin.uiapplications.get_list'));
$GLOBALS['egw']->template->set_var('lang_showing',$this->nextmatchs->show_hits($total,$start));
$GLOBALS['egw']->template->set_var('left',$this->nextmatchs->left('/index.php',$start,$total,'menuaction=admin.uiapplications.get_list'));
$GLOBALS['egw']->template->set_var('right',$this->nextmatchs->right('index.php',$start,$total,'menuaction=admin.uiapplications.get_list'));
$GLOBALS['egw']->template->set_var('lang_edit',lang('Edit'));
$GLOBALS['egw']->template->set_var('lang_delete',lang('Delete'));
$GLOBALS['egw']->template->set_var('lang_enabled',lang('Enabled'));
$GLOBALS['egw']->template->set_var('new_action',$GLOBALS['egw']->link('/index.php','menuaction=admin.uiapplications.add'));
$GLOBALS['egw']->template->set_var('lang_note',lang('(To install new applications use
Setup [Manage Applications] !!!)'));
$GLOBALS['egw']->template->set_var('lang_add',lang('add'));
foreach($applications as $app)
{
$tr_color = $this->nextmatchs->alternate_row_color($tr_color);
$GLOBALS['egw']->template->set_var('tr_color',$tr_color);
$GLOBALS['egw']->template->set_var('name',$app['title']);
$GLOBALS['egw']->template->set_var('edit',$can_edit ? ' ' . lang('Edit') . ' ' : ' ');
$GLOBALS['egw']->template->set_var('delete',$can_delete ? ' ' . lang('Delete') . ' ' : ' ');
if ($app['status'])
{
$status = lang('Yes');
}
else
{
$status = '' . lang('No') . '';
}
$GLOBALS['egw']->template->set_var('status',$status);
$GLOBALS['egw']->template->parse('rows','row',True);
}
if ($can_add)
{
$GLOBALS['egw']->template->parse('addbutton','add');
}
else
{
$GLOBALS['egw']->template->set_var('addbutton','');
}
$GLOBALS['egw']->template->pparse('out','list');
}
function display_row($label, $value)
{
$GLOBALS['egw']->template->set_var('tr_color',$this->nextmatchs->alternate_row_color());
$GLOBALS['egw']->template->set_var('label',$label);
$GLOBALS['egw']->template->set_var('value',$value);
$GLOBALS['egw']->template->parse('rows','row',True);
}
function add()
{
if ($GLOBALS['egw']->acl->check('applications_access',2,'admin'))
{
$GLOBALS['egw']->redirect_link('/index.php');
}
$start = get_var('start',array('POST','GET'));
$GLOBALS['egw']->template->set_file(array('application' => 'application_form.tpl'));
$GLOBALS['egw']->template->set_block('application','form','form');
$GLOBALS['egw']->template->set_block('application','row','row');
$GLOBALS['egw']->template->set_block('form','delete_button');
$GLOBALS['egw']->template->set_var('delete_button','');
if ($_POST['cancel'])
{
$GLOBALS['egw']->redirect_link('/index.php','menuaction=admin.uiapplications.get_list&start='.$start);
}
if ($_POST['save'])
{
$totalerrors = 0;
$app_order = $_POST['app_order'] ? $_POST['app_order'] : 0;
$n_app_name = chop($_POST['n_app_name']);
$n_app_status = $_POST['n_app_status'];
if ($this->bo->exists($n_app_name))
{
$error[$totalerrors++] = lang('That application name already exists.');
}
if (preg_match("/\D/",$app_order))
{
$error[$totalerrors++] = lang('That application order must be a number.');
}
if (!$n_app_name)
{
$error[$totalerrors++] = lang('You must enter an application name.');
}
if (!$totalerrors)
{
$this->bo->add(array(
'n_app_name' => $n_app_name,
'n_app_status' => $n_app_status,
'app_order' => $app_order
));
$GLOBALS['egw']->redirect_link('/index.php','menuaction=admin.uiapplications.get_list&start='.$start);
$GLOBALS['egw']->common->egw_exit();
}
else
{
$GLOBALS['egw']->template->set_var('error','