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


PHP Reminder::setCreatedBy方法代码示例

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


在下文中一共展示了Reminder::setCreatedBy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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')) {
//.........这里部分代码省略.........
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:101,代码来源:RemindersController.class.php


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