/** * ノーイメージ画像データ取得 * @return type */ private function getNoimageContent() { if (!self::$noimage_content) { $noimagePath = SwcUtils::getNoImageFilePath(); self::$noimage_content = file_get_contents($noimagePath); } return self::$noimage_content; }
/** * Metodo para subir SOLO IMAGENES al servidor y guardarlo en el sistema de archivos * @param _FILE $file archivo que se esta subiendo * @param Attachment Entidad con toda la informacion de un archivo a guardar * @return JSON respuesta del proceso de carga de archivo */ public static function uploadImages($file, $attachment = '') { $arr_response = array(); $file_image = $file; $file = array('image' => $file_image); $rules = array('image' => 'required'); //mimes:jpeg,bmp,png and for max size max:10000 // se valida que sea una imagen, esto es doble verificacion $validator = Validator::make($file, $rules); if ($validator->fails()) { $arr_response = array('valid' => false, 'error' => array('error' => $validator)); } else { $arr_response = AttachmentController::uploadAttachment($file, $attachment); } return $arr_response; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $user = User::find($id); $user->delete(); //Eliminamos imagen asociada de usuario AttachmentController::destroyAllBy('user_id', $user->id); return Redirect::to('admin/user'); }
/** * @param array $actionlist * @return array(title,content) */ function dispatch($actionlist) { // Less than two params is NOT a valid attachment handler // Example of valids: // * /attachment/Wiki/WikiAttachmentExample // * /attachment/Wiki/WikiAttachmentExample/test.jpg if (count($actionlist) < 2) { return array('Attachment Error', VoodooError::displayError('Incorrect SubController Actionlist')); } // We default to not having an attachment set $attachment = false; if (count($actionlist) == 3) { // The third action from the actionlist is the attachment list($controller, $action, $attachment) = $actionlist; } else { list($controller, $action) = $actionlist; } $this->cont = $controller; $this->action = $action; $lookup = $controller . ($attachment ? '.' . $attachment : ''); // We need at least view rights to continue if (!$this->privs->hasRights($_SESSION['access'], 'view', 'attachment', $this->conf['privileges'], $lookup)) { return array('Attachment Error', VoodooError::displayError('Permission Denied')); } require_once ATTACHMENT_CLASSES . 'Attachment.php'; $class = 'AttachmentLink'; // The controller is enabled. $uc = strtoupper($controller); // Lets see if the linked object has its own linked attachment object if (defined($uc . '_CLASSES')) { $conf = VoodooIni::load($controller); if (!isset($conf['attachment']) || !$conf['attachment']['attachment']) { return array('Attachment Error', VoodooError::displayError('This Controller Doesnt Support Attachments')); } if (isset($conf['attachment']['class'])) { if (!is_file(constant($uc . '_CLASSES') . $conf['attachment']['class'])) { return array('Attachment Error', VoodooError::displayError('This Controller Attachment Class doesnt exist.')); } require_once constant($uc . '_CLASSES') . $conf['attachment']['class']; $class = ucfirst($controller) . 'Attachment'; } } // Lets init a new link object $al = new $class($this->controller->DBConnect(), $uc); if (isset($_REQUEST['action'])) { switch ($_REQUEST['action']) { case 'download': $ad = new AttachmentDownload($this, $attachment, $al); return $ad->execute(); break; case 'create': $ac = new AttachmentCreate($this, $attachment, $al); return $ac->execute(); break; case 'delete': $ad = new AttachmentDelete($this, $attachment, $al); return $ad->execute(); break; case 'modify': break; } } // Display the attachment information, dont auto download $av = new AttachmentView($this, $attachment, $al); return $av->execute(); }