Example #1
0
 public static function getPage_Invitations($contents, $containers)
 {
     $repositoryID = self::validateID(self::getDataGET('project'), true);
     $repositoryData = Database::getRepositoryData($repositoryID);
     if (empty($repositoryData)) {
         self::addBreadcrumbItem(URL::toProject($repositoryID), 'Project not found');
         self::setTitle('Project not found');
         $contents[] = new UI_Heading('Project not found', true);
         $contents[] = new UI_Paragraph('We\'re sorry, but we could not find the project that you requested.');
         $contents[] = new UI_Paragraph('Please check if you have made any typing errors.');
     } else {
         if (Authentication::getUserID() <= 0) {
             self::setTitle($repositoryData['name']);
             $contents[] = new UI_Heading(htmlspecialchars($repositoryData['name']), true);
             $contents[] = self::getLoginForm();
         } elseif (!Repository::hasUserPermissions(Authentication::getUserID(), $repositoryID, $repositoryData, Repository::ROLE_ADMINISTRATOR)) {
             self::setTitle($repositoryData['name']);
             $contents[] = new UI_Heading(htmlspecialchars($repositoryData['name']), true);
             $contents[] = new UI_Paragraph('Only administrators of this project are allowed to review invitation requests.');
         } else {
             $currentPageURL = URL::toInvitations($repositoryID);
             self::addBreadcrumbItem($currentPageURL, 'Invitations');
             self::setTitle('Invitations');
             $contents[] = new UI_Heading('Invitations', true);
             $invitationData = Database::getInvitationByRepository($repositoryID);
             if (empty($invitationData)) {
                 // no invitations available for review (anymore)
                 UI::redirectToURL(URL::toDashboard());
             } else {
                 // edits available to review
                 Time::init();
                 $form = new UI_Form(htmlspecialchars($currentPageURL), false);
                 $table = new UI_Table(array('', ''));
                 $table->setColumnPriorities(6, 6);
                 $buttonAccept = new UI_Form_Button('Accept', UI_Link::TYPE_SUCCESS, UI_Form_Button::ACTION_SUBMIT, 'invitations[accept]', Repository::INVITATION_ACCEPTED);
                 $buttonDecline = new UI_Form_Button('Decline', UI_Link::TYPE_WARNING, UI_Form_Button::ACTION_SUBMIT, 'invitations[accept]', Repository::INVITATION_DECLINED);
                 $actionButtons = new UI_Form_ButtonGroup(array($buttonAccept, $buttonDecline), true);
                 $invitationRoleSelect = new UI_Form_Select('', 'invitations[role]', '', false, '', '', '', true);
                 $invitationRoleSelect->addOption(Repository::getRoleName(Repository::ROLE_CONTRIBUTOR), Repository::ROLE_CONTRIBUTOR);
                 $invitationRoleSelect->addOption(Repository::getRoleName(Repository::ROLE_MODERATOR), Repository::ROLE_MODERATOR);
                 $invitationRoleSelect->addOption(Repository::getRoleName(Repository::ROLE_DEVELOPER), Repository::ROLE_DEVELOPER);
                 $invitationRoleSelect->addOption(Repository::getRoleName(Repository::ROLE_ADMINISTRATOR), Repository::ROLE_ADMINISTRATOR);
                 $table->addRow(array('<strong>Assigned role</strong>', $invitationRoleSelect->getHTML()));
                 $table->addRow(array('<strong>Username</strong>', htmlspecialchars($invitationData[0]['username'])));
                 $table->addRow(array('<strong>Real name</strong>', empty($invitationData[0]['real_name']) ? '&mdash;' : htmlspecialchars($invitationData[0]['real_name'])));
                 $table->addRow(array('<strong>Country</strong>', empty($invitationData[0]['localeCountry']) ? '&mdash;' : Time::getCountryName($invitationData[0]['localeCountry'], '&mdash;')));
                 $table->addRow(array('<strong>Request date</strong>', date('d.m.Y H:i', $invitationData[0]['request_time'])));
                 $table->addRow(array('<strong>Sign-up date</strong>', date('d.m.Y H:i', $invitationData[0]['join_date'])));
                 $table->addRow(array('<strong>Last sign-in</strong>', date('d.m.Y H:i', $invitationData[0]['last_login'])));
                 $form->addContent(new UI_Form_Hidden('invitations[userID]', URL::encodeID($invitationData[0]['userID'])));
                 $form->addContent($actionButtons);
                 $form->addContent($table);
                 $form->addContent($actionButtons);
                 $contents[] = $form;
             }
         }
     }
     $cell = new UI_Cell($contents);
     $row = new UI_Row(array($cell));
     $containers[] = new UI_Container(array($row));
     return new UI_Group($containers);
 }