Beispiel #1
0
 private function __construct()
 {
     $this->tablesManager = TablesManager::getInstance();
     $this->fieldsManager = FieldsManager::getInstance();
     $this->metaManager = MetaManager::getInstance();
     $this->relationsManager = RelationsManager::getInstance();
     $this->itemsManager = ItemsManager::getInstance();
     $this->commentsManager = CommentsManager::getInstance();
     $this->tablesMeta = [];
 }
 protected function handle_submit()
 {
     $form = $this->get_form();
     CommentsManager::edit_comment($this->id_comment, $form->get_value('message'));
     AppContext::get_response()->redirect(CommentsUrlBuilder::comment_added($this->topic_path, $this->id_comment));
 }
Beispiel #3
0
 /**
  * Фунция должна восстанавливать данные о настройках таблиы по реальной структуре таблицы, пока не работает в полном объеме
  * @param type $table имя табилцы
  */
 public function updateSettings($table)
 {
     $fields = $this->get($table)->getFields();
     $node = $this->load($table);
     if ($node->dry()) {
         return false;
     }
     $is_commentable = CommentsManager::getInstance()->hasComments($table);
     unset($this->tables[$table]);
     $node['is_commentable'] = $is_commentable;
     $node['is_sortable'] = isset($fields['sort']);
     $node['is_moderated'] = isset($fields['moderation']);
     $node['is_priority'] = isset($fields['priority']);
     $node['is_tree'] = isset($fields['pid']);
     $node->save();
 }
Beispiel #4
0
 public static function getComments($params)
 {
     $id = $params['id'];
     $commentsManager = new CommentsManager();
     return $commentsManager->getComments($id);
 }
 private function save()
 {
     $now = new Date();
     $pm_recipients_list = array();
     $send_pm = true;
     $versions = array_reverse($this->config->get_versions_fix(), true);
     $status = $this->form->get_value('status')->get_raw_value();
     if (count($versions)) {
         if (!$this->form->field_is_disabled('fixed_in')) {
             $fixed_in = $this->form->get_value('fixed_in')->get_raw_value() ? $this->form->get_value('fixed_in')->get_raw_value() : 0;
             if ($fixed_in != $this->bug->get_fixed_in()) {
                 //Bug history update
                 BugtrackerService::add_history(array('bug_id' => $this->bug->get_id(), 'updater_id' => $this->current_user->get_id(), 'update_date' => $now->get_timestamp(), 'updated_field' => 'fixed_in', 'old_value' => $this->bug->get_fixed_in(), 'new_value' => $fixed_in));
                 $this->bug->set_fixed_in($fixed_in);
             }
         } else {
             if (in_array($status, array(Bug::NEW_BUG, Bug::REJECTED))) {
                 $this->bug->set_fixed_in(0);
             }
         }
     }
     if (!$this->form->field_is_disabled('assigned_to')) {
         $assigned_to = $this->form->get_value('assigned_to');
         $assigned_to_id = UserService::user_exists("WHERE display_name = :display_name", array('display_name' => $assigned_to));
         if ($this->bug->get_assigned_to_id()) {
             $old_user_assigned_id = UserService::user_exists("WHERE user_id = :user_id", array('user_id' => $this->bug->get_assigned_to_id()));
             $old_user_assigned = !empty($old_user_assigned_id) ? UserService::get_user($old_user_assigned_id) : 0;
         } else {
             $old_user_assigned = 0;
         }
         $new_user_assigned = !empty($assigned_to) && !empty($assigned_to_id) ? UserService::get_user($assigned_to_id) : 0;
         $new_assigned_to_id = !empty($new_user_assigned) ? $new_user_assigned->get_id() : 0;
         if ($new_assigned_to_id != $this->bug->get_assigned_to_id()) {
             //Bug history update
             BugtrackerService::add_history(array('bug_id' => $this->bug->get_id(), 'updater_id' => $this->current_user->get_id(), 'update_date' => $now->get_timestamp(), 'updated_field' => 'assigned_to_id', 'old_value' => $old_user_assigned ? $old_user_assigned->get_display_name() : $this->lang['notice.no_one'], 'new_value' => $new_user_assigned ? $new_user_assigned->get_display_name() : $this->lang['notice.no_one']));
             //Bug update
             $this->bug->set_assigned_to_id($new_assigned_to_id);
             //The PM will only be sent to the assigned user
             if ($new_assigned_to_id != $this->current_user->get_id()) {
                 $pm_recipients_list[] = $new_assigned_to_id;
             } else {
                 $send_pm = false;
             }
         }
     }
     if ($status != $this->bug->get_status()) {
         //Bug history update
         BugtrackerService::add_history(array('bug_id' => $this->bug->get_id(), 'updater_id' => $this->current_user->get_id(), 'update_date' => $now->get_timestamp(), 'updated_field' => 'status', 'old_value' => $this->bug->get_status(), 'new_value' => $status));
         //Bug update
         $this->bug->set_status($status);
         if ($this->bug->is_fixed() || $this->bug->is_rejected()) {
             $this->bug->set_fix_date($now);
         } else {
             $this->bug->set_fix_date(0);
         }
     }
     BugtrackerService::update($this->bug);
     Feed::clear_cache('bugtracker');
     switch ($status) {
         case Bug::IN_PROGRESS:
             $is_pm_enabled = $this->config->are_pm_in_progress_enabled();
             break;
         case Bug::PENDING:
             $is_pm_enabled = $this->config->are_pm_pending_enabled();
             break;
         case Bug::ASSIGNED:
             $is_pm_enabled = $this->config->are_pm_assign_enabled();
             break;
         case Bug::FIXED:
             $is_pm_enabled = $this->config->are_pm_fix_enabled();
             break;
         case Bug::REOPEN:
             $is_pm_enabled = $this->config->are_pm_reopen_enabled();
             break;
         case Bug::REJECTED:
             $is_pm_enabled = $this->config->are_pm_reject_enabled();
             break;
         default:
             $is_pm_enabled = false;
             break;
     }
     //Add comment if needed
     $comment = $this->form->get_value('comments_message', '');
     if (!empty($comment)) {
         $comments_topic = new BugtrackerCommentsTopic();
         $comments_topic->set_id_in_module($this->bug->get_id());
         $comments_topic->set_url(BugtrackerUrlBuilder::detail($this->bug->get_id() . '-' . $this->bug->get_rewrited_title()));
         CommentsManager::add_comment($comments_topic->get_module_id(), $comments_topic->get_id_in_module(), $comments_topic->get_topic_identifier(), $comments_topic->get_path(), $comment);
         //New line in the bug history
         BugtrackerService::add_history(array('bug_id' => $this->bug->get_id(), 'updater_id' => $this->current_user->get_id(), 'update_date' => $now->get_timestamp(), 'change_comment' => $this->lang['notice.new_comment']));
     }
     //Send PM with comment to updaters if the option is enabled
     if (!$this->bug->is_new() && $this->config->are_pm_enabled() && $is_pm_enabled && $send_pm) {
         BugtrackerPMService::send_PM_to_updaters($status, $this->bug->get_id(), $comment, $pm_recipients_list);
     }
     if (in_array($status, array(Bug::NEW_BUG, Bug::REOPEN, Bug::REJECTED, Bug::FIXED)) && $this->config->are_admin_alerts_enabled() && in_array($this->bug->get_severity(), $this->config->get_admin_alerts_levels())) {
         $alerts = AdministratorAlertService::find_by_criteria($this->bug->get_id(), 'bugtracker');
         if (!empty($alerts)) {
             $alert = $alerts[0];
             if ($this->bug->is_new() || $this->bug->is_reopen()) {
                 $alert->set_status(AdministratorAlert::ADMIN_ALERT_STATUS_UNREAD);
                 AdministratorAlertService::save_alert($alert);
             } else {
                 if ($this->config->is_admin_alerts_fix_action_fix()) {
                     $alert->set_status(AdministratorAlert::ADMIN_ALERT_STATUS_PROCESSED);
                     AdministratorAlertService::save_alert($alert);
                 } else {
                     AdministratorAlertService::delete_alert($alert);
                 }
             }
         }
     }
     BugtrackerStatsCache::invalidate();
 }
 protected function handle_submit()
 {
     $form = $this->get_form();
     if ($form->has_field('name')) {
         $id_comment = CommentsManager::add_comment($this->module_id, $this->id_in_module, $this->topic_identifier, $this->topic_path, $form->get_value('message'), $form->get_value('name'));
     } else {
         $id_comment = CommentsManager::add_comment($this->module_id, $this->id_in_module, $this->topic_identifier, $this->topic_path, $form->get_value('message'));
     }
     $this->comments_topic->get_events()->execute_add_comment_event();
     AppContext::get_response()->redirect(CommentsUrlBuilder::comment_added($this->topic_path, $id_comment));
 }
 public static function __static()
 {
     self::$user = AppContext::get_current_user();
 }
 private static function is_authorized_edit_or_delete_comment($authorizations, $comment_id)
 {
     $user_id_posted_comment = CommentsManager::get_user_id_posted_comment($comment_id);
     if ($user_id_posted_comment !== '-1') {
         return ($authorizations->is_authorized_moderation() || $user_id_posted_comment == self::$user->get_id()) && $authorizations->is_authorized_access_module();
     }
     return false;
 }