control.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. <?php
  2. /**
  3. * The control file of convert currentModule of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
  6. * @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Chunsheng Wang <chunsheng@cnezsoft.com>
  8. * @package convert
  9. * @version $Id: control.php 4976 2013-07-02 08:15:31Z wyd621@gmail.com $
  10. * @link https://www.zentao.net
  11. */
  12. class convert extends control
  13. {
  14. /**
  15. * 数据导入首页。
  16. * Index page of convert.
  17. *
  18. * @param string $mode
  19. * @access public
  20. * @return void
  21. */
  22. public function index($mode = '')
  23. {
  24. $jiraRelation = $this->session->jiraRelation;
  25. $jiraRelation = $jiraRelation ? json_decode($jiraRelation, true) : array();
  26. if($jiraRelation && $mode == 'restore')
  27. {
  28. $currentStep = 'object';
  29. $stepStatus = $this->session->stepStatus;
  30. $stepStatus = $stepStatus ? json_decode($stepStatus, true) : array();
  31. $stepList = $this->convert->getJiraStepList($jiraRelation);
  32. foreach($stepList as $step => $stepLabel)
  33. {
  34. if(!empty($stepStatus[$step]) && $stepStatus[$step] == 'done') $currentStep = $step;
  35. }
  36. $confirmedURL = $currentStep == 'user' ? inlink('initJiraUser', "method={$this->session->jiraMethod}&dbName={$this->session->jiraDB}") : inlink('mapJira2Zentao', "method={$this->session->jiraMethod}&dbName={$this->session->jiraDB}&step=$currentStep");
  37. $canceledURL = inlink('index', 'type=reset');
  38. $this->send(array('result' => 'success', 'load' => array('confirm' => $this->lang->convert->jira->restore, 'confirmed' => $confirmedURL, 'canceled' => $canceledURL)));
  39. }
  40. if($mode == 'reset')
  41. {
  42. unset($_SESSION['jiraDB']);
  43. unset($_SESSION['jiraMethod']);
  44. unset($_SESSION['jiraRelation']);
  45. unset($_SESSION['stepStatus']);
  46. unset($_SESSION['jiraUser']);
  47. }
  48. $this->view->title = $this->lang->convert->common;
  49. $this->display();
  50. }
  51. /**
  52. * 选择来源系统。
  53. * Select the source system.
  54. *
  55. * @access public
  56. * @return void
  57. */
  58. public function selectSource()
  59. {
  60. $this->view->title = $this->lang->convert->common . $this->lang->hyphen . $this->lang->convert->start;
  61. $this->display();
  62. }
  63. /**
  64. * 生成配置文件。
  65. * Set configs of converter.
  66. *
  67. * This is the extrance of every system. It will call the set function of corresponding module.
  68. *
  69. * @access public
  70. * @return void
  71. */
  72. public function setConfig()
  73. {
  74. if(!$this->post->source) return $this->sendError($this->lang->convert->mustSelectSource, 'back');
  75. list($sourceName, $version) = explode('_', $this->post->source);
  76. $setFunc = "set$sourceName";
  77. $this->view->title = $this->lang->convert->common . $this->lang->hyphen . $this->lang->convert->setting;
  78. $this->view->source = $sourceName;
  79. $this->view->version = $version;
  80. $this->view->setting = $this->fetch('convert', $setFunc, "version=$version");
  81. $this->display();
  82. }
  83. /**
  84. * 设置bugfree页面。
  85. * The setting page of bugfree.
  86. *
  87. * @param int $version
  88. * @access public
  89. * @return void
  90. */
  91. public function setBugFree($version)
  92. {
  93. $this->view->source = 'BugFree';
  94. $this->view->version = $version;
  95. $this->view->tablePrefix = $version > 1 ? 'bf_' : '';
  96. $this->view->dbName = $version > 1 ? 'bugfree2' : 'BugFree';
  97. $this->view->dbCharset = 'utf8';
  98. $this->display();
  99. }
  100. /**
  101. * 设置Redmine页面。
  102. * The setting page of Redmine.
  103. *
  104. * @param string $version
  105. * @access public
  106. * @return void
  107. */
  108. public function setRedmine($version)
  109. {
  110. $this->view->source = 'Redmine';
  111. $this->view->version = $version;
  112. $this->view->dbName = 'redmine';
  113. $this->view->dbCharset = 'utf8';
  114. $this->display();
  115. }
  116. /**
  117. * 检查配置。
  118. * Check config. Same as setConfig.
  119. *
  120. * @access public
  121. * @return void
  122. */
  123. public function checkConfig()
  124. {
  125. $checkFunc = 'check' . $this->post->source;
  126. $this->view->title = $this->lang->convert->common . $this->lang->hyphen . $this->lang->convert->checkConfig;
  127. $this->view->source = $this->post->source;
  128. $this->view->checkResult = $this->fetch('convert', $checkFunc, "version={$this->post->version}");
  129. $this->display();
  130. }
  131. /**
  132. * 检查bugfree设置。
  133. * Check settings of bugfree.
  134. *
  135. * @param int $version
  136. * @access public
  137. * @return void
  138. */
  139. public function checkBugFree($version)
  140. {
  141. helper::import('./converter/bugfree.php');
  142. $converter = new bugfreeConvertModel();
  143. /* Check it. */
  144. $checkInfo['db'] = $converter->connectDB();
  145. $checkInfo['path'] = $converter->checkPath();
  146. /* Compute the checking result. */
  147. $result = 'pass';
  148. if(!is_object($checkInfo['db']) || !$checkInfo['path']) $result = 'fail';
  149. /* Assign. */
  150. $this->view->version = $version;
  151. $this->view->source = 'bugfree';
  152. $this->view->result = $result;
  153. $this->view->checkInfo = $checkInfo;
  154. $this->display();
  155. }
  156. /**
  157. * 检查Redmine的设置。
  158. * Check settings of Redmine.
  159. *
  160. * @param int $version
  161. * @access public
  162. * @return void
  163. */
  164. public function checkRedmine($version)
  165. {
  166. helper::import('./converter/redmine.php');
  167. $converter = new redmineConvertModel();
  168. /* Check it. */
  169. $checkInfo['db'] = $converter->connectDB();
  170. $checkInfo['path'] = $converter->checkPath();
  171. $this->view->trackers = $this->dao->dbh($converter->sourceDBH)->select('id, name')->from('trackers')->fetchAll('id');
  172. $this->view->statuses = $this->dao->dbh($converter->sourceDBH)->select('id, name')->from('issue_statuses')->fetchAll('id');
  173. $this->view->pries = $this->dao->dbh($converter->sourceDBH)->select('id, name')->from('enumerations')->where('type')->eq('IssuePriority')->fetchAll('id');
  174. /* Compute the checking result. */
  175. $result = 'pass';
  176. if(!is_object($checkInfo['db']) || !$checkInfo['path']) $result = 'fail';
  177. $this->app->loadLang('bug');
  178. $this->app->loadLang('story');
  179. $this->app->loadLang('task');
  180. $this->view->aimTypeList['bug'] = 'bug';
  181. $this->view->aimTypeList['task'] = 'task';
  182. $this->view->aimTypeList['story'] = 'story';
  183. /* Assign. */
  184. $this->view->version = $version;
  185. $this->view->source = 'Redmine';
  186. $this->view->result = $result;
  187. $this->view->checkInfo = $checkInfo;
  188. $this->display();
  189. }
  190. /**
  191. * 执行数据导入。
  192. * Execute the converting.
  193. *
  194. * @access public
  195. * @return void
  196. */
  197. public function execute()
  198. {
  199. $convertFunc = 'convert' . $this->post->source;
  200. $this->view->title = $this->lang->convert->common . $this->lang->hyphen . $this->lang->convert->execute;
  201. $this->view->source = $this->post->source;
  202. $this->view->version = $this->post->version;
  203. $this->view->executeResult = $this->fetch('convert', $convertFunc, "version={$this->post->version}");
  204. $this->display();
  205. }
  206. /**
  207. * 导入bugfree。
  208. * Convert bugfree.
  209. *
  210. * @param int $version
  211. * @access public
  212. * @return void
  213. */
  214. public function convertBugFree($version)
  215. {
  216. helper::import('./converter/bugfree.php');
  217. helper::import("./converter/bugfree$version.php");
  218. $className = "bugfree{$version}ConvertModel";
  219. $converter = new $className();
  220. $this->view->version = $version;
  221. $this->view->result = $converter->execute($version);
  222. $this->view->info = bugfreeConvertModel::$info;
  223. $this->display();
  224. }
  225. /**
  226. * 导入redmine。
  227. * convert redmine.
  228. *
  229. * @param int $version
  230. * @access public
  231. * @return void
  232. */
  233. public function convertRedmine($version)
  234. {
  235. helper::import('./converter/redmine.php');
  236. helper::import("./converter/redmine$version.php");
  237. $redmine = new stdclass();
  238. $redmine->aimTypes = $this->post->aimTypes;
  239. $redmine->statusTypes['bug'] = $this->post->statusTypesOfBug;
  240. $redmine->statusTypes['story'] = $this->post->statusTypesOfStory;
  241. $redmine->statusTypes['task'] = $this->post->statusTypesOfTask;
  242. $redmine->priTypes['bug'] = $this->post->priTypesOfBug;
  243. $redmine->priTypes['story'] = $this->post->priTypesOfStory;
  244. $redmine->priTypes['task'] = $this->post->priTypesOfTask;
  245. $className = "redmine11ConvertModel";
  246. $converter = new $className($redmine);
  247. $this->view->version = $version;
  248. $this->view->result = $converter->execute($version);
  249. $this->view->info = redmineConvertModel::$info;
  250. $this->display();
  251. }
  252. /**
  253. * Jira数据导入提示。
  254. * Import jira notice.
  255. *
  256. * @param string $mehotd db|file
  257. * @access public
  258. * @return void
  259. * @param string $method
  260. */
  261. public function importJiraNotice($method = 'db')
  262. {
  263. if($this->server->request_method == 'POST')
  264. {
  265. $domain = $this->post->jiraDomain;
  266. if($domain && strpos($domain, 'http') === false) $domain = 'http://' . $domain;
  267. $jiraApi = array();
  268. $jiraApi['domain'] = $domain ? trim($domain, '/') : '';
  269. $jiraApi['admin'] = $domain ? $this->post->jiraAdmin : '';
  270. $jiraApi['token'] = $domain ? $this->post->jiraToken : '';
  271. $this->session->set('jiraApi', json_encode($jiraApi));
  272. $this->session->set('jiraDB', $this->post->dbName);
  273. $this->session->set('jiraMethod', $method);
  274. if($method == 'db')
  275. {
  276. $dbName = $this->post->dbName;
  277. if(!$dbName) return $this->send(array('result' => 'fail', 'message' => array('dbName' => sprintf($this->lang->error->notempty, $this->lang->convert->jira->database))));
  278. if(!$this->convert->dbExists($dbName)) return $this->send(array('result' => 'fail', 'message' => array('dbName' => $this->lang->convert->jira->invalidDB)));
  279. if(!$this->convert->tableExistsOfJira($dbName, 'nodeassociation')) return $this->send(array('result' => 'fail', 'message' => array('dbName' => $this->lang->convert->jira->invalidTable)));
  280. }
  281. elseif($method == 'api')
  282. {
  283. $domain = $jiraApi['domain'];
  284. if(!$domain) return $this->send(array('result' => 'fail', 'message' => array('dbName' => sprintf($this->lang->error->notempty, $this->lang->convert->jira->domain))));
  285. $this->convert->checkJiraApi();
  286. if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
  287. }
  288. else
  289. {
  290. if($domain)
  291. {
  292. $this->convert->checkJiraApi();
  293. if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
  294. }
  295. $this->convert->deleteJiraFile();
  296. $jiraFilePath = $this->app->getTmpRoot() . 'jirafile/';
  297. if(!is_readable($jiraFilePath) || !is_writable($jiraFilePath)) return $this->send(array('result' => 'fail', 'message' => sprintf($this->lang->convert->jira->notReadAndWrite, $jiraFilePath)));
  298. if(!file_exists($jiraFilePath . 'entities.xml')) return $this->send(array('result' => 'fail', 'message' => sprintf($this->lang->convert->jira->notExistEntities, $jiraFilePath . 'entities.xml')));
  299. /* 解析entities.xml文件。 */
  300. $this->convert->splitFile();
  301. }
  302. $link = $this->createLink('convert', 'mapJira2Zentao', "method={$method}&dbName={$this->post->dbName}");
  303. return $this->send(array('result' => 'success', 'load' => $link));
  304. }
  305. $this->view->title = $this->lang->convert->jira->method;
  306. $this->view->method = $method;
  307. $this->view->jiraApi = !empty($_SESSION['jiraApi']) ? json_decode($this->session->jiraApi) : array();
  308. $this->display();
  309. }
  310. /**
  311. * 获取下一步。
  312. * Get next key.
  313. *
  314. * @param array $array
  315. * @param string $currentKey
  316. * @access public
  317. * @return void
  318. */
  319. public function getNextKey($array, $currentKey)
  320. {
  321. $keys = array_keys($array);
  322. $currentIndex = array_search($currentKey, $keys);
  323. if($currentIndex !== false && isset($keys[$currentIndex + 1])) return $keys[$currentIndex + 1];
  324. return false;
  325. }
  326. /**
  327. * 获取上一步。
  328. * Get back key.
  329. *
  330. * @param array $array
  331. * @param string $currentKey
  332. * @access public
  333. * @return void
  334. */
  335. public function getBackKey($array, $currentKey)
  336. {
  337. $keys = array_keys($array);
  338. $currentIndex = array_search($currentKey, $keys);
  339. if($currentIndex !== false && isset($keys[$currentIndex - 1])) return $keys[$currentIndex - 1];
  340. return false;
  341. }
  342. /**
  343. * 将jira对象映射到zentao。
  344. * Map jira objects to zentao.
  345. *
  346. * @param string $method db|file
  347. * @param string $dbName
  348. * @param string $step
  349. * @access public
  350. * @return void
  351. */
  352. public function mapJira2Zentao($method = 'db', $dbName = '', $step = 'object')
  353. {
  354. $stepStatus = $this->session->stepStatus;
  355. $stepStatus = $stepStatus ? json_decode($stepStatus, true) : array();
  356. $jiraRelation = $this->session->jiraRelation;
  357. $jiraRelation = $jiraRelation ? json_decode($jiraRelation, true) : array();
  358. if($step != 'object' && empty($jiraRelation)) $this->locate(inlink('index'));
  359. if($_POST)
  360. {
  361. $this->convert->checkImportJira($step);
  362. if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
  363. foreach($_POST as $key => $value) $jiraRelation[$key] = $value;
  364. $this->session->set('jiraRelation', json_encode($jiraRelation));
  365. $stepStatus[$step] = 'done';
  366. $this->session->set('stepStatus', json_encode($stepStatus));
  367. /* 提交后要获取新的步骤列表。 */
  368. $stepList = $this->convert->getJiraStepList($jiraRelation);
  369. $nextSteps = $this->getNextKey($stepList, $step);
  370. $link = $step == 'relation' ? inlink('initJiraUser', "method={$method}&dbName={$dbName}") : inlink('mapJira2Zentao', "method={$method}&dbName={$dbName}&step={$nextSteps}");
  371. return $this->send(array('result' => 'success', 'load' => $link));
  372. }
  373. $this->loadModel('story');
  374. $this->loadModel('bug');
  375. $this->loadModel('task');
  376. $objectRelation = !empty($jiraRelation['zentaoObject']) && in_array($step, array_keys($jiraRelation['zentaoObject']));
  377. $resolutionList = $objectRelation ? $this->convert->getJiraData($method, 'resolution') : array();
  378. $statusList = $objectRelation ? $this->convert->getJiraStatusList($step) : array();
  379. $jiraFields = $objectRelation ? zget($this->convert->getJiraCustomField(), $step, array()) : array();
  380. $issueTypeList = $this->convert->getJiraTypeList();
  381. $linkTypeList = $step == 'relation' ? $this->convert->getJiraData($method, 'issuelinktype') : array();
  382. $stepList = $this->convert->getJiraStepList($jiraRelation, $issueTypeList);
  383. $backSteps = $this->getBackKey($stepList, $step);
  384. $jiraActions = $this->convert->getJiraWorkflowActions();
  385. $this->view->title = $this->lang->convert->jira->mapJira2Zentao;
  386. $this->view->method = $method;
  387. $this->view->step = $step;
  388. $this->view->dbName = $dbName;
  389. $this->view->stepStatus = $stepStatus;
  390. $this->view->stepList = $stepList;
  391. $this->view->jiraRelation = $jiraRelation;
  392. $this->view->issueTypeList = $issueTypeList;
  393. $this->view->zentaoObjects = $this->convert->getZentaoObjectList();
  394. $this->view->fieldList = $jiraFields;
  395. $this->view->statusList = $statusList;
  396. $this->view->jiraActions = $this->session->jiraMethod == 'api' ? zget($jiraActions, $step, array()) : $jiraActions;
  397. $this->view->resolutionList = $resolutionList;
  398. $this->view->defaultValue = $this->convert->getObjectDefaultValue($step);
  399. $this->view->linkTypeList = $linkTypeList;
  400. $this->view->backUrl = $backSteps ? inlink('mapJira2Zentao', "method={$method}&dbName={$dbName}&step={$backSteps}") : '';
  401. $this->display();
  402. }
  403. /**
  404. * 初始化jira用户。
  405. * Init jira user.
  406. *
  407. * @param string $method db|file
  408. * @param string $dbName
  409. * @access public
  410. * @return void
  411. */
  412. public function initJiraUser($method = 'db', $dbName = '')
  413. {
  414. $this->app->loadLang('user');
  415. $stepStatus = $this->session->stepStatus;
  416. $stepStatus = $stepStatus ? json_decode($stepStatus, true) : array();
  417. if($_POST)
  418. {
  419. $errors = array();
  420. if(!$this->post->password1) $errors['password1'][] = sprintf($this->lang->error->notempty, $this->lang->user->password);
  421. if(!$this->post->password2) $errors['password2'][] = sprintf($this->lang->error->notempty, $this->lang->user->password2);
  422. if($this->post->password1 && strlen(trim($this->post->password1)) < 6) $errors['password1'][] = $this->lang->convert->jira->passwordLess;
  423. if($this->post->password1 && $this->post->password2 && $this->post->password1 != $this->post->password2) $errors['password2'][] = $this->lang->convert->jira->passwordDifferent;
  424. if($errors) return $this->send(array('result' => 'fail', 'message' => $errors));
  425. $jiraUser['password'] = md5($this->post->password1);
  426. $jiraUser['group'] = $this->post->group;
  427. $jiraUser['mode'] = $this->post->mode;
  428. $this->session->set('jiraUser', $jiraUser);
  429. $stepStatus['user'] = 'done';
  430. $this->session->set('stepStatus', json_encode($stepStatus));
  431. return $this->send(array('result' => 'success', 'load' => inlink('importJira', "method={$method}")));
  432. }
  433. $jiraRelation = $this->session->jiraRelation;
  434. $jiraRelation = $jiraRelation ? json_decode($jiraRelation, true) : array();
  435. if(empty($jiraRelation)) $this->locate(inlink('index'));
  436. $stepList = $this->convert->getJiraStepList($jiraRelation);
  437. $backSteps = $this->getBackKey($stepList, 'user');
  438. $this->loadModel('admin');
  439. $maxUsers = 0;
  440. if(method_exists($this->admin, 'getIoncubeProperties'))
  441. {
  442. $ioncubeProperties = $this->admin->getIoncubeProperties();
  443. $maxUsers = zget($ioncubeProperties, 'user', 0);
  444. }
  445. $this->view->title = $this->lang->convert->jira->initJiraUser;
  446. $this->view->method = $method;
  447. $this->view->dbName = $dbName;
  448. $this->view->step = 'user';
  449. $this->view->stepList = $stepList;
  450. $this->view->stepStatus = $stepStatus;
  451. $this->view->backUrl = $backSteps ? inlink('mapJira2Zentao', "method={$method}&dbName={$dbName}&step={$backSteps}") : '';
  452. $this->view->groups = $this->loadModel('group')->getPairs();
  453. $this->view->maxUsers = $maxUsers;
  454. $this->display();
  455. }
  456. /**
  457. * 导入jira数据。
  458. * Import jira main logic.
  459. *
  460. * @param string $method db|file
  461. * @param string $mode show|import
  462. * @param string $type user|issue|project|attachment
  463. * @param int $lastID
  464. * @param bool $createTable
  465. * @access public
  466. * @return void
  467. */
  468. public function importJira($method = 'db', $mode = 'show', $type = 'user', $lastID = 0, $createTable = false)
  469. {
  470. set_time_limit(0);
  471. if($mode == 'import')
  472. {
  473. $result = $this->convert->importJiraData($type, $lastID, $createTable);
  474. if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
  475. if(!empty($result['finished'])) return $this->send(array('result' => 'finished', 'message' => $this->lang->convert->jira->importSuccessfully));
  476. $type = zget($this->lang->convert->jira->objectList, $result['type'], $result['type']);
  477. $response['result'] = 'unfinished';
  478. $response['type'] = $type;
  479. $response['count'] = $result['count'];
  480. $response['message'] = sprintf($this->lang->convert->jira->importResult, $type, $type, $result['count']);
  481. $response['next'] = inlink('importJira', "method={$method}&mode={$mode}&type={$result['type']}&lastID={$result['lastID']}");
  482. return $this->send($response);
  483. }
  484. $jiraRelation = $this->session->jiraRelation;
  485. $jiraRelation = $jiraRelation ? json_decode($jiraRelation, true) : array();
  486. if(empty($jiraRelation)) $this->locate(inlink('index'));
  487. $stepStatus = $this->session->stepStatus;
  488. $stepStatus = $stepStatus ? json_decode($stepStatus, true) : array();
  489. $stepList = $this->convert->getJiraStepList($jiraRelation);
  490. $backSteps = $this->getBackKey($stepList, 'user');
  491. $this->view->title = $this->lang->convert->jira->importJira;
  492. $this->view->method = $method;
  493. $this->view->dbName = $this->session->jiraDB;
  494. $this->view->step = 'confirme';
  495. $this->view->stepList = $stepList;
  496. $this->view->stepStatus = $stepStatus;
  497. $this->view->backUrl = $backSteps ? inlink('initJiraUser', "method={$method}&dbName={$this->session->jiraDB}") : '';
  498. $this->display();
  499. }
  500. /**
  501. * 接口调用快速导入jira数据。
  502. * Ajax quick import jira data.
  503. *
  504. * @access public
  505. * @return void
  506. */
  507. public function quickImportJiraData()
  508. {
  509. $status = 'success';
  510. try
  511. {
  512. $this->convert->quickImportJiraData();
  513. $status = dao::isError() ? 'fail' : 'success';
  514. }
  515. catch(Exception $e)
  516. {
  517. $status = 'fail';
  518. }
  519. $websiteUrl = isset($this->config->sanplexWebsite->url) ? $this->config->sanplexWebsite->url : '';
  520. if(!empty($websiteUrl))
  521. {
  522. $admins = $this->dao->select('admins')->from(TABLE_COMPANY)->fetch('admins');
  523. $currentDomain = $this->loadModel('user')->getCurrentDomain();
  524. $postData = array
  525. (
  526. 'domain' => $currentDomain,
  527. 'admin' => !empty($admins) ? current(explode(',', trim($admins, ','))) : '',
  528. 'status' => $status
  529. );
  530. common::http($websiteUrl . '/convert-importResult.json', $postData);
  531. }
  532. if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
  533. $this->send(array('result' => 'success'));
  534. }
  535. }