예제 #1
0
 public function getAdminUI()
 {
     $db = AbstractDb::getObject();
     $currentUser = self::getCurrentUser();
     $userPreferencesItems = array();
     $finalHtml = '';
     if (Security::hasPermission(Permission::P('NETWORK_PERM_VIEW_STATISTICS'), $this->getNetwork())) {
         /* Statistics */
         $content = "<a href='" . BASE_SSL_PATH . "admin/stats.php?Statistics=" . $this->getNetwork()->getId() . "&distinguish_users_by=user_id&stats_selected_users=" . $this->getUsername() . "&UserReport=on&user_id=" . $this->getId() . "&action=generate'>" . _("Get user statistics") . "</a>\n";
         $administrationItems[] = InterfaceElements::genSectionItem($content);
         /* Account status */
         $title = _("Account Status");
         $help = _("Note that Error is for internal use only");
         $name = "user_" . $this->getId() . "_accountstatus";
         global $account_status_to_text;
         $content = FormSelectGenerator::generateFromKeyLabelArray($account_status_to_text, $this->getAccountStatus(), $name, null, false);
         $administrationItems[] = InterfaceElements::genSectionItem($content, $title, $help);
         $finalHtml .= InterfaceElements::genSection($administrationItems, _("Administrative options"));
     }
     if ($this == $currentUser && !$this->isSplashOnlyUser() || Security::hasPermission(Permission::P('NETWORK_PERM_EDIT_ANY_USER'), $this->getNetwork())) {
         /* Username */
         $title = _("Username");
         $name = "user_" . $this->getId() . "_username";
         $content = "<input type='text' name='{$name}' value='" . htmlentities($this->getUsername()) . "' size=30><br/>\n";
         $content .= _("Be careful when changing this: it's the username you use to log in!");
         $userPreferencesItems[] = InterfaceElements::genSectionItem($content, $title);
         /* Email */
         $title = _("Email");
         $name = "email_" . $this->getId() . "_email";
         $content = "<input type='text' name='{$name}' disabled='disabled' value='" . htmlentities($this->getEmail()) . "' size=30><br/>\n";
         $content .= _("If you wish to change this address, please Email Support!");
         $userPreferencesItems[] = InterfaceElements::genSectionItem($content, $title);
         /* Change password */
         $changePasswordItems = array();
         if ($this == $currentUser) {
             //Don't enter the old password if changing password for another user
             $title = _("Your current password");
             $name = "user_" . $this->getId() . "_oldpassword";
             $content = "<input type='password' name='{$name}' size='20'>\n";
             $changePasswordItems[] = InterfaceElements::genSectionItem($content, $title);
         }
         $title = _("Your new password");
         $name = "user_" . $this->getId() . "_newpassword";
         $content = "<input type='password' name='{$name}' size='20'>\n";
         $changePasswordItems[] = InterfaceElements::genSectionItem($content, $title);
         $title = _("Your new password (again)");
         $name = "user_" . $this->getId() . "_newpassword_again";
         $content = "<input type='password' name='{$name}' size='20'>\n";
         $changePasswordItems[] = InterfaceElements::genSectionItem($content, $title);
         $userPreferencesItems[] = InterfaceElements::genSection($changePasswordItems, _("Change my password"));
         $finalHtml .= InterfaceElements::genSection($userPreferencesItems, _("User preferences"), false, false, get_class($this));
         //N.B: For now, let pretend we have only one profile per use...
         $profiles = $this->getAllProfiles();
         $current_profile = null;
         if (!empty($profiles)) {
             $current_profile = $profiles[0];
         }
         if ($current_profile != null) {
             $finalHtml .= $current_profile->getAdminUI();
             $name = "user_" . $this->getId() . "_delete_profile_" . $current_profile->getId();
             $value = _("Completely delete my public profile");
             $finalHtml .= "<div class='admin_element_tools'>";
             $finalHtml .= '<input type="submit" class="submit" name="' . $name . '" value="' . $value . '">';
             $finalHtml .= "</div>";
         } else {
             // Get the list of profile templates for the users' network
             $profile_templates = ProfileTemplate::getAllProfileTemplates($this->getNetwork());
             if (!empty($profile_templates)) {
                 $name = "user_" . $this->getId() . "_add_profile";
                 $value = _("Create my public profile");
                 $finalHtml .= "<div class='admin_element_tools'>";
                 $finalHtml .= '<input type="submit" class="submit" name="' . $name . '" value="' . $value . '">';
                 $finalHtml .= "</div>";
             }
         }
     }
     return $finalHtml;
 }
예제 #2
0
 /**
  * Retreives the admin interface of this object
  *
  * @return string The HTML fragment for this interface
  */
 public function getAdminUI()
 {
     // Init values
     $html = '';
     // All sections
     $profileSections = array();
     // Metadata section
     $profileMetadataItems = array();
     //  is_visible
     $title = _("Should this profile be publicly visible?");
     $name = "profile_" . $this->getId() . "_is_visible";
     $data = InterfaceElements::generateInputCheckbox($name, "", _("Yes"), $this->isVisible(), "profile_is_visible_radio");
     $profileMetadataItems[] = InterfaceElements::genSectionItem($data, $title);
     $profileSections[] = InterfaceElements::genSection($profileMetadataItems, _("Profile preferences"));
     // Fields section
     $profileFieldsUI = array();
     $template = $this->getTemplate();
     // Aggregate the fields UI
     $profileFields = $this->getFields();
     //var_dump($profileFields);
     foreach ($template->getFields() as $templateField) {
         //var_dump($templateField);
         if (!empty($profileFields[$templateField->getId()])) {
             //We already have a real field instanciated
             $field = $profileFields[$templateField->getId()];
             //var_dump($field);
             $profileFieldsUI[] = InterfaceElements::genSectionItem($field->getAdminUI());
         } else {
             //show the template admin UI
             //$profileFieldsUI[] = InterfaceElements::genSectionItem($templateField->getUserUI());
             // Init values
             $tmp_html = '';
             $admin_label = $templateField->getAdminLabelContent();
             if ($admin_label != null) {
                 $title = $admin_label->__toString();
             } else {
                 $title = null;
             }
             $tmp_html .= "<fieldset class='admin_container " . get_class($this) . "'>\n";
             if (!empty($title)) {
                 $tmp_html .= "<legend>{$title}</legend>\n";
             }
             $futureProfileFieldId = get_guid();
             $name = "profile_template_field_{$templateField->getId()}_field_future_id";
             $tmp_html .= '<input type="hidden" name="' . $name . '" value="' . $futureProfileFieldId . '">';
             $userData['contentTypeFilter'] = $templateField->getContentTypeFilter();
             //echo "Profile::getAdminUI: userData";pretty_print_r($userData);
             $tmp_html .= ProfileField::getNewUI($futureProfileFieldId, $userData);
             $tmp_html .= "</fieldset>\n";
             $profileFieldsUI[] = $tmp_html;
         }
     }
     $profileSections[] = InterfaceElements::genSection($profileFieldsUI, _("Profile fields"));
     $html .= InterfaceElements::genSection($profileSections, _("Profile"), false, false, get_class($this));
     return $html;
 }