public function create() { try { $this->db = fORMDatabase::retrieve(); $this->db->query('BEGIN'); $profile = new Profile(); $profile->setLoginName(UserHelper::getName()); $profile->setDisplayName(UserHelper::getDisplayName()); $profile->setStartYear(fRequest::get('start_year')); $profile->setClassNumber(fRequest::get('class_number')); $profile->setStudentNumber(trim(fRequest::get('student_number'))); if (strlen($profile->getStudentNumber()) && !preg_match('/^\\d{10}$/', $profile->getStudentNumber())) { throw new fValidationException('学号必须为10位数字'); } $profile->setBirthday(trim(fRequest::get('birthday'))); $profile->setGender(fRequest::get('gender')); //$profile->setLocation(trim(fRequest::get('location'))); $province = trim(fRequest::get('province')); $city = trim(fRequest::get('city')); $profile->setLocation(self::formatLocation($province, $city)); $profile->setPostNumber(trim(fRequest::get('post_number'))); $profile->setSubscription(trim(fRequest::get('subscription'))); $profile->setAdvices(trim(fRequest::get('advices'))); $profile->setPrivacyControl(trim(fRequest::get('privacy', 'int', 0))); $profile->setField(trim(fRequest::get('field'))); $profile->setInstitute(trim(fRequest::get('institute'))); $profile->setPosition(trim(fRequest::get('position'))); $profile->setMajor(trim(fRequest::get('major'))); $profile->setMentor(trim(fRequest::get('mentor'))); $profile->setCreatedAt(Util::currentTime()); $profile->store(); foreach ($this->contact_types as $type) { if (strlen(trim(fRequest::get($type)))) { $contact = new Contact(); $contact->setProfileId($profile->getId()); $contact->setType($type); $contact->setContent(trim(fRequest::get($type))); $contact->setCreatedAt(Util::currentTime()); $contact->store(); } } $this->db->query('COMMIT'); Activity::fireNewProfile(); $this->ajaxReturn(array('result' => 'success', 'profile_id' => $profile->getId())); } catch (fException $e) { if (isset($this->db)) { $this->db->query('ROLLBACK'); } $this->ajaxReturn(array('result' => 'failure', 'message' => $e->getMessage())); } }
/** * This function never fails. */ protected static function fire($type) { try { $activity = new Activity(); try { $activity->setProfileId(UserHelper::getProfileId()); } catch (fException $e) { $activity->setProfileId(NULL); } $activity->setRealname(UserHelper::getDisplayName()); $activity->setType($type); $activity->store(); } catch (Exception $e) { // do nothing } }
/** * Display the list of people monitoring the package with the delete form * * @param Integer $fileModuleId Id of the package * @param UserManager $um UserManager instance * @param UserHelper $userHelper UserHelper instance * * @return String */ public function getMonitoringListHTML($fileModuleId, $um, $userHelper) { $editContent = '<h3>' . $GLOBALS['Language']->getText('file_filemodule_monitor', 'monitoring_people_title') . '</h3>'; $list = $this->whoIsPubliclyMonitoringPackage($fileModuleId); $totalCount = count($this->getFilesModuleMonitorFromDb($fileModuleId)); $count = $totalCount - count($this->whoIsPubliclyMonitoringPackage($fileModuleId)); if ($list->rowCount() == 0) { $editContent .= $GLOBALS['Language']->getText('file_filemodule_monitor', 'users_monitor', $count) . '<br />'; $editContent .= $GLOBALS['Language']->getText('file_filemodule_monitor', 'no_list'); } else { $editContent .= '<form id="filemodule_monitor_form_delete" method="post" >'; $editContent .= '<input type="hidden" name="action" value="delete_monitoring">'; $editContent .= html_build_list_table_top(array($GLOBALS['Language']->getText('file_filemodule_monitor', 'user'), $GLOBALS['Language']->getText('global', 'delete') . '?'), false, false, false); $rowBgColor = 0; foreach ($list as $entry) { $user = $um->getUserById($entry['user_id']); $editContent .= '<tr class="' . html_get_alt_row_color(++$rowBgColor) . '"><td>' . $userHelper->getDisplayName($user->getName(), $user->getRealName()) . '</td><td><input type="checkbox" name="delete_user[]" value="' . $entry['user_id'] . '" /></td></tr>'; } $editContent .= '<tr class="' . html_get_alt_row_color(++$rowBgColor) . '"><td>' . $GLOBALS['Language']->getText('file_filemodule_monitor', 'users_monitor', $count) . '</td><td></td></tr>'; $editContent .= '<tr class="' . html_get_alt_row_color(++$rowBgColor) . '"><td>' . $GLOBALS['Language']->getText('global', 'total') . ': ' . $totalCount . '</td><td><input id="filemodule_monitor_submit" type="submit" value="' . $GLOBALS['Language']->getText('global', 'delete') . '" /></td></tr>'; $editContent .= '</table>'; $editContent .= '</form>'; } return $editContent; }
echo ' </TD><TD> </TD><TD width=50%>'; $HTML->box1_top($Language->getText('project_admin_editugroup', 'proj_members') . " " . help_button('project-admin.html#user-permissions')); /* Show the members of this project */ $sql = "SELECT user.realname, user.user_id, user.user_name, user.status, IF(generic_user.group_id, 1, 0) AS is_generic\n FROM user_group\n INNER JOIN user ON (user.user_id = user_group.user_id)\n LEFT JOIN generic_user ON (\n generic_user.user_id = user.user_id AND\n generic_user.group_id = {$group_id})\n WHERE user_group.group_id = {$group_id}\n ORDER BY user.realname"; $res_memb = db_query($sql); print '<div style="max-height:200px; overflow:auto;">'; print '<TABLE WIDTH="100%" BORDER="0">'; $user_helper = new UserHelper(); while ($row_memb = db_fetch_array($res_memb)) { $display_name = ''; $em->processEvent('get_user_display_name', array('user_id' => $row_memb['user_id'], 'user_name' => $row_memb['user_name'], 'realname' => $row_memb['realname'], 'user_display_name' => &$display_name)); if (!$display_name) { $display_name = $hp->purify($user_helper->getDisplayName($row_memb['user_name'], $row_memb['realname'])); } $edit_settings = ''; if ($row_memb['is_generic']) { $url = '/project/admin/editgenericmember.php?group_id=' . $group_id; $title = $GLOBALS['Language']->getText('project_admin', 'edit_generic_user_settings'); $edit_settings = '<a href="' . $url . '" title="' . $title . '">'; $edit_settings .= $GLOBALS['HTML']->getImage('ic/edit.png'); $edit_settings .= '</a>'; } print '<FORM ACTION="?" METHOD="POST"><INPUT TYPE="HIDDEN" NAME="func" VALUE="rmuser">' . '<INPUT TYPE="HIDDEN" NAME="rm_id" VALUE="' . $row_memb['user_id'] . '">' . '<INPUT TYPE="HIDDEN" NAME="group_id" VALUE="' . $group_id . '">' . '<TR><TD class="delete-project-member"><INPUT TYPE="IMAGE" NAME="DELETE" SRC="' . util_get_image_theme("ic/trash.png") . '" HEIGHT="16" WIDTH="16" BORDER="0"></TD></FORM>' . '<TD><A href="/users/' . $row_memb['user_name'] . '/">' . $display_name . ' </A>' . $edit_settings . '</TD></TR>'; } print '</TABLE></div> <HR NoShade SIZE="1">'; /* Add member form */
<div style="text-align:right;padding-right:20px;"> <?php if (fAuthorization::checkLoggedIn()) { ?> <?php if (UserHelper::hasProfile()) { $profile_link = SITE_BASE . '/profile/' . UserHelper::getProfileId(); } else { $profile_link = SITE_BASE . '/profiles/new'; } ?> Hi, <a href="<?php echo $profile_link; ?> "><?php echo htmlspecialchars(UserHelper::getDisplayName()); ?> </a> | <?php if (UserHelper::isEditor()) { ?> <a href="<?php echo SITE_BASE; ?> /manage">管理</a> | <?php } ?> <a href="<?php echo SITE_BASE; ?>
/** * Show list of people monitoring the document directly or indirectly by monitoring one of the parents and its subitems * * @param Integer $itemId Id of the document * * @return String */ function displayListeningUsers($itemId) { $dpm = Docman_PermissionsManager::instance($this->item->getGroupId()); $userHelper = new UserHelper(); $um = UserManager::instance(); $content = ''; if ($dpm->userCanManage($um->getCurrentUser(), $itemId)) { $listeners = $this->notificationsManager->getListeningUsers($this->item); if (!empty($listeners)) { $content .= '<fieldset><legend>' . $GLOBALS['Language']->getText('plugin_docman', 'details_listeners') . '</legend>'; $content .= '<form name="remove_monitoring" method="POST" action="">'; $content .= '<input type="hidden" name="action" value="remove_monitoring" />'; $content .= '<table><tr><td>'; $content .= html_build_list_table_top(array($GLOBALS['Language']->getText('people_viewprofile', 'user_name'), $GLOBALS['Language']->getText('plugin_docman', 'details_notifications_monitored_doc'), $GLOBALS['Language']->getText('docman_doc_utils', 'delete_ask')), false, false, false); $rowBgColor = 0; $hp = Codendi_HTMLPurifier::instance(); foreach ($listeners as $userId => $item) { $content .= '<tr class="' . html_get_alt_row_color(++$rowBgColor) . '">'; $user = $um->getUserById($userId); $content .= '<td>' . $userHelper->getDisplayName($user->getName(), $user->getRealName()) . '</td>'; $content .= '<td>' . $item->getTitle() . '</td><td>'; if ($this->item == $item) { $content .= '<input type="checkbox" value="' . $userId . '" name="listeners_to_delete[]">'; } else { $content .= '<input type="checkbox" value="' . $userId . '" name="listeners_to_delete[]" disabled="disabled">'; } $content .= '</td></tr>'; } // TODO : ask user if he wants or not to notify the users he remove // TODO : We may ask him also if his name will appear as the guilty one or not $content .= '<td colspan="2"><input type="submit" value="' . $GLOBALS['Language']->getText('plugin_docman', 'action_delete') . '"></td></tr>'; $content .= '</tbody></table></form>'; $content .= '</td><td><div class="docman_help">' . $GLOBALS['Language']->getText('plugin_docman', 'details_notifications_help') . '</div></td></tr>'; } $content .= $this->addListeningUser($itemId); $content .= '</table></fieldset>'; } return $content; }
echo $head; $i = 0; function userperms_add_cell($user_name, $cell) { global $k; if ($k++ % 10 == 0) { echo '<td>' . $user_name . '</td>'; } echo $cell; } $uh = new UserHelper(); $hp = Codendi_HTMLPurifier::instance(); while ($row_dev = db_fetch_array($res_dev)) { $i++; print '<TR class="' . util_get_alt_row_color($i) . '">'; $user_name = $hp->purify($uh->getDisplayName($row_dev['user_name'], $row_dev['realname']), CODENDI_PURIFIER_CONVERT_HTML); echo '<td><a name="' . ucfirst(substr($row_dev['user_name'], 0, 1)) . '"></a>' . $user_name . '</td>'; echo ' <TD> <INPUT TYPE="RADIO" NAME="admin_user_' . $row_dev['user_id'] . '" VALUE="A" ' . ($row_dev['admin_flags'] == 'A' ? 'CHECKED' : '') . '> ' . $Language->getText('global', 'yes') . '<BR> <INPUT TYPE="RADIO" NAME="admin_user_' . $row_dev['user_id'] . '" VALUE="" ' . ($row_dev['admin_flags'] == '' ? 'CHECKED' : '') . '> ' . $Language->getText('global', 'no') . ' </TD>'; if ($project->usesCVS()) { echo '<TD>' . $Language->getText('global', 'yes') . '</TD>'; } // svn if ($project->usesSVN()) { $cell = ''; $cell .= '<TD><SELECT name="svn_user_' . $row_dev['user_id'] . '">'; $cell .= '<OPTION value="0"' . ($row_dev['svn_flags'] == 0 ? " selected" : "") . '>' . $Language->getText('global', 'none'); $cell .= '<OPTION value="2"' . ($row_dev['svn_flags'] == 2 ? " selected" : "") . '>' . $Language->getText('project_admin_index', 'admin');