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 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); }
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; }
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']; }