本文整理汇总了PHP中Reminder::setAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Reminder::setAttributes方法的具体用法?PHP Reminder::setAttributes怎么用?PHP Reminder::setAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reminder
的用法示例。
在下文中一共展示了Reminder::setAttributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* Create a new reminder
*
* @param void
* @return null
*/
function add()
{
$this->wireframe->print_button = false;
$parent = ProjectObjects::findById($this->request->getId('parent_id'));
if (!instance_of($parent, 'ProjectObject')) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
$project = $parent->getProject();
if (!instance_of($project, 'Project')) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
$assignees = $parent->getAssignees();
$subscribers = $parent->getSubscribers();
$commenters = Comments::findCommenters($parent, $this->logged_user);
$reminder_data = $this->request->post('reminder');
if (!is_array($reminder_data)) {
$who = 'user';
if (is_foreachable($assignees)) {
$who = 'assignees';
} elseif (is_foreachable($subscribers)) {
$who = 'subscribers';
} elseif (is_foreachable($commenters)) {
$who = 'commenters';
}
// if
$reminder_data = array('who' => $who);
}
// if
$this->smarty->assign(array('parent' => $parent, 'assignees' => $assignees, 'subscribers' => $subscribers, 'commenters' => $commenters, 'project_users' => ProjectUsers::findUserIdsByProject($project), 'reminder_data' => $reminder_data));
if ($this->request->isSubmitted()) {
$send_to_users = null;
switch ($reminder_data['who']) {
case 'assignees':
$send_to_users = $assignees;
break;
case 'subscribers':
$send_to_users = $subscribers;
break;
case 'commenters':
$send_to_users = $commenters;
break;
case 'user':
$user_id = (int) array_var($reminder_data, 'user_id');
if ($user_id) {
$user = Users::findById($user_id);
if (instance_of($user, 'User')) {
$send_to_users = array($user);
}
// if
}
// if
break;
}
// switch
// Do reminder
if (is_foreachable($send_to_users)) {
$comment = trim(array_var($reminder_data, 'comment'));
if ($comment) {
require_once SMARTY_PATH . '/plugins/modifier.clickable.php';
require_once ANGIE_PATH . '/classes/htmlpurifier/init.php';
$comment = strip_tags(prepare_html($comment, true));
// make sure we have clean text
$comment = nl2br(smarty_modifier_clickable($comment));
// preserve breaklines and convert links
}
// if
db_begin_work();
$reminders_sent = array();
foreach ($send_to_users as $user) {
$reminder = new Reminder();
$reminder->setAttributes(array('user_id' => $user->getId(), 'object_id' => $parent->getId(), 'comment' => $comment));
$reminder->setCreatedBy($this->logged_user);
$save = $reminder->save();
if ($save && !is_error($save)) {
$reminders_sent[] = $user->getDisplayName();
ApplicationMailer::send($user, 'system/reminder', array('reminded_by_name' => $this->logged_user->getDisplayName(), 'reminded_by_url' => $this->logged_user->getViewUrl(), 'object_name' => $parent->getName(), 'object_url' => $parent->getViewUrl(), 'object_type' => strtolower($parent->getType()), 'comment_body' => $comment, 'project_name' => $project->getName(), 'project_url' => $project->getOverviewUrl()), $parent);
}
// if
}
// foreach
db_commit();
$message = lang('Users reminded: :users', array('users' => implode(', ', $reminders_sent)));
if ($this->request->get('skip_layout')) {
$this->renderText($message);
} else {
flash_success($message);
$this->redirectToUrl($parent->getViewUrl());
}
// if
// No reminders
} else {
if ($this->request->get('skip_layout')) {
//.........这里部分代码省略.........
示例2: system_handle_on_daily
//.........这里部分代码省略.........
$result = mysql_query($sql, $link);
while ($entry = mysql_fetch_assoc($result)) {
list($name, ) = explode('-', $entry['name']);
$name = trim($name);
$pages[$name] = $entry['id'];
}
$current_time = time();
$users = Users::findAll();
foreach ($users as $user) {
$flag = 1;
$message = '';
$name = $user->getName();
if (array_key_exists($name, $pages)) {
$page = new Page($pages[$name]);
if ($page) {
$sql = "select id from healingcrystals_project_objects where parent_id='" . $pages[$name] . "' and parent_type='Page' and type='Task' and completed_on is null and priority is null and created_on>='" . date('Y-m-d H:i:s', $current_time - 1 * 24 * 60 * 60) . "' order by created_on";
$result = mysql_query($sql, $link);
if (mysql_num_rows($result)) {
$show_task_list = true;
} else {
$show_task_list = false;
}
if (date('N') == '1' || $show_task_list) {
$message .= '<style>
.odd {background-color:#ffffff;}
.even{background-color:#eeeeee;}
</style>
<table>
<tr>
<td colspan="3">Task List: ' . $name . '</td>
</tr>
<tr>
<td align="center">Priority</td>
<td>Task</td>
<td> </td>
</tr>';
$tasks = Tasks::findOpenByObject($page);
foreach ($tasks as $task) {
$message .= '
<tr class="' . ($flag % 2 === 1 ? 'odd' : 'even') . '">
<td valign="top" align="center"><img src="http://projects.ffbh.org/public/' . $priorities_images[$task->getPriority()] . '"/></td>
<td valign="top">' . $task->getName() . '</td>
<td valign="top"><a href="' . $task->getViewUrl() . '">View</a></td>
</tr>';
$flag++;
}
$message .= '
</table>';
$subject = 'projects: healingcrystals.com Task list';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'From: FFBH Reminder <auto@ffbh.org>' . "\r\n";
mail($user->getEmail(), $subject, $message, $headers);
}
}
}
}
$sql = "select po.id, cast(if( pom.recurring_period_type='D', DATE_ADD(po.due_on, interval pom.recurring_period day), if(pom.recurring_period_type='W', DATE_ADD(po.due_on, interval pom.recurring_period week), if(pom.recurring_period_type='M', DATE_ADD(po.due_on, interval pom.recurring_period month), null ) ) ) as Date) as next_due_date, cast(DATE_ADD(now(), interval 0 day) as Date) as cur_date, cast(if(isnull(pom.email_reminder_unit), null, if( pom.email_reminder_unit='D', DATE_ADD(po.due_on, interval pom.email_reminder_period day), if(pom.email_reminder_unit='W', DATE_ADD(po.due_on, interval pom.email_reminder_period week), if(pom.email_reminder_unit='M', DATE_ADD(po.due_on, interval pom.email_reminder_period month), null ) ) )\t) as Date) as reminder_date from healingcrystals_project_objects po inner join healingcrystals_project_object_misc pom on po.id=pom.object_id where po.type='Task' and po.due_on is not null and po.due_on<=now() and po.completed_on is null and pom.recurring_period_condition='after_due_date' and if(pom.recurring_end_date is not null and pom.recurring_end_date!='0000-00-00', if(pom.recurring_end_date>=now(), 1, 0), 1)=1 having next_due_date=cur_date";
$result = mysql_query($sql);
while ($entry = mysql_fetch_assoc($result)) {
$task = new Task($entry['id']);
$action = $task->complete(new AnonymousUser('auto', 'auto@projects.ffbh.org'));
if (!empty($entry['reminder_date']) && $entry['cur_date'] == $entry['reminder_date']) {
$sql02 = "select id from " . TABLE_PREFIX . "project_objects where type='Task' and project_id='" . $task->getProjectId() . "' and milestone_id='" . $task->getMilestoneId() . "' and parent_id='" . $task->getParentId() . "' order by id desc limit 0, 1";
$result02 = mysql_query($sql02);
if (mysql_num_rows($result02)) {
$info = mysql_fetch_assoc($result02);
$recurring_task = new Task($info['id']);
$parent = $recurring_task->getParent();
$project = $recurring_task->getProject();
$assignees = $recurring_task->getAssignees();
$priorities = array(PRIORITY_HIGHEST => lang('Highest'), PRIORITY_HIGH => lang('High'), PRIORITY_NORMAL => lang('Normal'), PRIORITY_LOW => lang('Low'), PRIORITY_LOWEST => lang('Lowest'), PRIORITY_ONGOING => lang('Ongoing'), PRIORITY_HOLD => lang('Hold'));
$due_date = $task->getDueOn();
$due_date = date('m/d/Y', strtotime($due_date));
$reminder_date = date('m/d/Y', strtotime($entry['reminder_date']));
foreach ($assignees as $assignee) {
$assignees_string .= $assignee->getDisplayName() . ', ';
}
if (!empty($assignees_string)) {
$assignees_string = substr($assignees_string, 0, -2);
} else {
$assignees_string = '--';
}
$reminders_sent = array();
foreach ($assignees as $user) {
//if ($user->getEmail()=='anuj@focusindia.com'){
$reminder = new Reminder();
$reminder->setAttributes(array('user_id' => $user->getId(), 'object_id' => $recurring_task->getId(), 'comment' => $comment));
$save = $reminder->save();
if ($save && !is_error($save)) {
$reminders_sent[] = $user->getDisplayName();
ApplicationMailer::send($user, 'system/reminder', array('reminded_by_name' => 'AutoReminder', 'reminded_by_url' => '', 'object_name' => $recurring_task->getName(), 'object_url' => $recurring_task->getViewUrl(), 'object_type' => strtolower($recurring_task->getType()), 'comment_body' => $comment, 'project_name' => $project->getName(), 'project_url' => $project->getOverviewUrl(), 'ticket_name' => $parent->getName(), 'ticket_url' => $parent->getViewUrl(), 'object_priority' => $priorities[(string) $recurring_task->getPriority()], 'object_due_date' => $due_date, 'object_reminder_date_n_time' => $reminder_date, 'object_assignees' => $assignees_string, 'task_mark_complete_url' => $recurring_task->getCompleteUrl() . '&auto=1', 'display_status_for_complete_url' => $recurring_task->is_action_request_task() ? '' : 'none'), $recurring_task);
}
//}
}
}
}
}
mysql_close($link);
}
示例3: system_handle_on_hourly
/**
* Do hourly tasks
*
* @param void
* @return null
*/
function system_handle_on_hourly()
{
$cache =& Cache::instance();
if (instance_of($cache->backend, 'CacheBackend')) {
$cache->backend->cleanup();
}
// if
//BOF:mod
$time_current = $time_end = time() - 4 * 60 * 60;
$time_start = $time_end - 60 * 60;
$comment = 'Auto Reminder';
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
mysql_select_db(DB_NAME);
//BOF:mod 20120816
/*
//EOF:mod 20120816
$query = "select distinct a.object_id from
healingcrystals_project_object_misc a
inner join healingcrystals_project_objects b on a.object_id=b.id where
b.type='Task' and
b.state='" . STATE_VISIBLE . "' and
(b.completed_on is null or b.completed_on='') and
a.reminder_date is not null and
a.reminder_date<>'0000-00-00' and
a.auto_email_status='1' and
((a.reminder_date between '" . date('Y-m-d H:i:s', $time_start) . "' and '" . date('Y-m-d H:i:s', $time_end) . "')
or (a.recurring_period_type = 'D' and recurring_period = '1' and recurring_period_condition = 'after_due_date' and (recurring_end_date > '".date('Y-m-d')."' or recurring_end_date = '0000-00-00') and date_format(a.reminder_date,'%H:%i:%s') between '" . date('H:i:s', $time_start) . "' and '" . date('H:i:s', $time_end) . "'))";
mysql_query("insert into testing (date_added, content) values (now(), '" . mysql_real_escape_string($query) . "')");
//BOF:mod 20120816
*/
/*
$query = "select distinct a.object_id, a.reminder_date from
healingcrystals_project_object_misc a
inner join healingcrystals_project_objects b on a.object_id=b.id where
b.type='Task' and
b.state='" . STATE_VISIBLE . "' and
(b.completed_on is null or b.completed_on='') and
a.reminder_date is not null and
a.reminder_date<>'0000-00-00' and
a.auto_email_status='1' and
((a.reminder_date between '" . date('Y-m-d H:i:s', $time_start) . "' and '" . date('Y-m-d H:i:s', $time_end) . "')
or (a.recurring_period_type = 'D' and recurring_period = '1' and recurring_period_condition = 'after_due_date' and (recurring_end_date > '".date('Y-m-d')."' or recurring_end_date = '0000-00-00') and date_format(a.reminder_date,'%H:%i:%s') between '" . date('H:i:s', $time_start) . "' and '" . date('H:i:s', $time_end) . "'))";
*/
$query = "select distinct \n\t\t\t\ta.object_id, \n\t\t\t\tcast(if(a.email_reminder_unit='D', \n\t\t\t\t\tconcat(DATE_SUB(b.due_on, interval a.email_reminder_period day), ' ', a.email_reminder_time), \n\t\t\t\t\tif(a.email_reminder_unit='W', \n\t\t\t\t\t\tconcat(DATE_SUB(b.due_on, interval a.email_reminder_period week), ' ', a.email_reminder_time), \n\t\t\t\t\t\tif(a.email_reminder_unit='M', \n\t\t\t\t\t\t\tconcat(DATE_SUB(b.due_on, interval a.email_reminder_period month), ' ', a.email_reminder_time), \n\t\t\t\t\t\t\tnull\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t) as datetime) as reminder \n\t\t\t from \n\t\t\t\thealingcrystals_project_object_misc a \n\t\t\t\tinner join healingcrystals_project_objects b on a.object_id=b.id \n\t\t\t where \n\t\t\t\tb.type='Task' and \n\t\t\t\tb.state='" . STATE_VISIBLE . "' and \n\t\t\t\t(b.completed_on is null or b.completed_on='') and \n\t\t\t\ta.auto_email_status='1' and \n\t\t\t\ta.email_reminder_unit is not null and \n\t\t\t\tb.due_on is not null and \n\t\t\t\t(a.snooze_datetime is null or a.snooze_datetime='0000-00-00 00:00:00' or a.snooze_datetime<'" . date('Y-m-d H:i:s', $time_current) . "') and \n\t\t\t\tcast(if(a.email_reminder_unit='D', \n\t\t\t\t\tconcat(DATE_SUB(b.due_on, interval a.email_reminder_period day), ' ', a.email_reminder_time), \n\t\t\t\t\tif(a.email_reminder_unit='W', \n\t\t\t\t\t\tconcat(DATE_SUB(b.due_on, interval a.email_reminder_period week), ' ', a.email_reminder_time), \n\t\t\t\t\t\tif(a.email_reminder_unit='M', \n\t\t\t\t\t\t\tconcat(DATE_SUB(b.due_on, interval a.email_reminder_period month), ' ', a.email_reminder_time), \n\t\t\t\t\t\t\tnull\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t) as datetime) between '" . date('Y-m-d H:i:s', $time_start) . "' and '" . date('Y-m-d H:i:s', $time_end) . "'\n\t\t\t ";
//EOF:mod 20120816
$result = mysql_query($query, $link);
while ($entry = mysql_fetch_assoc($result)) {
$task_obj = new Task($entry['object_id']);
$parent = $task_obj->getParent();
$project = $task_obj->getProject();
$assignees = $task_obj->getAssignees();
//BOF:mod 20120816
$priorities = array(PRIORITY_HIGHEST => lang('Highest'), PRIORITY_HIGH => lang('High'), PRIORITY_NORMAL => lang('Normal'), PRIORITY_LOW => lang('Low'), PRIORITY_LOWEST => lang('Lowest'), PRIORITY_ONGOING => lang('Ongoing'), PRIORITY_HOLD => lang('Hold'));
$due_date = $task_obj->getDueOn();
if (!empty($due_date) && $due_date != '0000-00-00') {
$due_date = date('m/d/Y', strtotime($due_date));
} else {
$due_date = '--';
}
$reminder_date = $entry['reminder'];
//$reminder_date = $entry['reminder_date'];
if (!empty($reminder_date) && $reminder_date != '0000-00-00 00:00:00') {
$reminder_date = date('m/d/Y H:i', strtotime($reminder_date));
} else {
$reminder_date = '--';
}
foreach ($assignees as $assignee) {
$assignees_string .= $assignee->getDisplayName() . ', ';
}
if (!empty($assignees_string)) {
$assignees_string = substr($assignees_string, 0, -2);
} else {
$assignees_string = '--';
}
//EOF:mod 20120816
$reminders_sent = array();
foreach ($assignees as $user) {
//if ($user->getEmail()=='anuj@focusindia.com'){
$reminder = new Reminder();
$reminder->setAttributes(array('user_id' => $user->getId(), 'object_id' => $task_obj->getId(), 'comment' => $comment));
//$reminder->setCreatedBy($this->logged_user);
$save = $reminder->save();
if ($save && !is_error($save)) {
$reminders_sent[] = $user->getDisplayName();
ApplicationMailer::send($user, 'system/reminder', array('reminded_by_name' => 'AutoReminder', 'reminded_by_url' => '', 'object_name' => $task_obj->getName(), 'object_url' => $task_obj->getViewUrl(), 'object_type' => strtolower($task_obj->getType()), 'comment_body' => $comment, 'project_name' => $project->getName(), 'project_url' => $project->getOverviewUrl(), 'ticket_name' => $parent->getName(), 'ticket_url' => $parent->getViewUrl(), 'object_priority' => $priorities[(string) $task_obj->getPriority()], 'object_due_date' => $due_date, 'object_reminder_date_n_time' => $reminder_date, 'object_assignees' => $assignees_string, 'task_mark_complete_url' => $task_obj->getCompleteUrl() . '&auto=1', 'display_status_for_complete_url' => ''), $task_obj);
}
// if
//}
}
// foreach
}
mysql_close($link);
//EOF:mod
}