Ejemplo n.º 1
0
 function launch()
 {
     global $interface;
     global $configArray;
     global $user;
     //If the user isn't logged in, take them to the login page
     if (!$user) {
         header("Location: {$configArray['Site']['path']}/MyAccount/Login");
         die;
     }
     //Make sure the user has permission to access the page
     if (!$user->hasRole('epubAdmin')) {
         $interface->setTemplate('../Admin/noPermission.tpl');
         $interface->display('layout.tpl');
         exit;
     }
     $structure = EContentRecord::getObjectStructure();
     if (isset($_REQUEST['submitStay']) || isset($_REQUEST['submit']) || isset($_REQUEST['submitReturnToList']) || isset($_REQUEST['submitAddAnother'])) {
         //Save the object
         $results = DataObjectUtil::saveObject($structure, 'EContentRecord');
         $eContentRecord = $results['object'];
         //redirect to the view of the eContentRecord if we saved ok.
         if (!$results['validatedOk'] || !$results['saveOk']) {
             //Display the errors for the user.
             $interface->assign('errors', $results['errors']);
             $interface->assign('object', $eContentRecord);
             $_REQUEST['id'] = ${$eContentRecord}->id;
         } else {
             //Show the new tip that was created
             header('Location:' . $configArray['Site']['path'] . "/EcontentRecord/{$eContentRecord->id}/Home");
             exit;
         }
     }
     $isNew = true;
     if (isset($_REQUEST['id']) && strlen($_REQUEST['id']) > 0 && is_numeric($_REQUEST['id'])) {
         $object = EContentRecord::staticGet('id', strip_tags($_REQUEST['id']));
         $interface->assign('object', $object);
         $interface->setPageTitle('Edit EContentRecord');
         $isNew = false;
     } else {
         $interface->setPageTitle('Submit a New EContentRecord');
     }
     //Manipulate the structure as needed
     if ($isNew) {
     } else {
     }
     $interface->assign('isNew', $isNew);
     $interface->assign('submitUrl', $configArray['Site']['path'] . '/EcontentRecord/Edit');
     $interface->assign('editForm', DataObjectUtil::getEditForm($structure));
     $interface->setTemplate('edit.tpl');
     $interface->display('layout.tpl');
 }