1<?php 2 3class Cron_dummy_action extends DokuWiki_Action_Plugin { 4 public function getPluginName() { 5 return 'bez'; 6 } 7 8 public static function id() { 9 $args = func_get_args(); 10 array_unshift($args, 'bez'); 11 12 return implode(':', $args); 13 } 14 15 public static function url() { 16 $args = func_get_args(); 17 18 $id = call_user_func_array('Cron_dummy_action::id', $args); 19 return DOKU_URL . 'doku.php?id=' . $id; 20 21 22 } 23}; 24 25$dummy_action = new Cron_dummy_action(); 26$model = new \dokuwiki\plugin\bez\mdl\Model($auth, $dw_user, $dummy_action, $conf); 27 28function send_inactive_issue() { 29 global $model; 30 31 $threads = $model->threadFactory->get_all(array( 32 'last_activity_date' => array('<=', date('c', strtotime('-26 days'))), 33 'state' => 'opened' 34 )); 35 36 foreach ($threads as $thread) { 37 //send reminder once a month 38 $day_of_issue_last_activity = date('d', strtotime($thread->last_activity_date)); 39 if ($day_of_issue_last_activity == date('d')) { 40 //send message to all 41 $thread->mail_notify_issue_inactive($thread->get_participants('subscribent')); 42 } 43 } 44} 45 46function send_one_day_task_reminder() { 47 global $model; 48 49 $tasks = $model->taskFactory->get_all(array( 50 'plan_date' => date('Y-m-d', strtotime('+1 day')), 51 'state' => 'opened' 52 )); 53 54 foreach ($tasks as $task) { 55 $task->mail_notify_remind($task->get_participants('subscribent')); 56 } 57} 58 59//function send_weekly_message($simulate=true) { 60// global $conf, $auth; 61// 62// //$helper = new helper_plugin_bez(); 63// 64// //email => array('user' => array('issues' => array(), 'tasks' => array())) 65// $msg = array(); 66// $output = array(); 67// 68// try { 69// $isso = new Issues(); 70// $tasko = new Tasks(); 71// } catch (Exception $e) { 72// echo $e->getMessage().': '.$e->getFile(); 73// } 74// 75// $issues = $isso->cron_get_unsolved(); 76// 77// foreach ($issues as $issue) { 78// $key = $issue['coordinator']; 79// if (!isset($msg[$key])) 80// $msg[$key] = array('issues' => array(), 'coming_tasks' => array(), 81// 'outdated_tasks' => array()); 82// 83// $msg[$key]['issues'][] = $issue; 84// } 85// 86// $coming_tasks_all = $tasko->cron_get_coming_tasks(); 87// 88// foreach ($coming_tasks_all as $task) { 89// $key = $task['executor']; 90// if (!isset($msg[$key])) 91// $msg[$key] = array('issues' => array(), 'coming_tasks' => array(), 92// 'outdated_tasks' => array()); 93// 94// $msg[$key]['coming_tasks'][] = $task; 95// } 96// 97// $outdated_tasks_all = $tasko->cron_get_outdated_tasks(); 98// 99// foreach ($outdated_tasks_all as $task) { 100// $key = $task['executor']; 101// if (!isset($msg[$key])) 102// $msg[$key] = array('issues' => array(), 'coming_tasks' => array(), 103// 'outdated_tasks' => array()); 104// 105// $msg[$key]['outdated_tasks'][] = $task; 106// } 107// 108// //outdated_tasks, coming_tasks, open_tasks 109// 110// 111// foreach ($msg as $user => $data) { 112// $udata = $auth->getUserData($user); 113// 114// $his_issues = $data['issues']; 115// $outdated_tasks = $data['outdated_tasks']; 116// $coming_tasks = $data['coming_tasks']; 117// 118// 119// if (count($his_issues) + count($outdated_tasks) + count($coming_tasks) == 0) 120// continue; 121// 122// $to = $udata['name'].' <'.$udata['mail'].'>'; 123// 124// ob_start(); 125// include 'tpl/weekly-message.php'; 126// $body = ob_get_clean(); 127// 128// $mailer = new \dokuwiki\plugin\bez\meta\Mailer(); 129// $rep = array(); 130// $mailer->setBody('', $rep, NULL, $body, false); 131// 132// $mailer->to($to); 133// $subject = 'Nadchodzące zadania'; 134// $mailer->subject($subject); 135// 136// if ($simulate === false) { 137// $send = $mailer->send(); 138// } 139// $output[] = array($to, $subject, $body, array()); 140// } 141// 142// return $output; 143//} 144