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


PHP Comment::createFromArray方法代码示例

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


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

示例1: execute

 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $this->logSection('repeater', 'Getting repeaters');
     $repeaters = Doctrine_Query::create()->from('TicketRepeater r')->addWhere('r.isClosed = ?', false)->addWhere('r.next_start <= ?', date('Y-m-d H:i:s'))->leftJoin('r.Responsibles')->leftJoin('r.Observers')->execute();
     $this->logSection('repeater', sprintf('Found %d possibly not resheduled repeaters', count($repeaters)));
     foreach ($repeaters as $repeater) {
         $this->logSection('repeater', sprintf('Processing repeater #%d', $repeater->getId()));
         $ticketNextPlannedStartTime = strtotime($repeater->getNextStart());
         $createBeforeDays = $repeater->getCreateBeforeDays();
         $isTicketAlreadyCreated = Doctrine_Query::create()->from('Ticket t')->addWhere('t.planned_start = ?', $repeater->getNextStart())->count() === 1;
         $createBeforeDaysFulfilled = strtotime('-' . $createBeforeDays . ' days', $ticketNextPlannedStartTime) <= time();
         if (!$isTicketAlreadyCreated and $createBeforeDaysFulfilled) {
             $this->logSection('repeater', sprintf('Creating ticket for #%d', $repeater->getId()));
             $deadlineDays = $repeater->getDeadlineDays();
             $deadlineTime = strtotime('+' . $deadlineDays . ' days', $ticketNextPlannedStartTime);
             $ticket = Ticket::createFromArray(['name' => $repeater->getName(), 'company_id' => $repeater->getCompanyId(), 'category_id' => $repeater->getCategoryId(), 'description' => $repeater->getDescription(), 'planned_start' => date('Y-m-d H:i:s', $ticketNextPlannedStartTime), 'deadline' => date('Y-m-d H:i:s', $deadlineTime), 'repeater_id' => $repeater->getId(), 'created_by' => $repeater->getInitiatorId()]);
             $ticket->save();
             $ticket->link('Responsibles', array_map(function ($user) {
                 return $user['id'];
             }, $repeater->getResponsibles()->toArray()));
             $ticket->link('Observers', array_map(function ($user) {
                 return $user['id'];
             }, $repeater->getObservers()->toArray()));
             $ticket->save();
             $this->logSection('repeater', sprintf('Created ticket #%d for repeater #%d', $ticket->getId(), $repeater->getId()));
             $comment = Comment::createFromArray(['skip_notification' => true, 'ticket_id' => $ticket->getId(), 'text' => 'Заявка относится к регламентной работе ##' . $repeater->getId(), 'created_by' => $repeater->getInitiatorId()]);
             $comment->save();
             $nextStartTime = strtotime('+' . $repeater->getRepeatedEveryDays() . ' days', strtotime($repeater->getNextStart()));
             $repeater->setNextStart(date('Y-m-d H:i:s', $nextStartTime));
             $repeater->save();
             $this->logSection('repeater', sprintf('Sheduled repeater #%d to %s', $repeater->getId(), $repeater->getNextStart()));
         }
     }
 }
开发者ID:vik0803,项目名称:helpdesk,代码行数:35,代码来源:ticketRepeaterTask.class.php

示例2: create

 function create()
 {
     $comment = Comment::createFromArray('Comment', $this->parameters['comment']);
     if ($comment->save()) {
         $this->redirect('/posts/' . $comment->post_id);
         return;
     }
     $this->vars['comment'] = $comment;
 }
开发者ID:jpic,项目名称:Jetfuel,代码行数:9,代码来源:CommentsController.php

示例3: executePost

 public function executePost(sfWebRequest $request)
 {
     // drop self sent emails
     if ($request->getParameter('sender') === 'support@helpdesk.f1lab.ru') {
         die('dropped self sent email');
     }
     $result = [];
     // get sender user
     $from = Doctrine_Query::create()->from('sfGuardUser u')->addWhere('u.email_address = ?', strtolower($request->getParameter('sender')))->fetchOne();
     $ticket = null;
     $subject = $request->getParameter('subject');
     // search for ticket id in subject and search for such ticket in db
     if (preg_match('/\\[F1LAB\\-HLPDSK\\-([\\d]+)\\]/', $subject, $mathed)) {
         $result[] = 'matched magic subject';
         $ticket = Doctrine_Query::create()->from('Ticket t')->addWhere('t.id = ?', $mathed[1])->limit(1)->fetchOne();
         if ($ticket) {
             $result[] = 'ticket found';
             // ticket found, reopen if needed and add comment
             $comment = Comment::createFromArray(['ticket_id' => $ticket->getId(), 'text' => $request->getParameter('body-plain'), 'created_by' => $from ? $from->getId() : 82]);
             if ($ticket->getIsClosed()) {
                 $comment->setChangedTicketStateTo('opened');
                 $ticket->setIsClosed(false)->save();
             }
             $comment->save();
             $result[] = 'comment created';
         }
     }
     // no such ticket found, creating
     if (!$ticket) {
         $result[] = 'no such ticket';
         $ticket = Ticket::createFromArray(['name' => $subject, 'company_id' => $from && $from->getGroups() && $from->getGroups()->getFirst() ? $from->getGroups()->getFirst() : 1, 'description' => str_replace("\n", "<br/>\n", $request->getParameter('body-plain')), 'created_by' => $from ? $from->getId() : 82, 'real_sender' => $from ? null : $request->getParameter('sender')]);
         $ticket->save();
         $result[] = 'ticket created';
     }
     // adding files to ticket
     if (count($_FILES)) {
         $destination = sfConfig::get('sf_upload_dir') . DIRECTORY_SEPARATOR . 'comment-attachments' . DIRECTORY_SEPARATOR;
         foreach ($_FILES as $file) {
             $nameParts = explode('.', $file['name']);
             $extension = array_pop($nameParts);
             $newName = uniqid() . '.' . $extension;
             if (move_uploaded_file($file['tmp_name'], $destination . $newName)) {
                 $comment = Comment::createFromArray(['ticket_id' => $ticket->getId(), 'text' => 'Добавлен файл из письма: ' . $file['name'], 'attachment' => $newName, 'created_by' => $from ? $from->getId() : 82, 'skip_notification' => true]);
                 $comment->save();
                 $result[] = 'comment with file created';
             }
         }
     }
     die(print_r($result, 1));
 }
开发者ID:vik0803,项目名称:helpdesk,代码行数:50,代码来源:actions.class.php

示例4: preDqlDelete

 public function preDqlDelete($event)
 {
     $parameters = $event->getQuery()->getParams()['where'];
     $ticketId = array_shift($parameters);
     $usersIds = $parameters;
     foreach ($usersIds as $userId) {
         $observer = Doctrine_Core::getTable('sfGuardUser')->find($userId);
         // add comment to ticket
         if ($observer) {
             $comment = Comment::createFromArray(['ticket_id' => $ticketId, 'created_by' => sfContext::getInstance()->getUser()->getGuardUser()->getId(), 'text' => 'Убрал из списка наблюдателей ' . $observer, 'skip_notification' => true]);
             $comment->save();
         }
     }
 }
开发者ID:vik0803,项目名称:helpdesk,代码行数:14,代码来源:RefTicketObserver.class.php

示例5: executeApply

 public function executeApply(sfWebRequest $request)
 {
     $ticket = Doctrine_Core::getTable('Ticket')->findOneById($request->getParameter('id'));
     $this->forward404Unless($ticket);
     $applier = Comment::createFromArray(['changed_ticket_state_to' => 'applied', 'ticket_id' => $ticket->getId(), 'text' => 'Принял в работу']);
     $applier->save() and $this->redirect($request->getReferer());
 }
开发者ID:vik0803,项目名称:helpdesk,代码行数:7,代码来源:actions.class.php

示例6: preDelete

 public function preDelete($event)
 {
     $responsible = Doctrine_Core::getTable('sfGuardUser')->find($this->getUserId());
     $comment = Comment::createFromArray(['ticket_id' => $this->getTicketId(), 'created_by' => sfContext::getInstance()->getUser()->getGuardUser()->getId(), 'text' => 'Убрал из списка ответственных ' . $responsible, 'skip_notification' => true]);
     $comment->save();
 }
开发者ID:vik0803,项目名称:helpdesk,代码行数:6,代码来源:RefTicketResponsible.class.php

示例7: executeIAmNotResponsibleForThis

 public function executeIAmNotResponsibleForThis(sfWebRequest $request)
 {
     $this->getResponse()->setHeaderOnly(true);
     $this->forward404Unless($this->getUser()->isAuthenticated());
     $json = file_get_contents('php://input');
     $data = json_decode($json, true);
     $this->forward404Unless($json and $data and $data['ticketId'] and $data['reason']);
     $ref = Doctrine_Query::create()->from('RefTicketResponsible ref')->addWhere('ref.ticket_id = ?', $data['ticketId'])->addWhere('ref.user_id = ?', $this->getUser()->getGuardUser()->getId())->limit(1)->fetchOne();
     if ($ref) {
         $comment = Comment::createFromArray(['ticket_id' => $data['ticketId'], 'text' => 'Пользователь @' . $this->getUser()->getGuardUser()->getUsername() . ' отказался от выполнения заявки по причине: ' . $data['reason']]);
         $ref->delete();
         $comment->save();
     }
     return sfView::NONE;
 }
开发者ID:vik0803,项目名称:helpdesk,代码行数:15,代码来源:actions.class.php


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