function get_all_alerts($criteria = 'creation_date', $order = 'desc', $begin = 0, $number = 20)
 {
     global $Sql;
     $array_result = array();
     $result = $Sql->query_while("SELECT id, entitled, fixing_url, current_status, creation_date, identifier, id_in_module, type, priority, description\n\t\tFROM " . DB_TABLE_EVENTS . "\n\t\tWHERE contribution_type = " . ADMINISTRATOR_ALERT_TYPE . "\n\t\tORDER BY " . $criteria . " " . strtoupper($order) . " " . $Sql->limit($begin, $number), __LINE__, __FILE__);
     while ($row = $Sql->fetch_assoc($result)) {
         $alert = new AdministratorAlert();
         $alert->build($row['id'], $row['entitled'], $row['description'], $row['fixing_url'], $row['current_status'], new Date(DATE_TIMESTAMP, TIMEZONE_SYSTEM, $row['creation_date']), $row['id_in_module'], $row['identifier'], $row['type'], $row['priority']);
         $array_result[] = $alert;
     }
     $Sql->query_close($result);
     return $array_result;
 }
 public static function send_email_confirmation($user_id, $email, $pseudo, $login, $password, $registration_pass)
 {
     $lang = LangLoader::get('user-common');
     $user_accounts_config = UserAccountsConfig::load();
     $general_config = GeneralConfig::load();
     $site_name = $general_config->get_site_name();
     $subject = StringVars::replace_vars($lang['registration.subject-mail'], array('site_name' => $site_name));
     switch ($user_accounts_config->get_member_accounts_validation_method()) {
         case UserAccountsConfig::AUTOMATIC_USER_ACCOUNTS_VALIDATION:
             $parameters = array('pseudo' => $pseudo, 'site_name' => $site_name, 'host' => $general_config->get_site_url(), 'login' => $login, 'password' => $password, 'accounts_validation_explain' => $lang['registration.email.automatic-validation'], 'signature' => MailServiceConfig::load()->get_mail_signature());
             $content = StringVars::replace_vars($lang['registration.content-mail'], $parameters);
             AppContext::get_mail_service()->send_from_properties($email, $subject, $content);
             break;
         case UserAccountsConfig::MAIL_USER_ACCOUNTS_VALIDATION:
             $parameters = array('pseudo' => $pseudo, 'site_name' => $site_name, 'host' => $general_config->get_site_url(), 'login' => $login, 'password' => $password, 'accounts_validation_explain' => StringVars::replace_vars($lang['registration.email.mail-validation'], array('validation_link' => UserUrlBuilder::confirm_registration($registration_pass)->absolute())), 'signature' => MailServiceConfig::load()->get_mail_signature());
             $content = StringVars::replace_vars($lang['registration.content-mail'], $parameters);
             AppContext::get_mail_service()->send_from_properties($email, $subject, $content);
             break;
         case UserAccountsConfig::ADMINISTRATOR_USER_ACCOUNTS_VALIDATION:
             $alert = new AdministratorAlert();
             $alert->set_entitled($lang['registration.pending-approval']);
             $alert->set_fixing_url(UserUrlBuilder::edit_profile($user_id)->relative());
             $alert->set_priority(AdministratorAlert::ADMIN_ALERT_MEDIUM_PRIORITY);
             $alert->set_id_in_module($user_id);
             $alert->set_type('member_account_to_approbate');
             AdministratorAlertService::save_alert($alert);
             $parameters = array('pseudo' => $pseudo, 'site_name' => $site_name, 'host' => $general_config->get_site_url(), 'login' => $login, 'password' => $password, 'accounts_validation_explain' => $lang['registration.email.administrator-validation'], 'signature' => MailServiceConfig::load()->get_mail_signature());
             $content = StringVars::replace_vars($lang['registration.content-mail'], $parameters);
             AppContext::get_mail_service()->send_from_properties($email, $subject, $content);
             break;
     }
 }
Ejemplo n.º 3
0
 function _add_update_alert(&$app)
 {
     import('events/administrator_alert_service');
     $identifier = $app->get_identifier();
     if (AdministratorAlertService::find_by_identifier($identifier, 'updates', 'kernel') === null) {
         $alert = new AdministratorAlert();
         global $LANG, $CONFIG;
         require_once PATH_TO_ROOT . '/lang/' . get_ulang() . '/admin.php';
         if ($app->get_type() == APPLICATION_TYPE__KERNEL) {
             $alert->set_entitled(sprintf($LANG['kernel_update_available'], $app->get_version()));
         } else {
             $alert->set_entitled(sprintf($LANG['update_available'], $app->get_type(), $app->get_name(), $app->get_version()));
         }
         $alert->set_fixing_url('admin/updates/detail.php?identifier=' . $identifier);
         $alert->set_priority($app->get_priority());
         $alert->set_properties(serialize($app));
         $alert->set_type('updates');
         $alert->set_identifier($identifier);
         AdministratorAlertService::save_alert($alert);
     }
 }
 /** 
  * @desc Deletes an alert from the database.
  * @param AdministratorAlert $alert The alert to delete.
  */
 public static function delete_alert($alert)
 {
     // If it exists in the data base
     if ($alert->get_id() > 0) {
         self::$db_querier->delete(DB_TABLE_EVENTS, 'WHERE id = :id', array('id' => $alert->get_id()));
         $alert->set_id(0);
         AdministratorAlertCache::invalidate();
     }
     //Else it's not present in the database, we have nothing to delete
 }
Ejemplo n.º 5
0
 /**
  * @desc Save an alert for Update Notification
  */
 private function add_update_alert($app)
 {
     $identifier = $app->get_identifier();
     // We verify that the alert is not already registered
     if (AdministratorAlertService::find_by_identifier($identifier, 'updates', 'kernel') === null) {
         $alert = new AdministratorAlert();
         require_once PATH_TO_ROOT . '/lang/' . AppContext::get_current_user()->get_locale() . '/admin.php';
         if ($app->get_type() == Application::KERNEL_TYPE) {
             $alert->set_entitled(sprintf(LangLoader::get_message('kernel_update_available', 'admin'), $app->get_version()));
         } else {
             $alert->set_entitled(sprintf(LangLoader::get_message('update_available', 'admin'), $app->get_type(), $app->get_name(), $app->get_version()));
         }
         $alert->set_fixing_url('admin/updates/detail.php?identifier=' . $identifier);
         $alert->set_priority($app->get_priority());
         $alert->set_properties(serialize($app));
         $alert->set_type('updates');
         $alert->set_identifier($identifier);
         //Save
         AdministratorAlertService::save_alert($alert);
     }
 }
Ejemplo n.º 6
0
 $check_user = $Sql->query("SELECT COUNT(*) as compt FROM " . DB_TABLE_MEMBER . " WHERE login = '******'", __LINE__, __FILE__);
 $check_mail = $Sql->query("SELECT COUNT(*) as compt FROM " . DB_TABLE_MEMBER . " WHERE user_mail = '" . $user_mail . "'", __LINE__, __FILE__);
 if ($check_user >= 1) {
     redirect(HOST . DIR . '/member/register' . url('.php?error=pseudo_auth') . '#errorh');
 } elseif ($check_mail >= 1) {
     redirect(HOST . DIR . '/member/register' . url('.php?error=mail_auth') . '#errorh');
 } else {
     $user_aprob = $CONFIG_USER['activ_mbr'] == 0 ? 1 : 0;
     $activ_mbr = $CONFIG_USER['activ_mbr'] == 1 ? substr(strhash(uniqid(rand(), true)), 0, 15) : '';
     @unlink('../cache/sex.png');
     @unlink('../cache/theme.png');
     $Sql->query_inject("INSERT INTO " . DB_TABLE_MEMBER . " (login,password,level,user_groups,user_lang,user_theme,user_mail,user_show_mail,user_editor,user_timezone,timestamp,user_avatar,user_msg,user_local,user_msn,user_yahoo,user_web,user_occupation,user_hobbies,user_desc,user_sex,user_born,user_sign,user_pm,user_warning,last_connect,test_connect,activ_pass,new_pass,user_ban,user_aprob)\n\t\t\t\t\tVALUES ('" . $login . "', '" . $password_hash . "', 0, '0', '" . $user_lang . "', '" . $user_theme . "', '" . $user_mail . "', '" . $user_show_mail . "', '" . $user_editor . "', '" . $user_timezone . "', '" . time() . "', '" . $user_avatar . "', 0, '" . $user_local . "', '" . $user_msn . "', '" . $user_yahoo . "', '" . $user_web . "', '" . $user_occupation . "', '" . $user_hobbies . "', '" . $user_desc . "', '" . $user_sex . "', '" . $user_born . "', '" . $user_sign . "', 0, 0, '" . time() . "', 0, '" . $activ_mbr . "', '', 0, '" . $user_aprob . "')", __LINE__, __FILE__);
     $last_mbr_id = $Sql->insert_id("SELECT MAX(id) FROM " . DB_TABLE_MEMBER);
     if ($CONFIG_USER['activ_mbr'] == 2) {
         import('events/administrator_alert_service');
         $alert = new AdministratorAlert();
         $alert->set_entitled($LANG['member_registered_to_approbate']);
         $alert->set_fixing_url('admin/admin_members.php?id=' . $last_mbr_id);
         $alert->set_priority(ADMIN_ALERT_MEDIUM_PRIORITY);
         $alert->set_id_in_module($last_mbr_id);
         $alert->set_type('member_account_to_approbate');
         AdministratorAlertService::save_alert($alert);
     } else {
         $Cache->Generate_file('stats');
     }
     $extend_field_exist = $Sql->query("SELECT COUNT(*) FROM " . DB_TABLE_MEMBER_EXTEND_CAT . " WHERE display = 1", __LINE__, __FILE__);
     if ($extend_field_exist > 0) {
         $req_update = '';
         $req_field = '';
         $req_insert = '';
         $result = $Sql->query_while("SELECT field_name, field, possible_values, regex, required\n\t\t\t\t\t\tFROM " . DB_TABLE_MEMBER_EXTEND_CAT . "\n\t\t\t\t\t\tWHERE display = 1", __LINE__, __FILE__);
    private function save()
    {
        $bug = $this->get_bug();
        if ($bug->get_id() === null) {
            $title = $this->form->get_value('title');
            $bug->set_title($title);
            $bug->set_rewrited_title(Url::encode_rewrite($title));
            $bug->set_contents($this->form->get_value('contents'));
            $bug->set_type($this->form->get_value('type') ? $this->form->get_value('type')->get_raw_value() : $this->config->get_default_type());
            $bug->set_category($this->form->get_value('category') ? $this->form->get_value('category')->get_raw_value() : $this->config->get_default_category());
            $bug->set_severity($this->form->get_value('severity') ? $this->form->get_value('severity')->get_raw_value() : $this->config->get_default_severity());
            $bug->set_priority($this->form->get_value('priority') ? $this->form->get_value('priority')->get_raw_value() : $this->config->get_default_priority());
            $bug->set_detected_in($this->form->get_value('detected_in') ? $this->form->get_value('detected_in')->get_raw_value() : $this->config->get_default_version());
            $bug->set_reproductible($this->form->get_value('reproductible') ? true : 0);
            if ($bug->is_reproductible()) {
                $bug->set_reproduction_method($this->form->get_value('reproduction_method'));
            }
            //Bug creation
            $bug->set_id(BugtrackerService::add($bug));
            if ($this->config->are_admin_alerts_enabled() && in_array($bug->get_severity(), $this->config->get_admin_alerts_levels())) {
                $alert = new AdministratorAlert();
                $alert->set_entitled('[' . $this->lang['module_title'] . '] ' . $bug->get_title());
                $alert->set_fixing_url(BugtrackerUrlBuilder::detail($bug->get_id() . '-' . $bug->get_rewrited_title())->relative());
                switch ($bug->get_priority()) {
                    case 1:
                        switch ($bug->get_severity()) {
                            case 1:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_VERY_LOW_PRIORITY;
                                break;
                            case 2:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_LOW_PRIORITY;
                                break;
                            default:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_MEDIUM_PRIORITY;
                                break;
                        }
                        break;
                    case 2:
                        switch ($bug->get_severity()) {
                            case 1:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_LOW_PRIORITY;
                                break;
                            default:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_MEDIUM_PRIORITY;
                                break;
                        }
                        break;
                    case 3:
                        switch ($bug->get_severity()) {
                            case 1:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_LOW_PRIORITY;
                                break;
                            case 2:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_MEDIUM_PRIORITY;
                                break;
                            case 3:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_HIGH_PRIORITY;
                                break;
                            default:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_MEDIUM_PRIORITY;
                                break;
                        }
                        break;
                    case 4:
                        switch ($bug->get_severity()) {
                            case 2:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_MEDIUM_PRIORITY;
                                break;
                            case 3:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_HIGH_PRIORITY;
                                break;
                            default:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_LOW_PRIORITY;
                                break;
                        }
                        break;
                    case 5:
                        switch ($bug->get_severity()) {
                            case 2:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_HIGH_PRIORITY;
                                break;
                            case 3:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_VERY_HIGH_PRIORITY;
                                break;
                            default:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_MEDIUM_PRIORITY;
                                break;
                        }
                        break;
                    default:
                        switch ($bug->get_severity()) {
                            case 1:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_LOW_PRIORITY;
                                break;
                            case 2:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_MEDIUM_PRIORITY;
                                break;
                            case 3:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_HIGH_PRIORITY;
                                break;
                            default:
                                $alert_priority = AdministratorAlert::ADMIN_ALERT_MEDIUM_PRIORITY;
                                break;
                        }
                        break;
                }
                $alert->set_priority($alert_priority);
                $alert->set_id_in_module($bug->get_id());
                $alert->set_type('bugtracker');
                AdministratorAlertService::save_alert($alert);
            }
        } else {
            $old_values = clone $bug;
            $now = new Date();
            $types = $this->config->get_types();
            $categories = $this->config->get_categories();
            $severities = $this->config->get_severities();
            $priorities = $this->config->get_priorities();
            $versions = $this->config->get_versions();
            $display_versions = count($versions) > 1;
            $status_list = $this->config->get_status_list();
            $common_lang = LangLoader::get('common');
            $title = $this->form->get_value('title', $old_values->get_title());
            $bug->set_title($title);
            $bug->set_rewrited_title(Url::encode_rewrite($title));
            $bug->set_contents($this->form->get_value('contents', $old_values->get_contents()));
            $bug->set_type($this->form->get_value('type') ? $this->form->get_value('type')->get_raw_value() : $old_values->get_type());
            $bug->set_category($this->form->get_value('category') ? $this->form->get_value('category')->get_raw_value() : $old_values->get_category());
            $bug->set_severity($this->form->get_value('severity') ? $this->form->get_value('severity')->get_raw_value() : $old_values->get_severity());
            $bug->set_priority($this->form->get_value('priority') ? $this->form->get_value('priority')->get_raw_value() : $old_values->get_priority());
            $bug->set_detected_in($this->form->get_value('detected_in') ? $this->form->get_value('detected_in')->get_raw_value() : $old_values->get_detected_in());
            $bug->set_reproductible($this->form->get_value('reproductible') ? true : 0);
            if ($bug->is_reproductible()) {
                $bug->set_reproduction_method($this->form->get_value('reproduction_method', $old_values->get_reproduction_method()));
            }
            $pm_comment = '';
            $modification = false;
            $fields = array('title', 'contents', 'type', 'category', 'severity', 'priority', 'detected_in', 'reproductible', 'reproduction_method');
            $n_values = $bug->get_properties();
            $o_values = $old_values->get_properties();
            foreach ($fields as $field) {
                if ($o_values[$field] != $n_values[$field]) {
                    $modification = true;
                    $comment = '';
                    switch ($field) {
                        case 'title':
                            $new_value = stripslashes($n_values[$field]);
                            $o_values[$field] = addslashes($o_values[$field]);
                            $comment = '';
                            break;
                        case 'contents':
                            $o_values[$field] = '';
                            $n_values[$field] = '';
                            $comment = $this->lang['notice.contents_update'];
                            break;
                        case 'reproduction_method':
                            $o_values[$field] = '';
                            $n_values[$field] = '';
                            $comment = $this->lang['notice.reproduction_method_update'];
                            break;
                        case 'type':
                            $new_value = !empty($n_values[$field]) ? stripslashes($types[$n_values[$field]]) : $this->lang['notice.none'];
                            break;
                        case 'category':
                            $new_value = !empty($n_values[$field]) ? stripslashes($categories[$n_values[$field]]) : $this->lang['notice.none_e'];
                            break;
                        case 'priority':
                            $new_value = !empty($n_values[$field]) ? stripslashes($priorities[$n_values[$field]]) : $this->lang['notice.none_e'];
                            break;
                        case 'severity':
                            $new_value = !empty($n_values[$field]) ? stripslashes($severities[$n_values[$field]]['name']) : $this->lang['notice.none'];
                            break;
                        case 'detected_in':
                            $new_value = !empty($n_values[$field]) ? stripslashes($versions[$n_values[$field]]['name']) : $this->lang['notice.none_e'];
                            break;
                        case 'status':
                            $new_value = $this->lang['status.' . $n_values[$field]];
                            break;
                        case 'reproductible':
                            $new_value = $n_values[$field] ? $common_lang['yes'] : $common_lang['no'];
                            break;
                        default:
                            $new_value = $n_values[$field];
                            $comment = '';
                    }
                    $pm_comment .= $field != 'contents' && $field != 'reproduction_method' ? $this->lang['labels.fields.' . $field] . ' : ' . stripslashes($new_value) . '
	' : '';
                    //Bug history update
                    BugtrackerService::add_history(array('bug_id' => $bug->get_id(), 'updater_id' => $this->current_user->get_id(), 'update_date' => $now->get_timestamp(), 'updated_field' => $field, 'old_value' => $o_values[$field], 'new_value' => $n_values[$field], 'change_comment' => $comment));
                }
            }
            if ($modification) {
                //Bug update
                BugtrackerService::update($bug);
                //Send PM to updaters if the option is enabled
                if ($this->config->are_pm_enabled() && $this->config->are_pm_edit_enabled() && !empty($pm_comment)) {
                    BugtrackerPMService::send_PM_to_updaters('edit', $bug->get_id(), $pm_comment);
                }
            }
        }
        Feed::clear_cache('bugtracker');
        BugtrackerStatsCache::invalidate();
        AppContext::get_response()->redirect($this->form->get_value('referrer') ? $this->form->get_value('referrer') : BugtrackerUrlBuilder::unsolved(), StringVars::replace_vars($this->is_new_bug ? $this->lang['success.add'] : $this->lang['success.edit'], array('id' => $bug->get_id())));
    }
Ejemplo n.º 8
0
 function test_get_priority_name()
 {
     global $LANG;
     $alert = new AdministratorAlert();
     $alert->set_priority(AdministratorAlert::ADMIN_ALERT_VERY_LOW_PRIORITY);
     self::assertEquals($alert->get_priority_name(), $LANG['priority_very_low']);
     $alert->set_priority(AdministratorAlert::ADMIN_ALERT_LOW_PRIORITY);
     self::assertEquals($alert->get_priority_name(), $LANG['priority_low']);
     $alert->set_priority(AdministratorAlert::ADMIN_ALERT_MEDIUM_PRIORITY);
     self::assertEquals($alert->get_priority_name(), $LANG['priority_medium']);
     $alert->set_priority(AdministratorAlert::ADMIN_ALERT_HIGH_PRIORITY);
     self::assertEquals($alert->get_priority_name(), $LANG['priority_high']);
     $alert->set_priority(AdministratorAlert::ADMIN_ALERT_VERY_HIGH_PRIORITY);
     self::assertEquals($alert->get_priority_name(), $LANG['priority_very_high']);
 }