diff --git a/Makefile b/Makefile index b2a850775a..68f3d45019 100644 --- a/Makefile +++ b/Makefile @@ -52,9 +52,6 @@ tgz: mv zentaotest.zip zentaopms/tmp/extension mv zentaostory.zip zentaopms/tmp/extension mv zentaotask.zip zentaopms/tmp/extension - # copy dailyreminder to zentaopms. - svn export https://svn.cnezsoft.com/easysoft/trunk/zentaoext/dailyreminder - cp -rf dailyreminder/module zentaopms # notify.zip. mkdir zentaopms/www/data/notify/ wget http://192.168.1.99/release/notify.zip -O zentaopms/www/data/notify/notify.zip diff --git a/framework/helper.class.php b/framework/helper.class.php index 918e239990..fd5faa3ce7 100644 --- a/framework/helper.class.php +++ b/framework/helper.class.php @@ -541,7 +541,13 @@ function isLocalIP() */ function getWebRoot() { - return substr($_SERVER['SCRIPT_NAME'], 0, (strrpos($_SERVER['SCRIPT_NAME'], '/') + 1)); + $path = $_SERVER['SCRIPT_NAME']; + if(defined('IN_SHELL')) + { + $url = parse_url($_SERVER['argv'][1]); + $path = $url['path']; + } + return substr($path, 0, (strrpos($path, '/') + 1)); } /** diff --git a/module/report/config.php b/module/report/config.php new file mode 100644 index 0000000000..a82b84a83f --- /dev/null +++ b/module/report/config.php @@ -0,0 +1,5 @@ +report->dailyreminder->bug = true; +$config->report->dailyreminder->task = true; +$config->report->dailyreminder->todo = true; diff --git a/module/report/control.php b/module/report/control.php index bbe99e249e..4e80bcea11 100644 --- a/module/report/control.php +++ b/module/report/control.php @@ -119,4 +119,46 @@ class report extends control $this->view->submenu = 'staff'; $this->display(); } + + /** + * Send daily reminder mail. + * + * @access public + * @return void + */ + public function remind() + { + if($this->config->report->dailyreminder->bug) $bugs = $this->report->getUserBugs(); + if($this->config->report->dailyreminder->task) $tasks = $this->report->getUserTasks(); + if($this->config->report->dailyreminder->todo) $todos = $this->report->getUserTodos(); + + $reminder = array(); + if(!empty($bugs)) foreach($bugs as $user => $bug) $reminder[$user]->bugs = $bug; + if(!empty($tasks)) foreach($tasks as $user => $task) $reminder[$user]->tasks = $task; + if(!empty($todos)) foreach($todos as $user => $todo) $reminder[$user]->todos = $todo; + + $this->loadModel('mail'); + foreach($reminder as $user => $mail) + { + /* Get email content and title.*/ + $this->view->mail = $mail; + $mailContent = $this->parse('report', 'dailyreminder'); + $mailTitle = $this->lang->report->mailtitle->begin; + $mailTitle .= isset($mail->bugs) ? sprintf($this->lang->report->mailtitle->bug, count($mail->bugs)) : ''; + $mailTitle .= isset($mail->tasks) ? sprintf($this->lang->report->mailtitle->task, count($mail->tasks)) : ''; + $mailTitle .= isset($mail->todos) ? sprintf($this->lang->report->mailtitle->todo, count($mail->todos)) : ''; + $mailTitle = rtrim($mailTitle, ','); + $this->clear(); + + /* Send email.*/ + echo date('Y-m-d H:i:s') . " sending to $user, "; + $this->mail->send($user, $mailTitle, $mailContent, '', true); + if($this->mail->isError()) + { + echo "fail: \n" ; + a($this->mail->getError()); + } + echo "ok\n"; + } + } } diff --git a/module/report/lang/en.php b/module/report/lang/en.php index 20159ad61f..3972bebe63 100644 --- a/module/report/lang/en.php +++ b/module/report/lang/en.php @@ -70,4 +70,15 @@ $lang->report->manhourTotal = "Manhour Total"; $lang->report->bugTotal = "%s Bugs"; $lang->report->unplanned = 'unplanned'; +/* daily reminder. */ +$lang->report->idAB = 'ID'; +$lang->report->bugTitle = 'Bug Title'; +$lang->report->taskName = 'Task Name'; +$lang->report->todoName = 'Todo Name'; + +$lang->report->mailtitle->begin = 'Notice : Your'; +$lang->report->mailtitle->bug = " Bugs(%s),"; +$lang->report->mailtitle->task = " Tasks(%s),"; +$lang->report->mailtitle->todo = " Todos(%s),"; + $lang->report->proVersion = 'Try pro version for more!'; diff --git a/module/report/lang/zh-cn.php b/module/report/lang/zh-cn.php index 371396bbf7..8d835e57ba 100644 --- a/module/report/lang/zh-cn.php +++ b/module/report/lang/zh-cn.php @@ -70,4 +70,15 @@ $lang->report->manhourTotal = "总工时"; $lang->report->bugTotal = "共%s个Bug"; $lang->report->unplanned = '未计划'; +/* daily reminder. */ +$lang->report->idAB = 'ID'; +$lang->report->bugTitle = 'Bug标题'; +$lang->report->taskName = '任务名称'; +$lang->report->todoName = 'Todo名称'; + +$lang->report->mailtitle->begin = '提醒:您有'; +$lang->report->mailtitle->bug = " Bugs(%s),"; +$lang->report->mailtitle->task = " 任务(%s),"; +$lang->report->mailtitle->todo = " Todos(%s),"; + $lang->report->proVersion = '更多精彩,尽在专业版!'; diff --git a/module/report/model.php b/module/report/model.php index fae54c3332..b14116885a 100644 --- a/module/report/model.php +++ b/module/report/model.php @@ -470,4 +470,93 @@ EOT; unset($assign['closed']); return $assign; } + + /** + * Get System URL. + * + * @access public + * @return void + */ + public function getSysURL() + { + /* Ger URL when run in shell. */ + if(defined('IN_SHELL')) + { + $url = parse_url(trim($this->server->argv[1])); + $port = (empty($url['port']) or $url['port'] == 80) ? '' : $url['port']; + $host = empty($port) ? $url['host'] : $url['host'] . ':' . $port; + return $url['scheme'] . '://' . $host; + } + else + { + return common::getSysURL(); + } + } + + /** + * Get user bugs. + * + * @access public + * @return void + */ + public function getUserBugs() + { + $bugs = $this->dao->select('t1.id, t1.title, t2.account as user') + ->from(TABLE_BUG)->alias('t1') + ->leftJoin(TABLE_USER)->alias('t2') + ->on('t1.assignedTo = t2.account') + ->where('t1.assignedTo')->ne('') + ->andWhere('t1.assignedTo')->ne('closed') + ->andWhere('t1.deleted')->eq(0) + ->andWhere('t2.deleted')->eq(0) + ->fetchGroup('user'); + return $bugs; + } + + /** + * Get user tasks. + * + * @access public + * @return void + */ + public function getUserTasks() + { + $tasks = $this->dao->select('t1.id, t1.name, t2.account as user') + ->from(TABLE_TASK)->alias('t1') + ->leftJoin(TABLE_USER)->alias('t2') + ->on('t1.assignedTo = t2.account') + ->where('t1.assignedTo')->ne('') + ->andWhere('t1.deleted')->eq(0) + ->andWhere('t2.deleted')->eq(0) + ->andWhere('t1.status')->in('wait, doing') + ->fetchGroup('user'); + + return $tasks; + } + + /** + * Get user todos. + * + * @access public + * @return void + */ + public function getUserTodos() + { + $stmt = $this->dao->select('t1.*, t2.account as user') + ->from(TABLE_TODO)->alias('t1') + ->leftJoin(TABLE_USER)->alias('t2') + ->on('t1.account = t2.account') + ->where('t1.status')->eq('wait') + ->orWhere('t1.status')->eq('doing') + ->query(); + + $todos = array(); + while($todo = $stmt->fetch()) + { + if($todo->type == 'task') $todo->name = $this->dao->findById($todo->idvalue)->from(TABLE_TASK)->fetch('name'); + if($todo->type == 'bug') $todo->name = $this->dao->findById($todo->idvalue)->from(TABLE_BUG)->fetch('title'); + $todos[$todo->user][] = $todo; + } + return $todos; + } } diff --git a/module/report/view/dailyreminder.html.php b/module/report/view/dailyreminder.html.php new file mode 100755 index 0000000000..8f88e09497 --- /dev/null +++ b/module/report/view/dailyreminder.html.php @@ -0,0 +1,71 @@ +report->getSysURL();?> + +bugs)):?> + + + + + + bugs as $bug):?> + + + + + +
report->idAB;?>report->bugTitle;?>
id;?> + createLink('bug', 'view', "bugID=$bug->id"); + if($config->requestType == 'GET' and strpos($link, 'ztcli') !== false) $link = str_replace($this->server->php_self, $config->webRoot, $link); + echo html::a($url . $link, $bug->title); + ?> +
+ + +tasks)):?> + + + + + + tasks as $task):?> + + + + + +
report->idAB;?>report->taskName;?>
id;?> + createLink('task', 'view', "taskID=$task->id"); + if($config->requestType == 'GET' and strpos($link, 'ztcli') !== false) $link = str_replace($this->server->php_self, $config->webRoot, $link); + echo html::a($url . $link, $task->name); + ?> +
+ + +todos)):?> + + + + + + todos as $todo):?> + + + + + +
report->idAB;?>report->todoName;?>
id;?> + createLink('todo', 'view', "todoID=$todo->id"); + if($config->requestType == 'GET' and strpos($link, 'ztcli') !== false) $link = str_replace($this->server->php_self, $config->webRoot, $link); + echo html::a($url . $link, $todo->name); + ?> +
+