当前位置: 首页>>代码示例>>PHP>>正文


PHP Backend::add_notification方法代码示例

本文整理汇总了PHP中Backend::add_notification方法的典型用法代码示例。如果您正苦于以下问题:PHP Backend::add_notification方法的具体用法?PHP Backend::add_notification怎么用?PHP Backend::add_notification使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Backend的用法示例。


在下文中一共展示了Backend::add_notification方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create_task


//.........这里部分代码省略.........
     #array_unshift($sql_values, $task_id);
     $sql_keys_string = join(', ', $sql_keys);
     $sql_placeholder = $db->fill_placeholders($sql_values);
     $result = $db->Query("INSERT INTO {tasks}\n                                ({$sql_keys_string})\n                         VALUES ({$sql_placeholder})", $sql_values);
     $task_id = $db->Insert_ID();
     Backend::upload_links($task_id);
     // create tags
     if (isset($args['tags'])) {
         $tagList = explode(';', $args['tags']);
         $tagList = array_map('strip_tags', $tagList);
         $tagList = array_map('trim', $tagList);
         $tagList = array_unique($tagList);
         # avoid duplicates for inputs like: "tag1;tag1" or "tag1; tag1<p></p>"
         foreach ($tagList as $tag) {
             if ($tag == '') {
                 continue;
             }
             # old tag feature
             #$result2 = $db->Query("INSERT INTO {tags} (task_id, tag) VALUES (?,?)",array($task_id,$tag));
             # new tag feature. let's do it in 2 steps, it is getting too complicated to make it cross database compatible, drawback is possible (rare) race condition (use transaction?)
             $res = $db->Query("SELECT tag_id FROM {list_tag} WHERE (project_id=0 OR project_id=?) AND tag_name LIKE ? ORDER BY project_id", array($proj->id, $tag));
             if ($t = $db->FetchRow($res)) {
                 $tag_id = $t['tag_id'];
             } else {
                 if ($proj->prefs['freetagging'] == 1) {
                     # add to taglist of the project
                     $db->Query("INSERT INTO {list_tag} (project_id,tag_name) VALUES (?,?)", array($proj->id, $tag));
                     $tag_id = $db->Insert_ID();
                 } else {
                     continue;
                 }
             }
             $db->Query("INSERT INTO {task_tag}(task_id,tag_id) VALUES(?,?)", array($task_id, $tag_id));
         }
     }
     // Log the assignments and send notifications to the assignees
     if (isset($args['rassigned_to']) && is_array($args['rassigned_to'])) {
         // Convert assigned_to and store them in the 'assigned' table
         foreach ($args['rassigned_to'] as $val) {
             $db->Replace('{assigned}', array('user_id' => $val, 'task_id' => $task_id), array('user_id', 'task_id'));
         }
         // Log to task history
         Flyspray::logEvent($task_id, 14, implode(' ', $args['rassigned_to']));
         // Notify the new assignees what happened.  This obviously won't happen if the task is now assigned to no-one.
         $notify->Create(NOTIFY_NEW_ASSIGNEE, $task_id, null, $notify->SpecificAddresses($args['rassigned_to']), NOTIFY_BOTH, $proj->prefs['lang_code']);
     }
     // Log that the task was opened
     Flyspray::logEvent($task_id, 1);
     $result = $db->Query('SELECT  *
                             FROM  {list_category}
                            WHERE  category_id = ?', array($args['product_category']));
     $cat_details = $db->FetchRow($result);
     // We need to figure out who is the category owner for this task
     if (!empty($cat_details['category_owner'])) {
         $owner = $cat_details['category_owner'];
     } else {
         // check parent categories
         $result = $db->Query('SELECT  *
                                 FROM  {list_category}
                                WHERE  lft < ? AND rgt > ? AND project_id  = ?
                             ORDER BY  lft DESC', array($cat_details['lft'], $cat_details['rgt'], $cat_details['project_id']));
         while ($row = $db->FetchRow($result)) {
             // If there's a parent category owner, send to them
             if (!empty($row['category_owner'])) {
                 $owner = $row['category_owner'];
                 break;
             }
         }
     }
     if (!isset($owner)) {
         $owner = $proj->prefs['default_cat_owner'];
     }
     if ($owner) {
         if ($proj->prefs['auto_assign'] && ($args['item_status'] == STATUS_UNCONFIRMED || $args['item_status'] == STATUS_NEW)) {
             Backend::add_to_assignees($owner, $task_id, true);
         }
         Backend::add_notification($owner, $task_id, true);
     }
     // Reminder for due_date field
     if (!empty($sql_args['due_date'])) {
         Backend::add_reminder($task_id, L('defaultreminder') . "\n\n" . CreateURL('details', $task_id), 2 * 24 * 60 * 60, time());
     }
     // Create the Notification
     if (Backend::upload_files($task_id)) {
         $notify->Create(NOTIFY_TASK_OPENED, $task_id, 'files', null, NOTIFY_BOTH, $proj->prefs['lang_code']);
     } else {
         $notify->Create(NOTIFY_TASK_OPENED, $task_id, null, null, NOTIFY_BOTH, $proj->prefs['lang_code']);
     }
     // If the reporter wanted to be added to the notification list
     if (isset($args['notifyme']) && $args['notifyme'] == '1' && $user->id != $owner) {
         Backend::add_notification($user->id, $task_id, true);
     }
     if ($user->isAnon()) {
         $anonuser = array();
         $anonuser[$email] = array('recipient' => $args['anon_email'], 'lang' => $fs->prefs['lang_code']);
         $recipients = array($anonuser);
         $notify->Create(NOTIFY_ANON_TASK, $task_id, $token, $recipients, NOTIFY_EMAIL, $proj->prefs['lang_code']);
     }
     return array($task_id, $token);
 }
开发者ID:canneverbe,项目名称:flyspray,代码行数:101,代码来源:class.backend.php

示例2: create_task


//.........这里部分代码省略.........
     $sql_values[] = $plugins;
     // Token for anonymous users
     $token = '';
     if ($user->isAnon()) {
         $token = md5(uniqid(mt_rand(), true));
         $sql_params[] = 'task_token';
         $sql_values[] = $token;
     }
     $sql_params[] = 'anon_email';
     $sql_values[] = array_get($args, 'anon_email', '');
     $sql_cols = array_merge(array('date_opened', 'last_edited_time', 'project_id', 'item_summary', 'detailed_desc', 'opened_by', 'percent_complete'), $sql_params);
     $db->x->autoExecute('{tasks}', array_combine($sql_cols, $sql_values));
     $task_id = $db->lastInsertID();
     // [RED] Add task to redundancy table (opened by, last_changed_time)
     $db->x->autoExecute('{redundant}', array('task_id' => $task_id, 'last_changed_time' => time(), 'opened_by_real_name' => $user->infos['real_name'], 'opened_by_user_name' => $user->infos['user_name'], 'last_changed_by_real_name' => $user->infos['real_name'], 'last_changed_by_user_name' => $user->infos['user_name']));
     // Per project task ID
     $prefix_id = $db->x->GetOne('SELECT MAX(prefix_id)+1 FROM {tasks} WHERE project_id = ?', null, $proj->id);
     $db->x->execParam('UPDATE {tasks} SET prefix_id = ? WHERE task_id = ?', array($prefix_id, $task_id));
     // Now the custom fields
     if (count($proj->fields)) {
         $stmt = $db->x->autoPrepare('{field_values}', array('task_id', 'field_id', 'field_value'));
         foreach ($proj->fields as $field) {
             $stmt->execute(array($task_id, $field->id, $field->read(array_get($args, 'field' . $field->id, 0))));
         }
         $stmt->free();
     }
     $assignees = array();
     if (isset($args['assigned_to'])) {
         // Prepare assignee list
         $assignees = explode(';', trim($args['assigned_to']));
         $assignees = array_map(array('Flyspray', 'UserNameToId'), $assignees);
         $assignees = array_filter($assignees, create_function('$x', 'return ($x > 0);'));
         // Log the assignments and send notifications to the assignees
         if (count($assignees)) {
             // Convert assigned_to and store them in the 'assigned' table
             foreach ($assignees as $val) {
                 $fields = array('user_id' => array('value' => $val, 'key' => true), 'task_id' => array('value' => $task_id, 'key' => true));
                 $db->Replace('{assigned}', $fields);
             }
             Flyspray::logEvent($task_id, 14, implode(' ', $assignees));
             // Notify the new assignees what happened.  This obviously won't happen if the task is now assigned to no-one.
             Notifications::send($assignees, ADDRESS_USER, NOTIFY_NEW_ASSIGNEE, array('task_id' => $task_id));
         }
     }
     // Log that the task was opened
     Flyspray::logEvent($task_id, 1);
     // find category owners
     $owners = array();
     foreach ($proj->fields as $field) {
         if ($field->prefs['list_type'] != LIST_CATEGORY) {
             continue;
         }
         $cat = $db->x->getRow('SELECT  *
                              FROM  {list_category}
                             WHERE  category_id = ?', null, array_get($args, 'field' . $field->id, 0));
         if ($cat['category_owner']) {
             $owners[] = $cat['category_owner'];
         } else {
             // check parent categories
             $sql = $db->x->getAll('SELECT  *
                                  FROM  {list_category}
                                 WHERE  lft < ? AND rgt > ? AND list_id  = ?
                              ORDER BY  lft DESC', null, array($cat['lft'], $cat['rgt'], $cat['list_id']));
             foreach ($sql as $row) {
                 // If there's a parent category owner, send to them
                 if ($row['category_owner']) {
                     $owners[] = $row['category_owner'];
                     break;
                 }
             }
         }
     }
     // last try...
     if (!count($owners) && $proj->prefs['default_cat_owner']) {
         $owners[] = $proj->prefs['default_cat_owner'];
     }
     if (count($owners)) {
         foreach ($owners as $owner) {
             if ($proj->prefs['auto_assign'] && !in_array($owner, $assignees)) {
                 Backend::add_to_assignees($owner, $task_id, true);
             }
             Backend::add_notification($owner, $task_id, true);
         }
     }
     // Create the Notification
     if (Backend::upload_files($task_id)) {
         Notifications::send($task_id, ADDRESS_TASK, NOTIFY_TASK_OPENED, array('files' => true));
     } else {
         Notifications::send($task_id, ADDRESS_TASK, NOTIFY_TASK_OPENED);
     }
     // If the reporter wanted to be added to the notification list
     if (isset($args['notifyme']) && $args['notifyme'] == '1' && !in_array($user->id, $owners)) {
         Backend::add_notification($user->id, $task_id, true);
     }
     // this is relaxed, if the anonymous email is not valid, just dont bother..
     if ($user->isAnon() && Flyspray::check_email($args['anon_email'])) {
         Notifications::send($args['anon_email'], ADDRESS_EMAIL, NOTIFY_ANON_TASK, array('task_id' => $task_id, 'token' => $token));
     }
     return array($task_id, $token, true);
 }
开发者ID:negram,项目名称:flyspray,代码行数:101,代码来源:class.backend.php

示例3: switch

 case 'task.bulkupdate':
     # TODO check if the user has the right to do each action on each task id he send with the form!
     # TODO check if tasks have open subtasks before closing
     # TODO SQL Transactions with rollback function if something went wrong in the middle of bulk action
     $massopsenabled = 0;
     # 20150305 disabled for 1.0 release until proper checks are done
     if ($massopsenabled == 1) {
         // TODO: Log events in a later version.
         if (Post::val('updateselectedtasks') == "true") {
             //process quick actions
             switch (Post::val('bulk_quick_action')) {
                 case 'bulk_take_ownership':
                     Backend::assign_to_me(Post::val('user_id'), Post::val('ids'));
                     break;
                 case 'bulk_start_watching':
                     Backend::add_notification(Post::val('user_id'), Post::val('ids'));
                     break;
                 case 'bulk_stop_watching':
                     Backend::remove_notification(Post::val('user_id'), Post::val('ids'));
                     break;
             }
             //Process the tasks.
             $columns = array();
             $values = array();
             //determine the tasks properties that have been modified.
             if (!Post::val('bulk_status') == 0) {
                 array_push($columns, 'item_status');
                 array_push($values, Post::val('bulk_status'));
             }
             if (!Post::val('bulk_percent_complete') == 0) {
                 array_push($columns, 'percent_complete');
开发者ID:kandran,项目名称:flyspray,代码行数:31,代码来源:modify.inc.php

示例4: elseif

     break;
     // ##################
     // admin request
     // ##################
 // ##################
 // admin request
 // ##################
 case 'requestclose':
 case 'requestreopen':
     if ($action == 'requestclose') {
         Flyspray::AdminRequest(1, $proj->id, $task['task_id'], $user->id, Post::val('reason_given'));
         Flyspray::logEvent($task['task_id'], 20, Post::val('reason_given'));
     } elseif ($action == 'requestreopen') {
         Flyspray::AdminRequest(2, $proj->id, $task['task_id'], $user->id, Post::val('reason_given'));
         Flyspray::logEvent($task['task_id'], 21, Post::val('reason_given'));
         Backend::add_notification($user->id, $task['task_id']);
     }
     // Now, get the project managers' details for this project
     $sql = $db->Query("SELECT  u.user_id\n                             FROM  {users} u\n                        LEFT JOIN  {users_in_groups} uig ON u.user_id = uig.user_id\n                        LEFT JOIN  {groups} g ON uig.group_id = g.group_id\n                            WHERE  g.project_id = ? AND g.manage_project = '1'", array($proj->id));
     $pms = $db->fetchCol($sql);
     if (count($pms)) {
         // Call the functions to create the address arrays, and send notifications
         $notify->Create(NOTIFY_PM_REQUEST, $task['task_id'], null, $notify->SpecificAddresses($pms));
     }
     $_SESSION['SUCCESS'] = L('adminrequestmade');
     break;
     // ##################
     // denying a PM request
     // ##################
 // ##################
 // denying a PM request
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:31,代码来源:modify.inc.php

示例5: create_task


//.........这里部分代码省略.........
     foreach ($param_names as $param_name) {
         if (isset($args[$param_name])) {
             $sql_params[] = $param_name;
             $sql_values[] = $args[$param_name];
         }
     }
     // Process the due_date
     if (isset($args['due_date']) && ($due_date = $args['due_date']) || ($due_date = 0)) {
         $due_date = Flyspray::strtotime($due_date);
     }
     $sql_params[] = 'mark_private';
     $sql_values[] = intval($user->perms('manage_project') && isset($args['mark_private']) && $args['mark_private'] == '1');
     $sql_params[] = 'due_date';
     $sql_values[] = $due_date;
     $sql_params[] = 'closure_comment';
     $sql_values[] = '';
     // Token for anonymous users
     $token = '';
     if ($user->isAnon()) {
         $token = md5(function_exists('openssl_random_pseudo_bytes') ? openssl_random_pseudo_bytes(32) : uniqid(mt_rand(), true));
         $sql_params[] = 'task_token';
         $sql_values[] = $token;
         $sql_params[] = 'anon_email';
         $sql_values[] = $args['anon_email'];
     } else {
         $sql_params[] = 'anon_email';
         $sql_values[] = '';
     }
     $sql_params = join(', ', $sql_params);
     // +1 for the task_id column;
     $sql_placeholder = $db->fill_placeholders($sql_values, 1);
     $result = $db->Query('SELECT  MAX(task_id)+1
                             FROM  {tasks}');
     $task_id = $db->FetchOne($result);
     $task_id = $task_id ? $task_id : 1;
     //now, $task_id is always the first element of $sql_values
     array_unshift($sql_values, $task_id);
     $result = $db->Query("INSERT INTO  {tasks}\n                                 ( task_id, date_opened, last_edited_time,\n                                   project_id, item_summary,\n                                   detailed_desc, opened_by,\n                                   percent_complete, {$sql_params} )\n                         VALUES  ({$sql_placeholder})", $sql_values);
     // Log the assignments and send notifications to the assignees
     if (isset($args['rassigned_to']) && is_array($args['rassigned_to'])) {
         // Convert assigned_to and store them in the 'assigned' table
         foreach ($args['rassigned_to'] as $val) {
             $db->Replace('{assigned}', array('user_id' => $val, 'task_id' => $task_id), array('user_id', 'task_id'));
         }
         // Log to task history
         Flyspray::logEvent($task_id, 14, implode(' ', $args['rassigned_to']));
         // Notify the new assignees what happened.  This obviously won't happen if the task is now assigned to no-one.
         $notify->Create(NOTIFY_NEW_ASSIGNEE, $task_id, null, $notify->SpecificAddresses($args['rassigned_to']));
     }
     // Log that the task was opened
     Flyspray::logEvent($task_id, 1);
     $result = $db->Query('SELECT  *
                             FROM  {list_category}
                            WHERE  category_id = ?', array($args['product_category']));
     $cat_details = $db->FetchRow($result);
     // We need to figure out who is the category owner for this task
     if (!empty($cat_details['category_owner'])) {
         $owner = $cat_details['category_owner'];
     } else {
         // check parent categories
         $result = $db->Query('SELECT  *
                                 FROM  {list_category}
                                WHERE  lft < ? AND rgt > ? AND project_id  = ?
                             ORDER BY  lft DESC', array($cat_details['lft'], $cat_details['rgt'], $cat_details['project_id']));
         while ($row = $db->FetchRow($result)) {
             // If there's a parent category owner, send to them
             if (!empty($row['category_owner'])) {
                 $owner = $row['category_owner'];
                 break;
             }
         }
     }
     if (!isset($owner)) {
         $owner = $proj->prefs['default_cat_owner'];
     }
     if ($owner) {
         if ($proj->prefs['auto_assign'] && ($args['item_status'] == STATUS_UNCONFIRMED || $args['item_status'] == STATUS_NEW)) {
             Backend::add_to_assignees($owner, $task_id, true);
         }
         Backend::add_notification($owner, $task_id, true);
     }
     // Reminder for due_date field
     if ($due_date) {
         Backend::add_reminder($task_id, L('defaultreminder') . "\n\n" . CreateURL('details', $task_id), 2 * 24 * 60 * 60, time());
     }
     // Create the Notification
     if (Backend::upload_files($task_id)) {
         $notify->Create(NOTIFY_TASK_OPENED, $task_id, 'files');
     } else {
         $notify->Create(NOTIFY_TASK_OPENED, $task_id);
     }
     // If the reporter wanted to be added to the notification list
     if (isset($args['notifyme']) && $args['notifyme'] == '1' && $user->id != $owner) {
         Backend::add_notification($user->id, $task_id, true);
     }
     if ($user->isAnon()) {
         $notify->Create(NOTIFY_ANON_TASK, $task_id, $token, $args['anon_email'], NOTIFY_EMAIL);
     }
     return array($task_id, $token);
 }
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:101,代码来源:class.backend.php

示例6: action_requestclose

 function action_requestclose($task)
 {
     global $proj, $user, $db;
     if (Post::val('action') == 'requestclose') {
         Flyspray::AdminRequest(1, $proj->id, $task['task_id'], $user->id, Post::val('reason_given'));
         Flyspray::logEvent($task['task_id'], 20, Post::val('reason_given'));
     } else {
         Flyspray::AdminRequest(2, $proj->id, $task['task_id'], $user->id, Post::val('reason_given'));
         Flyspray::logEvent($task['task_id'], 21, Post::val('reason_given'));
         Backend::add_notification($user->id, $task['task_id']);
     }
     // Now, get the project managers' details for this project
     $pms = $db->x->GetCol('SELECT  u.user_id
                           FROM  {users} u
                      LEFT JOIN  {users_in_groups} uig ON u.user_id = uig.user_id
                      LEFT JOIN  {groups} g ON uig.group_id = g.group_id
                          WHERE  g.project_id = ? AND g.manage_project = 1', null, $proj->id);
     if (count($pms)) {
         Notifications::send($pms, ADDRESS_USER, NOTIFY_PM_REQUEST, array('task_id' => $task['task_id']));
     }
     return array(SUBMIT_OK, L('adminrequestmade'));
 }
开发者ID:negram,项目名称:flyspray,代码行数:22,代码来源:details.php


注:本文中的Backend::add_notification方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。