public function getContent() { $request =& HTTPRequest::instance(); $group_id = $request->get('group_id'); $pm = ProjectManager::instance(); $project = $pm->getProject($group_id); $res_admin = db_query("SELECT user.user_id AS user_id,user.user_name AS user_name, user.realname as realname " . "FROM user,user_group " . "WHERE user_group.user_id=user.user_id AND user_group.group_id=" . db_ei($group_id) . " AND " . "user_group.admin_flags = 'A'"); if (db_numrows($res_admin) > 0) { $user_helper = UserHelper::instance(); $hp = Codendi_HTMLPurifier::instance(); $em = EventManager::instance(); echo '<span class="develtitle">' . $GLOBALS['Language']->getText('include_project_home', 'proj_admins') . ':</span><br />'; while ($row_admin = db_fetch_array($res_admin)) { $display_name = ''; $em->processEvent('get_user_display_name', array('user_id' => $row_admin['user_id'], 'user_name' => $row_admin['user_name'], 'realname' => $row_admin['realname'], 'user_display_name' => &$display_name)); if (!$display_name) { $display_name = $hp->purify($user_helper->getDisplayNameFromUserId($row_admin['user_id'])); } echo '<a href="/users/' . $row_admin['user_name'] . '/">' . $display_name . '</a><br />'; } } echo '<span class="develtitle">' . $GLOBALS['Language']->getText('include_project_home', 'proj_members') . ':</span><br />'; // count of developers on this project $res_count = db_query("SELECT user_id FROM user_group WHERE group_id=" . db_ei($group_id)); echo db_numrows($res_count); echo ' <a href="/project/memberlist.php?group_id=' . $group_id . '">[' . $GLOBALS['Language']->getText('include_project_home', 'view_members') . ']</a>'; }
function getTable($params) { $this->defaultUrl = $params['default_url']; $content = ''; $content .= html_build_list_table_top(array($GLOBALS['Language']->getText('plugin_docman', 'view_documenttable_title'), $GLOBALS['Language']->getText('plugin_docman', 'view_documenttable_location'), $GLOBALS['Language']->getText('plugin_docman', 'admin_lock_infos_who'), $GLOBALS['Language']->getText('plugin_docman', 'admin_lock_infos_when'))); // Get list of all locked documents in the project. $dPM = Docman_PermissionsManager::instance($params['group_id']); $lockInfos = $dPM->getLockFactory()->getProjectLockInfos($params['group_id']); $uH = UserHelper::instance(); $hp = Codendi_HTMLPurifier::instance(); require_once dirname(__FILE__) . '/../Docman_ItemFactory.class.php'; $dIF = new Docman_ItemFactory($params['group_id']); $altRowClass = 0; foreach ($lockInfos as $row) { $trclass = html_get_alt_row_color($altRowClass++); $item = $dIF->getItemFromDb($row['item_id']); $parent = $dIF->getItemFromDb($item->getParentId()); $content .= '<tr class="' . $trclass . '">'; $content .= '<td>' . '<a href="/plugins/docman/?group_id=' . $params['group_id'] . '&action=details&id=' . $item->getId() . '">' . $item->getTitle() . '</a></td>'; $content .= '<td>'; if ($dIF->isRoot($parent)) { $content .= '</td>'; } else { $content .= '<a href="' . $this->defaultUrl . '&action=show&id=' . $parent->getId() . '">' . $parent->getTitle() . '</a></td>'; } $content .= '<td>' . $hp->purify($uH->getDisplayNameFromUserId($row['user_id'])) . '</td>'; $content .= '<td>' . format_date($GLOBALS['Language']->getText('system', 'datefmt'), $row['lock_date']) . '</td>'; $content .= '</tr>'; } $content .= '</table>'; return $content; }
public function __construct($default = array()) { parent::__construct($default); // init vars $this->joomla = JFactory::getApplication(); $this->user = JFactory::getUser(); $this->session = JFactory::getSession(); $this->document = JFactory::getDocument(); $this->dispatcher = JDispatcher::getInstance(); $this->option = YRequest::getCmd('option'); $this->link_base = 'index.php?option=' . $this->option; $this->controller = $this->getName(); // add super administrator var to user $this->user->superadmin = UserHelper::isJoomlaSuperAdmin($this->user); // init additional admin vars if ($this->joomla->isAdmin()) { $this->baseurl = 'index.php?option=' . $this->option . '&controller=' . $this->getName(); } // init additional site vars if ($this->joomla->isSite()) { $this->itemid = (int) $GLOBALS['Itemid']; $this->params = $this->joomla->getParams(); $this->pathway = $this->joomla->getPathway(); } }
function getContent() { $html = ''; $i = 1; $UH = UserHelper::instance(); $hp = Codendi_HTMLPurifier::instance(); while ($data = db_fetch_array($this->getLatestRevisions())) { $html .= '<div class="' . util_get_alt_row_color($i++) . '" style="border-bottom:1px solid #ddd">'; $html .= '<div style="font-size:0.98em;">'; $html .= '<a href="' . $this->_getLinkToCommit($data) . '">#' . $data['revision'] . '</a>'; $html .= ' by '; if (isset($data['whoid'])) { $name = $UH->getDisplayNameFromUserId($data['whoid']); } else { $name = $UH->getDisplayNameFromUserName($data['who']); } $html .= $hp->purify($name, CODENDI_PURIFIER_CONVERT_HTML) . ' on '; //In the db, svn dates are stored as int whereas cvs dates are stored as timestamp $html .= format_date($GLOBALS['Language']->getText('system', 'datefmt'), is_numeric($data['date']) ? $data['date'] : strtotime($data['date'])); $html .= '</div>'; $html .= '<div style="padding-left:20px; padding-bottom:4px; color:#555">'; $html .= util_make_links(substr($data['description'], 0, 255), $this->group_id); if (strlen($data['description']) > 255) { $html .= ' [...]'; } $html .= '</div>'; $html .= '</div>'; } $html .= '<div style="text-align:center" class="' . util_get_alt_row_color($i++) . '">'; $html .= '<a href="' . $this->_getLinkToMore() . '">[ More ]</a>'; $html .= '</div>'; return $html; }
public function show() { $this->editable = UserHelper::isEditor(); $cons = array(); $field = trim(fRequest::get('field')); $start_year = trim(fRequest::get('start_year')); $major = trim(fRequest::get('major')); $location = trim(fRequest::get('location')); $words = trim(fRequest::get('words')); $cons['login_name|display_name~'] = $words; if (!empty($field)) { $cons['field='] = $field; } if (!empty($start_year)) { $cons['start_year='] = $start_year; } if (!empty($major)) { $cons['major='] = $major; } if (!empty($location)) { $cons['location~'] = $location; } $this->users = fRecordSet::build('Profile', $cons, array('id' => 'asc')); $this->field = $field; $this->start_year = $start_year; $this->major = $major; $this->location = $location; $this->words = $words; $this->render('search/index'); }
/** * Before we do anything, check to see if the user is an admin. If it's * an un-auth'd call, log the user info (if they are logged in as a non-admin), * and the IP address */ public function __construct() { parent::__construct(); if (!UserHelper::isAdmin()) { log_message('error', "Attempted unauthorized access to admin section: " . UserHelper::getEmail() . '-' . UserHelper::getId() . '-' . $this->input->ip_address()); show_error("You do not have permission to access this resource. This has been logged."); } }
/** * * @return UserHelper */ public static function instance() { if (!isset(self::$_instance)) { $c = __CLASS__; self::$_instance = new $c(); } return self::$_instance; }
/** * An ajax call to get the current logged-in-user's profile page when logged in. * Loaded via ajax so the front page can be cached easily * Loads a login box if the user is not logged in, and a profile * box if they are */ public function get_profile_box() { if (UserHelper::isLoggedIn()) { $this->load->view('global/_profile_box'); } else { $this->load->view('global/_login_form'); } }
public function process() { $this->validate(); if (!$this->hasErrors()) { if (($model = Yii::app()->getUser()->getModel()) !== null) { return $model->saveAttributes(array('password' => UserHelper::encryptPassword($this->newPassword))); } } return false; }
function check() { if (config_item('is_maintanence')) { $CI =& get_instance(); $is_admin = in_array(UserHelper::getUsername(), config_item('admin_users')); if (!$is_admin && !($CI->uri->segment(1) == 'login')) { die('Hang on a bit while we upgrade the site :)'); } } }
/** * Performs social login. * * @param string $provider The name of the social network. */ public function actionSocial($provider) { if (Yii::app()->hasModule('social') && Yii::app()->hasModule('registration')) { /* social and registration modules are loaded */ Yii::import('application.modules.social.models.*'); Yii::import('application.modules.social.components.*'); try { $provider_params = array('redirect_uri' => 'http://' . $_SERVER['HTTP_HOST'] . Yii::app()->request->requestUri); $p = ProviderManager::getInstance($provider, $provider_params); if (isset($p)) { $result = $p->isAuthorized(); $user = null; if ($result['success']) { // app authorized if (!isset(Yii::app()->session['registration_user_id'])) { if ($result['registration_required']) { $user = UserHelper::createAccount($result['user_data']['social_email'], null, null, true, false, false); $p->setSession($result['user_data']); $p->storeOauthData($user->id, $result['user_data']); } else { $user = User::model()->findByPk($result['user_id']); $identity = new SocialUserIdentity($result['user_id'], $result['user_data']); $identity->authenticate(); $p->storeOauthData($result['user_id'], $result['user_data']); } } else { $user = User::model()->findByPk(Yii::app()->session['registration_user_id']); if (isset($user)) { $p->setSession($result['user_data']); $p->storeOauthData($user->id, $result['user_data']); } } $p->pullData($result['user_data']['social_oauth_id'], $result['user_data']['social_oauth_token'], $user); if (isset(Yii::app()->session['registration_user_id'])) { $this->redirect(Yii::app()->createUrl('registration')); } else { if ($result['registration_required']) { $this->redirect(Yii::app()->createUrl('registration')); } else { $this->redirect(Yii::app()->baseUrl); } } } else { // app not authorized $this->redirect($result['url']); } } } catch (Exception $ex) { $this->redirect(Yii::app()->createUrl('users')); } } else { /* modules are not loaded */ $this->redirect(Yii::app()->createUrl('users')); } }
public function getContent() { $html = ''; $uh = UserHelper::instance(); $request = HTTPRequest::instance(); $hp = Codendi_HTMLPurifier::instance(); $user = UserManager::instance()->getCurrentUser(); $pm = ProjectManager::instance(); $project_ids = $user->getProjects(); foreach ($project_ids as $project_id) { $project = $pm->getProject($project_id); if ($project->usesSVN()) { list($hide_now, $count_diff, $hide_url) = my_hide_url('my_svn_group', $project_id, $request->get('hide_item_id'), count($project_ids), $request->get('hide_my_svn_group')); $html .= $hide_url; $html .= '<strong>' . $project->getPublicName() . '</strong>'; if (!$hide_now) { list($latest_revisions, $nb_revisions) = svn_get_revisions($project, 0, $this->_nb_svn_commits, '', $user->getUserName(), '', '', 0, false); if (db_numrows($latest_revisions) > 0) { $i = 0; while ($data = db_fetch_array($latest_revisions)) { $html .= '<div class="' . util_get_alt_row_color($i++) . '" style="border-bottom:1px solid #ddd">'; $html .= '<div style="font-size:0.98em;">'; $html .= '<a href="' . $this->_getLinkToCommit($project->getGroupId(), $data['revision']) . '">rev #' . $data['revision'] . '</a>'; $html .= ' ' . $GLOBALS['Language']->getText('my_index', 'my_latest_svn_commit_on') . ' '; //In the db, svn dates are stored as int whereas cvs dates are stored as timestamp $html .= format_date($GLOBALS['Language']->getText('system', 'datefmt'), is_numeric($data['date']) ? $data['date'] : strtotime($data['date'])); $html .= ' ' . $GLOBALS['Language']->getText('my_index', 'my_latest_svn_commit_by') . ' '; if (isset($data['whoid'])) { $name = $uh->getDisplayNameFromUserId($data['whoid']); } else { $name = $uh->getDisplayNameFromUserName($data['who']); } $html .= $hp->purify($name, CODENDI_PURIFIER_CONVERT_HTML); $html .= '</div>'; $html .= '<div style="padding-left:20px; padding-bottom:4px; color:#555">'; $html .= util_make_links(substr($data['description'], 0, 255), $project->getGroupId()); if (strlen($data['description']) > 255) { $html .= ' [...]'; } $html .= '</div>'; $html .= '</div>'; } $html .= '<div style="text-align:center" class="' . util_get_alt_row_color($i++) . '">'; $html .= '<a href="' . $this->_getLinkToMore($project->getGroupId(), $user->getUserName()) . '">[ More ]</a>'; $html .= '</div>'; } else { $html .= '<div></div>'; } } else { $html .= '<div></div>'; } } } return $html; }
function getContent() { $content = ''; $uh = UserHelper::instance(); if (is_a($this->item, 'Docman_File')) { $content .= '<h3>' . $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions') . '</h3>'; $version_factory =& new Docman_VersionFactory(); $approvalFactory =& Docman_ApprovalTableFactory::getFromItem($this->item); if ($versions = $version_factory->getAllVersionForItem($this->item)) { if (count($versions)) { $titles = array(); $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_version'); $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_date'); $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_author'); $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_label'); $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_changelog'); $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_approval'); $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_delete_version'); $content .= html_build_list_table_top($titles, false, false, false); $odd_even = array('boxitem', 'boxitemalt'); $i = 0; foreach ($versions as $key => $nop) { $download = Docman_View_View::buildUrl($this->url, array('action' => 'show', 'id' => $this->item->getId(), 'version_number' => $versions[$key]->getNumber())); $delete = Docman_View_View::buildUrl($this->url, array('action' => 'confirmDelete', 'id' => $this->item->getId(), 'version' => $versions[$key]->getNumber())); $user = $versions[$key]->getAuthorId() ? $uh->getDisplayNameFromUserId($versions[$key]->getAuthorId()) : $GLOBALS['Language']->getText('plugin_docman', 'details_history_anonymous'); $content .= '<tr class="' . $odd_even[$i++ % count($odd_even)] . '">'; $content .= '<td align="center"><a href="' . $download . '">' . $versions[$key]->getNumber() . '</a></td>'; $content .= '<td>' . html_time_ago($versions[$key]->getDate()) . '</td>'; $content .= '<td>' . $this->hp->purify($user) . '</td>'; $content .= '<td>' . $this->hp->purify($versions[$key]->getLabel()) . '</td>'; $content .= '<td>' . $this->hp->purify($versions[$key]->getChangelog(), CODENDI_PURIFIER_LIGHT) . '</td>'; $table = $approvalFactory->getTableFromVersion($versions[$key]); if ($table != null) { $appTable = Docman_View_View::buildUrl($this->url, array('action' => 'details', 'section' => 'approval', 'id' => $this->item->getId(), 'version' => $versions[$key]->getNumber())); $content .= '<td align="center"><a href="' . $appTable . '">' . ($titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_approval_show') . '</a></td>'); } else { $content .= '<td></td>'; } $content .= '<td align="center"><a href="' . $delete . '"><img src="' . util_get_image_theme("ic/trash.png") . '" height="16" width="16" border="0"></a></td>'; $content .= '</tr>'; } $content .= '</table>'; } else { $content .= '<div>' . $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_no') . '</div>'; } } else { $content .= '<div>' . $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_error') . '</div>'; } } if ($this->logger) { $content .= $this->logger->fetchLogsForItem($this->item->getId(), $this->display_access_logs); } return $content; }
private function getNick() { $pUin = Utils::GetCookie('p_uin'); $pUin = intval($pUin); $ret = UserHelper::getUserInfo($pUin); if (!empty($ret)) { return $ret[$pUin]["nick_name"]; } else { return "腾讯网友"; } }
/** * Formats a password using the current encryption. * * @param string $plaintext The plaintext password to encrypt. * @param string $salt The salt to use to encrypt the password. [] * If not present, a new salt will be * generated. * @param string $encryption The kind of password encryption to use. * Defaults to md5-hex. * @param boolean $show_encrypt Some password systems prepend the kind of * encryption to the crypted password ({SHA}, * etc). Defaults to false. * * @return string The encrypted password. * * @since 11.1 */ public static function getCryptedPassword($plaintext, $salt = '', $encryption = 'md5-hex', $show_encrypt = false) { // Get the salt to use. $salt = UserHelper::getSalt($encryption, $salt, $plaintext); // Encrypt the password. switch ($encryption) { case 'md5-hex': default: $encrypted = $salt ? md5($plaintext . $salt) : md5($plaintext); return $show_encrypt ? '{MD5}' . $encrypted : $encrypted; } }
public function delete($id) { try { $users = new Name($id); if (!UserHelper::isEditor()) { throw new fValidationException('not allowed'); } $users->delete(); $this->ajaxReturn(array('result' => 'success')); } catch (fException $e) { $this->ajaxReturn(array('result' => 'failure', 'message' => $e->getMessage())); } }
public function delete($id) { try { $msg = new Msg($id); if (UserHelper::getProfileId() != $msg->getReceiver() and !UserHelper::isEditor()) { throw new fValidationException('not allowed'); } $msg->delete(); $this->ajaxReturn(array('result' => 'success')); } catch (fException $e) { $this->ajaxReturn(array('result' => 'failure', 'message' => $e->getMessage())); } }
/** * Upload an image file for avatar */ public function upload() { try { if (self::isImage($_FILES['avatar-file']) && move_uploaded_file($_FILES['avatar-file']['tmp_name'], $this->uploadfile)) { fURL::redirect(SITE_BASE . '/avatar/edit'); } else { throw new fValidationException('上传图片失败'); } } catch (Exception $e) { fMessaging::create('failure', 'upload avatar', $e->getMessage()); fURL::redirect(SITE_BASE . '/profile/' . UserHelper::getProfileId()); } }
function getContent() { $html = ''; $dwItemFactory = $this->getDocmanWatermarkItemFactory(); $watermarkingIsDisabled = $dwItemFactory->isWatermarkingDisabled($this->item->getId()); // Status if ($watermarkingIsDisabled) { $status = '<strong>' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_watermarking_disabled') . '</strong>'; } else { $status = $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_watermarking_enabled'); } $html .= '<p>' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_watermarking_status', array($status)) . '</p>'; // About section $html .= '<h2>' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_about_title') . '</h2>'; $html .= '<p>' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_disclamer_pdf') . '</p>'; // Disable/enable section $user = $this->getUserManager()->getCurrentUser(); $dPm = $this->getDocman_PermissionsManager($this->item->getGroupId()); if ($dPm->userCanManage($user, $this->item->getId())) { $html .= '<h2>' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_toggle_title') . '</h2>'; $html .= '<p>' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_watermarking_desc') . '</p>'; $html .= '<p>' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_watermarking_clicktoproceed') . '</p>'; $html .= '<form method="post" action="' . $this->url . '&item_id=' . $this->item->getId() . '&action=docmanwatermark_toggle_item">'; if ($watermarkingIsDisabled) { $html .= '<input type="submit" name="enable_watermarking" value="' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_watermarking_enableit') . '" />'; } else { $html .= '<input type="submit" name="disable_watermarking" value="' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_watermarking_disableit') . '" />'; } $html .= '</form>'; } // History $html .= '<h2>' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_history_title') . '</h2>'; $dwLog = $this->getDocmanWatermark_Log(); $dar = $dwLog->getLog($this->item); if ($dar && $dar->rowCount() > 0) { $uh = UserHelper::instance(); $hp = Codendi_HTMLPurifier::instance(); $titles = array($GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_history_when'), $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_history_who'), $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_history_what')); $html .= html_build_list_table_top($titles, false, false, false); $altColor = 0; foreach ($dar as $logEntry) { $html .= '<tr class="' . html_get_alt_row_color($altColor++) . '">'; $html .= '<td>' . util_timestamp_to_userdateformat($logEntry['time']) . '</td>'; $html .= '<td>' . $hp->purify($uh->getDisplayNameFromUserId($logEntry['who'])) . '</td>'; $html .= '<td>' . ($logEntry['watermarked'] == 0 ? $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_history_desactivate') : $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_history_activate')) . '</td>'; $html .= '</tr>'; } $html .= '</table>'; } return $html; }
/** * Redirect the current user to the login page. After they login or register, * they'll be sent back to $back_to * @param string $back_to The URL to come bak to after login. Default $back_to * is the current URL * @param string $message A message to show on the login page like "Login first, sucka" */ public static function redirectAndComeback($back_to = FALSE, $message = FALSE) { $CI =& get_instance(); # Come back to a diferent page? if (!$back_to) { $back_to = current_url(); } $CI->session->set_userdata('back_to', $back_to); # Set a message if ($message) { UserHelper::setNotice($message); } redirect(base_url() . 'login'); }
public function authenticate() { $user = User::model()->findByPk($this->username); if ($user === null) { $this->errorCode = self::ERROR_ID_NUMBER_INVALID; } else { if ($user->password !== UserHelper::encryptPassword($this->password)) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { $this->_id = $user->uid; $this->errorCode = self::ERROR_NONE; } } return !$this->errorCode; }
public function beforeSave() { if (parent::beforeSave()) { $this->email_address = strtolower($this->email_address); if ($this->getIsNewRecord()) { $this->password = UserHelper::encryptPassword($this->password); $this->deleted = 0; $this->datetime_created = new CDbExpression('now()'); } else { $this->last_modified = new CDbExpression('now()'); } return true; } return false; }
/** * Rate a package */ public function rate($package_name) { $this->load->model('spark'); $this->load->model('rating'); $spark = Spark::getInfo($package_name); if (!$spark) { show_404(); } if ($this->input->post('rating') && UserHelper::isLoggedIn()) { $this->load->model('rating'); $this->rating->rate(UserHelper::getId(), $spark->id, $this->input->post('rating')); } else { $this->error("You are not logged in, or your request was invalid"); } $this->success(array('ratings' => $this->rating->getRatings($spark->id))); }
/** * 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 } }
function snippet_show_package_snippets($version) { global $Language; //show the latest version $sql = "SELECT snippet.snippet_id, snippet_package_item.snippet_version_id, snippet_version.version,snippet.name,user.user_name, snippet_version.filesize " . "FROM snippet,snippet_version,snippet_package_item,user " . "WHERE snippet.snippet_id=snippet_version.snippet_id " . "AND user.user_id=snippet_version.submitted_by " . "AND snippet_version.snippet_version_id=snippet_package_item.snippet_version_id " . "AND snippet_package_item.snippet_package_version_id='{$version}'"; $result = db_query($sql); $rows = db_numrows($result); echo ' <P> <H3>' . $Language->getText('snippet_add_snippet_to_package', 's_in_p') . '</H3> <P>'; $title_arr = array(); $title_arr[] = $Language->getText('snippet_utils', 'version_id'); $title_arr[] = $Language->getText('snippet_details', 's_version'); $title_arr[] = $Language->getText('snippet_browse', 'title'); $title_arr[] = $Language->getText('snippet_details', 'author'); echo html_build_list_table_top($title_arr, $links_arr); if (!$result || $rows < 1) { echo db_error(); echo ' <TR><TD COLSPAN="4"><H3>' . $Language->getText('snippet_add_snippet_to_package', 'no_s_in_p') . '</H3></TD></TR>'; } else { //get the newest version, so we can display it's code $newest_version = db_result($result, 0, 'snippet_version_id'); for ($i = 0; $i < $rows; $i++) { echo ' <TR class="' . util_get_alt_row_color($i) . '"> <TD><A HREF="/snippet/detail.php?type=snippet&id=' . db_result($result, $i, 'snippet_id') . '"><b><center>' . db_result($result, $i, 'snippet_version_id') . '</center></b></A></TD> <TD>'; echo '<A HREF="/snippet/download.php?type=snippet&id=' . db_result($result, $i, 'snippet_version_id') . '"><b><center>' . db_result($result, $i, 'version') . '</b></A>'; // For uploaded files, the user can choose between view or display the code snippet if (db_result($result, $i, 'filesize') != 0) { // View link : the file is forced to be displayed as a text echo ' <a href="/snippet/download.php?mode=view&type=snippet&id=' . db_result($result, $i, 'snippet_version_id') . '">'; echo '<img src="' . util_get_image_theme("ic/view.png") . '" border="0" alt="' . $Language->getText('snippet_details', 'view') . '" title="' . $Language->getText('snippet_details', 'view') . '"></a>'; // Download link : the file is forced to be downloaded echo ' <a href="/snippet/download.php?mode=download&type=snippet&id=' . db_result($result, $i, 'snippet_version_id') . '">'; echo '<img src="' . util_get_image_theme("ic/download.png") . '" border="0" alt="' . $Language->getText('snippet_details', 'download') . '" title="' . $Language->getText('snippet_details', 'download') . '"></a>'; } $user = UserManager::instance()->getUserByUserName(db_result($result, $i, 'user_name')); echo '</center></TD> <TD>' . db_result($result, $i, 'name') . '</TD><TD>' . UserHelper::instance()->getLinkOnUser($user) . '</TD></TR>'; } } echo '</TABLE>'; }
function forum_show_a_nested_message($result, $row = 0) { /* accepts a database result handle to display a single message in the format appropriate for the nested messages second param is which row in that result set to use */ global $Language; $g_id = db_result($result, $row, 'group_id'); if ($g_id == $GLOBALS['sys_news_group']) { $f_id = db_result($result, $row, 'group_forum_id'); $gr = db_query("SELECT group_id FROM news_bytes WHERE forum_id=" . db_ei($f_id)); $g_id = db_result($gr, 0, 'group_id'); } $poster = UserManager::instance()->getUserByUserName(db_result($result, $i, 'user_name')); $ret_val = ' <TABLE BORDER="0" WIDTH="100%"> <TR> <TD class="thread" NOWRAP>' . $Language->getText('forum_forum', 'by') . ': ' . UserHelper::instance()->getLinkOnUser($poster) . '<BR><A HREF="/forum/message.php?msg_id=' . db_result($result, $row, 'msg_id') . '">' . '<IMG SRC="' . util_get_image_theme("msg.png") . '" BORDER=0 HEIGHT=12 WIDTH=10> ' . db_result($result, $row, 'subject') . ' [ ' . $Language->getText('forum_forum', 'reply') . ' ]</A> ' . '<BR>' . format_date($GLOBALS['Language']->getText('system', 'datefmt'), db_result($result, $row, 'date')) . ' </TD> </TR> <TR> <TD> ' . util_make_links(nl2br(db_result($result, $row, 'body')), $g_id) . ' </TD> </TR>'; $crossref_fact = new CrossReferenceFactory(db_result($result, $row, 'msg_id'), ReferenceManager::REFERENCE_NATURE_FORUMMESSAGE, $g_id); $crossref_fact->fetchDatas(); if ($crossref_fact->getNbReferences() > 0) { $ret_val .= '<tr>'; $ret_val .= ' <td class="forum_reference_separator">'; $ret_val .= ' <b> ' . $Language->getText('cross_ref_fact_include', 'references') . '</b>'; $ret_val .= $crossref_fact->getHTMLDisplayCrossRefs(); $ret_val .= ' </td>'; $ret_val .= '</tr>'; } $ret_val .= ' <tr> <td> </td> </tr> </TABLE>'; return $ret_val; }
/** * * @param unknown $model * @return boolean */ protected function performBasicRegistration($model) { $output = false; if (isset($model)) { $email = isset($model->email) ? $model->email : null; if (isset($email)) { if (isset(Yii::app()->session['social_email'])) { $this->_user = UserHelper::createAccount($email, $model->nickname, $model->password, true, true, true, Yii::app()->session['social_email']); } else { $this->_user = UserHelper::createAccount($email, $model->nickname, $model->password); } Yii::app()->session['registration_user_id'] = $this->_user->id; Yii::app()->session['registration_user_email'] = $email; $output = isset($this->_user->id); } } return $output; }
/** * The search page call */ function index() { $this->load->helper('form'); $this->load->library('form_validation'); $submit = $this->input->post('submit'); $search_results = array(); $search_term = $this->input->get_post('term', TRUE); if ($submit) { if ($this->form_validation->run('search')) { $this->load->model('spark'); $search_results = Spark::search($search_term); } else { UserHelper::setNotice('Whoops. There were some errors. Check below and re-submit!'); } } $data['search_term'] = $search_term; $data['sparks'] = $search_results; echo json_encode($data); }
public function reply($id) { try { $tweet = new Tweet($id); $comment = new TweetComment(); $comment->setTweetId($tweet->getId()); $comment->setProfileId(UserHelper::getProfileId()); $comment->setContent(trim(fRequest::get('tweet-comment'))); if (strlen($comment->getContent()) < 1) { throw new fValidationException('回复长度不能少于1个字符'); } if (strlen($comment->getContent()) > 140) { throw new fValidationException('回复长度不能超过140个字符'); } $comment->store(); } catch (fException $e) { // TODO } fURL::redirect(SITE_BASE . '/profile/' . $tweet->getProfileId() . '#tweet/' . $tweet->getId()); }
/** * The POST call to add a version to a package * Redirect to the package page on success */ public function add() { $submit = $this->input->post('submit'); if ($submit) { $this->load->library('form_validation'); $this->load->model('version'); $this->load->model('spark'); $insert = elements(array('spark_id', 'tag'), $_POST); if ($this->form_validation->run('add-version')) { if (Version::insert($insert)) { UserHelper::setNotice("Version added!"); } } else { UserHelper::setNotice("Try to enter a valid tag!", FALSE); } $spark = Spark::getById($insert['spark_id']); redirect(base_url() . 'packages/' . $spark->name . '/show'); } show_error("Whatcha doin' here?"); }