Esempio n. 1
0
 public function pcSyncAction()
 {
     $res = $this->get("request");
     $auth = $res->get("authcode");
     $interviewee = $res->get("interviewee");
     //$paras =  explode(",", trim(DES::decrypt($interviewee)));
     if ($auth == null || $auth == "") {
         $this->get("logger")->err("=====pcSyncAction Error:authcode为空!");
         return $this->render('JustsyBaseBundle:Account:pcsync_error.html.twig');
         //$this->redirect($this->generateUrl('JustsyBaseBundle_login'));
     }
     try {
         $auth = trim(DES::decrypt($auth));
         //解密参数串
         $paras = explode(",", trim(DES::decrypt($interviewee)));
         //授权码已过期
         $lng = time() - (int) $auth;
         if ($lng > 30 || $lng < 0) {
             $this->get("logger")->err("=====pcSyncAction Error:授权码已过期!");
             return $this->render('JustsyBaseBundle:Account:pcsync_error.html.twig');
             //$this->redirect($this->generateUrl('JustsyBaseBundle_login'));
         }
     } catch (\Exception $e) {
         $this->get("logger")->err($e);
         return $this->render('JustsyBaseBundle:Account:pcsync_error.html.twig');
         //$this->redirect($this->generateUrl('JustsyBaseBundle_login'));
     }
     try {
         if (count($paras) != 2 && count($paras) != 1) {
             $this->get("logger")->err("=====pcSyncAction Error:参数{$paras不正确!}");
             return $this->render('JustsyBaseBundle:Account:pcsync_error.html.twig');
             //$this->redirect($this->generateUrl('JustsyBaseBundle_login'));
         }
         $ec = new \Justsy\BaseBundle\Controller\PersonalHomeController();
         $ec->setContainer($this->container);
         //通过openID获取用户信息
         $user = $ec->loadUserByUsername($paras[0]);
         if ($user == null) {
             $this->get("logger")->err("=====pcSyncAction Error:{$paras用户信息未找到!}");
             return $this->render('JustsyBaseBundle:Account:pcsync_error.html.twig');
             //$this->redirect($this->generateUrl('JustsyBaseBundle_login'));
         }
         $network_domain = $user->edomain;
         //登记seesion
         $token = new UsernamePasswordToken($user, $user->getPassword(), "secured_area", $user->getRoles());
         $this->get("security.context")->setToken($token);
         $session = $res->getSession()->set('_security_' . 'secured_area', serialize($token));
         $event = new InteractiveLoginEvent($this->get("request"), $token);
         $this->get("event_dispatcher")->dispatch("security.interactive_login", $event);
         $account = "";
         if (count($paras) == 1) {
             $photo_url = $this->container->getParameter('FILE_WEBSERVER_URL') . $user->photo_path_big;
             $account = $user->getUsername();
             $list["account"] = $account;
             $list["name"] = $user->nick_name;
             $list["deptid"] = $user->dept_id;
             $list["deptname"] = $user->dept_name;
             $list["birthday"] = $user->birthday;
             $list["year"] = date('Y', strtotime($user->birthday));
             $list["month"] = date('n', strtotime($user->birthday));
             $list["day"] = date('j', strtotime($user->birthday));
             $list["birthday"] = $list["year"] . "年" . $list["month"] . "月" . $list["day"] . "日";
             $list["work_phone"] = $user->work_phone;
             $list["mobile"] = $user->mobile;
             $list["duty"] = $user->duty;
             $list["sex_id"] = empty($user->sex_id) ? "" : $user->sex_id;
             $list["isself"] = "1";
         } else {
             $user = $ec->getUserInfo($paras[1]);
             $user = $user["we_staff"]["rows"][0];
             $photo_url = $this->container->getParameter('FILE_WEBSERVER_URL') . $user["photo_path_big"];
             $account = $user["login_account"];
             $list["account"] = $account;
             $list["name"] = $user["nick_name"];
             $list["deptid"] = $user["dept_id"];
             $list["deptname"] = $user["dept_name"];
             $list["birthday"] = $user["birthday"];
             $list["year"] = date('Y', strtotime($list["birthday"]));
             $list["month"] = date('n', strtotime($list["birthday"]));
             $list["day"] = date('j', strtotime($list["birthday"]));
             $list["birthday"] = $list["year"] . "年" . $list["month"] . "月" . $list["day"] . "日";
             $list["work_phone"] = $user["work_phone"];
             $list["mobile"] = $user["mobile"];
             $list["duty"] = $user["duty"];
             $list["sex_id"] = empty($user["sex_id"]) ? "" : $user["sex_id"];
             $list["isself"] = "0";
         }
         $sql = "select a.mobile, a.mobile_bind,a.hometown,a.graduated,a.work_his,a.self_desc,a.specialty,a.hobby from we_staff a where a.login_account=?";
         $params = array();
         $params[] = $account;
         $da = $this->get("we_data_access");
         $ds = $da->GetData("we_staff_mobile", $sql, $params);
         $ds = $ds["we_staff_mobile"]["rows"][0];
         $list["mobile_bind"] = $ds["mobile_bind"];
         $list["self_desc"] = $ds["self_desc"];
         $list["hometown"] = $ds["hometown"];
         $list["graduated"] = $ds["graduated"];
         $list["work_his"] = $ds["work_his"];
         $list["specialty"] = $ds["specialty"];
         $list["hobby"] = $ds["hobby"];
         $list["direct_manages"] = "";
         $list["report_object"] = "";
         $list["path"] = $photo_url;
         $list["msg"] = null;
         $list["curr_network_domain"] = $network_domain;
         $perBase = new \Justsy\BaseBundle\Controller\CPerBaseInfoController();
         $perBase->setContainer($this->container);
         $list["InfoCompletePercent"] = $perBase->GetInfoCompletePercent($account);
         return $this->render('JustsyBaseBundle:Account:pcsync.html.twig', $list);
     } catch (\Exception $e) {
         $this->get("logger")->err($e);
         return $this->render('JustsyBaseBundle:Account:pcsync_error.html.twig');
         //$this->redirect($this->generateUrl('JustsyBaseBundle_login'));
     }
 }
 public function rightuserguidAction($network_domain)
 {
     $data = array();
     $data['curr_network_domain'] = $network_domain;
     $perBaseInfo = new \Justsy\BaseBundle\Controller\CPerBaseInfoController();
     $perBaseInfo->setContainer($this->container);
     $user = $this->get('security.context')->getToken()->getUser();
     $InfoCompletePercent = $perBaseInfo->GetInfoCompletePercent($user->getUsername());
     $data['InfoCompletePercent'] = $InfoCompletePercent;
     $data["ROSTER_INVITE"] = true;
     $data["DOC"] = true;
     if (!in_array(\Justsy\BaseBundle\Management\FunctionCode::$ROSTER_INVITE, $user->getFunctionCodes())) {
         $data["ROSTER_INVITE"] = false;
     }
     if (!in_array(\Justsy\BaseBundle\Management\FunctionCode::$ROSTER_INVITE, $user->getFunctionCodes())) {
         $data["DOC"] = false;
     }
     return $this->render('JustsyBaseBundle:EnterpriseHome:right_operation.html.twig', $data);
 }