Exemple #1
0
 public function create()
 {
     if (empty($_SESSION['user'])) {
         $_SESSION['jumpto'] = '/project/create';
         Message::Info(Text::get('user-login-required-to_create'));
         throw new Redirection(SEC_URL . "/user/login");
     }
     if ($_POST['action'] != 'continue' || $_POST['confirm'] != 'true') {
         throw new Redirection("/about/howto");
     }
     $project = new Model\Project();
     if ($project->create(\GOTEO_NODE)) {
         $_SESSION['stepped'] = array();
         // permisos para editarlo y borrarlo
         ACL::allow('/project/edit/' . $project->id . '/', '*', 'user', $_SESSION['user']->id);
         ACL::allow('/project/delete/' . $project->id . '/', '*', 'user', $_SESSION['user']->id);
         // Evento Feed
         $log = new Feed();
         $log->setTarget($_SESSION['user']->id, 'user');
         $log->populate('usuario crea nuevo proyecto', 'admin/projects', \vsprintf('%s ha creado un nuevo proyecto, %s', array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('project', $project->name, $project->id))));
         $log->doAdmin('project');
         unset($log);
         throw new Redirection("/project/edit/{$project->id}");
     }
     throw new \Goteo\Core\Exception('Fallo al crear un nuevo proyecto');
 }