public function modifyavatarAction() { $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"); $login_account = $user->getUsername(); $photofile = $_FILES['photofile']['tmp_name']; 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); } } } $photofile_24 = $photofile . "_24"; $photofile_48 = $photofile . "_48"; try { if (empty($photofile)) { throw new \Exception("param is null"); } $im = new \Imagick($photofile); $im->scaleImage(48, 48); $im->writeImage($photofile_48); $im->destroy(); $im = new \Imagick($photofile); $im->scaleImage(24, 24); $im->writeImage($photofile_24); $im->destroy(); $table = $da->GetData("staff", "select photo_path,photo_path_small,photo_path_big \n from we_staff where login_account=?", array((string) $login_account)); if ($table && $table["staff"]["recordcount"] > 0) { Utils::removeFile($table["staff"]["rows"][0]["photo_path"], $dm); Utils::removeFile($table["staff"]["rows"][0]["photo_path_small"], $dm); Utils::removeFile($table["staff"]["rows"][0]["photo_path_big"], $dm); } if (!empty($photofile)) { $photofile = Utils::saveFile($photofile, $dm); } if (!empty($photofile_48)) { $photofile_48 = Utils::saveFile($photofile_48, $dm); } if (!empty($photofile_24)) { $photofile_24 = Utils::saveFile($photofile_24, $dm); } $da->ExecSQL("update we_staff set photo_path=?,photo_path_big=?,photo_path_small=? \n where login_account=?", array((string) $photofile_48, (string) $photofile, (string) $photofile_24, (string) $login_account)); $message = json_encode(array("path" => $this->container->getParameter('FILE_WEBSERVER_URL') . $photofile)); $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get("we_data_access_im"), $user, $this->container->get("logger"), $this->container); Utils::sendImPresence($user->fafa_jid, implode(",", $staffMgr->getFriendJidList()), "staff-changeinfo", $message, $this->container, "", "", false, Utils::$systemmessage_code); $re["returncode"] = ReturnCode::$SUCCESS; $re["fileid"] = $photofile; $re["photo_path"] = $photofile_48; $re["photo_path_big"] = $photofile; $re["photo_path_small"] = $photofile_24; } 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; }
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; }
public function IndexAction() { $da = $this->get("we_data_access"); $user = $this->get('security.context')->getToken()->getUser(); $eno = $user->eno; $username = $user->getUsername(); $request = $this->getRequest(); $logo = $request->get("fileid"); $crop = $request->get("crop"); $type = $request->get("type"); $index = $request->get("index"); if (empty($type)) { $re = array("success" => false, "msg" => "请输入type参数值"); $result = new Response(json_encode($re)); $result->headers->set('Content-Type', 'text/json'); return $result; } $width = 0; $height = 0; if ($type == 1) { $width = 180; $height = 180; } else { if ($type == 2) { $width = 400; $height = 130; } else { if ($type == 3) { $width = 640; $height = 1136; } } } if (!empty($crop)) { $crop = json_decode($crop, true); } $appid = $request->get("appid"); $success = true; $newfileid = ""; if (!empty($logo) && !empty($crop)) { //源图像另存为 $doc = $this->get('doctrine.odm.mongodb.document_manager')->getRepository('JustsyMongoDocBundle:WeDocument')->find($logo); if (!empty($doc)) { $filename1 = strtolower($doc->getName()); $expname = explode(".", $filename1); $expname = $expname[1]; $src = tempnam(sys_get_temp_dir(), "tmp") . "." . $expname; $file = $doc->getFile(); $filename2 = $file->getFilename(); $tybes = $file->getBytes(); $cont = fopen($src, 'w'); fwrite($cont, $tybes); fclose($cont); $gd = new \Justsy\BaseBundle\Common\Gd(); $gd->open($src); if ($gd->is_image()) { $gd->crop((int) $crop["x"], (int) $crop["y"], (int) $crop["w"], (int) $crop["h"]); $gd->resize_to($width, $height, 'force'); $gd->save_to($src); $dm = $this->get('doctrine.odm.mongodb.document_manager'); $doc = new \Justsy\MongoDocBundle\Document\WeDocument(); $doc->setName(basename($src)); $doc->setFile($src); $dm->persist($doc); $dm->flush(); $newfileid = $doc->getId(); } unlink($src); //数据记录操作处理 $field = ""; if ($type == 1) { $sql = "update we_apps_portalconfig set logo=? where appid=?"; $field = "logo as fileid"; } else { if ($type == 2) { $sql = "update we_apps_portalconfig set login_image=? where appid=?"; $field = "login_image as fileid"; } else { if ($type == 3) { $sql = "update we_apps_portalconfig set start_image=? where appid=?"; $field = "start_image as fileid"; } else { if ($type == 4) { $sql = "update we_apps_portalconfig set guide" . $index . "=? where appid=?"; $field = "guide" . $index . " as fileid"; } } } } $params = array((string) $newfileid, $appid); //记录原来文件id $remove_fileid = ""; try { $remove_sql = "select " . $field . " from we_apps_portalconfig where appid=?;"; $ds = $da->GetData("table", $remove_sql, array((string) $appid)); if ($ds && $ds["table"]["recordcount"] > 0) { $remove_fileid = $ds["table"]["rows"][0]["fileid"]; } } catch (\Exception $e) { } $dm = $this->get('doctrine.odm.mongodb.document_manager'); Utils::removeFile($logo, $dm); try { $da->ExecSQL($sql, $params); //更改成功后删除原mogo文件 Utils::removeFile($remove_fileid, $dm); } catch (\Exception $e) { $success = false; $this->get("logger")->err($e->getMessage()); } } } $re = array("success" => $success, "fileid" => $newfileid); $result = new Response(json_encode($re)); $result->headers->set('Content-Type', 'text/json'); return $result; }
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; }
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; }
public function removeWorkflowNode($parameter) { $node_id = isset($parameter["node_id"]) ? $parameter["node_id"] : ""; if (empty($node_id)) { //节点已不存在时,直接返回 return false; } $data = $this->getNode($parameter); if (empty($data)) { //节点已不存在时,直接返回 return null; } $account = $parameter["user"]->getUserName(); if ($data["submit_staff"] == $account) { //如果是申请人并且是流程的创建者删除该节点时,删除该 流程所有数据 $wf = $this->getWorkflow($data); if (!empty($wf) && $wf["createstaff"] == $account) { $this->conn->ExecSQL("delete from we_app_businessworkflow where wf_id=?", array((string) $data["wf_id"])); } } $sql = "select * from we_app_workflow_attachment where node_id=?"; $attachmentDS = $this->conn->GetData("t", $sql, array((string) $node_id)); $sql2 = "delete from we_app_workflow_node where node_id=?"; $sql3 = "delete from we_app_workflow_nodesetting where node_id=?"; $sql4 = "delete from we_app_workflow_attachment where node_id=?"; $this->conn->ExecSQLs(array($sql2, $sql3, $sql4), array(array((string) $node_id), array((string) $node_id), array((string) $node_id))); if (count($attachmentDS["t"]["rows"]) > 0) { for ($i = 0; $i < count($attachmentDS["t"]["rows"]); $i++) { $file_id = $attachmentDS["t"]["rows"][$i]["file_id"]; Utils::removeFile($file_id, $this->containerObj); } } return $data; }
public function modifyavatar($parameter) { $re = array("success" => true); $request = $this->container->getRequest(); $user = $parameter["user"]; $dm = $this->container->get('doctrine.odm.mongodb.document_manager'); $da = $this->container->get("we_data_access"); $da_im = $this->container->get("we_data_access_im"); $login_account = $user->getUsername(); $photofile = $_FILES['photofile']['tmp_name']; if (empty($photofile)) { $photofile = tempnam(sys_get_temp_dir(), "we"); unlink($photofile); $somecontent1 = base64_decode($parameter['photodata']); if ($handle = fopen($photofile, "w+")) { if (!fwrite($handle, $somecontent1) == FALSE) { fclose($handle); } } } $photofile_24 = $photofile . "_24"; $photofile_48 = $photofile . "_48"; try { if (empty($photofile)) { throw new \Exception("param is null"); } $im = new \Imagick($photofile); $im->scaleImage(48, 48); $im->writeImage($photofile_48); $im->destroy(); $im = new \Imagick($photofile); $im->scaleImage(24, 24); $im->writeImage($photofile_24); $im->destroy(); $table = $this->getInfo(); if (!empty($table)) { Utils::removeFile($table["photo_path"], $dm); Utils::removeFile($table["photo_path_small"], $dm); Utils::removeFile($table["photo_path_big"], $dm); } if (!empty($photofile)) { $photofile = Utils::saveFile($photofile, $dm); } if (!empty($photofile_48)) { $photofile_48 = Utils::saveFile($photofile_48, $dm); } if (!empty($photofile_24)) { $photofile_24 = Utils::saveFile($photofile_24, $dm); } $da->ExecSQL("update we_staff set photo_path=?,photo_path_big=?,photo_path_small=? \n\t where login_account=?", array((string) $photofile_48, (string) $photofile, (string) $photofile_24, (string) $login_account)); $da_im->ExecSQL("update im_employee set photo=? where loginname=?", array((string) $photofile, (string) $table["fafa_jid"])); $this->getInfo(true); $this->syncAttrsToIM(); $message = json_encode(array('jid' => $user->fafa_jid, "path" => $this->container->getParameter('FILE_WEBSERVER_URL') . $photofile)); Utils::sendImPresence($user->fafa_jid, implode(",", $this->getFriendJidList()), "staff-changeinfo", $message, $this->container, "", "", false, Utils::$systemmessage_code); $re["success"] = true; $re["fileid"] = $photofile; $re["photo_path"] = $photofile_48; $re["photo_path_big"] = $photofile; $re["photo_path_small"] = $photofile_24; } catch (\Exception $e) { $re["success"] = false; $this->get('logger')->err($e); } return $re; }
public function updatePortalIconAction() { $da = $this->get("we_data_access"); $user = $this->get('security.context')->getToken()->getUser(); $eno = $user->eno; $username = $user->getUsername(); $request = $this->getRequest(); $logo = $request->get("fileid"); $crop = $request->get("crop"); if (!empty($crop)) { $crop = json_decode($crop, true); } $appid = $request->get("appid"); $success = true; $newfileid = ""; if (!empty($logo) && !empty($crop)) { //源图像另存为 $doc = $this->get('doctrine.odm.mongodb.document_manager')->getRepository('JustsyMongoDocBundle:WeDocument')->find($logo); if (!empty($doc)) { $filename1 = strtolower($doc->getName()); $expname = explode(".", $filename1); $expname = $expname[1]; $src = tempnam(sys_get_temp_dir(), "tmp") . "." . $expname; $file = $doc->getFile(); $filename2 = $file->getFilename(); $tybes = $file->getBytes(); $cont = fopen($src, 'w'); fwrite($cont, $tybes); fclose($cont); $gd = new \Justsy\AppCenterBundle\Common\Gd(); $gd->open($src); if ($gd->is_image()) { $gd->crop((int) $crop["x"], (int) $crop["y"], (int) $crop["w"], (int) $crop["h"]); $gd->resize_to(180, 180, 'force'); $gd->save_to($src); $dm = $this->get('doctrine.odm.mongodb.document_manager'); $doc = new \Justsy\MongoDocBundle\Document\WeDocument(); $doc->setName(basename($src)); $doc->setFile($src); $dm->persist($doc); $dm->flush(); $newfileid = $doc->getId(); } unlink($src); //数据记录操作处理 $sql = "update we_apps_portalconfig set logo=? where appid=?"; $params = array((string) $newfileid, $appid); //删除原来的文件 $dm = $this->get('doctrine.odm.mongodb.document_manager'); Utils::removeFile($logo, $dm); try { $da->ExecSQL($sql, $params); } catch (\Exception $e) { $success = false; $this->get("logger")->err($e->getMessage()); } } } $re = array("success" => $success, "fileid" => $newfileid); $result = new Response(json_encode($re)); $result->headers->set('Content-Type', 'text/json'); return $result; }