public function subir($contrato_id)
 {
     $this->contrato = $contrato_id;
     if (Input::hasPost('oculto')) {
         //para saber si se envió el form
         $_FILES['archivo']['name'] = date("Y_m_d_H_i_s_") . $_FILES['archivo']['name'];
         $archivo = Upload::factory('archivo');
         //llamamos a la libreria y le pasamos el nombre del campo file del formulario
         $archivo->setExtensions(array('pdf'));
         //le asignamos las extensiones a permitir
         $url = '/files/upload/';
         $archivo->setPath(getcwd() . $url);
         if ($archivo->isUploaded()) {
             if ($archivo->save()) {
                 Flash::valid('Archivo subido correctamente!!!');
                 $nuevo_documento = new Documentos(Input::post("documentos"));
                 // $nuevo_documento->contratos_id = $contrato_id;
                 // $nuevo_documento->subido_por = Auth::get("id");
                 // $nuevo_documento->tipo_documento = ;
                 $nuevo_documento->url = $url . $_FILES['archivo']['name'];
                 if ($nuevo_documento->save()) {
                     Flash::valid("Documento Guardado");
                 } else {
                     Flash::error("No se pudo guardar el documento");
                 }
             }
         } else {
             Flash::warning('No se ha Podido Subir el Archivo...!!!');
         }
     }
 }
Beispiel #2
0
 public function postEdit($slug)
 {
     $album = $this->repo->album($slug);
     if (!\Request::get('name')) {
         \Flash::error('Musisz podać nazwę.');
         return \Redirect::back()->withInput();
     }
     $name = \Request::get('name');
     $slug = \Str::slug($name);
     $description = \Request::get('description');
     $exists = $this->repo->album($slug);
     if ($exists && $exists->id != $album->id) {
         \Flash::error('Album z tą nazwą już istnieje.');
         return \Redirect::back()->withInput();
     }
     if (\Input::hasFile('image')) {
         $image_name = \Str::random(32) . \Str::random(32) . '.png';
         $image = \Image::make(\Input::file('image')->getRealPath());
         $image->save(public_path('assets/gallery/album_' . $image_name));
         $callback = function ($constraint) {
             $constraint->upsize();
         };
         $image->widen(480, $callback)->heighten(270, $callback)->resize(480, 270);
         $image->save(public_path('assets/gallery/album_thumb_' . $image_name));
         $album->image = $image_name;
     }
     $album->name = $name;
     $album->slug = $slug;
     $album->description = $description;
     $album->save();
     \Flash::success('Pomyślnie edytowano album.');
     return \Redirect::to('admin/gallery/' . $slug . '/edit');
 }
 function add_to_gallery()
 {
     $gallery_peer = new GalleryPeer();
     $gallery = $gallery_peer->find_by_id(Params::get("id_gallery"));
     $collection_peer = new GalleryCollectionPeer();
     $gallery_collection = $collection_peer->find_by_id($gallery->id_gallery_collection);
     $full_folder_path = GalleryCollectionController::GALLERY_COLLECTION_ROOT_DIR . $gallery_collection->folder . "/" . $gallery->folder;
     if (Upload::isUploadSuccessful("file")) {
         $filename = Random::newHexString() . "_" . Upload::getRealFilename("file");
         $gallery_dir = new Dir($full_folder_path);
         $uploaded_img = Upload::saveTo("file", $gallery_dir, $filename);
         if (isset(Config::instance()->GALLERY_RESIZE_BY_WIDTH)) {
             image_w($uploaded_img->getPath(), Config::instance()->GALLERY_RESIZE_BY_WIDTH);
         } else {
             if (isset(Config::instance()->GALLERY_RESIZE_BY_HEIGHT)) {
                 image_h($uploaded_img->getPath(), Config::instance()->GALLERY_RESIZE_BY_HEIGHT);
             }
         }
         $peer = new GalleryImagePeer();
         $do = $peer->new_do();
         $peer->setupByParams($do);
         $do->image_name = $filename;
         $peer->save($do);
         return Redirect::success();
     } else {
         Flash::error(Upload::getUploadError("file"));
         return Redirect::failure();
     }
 }
 public function after_validation()
 {
     if ($this->edad < 18 || $this->edad > 70) {
         Flash::error('Los usuarios deben de tener entre 18 y 70 años');
         return 'cancel';
     }
 }
 function add()
 {
     if (Upload::isUploadSuccessful("my_file")) {
         $peer = new ImmaginiPeer();
         $do = $peer->new_do();
         $peer->setupByParams($do);
         $d = new Dir("/immagini/user/" . Session::get("/session/username") . Params::get("folder"));
         if (!$d->exists()) {
             $d->touch();
         }
         $do->save_folder = $d->getPath();
         $do->real_name = Upload::getRealFilename("my_file");
         $do->folder = Params::get("folder");
         $tokens = explode(".", Upload::getRealFilename("my_file"));
         $extension = $tokens[count($tokens) - 1];
         $do->hash_name = md5(uniqid()) . "." . strtolower($extension);
         Upload::saveTo("my_file", $do->save_folder, $do->hash_name);
         $peer->save($do);
         if (is_html()) {
             Flash::ok("Immagine aggiunta con successo.");
             return Redirect::success();
         } else {
             return ActiveRecordUtils::toArray($do);
         }
     } else {
         Flash::error(Upload::getUploadError("my_file"));
         return Redirect::failure();
     }
 }
 function invia_commento()
 {
     try {
         $nome = Params::get("nome");
         $subject = Params::get("subject");
         $email = Params::get("email");
         $testo = Params::get("testo");
         //$codice_hidden = Params::get("codice_hidden");
         //$codice = Params::get("codice");
         //if ($codice_hidden!=$codice)
         //    throw new InvalidParameterException("Il codice non e' impostato correttamente!!");
         if ($nome != null && $subject != null && $email != null && $testo != null && isset(Config::instance()->EMAIL_COMMENT_RECEIVED)) {
             $e = new EMail("no_reply@" . Host::current_no_www(), Config::instance()->EMAIL_COMMENT_RECEIVED, "[Nuova commento da : " . $nome . "] - " . Host::current(), EMail::HTML_FORMAT);
             $e->render_and_send("include/messages/mail/alert/" . Lang::current() . "/nuovo_commento.php.inc", array("nome" => $nome, "email" => $email, "subject" => $subject, "testo" => $testo));
             return Redirect::success();
         } else {
             if (!isset(Config::instance()->EMAIL_COMMENT_RECEIVED)) {
                 throw new InvalidDataException("Il parametri di configurazione EMAIL_COMMENT_RECEIVED non e' impostato correttamente!!");
             } else {
                 throw new InvalidDataException("I dati immessi nella form non sono validi!!");
             }
         }
     } catch (Exception $ex) {
         Flash::error($ex->getMessage());
         return Redirect::failure();
     }
 }
 public function sala()
 {
     // http://gravatar.com/avatar/
     $this->title = 'Sala de Asistencia';
     if (Input::post("nombre") and Input::post("email") and Input::post("ayuda")) {
         $usuario = new Usuario();
         $usuario->nombre = Input::post("nombre");
         $usuario->email = Input::post("email");
         $usuario->online = 1;
         if ($usuario->save()) {
             $id = $usuario->find('columns: id', 'limit: 1', 'order: id desc');
             $canal = new Canal();
             $this->imagen = $this->get_gravatar($usuario->email);
             $imagen = "<img style='float:left;padding:4px;' src='" . $this->imagen . "' width=\"50\" alt=\"Tu Imagen\">";
             $canal->mensaje = "<span style='float:left;padding-top:10px;'>" . $imagen . "<b>" . $usuario->nombre . "(" . $usuario->email . ")</b>: <br>" . Input::post("ayuda") . "</span> <div class='clearfix'></div>";
             $canal->identificador_canal = md5(Input::post("email") . date("Y-m-d") . $id[0]->id);
             $canal->usuario_id = $id[0]->id;
             if ($canal->save()) {
                 $this->nombre = Input::post("nombre");
                 $this->email = Input::post("email");
                 $this->identificador_canal = $canal->identificador_canal;
                 $this->usuario_id = $canal->usuario_id;
             } else {
                 Flash::error("No se pudo abrir un canal de asistencia, Vuelva a intentarlo por favor!");
                 Router::redirect("index/chat");
             }
         } else {
             Flash::error("No pudo ingresar a una sala de asistencia, por favor intentelo de nuevo");
         }
     } else {
         Flash::error("El nombre, email y la consulta de como podemos ayudarte, son obligatorios");
         Router::redirect("index/chat");
     }
 }
 public function getExtend($uid, $period)
 {
     /* @var $user User */
     $user = User::find($uid);
     if (empty($user->announcement_stream)) {
         Flash::error('Пользователь не подписан на рассылку.');
         return Redirect::to('admin/subscriptions');
     }
     // Already has an active subscription.
     if ($user->announcement_expires && $user->announcement_expires->isFuture()) {
         $user->announcement_expires = $user->announcement_expires->addDays($period);
     }
     // Subscription expired.
     if ($user->announcement_expires && $user->announcement_expires->isPast()) {
         // Start tomorrow.
         $start = new Carbon();
         $start->setTime(0, 0, 0)->addDays(1);
         $user->announcement_start = $start;
         // Expire in $period from tomorrow.
         $expires = clone $start;
         $expires->addDays($period);
         $user->announcement_expires = $expires;
     }
     $user->save();
     Flash::success('Подписка продленна.');
     return Redirect::to('admin/subscriptions');
 }
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, \Closure $next)
 {
     if (\Setting::get('user::enable-profile')) {
         return $next($request);
     }
     \Flash::error(trans('user::messages.profile disabled'));
     return \Redirect::route('dashboard.index');
 }
 protected function before_filter()
 {
     // Verificando si el rol del usuario actual tiene permisos para la acción a ejecutar
     if (!$this->acl->is_allowed($this->userRol, $this->controller_name, $this->action_name)) {
         Flash::error("Acceso negado");
         return Router::redirect("usuario/ingresar");
     }
 }
 /**
  * Borra un Registro
  */
 public function borrar($id)
 {
     if (!Load::model($this->model)->delete((int) $id)) {
         Flash::error('Falló Operación');
     }
     //enrutando al index para listar los articulos
     Redirect::to();
 }
Beispiel #12
0
 /**
  * Se verifica mediante un callback de ActiveRecord
  * que el perfil a eliminar no se encuentre asociado
  * algún controller
  */
 public function before_delete()
 {
     $controller = new Controllers();
     if ($controller->count("perfil_id={$this->id}")) {
         Flash::error('El perfil no se puede eliminar porque esta asociado');
         return 'cancel';
     }
 }
 public function banear($id, $tiempo = null)
 {
     View::select(null);
     $usuario = new Usuario();
     $ban = $usuario->banear($id);
     Flash::error('Usuario baneado hasta el ' . $ban);
     Redirect::to('index');
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $tag = Tag::find($id);
     if (empty($tag)) {
         Flash::error('Tag not found');
         return redirect(route('admin.tags.index'));
     }
     return view('admin.tags.show')->with('tag', $tag);
 }
Beispiel #15
0
 public function store(PostRequest $request)
 {
     //        Post::create($request->all());
     $this->post = new Post();
     $this->post->fill($request->all());
     $tmp_post_id = $_POST['post_id'];
     if ($tmp_post_id == '-1') {
         //新規作成
         $this->post->post_id = Post::max('post_id') + 1;
         $this->post->res_id = 0;
     } else {
         $this->post->post_id = $tmp_post_id;
         $this->post->res_id = Post::where('post_id', '=', $tmp_post_id)->max('res_id') + 1;
     }
     if ($this->post->contributor == null || $this->post->contributor == "") {
         $this->post->contributor = 'No name';
     }
     $image = Input::file('data');
     //        dd(var_dump($image));
     if (!empty($image)) {
         if ($image->getClientSize() > 10000000) {
             \Flash::error('アップロードは10M以下の画像ファイル(ipg, png, gif)のみです。');
             return redirect()->back();
         }
         $this->post->fig_mime = $image->getMimeType();
         switch ($this->post->fig_mime) {
             case "image/jpeg":
                 $flag = TRUE;
                 break;
             case "image/png":
                 $flag = TRUE;
                 break;
             case "image/gif":
                 $flag = TRUE;
                 break;
             default:
                 $flag = FALSE;
         }
         if ($flag == FALSE) {
             \Flash::error('アップロード可能な画像ファイルは jpg, png, gif のみです。');
             return redirect()->back();
         }
         $name = md5(sha1(uniqid(mt_rand(), true))) . '.' . $image->getClientOriginalExtension();
         $upload = $image->move('media', $name);
         #サムネイル作成
         Image::make('media/' . $name)->resize(400, 400)->save('media/mini/' . $name);
         $this->post->fig_name = $name;
         //            $this->post->fig_orig = file_get_contents($image);
     }
     $this->post->save();
     \Flash::success('記事が投稿されました。');
     if ($tmp_post_id == '-1') {
         //新規作成
         return redirect()->route('posts.index');
     }
     return redirect()->route('posts.show', [$tmp_post_id]);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $user = User::find($id);
     if (empty($user)) {
         Flash::error('Lesson not found');
         return redirect(route('admin.users.index'));
     }
     return view('site.users.show')->with('user', $user);
 }
 protected final function initialize()
 {
     if (Router::get('controller') == 'usuarios' || Router::get('controller') == 'reportes') {
         if (!Auth::is_valid()) {
             Flash::error('Necesita ser un administrador e iniciar sesión para acceder a esta zona.');
             Redirect::to('index');
         }
     }
 }
 /**
  * Preview PDF template
  *
  * @param $recordId
  * @return mixed
  */
 public function preview($recordId)
 {
     try {
         $model = $this->formFindModelObject($recordId);
         return PDFTemplate::render($model->code);
     } catch (Exception $ex) {
         Flash::error($ex->getMessage());
     }
 }
 /**
  * Valida el archivo antes de guardar
  * 
  * @return boolean
  */
 protected function _validates()
 {
     // Verifica que se pueda escribir en el directorio
     if (!is_writable($this->_path)) {
         Flash::error('Error: no se puede escribir en el directorio');
         return FALSE;
     }
     return parent::_validates();
 }
Beispiel #20
0
 public function delete(Sprint $sprint)
 {
     if ($sprint->delete()) {
         Flash::success('The sprint was deleted.');
         return Redirect::route('project_path', ['project' => $sprint->project->slug]);
     } else {
         Flash::error('The sprint could not be deleted. Please try again.');
         return Redirect::back();
     }
 }
 public function delete($id_contacto, $id_usuario_contacto)
 {
     $contacto = Load::model("contactos")->find($id_contacto);
     if ($contacto->delete()) {
         Flash::valid("Contacto Eliminado");
     } else {
         Flash::error("No se eliminó el contacto");
     }
     Router::redirect("contactos/usuario/{$id_usuario_contacto}");
 }
 public function delete(SprintSnapshot $snapshot)
 {
     if ($snapshot->delete()) {
         Flash::success('The snapshot was deleted.');
         return Redirect::route('sprint_path', ['sprint' => $snapshot->sprint->phabricator_id]);
     } else {
         Flash::error('The snapshot could not be deleted. Please try again.');
         return Redirect::back();
     }
 }
 public function eliminarasignatura($profesor_id, $codigo)
 {
     $profesorasignatura = new Profesorasignatura();
     if ($profesorasignatura->eliminar($profesor_id, $codigo)) {
         Flash::valid("Asignatura Eliminada");
     } else {
         Flash::error("Asignatura no eliminada");
     }
     Router::redirect("profesor/asignatura/{$profesor_id}");
 }
 public function delete($id)
 {
     $role = Load::model("roles")->find($id);
     if ($role->delete()) {
         Flash::valid("role Eliminado");
     } else {
         Flash::error("No se elimino el role");
     }
     Router::redirect("roles/");
 }
 public function delete($id)
 {
     $usuario = Load::model("usuarios")->find($id);
     if ($usuario->delete()) {
         Flash::valid("Usuario Eliminado");
     } else {
         Flash::error("No se elimino el usuario");
     }
     Router::redirect("usuarios/");
 }
 public function deleteDelete($statusId)
 {
     $status = \App\Status::find($statusId);
     if (!$status) {
         \Flash::error('Status not found');
         return redirect('statuses');
     }
     $status->delete();
     \Flash::success('Status Deleted');
     return redirect('statuses');
 }
 /**
  * Log user in after doing the validation
  *
  * @param  Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['email' => 'required', 'password' => 'required']);
     if ($this->signIn($request)) {
         // Authentication passed...
         \Flash::success('Welcome in ' . Auth::user()->name);
         return redirect()->intended('/articles');
     }
     \Flash::error('Sorry your login credentials didn\'t match');
     return redirect()->back();
 }
 /**
  * Store a newly created resource in storage.
  * POST /sessions
  *
  * @return Response
  */
 public function store()
 {
     $formData = Input::only('email', 'password');
     $this->signInForm->validate($formData);
     if (!Auth::attempt($formData)) {
         Flash::error('Felaktiga uppgifter!');
         return Redirect::back()->withInput();
     }
     Flash::message('Välkommen tillbaka!');
     return Redirect::intended('/statuses');
 }
 /**
  * Eliminar un menu
  *
  * @param int $id
  */
 public function borrar($id = null)
 {
     if ($id) {
         if (!Load::model($this->model)->delete($id)) {
             Flash::error('Falló Operación');
         }
     }
     //enrutando al index para listar los articulos
     Router::redirect("{$this->controller_path}");
     View::select(NULL, NULL);
 }
 public function store(Request $request)
 {
     $data = $request->all();
     $station_data = StationData::create($data);
     if ($station_data->id) {
         \Flash::success("Saved! Athlete ID: " . $station_data->athlete_id . ' Data: ' . $station_data->data);
     } else {
         \Flash::error("Something happened and we could not save this data! Please seek assistance!");
     }
     return redirect()->back();
 }