Example #1
0
$DisableCacheDeleteButton = $DeleteModel || is_null($ModelID) || !$CurrentUser->hasPermission(RIGHT_CACHE_DELETE);
$TagsInDB = Tag::GetTags();
$TagsThisModel = Tag2All::GetTag2Alls(new Tag2AllSearchParameters(FALSE, FALSE, FALSE, $ModelID, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE));
if ($ModelID) {
    $Models = Model::GetModels(new ModelSearchParameters($ModelID));
    if ($Models) {
        $Model = $Models[0];
    } else {
        HTMLstuff::RefererRedirect();
    }
} else {
    $Model = new Model(NULL, $lang->g('NavigationNewModel'));
}
if (array_key_exists('hidAction', $_POST) && $_POST['hidAction'] == 'ModelView') {
    $Model->setFirstName(Utils::NullIfEmpty($_POST['txtFirstName']));
    $Model->setLastName(Utils::NullIfEmpty($_POST['txtLastName']));
    if ($_POST['txtBirthDate'] && $_POST['txtBirthDate'] != 'YYYY-MM-DD' && strtotime($_POST['txtBirthDate']) !== FALSE) {
        $Model->setBirthDate(strtotime($_POST['txtBirthDate']));
    } else {
        $Model->setBirthDate(-1);
    }
    $tags = Tag::GetTagArray($_POST['txtTags']);
    $Model->setRemarks(Utils::NullIfEmpty($_POST['txtRemarks']));
    if ($Model->getID()) {
        if ($DeleteModel) {
            if ($CurrentUser->hasPermission(RIGHT_MODEL_DELETE) && Model::Delete($Model, $CurrentUser)) {
                header('location:index.php');
                exit;
            }
        } else {
            if ($CurrentUser->hasPermission(RIGHT_MODEL_EDIT) && Model::Update($Model, $CurrentUser)) {