Esempio 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');
 }
Esempio n. 2
0
 public function ResetPassWordAction()
 {
     $da = $this->get("we_data_access");
     $da_im = $this->get("we_data_access_im");
     $request = $this->getRequest();
     $account = strtolower($request->get("account"));
     $password = $request->get("password");
     $result = array("success" => true, "message" => "");
     $user = $this->get('security.context')->getToken()->getUser();
     try {
         $u_staff = new Staff($da, $da_im, $account, $this->get('logger'), $this->container);
         $targetStaffInfo = $u_staff->getInfo();
         $re = $u_staff->changepassword($targetStaffInfo["login_account"], $password, $this->get('security.encoder_factory'));
         if ($re) {
             //$this->get("logger")->err("sendImPresence:".$targetStaffInfo["fafa_jid"]);
             //给自己发送一个staff-changepasswod的出席,通知在线客户端密码发生修改,需要新密码重新登录
             Utils::sendImPresence($user->fafa_jid, $targetStaffInfo["fafa_jid"], "staff-changepasswod", "staff-changepasswod", $this->container, "", "", false, Utils::$systemmessage_code);
             //记录用户操作日志
             $syslog = new \Justsy\AdminAppBundle\Controller\SysLogController();
             $syslog->setContainer($this->container);
             $desc = "重置了用户账号:" . $account . "登录密码!";
             $syslog->AddSysLog($desc, "重置密码");
         } else {
             $result = array("success" => false, "message" => "修改密码错误!");
         }
     } catch (\Exception $e) {
         $this->get("logger")->err($e->getMessage());
         $result = array("success" => false, "message" => "修改密码错误!");
     }
     $response = new Response(json_encode($result));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
Esempio n. 3
0
 private function SendImMessage($planid, $title, $tojid, $message)
 {
     if (!empty($planid)) {
         if (empty($message)) {
             //获取消息内容
             if (!empty($planid)) {
                 $ds = $this->GetPlan($planid);
                 if (count($ds) > 0) {
                     $message = json_encode($ds[0]);
                 } else {
                     return false;
                 }
             } else {
                 return false;
             }
         }
         if (!empty($this->user)) {
             if (empty($tojid)) {
                 $sql = "select GROUP_CONCAT(staffid) as staffid from we_meeting_member where planid=? ";
                 $paras = array((string) $planid);
                 $ds = $this->conn->GetData("result", $sql, $paras);
                 $tojid = $ds["result"]["rows"][0]["staffid"];
             }
             $staffinfo = "{\"nick_name\":\"" . $this->user->nick_name . "\",";
             if (!empty($message)) {
                 $message = str_replace("{", $staffinfo, $message);
             }
             //开始发送消息
             Utils::sendImMessage($this->user->fafa_jid, $tojid, $title . "_meetingmember", $message, $this->container, "", "", false, Utils::$systemmessage_code);
         }
     }
 }
Esempio n. 4
0
 public function sendAvicSMSAction($mobiles, $msg)
 {
     $SMS_ACT = $this->container->getParameter('SMS_ACT');
     $SMS_PWD = $this->container->getParameter('SMS_PWD');
     $SMS_URL = $this->container->getParameter('SMS_URL');
     $SMS_EID = $this->container->getParameter('SMS_EID');
     $mobiles = str_replace(";", ",", $mobiles);
     $content = urlEncode(urlEncode(mb_convert_encoding($msg, 'gb2312', 'utf-8')));
     $pwd = md5($SMS_PWD);
     $apidata = "username={$SMS_ACT}&password={$pwd}&message={$content}&phone={$mobiles}&epid={$SMS_EID}&linkid=&subcode=";
     $this->get("logger")->err($SMS_URL . "?" . $apidata);
     $result = mb_convert_encoding($this->do_post_request($SMS_URL . "?" . $apidata, null), 'utf-8', 'gb2312');
     $this->get("logger")->err($result);
     return Utils::WrapResultOK('');
 }
Esempio n. 5
0
 public function loadUserByUsername($username, $comeform = "")
 {
     if (Utils::validateMobile($username)) {
         //手机登录
         return $this->loadUserByUsernameWithMobile($username);
     }
     $DataAccess = $this->container->get('we_data_access');
     $staff = new \Justsy\BaseBundle\Management\Staff($DataAccess, $this->container->get('we_data_access_im'), $username, $this->container->get("logger"), $this->container);
     $us = $staff->getInfo();
     if (!empty($us)) {
         $us = $staff->getSessionUser($us);
         return $us;
     } else {
         throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
     }
 }
Esempio n. 6
0
 public function e($parameters)
 {
     if (count($parameters) == 0) {
         return Utils::WrapResultError("无效的eno参数");
     }
     $eno = $parameters[0];
     if (empty($eno)) {
         return Utils::WrapResultError("无效的eno参数");
     }
     $staffMgr = new Enterprise($this->conn, $this->logger, $this->container);
     $staffdata = $staffMgr->getInfo($eno);
     if (empty($staffdata)) {
         return Utils::WrapResultError("未查找到企业信息");
     }
     return Utils::WrapResultOK($staffdata);
 }
Esempio n. 7
0
 private function SendImPresence($roomid, $title, $message)
 {
     if (empty($message)) {
         //获取消息内容
         $ds = $this->GetRoom($roomid);
         $message = json_encode($ds[0]);
     }
     if (!empty($this->user)) {
         $eno = $this->user->eno;
         //根据企业号获取接收人
         $sqltojid = " select GROUP_CONCAT(distinct fafa_jid) as login_account from we_circle t1 left join we_circle_staff t2 on t1.circle_id=t2.circle_id  inner join we_staff t3 on t1.enterprise_no=t3.eno where t1.enterprise_no=? ";
         $parastojid = array((string) $eno);
         $dstojid = $this->conn->GetData("result", $sqltojid, $parastojid);
         $tojid = $dstojid["result"]["rows"][0]["login_account"];
         $title .= "_meetingroom";
         $staffinfo = "{\"nick_name\":\"" . $this->user->nick_name . "\",";
         if (!empty($message)) {
             $message = str_replace("{", $staffinfo, $message);
         }
         //开始发送消息
         Utils::sendImPresence($this->user->fafa_jid, $tojid, $title, $message, $this->container, "", "", false, Utils::$systemmessage_code);
     }
 }
Esempio n. 8
0
 public static function ssoAction($container, $conn, $appid, $openid, $token, $encrypt)
 {
     $da = $conn;
     $sql = "select authkey,bind_uid from we_staff_account_bind a,we_staff b where a.bind_account=b.openid and a.bind_account=? and a.bind_type=?";
     $ds = $da->GetData("tb", $sql, array((string) $openid, self::$bind_type));
     if (count($ds["tb"]["rows"]) > 0) {
         //解析autokey
         $bind_uid = $ds['tb']['rows'][0]["bind_uid"];
         $sql = "select appkey from we_appcenter_apps where appid=?";
         $ds = $da->GetData("t", $sql, array((string) $appid));
         $appkey = $ds['t']['recordcount'] > 0 ? $ds['t']['rows'][0]['appkey'] : '';
         if ($encrypt == '1') {
             $bind_uid = DES::decrypt2($bind_uid, $appkey);
         }
         $EmployeeNO = $bind_uid;
         $login_url = self::$login_url;
         $params = array("Channel" => "", "AccessUserID" => self::$AccessUK, "AccessPassword" => self::$AccessPK, "token" => $token, "EmployeeID" => $EmployeeNO, "AppID" => self::$AccessAppid, "InitPage" => "Home");
         return array("login_url" => $login_url, "params" => $params);
         //Utils::do_post_request(self::$login_url,"Channel=&AccessUserID=".self::$AccessUK."&AccessPassword="******"&token=".$token."&EmployeeID=".$EmployeeNO."&AppID=".self::$AccessAppid."&InitPage=Home");
     }
     $page = self::$xc_homepage;
     return Utils::http_redirect($page);
 }
Esempio n. 9
0
 public static function ssoAction($container, $con, $appid, $openid, $token, $encrypt)
 {
     $da = $con;
     //$result = Utils::do_post_request("http://www.wefafa.com", array());
     $sql = "select appkey from we_appcenter_apps where appid=?";
     $ds = $da->GetData("t", $sql, array((string) $appid));
     $result = "";
     if (count($ds["t"]["rows"]) == 0) {
         $result = "invalid appid";
     } else {
         $appkey = $ds["t"]["rows"][0]["appkey"];
         $sql = "select a.authkey,b.login_account from we_staff_account_bind a,we_staff b where a.bind_account=b.openid and a.bind_account=? and a.appid=?";
         $ds = $da->GetData("t", $sql, array((string) $openid, (string) $appid));
         if (count($ds["t"]["rows"]) > 0) {
             $row = $ds["t"]["rows"][0];
             //$authkey = $row["authkey"];
             //$authkey=DES::decrypt2($authkey,$appkey);
             //$parameter = "";
             //自动登录
             $Obj = new \Justsy\BaseBundle\Login\UserProvider($container->container);
             $user = $Obj->loadUserByUsername($row["login_account"]);
             $token = new \Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken($user, $user->getPassword(), "secured_area", $user->getRoles());
             $container->get("security.context")->setToken($token);
             $session = $container->get("request")->getSession()->set('_security_' . 'secured_area', serialize($token));
             $event = new \Symfony\Component\Security\Http\Event\InteractiveLoginEvent($container->get("request"), $token);
             $container->get("event_dispatcher")->dispatch("security.interactive_login", $event);
             //$result = Utils::do_post_request("http://we.fafatime.com", array());
             $weburl = "http://we.fafatime.com";
             return Utils::http_redirect($weburl);
         } else {
             $result = "not bind";
         }
     }
     $resp = new Response($result);
     $resp->headers->set('Content-Type', 'text/html');
     return $resp;
 }
Esempio n. 10
0
 public static function rest($controller, $user, $re, $parameters, $need_params)
 {
     $appid = $parameters["appid"];
     $openid = $user->openid;
     $cookie_key = self::$bind_type . "_" . $openid;
     $restUrl = $re["inf_url"];
     $str_para = array();
     $app = new \Justsy\BaseBundle\Management\App($controller);
     $bindinfo = $app->getappbind(array("appid" => $appid, "openid" => $openid));
     if (!empty($parameters)) {
         //将参数数组转化为字符串
         if (is_array($parameters) && !empty($need_params)) {
             $parameters["uid"] = $bindinfo["bind_uid"];
             for ($i = 0; $i < count($need_params); $i++) {
                 $pname = $need_params[$i]["paramname"];
                 $val = isset($parameters[$pname]) ? $parameters[$pname] : $need_params[$i]["paramvalue"];
                 $str_para[$pname] = $val;
             }
         }
     }
     if (strpos($restUrl, "?") === false) {
         $restUrl = $restUrl . "?" . http_build_query($str_para);
     } else {
         $restUrl = $restUrl . "&" . http_build_query($str_para);
     }
     $controller->get("logger")->err("===============restUrl:" . $restUrl);
     $re = Utils::do_post_request_cookie($restUrl, null, null, $cookie_key);
     //session过期时自动登录
     /*$sessionActive = true;
     		if(!$sessionActive)
     		{
     			
     			$appinfo = $app->getappinfo(array("appid"=>$appid));			
     			$loginUrl = $appdata["authorization_url"];
     			//登录
     			$authResult = Utils::do_get_request_cookie($loginUrl."&".http_build_query(array("uid"=>$bindinfo["bind_uid"],"upwd"=>md5(DES::decrypt($bindinfo["authkey"])))),
     	            	null,
     	            	null,
     	            	$cookie_key);
     			//重新提交
     	        $re = Utils::do_post_request_cookie($restUrl."&".http_build_query($str_para),null,null,$cookie_key);
     		}*/
     return $re;
 }
Esempio n. 11
0
 public function removeMonitorAction()
 {
     $da = $this->get("we_data_access");
     $da_im = $this->get('we_data_access_im');
     $request = $this->getRequest();
     //访问权限校验
     $api = new ApiController();
     $api->setContainer($this->container);
     $isWeFaFaDomain = $api->checkWWWDomain();
     if (!$isWeFaFaDomain) {
         $token = $api->checkAccessToken($request, $da);
         if (!$token) {
             $re = array("returncode" => "9999");
             $re["code"] = "err0105";
             $re["msg"] = "参数Appid或Openid或Access_token未指定或无效.";
             return $this->responseJson($request, $re);
         }
     }
     $openid = $request->get("openid");
     $staffinfo = new Staff($da, $da_im, $openid, $this->get("logger"), $this->container);
     $staffdata = $staffinfo->getInfo();
     if (empty($staffdata)) {
         $result = Utils::WrapResultError("无效操作帐号");
         return $this->responseJson($request, $result);
     }
     $to = $request->get("to");
     if (empty($to)) {
         $result = Utils::WrapResultError("无效的帐号");
         return $this->responseJson($request, $result);
     }
     $to = $staffinfo->getStaffInfo($to);
     if (empty($to)) {
         $result = Utils::WrapResultError("无效的帐号");
         return $this->responseJson($request, $result);
     }
     try {
         $sql = 'delete from  t_module_location_monitor where staff=?';
         $da->ExecSQL($sql, array((string) $to['jid']));
         $sql = 'delete from  t_module_location where staff=?';
         $da->ExecSQL($sql, array((string) $to['login_account']));
     } catch (\Exception $e) {
     }
     $senddata = array('opt' => 'stop');
     $msg = Utils::WrapMessage('sendlocation', $senddata, array());
     //$msgxml = Utils::WrapMessageXml($this->module["jid"],$msg,'sendlocation-id');
     $api->sendMsg("", $to['jid'], 'sendlocation', json_encode($msg));
     return $this->responseJson($request, Utils::WrapResultOk(""));
 }
Esempio n. 12
0
 public function accessCheck()
 {
     $da = $this->get("we_data_access");
     $da_im = $this->get('we_data_access_im');
     $request = $this->getRequest();
     //访问权限校验
     $api = new ApiController();
     $api->setContainer($this->container);
     $isWeFaFaDomain = $api->checkWWWDomain();
     if (!$isWeFaFaDomain) {
         $token = $api->checkAccessToken($request, $da);
         if (!$token) {
             $re = array("returncode" => "9999");
             $re["code"] = "err0105";
             $re["msg"] = "参数Appid或Openid或Access_token未指定或无效.";
             return $re;
         }
     }
     $openid = $request->get("openid");
     $staffinfo = new Staff($da, $da_im, $openid, $this->get("logger"), $this->container);
     $staffdata = $staffinfo->getInfo();
     if (empty($staffdata)) {
         return Utils::WrapResultError("无效操作帐号");
     }
     return Utils::WrapResultOk($staffinfo->getSessionUser($staffdata));
 }
Esempio n. 13
0
 public static function bindBatAction($controller, $con, $appid, $eno, $encrypt, $params)
 {
     $re = array('s' => '1', 'm' => '');
     try {
         $openids = $params->get("openids");
         if ($openids == 'all') {
             $sql = "select openid from we_staff where eno=? and auth_level!='J'";
             $param = array($eno);
             $ds = $con->getdata('info', $sql, $param);
             $rows = $ds['info']['rows'];
             foreach ($rows as $row) {
                 $openidArr[] = $row['openid'];
             }
         } else {
             $openidArr = explode(',', $openids);
         }
         $sql = "select appkey from we_appcenter_apps where appid=?";
         $ds = $con->GetData("t", $sql, array((string) $appid));
         $appkey = '';
         if (count($ds["t"]["rows"]) > 0) {
             $appkey = $ds["t"]["rows"][0]["appkey"];
         }
         $sqls = [];
         $paras = [];
         for ($i = 0; $i < count($openidArr); $i++) {
             $sql = "select mobile,nick_name,birthday,sex_id,login_account from we_staff where openid=?";
             $params = array($openidArr[$i]);
             $ds = $con->getdata('info', $sql, $params);
             if ($ds['info']['recordcount'] > 0) {
                 $pam_account = array();
                 $pam_account['login_name'] = $ds['info']['rows'][0]['login_account'];
                 $pam_account['login_password'] = '******';
                 $pam_account['psw_confirm'] = '123456';
                 $auth = array('userid' => $pam_account['login_name'], 'passwd' => $pam_account['login_password']);
                 $auth = json_encode($auth);
                 //$auth=DES::encrypt2($auth,'_sddb74+');
                 $auth = DES::encrypt2($auth, $appkey);
                 $pam_account = json_encode($pam_account);
                 $pam_account = DES::encrypt2($pam_account, 'ecstore');
                 $addr = "";
                 $name = $ds['info']['rows'][0]['nick_name'];
                 $phone = $ds['info']['rows'][0]['phone'];
                 $qq = "";
                 $zipcode = "";
                 $birthday = $ds['info']['rows'][0]['birthday'];
                 $gender = $ds['info']['rows'][0]['sex_id'] == '女' ? 'female' : 'male';
                 $data = "pam_account={$pam_account}&addr={$addr}&name={$name}&phone={$phone}&qq={$qq}&zipcode={$zipcode}&birthday={$birthday}&gender={$gender}";
                 $result = Utils::do_post_request(self::$bind_url . "&" . $data);
                 $result = json_decode($result, true);
                 if ($result['rsp'] != 'fail') {
                     $sql = "delete from we_staff_account_bind where bind_account=? and bind_type=? and appid=?";
                     $params = array($openidArr[$i], self::$bind_type, $appid);
                     array_push($sqls, $sql);
                     array_push($paras, $params);
                     $sql = "insert into we_staff_account_bind(bind_account,appid,bind_uid,authkey,bind_type,bind_created)values(?,?,?,?,?,now())";
                     $params = array($openidArr[$i], (string) $appid, $ds['info']['rows'][0]['login_account'], (string) $auth, self::$bind_type);
                     array_push($sqls, $sql);
                     array_push($paras, $params);
                 }
             }
         }
         if (count($sqls) > 0) {
             if (!$con->ExecSQLs($sqls, $paras)) {
                 $re = array('s' => '0', 'm' => '操作失败');
             }
         }
     } catch (\Exception $e) {
         $re = array('s' => '0', 'm' => $e->getMessage());
     }
     return $re;
 }
Esempio n. 14
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;
 }
Esempio n. 15
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;
 }
Esempio n. 16
0
 public function removeapply($paraObj)
 {
     $wfl = new \Justsy\BaseBundle\Business\WeWorkflow($this->container);
     $re = $wfl->cancel($paraObj);
     //消息通知
     if ($re) {
         $message = "申请取消成功";
         Utils::sendImMessage("", $paraObj["user"]->fafa_jid, "bus_apply_remove", $message, $this->container, "", "", false, '', '0');
         //通知所有的节点处理人
         $dealstaffJids = isset($re["dealstaffs"]) ? $re["dealstaffs"] : "";
         if (!empty($dealstaffJids)) {
             $to = explode(",", $dealstaffJids);
             Utils::sendImMessage("", $to, "bus_apply_remove", json_encode($re), $this->container, "", "", false, '', '0');
         }
     }
     return Utils::WrapResultOK($re);
 }
Esempio n. 17
0
 public function savePcSyncAction(Request $request)
 {
     $session = $this->get('session');
     $filename120 = $session->get("avatar_big");
     $filename48 = $session->get("avatar_middle");
     $filename24 = $session->get("avatar_small");
     $user = $this->get('security.context')->getToken()->getUser();
     $dm = $this->get('doctrine.odm.mongodb.document_manager');
     if (!empty($filename120)) {
         $filename120 = $this->saveFile($filename120, $dm);
     }
     if (!empty($filename48)) {
         $filename48 = $this->saveFile($filename48, $dm);
     }
     if (!empty($filename24)) {
         $filename24 = $this->saveFile($filename24, $dm);
     }
     $session->remove("avatar_big");
     $session->remove("avatar_middle");
     $session->remove("avatar_small");
     $da = $this->get("we_data_access");
     $da_im = $this->get('we_data_access_im');
     $para["account"] = $user->getUsername();
     $table = $da->GetData("staff", "select nick_name,photo_path,photo_path_small,photo_path_big,fafa_jid from we_staff where login_account=?", array((string) $para["account"]));
     $oldRow = $table["staff"]["rows"][0];
     if (!empty($filename120)) {
         if ($table && $table["staff"]["recordcount"] > 0) {
             $this->removeFile($table["staff"]["rows"][0]["photo_path"], $dm);
             $this->removeFile($table["staff"]["rows"][0]["photo_path_small"], $dm);
             $this->removeFile($table["staff"]["rows"][0]["photo_path_big"], $dm);
         }
     }
     $old_nick_name = $oldRow["nick_name"];
     $Jid = $oldRow["fafa_jid"];
     $y = $request->get("dateYear");
     $birthday = empty($y) || $y == "0000" ? "" : $y . "-" . $request->get("dateMonth") . "-" . $request->get("dateDay");
     $nick_name = $request->get("txtname");
     if (empty($filename120)) {
         $sql = "update we_staff set nick_name=?,birthday=?,dept_id=?,work_phone=?,mobile=?,self_desc=?,specialty=?,hobby=?,hometown=?,graduated=?,work_his=?,sex_id=? where login_account=?";
         $paras[] = $nick_name;
         $paras[] = $birthday;
         $paras[] = $request->get("txtdeptid");
         $paras[] = $request->get("txtwork_phone");
         $paras[] = $request->get("txtmobile");
         $paras[] = $request->get("txtself_desc");
         $paras[] = $request->get("txtspecialty");
         $paras[] = $request->get("txthobby");
         $paras[] = $request->get("txthometown");
         $paras[] = $request->get("txtgraduated");
         $paras[] = $request->get("txtwork_his");
         $paras[] = $request->get("txtsex");
         $paras[] = $para["account"];
     } else {
         $sql = "update we_staff set nick_name=?,birthday=?,photo_path=?,photo_path_small=?,photo_path_big=?,dept_id=?,work_phone=?,mobile=?,self_desc=?,specialty=?,hobby=?,hometown=?,graduated=?,work_his=?,sex_id=?  where login_account=?";
         $paras[] = $nick_name;
         $paras[] = $birthday;
         $paras[] = $filename48;
         $paras[] = $filename24;
         $paras[] = $filename120;
         $paras[] = $request->get("txtdeptid");
         $paras[] = $request->get("txtwork_phone");
         $paras[] = $request->get("txtmobile");
         $paras[] = $request->get("txtself_desc");
         $paras[] = $request->get("txtspecialty");
         $paras[] = $request->get("txthobby");
         $paras[] = $request->get("txthometown");
         $paras[] = $request->get("txtgraduated");
         $paras[] = $request->get("txtwork_his");
         $paras[] = $request->get("txtsex");
         $paras[] = $para["account"];
     }
     try {
         if (empty($filename120)) {
             if ($table && $table["staff"]["recordcount"] > 0) {
                 $para["path"] = $this->container->getParameter('FILE_WEBSERVER_URL') . $table["staff"]["rows"][0]["photo_path_big"];
             } else {
                 $para["path"] = $this->get('templating.helper.assets')->geturl('bundles/fafatimewebase/images/no_photo.png');
             }
         } else {
             $para["path"] = $this->container->getParameter('FILE_WEBSERVER_URL') . $filename120;
             $friendevent = new \Justsy\BaseBundle\Management\FriendEvent($da, $this->get('logger'), $this->container);
             $friendevent->photochange($user->getUserName(), $user->nick_name);
         }
         try {
             $da->ExecSQL($sql, $paras);
         } catch (\Exception $ex) {
             $this->get("logger")->err("========保存人员资料时错误:" . $ex);
             $this->get("logger")->err("========保存人员资料时错误-SQL:" . $sql);
             $this->get("logger")->err("========保存人员资料时错误-DATA:" . $paras);
             Utils::sendImPresence("", "*****@*****.**", "保存人员资料时错误", "AccountController->savePcSyncAction:<br>" . $sql . "<br>" . $paras, $this->container);
         }
         //如果更改了姓名时,需要同步到im库中并更新相关引用
         if ($old_nick_name != $nick_name) {
             $da_im->ExecSQL("call emp_change_name(?,?)", array((string) $user->fafa_jid, (string) $nick_name));
         }
         //发送个人资料编辑通知
         try {
             //发送即时消息
             $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $user);
             $message = "{\"path\":\"" . $para["path"] . "\",\"desc\":\"" . strtr($request->get("txtself_desc"), array("\"" => "“")) . "\"}";
             Utils::sendImPresence($user->fafa_jid, implode(",", $staffMgr->getFriendAndColleagueJid()), "staff-changeinfo", $message, $this->container, "", "", false, Utils::$systemmessage_code);
         } catch (\Exception $e) {
             $this->get('logger')->err($e);
         }
         $response = new Response("{\"succeed\":1,\"path\":\"" . $para["path"] . "\"}");
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     } catch (\Exception $e) {
         //return $this->render('JustsyBaseBundle:login:index.html.twig', array('name' => 'err'));
         $response = new Response("{\"succeed\":0,\"e\":{$e}}");
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
 }
Esempio n. 18
0
 public function getProxytokenAction()
 {
     $request = $this->getRequest();
     if ($_SERVER['REQUEST_METHOD'] != "POST") {
         return $this->responseJson($request, array("error" => "10009", "msg" => "HTTP请求仅支持POST提交方式"));
     }
     $conn = $this->get("we_data_access");
     $conn_im = $this->get("we_data_access_im");
     $appid = trim($request->get("appid"));
     $openid = trim($request->get("openid"));
     $code = trim($request->get("code"));
     $grant_type = trim($request->get("grant_type"));
     $state = trim($request->get("state"));
     if (empty($appid)) {
         return $this->responseJson($request, array("error" => ReturnCode::$SYSERROR, "msg" => "应用ID不能为空。"));
     }
     if (empty($code)) {
         return $this->responseJson($request, array("error" => ReturnCode::$SYSERROR, "msg" => "动态授权码不能为空。"));
     }
     if (empty($grant_type)) {
         return $this->responseJson($request, array("error" => ReturnCode::$SYSERROR, "msg" => "固定值grant_type不能为空。"));
     }
     if ($grant_type !== "proxy") {
         return $this->responseJson($request, array("error" => ReturnCode::$SYSERROR, "msg" => "固定值grant_type不正确。"));
     }
     $sql_app = "select appkey from we_appcenter_apps where appid=?";
     $para_app = array($appid);
     $data_app = $conn->GetData("dt", $sql_app, $para_app);
     if ($data_app == null || count($data_app["dt"]["rows"]) == 0 || empty($data_app["dt"]["rows"][0]["appkey"])) {
         return $this->responseJson($request, array("returncode" => ReturnCode::$SYSERROR, "msg" => "应用ID不正确。"));
     }
     $appkey = $data_app["dt"]["rows"][0]["appkey"];
     if (strtolower($code) != strtolower(MD5($appid . $appkey))) {
         return $this->responseJson($request, array("returncode" => ReturnCode::$SYSERROR, "msg" => "动态授权码不正确。"));
     }
     $json = $this->getProxySession($appid, $code, $state, $openid);
     $json = Utils::WrapResultOK($json);
     return $this->responseJson($request, $json);
 }
Esempio n. 19
0
 public function weibocallbackAction()
 {
     $request = $this->get("request");
     $o = new SaeTOAuthV2(Utils::$WB_AKEY, Utils::$WB_SKEY);
     $login_type = $request->get('_wefafa_t');
     $code_url = $o->getAuthorizeURL("http://we.fafatime.com/api/weibo/callback?_wefafa_t=" . $login_type);
     $keys = array();
     $keys['code'] = $request->get('code');
     $keys['redirect_uri'] = "http://we.fafatime.com";
     try {
         $token = $o->getAccessToken('code', $keys);
         $c = new SaeTClientV2(Utils::$WB_AKEY, Utils::$WB_SKEY, $token["access_token"]);
         $info = $c->show_user_by_id($token["uid"]);
         if (!empty($info["error"])) {
             $this->get("logger")->err(json_encode($info));
         }
         $province = Utils::do_post_request("http://api.t.sina.com.cn/provinces.json", "");
         //查询当前用户的已获取粉丝列表
         //$mgr = new SinaWeiboMgr($this->get('we_data_access'),$token["uid"],$token["access_token"]);
         //$myfans = $mgr->getlist();
         //$wangbin_fans = $c->followers_by_id("2793358674");
         $accountbind = new \Justsy\BaseBundle\Management\StaffAccountBind($this->get('we_data_access'), null, $this->get('logger'));
         $bind = $accountbind->GetBind_By_Uid($login_type, $token["uid"], empty($info["error"]) ? $info : null);
         //判断是否绑定帐号,没有则跳转到绑定页面,已绑定则获取对应wefafa帐号自动登录
         $_SESSION["uid"] = $token["uid"];
         //$_SESSION["weibo_account"]= $info["uid"];
         $_SESSION["token"] = $token["access_token"];
         return $this->render('JustsyBaseBundle:Login:weibo_auth.html.twig', array('code' => $keys['code'], 'token' => $token["access_token"], "uid" => $token["uid"], "info" => $info, "code_url" => $code_url, "province" => $province, "isbind" => empty($bind) ? "0" : "1", "error" => empty($info["error"]) ? "" : "帐号异常,无法调用微博API!", "error_msg" => empty($info["error"]) ? "" : $info["error"]));
     } catch (\Exception $e) {
         $this->get("logger")->err($e);
     }
     return $this->render('JustsyBaseBundle:Login:default.html.twig', array('code_url' => $code_url));
 }
Esempio n. 20
0
 public function getReplyList($data)
 {
     $noticeid = $data['noticeid'];
     $lastreadid = isset($data['lastreadid']) ? $data['lastreadid'] : '';
     if (empty($lastreadid)) {
         //$sql = 'select ifnull(lastread_reply,0) lastread_reply from im_pushnotice_memebr where noticeid=? and employeeid=?';
         //$ds = $this->conn_im->Getdata('t',$sql,array((int)$noticeid,(string)$this->user['jid']));
         $lastread_reply = 0;
         //$ds['t']['rows'][0]['lastread_reply'];
         $sql = 'select a.msg from im_pushnotice_msg a where a.replyid=? and a.id>? order by a.id desc limit 0,30';
         $ds = $this->conn_im->Getdata('t', $sql, array((int) $noticeid, (int) $lastread_reply));
     } else {
         $sql = 'select a.msg from im_pushnotice_msg a where a.replyid=? and a.id<? order by a.id desc limit 0,30';
         $ds = $this->conn_im->Getdata('t', $sql, array((int) $noticeid, (int) $lastreadid));
     }
     if (empty($lastreadid)) {
         $this->conn_im->ExecSQL('update im_pushnotice_memebr set lastread_reply=(select max(id) from im_pushnotice_msg where replyid=?) where noticeid=? and employeeid=?', array((int) $noticeid, (int) $noticeid, (string) $this->user['jid']));
     }
     $result = array();
     foreach ($ds['t']['rows'] as $key => $value) {
         $result[] = json_decode($value['msg'], true);
     }
     return Utils::WrapResultOK($result);
 }
Esempio n. 21
0
 public function write_msg($fromjid, $msgxml, $msgid)
 {
     if (empty($fromjid)) {
         $domain = $this->container->getParameter('edomain');
         $staffinfo = new \Justsy\BaseBundle\Management\Staff($this->conn, $this->conn_im, 'admin@' . $domain, $this->container->get("logger"), $this->container);
         $staffdata = $staffinfo->getInfo();
         $fromjid = $staffdata['jid'];
     }
     if (empty($msgid)) {
         $msgid = split("@", $fromjid);
         $msgid = $msgid[0] . time();
     }
     //存储业务消息
     $xml = Utils::WrapMessageXml($fromjid, $msgxml, $msgid);
     $sql = 'insert into im_b_msg(msg,created,us,msgid)values(?,now(),?,?)';
     $para = array((string) $xml, (string) $fromjid, (string) $msgid);
     $this->conn_im->ExecSQL($sql, $para);
 }
Esempio n. 22
0
    public function replyConv($da, $user, $conv_root_id, $conv_id, $conv_content, $reply_to, $comefrom = "00", $ownerContoller = null, $attachs = [])
    {
        $sqls = array();
        $all_params = array();
        $sql = "update we_convers_list set reply_num=reply_num+1 where conv_id=?";
        $params = array();
        $params[] = (string) $conv_root_id;
        $sqls[] = $sql;
        $all_params[] = $params;
        $sqlInsert = 'insert into we_convers_list (conv_id, login_account, post_date, conv_type_id, conv_root_id, conv_content, post_to_group, post_to_circle, reply_to, copy_num, reply_num, comefrom) 
select ?, ?, CURRENT_TIMESTAMP(), ?, ?, ?, a.post_to_group, a.post_to_circle, ?, 0, 0, ?
from we_convers_list a
where a.conv_id=?';
        $params = array();
        $params[] = (string) $conv_id;
        $params[] = (string) $user->getUserName();
        $params[] = (string) '99';
        $params[] = (string) $conv_root_id;
        $params[] = (string) $conv_content;
        $params[] = (string) $reply_to;
        $params[] = (string) $comefrom;
        $params[] = (string) $conv_root_id;
        $sqls[] = $sqlInsert;
        $all_params[] = $params;
        //    for ($i=0; $i<count($notifystaff); $i++)
        //    {
        //      $sqlInsert = 'insert into we_convers_notify (conv_id, cc_login_account) values (?, ?)';
        //      $params = array();
        //      $params[] = (string)$conv_id;
        //      $params[] = (string)$notifystaff[$i];
        //
        //      $sqls[] = $sqlInsert;
        //      $all_params[] = $params;
        //    }
        for ($i = 0; $i < count($attachs); $i++) {
            $sqlInsert = "insert into we_convers_attach (conv_id, attach_type, attach_id) values (?, '0', ?)";
            $params = array();
            $params[] = (string) $conv_id;
            $params[] = (string) $attachs[$i];
            $sqls[] = $sqlInsert;
            $all_params[] = $params;
        }
        $da->ExecSQLs($sqls, $all_params);
        if ($ownerContoller != null && $reply_to != $user->getUserName()) {
            try {
                $link = $ownerContoller->get('router')->generate("JustsyBaseBundle_view_oneconv", array("conv_root_id" => $conv_root_id), true);
                //发送即时消息
                //$link = $this->generateUrl("JustsyBaseBundle_view_oneconv",array("conv_root_id"=> $conv_root_id),true);
                $linkButtons = Utils::makeBusButton(array(array("code" => "action", "text" => "查看", "blank" => "1", "value" => "")));
                if (empty($reply_to)) {
                    $message = "好友" . Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "评论了您的动态!";
                    $tmp_rs = $da->GetData("tmp", "SELECT b.fafa_jid,b.login_account FROM we_convers_list a,we_staff b where a.login_account=b.login_account and a.conv_id=?", array((string) $conv_root_id));
                    //var_dump($tmp_rs["tmp"]["rows"][0]["login_account"],$user->getUserName());
                    if ($tmp_rs != null && count($tmp_rs["tmp"]["rows"]) > 0 && $tmp_rs["tmp"]["rows"][0]["login_account"] != $user->getUserName()) {
                        //回复自己发的动态不发消息
                        $to_jid = $tmp_rs["tmp"]["rows"][0]["fafa_jid"];
                        Utils::sendImMessage($user->fafa_jid, $to_jid, "trend-reply", $message, $ownerContoller, $link, $linkButtons, false, Utils::$systemmessage_code);
                    }
                } else {
                    $message = "好友" . Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "回复了您的评论!";
                    $tmp_rs = $da->GetData("tmp", "SELECT b.fafa_jid FROM we_staff b where b.login_account=?", array((string) $reply_to));
                    //var_dump($reply_to,$tmp_rs["tmp"]["rows"][0]["fafa_jid"],$user->getUserName());
                    if ($tmp_rs != null && count($tmp_rs["tmp"]["rows"]) > 0) {
                        $to_jid = $tmp_rs["tmp"]["rows"][0]["fafa_jid"];
                        Utils::sendImMessage($user->fafa_jid, $to_jid, "trend-reply", $message, $ownerContoller, $link, $linkButtons, false, Utils::$systemmessage_code);
                    }
                }
            } catch (\Exception $e) {
                $this->get('logger')->err($e);
            }
        }
        //生成评论数
        if ($reply_to != $user->getUserName()) {
            $sql = "";
            $params = array();
            if (empty($reply_to)) {
                $sql = "insert into we_notify(notify_type, msg_id, notify_staff) \nselect '04', ?, login_account \nfrom we_convers_list\nwhere conv_id=? and login_account<>?";
                $params = array();
                $params[] = (string) $conv_id;
                $params[] = (string) $conv_root_id;
                $params[] = (string) $user->getUserName();
            } else {
                $sql = "insert into we_notify(notify_type, msg_id, notify_staff) values('04', ?, ?)";
                $params = array();
                $params[] = (string) $conv_id;
                $params[] = (string) $reply_to;
            }
            $da->ExecSQL($sql, $params);
        }
        \Justsy\BaseBundle\Controller\CInputAreaController::genAtMe($da, $conv_content, $conv_id, $user, $ownerContoller);
    }
Esempio n. 23
0
 public function SendMsgAction()
 {
     $conn = $this->get("we_data_access");
     $conn_im = $this->get("we_data_access_im");
     $request = $this->getRequest();
     $currUser = $this->get('security.context')->getToken();
     if ($currUser == null) {
         $openid = $request->get('openid');
         $staffinfo = new \Justsy\BaseBundle\Management\Staff($conn, $conn_im, $openid, $this->get("logger"), $this->container);
         $staffdata = $staffinfo->getInfo();
         if (empty($staffdata)) {
             $re = array('returncode' => '9999', 'msg' => '无效的操作人');
             return $this->responseJson(json_encode($re));
         }
         $user = $staffinfo->getSessionUser($staffdata);
     } else {
         $user = $this->get('security.context')->getToken()->getUser();
     }
     //公众号相关参数
     $microObj = $request->get('microObj');
     $microName = $microObj["microName"];
     //接收对象(公众号名称)
     $microNumber = $microObj["microNumber"];
     //接收对象(公众号帐号)
     $microOpenid = $microObj["microOpenid"];
     //接收对象(公众号Openid)
     $microType = $microObj["microType"];
     //接收对象(公众号类型,内部或外部)
     $microUse = $microObj["microUse"];
     //接收对象(是公众号还是微应用)
     $microGroupId = "";
     //$microObj["microGroupId"]; //接收对象(公众号分组主键)
     //消息参数
     $msgType = "";
     //消息类型
     $msgContent = "";
     //消息内容(XML拼接Json字符串,包括标题,图片,摘要等)
     $msgContentHtml = "";
     //消息内容(HTML内容)
     $msgTitle = "";
     //消息标题
     $imgUrl = "";
     //图片地址
     $formid = "";
     //表单编号。推送表单时设置
     $webpage_url = "";
     //网页地址。推送网页地址时设置
     $msgObj_list = $request->get('msgObj');
     //消息对象
     if (!empty($msgObj_list)) {
         foreach ($msgObj_list as $key => $val) {
             if ($key == "type") {
                 $msgType = $val;
             } else {
                 if ($key == "msgContent") {
                     $msgContent = $val;
                 } else {
                     if ($key == "contentHtml") {
                         $msgContentHtml = $val;
                     } else {
                         if ($key == "title") {
                             $msgTitle = $val;
                         } else {
                             if ($key == "imgUrl") {
                                 $imgUrl = $val;
                             } else {
                                 if ($key == "formid") {
                                     $formid = $val;
                                 } else {
                                     if ($key == "webpage_url") {
                                         $webpage_url = $val;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $staffinfo = new \Justsy\BaseBundle\Management\Staff($conn, $conn_im, empty($microNumber) ? $microOpenid : $microNumber, $this->get("logger"), $this->container);
     $staffdata = $staffinfo->getInfo();
     if (empty($staffdata)) {
         $re = array('returncode' => '9999', 'msg' => '请选择接收对象');
         return $this->responseJson(json_encode($re));
     } else {
         $microOpenid = $staffdata["openid"];
         $microNumber = $staffdata["login_account"];
     }
     $re = array('returncode' => '0000');
     $sqls = array();
     $paras = array();
     $send_state = '2';
     $id = SysSeq::GetSeqNextValue($conn, 'we_micro_send_message', 'id');
     $sqls[] = "insert into `we_micro_send_message` (`id`, `send_account`, `send_groupid`, `send_datetime`, `send_state`, `send_isbutton`, `send_source`,`send_type`) VALUES (?, ?, ?, now(), ?, ?, ?,?);";
     $paras[] = array($id, $microNumber, $microGroupId, $send_state, false, 'wefafa', $msgType);
     $error = array('returncode' => '9999', 'msg' => '消息内容有误,请检查');
     //处理消息
     switch ($msgType) {
         case 'PICTURE':
             $title = '';
             //标题
             $image_type = '';
             //图片类型  URL或CODE
             $image_value = '';
             //图片地址
             $content = '';
             //摘要
             $link = '';
             //手机端点击之后连接地址
             try {
                 foreach ($msgContent as $key => $value) {
                     if ($key == 'picturemsg') {
                         $picturemsg = $value;
                         //判断参数是否为空。并返回错误提示
                         if (empty($picturemsg)) {
                             return $this->responseJson(json_encode($error));
                         }
                         foreach ($picturemsg as $pkey => $pvalue) {
                             if ($pkey == 'headitem') {
                                 $headitem = $pvalue;
                                 //判断参数是否为空。并返回错误提示
                                 if (empty($headitem)) {
                                     return $this->responseJson(json_encode($error));
                                 }
                                 foreach ($headitem as $hkey => $hvalue) {
                                     if ($hkey == 'title') {
                                         $title = $hvalue;
                                     } else {
                                         if ($hkey == 'image') {
                                             $image = $hvalue;
                                             //判断参数是否为空。并返回错误提示
                                             if (empty($image)) {
                                                 return $this->responseJson(json_encode($error));
                                             }
                                             foreach ($image as $ikey => $ivalue) {
                                                 if ($ikey == 'type') {
                                                     $image_type = $ivalue;
                                                 } else {
                                                     if ($ikey == 'value') {
                                                         $image_value = $ivalue;
                                                     }
                                                 }
                                             }
                                         } else {
                                             if ($hkey == 'content') {
                                                 $content = $hvalue;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             } catch (Exception $e) {
                 $this->get('logger')->err($e->getMessage());
                 return $this->responseJson(json_encode($error));
             }
             if (!empty($webpage_url)) {
                 $link = $webpage_url;
                 $uniqid = $webpage_url;
             } else {
                 $uniqid = str_replace('.', '', uniqid('', true));
                 $link = !empty($formid) ? $this->getWebFormLink($formid) : $this->getLink($uniqid);
                 if (!empty($formid)) {
                     $uniqid = $link;
                 }
             }
             $noticeinfo = Utils::WrapMessageNoticeinfo($title, $microName);
             $msgContent = Utils::WrapMessage("mm-picturemsg", array('headitem' => array('title' => $title, 'image' => array('type' => $image_type, 'value' => $image_value), 'content' => $content, 'link' => $link)), $noticeinfo);
             //$msgContent= array('picturemsg'=>array('headitem'=>array('title'=>$title,'image'=>array('type'=>$image_type,'value'=>$image_value),'content'=>$content,'link'=>$link)));
             $msgid = SysSeq::GetSeqNextValue($conn, 'we_micro_message', 'id');
             $sqls[] = "insert into `we_micro_message` (`id`, `send_id`, `msg_title`, `msg_type`, `msg_text`, `msg_content`, `msg_summary`, `msg_img_type`, `msg_img_url`, `msg_web_url`, `ishead`, `isread`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
             $msgContentHtml = $this->SetElementStyle($msgContentHtml);
             $paras[] = array($msgid, $id, $title, $msgType, null, $msgContentHtml, $content, $image_type, $image_value, $uniqid, true, false);
             break;
         case 'TEXTPICTURE':
             try {
                 $headitem = array();
                 $items = array();
                 foreach ($msgContent as $key => $value) {
                     if ($key == 'textpicturemsg') {
                         $textpicturemsg = $value;
                         if (empty($textpicturemsg)) {
                             return $this->responseJson(json_encode($error));
                         }
                         foreach ($textpicturemsg as $tpmkey => $tpmvalue) {
                             if ($tpmkey == 'headitem') {
                                 $headitem = $tpmvalue;
                                 if (empty($headitem)) {
                                     return $this->responseJson(json_encode($error));
                                 }
                                 $head_title = '';
                                 $head_img_type = '';
                                 $head_img_url = '';
                                 $head_contentHtml = '';
                                 $head_link = '';
                                 $formid = "";
                                 foreach ($headitem as $hkey => $hvalue) {
                                     if ($hkey == 'title') {
                                         $head_title = $hvalue;
                                     } else {
                                         if ($hkey == 'image') {
                                             $image = $hvalue;
                                             if (empty($image)) {
                                                 return $this->responseJson(json_encode($error));
                                             }
                                             foreach ($image as $imgkey => $imgvalue) {
                                                 if ($imgkey == 'type') {
                                                     $head_img_type = $imgvalue;
                                                 } else {
                                                     if ($imgkey == 'value') {
                                                         $head_img_url = $imgvalue;
                                                     }
                                                 }
                                             }
                                         } else {
                                             if ($hkey == 'content') {
                                                 $head_contentHtml = $hvalue;
                                             } else {
                                                 if ($hkey == 'formid') {
                                                     $formid = $hvalue;
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 $uniqid = str_replace('.', '', uniqid('', true));
                                 $head_link = !empty($formid) ? $this->getWebFormLink($formid) : $this->getLink($uniqid);
                                 $headitem = array('title' => $head_title, 'image' => array('type' => $head_img_type, 'value' => $head_img_url), 'link' => $head_link);
                                 $msgid = SysSeq::GetSeqNextValue($conn, 'we_micro_message', 'id');
                                 $sqls[] = "insert into `we_micro_message` (`id`, `send_id`, `msg_title`, `msg_type`, `msg_text`, `msg_content`, `msg_summary`, `msg_img_type`, `msg_img_url`, `msg_web_url`, `ishead`, `isread`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
                                 $head_contentHtml = $this->SetElementStyle($head_contentHtml);
                                 $paras[] = array($msgid, $id, $head_title, $msgType, null, $head_contentHtml, null, $head_img_type, $head_img_url, $uniqid, true, false);
                             } else {
                                 if ($tpmkey == 'item') {
                                     $item = $tpmvalue;
                                     if (empty($item)) {
                                         return $this->responseJson(json_encode($error));
                                     }
                                     $item_array = array();
                                     for ($i = 0; $i < count($item); $i++) {
                                         $item_title = '';
                                         $item_img_type = '';
                                         $item_img_url = '';
                                         $item_contentHtml = '';
                                         $item_link = '';
                                         $formid = "";
                                         foreach ($item[$i] as $itemkey => $itemvalue) {
                                             if ($itemkey == 'title') {
                                                 $item_title = $itemvalue;
                                             } else {
                                                 if ($itemkey == 'image') {
                                                     $image = $itemvalue;
                                                     if (empty($image)) {
                                                         return $this->responseJson(json_encode($error));
                                                     }
                                                     foreach ($image as $imgkey => $imgvalue) {
                                                         if ($imgkey == 'type') {
                                                             $item_img_type = $imgvalue;
                                                         } else {
                                                             if ($imgkey == 'value') {
                                                                 $item_img_url = $imgvalue;
                                                             }
                                                         }
                                                     }
                                                 } else {
                                                     if ($itemkey == 'content') {
                                                         $item_contentHtml = $itemvalue;
                                                     } else {
                                                         if ($itemkey == 'formid') {
                                                             $formid = $itemvalue;
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                         $uniqid = str_replace('.', '', uniqid('', true));
                                         $item_link = !empty($formid) ? $this->getWebFormLink($formid) : $this->getLink($uniqid);
                                         $item_array = array('title' => $item_title, 'image' => array('type' => $item_img_type, 'value' => $item_img_url), 'link' => $item_link);
                                         array_push($items, $item_array);
                                         $msgid = SysSeq::GetSeqNextValue($conn, 'we_micro_message', 'id');
                                         $sqls[] = "INSERT INTO `we_micro_message` (`id`, `send_id`, `msg_title`, `msg_type`, `msg_text`, `msg_content`, `msg_summary`, `msg_img_type`, `msg_img_url`, `msg_web_url`, `ishead`, `isread`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
                                         $paras[] = array($msgid, $id, $item_title, $msgType, null, $item_contentHtml, null, $item_img_type, $item_img_url, $uniqid, false, false);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $noticeinfo = Utils::WrapMessageNoticeinfo($headitem["title"], $microName);
                 $msgContent = Utils::WrapMessage("mm-textpicturemsg", array('headitem' => $headitem, 'item' => $items), $noticeinfo);
                 //$msgContent= array('textpicturemsg'=>array('headitem'=>$headitem,'item'=>$items));
             } catch (\Exception $e) {
                 $this->get('logger')->err($e->getMessage());
                 return $this->responseJson(json_encode($error));
             }
             break;
         case 'TEXT':
             foreach ($msgContent as $key => $value) {
                 if ($key == 'textmsg') {
                     $textmsg = $value;
                     //判断参数是否为空。并返回错误提示
                     if (empty($textmsg)) {
                         return $this->responseJson(json_encode($error));
                     }
                     foreach ($textmsg as $tkey => $tvalue) {
                         if ($tkey == 'item') {
                             $items = $tvalue;
                             //判断参数是否为空。并返回错误提示
                             if (empty($items)) {
                                 return $this->responseJson(json_encode($error));
                             }
                             $new_items = array();
                             for ($i = 0; $i < count($items); $i++) {
                                 $title = '';
                                 $content = '';
                                 foreach ($items[$i] as $itemkey => $itemvalue) {
                                     if ($itemkey == 'title') {
                                         $title = $itemvalue;
                                     } else {
                                         if ($itemkey == 'content') {
                                             $content = $itemvalue;
                                         }
                                     }
                                 }
                                 if (empty($title)) {
                                     return $this->responseJson(json_encode($error));
                                 }
                                 if (empty($content)) {
                                     return $this->responseJson(json_encode($error));
                                 }
                                 array_push($new_items, array('title' => $title, 'content' => $content));
                                 $msgid = SysSeq::GetSeqNextValue($conn, 'we_micro_message', 'id');
                                 $sqls[] = "INSERT INTO `we_micro_message` (`id`, `send_id`, `msg_title`, `msg_type`, `msg_text`, `msg_content`, `msg_summary`, `msg_img_type`, `msg_img_url`, `msg_web_url`, `ishead`, `isread`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
                                 $paras[] = array($msgid, $id, $title, $msgType, $content, null, null, null, null, null, false, false);
                             }
                             $noticeinfo = Utils::WrapMessageNoticeinfo($title, $microName);
                             $msgContent = Utils::WrapMessage("mm-textmsg", array('item' => $new_items), $noticeinfo);
                             // array('code'=>'textmsg','data'=>array('item'=>$new_items),'noticeinfo'=>'');
                         }
                     }
                 }
             }
             break;
         default:
             //消息类型有误
             return $this->responseJson(json_encode($error));
             break;
     }
     $msgContent = json_encode($msgContent);
     try {
         $staffMgr = new \Justsy\BaseBundle\Management\Staff($conn, $conn_im, $microNumber, $this->get("logger"), $this->container);
         $microData = $staffMgr->getInfo();
         $mic_jid = $microData["fafa_jid"];
         $msgxml = Utils::WrapMicroMessageXml($mic_jid, $msgContent, $id);
         $im_msg_sql = "insert into im_microaccount_msg(microaccount,msg,created,us,msgid)values(?,?,now(),?,?)";
         $conn_im->ExecSQL($im_msg_sql, array((string) $mic_jid, (string) $msgxml, "", (string) $id));
         $fafa_jids = array();
         $sqls_staff = array();
         $paras_staff = array();
         $apicontroller = new \Justsy\OpenAPIBundle\Controller\ApiController();
         $apicontroller->setContainer($this->container);
         $serviceMgr = new \Justsy\BaseBundle\Management\Service($this->container);
         //$this->get('logger')->err("================1:".time());
         $fafa_jids = $serviceMgr->service_sendjid($mic_jid, true);
         //$this->get('logger')->err("================:".json_encode($fafa_jids));
         if (!empty($fafa_jids)) {
             $jids = array();
             $count = count($fafa_jids);
             for ($i = 0; $i < $count; $i++) {
                 array_push($jids, (string) $fafa_jids[$i]);
                 if ($i > 0 && $i % 5000 == 0) {
                     $re = $apicontroller->sendMsg2($microOpenid, implode(",", $jids), $msgContent, $msgType, false, "0", $id);
                     $jids = array();
                 }
             }
             if (!empty($jids) && count($jids) > 0) {
                 $re = $apicontroller->sendMsg2($microOpenid, implode(",", $jids), $msgContent, $msgType, false, "0", $id);
             }
         }
         //$this->get('logger')->err("================3:".time());
         if (!empty($re['returncode']) && $re['returncode'] == '0000') {
             //添加发送消息数据
             if (!empty($sqls)) {
                 $conn->ExecSQLs($sqls, $paras);
             }
             //添加接收人员
             if (!empty($sqls_staff)) {
                 $conn->ExecSQLs($sqls_staff, $paras_staff);
             }
         }
     } catch (\Exception $e) {
         $this->get('logger')->err($e->getMessage());
         $re = array('returncode' => '9999', 'msg' => '消息发送失败');
     }
     return $this->responseJson(json_encode($re));
 }
Esempio n. 24
0
 public function updateStaffAction()
 {
     $da = $this->get("we_data_access");
     $da_im = $this->get('we_data_access_im');
     $request = $this->getRequest();
     $state = $request->get("state");
     $im_deptid = $request->get("dept_id");
     //将im的部门id转化为sns里的部门id
     $deptInfo = $this->getDeptInfo($im_deptid);
     $sns_deptid = $deptInfo["deptid"];
     $login_account = $request->get("login_account");
     $e_mail = $request->get("e_mail");
     $nick_name = $request->get("nick_name");
     $password = $request->get("password");
     $sex = $request->get("sex");
     $duty = $request->get("duty");
     $duty = empty($duty) ? null : $duty;
     $mobile = $request->get("mobile");
     $mobile = empty($mobile) ? null : $mobile;
     $success = true;
     $msg = "";
     //判断手机号正误
     if (!empty($mobile)) {
         if (!Utils::validateMobile($mobile)) {
             $result = array("success" => false, "msg" => "手机账号格式错误!");
             $response = new Response(json_encode($result));
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         } else {
             $sql = "";
             $para = array();
             if ($state == "add") {
                 $sql = "select count(*) number from we_staff where mobile_bind=?;";
                 array_push($para, (string) $mobile);
             } else {
                 $sql = "select count(*) number from we_staff where mobile_bind=? and login_account!=?;";
                 array_push($para, (string) $mobile, $login_account);
             }
             try {
                 $ds = $da->GetData("table", $sql, $para);
                 if ($ds && $ds["table"]["recordcount"] > 0) {
                     if ((int) $ds["table"]["rows"][0]["number"] > 0) {
                         $result = array("success" => false, "msg" => "已存在该手机号码!");
                         $response = new Response(json_encode($result));
                         $response->headers->set('Content-Type', 'text/json');
                         return $response;
                     }
                 }
             } catch (\Exception $e) {
                 $this->get("logger")->err($e->getMessage());
             }
         }
     }
     $user = $this->get('security.context')->getToken()->getUser();
     $deptMgr = new \Justsy\BaseBundle\Management\Dept($da, $da_im, $this->container);
     $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $login_account, $this->container->get("logger"), $this->container);
     if ($state == "add") {
         if ($staffMgr->checkUser($mobile)) {
             $result = array("success" => false, "msg" => "用户账号已存在,请重新输入!");
             $response = new Response(json_encode($result));
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
         //获得ldap_uid
         $login_array = explode("@", $login_account);
         if (count($login_array) < 2) {
             continue;
         }
         $ldap_uid = $login_array[0];
         //注册用户账号
         $register = new \Justsy\BaseBundle\Controller\ActiveController();
         $register->setContainer($this->container);
         $parameter = array("account" => $login_account, "realName" => $nick_name, "passWord" => $password, "ldap_uid" => $ldap_uid, "eno" => $user->eno, "ename" => $user->ename, "isNew" => '0', "mailtype" => "1", "import" => '1', "isSendMessage" => "N", "mobile" => $mobile, "duty" => $duty, "deptid" => $sns_deptid, "mutual" => "Y");
         $result = $register->doSave($parameter);
         if ($result["returncode"] == "0000") {
             $staffdata = $staffMgr->getInfo();
             //成功后统计人员
             $sql = "call dept_emp_stat(?)";
             $da_im->ExecSQL($sql, array((string) $staffdata["fafa_jid"]));
             //自动关注服务号
             $servicerMgr = new \Justsy\BaseBundle\Management\Service($this->container);
             $parameter = array("eno" => $user->eno, "deptid" => $im_deptid, "login_account" => $login_account);
             $servicerMgr->atten_service($parameter);
             $revJids = $staffMgr->getFriendAndColleagueJid();
             Utils::sendImMessage($user->fafa_jid, implode(",", $revJids), "newstaff", json_encode($staffMgr->getinfo()), $this->container, "", "", false, Utils::$systemmessage_code);
         } else {
             $success = false;
             $msg = "添加用户账号失败:" . $result["msg"];
         }
         $result = array("success" => $success, "msg" => $msg);
         $response = new Response(json_encode($result));
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     } else {
         $staffinfo = $staffMgr->getInfo();
         $deptinfo = $deptMgr->getinfo($staffinfo["dept_id"]);
         //判断是否更改了性别
         if ($sex == $staffinfo["sex_id"]) {
             $sex = null;
         }
         //判断是否更改了职务
         if ($duty == $staffinfo["duty"]) {
             $duty = null;
         }
         //判断是否更改了姓名
         if ($nick_name == $staffinfo["nick_name"]) {
             $nick_name = null;
         }
         //判断是否更新了部门
         if ($sns_deptid == $deptinfo["dept_id"]) {
             $sns_deptid = null;
         }
         //判断是否更新了手机
         if ($mobile == $staffinfo["mobile_bind"]) {
             $mobile = null;
         }
         $uResult = $staffMgr->checkAndUpdate($nick_name, $mobile, $sns_deptid, $duty, null, $sex, null, $e_mail);
         $u_staff = null;
         $factory = null;
         //判断是否修改了密码
         if (!empty($password)) {
             $u_staff = new Staff($da, $da_im, $login_account, $this->get('logger'), $this->container);
             $factory = $this->get('security.encoder_factory');
             $targetStaffInfo = $u_staff->getInfo();
             $re = $u_staff->changepassword($targetStaffInfo["login_account"], $password, $factory);
             if ($re) {
                 //给自己发送一个staff-changepasswod的出席,通知在线客户端密码发生修改,需要新密码重新登录
                 Utils::sendImPresence($user->fafa_jid, $targetStaffInfo["fafa_jid"], "staff-changepasswod", "staff-changepasswod", $this->container, "", "", false, Utils::$systemmessage_code);
             }
         }
         //判断是否修改了帐号
         if ($e_mail != $login_account) {
             //判断邮件是否存在
             if (empty($u_staff)) {
                 $u_staff = new Staff($da, $da_im, $login_account, $this->get('logger'), $this->container);
             }
             if (empty($factory)) {
                 $factory = $this->get('security.encoder_factory');
             }
             $u_staff->changeLoginAccount($e_mail, $factory);
         }
         try {
             $revJids = $staffMgr->getFriendAndColleagueJid();
             if ($uResult && !empty($sns_deptid)) {
                 //部门变更时,需要通知手机端更新原部门和新部门数据
                 Utils::sendImMessage("", implode(",", $revJids), "staff-changedept", json_encode($deptinfo), $this->container, "", "", false, Utils::$systemmessage_code);
                 Utils::sendImMessage("", implode(",", $revJids), "staff-changedept", json_encode($deptMgr->getinfo($sns_deptid)), $this->container, "", "", false, Utils::$systemmessage_code);
                 $old_fafa_deptid = $deptinfo["fafa_deptid"];
                 $fafa_jid = $staffinfo["fafa_jid"];
                 //取消关注服务号
                 $servicerMgr = new \Justsy\BaseBundle\Management\Service($this->container);
                 $parameter = array("eno" => $user->eno, "deptid" => $old_fafa_deptid, "login_account" => $login_account);
                 $servicerMgr->cancel_atten($parameter);
                 //自动关注服务号
                 $parameter = array("eno" => $user->eno, "deptid" => $im_deptid, "login_account" => $login_account);
                 $servicerMgr->atten_service($parameter);
             }
         } catch (\Exception $e) {
             $this->get("logger")->err($e->getMessage());
             $success = false;
             $msg = "修改人员信息失败!";
         }
     }
     $result = array("success" => $success, "msg" => $msg);
     $response = new Response(json_encode($result));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
Esempio n. 25
0
 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;
 }
Esempio n. 26
0
 public function setCovert($parameter)
 {
     $groupid = isset($parameter["groupid"]) ? $parameter["groupid"] : null;
     $jid = isset($parameter["jid"]) ? $parameter["jid"] : null;
     $state = isset($parameter["state"]) ? $parameter["state"] : "1";
     //默认为添加
     $success = true;
     $msg = "";
     if (empty($groupid)) {
         return Utils::WrapResultError('群编号不能为空');
     } else {
         if (empty($jid)) {
             return Utils::WrapResultError('设置的成员帐号不能为空');
         }
     }
     $sql = "";
     $para = array();
     if ($state == "1") {
         $sql = "insert into im_groupemployee_covert(groupid,jid)values(?,?);";
     } else {
         $sql = "delete from im_groupemployee_covert where groupid=? and jid=?;";
     }
     try {
         $this->conn_im->ExecSQL($sql, array((string) $groupid, (string) $jid));
         //向成员发送出席
         $user = $parameter["user"];
         $title = $state == "1" ? "set_covert" : "cancel_covert";
         $message = $state == "1" ? "设置了您的屏蔽群消息" : "取消了您的屏蔽群消息";
         Utils::sendImPresence($user->fafa_jid, $jid, $title, $message, $this->container, "", "", true, '', '0');
     } catch (\Exception $e) {
         $success = false;
         $msg = $state == "1" ? "设置屏蔽成员失败!" : "取消屏蔽成员失败!";
         return Utils::WrapResultError($e->getMessage());
     }
     return Utils::WrapResultOK('1');
 }
Esempio n. 27
0
 public function search($parameter)
 {
     $userinfo = $parameter["user"];
     $appname = isset($parameter["appname"]) ? $parameter["appname"] : "";
     if (!empty($appid)) {
         return $this->getappinfo(array("appid" => $appid));
     }
     $url = $this->containerObj->getParameter('FILE_WEBSERVER_URL');
     $pageno = isset($parameter["pageno"]) ? $parameter["pageno"] : 0;
     //获取列表的起始位置
     $pagesize = isset($parameter["pagesize"]) ? $parameter["pagesize"] : 50;
     $ordertype = isset($parameter["ordertype"]) ? $parameter["ordertype"] : "";
     //排序类型。默认按发布日期
     $sql = "select a.appid,a.appkey,a.appname,a.appdeveloper,a.version,a.show_type,a.apptype,concat('{$url}',a.logo) logo,case a.show_type when '01' then '企业应用' else '个人应用' end show_type_name " . " from we_appcenter_apps a where 1=1 ";
     $para = array();
     if (!empty($appname)) {
         $sql .= " and a.appname like concat('%',?,'%')";
         $para[] = (string) $appname;
     }
     $sql .= " order by a.sortid ";
     $startno = $pageno * $pagesize;
     $sql .= " limit {$startno},{$pagesize} ";
     $ds = $this->conn->GetData("table", $sql, $para);
     return Utils::WrapResultOK($ds["table"]["rows"]);
 }
Esempio n. 28
0
 public function push_receiverlistAction()
 {
     $da = $this->get("we_data_access");
     $da_im = $this->get('we_data_access_im');
     $request = $this->getRequest();
     //访问权限校验
     $api = new \Justsy\OpenAPIBundle\Controller\ApiController();
     $api->setContainer($this->container);
     $isWeFaFaDomain = $api->checkWWWDomain();
     if (!$isWeFaFaDomain) {
         $token = $api->checkAccessToken($request, $da);
         if (!$token) {
             $re = array("returncode" => "9999");
             $re["code"] = "err0105";
             $re["msg"] = "参数Appid或Openid或Access_token未指定或无效.";
             return $this->responseJson($request, $re);
         }
     }
     $openid = $request->get("openid");
     $staffinfo = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $openid, $this->get("logger"), $this->container);
     $staffdata = $staffinfo->getInfo();
     if (empty($staffdata)) {
         $result = Utils::WrapResultError("无效操作帐号");
         return $this->responseJson($request, $result);
     }
     $appid = $request->get('appid');
     $appmgr = new \Justsy\BaseBundle\Management\App($this->container);
     $appdata = $appmgr->getappinfo(array('appid' => $appid));
     if (empty($appdata)) {
         $result = Utils::WrapResultError("无效应用标识");
         return $this->responseJson($request, $result);
     }
     $data = $request->get("data");
     //部门名称
     if (empty($data)) {
         $result = Utils::WrapResultError("无效的数据");
         return $this->responseJson($request, $result);
     }
     $data = json_decode($data, true);
     $noticeMgr = new \Justsy\BaseBundle\Management\PromptlyNotice($this->container, $staffdata, $appdata);
     $result = $noticeMgr->getReceiverList($data);
     return $this->responseJson($request, $result);
 }
Esempio n. 29
0
 public function webServerCtl($paraObj)
 {
     $command = $paraObj['command'];
     if (empty($command)) {
         $result = Utils::WrapResultError("无效的命令");
         return $this->responseJson($result);
     }
     try {
         $dir = explode("src", __DIR__);
         if ($command == "start") {
             $str = "php {$dir[0]}app/console cache:clear --env=prod --no-debug\nchmod -R 777 {$dir[0]}app";
             $command = $dir[0] . 'clear_cache_prod.sh';
             $data = shell_exec($command);
             if (strpos($data, 'Clearing the cache for the prod environment with debug false') === false) {
                 throw new Exception($data);
             }
             return Utils::WrapResultOK($data);
         }
         return Utils::WrapResultError('无效的命令' . $command);
     } catch (\Exception $e) {
         $this->logger->err($e);
         return Utils::WrapResultError($e->getMessage());
     }
 }
Esempio n. 30
0
 public static function userAuthAction($container, $request, $dbcon, $con_im, $login_account, $password, $comefrom)
 {
     //判断是门户登录还是独立登录
     if (strlen($login_account) < 32) {
         //独立登录模式
         $classname = "\\Justsy\\InterfaceBundle\\SsoAuth\\SsoWefafaMd5Auth";
         $re = call_user_func(array($classname, 'userAuthAction'), $container, $request, $dbcon, $con_im, $login_account, $password, $comefrom);
         return $re;
     }
     //解密token和pass
     $token = DES::decrypt_crv_fortoken($login_account, "cn.com.crv.ivv");
     if ($token === false) {
         $container->get("logger")->err("decrypt token error:" . $login_account);
         $re["returncode"] = ReturnCode::$SYSERROR;
         return $re;
     }
     $pass = DES::decrypt_crv_fortoken($password, "cn.com.crv.ivv");
     if ($pass === false) {
         $container->get("logger")->err("decrypt password error:" . $password);
         $re["returncode"] = ReturnCode::$SYSERROR;
         return $re;
     }
     $defaultPostURl = "http://cremobile.crc.com.cn:9090/conn/CrvSecurityWS/userresource/userprofile";
     $cacheobj = new Enterprise($dbcon, $container->get("logger"), $container);
     //
     $authConfig = $cacheobj->getUserAuth();
     $httpUrlConfig = $authConfig["ssoauthurl"];
     if (empty($httpUrlConfig)) {
         $httpUrlConfig = $defaultPostURl;
         $eno = "100001";
     } else {
         $ldapConfgiObject = json_decode($httpUrlConfig, true);
         $eno = $ldapConfgiObject["ENO"];
         $httpUrlConfig = $ldapConfgiObject["URL"];
     }
     try {
         $para = "access_token=" . $token;
         $container->get("logger")->err("SOA URL:" . $httpUrlConfig . "?" . $para);
         $postresult = Utils::getUrlContent($httpUrlConfig . "?" . $para, null);
         $container->get("logger")->err("SOA Result:" . $postresult);
         $resultObject = json_decode($postresult, true);
         //$resultObject=array("empUid"=>"test101","empName"=>"TEST101"); //集成测试
         if (!isset($resultObject["empUid"])) {
             $container->get("logger")->err("get user info error." . $postresult);
             $re["returncode"] = ReturnCode::$SYSERROR;
             return $re;
         }
         $crvuser = $resultObject["empUid"];
         $email = $resultObject["email"];
         $fafa_account = !empty($crvuser) ? strtolower($crvuser) : $email;
         $Obj = new \Justsy\BaseBundle\Login\UserProvider($container);
         $user = $Obj->loadUserByUsername($fafa_account, $comefrom);
         //�Ǽ�seesion
         $token = new \Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken($user, $user->getPassword(), "secured_area", $user->getRoles());
         $container->get("security.context")->setToken($token);
         $session = $request->getSession()->set('_security_' . 'secured_area', serialize($token));
         $event = new \Symfony\Component\Security\Http\Event\InteractiveLoginEvent($request, $token);
         $container->get("event_dispatcher")->dispatch("security.interactive_login", $event);
         $re["returncode"] = ReturnCode::$SUCCESS;
         $re["openid"] = $user->openid;
         $re["login_account"] = $fafa_account;
         $re["ldap_uid"] = $user->ldap_uid;
         $re["jid"] = $user->fafa_jid;
         //为了避免用户修改密码后只刷新了所在服务器,im密码实时获取
         $sql = "select password from users where username=?";
         $iminfo = $con_im->GetData("im", $sql, array((string) $user->fafa_jid));
         $re["des"] = count($iminfo["im"]["rows"]) > 0 ? $iminfo["im"]["rows"][0]["password"] : "";
     } catch (\Symfony\Component\Security\Core\Exception\UsernameNotFoundException $e) {
         $re["returncode"] = ReturnCode::$ERROFUSERORPWD;
     } catch (\Exception $e) {
         $container->get("logger")->err($e);
         $re["returncode"] = ReturnCode::$SYSERROR;
     }
     return $re;
 }