Esempio n. 1
0
 public function actionAdd()
 {
     MainUtil::checkLicenseLimit();
     if (EnvUtil::submitCheck("userSubmit")) {
         $origPass = filter_input(INPUT_POST, "password", FILTER_SANITIZE_STRING);
         $_POST["salt"] = StringUtil::random(6);
         $_POST["password"] = !empty($origPass) ? md5(md5($origPass) . $_POST["salt"]) : "";
         $_POST["createtime"] = TIMESTAMP;
         $_POST["guid"] = StringUtil::createGuid();
         $this->dealWithSpecialParams();
         $data = User::model()->create();
         $newId = User::model()->add($data, true);
         if ($newId) {
             UserCount::model()->add(array("uid" => $newId));
             $ip = Ibos::app()->setting->get("clientip");
             UserStatus::model()->add(array("uid" => $newId, "regip" => $ip, "lastip" => $ip));
             UserProfile::model()->add(array("uid" => $newId));
             if (!empty($_POST["auxiliarydept"])) {
                 $deptIds = StringUtil::getId($_POST["auxiliarydept"]);
                 $this->handleAuxiliaryDept($newId, $deptIds, $_POST["deptid"]);
             }
             if (!empty($_POST["auxiliarypos"])) {
                 $posIds = StringUtil::getId($_POST["auxiliarypos"]);
                 $this->handleAuxiliaryPosition($newId, $posIds, $_POST["positionid"]);
             }
             $newUser = User::model()->fetchByPk($newId);
             $users = UserUtil::loadUser();
             $users[$newId] = UserUtil::wrapUserInfo($newUser);
             User::model()->makeCache($users);
             OrgUtil::update();
             OrgUtil::hookSyncUser($newId, $origPass, 1);
             $this->success(Ibos::lang("Save succeed", "message"), $this->createUrl("user/index"));
         } else {
             $this->error(Ibos::lang("Add user failed"), $this->createUrl("user/index"));
         }
     } else {
         $deptid = "";
         $manager = "";
         $account = Ibos::app()->setting->get("setting/account");
         if ($account["mixed"]) {
             $preg = "[0-9]+[A-Za-z]+|[A-Za-z]+[0-9]+";
         } else {
             $preg = "^[A-Za-z0-9\\!\\@\\#\$\\%\\^\\&\\*\\.\\~]{" . $account["minlength"] . ",32}\$";
         }
         if ($deptid = EnvUtil::getRequest("deptid")) {
             $deptid = StringUtil::wrapId(EnvUtil::getRequest("deptid"), "d");
             $manager = StringUtil::wrapId(Department::model()->fetchManagerByDeptid(EnvUtil::getRequest("deptid")), "u");
         }
         $this->setPageTitle(Ibos::lang("Add user"));
         $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Organization"), "url" => $this->createUrl("department/index")), array("name" => Ibos::lang("User manager"), "url" => $this->createUrl("user/index")), array("name" => Ibos::lang("Add user"))));
         $this->render("add", array("deptid" => $deptid, "manager" => $manager, "passwordLength" => $account["minlength"], "preg" => $preg));
     }
 }
Esempio n. 2
0
 protected function getDataByLetter()
 {
     $deptid = intval(EnvUtil::getRequest("deptid"));
     if (!empty($deptid)) {
         $deptids = Department::model()->fetchChildIdByDeptids($deptid, true);
         $uids = User::model()->fetchAllUidByDeptids($deptids, false);
     } else {
         $users = UserUtil::loadUser();
         $uids = ConvertUtil::getSubByKey($users, "uid");
     }
     $uids = $this->removeDisabledUid($uids);
     $res = UserUtil::getUserByPy($uids);
     return ContactUtil::handleLetterGroup($res);
 }
Esempio n. 3
0
 private static function createStaticJs()
 {
     CacheUtil::load(array("department", "position"), true);
     $unit = Ibos::app()->setting->get("setting/unit");
     $department = DepartmentUtil::loadDepartment();
     $users = UserUtil::loadUser();
     $position = PositionUtil::loadPosition();
     $positionCategory = PositionUtil::loadPositionCategory();
     $companyData = self::initCompany($unit);
     $deptData = self::initDept($department);
     $userData = self::initUser($users);
     $posData = self::initPosition($position);
     $posCatData = self::initPositionCategory($positionCategory);
     $default = file_get_contents(PATH_ROOT . "/static/js/src/org.default.js");
     if ($default) {
         $patterns = array("/\\{\\{(company)\\}\\}/", "/\\{\\{(department)\\}\\}/", "/\\{\\{(position)\\}\\}/", "/\\{\\{(users)\\}\\}/", "/\\{\\{(positioncategory)\\}\\}/");
         $replacements = array($companyData, $deptData, $posData, $userData, $posCatData);
         $new = preg_replace($patterns, $replacements, $default);
         FileUtil::createFile("data/org.js", $new);
         CacheUtil::update("setting");
     }
 }
Esempio n. 4
0
 public function updateByUid($uid, $attributes)
 {
     $counter = $this->updateByPk($uid, $attributes);
     $users = UserUtil::loadUser();
     $users[$uid] = UserUtil::wrapUserInfo(array_merge($users[$uid], $attributes));
     $this->makeCache($users);
     return $counter;
 }
Esempio n. 5
0
 public static function exportExcel($id)
 {
     $data = Email::model()->fetchById($id);
     if ($data) {
         $users = UserUtil::loadUser();
         header("Cache-control: private");
         header("Content-type: application/vnd.ms-excel");
         header("Content-Disposition: attachment; filename=" . ConvertUtil::iIconv($data["subject"], CHARSET, "GBK") . "(" . date("Y-m-d") . ").xls");
         //$html = "            <html xmlns:o=\"urn:schemas-microsoft-com:office:office\"\r\n\t\txmlns:x=\"urn:schemas-microsoft-com:office:excel\"\r\n\t\txmlns=\"http://www.w3.org/TR/REC-html40\">\r\n\t\t<head>\r\n\t\t<title></title>\r\n\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n\t\t</head>\r\n\t\t<body topmargin=\"5\">\r\n\t\t <table border=\"1\" cellspacing=\"1\" width=\"95%\" class=\"small\" cellpadding=\"3\">\r\n\t\t\t<tr style=\"BACKGROUND: #D3E5FA; color: #000000; font-weight: bold;\">\r\n\t\t\t  <td align=\"center\">收件人:</td>\r\n\t\t\t  <td align=\"center\">发件人:</td>\r\n\t\t\t  <td align=\"center\">抄送:</td>\r\n\t\t\t  <td align=\"center\">重要性:</td>\r\n\t\t\t  <td align=\"center\">标题:</td>\r\n\t\t\t  <td align=\"center\">发送时间:</td>\r\n\t\t\t  <td align=\"center\">内容:</td>\r\n\t\t\t  <td align=\"center\">附件名称:</td>\r\n\t\t\t</tr>      ";
         $html = '<html xmlns:o="urn:schemas-microsoft-com:office:office"
     xmlns:x="urn:schemas-microsoft-com:office:excel"
     xmlns="http://www.w3.org/TR/REC-html40">
     <head>
     <title></title>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     </head>
     <body topmargin="5">
      <table border="1" cellspacing="1" width="95%" class="small" cellpadding="3">
         <tr style="BACKGROUND: #D3E5FA; color: #000000; font-weight: bold;">
           <td align="center">收件人:</td>
           <td align="center">发件人:</td>
           <td align="center">抄送:</td>
           <td align="center">重要性:</td>
           <td align="center">标题:</td>
           <td align="center">发送时间:</td>
           <td align="center">内容:</td>
           <td align="center">附件名称:</td>
         </tr>';
         $data["toname"] = self::joinStringByArray($data["toids"], $users, "realname", ";");
         $data["content"] = str_replace("  ", "&nbsp;&nbsp;", $data["content"]);
         $data["content"] = str_replace("\n", "<br>", $data["content"]);
         $data["fromname"] = isset($users[$data["fromid"]]) ? $users[$data["fromid"]]["realname"] : "";
         $data["copytoname"] = self::joinStringByArray($data["copytoids"], $users, "realname", ";");
         $important_desc = "";
         if ($data["important"] == "0") {
             $important_desc = "";
         } elseif ($data["important"] == "1") {
             $important_desc = "<font color=\"#ff6600\">一般邮件</font>";
         } elseif ($data["important"] == "2") {
             $important_desc = "<font color=\"#FF0000\">重要邮件</font>";
         }
         $attachmentname = "";
         if ($data["attachmentid"] !== "") {
             $tempdata = AttachUtil::getAttach($data["attachmentid"]);
             foreach ($tempdata as $value) {
                 $attachmentname .= $value["filename"] . "; ";
             }
         }
         $data["sendtime"] = ConvertUtil::formatDate($data["sendtime"]);
         //$html .= "\r\n                <tr>\r\n                    <td nowrap align=\"center\">" . $data["toname"] . "</td>\r\n                    <td nowrap align=\"center\">" . $data["fromname"] . "</td>\r\n                    <td>" . $data["copytoname"] . "</td>\r\n                    <td nowrap align=\"center\">" . $important_desc . "</td>\r\n                    <td nowrap>" . $data["subject"] . "</td>\r\n                    <td nowrap align=\"center\" x:str=\"" . $data["sendtime"] . "\">" . $data["sendtime"] . "</td>\r\n                    <td>" . $data["content"] . "</td>\r\n                    <td>" . $attachmentname . "</td>\r\n                </tr>\r\n            </table>";
         $html .= '<tr>
                     <td nowrap align="center">' . $data["toname"] . '</td>
                     <td nowrap align="center">' . $data["fromname"] . '</td>
                     <td>' . $data["copytoname"] . '</td>
                     <td nowrap align="center">' . $important_desc . '</td>
                     <td nowrap>' . $data["subject"] . '</td>
                     <td nowrap align="center" x:str="' . $data["sendtime"] . '">' . $data["sendtime"] . '</td>
                     <td>' . $data["content"] . '</td>
                     <td>' . $attachmentname . '</td>
                 </tr></table>';
         echo $html;
     }
 }
Esempio n. 6
0
 public static function getUserByPy($uids = null, $first = false)
 {
     $group = array();
     if (is_array($uids)) {
         $list = User::model()->fetchAllByUids($uids);
     } else {
         $list = UserUtil::loadUser();
     }
     foreach ($list as $k => $v) {
         $py = ConvertUtil::getPY($v["realname"], $first);
         if (!empty($py)) {
             $group[strtoupper($py[0])][] = $k;
         }
     }
     ksort($group);
     $data = array("datas" => $list, "group" => $group);
     return $data;
 }
Esempio n. 7
0
 public function actionBindingUser()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $map = filter_input(INPUT_POST, "map", FILTER_SANITIZE_STRING);
         if (!empty($map)) {
             UserBinding::model()->deleteAllByAttributes(array("app" => "bqq"));
             $maps = explode(",", $map);
             foreach ($maps as $relation) {
                 list($uid, $openId) = explode("=", $relation);
                 UserBinding::model()->add(array("uid" => $uid, "bindvalue" => $openId, "app" => "bqq"));
             }
             $this->ajaxReturn(array("isSuccess" => true));
         }
         $this->ajaxReturn(array("isSuccess" => false));
     } elseif (MessageUtil::getIsImOpen("qq")) {
         $imCfg = Ibos::app()->setting->get("setting/im/qq");
         $factory = new ICIMFactory();
         $adapter = $factory->createAdapter("ICIMQq", $imCfg);
         $api = $adapter->getApi();
         $rs = $api->getUserList(array("timestamp" => 0));
         $bqqUsers = array();
         if (substr($rs, 0, 5) !== "error") {
             $rsArr = json_decode($rs, true);
             if (isset($rsArr["ret"]) && $rsArr["ret"] == 0) {
                 $bqqUsers = $rsArr["data"]["items"];
             }
         }
         $data = array("ibosUsers" => UserUtil::loadUser(), "binds" => UserBinding::model()->fetchAllSortByPk("uid", "app = 'bqq'"), "bqqUsers" => $bqqUsers);
         $this->renderPartial("qqbinding", $data);
     }
 }
Esempio n. 8
0
 public function autoProcessor($item, $readOnly)
 {
     $field = $item["data-field"];
     $width = isset($item["data-width"]) ? $item["data-width"] : "200";
     $autoValue = "";
     $value = $this->getValue($item);
     $hourTime = date("H:i:s", TIMESTAMP);
     $date = date("Y-m-d");
     $time = $date . " " . $hourTime;
     $isTextAuto = substr($field, 0, 8) !== "sys_list";
     $lang = Ibos::getLangSource("workflow.default");
     if ($isTextAuto) {
         switch ($field) {
             case "sys_date":
                 $autoValue = $date;
                 break;
             case "sys_date_cn":
                 $autoValue = ConvertUtil::formatDate(TIMESTAMP, "Y" . $lang["Year"] . "m" . $lang["Month"] . "d" . $lang["Chinese day"]);
                 break;
             case "sys_date_cn_short1":
                 $autoValue = ConvertUtil::formatDate(TIMESTAMP, "Y" . $lang["Year"] . "m" . $lang["month"]);
                 break;
             case "sys_date_cn_short2":
                 $autoValue = ConvertUtil::formatDate(TIMESTAMP, "m" . $lang["Month"] . "d" . $lang["Chinese day"]);
                 break;
             case "sys_date_cn_short3":
                 $autoValue = ConvertUtil::formatDate(TIMESTAMP, "Y" . $lang["Year"]);
                 break;
             case "sys_date_cn_short4":
                 $autoValue = date("Y", TIMESTAMP);
                 break;
             case "sys_time":
                 $autoValue = $hourTime;
                 break;
             case "sys_datetime":
                 $autoValue = $time;
                 break;
             case "sys_week":
                 $autoValue = WfCommonUtil::getWeek();
                 break;
             case "sys_userid":
                 $autoValue = Ibos::app()->user->uid;
                 break;
             case "sys_realname":
                 $autoValue = Ibos::app()->user->realname;
                 break;
             case "sys_userpos":
                 $autoValue = Ibos::app()->user->posname;
                 break;
             case "sys_realname_date":
                 $autoValue = Ibos::app()->user->realname . " " . $date;
                 break;
             case "sys_realname_datetime":
                 $autoValue = Ibos::app()->user->realname . " " . $time;
                 break;
             case "sys_deptname":
                 $autoValue = Department::model()->fetchDeptNameByDeptId(Ibos::app()->user->alldeptid);
                 break;
             case "sys_deptname_short":
                 $autoValue = Ibos::app()->user->deptname;
                 break;
             case "sys_formname":
                 $autoValue = $this->form->formname;
                 break;
             case "sys_runname":
                 $autoValue = $this->inDebug ? "" : $this->run->name;
                 break;
             case "sys_rundate":
                 $autoValue = $this->inDebug ? "" : ConvertUtil::formatDate($this->run->begintime, "d");
                 break;
             case "sys_rundatetime":
                 $autoValue = $this->inDebug ? "" : ConvertUtil::formatDate($this->run->begintime);
                 break;
             case "sys_runid":
                 $autoValue = $this->inDebug ? "" : $this->run->runid;
                 break;
             case "sys_autonum":
                 $autoValue = $this->inApp ? $this->flow->autonum : "";
                 break;
             case "sys_ip":
                 $autoValue = EnvUtil::getClientIp();
                 break;
             case "sys_sql":
                 $sql = $item["data-src"];
                 $tempopt = array("uid" => Ibos::app()->user->uid, "deptid" => Ibos::app()->user->deptid, "positionid" => Ibos::app()->user->positionid, "runid" => $this->inDebug ? "" : $this->run->runid);
                 $autoValue = $this->execSysSql($sql, $tempopt, false);
                 break;
             case "sys_manager1":
                 $main = Ibos::app()->user->deptid;
                 $deptCache = DepartmentUtil::loadDepartment();
                 $managerID = $deptCache[$main]["manager"];
                 if ($managerID != 0) {
                     $autoValue = User::model()->fetchRealnameByUid($managerID);
                 }
                 break;
             case "sys_manager2":
                 $main = Ibos::app()->user->deptid;
                 $deptCache = DepartmentUtil::loadDepartment();
                 $upid = $deptCache[$main]["upid"];
                 if ($upid != 0) {
                     if ($deptCache[$upid]["manager"] != 0) {
                         $autoValue = User::model()->fetchRealnameByUid($deptCache[$upid]["manager"]);
                     }
                 }
                 break;
             case "sys_manager3":
                 $main = Ibos::app()->user->deptid;
                 $deptCache = DepartmentUtil::loadDepartment();
                 $dept_str = Department::model()->queryDept($main);
                 $temp = explode(",", $dept_str);
                 $count = count($temp);
                 $dept = $temp[$count - 2];
                 if ($deptCache[$dept]["manager"] != 0) {
                     $autoValue = User::model()->fetchRealnameByUid($deptCache[$dept]["manager"]);
                 }
                 break;
             default:
                 break;
         }
         if ($value == "" && !$readOnly || $this->flow->isFixed() && $readOnly && StringUtil::findIn($this->process->processitemauto, $item["data-title"]) && $this->rp->opflag) {
             $eleout = "\t\t\t\t<input type=\"text\" style=\"width:{$width} px;\" name=\"data_{$item["itemid"]}\" value=\"{$autoValue}\" title=\"{$item["data-title"]}\" />";
         } else {
             $eleout = "\t\t\t\t<input type=\"text\" style=\"width:{$width} px;\" name=\"data_{$item["itemid"]}\" value=\"{$value}\" title=\"{$item["data-title"]}\" />";
         }
         $hidden = isset($item["data-hide"]) ? $item["data-hide"] : "0";
         if ($hidden == "1") {
             $eleout = str_ireplace("type=\"text\"", "type=\"hidden\"", $eleout);
         }
         if (!$readOnly) {
             if ($this->inApp && $this->flow->isFixed() && StringUtil::findIn($this->process->processitemauto, $item["data-title"])) {
                 $readOnly = true;
             } else {
                 $eleout = str_ireplace("<input", "<input data-orig-value=\"{$autoValue}\" data-focus=\"restore\"", $eleout);
             }
         }
         if ($readOnly) {
             $this->setCommonReadOnly($item, $eleout, "input");
         }
     } else {
         $autoValue = "<option value=\"\"";
         if ($value == "") {
             $autoValue .= " selected";
         }
         $autoValue .= "></option>\n";
         switch ($field) {
             case "sys_list_dept":
                 $cache = DepartmentUtil::loadDepartment();
                 $str = StringUtil::getTree($cache, "<option value='\$deptid' \$selected>\$spacer\$deptname</option>", $value);
                 $autoValue .= $str;
                 break;
             case "sys_list_user":
                 foreach (UserUtil::loadUser() as $user) {
                     $selected = $value == $user["uid"] ? "selected" : "";
                     $autoValue .= "<option {$selected} value='" . $user["uid"] . "'>" . $user["realname"] . "</option>";
                 }
                 break;
             case "sys_list_pos":
                 foreach (PositionUtil::loadPosition() as $pos) {
                     $selected = $value == $pos["positionid"] ? "selected" : "";
                     $autoValue .= "<option {$selected} value='" . $pos["positionid"] . "'>" . $pos["posname"] . "</option>";
                 }
                 break;
             case "sys_list_prcsuser1":
                 $autoValue .= $this->getProcessUserList($this->flow->flowid, 0, $value);
                 break;
             case "sys_list_prcsuser2":
                 $autoValue .= $this->getProcessUserList($this->flow->flowid, $this->process->processid, $value, true);
                 break;
             case "sys_list_sql":
                 $sql = $item["data-src"];
                 $tempopt = array("uid" => Ibos::app()->user->uid, "deptid" => Ibos::app()->user->deptid, "positionid" => Ibos::app()->user->positionid, "runid" => $this->inDebug ? "" : $this->run->runid);
                 $autoValue = $this->execSysSql($sql, $tempopt);
                 $autoValue .= $this->arrayTolist($autoValue, $value);
                 break;
             case "sys_list_manager1":
                 $main = Ibos::app()->user->deptid;
                 $autoValue .= $this->getManagerList($main, $value);
                 break;
             case "sys_list_manager2":
                 $main = Ibos::app()->user->deptid;
                 $deptCache = DepartmentUtil::loadDepartment();
                 $upid = $deptCache[$main]["upid"];
                 if ($upid != 0) {
                     $autoValue .= $this->getManagerList($main, $value);
                 }
                 break;
             case "sys_list_manager3":
                 $main = Ibos::app()->user->deptid;
                 $deptCache = DepartmentUtil::loadDepartment();
                 $dept_str = Department::model()->queryDept($main);
                 $temp = explode(",", $dept_str);
                 $count = count($temp);
                 $dept = $temp[$count - 2];
                 $autoValue .= $this->getManagerList($dept, $value);
                 break;
         }
         $eleout = "\t\t\t\t\t<select title=\"{$item["data-title"]}\" name=\"data_{$item["itemid"]}\">\r\n\t\t\t\t\t{$autoValue}\r\n\t\t\t\t\t</select>";
         if ($readOnly) {
             $this->setCommonReadOnly($item, $eleout, "select");
         }
     }
     return $eleout;
 }
Esempio n. 9
0
 public function fetchAllUidsByDocId($docId)
 {
     $doc = $this->fetchByPk($docId);
     if (empty($doc)) {
         return null;
     }
     if ($doc["deptid"] == "alldept" || empty($doc["deptid"]) && empty($doc["positionid"]) && empty($doc["uid"])) {
         $users = UserUtil::loadUser();
         $uids = ConvertUtil::getSubByKey($users, "uid");
     } else {
         $uids = array();
         if (!empty($doc["deptid"])) {
             $deptids = Department::model()->fetchChildIdByDeptids($doc["deptid"], true);
             $uids = array_merge($uids, User::model()->fetchAllUidByDeptids($deptids, false));
         }
         if (!empty($doc["positionid"])) {
             $uids = array_merge($uids, User::model()->fetchAllUidByPositionIds($doc["positionid"], false));
         }
         if (!empty($doc["uid"])) {
             $uids = array_merge($uids, explode(",", $doc["uid"]));
         }
     }
     return array_unique($uids);
 }
Esempio n. 10
0
 private function addUser()
 {
     if (Ibos::app()->request->isAjaxRequest) {
         $fields = array("username", "password", "realname", "mobile", "deptid", "positionid", "email");
         if (empty($_POST["username"]) || empty($_POST["password"])) {
             $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("Username or password not empty")));
         }
         foreach ($fields as $field) {
             if (isset($_POST[$field]) && !empty($_POST[$field])) {
                 $_POST[$field] = StringUtil::filterDangerTag($_POST[$field]);
             }
         }
         $salt = StringUtil::random(6);
         $userData = array("salt" => $salt, "username" => $_POST["username"], "password" => !empty($_POST["password"]) ? md5(md5($_POST["password"]) . $salt) : "", "realname" => $_POST["realname"], "mobile" => $_POST["mobile"], "createtime" => TIMESTAMP, "deptid" => intval($_POST["deptid"]), "positionid" => intval($_POST["positionid"]), "email" => $_POST["email"]);
         $newId = User::model()->add($userData, true);
         if ($newId) {
             UserCount::model()->add(array("uid" => $newId));
             $ip = Ibos::app()->setting->get("clientip");
             UserStatus::model()->add(array("uid" => $newId, "regip" => $ip, "lastip" => $ip));
             UserProfile::model()->add(array("uid" => $newId));
             $newUser = User::model()->fetchByPk($newId);
             $users = UserUtil::loadUser();
             $users[$newId] = UserUtil::wrapUserInfo($newUser);
             User::model()->makeCache($users);
             OrgUtil::update();
             $res["isSuccess"] = true;
         } else {
             $res["isSuccess"] = false;
             $res["msg"] = Ibos::lang("Add user failed");
         }
         $this->ajaxReturn($res);
     }
 }