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


PHP Notifier::newOtherComment方法代码示例

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


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

示例1: add

 /**
  * Add comment
  * 
  * Through this controller only logged users can post (no anonymous comments here)
  *
  * @param void
  * @return null
  */
 function add()
 {
     $this->setTemplate('add_comment');
     $object_id = get_id('object_id');
     $object_manager = array_var($_GET, 'object_manager');
     if (!is_valid_function_name($object_manager)) {
         flash_error(lang('invalid request'));
         $this->redirectToUrl(active_project()->getOverviewUrl());
     }
     // if
     $object = get_object_by_manager_and_id($object_id, $object_manager);
     if (!$object instanceof ProjectDataObject || !$object->canComment(logged_user())) {
         flash_error(lang('no access permissions'));
         $this->redirectToUrl(active_project()->getOverviewUrl());
     }
     // if
     $comment = new Comment();
     $comment_data = array_var($_POST, 'comment');
     if (!is_array($comment_data)) {
         $comment_data = array('text' => '', 'is_private' => config_option('default_private', false));
         // array
     }
     // if
     tpl_assign('comment_form_object', $object);
     tpl_assign('comment', $comment);
     tpl_assign('comment_data', $comment_data);
     if (is_array($comment_data)) {
         try {
             try {
                 $attached_files = ProjectFiles::handleHelperUploads(active_project());
             } catch (Exception $e) {
                 $attached_files = null;
             }
             // try
             $comment->setFromAttributes($comment_data);
             $comment->setRelObjectId($object_id);
             $comment->setRelObjectManager($object_manager);
             if (!logged_user()->isMemberOfOwnerCompany()) {
                 $comment->setIsPrivate(false);
             }
             // if
             if ($object instanceof ProjectMessage || $object instanceof ProjectFile) {
                 if ($object->getIsPrivate()) {
                     $comment->setIsPrivate(true);
                 }
                 // if
             }
             // if
             DB::beginWork();
             $comment->save();
             if (is_array($attached_files)) {
                 foreach ($attached_files as $attached_file) {
                     $comment->attachFile($attached_file);
                 }
                 // foreach
             }
             // if
             ApplicationLogs::createLog($comment, active_project(), ApplicationLogs::ACTION_ADD);
             // Subscribe user to object (if $object is subscribible)
             if ($object->isSubscribable()) {
                 if (!$object->isSubscriber(logged_user())) {
                     $object->subscribeUser(logged_user());
                 }
                 // if
             }
             // if
             DB::commit();
             // Try to send notification on comments other than Messages (messages already managed by subscription)
             if (!$comment->getObject() instanceof ProjectMessage) {
                 // Try to send notifications but don't break submission in case of an error
                 // define all the users to be notified - here all project users, from all companies.
                 // Restrictions if comment is private is taken into account in newOtherComment()
                 try {
                     $notify_people = array();
                     $project_companies = active_project()->getCompanies();
                     foreach ($project_companies as $project_company) {
                         $company_users = $project_company->getUsersOnProject(active_project());
                         if (is_array($company_users)) {
                             foreach ($company_users as $company_user) {
                                 if (array_var($comment_data, 'notify_company_' . $project_company->getId()) == 'checked' || array_var($comment_data, 'notify_user_' . $company_user->getId())) {
                                     $notify_people[] = $company_user;
                                 }
                                 // if
                             }
                             // if
                         }
                         // if
                     }
                     // if
                     Notifier::newOtherComment($comment, $notify_people);
                     // send notification email...
                 } catch (Exception $e) {
//.........这里部分代码省略.........
开发者ID:federosky,项目名称:ProjectPier-Core,代码行数:101,代码来源:CommentController.class.php


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