Ejemplo n.º 1
0
 public function IndexAction()
 {
     $da = $this->get("we_data_access");
     $request = $this->getrequest();
     $fileElementName = $request->get("filename");
     $success = true;
     $msg = "";
     $fileid = "";
     try {
         $filename = $_FILES[$fileElementName]['name'];
         $filesize = $_FILES[$fileElementName]['size'];
         $filetemp = $_FILES[$fileElementName]['tmp_name'];
         $dm = $this->get('doctrine.odm.mongodb.document_manager');
         $fileid = Utils::saveFile($filetemp, $dm);
         if (empty($fileid)) {
             $success = false;
             $msg = '文件上传失败';
         }
     } catch (\Exception $e) {
         $this->logger->err($e->getMessage());
         $msg = $e->getMessage();
     }
     $result = array("success" => $success, "msg" => $msg, "fileid" => $fileid);
     $response = new Response(json_encode($result));
     $response->headers->set('Content-Type', 'text/html');
     return $response;
     //return $this->render('JustsyAdminAppBundle:Sys:parameter.html.twig');
 }
Ejemplo n.º 2
0
 public function saveLogoAction()
 {
     $DataAccess = $this->get('we_data_access');
     $da_im = $this->get('we_data_access_im');
     $request = $this->getRequest();
     $group_id = $request->get("groupid");
     $group_photo_path = '';
     try {
         $session = $this->get('session');
         $dm = $this->get('doctrine.odm.mongodb.document_manager');
         $group_photo_path = $session->get('avatar_middle');
         $group_photo_path_big = $session->get('avatar_big');
         $group_photo_path_small = $session->get('avatar_small');
         $group_photo_path = Utils::saveFile($group_photo_path, $dm);
         //$group_photo_path_big=$this->saveFile($group_photo_path_big,$dm);
         unlink($group_photo_path_big);
         //$group_photo_path_small=$this->saveFile($group_photo_path_small,$dm);
         unlink($group_photo_path_small);
         $session->remove('avatar_middle');
         $session->remove('avatar_big');
         $session->remove('avatar_small');
         $session->set('group_photo_path', $group_photo_path);
         if (!empty($group_id)) {
             $sql = 'select group_id,group_photo_path,fafa_groupid,group_name from we_groups where group_id=?';
             $dataset = $DataAccess->GetData('we_groups', $sql, array((string) $group_id));
             if ($dataset != null && count($dataset['we_groups']['rows']) > 0) {
                 $this->deleteFile($dataset['we_groups']["rows"][0]["group_photo_path"], $dm);
                 $sql = "update we_groups set group_photo_path=? where group_id=? ";
                 $para = array($group_photo_path, $group_id);
                 $DataAccess->ExecSQL($sql, $para);
                 //取群成员
                 $sql = "SELECT b.fafa_jid FROM we_group_staff a LEFT JOIN we_staff b ON a.login_account=b.login_account WHERE a.group_id=? AND b.fafa_jid IS NOT NULL";
                 $para = array($group_id);
                 $data = $DataAccess->GetData('dt', $sql, $para);
                 //var_dump($sql,$para);
                 if ($data != null && count($data['dt']['rows']) > 0 && !empty($group_photo_path)) {
                     //修改头像之后需要发出席消息。让各端及时修改头像
                     $user = $this->get('security.context')->getToken()->getUser();
                     $fafa_jid = $user->fafa_jid;
                     $tojid = array();
                     for ($i = 0; $i < count($data['dt']['rows']); $i++) {
                         array_push($tojid, $data['dt']['rows'][$i]['fafa_jid']);
                     }
                     $groupjid = $dataset['we_groups']["rows"][0]["fafa_groupid"];
                     $groupname = $dataset['we_groups']["rows"][0]["group_name"];
                     $message = json_encode(array('group_id' => $group_id, 'logo_path' => $group_photo_path, 'jid' => $groupjid, 'group_name' => $groupname));
                     //var_dump($groupjid,$group_id,$tojid,$fafa_jid);
                     Utils::sendImMessage($fafa_jid, implode(",", $tojid), "group_info_change", $message, $this->container, "", "", false, Utils::$systemmessage_code);
                 }
             }
         }
     } catch (\Exception $e) {
         $this->get('logger')->err($e);
         $group_photo_path = '';
     }
     $response = new Response(json_encode(array('group_photo_path' => $group_photo_path)));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
Ejemplo n.º 3
0
 public function uploadheadimageorlogoAction()
 {
     $re = array("returncode" => ReturnCode::$SUCCESS);
     $request = $this->getRequest();
     $user = $this->get('security.context')->getToken()->getUser();
     $dm = $this->get('doctrine.odm.mongodb.document_manager');
     $da = $this->get("we_data_access");
     // multipart/form-data
     $filepath = $_FILES['filepath']['tmp_name'];
     if (empty($filepath)) {
         $filepath = tempnam(sys_get_temp_dir(), "we");
         unlink($filepath);
         $somecontent1 = base64_decode($request->get('filedata'));
         if ($handle = fopen($filepath, "w+")) {
             if (!fwrite($handle, $somecontent1) == FALSE) {
                 fclose($handle);
             }
         }
     }
     $filepath_24 = $filepath . "_24";
     $filepath_48 = $filepath . "_48";
     try {
         if (empty($filepath)) {
             throw new \Exception("param is null");
         }
         $im = new \Imagick($filepath);
         $im->scaleImage(48, 48);
         $im->writeImage($filepath_48);
         $im->destroy();
         $im = new \Imagick($filepath);
         $im->scaleImage(24, 24);
         $im->writeImage($filepath_24);
         $im->destroy();
         if (!empty($filepath)) {
             $filepath = Utils::saveFile($filepath, $dm);
         }
         if (!empty($filepath_48)) {
             $filepath_48 = Utils::saveFile($filepath_48, $dm);
         }
         if (!empty($filepath_24)) {
             $filepath_24 = Utils::saveFile($filepath_24, $dm);
         }
         $re["returncode"] = ReturnCode::$SUCCESS;
         $re["filepath"] = $filepath_48;
         $re["filepath_small"] = $filepath_24;
         $re["filepath_big"] = $filepath;
     } catch (\Exception $e) {
         $re["returncode"] = ReturnCode::$SYSERROR;
         $this->get('logger')->err($e);
     }
     $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
Ejemplo n.º 4
0
 public function setgrouplogoAction()
 {
     $request = $this->getRequest();
     $groupid = $request->get("groupid");
     $dm = $this->container->get('doctrine.odm.mongodb.document_manager');
     $da = $this->get('we_data_access_im');
     $photofile = "";
     try {
         $photofile = empty($_FILES['photofile']) ? null : $_FILES['photofile']['tmp_name'];
     } catch (\Exception $e) {
     }
     if (empty($photofile)) {
         $photofile = tempnam(sys_get_temp_dir(), "we");
         unlink($photofile);
         $somecontent1 = base64_decode($request->get('photodata'));
         if ($handle = fopen($photofile, "w+")) {
             if (!fwrite($handle, $somecontent1) == FALSE) {
                 fclose($handle);
             }
         }
     }
     $returncode = "0000";
     $path = "";
     try {
         if (empty($photofile)) {
             throw new \Exception("param is null");
         }
         $im = new \Imagick($photofile);
         $im->scaleImage(120, 120);
         $im->writeImage($photofile);
         $im->destroy();
         $sql = "select logo from im_group where groupid=?;";
         $table = $da->GetData("group", $sql, array((string) $groupid));
         if ($table && $table["group"]["recordcount"] > 0) {
             $file = $table["group"]["rows"][0]["logo"];
             if (!empty($file)) {
                 Utils::removeFile($table["group"]["rows"][0]["logo"], $dm);
             }
         }
         $fileid = "";
         if (!empty($photofile)) {
             $fileid = Utils::saveFile($photofile, $dm);
         }
         $sql = "update im_group set logo=? where groupid=?;";
         try {
             $da->ExecSQL($sql, array((string) $fileid, (string) $groupid));
         } catch (\Exception $e) {
             $this->get("logger")->err($e->getMessage());
         }
         if (!empty($fileid)) {
             $path = $this->container->getParameter('FILE_WEBSERVER_URL');
             $path = $path . $fileid;
         }
         $path = $path . $fileid;
         //发送出席
         $groupMgr = new \Justsy\BaseBundle\Management\GroupMgr($this->get('we_data_access'), $da, $this->container);
         $groupObj = $groupMgr->getGroupMemberJid($groupid);
         $to_jid = $groupObj["member_jid"];
         $groupname = $groupObj["groupname"];
         $user = $this->get('security.context')->getToken()->getUser();
         $nick_name = $user->nick_name;
         $send_jid = $user->fafa_jid;
         if (!empty($to_jid)) {
             $title = "group-changelogo";
             $message = $nick_name . "修改了群(" . $groupname . ")头像!";
             Utils::sendImPresence($send_jid, $to_jid, $title, $message, $this->container, "", "", false, Utils::$systemmessage_code);
         }
     } catch (\Exception $e) {
         $returncode = "9999";
         $this->get("logger")->err($e->getMessage());
     }
     $result = array("returncode" => $returncode, "fileid" => $fileid, "path" => $path);
     $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($result) . ");" : json_encode($result));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
Ejemplo n.º 5
0
 public function savelogoAction()
 {
     $user = $this->get('security.context')->getToken()->getUser();
     $re = array();
     $request = $this->get('request');
     $session = $this->get('session');
     $fileid = '';
     $re = array('s' => 1, 'm' => '', 'fileid' => '');
     try {
         $filename120 = $session->get("avatar_big");
         $session->remove("avatar_big");
         $session->remove("avatar_middle");
         $session->remove("avatar_small");
         if (!empty($filename120)) {
             $fileid = Utils::saveFile($filename120, $this->get('doctrine.odm.mongodb.document_manager'));
             $session->set('group_logo_id', $fileid);
         }
         $re = array('s' => 1, 'm' => '', 'fileid' => $fileid);
     } catch (\Exception $e) {
         $this->get('logger')->err($e);
         $re = array('s' => 0, 'm' => '上传失败', 'fileid' => '');
     }
     $response = new Response(json_encode($re));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
Ejemplo n.º 6
0
 public function modifygrouplogoAction()
 {
     $re = array("returncode" => ReturnCode::$SUCCESS);
     $user = $this->get('security.context')->getToken()->getUser();
     $dm = $this->get('doctrine.odm.mongodb.document_manager');
     $request = $this->getRequest();
     $circle_id = $request->get("circle_id");
     $group_id = $request->get("group_id");
     $filepath = $_FILES['filepath']['tmp_name'];
     if (empty($filepath)) {
         $filepath = tempnam(sys_get_temp_dir(), "we");
         unlink($filepath);
         $somecontent1 = base64_decode($request->get('filedata'));
         if ($handle = fopen($filepath, "w+")) {
             if (!fwrite($handle, $somecontent1) == FALSE) {
                 fclose($handle);
             }
         }
     }
     $da = $this->get("we_data_access");
     try {
         if (empty($circle_id) || empty($group_id) || empty($filepath)) {
             $re["returncode"] = ReturnCode::$SYSERROR;
             $re["error"] = "参数传递错误!";
             $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
         $filepath = Utils::saveFile($filepath, $dm);
         $sql = 'select group_id,group_photo_path,fafa_groupid,group_name from we_groups where group_id=? and circle_id=?';
         $dataset = $da->GetData('we_groups', $sql, array($group_id, $circle_id));
         if ($dataset != null && count($dataset['we_groups']['rows']) > 0) {
             Utils::removeFile($dataset['we_groups']["rows"][0]["group_photo_path"], $dm);
             $sql = "update we_groups set group_photo_path=? where group_id=? ";
             $para = array($filepath, $group_id);
             $da->ExecSQL($sql, $para);
             //取群成员
             $sql = "select b.fafa_jid from we_group_staff a left join  we_staff b on a.login_account=b.login_account where a.group_id=? and b.fafa_jid is not null";
             $para = array($group_id);
             $data = $da->GetData('dt', $sql, $para);
             if ($data != null && count($data['dt']['rows']) > 0) {
                 //修改头像之后需要发出席消息。让各端及时修改头像
                 $fafa_jid = $user->fafa_jid;
                 $tojid = array();
                 for ($i = 0; $i < count($data['dt']['rows']); $i++) {
                     array_push($tojid, $data['dt']['rows'][$i]['fafa_jid']);
                 }
                 $groupjid = $dataset['we_groups']["rows"][0]["fafa_groupid"];
                 $groupname = $dataset['we_groups']["rows"][0]["group_name"];
                 $message = json_encode(array('group_id' => $group_id, 'logo_path' => $filepath, 'jid' => $groupjid, 'group_name' => $groupname));
                 Utils::sendImMessage($fafa_jid, implode(",", $tojid), "group_info_change", $message, $this->container, "", "", false, Utils::$systemmessage_code);
             }
         }
         $re["returncode"] = ReturnCode::$SUCCESS;
         $re["filepath"] = $filepath;
     } catch (\Exception $e) {
         $re["returncode"] = ReturnCode::$SYSERROR;
         $re["error"] = "系统错误,创建圈子失败!";
         $this->get('logger')->err($e);
     }
     $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
Ejemplo n.º 7
0
 public function modifycirclelogoAction()
 {
     $re = array("returncode" => ReturnCode::$SUCCESS);
     $request = $this->getRequest();
     $user = $this->get('security.context')->getToken()->getUser();
     $dm = $this->get('doctrine.odm.mongodb.document_manager');
     $da = $this->get("we_data_access");
     $circleid = $request->get("circle_id");
     // multipart/form-data
     $filepath = $_FILES['filepath']['tmp_name'];
     if (empty($filepath)) {
         $filepath = tempnam(sys_get_temp_dir(), "we");
         unlink($filepath);
         $somecontent1 = base64_decode($request->get('filedata'));
         if ($handle = fopen($filepath, "w+")) {
             if (!fwrite($handle, $somecontent1) == FALSE) {
                 fclose($handle);
             }
         }
     }
     $filepath_24 = $filepath . "_24";
     $filepath_48 = $filepath . "_48";
     try {
         if (empty($circleid) || empty($filepath)) {
             $re["returncode"] = ReturnCode::$SYSERROR;
             $re["error"] = "参数传递错误!";
             $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
         $im = new \Imagick($filepath);
         $im->scaleImage(48, 48);
         $im->writeImage($filepath_48);
         $im->destroy();
         $im = new \Imagick($filepath);
         $im->scaleImage(24, 24);
         $im->writeImage($filepath_24);
         $im->destroy();
         if (!empty($filepath)) {
             $filepath = Utils::saveFile($filepath, $dm);
         }
         if (!empty($filepath_48)) {
             $filepath_48 = Utils::saveFile($filepath_48, $dm);
         }
         if (!empty($filepath_24)) {
             $filepath_24 = Utils::saveFile($filepath_24, $dm);
         }
         $sql = "select logo_path,logo_path_small,logo_path_big,fafa_groupid,circle_name from we_circle where circle_id=?";
         $table = $da->GetData("circle", $sql, array($circleid));
         if ($table && $table['circle']['recordcount'] > 0) {
             Utils::removeFile($table['circle']['rows'][0]['logo_path'], $dm);
             Utils::removeFile($table['circle']['rows'][0]['logo_path_small'], $dm);
             Utils::removeFile($table['circle']['rows'][0]['logo_path_big'], $dm);
         }
         $sql = "update we_circle set logo_path=?,logo_path_small=?,logo_path_big=? where circle_id=?";
         $params = array($filepath_48, $filepath_24, $filepath, $circleid);
         $da->ExecSQL($sql, $params);
         //取圈子成员
         $sql = "select b.fafa_jid from we_circle_staff a left join we_staff b on a.login_account=b.login_account where a.circle_id=? and b.fafa_jid is not null";
         $para = array($circleid);
         $data = $da->GetData('dt', $sql, $para);
         if ($data != null && count($data['dt']['rows']) > 0) {
             //修改头像之后需要发出席消息。让各端及时修改头像
             $fafa_jid = $user->fafa_jid;
             $tojid = array();
             for ($i = 0; $i < count($data['dt']['rows']); $i++) {
                 array_push($tojid, $data['dt']['rows'][$i]['fafa_jid']);
             }
             if ($table != null && count($table['circle']['rows']) > 0) {
                 $circlejid = $table["circle"]["rows"][0]["fafa_groupid"];
                 $circlename = $table["circle"]["rows"][0]["circle_name"];
                 $message = json_encode(array('circle_id' => $circleid, 'logo_path' => $filepath, 'circle_name' => $circlename, 'jid' => $circlejid));
                 Utils::sendImMessage($fafa_jid, implode(",", $tojid), "circle_info_change", $message, $this->container, "", "", false, Utils::$systemmessage_code);
             }
         }
         $re["returncode"] = ReturnCode::$SUCCESS;
         $re["filepath"] = $filepath_48;
         $re["filepath_small"] = $filepath_24;
         $re["filepath_big"] = $filepath;
     } catch (\Exception $e) {
         $re["returncode"] = ReturnCode::$SYSERROR;
         $re["error"] = "系统错误,创建圈子失败!";
         $this->get('logger')->err($e);
     }
     $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
Ejemplo n.º 8
0
 public function save_Photo($parameter)
 {
     $success = true;
     $session = $this->container->get('session');
     $path = $session->get("avatar_big");
     $dm = $this->container->get('doctrine.odm.mongodb.document_manager');
     $login_account = $parameter["login_account"];
     $fileid = Utils::saveFile($path, $dm);
     $session->remove("avatar_big");
     return array("success" => $success, "fileid" => $fileid);
 }