File Manager
<?php
if( !isset($gCms) ) exit;
if( !$this->CheckPermission('Manage Calendar Attributes') ) return;
$this->SetCurrentTab('admin_manage_categories');
// handle cancel
if( isset($params['cancel']) ) $this->RedirectToTab($id);
// setup
$catid = (int)cge_utils::get_param($params,'catid');
$category = null;
try {
// create/get initial empty category (for adding)
$category = new \CGCalendar\category;
// if we have a category load it.
if( $catid > 0 ) $category = \CGCalendar\category::load($catid);
// handle submit
if( isset($params['submit']) ) {
// merge the form data into the category
$category['name'] = $params['name'];
$category['bgcolor'] = $params['bgcolor'];
$category['fgcolor'] = $params['fgcolor'];
// save
$category->save();
// redirect outa here.
$this->SetMessage($this->Lang('categoryupdated'));
$this->RedirectToTab();
}
}
catch( Exception $e ) {
echo $this->ShowErrors($e->GetMessage());
}
// give the category to smarty
$parms = array();
if( $catid > 0 ) $parms['catid'] = $catid;
$smarty->assign('formstart',$this->CGCreateFormStart($id,'admin_addedit_category',$returnid,$parms));
$smarty->assign('formend',$this->CreateFormEnd());
$smarty->assign('category',$category);
// display the template
echo $this->ProcessTemplate('admin_addedit_category.tpl');
?>
File Manager Version 1.0, Coded By Lucas
Email: hehe@yahoo.com