public function synchronize()
 {
     $this->bugs_number = array('total' => 0);
     $db_querier = PersistenceContext::get_querier();
     $config = BugtrackerConfig::load();
     $versions = $config->get_versions();
     $result = $db_querier->select("SELECT status, COUNT(*) as bugs_number\r\n\t\tFROM " . BugtrackerSetup::$bugtracker_table . "\r\n\t\tGROUP BY status\r\n\t\tORDER BY status ASC");
     foreach ($result as $row) {
         $this->bugs_number[$row['status']] = $row['bugs_number'];
         $this->bugs_number['total'] += $row['bugs_number'];
     }
     $result->dispose();
     $result = $db_querier->select("SELECT @fixed_in:=fixed_in AS fixed_in, \r\n\t\tCOUNT(*) as bugs_number, \r\n\t\t(SELECT COUNT(*) FROM " . BugtrackerSetup::$bugtracker_table . " WHERE fixed_in = @fixed_in AND status = '" . Bug::FIXED . "') as fixed_bugs_number, \r\n\t\t(SELECT COUNT(*) FROM " . BugtrackerSetup::$bugtracker_table . " WHERE fixed_in = @fixed_in AND (status = '" . Bug::IN_PROGRESS . "' OR status = '" . Bug::REOPEN . "')) as in_progress_bugs_number\r\n\t\tFROM " . BugtrackerSetup::$bugtracker_table . "\r\n\t\tGROUP BY fixed_in\r\n\t\tORDER BY fixed_in ASC");
     foreach ($result as $row) {
         if (!empty($row['fixed_in']) && isset($versions[$row['fixed_in']])) {
             $this->bugs_number_per_version[$row['fixed_in']] = array('all' => $row['bugs_number'], Bug::FIXED => $row['fixed_bugs_number'], Bug::IN_PROGRESS => $row['in_progress_bugs_number']);
         }
     }
     $result->dispose();
     $result = $db_querier->select("SELECT member.*, COUNT(*) as bugs_number\r\n\t\tFROM " . BugtrackerSetup::$bugtracker_table . " bugtracker\r\n\t\tJOIN " . DB_TABLE_MEMBER . " member ON member.user_id = bugtracker.author_id\r\n\t\tWHERE status <> '" . Bug::REJECTED . "'\r\n\t\tGROUP BY author_id\r\n\t\tORDER BY bugs_number DESC\r\n\t\tLIMIT " . $config->get_stats_top_posters_number());
     $i = 1;
     foreach ($result as $row) {
         $author = new User();
         if (!empty($row['user_id'])) {
             $author->set_properties($row);
         } else {
             $author->init_visitor_user();
         }
         $this->top_posters[$i] = array('user' => $author, 'bugs_number' => $row['bugs_number']);
         $i++;
     }
     $result->dispose();
 }
 private function build_table()
 {
     $number_admins = UserService::count_admin_members();
     $table_model = new SQLHTMLTableModel(DB_TABLE_MEMBER, 'table', array(new HTMLTableColumn($this->lang['display_name'], 'display_name'), new HTMLTableColumn($this->lang['level'], 'level'), new HTMLTableColumn($this->lang['email']), new HTMLTableColumn($this->lang['registration_date'], 'registration_date'), new HTMLTableColumn($this->lang['last_connection'], 'last_connection_date'), new HTMLTableColumn($this->lang['approbation'], 'approved'), new HTMLTableColumn('')), new HTMLTableSortingRule('display_name', HTMLTableSortingRule::ASC));
     $table = new HTMLTable($table_model);
     $table_model->set_caption(LangLoader::get_message('members.members-management', 'admin-user-common'));
     $results = array();
     $result = $table_model->get_sql_results('m LEFT JOIN ' . DB_TABLE_INTERNAL_AUTHENTICATION . ' ia ON ia.user_id = m.user_id');
     foreach ($result as $row) {
         $user = new User();
         $user->set_properties($row);
         $edit_link = new LinkHTMLElement(UserUrlBuilder::edit_profile($user->get_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit');
         if ($user->get_level() != User::ADMIN_LEVEL || $user->get_level() == User::ADMIN_LEVEL && $number_admins > 1) {
             $delete_link = new LinkHTMLElement(AdminMembersUrlBuilder::delete($user->get_id()), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => 'delete-element'), 'fa fa-delete');
         } else {
             $delete_link = new LinkHTMLElement('', '', array('title' => LangLoader::get_message('delete', 'common'), 'onclick' => 'return false;'), 'fa fa-delete icon-disabled');
         }
         $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
         $results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement(UserUrlBuilder::profile($user->get_id()), $user->get_display_name(), !empty($user_group_color) ? array('style' => 'color: ' . $user_group_color) : array(), UserService::get_level_class($user->get_level()))), new HTMLTableRowCell(UserService::get_level_lang($user->get_level())), new HTMLTableRowCell(new LinkHTMLElement('mailto:' . $user->get_email(), $this->lang['email'], array(), 'basic-button smaller')), new HTMLTableRowCell(Date::to_format($row['registration_date'], Date::FORMAT_DAY_MONTH_YEAR)), new HTMLTableRowCell(!empty($row['last_connection_date']) ? Date::to_format($row['last_connection_date'], Date::FORMAT_DAY_MONTH_YEAR) : LangLoader::get_message('never', 'main')), new HTMLTableRowCell($row['approved'] ? LangLoader::get_message('yes', 'common') : LangLoader::get_message('no', 'common')), new HTMLTableRowCell($edit_link->display() . $delete_link->display())));
     }
     $table->set_rows($table_model->get_number_of_matching_rows(), $results);
     $this->view->put_all(array('FORM' => $this->build_form()->display(), 'table' => $table->display()));
 }
 public function set_properties(array $properties)
 {
     $this->id = $properties['id'];
     $this->category_id = $properties['id_category'];
     $this->title = $properties['title'];
     $this->rewrited_title = $properties['rewrited_title'];
     $this->contents = $properties['contents'];
     $this->location = $properties['location'];
     if ($properties['approved']) {
         $this->approve();
     } else {
         $this->unapprove();
     }
     if ($properties['registration_authorized']) {
         $this->authorize_registration();
     } else {
         $this->unauthorize_registration();
     }
     $this->max_registered_members = $properties['max_registered_members'];
     $this->last_registration_date_enabled = !empty($properties['last_registration_date']);
     $this->last_registration_date = !empty($properties['last_registration_date']) ? new Date($properties['last_registration_date'], Timezone::SERVER_TIMEZONE) : null;
     $this->register_authorizations = unserialize($properties['register_authorizations']);
     $this->creation_date = new Date($properties['creation_date'], Timezone::SERVER_TIMEZONE);
     $this->repeat_number = $properties['repeat_number'];
     $this->repeat_type = $properties['repeat_type'];
     $user = new User();
     if (!empty($properties['user_id'])) {
         $user->set_properties($properties);
     } else {
         $user->init_visitor_user();
     }
     $this->set_author_user($user);
 }
 public function set_properties(array $properties)
 {
     $this->id = $properties['id'];
     $this->id_category = $properties['id_category'];
     $this->name = $properties['name'];
     $this->rewrited_name = $properties['rewrited_name'];
     $this->url = new Url($properties['url']);
     $this->size = $properties['size'];
     $this->contents = $properties['contents'];
     $this->short_contents = $properties['short_contents'];
     $this->approbation_type = $properties['approbation_type'];
     $this->start_date = !empty($properties['start_date']) ? new Date($properties['start_date'], Timezone::SERVER_TIMEZONE) : null;
     $this->end_date = !empty($properties['end_date']) ? new Date($properties['end_date'], Timezone::SERVER_TIMEZONE) : null;
     $this->end_date_enabled = !empty($properties['end_date']);
     $this->creation_date = new Date($properties['creation_date'], Timezone::SERVER_TIMEZONE);
     $this->updated_date = !empty($properties['updated_date']) ? new Date($properties['updated_date'], Timezone::SERVER_TIMEZONE) : null;
     $this->number_downloads = $properties['number_downloads'];
     $this->picture_url = new Url($properties['picture_url']);
     $user = new User();
     if (!empty($properties['user_id'])) {
         $user->set_properties($properties);
     } else {
         $user->init_visitor_user();
     }
     $this->set_author_user($user);
     $notation = new Notation();
     $notation->set_module_name('download');
     $notation->set_notation_scale(DownloadConfig::load()->get_notation_scale());
     $notation->set_id_in_module($properties['id']);
     $notation->set_number_notes($properties['number_notes']);
     $notation->set_average_notes($properties['average_notes']);
     $notation->set_user_already_noted(!empty($properties['note']));
     $this->notation = $notation;
     $this->author_display_name = !empty($properties['author_display_name']) ? $properties['author_display_name'] : $this->author_user->get_display_name();
     $this->author_display_name_enabled = !empty($properties['author_display_name']);
     $units = array(LangLoader::get_message('unit.bytes', 'common'), LangLoader::get_message('unit.kilobytes', 'common'), LangLoader::get_message('unit.megabytes', 'common'), LangLoader::get_message('unit.gigabytes', 'common'));
     $power = $this->size > 0 ? floor(log($this->size, 1024)) : 0;
     $this->formated_size = (double) number_format($this->size / pow(1024, $power), 2, '.', ',') . ' ' . $units[$power];
 }
Example #5
0
 public function set_properties(array $properties)
 {
     $this->id = $properties['id'];
     $this->id_category = $properties['id_category'];
     $this->q_order = $properties['q_order'];
     $this->question = $properties['question'];
     $this->rewrited_question = Url::encode_rewrite($properties['question']);
     $this->answer = $properties['answer'];
     $this->creation_date = new Date($properties['creation_date'], Timezone::SERVER_TIMEZONE);
     $this->approved = (bool) $properties['approved'];
     $user = new User();
     if (!empty($properties['user_id'])) {
         $user->set_properties($properties);
     } else {
         $user->init_visitor_user();
     }
     $this->set_author_user($user);
 }
 function updateAction()
 {
     $user = new User($this->args[1]);
     $dat = $_POST['user'];
     //We don't want anyone modifying these properties
     //of their own profiles
     if ($_SESSION[user]->username != $user->username) {
         $user->username = $dat['username'];
         $user->admin_privileges = $dat['admin_privileges'] == 'admin' ? 1 : 0;
     }
     $user->name = $dat['name'];
     $user->email = $dat['email'];
     $user->allow_email = $dat['allow_email'] == 'allow' ? 1 : 0;
     if ($user->set_properties()) {
         $_SESSION['flash'][] = array('info', 'User profile updated successfully.');
         redirect_to(ADMIN_URL . '/users/show/' . $user->username);
     } else {
         $_SESSION['flash'][] = array('error', 'Your submission failed. Please check all fields and try again.');
         redirect_to(ADMIN_URL . '/users/show/' . $this->args[1]);
     }
 }
 public function set_properties(array $properties)
 {
     $this->id = $properties['id'];
     $this->contents = $properties['contents'];
     $this->login = $properties['glogin'];
     $this->creation_date = new Date($properties['timestamp'], Timezone::SERVER_TIMEZONE);
     $user = new User();
     if (!empty($properties['user_id'])) {
         $user->set_properties($properties);
     } else {
         $user->init_visitor_user();
     }
     $this->set_author_user($user);
 }
Example #8
0
 public function set_properties(array $properties)
 {
     $this->id = $properties['id'];
     $this->id_category = $properties['id_category'];
     $this->name = $properties['name'];
     $this->rewrited_name = $properties['rewrited_name'];
     $this->url = new Url($properties['url']);
     $this->contents = $properties['contents'];
     $this->short_contents = $properties['short_contents'];
     $this->approbation_type = $properties['approbation_type'];
     $this->start_date = !empty($properties['start_date']) ? new Date($properties['start_date'], Timezone::SERVER_TIMEZONE) : null;
     $this->end_date = !empty($properties['end_date']) ? new Date($properties['end_date'], Timezone::SERVER_TIMEZONE) : null;
     $this->end_date_enabled = !empty($properties['end_date']);
     $this->creation_date = new Date($properties['creation_date'], Timezone::SERVER_TIMEZONE);
     $this->number_views = $properties['number_views'];
     $this->partner = (bool) $properties['partner'];
     $this->partner_picture = new Url($properties['partner_picture']);
     $this->privileged_partner = (bool) $properties['privileged_partner'];
     $user = new User();
     if (!empty($properties['user_id'])) {
         $user->set_properties($properties);
     } else {
         $user->init_visitor_user();
     }
     $this->set_author_user($user);
     $notation = new Notation();
     $notation->set_module_name('web');
     $notation->set_notation_scale(WebConfig::load()->get_notation_scale());
     $notation->set_id_in_module($properties['id']);
     $notation->set_number_notes($properties['number_notes']);
     $notation->set_average_notes($properties['average_notes']);
     $notation->set_user_already_noted(!empty($properties['note']));
     $this->notation = $notation;
 }
Example #9
0
 public function set_properties(array $properties)
 {
     $this->id = $properties['id'];
     $this->title = $properties['title'];
     $this->rewrited_title = Url::encode_rewrite($properties['title']);
     $this->contents = $properties['contents'];
     $this->submit_date = !empty($properties['submit_date']) ? new Date($properties['submit_date'], Timezone::SERVER_TIMEZONE) : null;
     $this->fix_date = !empty($properties['fix_date']) ? new Date($properties['fix_date'], Timezone::SERVER_TIMEZONE) : null;
     $this->status = $properties['status'];
     $this->type = $properties['type'];
     $this->category = $properties['category'];
     $this->severity = $properties['severity'];
     $this->priority = $properties['priority'];
     $this->reproductible = $properties['reproductible'];
     $this->reproduction_method = $properties['reproduction_method'];
     $this->detected_in = $properties['detected_in'];
     $this->fixed_in = $properties['fixed_in'];
     $this->assigned_to_id = $properties['assigned_to_id'];
     $user = new User();
     if (!empty($properties['user_id'])) {
         $user->set_properties($properties);
     } else {
         $user->init_visitor_user();
     }
     $this->set_author_user($user);
 }
Example #10
0
 public function set_properties(array $properties)
 {
     $this->id = $properties['id'];
     $this->id_cat = $properties['id_category'];
     $this->name = $properties['name'];
     $this->rewrited_name = $properties['rewrited_name'];
     $this->contents = $properties['contents'];
     $this->short_contents = $properties['short_contents'];
     $this->approbation_type = $properties['approbation_type'];
     $this->start_date = !empty($properties['start_date']) ? new Date($properties['start_date'], Timezone::SERVER_TIMEZONE) : null;
     $this->end_date = !empty($properties['end_date']) ? new Date($properties['end_date'], Timezone::SERVER_TIMEZONE) : null;
     $this->end_date_enabled = !empty($properties['end_date']);
     $this->top_list_enabled = (bool) $properties['top_list_enabled'];
     $this->creation_date = new Date($properties['creation_date'], Timezone::SERVER_TIMEZONE);
     $this->updated_date = !empty($properties['updated_date']) ? new Date($properties['updated_date'], Timezone::SERVER_TIMEZONE) : null;
     $this->picture_url = new Url($properties['picture_url']);
     $this->sources = !empty($properties['sources']) ? unserialize($properties['sources']) : array();
     $user = new User();
     if (!empty($properties['user_id'])) {
         $user->set_properties($properties);
     } else {
         $user->init_visitor_user();
     }
     $this->set_author_user($user);
 }
Example #11
0
 public function set_properties(array $properties)
 {
     $this->set_id($properties['id']);
     $this->set_id_category($properties['id_category']);
     $this->set_title($properties['title']);
     $this->set_rewrited_title($properties['rewrited_title']);
     $this->set_description($properties['description']);
     $this->set_contents($properties['contents']);
     $this->set_picture(new Url($properties['picture_url']));
     $this->set_number_view($properties['number_view']);
     $this->set_author_name_displayed($properties['author_name_displayed']);
     $this->set_publishing_state($properties['published']);
     $this->publishing_start_date = !empty($properties['publishing_start_date']) ? new Date($properties['publishing_start_date'], Timezone::SERVER_TIMEZONE) : null;
     $this->publishing_end_date = !empty($properties['publishing_end_date']) ? new Date($properties['publishing_end_date'], Timezone::SERVER_TIMEZONE) : null;
     $this->end_date_enabled = !empty($properties['publishing_end_date']);
     $this->set_date_created(new Date($properties['date_created'], Timezone::SERVER_TIMEZONE));
     $this->date_updated = !empty($properties['date_updated']) ? new Date($properties['date_updated'], Timezone::SERVER_TIMEZONE) : null;
     $this->set_notation_enabled($properties['notation_enabled']);
     $this->set_sources(!empty($properties['sources']) ? unserialize($properties['sources']) : array());
     $user = new User();
     if (!empty($properties['user_id'])) {
         $user->set_properties($properties);
     } else {
         $user->init_visitor_user();
     }
     $this->set_author_user($user);
     $notation = new Notation();
     $notation->set_module_name('articles');
     $notation->set_notation_scale(ArticlesConfig::load()->get_notation_scale());
     $notation->set_id_in_module($properties['id']);
     $notation->set_number_notes($properties['number_notes']);
     $notation->set_average_notes($properties['average_notes']);
     $notation->set_user_already_noted(!empty($properties['note']));
     $this->notation = $notation;
 }
Example #12
0
 /**
  * @desc Returns a user
  * @param string $condition
  * @param array $parameters
  * @return User
  */
 public static function get_user($user_id)
 {
     $row = self::$querier->select_single_row(PREFIX . 'member', array('*'), 'WHERE user_id=:user_id', array('user_id' => $user_id));
     $user = new User();
     $user->set_properties($row);
     return $user;
 }
 private function build_view($request)
 {
     $current_page = $request->get_getint('page', 1);
     //Configuration load
     $config = BugtrackerConfig::load();
     $types = $config->get_types();
     $categories = $config->get_categories();
     $severities = $config->get_severities();
     $priorities = $config->get_priorities();
     $versions = $config->get_versions();
     $history_lines_number = BugtrackerService::count_history($this->bug->get_id());
     $pagination = $this->get_pagination($history_lines_number, $current_page);
     $common_lang = LangLoader::get('common');
     $this->view->put_all(array('C_PAGINATION' => $pagination->has_several_pages(), 'C_HISTORY' => $history_lines_number, 'PAGINATION' => $pagination->display()));
     $result = PersistenceContext::get_querier()->select("SELECT *\n\t\tFROM " . BugtrackerSetup::$bugtracker_table . " b\n\t\tJOIN " . BugtrackerSetup::$bugtracker_history_table . " bh ON (bh.bug_id = b.id)\n\t\tLEFT JOIN " . DB_TABLE_MEMBER . " member ON (member.user_id = bh.updater_id)\n\t\tWHERE b.id = '" . $this->bug->get_id() . "'\n\t\tORDER BY update_date DESC\n\t\tLIMIT :number_items_per_page OFFSET :display_from", array('number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
     while ($row = $result->fetch()) {
         switch ($row['updated_field']) {
             case 'type':
                 $old_value = !empty($row['old_value']) && isset($types[$row['old_value']]) ? stripslashes($types[$row['old_value']]) : $this->lang['notice.none'];
                 $new_value = !empty($row['new_value']) && isset($types[$row['new_value']]) ? stripslashes($types[$row['new_value']]) : $this->lang['notice.none'];
                 break;
             case 'category':
                 $old_value = !empty($row['old_value']) && isset($categories[$row['old_value']]) ? stripslashes($categories[$row['old_value']]) : $this->lang['notice.none_e'];
                 $new_value = !empty($row['new_value']) && isset($categories[$row['new_value']]) ? stripslashes($categories[$row['new_value']]) : $this->lang['notice.none_e'];
                 break;
             case 'severity':
                 $old_value = !empty($row['old_value']) ? stripslashes($severities[$row['old_value']]['name']) : $this->lang['notice.none'];
                 $new_value = !empty($row['new_value']) ? stripslashes($severities[$row['new_value']]['name']) : $this->lang['notice.none'];
                 break;
             case 'priority':
                 $old_value = !empty($row['old_value']) ? stripslashes($priorities[$row['old_value']]) : $this->lang['notice.none_e'];
                 $new_value = !empty($row['new_value']) ? stripslashes($priorities[$row['new_value']]) : $this->lang['notice.none_e'];
                 break;
             case 'detected_in':
             case 'fixed_in':
                 $old_value = !empty($row['old_value']) && isset($versions[$row['old_value']]) ? stripslashes($versions[$row['old_value']]['name']) : $this->lang['notice.none_e'];
                 $new_value = !empty($row['new_value']) && isset($versions[$row['new_value']]) ? stripslashes($versions[$row['new_value']]['name']) : $this->lang['notice.none_e'];
                 break;
             case 'status':
                 $old_value = $this->lang['status.' . $row['old_value']];
                 $new_value = $this->lang['status.' . $row['new_value']];
                 break;
             case 'reproductible':
                 $old_value = $row['old_value'] ? $common_lang['yes'] : $common_lang['no'];
                 $new_value = $row['new_value'] ? $common_lang['yes'] : $common_lang['no'];
                 break;
             default:
                 $old_value = $row['old_value'];
                 $new_value = $row['new_value'];
         }
         $update_date = new Date($row['update_date'], Timezone::SERVER_TIMEZONE);
         $user = new User();
         if (!empty($row['user_id'])) {
             $user->set_properties($row);
         } else {
             $user->init_visitor_user();
         }
         $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
         $this->view->assign_block_vars('history', array('C_UPDATER_GROUP_COLOR' => !empty($user_group_color), 'C_UPDATER_EXIST' => $user->get_id() !== User::VISITOR_LEVEL, 'UPDATED_FIELD' => !empty($row['updated_field']) ? $this->lang['labels.fields.' . $row['updated_field']] : $this->lang['notice.none'], 'OLD_VALUE' => stripslashes($old_value), 'NEW_VALUE' => stripslashes($new_value), 'COMMENT' => $row['change_comment'], 'UPDATE_DATE_SHORT' => $update_date->format(Date::FORMAT_DAY_MONTH_YEAR), 'UPDATE_DATE' => $update_date->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'UPDATER' => $user->get_display_name(), 'UPDATER_LEVEL_CLASS' => UserService::get_level_class($user->get_level()), 'UPDATER_GROUP_COLOR' => $user_group_color, 'LINK_UPDATER_PROFILE' => UserUrlBuilder::profile($user->get_id())->rel()));
     }
     $result->dispose();
 }