public function WeiXinLoginAction()
 {
     $deploy_mode = $this->container->getParameter('deploy_mode');
     $da = $this->get("we_data_access");
     $request = $this->getRequest();
     $openid = $request->get("openid");
     $unionid = $request->get("unionid");
     $logintype = $request->get("logintype");
     $logintype = empty($logintype) ? "02" : $logintype;
     $ldap_uid = null;
     $login_account = $unionid . "@fafatime.com";
     $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get('we_data_access_im'), $login_account, $this->get("logger"), $this->container);
     $staffdata = $staffMgr->getInfo();
     $re = array("returncode" => ReturnCode::$SYSERROR, "msg" => "");
     $password = "";
     //账号为空表示不存在
     if (empty($staffdata)) {
         $eno = $deploy_mode == "C" ? Utils::$PUBLIC_ENO : "";
         if (empty($eno)) {
             $cacheobj = new \Justsy\BaseBundle\Management\Enterprise($da, $this->get("logger"), $this->container);
             //获取用户认证模块
             $authConfig = $cacheobj->getUserAuth();
             if (!empty($authConfig)) {
                 $eno = $authConfig["ENO"];
             }
             if (empty($eno)) {
                 $re["returncode"] = ReturnCode::$SYSERROR;
                 $re["msg"] = "企业号不能为空。";
                 return $re;
             }
         }
         $ldap_uid = $unionid;
         $password = rand(1000000, 999999);
         $parameter = array("appid" => $request->get("appid"), "eno" => $eno, "openid" => $openid, "nick_name" => $request->get("nickname"), "sex" => $request->get("sex"), "province" => $request->get("province"), "city" => $request->get("city"), "headimgurl" => $request->get("headimgurl"), "unionid" => $unionid, "account" => "", "password" => $password, "ldap_uid" => $ldap_uid, "type" => "weixin");
         $staffdata = $staffMgr->createstaff($parameter);
         //注册用户账号
         if ($staffdata["returncode"] == ReturnCode::$SUCCESS) {
             $re = $this->autologin($login_account, $password, $logintype);
         } else {
             $re = $staffdata;
         }
     } else {
         $password = DES::decrypt($staffdata["t_code"]);
         $re = $this->autologin($login_account, $password, $logintype);
     }
     //$staffdata["des"] = DES::decrypt($staffdata["t_code"]);
     $response = new Response(json_encode($re));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
Beispiel #2
0
 public function createWorkflow($parameter)
 {
     $appid = $parameter["appid"];
     $userinfo = $parameter["user"];
     $to = isset($parameter["to"]) ? $parameter["to"] : "";
     $wf_name = $parameter["wf_name"];
     $wf_type = $parameter["wf_type"];
     $wf_content = $parameter["wf_content"];
     if (empty($wf_content)) {
         $wf_content = $wf_name;
     }
     $wf_remark = isset($parameter["wf_remark"]) ? $parameter["wf_remark"] : "";
     $eno = $userinfo->eno;
     $account = $userinfo->getUserName();
     if (empty($to)) {
         $enobj = new \Justsy\BaseBundle\Management\Enterprise($this->conn, $this->logger, $this->containerObj);
         $endata = $enobj->getInfo($eno);
         $to = $endata["sys_manager"] || $endata["create_staff"];
         if (empty($to)) {
             throw new \Exception("提交失败:企业未指定管理员");
         }
     }
     if (empty($appid) || empty($wf_name)) {
         throw new \Exception("提交失败:请检查是否指定了wf_name和appid参数");
     }
     $wf_id = SysSeq::GetSeqNextValue($this->conn, "we_app_businessworkflow", "wf_id");
     $sql = array("insert into we_app_businessworkflow select ?,?,?,?,now(),?,?,?,?");
     $para = array(array((string) $wf_id, (string) $wf_name, (string) $appid, (string) $wf_content, (string) $account, (string) $wf_remark, (string) $eno, (string) $wf_type));
     $re = null;
     //生成第一个流转节点
     $node_id = SysSeq::GetSeqNextValue($this->conn, "we_app_workflow_node", "node_id");
     //节点状态:9->未审批  0->审批拒绝  1->审批同意
     $sql[] = "insert into we_app_workflow_node select ?,?,?,?,now(),9,'','','',''";
     $para[] = array((string) $node_id, (string) $wf_name, (string) $wf_id, (string) $account);
     //附件处理
     if (!empty($parameter["attachment"])) {
         $attachment = explode(",", $parameter["attachment"]);
         for ($i = 0; $i < count($attachment); $i++) {
             if (empty($attachment[$i])) {
                 continue;
             }
             $attachment_id = SysSeq::GetSeqNextValue($this->conn, "we_app_workflow_attachment", "id");
             $sql[] = "insert into we_app_workflow_attachment(id,node_id,file_id)values(?,?,?)";
             $para[] = array((string) $attachment_id, (string) $node_id, (string) ${$attachment}[$i]);
         }
     }
     //生成审批人列表
     $tos = explode(";", $to);
     for ($i = 0; $i < count($tos); $i++) {
         $staffobj = new \Justsy\BaseBundle\Management\Staff($this->conn, $this->conn_im, $tos[$i], $this->logger, $this->containerObj);
         $staffata = $staffobj->getInfo();
         if (empty($staffata)) {
             continue;
         }
         $id = SysSeq::GetSeqNextValue($this->conn, "we_app_workflow_nodesetting", "id");
         $sql[] = "insert into we_app_workflow_nodesetting select ?,?,?,?,?,?,?,?";
         $para[] = array((string) $id, (string) $wf_id, (string) $node_id, (string) $wf_name, (string) $tos[$i], "0", "0", (string) $staffata["fafa_jid"]);
     }
     $this->conn->ExecSQLs($sql, $para);
     $re = $this->getNode(array("node_id" => $node_id));
     //$message = ($user->nick_name)."修改了群组(".$groupname.")资料!";
     //Utils::sendImPresence($user->fafa_jid,$to_jid,"edit_groupinfo",$message,$this->container,"","",true,'','0');
     return $re;
 }
 public function savemanager_settingAction($network_domain)
 {
     $DataAccess = $this->get('we_data_access');
     $manager = $this->getRequest()->get('array_manager');
     $meeting_manager = $this->getRequest()->get('array_meeting_manager');
     $mobile_manager = $this->getRequest()->get('array_mobile_manager');
     $sql = 'select a.enterprise_no,a.circle_id,b.ename from we_circle a,we_enterprise b where a.network_domain=? and a.enterprise_no=b.eno ';
     $dataset = $DataAccess->GetData('we_circle', $sql, array((string) $network_domain));
     if ($dataset['we_circle']['recordcount'] > 0) {
         $enterprise_no = $dataset['we_circle']['rows'][0]['enterprise_no'];
         $circle_id = $dataset['we_circle']['rows'][0]['circle_id'];
         $ename = $dataset['we_circle']['rows'][0]['ename'];
     } else {
         return '';
     }
     //设置指定企业的会议管理专员
     $da = $this->get('we_data_access');
     $da_im = $this->get("we_data_access_im");
     $meetingManager = new MeetingManager($da, $da_im);
     $meetingManager->Set($enterprise_no, $meeting_manager);
     //设置指定的移动门户管理员
     $set = new \Justsy\BaseBundle\Management\StaffCompetenceMgr($da, $da_im);
     $sql = "delete from we_function_onoff where functionid='MAPP_ADMIN' and eno=?";
     $da->ExecSQL($sql, array((string) $enterprise_no));
     if (!empty($mobile_manager)) {
         $mobile_manager_array = explode(';', $mobile_manager);
         foreach ($mobile_manager_array as $key => $value) {
             $set->Set($enterprise_no, "mapp-manager", $value);
             $sql = "insert into we_function_onoff(functionid,login_account,state,eno)values('MAPP_ADMIN',?,'1',?)";
             $da->ExecSQL($sql, array((string) $value, (string) $enterprise_no));
         }
     }
     //设置指定的企业管理员
     $sqls = array('update we_enterprise set sys_manager=? where eno=?', 'update we_circle     set     manager=? where circle_id=?');
     $paras = array(array((string) $manager, (string) $enterprise_no), array((string) $manager, (string) $circle_id));
     $new_manager_array = array();
     $old_manager_array = array();
     $new_manager_array = explode(';', $manager);
     $sql = 'select manager from we_circle where network_domain=?';
     $dataset = $DataAccess->GetData('we_circle', $sql, array((string) $network_domain));
     if ($dataset['we_circle']['recordcount'] > 0) {
         $old_manager_array = explode(';', $dataset['we_circle']['rows'][0]['manager']);
     }
     //var_dump($new_manager_array);
     //var_dump($old_manager_array);
     //exit;
     $new_manager = array_diff($new_manager_array, $old_manager_array);
     // 新增管理员
     $old_manager = array_diff($old_manager_array, $new_manager_array);
     //取消了的管理员
     $dataexec = $DataAccess->ExecSQLs($sqls, $paras);
     if ($dataexec) {
         if (count($new_manager) > 0 || count($old_manager) > 0) {
             $sqls = array('insert into we_message(msg_id,sender,send_date,title,content,isread,recver) values(?,?,CURRENT_TIMESTAMP(),?,?,?,?)', 'insert into we_notify(notify_type,msg_id,notify_staff) values(?,?,?)');
             $login_account = $this->get('security.context')->getToken()->getUser()->getUsername();
             $FAFA_CIRCLE_URL = $this->generateUrl('JustsyBaseBundle_enterprise_home', array('network_domain' => $network_domain), true);
             foreach ($new_manager as $key => $value) {
                 $msg_id = \Justsy\BaseBundle\DataAccess\SysSeq::GetSeqNextValue($DataAccess, "we_message", "msg_id");
                 $sys_manager = $value;
                 $title = '您被设置为管理员';
                 $content = '您被设置为企业' . '<a target="_blank" href="' . $FAFA_CIRCLE_URL . '">【' . $ename . '】</a>的管理员!';
                 $paras = array(array((string) $msg_id, (string) $login_account, (string) $title, (string) $content, '0', (string) $sys_manager), array('02', (string) $msg_id, (string) $sys_manager));
                 $dataexec1 = $DataAccess->ExecSQLs($sqls, $paras);
             }
             foreach ($old_manager as $key => $value) {
                 $msg_id = \Justsy\BaseBundle\DataAccess\SysSeq::GetSeqNextValue($DataAccess, "we_message", "msg_id");
                 $sys_manager = $value;
                 $title = '您被取消了管理员';
                 $content = '您被取消了企业' . '<a target="_blank" href="' . $FAFA_CIRCLE_URL . '">【' . $ename . '】</a>的管理员!';
                 $paras = array(array((string) $msg_id, (string) $login_account, (string) $title, (string) $content, '0', (string) $sys_manager), array('02', (string) $msg_id, (string) $sys_manager));
                 $dataexec2 = $DataAccess->ExecSQLs($sqls, $paras);
             }
             //更新企业缓存
             $enMgr = new \Justsy\BaseBundle\Management\Enterprise($DataAccess, $this->get("logger"), $this->container);
             $enMgr->refresh($enterprise_no);
         }
         return $this->res('{"success":1}', 'json');
     } else {
         return $this->res('{"success":0}', 'json');
     }
 }
Beispiel #4
0
 public function InsertStaffRole($staff_account, $roleid, $eno)
 {
     $turn = '0';
     //判断权限控制类型
     $cacheobj = new \Justsy\BaseBundle\Management\Enterprise($this->conn, $this->logger, $this->container);
     $enterinfo = $cacheobj->getInfo($eno);
     $eno_level = $enterinfo['eno_level'];
     $mstyle = $enterinfo['mstyle'];
     if ($eno_level != 'S' || $mstyle == 'outpriv') {
         $turn = '1';
     }
     $array["success"] = 0;
     $array["msg"] = "";
     $staff_fafajid = $this->getStaffJid($staff_account);
     if (empty($staff_fafajid)) {
         $array["success"] = 1;
         $array["msg"] = "帐号不存在";
     } else {
         $sqls = array();
         $paras = array();
         $sqls_im = array();
         $paras_im = array();
         if (count($this->getStaffRole($staff_account, $roleid)) > 0) {
             $array["success"] = 1;
             $array["msg"] = "人员角色已经存在";
         } else {
             $id = SysSeq::GetSeqNextValue($this->conn, "we_staff_role", "id");
             $sqls[] = "insert into we_staff_role(id,staff,roleid,eno) values(?,?,?,?)";
             $para = array();
             array_push($para, (string) $id);
             array_push($para, (string) $staff_account);
             array_push($para, (string) $roleid);
             array_push($para, (string) $eno);
             $paras[] = $para;
             $data_function = $this->getFunctionCode($roleid);
             if (count($data_function) > 0) {
                 $sqls[] = "delete from we_function_onoff where login_account=? ";
                 $paras[] = array($staff_account);
                 $sqls_im = "delete from im_employeerole where employeeid=? ";
                 $para_im = array();
                 array_push($para_im, (string) $staff_fafajid);
                 $this->conn_im->ExecSQL($sqls_im, $para_im);
                 $sqls_im = array();
                 $paras_im = array();
                 if ($turn == '1') {
                     for ($i = 0; $i < count($data_function); $i++) {
                         $sqls[] = "insert into we_function_onoff (functionid,login_account,state,eno) values(?,?,?,?)";
                         $paras[] = array($data_function[$i]["code"], $staff_account, $turn, $eno);
                         $sqls_im[] = "insert into im_employeerole(employeeid,roleid) values(?,?)";
                         $para_im = array();
                         array_push($para_im, (string) $staff_fafajid);
                         array_push($para_im, (string) $data_function[$i]["code"]);
                         $paras_im[] = $para_im;
                     }
                 }
             }
         }
         try {
             if (!empty($sqls)) {
                 $dataexec = $this->conn->ExecSQLs($sqls, $paras);
                 if ($dataexec && !empty($sqls_im)) {
                     $this->conn_im->ExecSQLs($sqls_im, $paras_im);
                     $array["success"] = 0;
                     $array["msg"] = "数据保存成功";
                 } else {
                     $array["success"] = 1;
                     $array["msg"] = "数据保存失败";
                 }
             }
         } catch (\Exception $exc) {
             $this->logger->err($exc);
             $array["success"] = 1;
             $array["msg"] = "保存出现异常";
         }
     }
     return $array;
 }
Beispiel #5
0
 public function createstaff($parameter)
 {
     $deploy_mode = $this->container->getParameter('deploy_mode');
     $mobile_num = $parameter['account'];
     $mobile_pwd = $parameter['password'];
     $org_pwd = $mobile_pwd;
     //原始密码
     $deptid = isset($parameter['deptid']) ? $parameter['deptid'] : "";
     $eno = isset($parameter['eno']) ? $parameter['eno'] : $this->container->getParameter('ENO');
     $nick_name = $parameter['nick_name'];
     $ldap_uid = isset($parameter["ldap_uid"]) ? $parameter["ldap_uid"] : "";
     //优先采用第三方标识做为帐号,其次使用手机号做为帐号
     $login_account = empty($ldap_uid) ? $mobile_num : $ldap_uid;
     if (empty($login_account)) {
         return Utils::WrapResultError("请输入帐号!");
     }
     if (empty($mobile_pwd)) {
         return Utils::WrapResultError("请输入密码!");
     }
     if (empty($nick_name)) {
         return Utils::WrapResultError("请输入昵称!");
     }
     if (!strpos($login_account, "@")) {
         $domain = $this->container->getParameter('edomain');
         $login_account .= "@" . $domain;
     }
     $this->account = $login_account;
     $isHd = $this->getInfo();
     if (!empty($isHd)) {
         //已经注册,直接返回
         return Utils::WrapResultOK($isHd);
     }
     if (!empty($mobile_num) && Utils::validateMobile($mobile_num)) {
         if ($this->checkUser($mobile_num)) {
             return Utils::WrapResultError("该手机号已被绑定,请解绑后重试");
         }
     }
     $da = $this->conn;
     $da_im = $this->conn_im;
     try {
         //同步人员到业务系统
         $syncurl = null;
         try {
             //判断是否需要同步到其他系统
             $syspara = new \Justsy\BaseBundle\DataAccess\SysParam($this->container);
             $syncurl = $syspara->GetSysParam('staff_sync_url', '');
         } catch (\Exception $e) {
         }
         $cacheobj = new \Justsy\BaseBundle\Management\Enterprise($da, $this->logger, $this->container);
         //获取用户认证模块
         $authConfig = $cacheobj->getUserAuth();
         if (!empty($syncurl) && !empty($authConfig)) {
             try {
                 $classname = $authConfig["ssoauthmodule"];
                 if (!empty($classname)) {
                     $parameters = array("nick_name" => $nick_name, "mobile" => $login_account, "password" => $mobile_pwd);
                     $classname = "\\Justsy\\InterfaceBundle\\SsoAuth\\Sso" . $classname;
                     $re = call_user_func(array($classname, 'createUser'), $this->container, $parameters);
                     $ldap_uid = $re["ldap_uid"];
                     //该 属性必须由对应用户认证模块的方法createUser返回
                 }
             } catch (\Exception $e) {
                 $this->get("logger")->err($e);
                 return Utils::WrapResultError($e->getMessage());
             }
         }
         if (!empty($authConfig) && empty($eno)) {
             $eno = $authConfig["ENO"];
         }
         //验证企业号
         if (!empty($eno)) {
             $enterinfo = $cacheobj->getInfo($eno);
             if ($enterinfo == null) {
                 return Utils::WrapResultError("未找到您注册的企业!");
             }
             $edomain = $enterinfo['edomain'];
         }
         if (empty($deptid)) {
             $deptinfo = new \Justsy\BaseBundle\Management\Dept($da, $da_im);
             $deptid = $deptinfo->getDefaultDept($eno);
             $fafa_deptid = $deptid["deptid"];
             $deptid = $deptid["deptid"];
         } else {
             $deptinfo = new \Justsy\BaseBundle\Management\Dept($da, $da_im);
             $deptid = $deptinfo->getinfo($deptid);
             $fafa_deptid = $deptid["deptid"];
             $deptid = $deptid["deptid"];
         }
         $auth_level = "S";
         $eno_vip = $enterinfo['vip_level'];
         $eno_level = $enterinfo['eno_level'];
         $edomain = $enterinfo['edomain'];
         $circleId = $enterinfo['circle_id'];
         //注册jid
         $jid = SysSeq::GetSeqNextValue($da, "we_staff", "fafa_jid");
         $jid .= "-" . $eno . "@" . $edomain;
         //生成密码
         $user = new UserSession($login_account, $mobile_pwd, $login_account, array("ROLE_USER"));
         $factory = $this->container->get("security.encoder_factory");
         $encoder = $factory->getEncoder($user);
         $pwd = $encoder->encodePassword($mobile_pwd, $user->getSalt());
         $mobile_pwd = DES::encrypt($mobile_pwd);
         $istester = "";
         //是否是通过万能验证码激活的测试人员
         //插入人员、圈子信息
         $sqls[] = "insert into we_staff (dept_id,login_account,eno,password,nick_name,photo_path,state_id,fafa_jid,photo_path_small,photo_path_big,openid,register_date,active_date,t_code,auth_level,mobile,mobile_bind,ldap_uid,login_source) values (?,?,?,?,?,?,?,?,?,?,?,(select register_date from we_register where login_account=?),now(),?,?,?,?,?,?)";
         $sqls[] = "insert into we_circle_staff (circle_id,login_account,nick_name) values (?,?,?)";
         $sqls[] = "update we_register set state_id='3' where login_account=?";
         $paras[] = array((string) $deptid, (string) $login_account, (string) $eno, (string) $pwd, (string) $nick_name, (string) '', (string) "1", (string) $jid, (string) '', (string) '', (string) md5($eno . $login_account), (string) $login_account, (string) $mobile_pwd, (string) $auth_level, empty($mobile_num) ? null : (string) $mobile_num, empty($mobile_num) ? null : (string) $mobile_num, (string) $ldap_uid, $istester);
         $paras[] = array((string) $circleId, (string) $login_account, (string) $nick_name);
         $paras[] = array((string) $login_account);
         $da->ExecSQLs($sqls, $paras);
         //向RBAC跟新用户身份
         //$staffRole=new \Justsy\BaseBundle\Rbac\StaffRole($da,$da_im,$this->logger);
         //$staffRole->InsertStaffRoleByCode($login_account,$auth_level.$eno_vip,$eno);
     } catch (\Exception $e) {
         $this->logger->err($e);
         return Utils::WrapResultError($e->getMessage());
     }
     //写we_im库
     $sqls = array();
     $paras = array();
     try {
         //写入人员 如果$jid_old为空执行原有逻辑,否则更新旧jid数据
         if (empty($jid_old)) {
             $sqls = array();
             $paras = array();
             $pinyin = Utils::Pinyin($nick_name);
             $employeeid = SysSeq::GetSeqNextValue($da_im, "im_employee", "employeeid");
             $sqls[] = "insert into im_employee (employeeid, deptid, loginname, password, employeename,spell) values (?, ?, ?, ?, ?,?)";
             $paras[] = array((string) $employeeid, (string) $fafa_deptid, (string) $jid, (string) $mobile_pwd, (string) $nick_name, (string) $pinyin);
             $sqls[] = "insert into users (username, password, created_at) values (?, ?, now())";
             $paras[] = array((string) $jid, (string) $mobile_pwd);
             $sqls[] = "insert into im_b_msg_read (employeeid, lastid, readdatetime) values (?, (select max(id) from im_b_msg), now())";
             $paras[] = array((string) $jid);
             $da_im->ExecSQLs($sqls, $paras);
             try {
                 $da_im->ExecSQL("call dept_emp_stat(?)", array((string) $jid));
             } catch (\Exception $e) {
             }
             $this->syncAttrsToIM();
             $jid_old = $jid;
         }
     } catch (\Exception $e) {
         $this->logger->err($e);
         return Utils::WrapResultError($e->getMessage());
     }
     //关注自己所属企业的开放的内部公众号
     $mac = new \Justsy\BaseBundle\Management\MicroAccountMgr($da, $da_im, $login_account, $this->logger, $this->container);
     $mac->attenCompanyOpenAccount();
     //自动关注当前企业的开放公众号
     $re = $this->getInfo();
     return Utils::WrapResultOK($re);
 }
 private function getECircle($da, $eno)
 {
     $en = new \Justsy\BaseBundle\Management\Enterprise($da, $this->get('logger'), $this->container);
     $eninfo = $en->getInfo($eno);
     return empty($eninfo) ? '' : $eninfo['circle_id'];
 }