本文整理汇总了PHP中Hubzero\Utility\Sanitize::paranoid方法的典型用法代码示例。如果您正苦于以下问题:PHP Sanitize::paranoid方法的具体用法?PHP Sanitize::paranoid怎么用?PHP Sanitize::paranoid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hubzero\Utility\Sanitize
的用法示例。
在下文中一共展示了Sanitize::paranoid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onIndex
/**
* onIndex
*
* @param string $type
* @param integer $id
* @param boolean $run
* @access public
* @return void
*/
public function onIndex($type, $id, $run = false)
{
if ($type == 'wiki') {
if ($run === true) {
// Establish a db connection
$db = App::get('db');
// Sanitize the string
$id = \Hubzero\Utility\Sanitize::paranoid($id);
// Get the record
$sql = "SELECT * FROM #__wiki_pages\n\t\t\t\t\tJOIN #__wiki_versions\n\t\t\t\t\tON #__wiki_pages.version_id = #__wiki_versions.id\n\t\t\t\t\tWHERE #__wiki_pages.id = {$id} AND #__wiki_pages.state = 1;";
$row = $db->setQuery($sql)->query()->loadObject();
// Get the name of the author
$sql1 = "SELECT name FROM #__users WHERE id={$row->created_by};";
$author = $db->setQuery($sql1)->query()->loadResult();
// Get any tags
$sql2 = "SELECT tag \n\t\t\t\t\tFROM #__tags\n\t\t\t\t\tLEFT JOIN #__tags_object\n\t\t\t\t\tON #__tags.id=#__tags_object.tagid\n\t\t\t\t\tWHERE #__tags_object.objectid = {$id} AND #__tags_object.tbl = 'wiki';";
$tags = $db->setQuery($sql2)->query()->loadColumn();
// Determine the path
if ($row->scope == 'site') {
$path = '/wiki/' . $row->path;
} elseif ($row->scope == 'group') {
$group = \Hubzero\User\Group::getInstance($row->scope_id);
// Make sure group is valid.
if (is_object($group)) {
$cn = $group->get('cn');
$path = '/groups/' . $cn . '/wiki/' . $row->path;
}
} else {
// Only group and site wiki is supported right now
// @TODO: Project Notes
return;
}
// Public condition
if ($row->state == 1 && ($row->access == 0 || ($row->access = 1))) {
$access_level = 'public';
} elseif ($row->state == 1 && $row->access == 2) {
$access_level = 'registered';
} else {
$access_level = 'private';
}
if ($row->scope != 'group') {
$owner_type = 'user';
$owner = $row->created_by;
} else {
$owner_type = 'group';
$owner = $row->scope_id;
}
// Get the title
$title = $row->title;
// Build the description, clean up text
$content = $row->pagehtml;
$content = preg_replace('/<[^>]*>/', ' ', $content);
$content = preg_replace('/ {2,}/', ' ', $content);
$description = \Hubzero\Utility\Sanitize::stripAll($content);
// Create a record object
$record = new \stdClass();
$record->id = $type . '-' . $id;
$record->hubtype = $type;
$record->title = $title;
$record->description = $description;
$record->author = array($author);
$record->tags = $tags;
$record->path = $path;
$record->access_level = $access_level;
$record->owner = $owner;
$record->owner_type = $owner_type;
// Return the formatted record
return $record;
} else {
$db = App::get('db');
$sql = "SELECT #__wiki_pages.id FROM #__wiki_pages\n\t\t\t\t\tJOIN #__wiki_versions\n\t\t\t\t\tON #__wiki_pages.version_id = #__wiki_versions.id\n\t\t\t\t\tWHERE #__wiki_pages.state = 1;";
$ids = $db->setQuery($sql)->query()->loadColumn();
return $ids;
}
}
}
示例2: onIndex
/**
* onIndex
*
* @param string $type
* @param integer $id
* @param boolean $run
* @access public
* @return void
*/
public function onIndex($type, $id, $run = false)
{
if ($type == 'event') {
if ($run === true) {
// Establish a db connection
$db = App::get('db');
// Sanitize the string
$id = \Hubzero\Utility\Sanitize::paranoid($id);
// Get the record
$sql = "SELECT * FROM #__events WHERE id={$id};";
$row = $db->setQuery($sql)->query()->loadObject();
// Get the (start) date of the event
// Format the date for SOLR
$date = Date::of($row->publish_up)->format('Y-m-d');
$date .= 'T';
$date .= Date::of($row->publish_up)->format('h:m:s') . 'Z';
// Get the name of the author
$sql1 = "SELECT name FROM #__users WHERE id={$row->created_by};";
$author = $db->setQuery($sql1)->query()->loadResult();
// Get any tags
$sql2 = "SELECT tag \n\t\t\t\t\tFROM #__tags\n\t\t\t\t\tLEFT JOIN #__tags_object\n\t\t\t\t\tON #__tags.id=#__tags_object.tagid\n\t\t\t\t\tWHERE #__tags_object.objectid = {$id} AND #__tags_object.tbl = 'events';";
$tags = $db->setQuery($sql2)->query()->loadColumn();
if ($row->scope == 'event' || $row->scope == '') {
$path = '/events/details/' . $row->id;
} elseif ($row->scope == 'group') {
$group = \Hubzero\User\Group::getInstance($row->scope_id);
// Make sure group is valid.
if (is_object($group)) {
$cn = $group->get('cn');
$path = '/groups/' . $cn . '/calendar/details/' . $row->id;
} else {
$path = '';
}
}
// Public condition
if ($row->state == 1 && $row->approved == 1 && $row->scope != 'group') {
$access_level = 'public';
} else {
// Default private
$access_level = 'private';
}
if ($row->scope != 'group') {
$owner_type = 'user';
$owner = $row->created_by;
} else {
$owner_type = 'group';
$owner = $row->scope_id;
}
// Get the title
$title = $row->title;
// Build the description, clean up text
$content = preg_replace('/<[^>]*>/', ' ', $row->content);
$content = preg_replace('/ {2,}/', ' ', $content);
$description = \Hubzero\Utility\Sanitize::stripAll($content);
// Format the date for SOLR
$date = Date::of($row->publish_up)->format('Y-m-d');
$date .= 'T';
$date .= Date::of($row->publish_up)->format('h:m:s') . 'Z';
// Create a record object
$record = new \stdClass();
$record->id = $type . '-' . $id;
$record->hubtype = $type;
$record->title = $title;
$record->description = $description;
$record->author = array($author);
$record->tags = $tags;
$record->path = $path;
$record->access_level = $access_level;
$record->date = $date;
$record->owner = $owner;
$record->owner_type = $owner_type;
// Return the formatted record
return $record;
} else {
$db = App::get('db');
$sql = "SELECT id FROM #__events;";
$ids = $db->setQuery($sql)->query()->loadColumn();
return $ids;
}
}
}
示例3: onIndex
/**
* onIndex
*
* @param string $type
* @param integer $id
* @param boolean $run
* @access public
* @return void
*/
public function onIndex($type, $id, $run = false)
{
if ($type == 'publication') {
if ($run === true) {
// Establish a db connection
$db = App::get('db');
// Sanitize the string
$id = \Hubzero\Utility\Sanitize::paranoid($id);
// Get the record
$sql = "SELECT\n\t\t\t\t\t#__publications.id,\n\t\t\t\t\talias,\n\t\t\t\t\t#__publications.access,\n\t\t\t\t\tmaster_doi,\n\t\t\t\t\tpublished_up,\n\t\t\t\t\t#__publications.created_by,\n\t\t\t\t\tabstract,\n\t\t\t\t\tdescription,\n\t\t\t\t\ttitle,\n\t\t\t\t\tdoi,\n\t\t\t\t\tstate,\n\t\t\t\t\trelease_notes,\n\t\t\t\t\tMAX(#__publication_versions.id) as latestVersion\n\t\t\t\t\tFROM #__publications \n\t\t\t\tLEFT JOIN #__publication_versions\n\t\t\t\tON #__publications.id = #__publication_versions.publication_id\n\t\t\t\tWHERE #__publications.id = {$id};";
$row = $db->setQuery($sql)->query()->loadObject();
// Get the name of the author
if (isset($row->latestVersion)) {
$sql1 = "SELECT user_id, name FROM #__publication_authors WHERE publication_version_id={$row->latestVersion} AND role != 'submitter';";
$authors = $db->setQuery($sql1)->query()->loadAssocList();
// Get any tags
$sql2 = "SELECT tag\n\t\t\t\t\t\tFROM #__tags\n\t\t\t\t\t\tLEFT JOIN #__tags_object\n\t\t\t\t\t\tON #__tags.id=#__tags_object.tagid\n\t\t\t\t\t\tWHERE #__tags_object.objectid = {$row->latestVersion} AND #__tags_object.tbl = 'publications';";
$tags = $db->setQuery($sql2)->query()->loadColumn();
} else {
$authors = array();
$tags = array();
}
// @TODO: PHP 5.5 includes array_column()
$owners = array();
$authorNames = array();
if (isset($authors) && !empty($authors)) {
foreach ($authors as $author) {
array_push($owners, $author['user_id']);
}
foreach ($authors as $author) {
array_push($authorNames, $author['name']);
}
}
// Determine the path
if ($row->alias != '') {
$path = '/publications/' . $row->alias;
} else {
$path = '/publications/' . $id;
}
// Public condition
if ($row->state == 1 && $row->access == 0) {
$access_level = 'public';
} elseif ($row->state == 1 && $row->access == 1) {
$access_level = 'registered';
} else {
$access_level = 'private';
}
// Authors have access
$owner_type = 'user';
// So does submitter;
array_push($owners, $row->created_by);
// Get the title
$title = $row->title;
// Build the description, clean up text
$content = $row->abstract . ' ' . $row->description . ' ' . $row->release_notes;
$content = preg_replace('/<[^>]*>/', ' ', $content);
$content = preg_replace('/ {2,}/', ' ', $content);
$description = \Hubzero\Utility\Sanitize::stripAll($content);
if (isset($row->doi)) {
$doi = $row->doi;
} else {
$doi = '';
}
// Create a record object
$record = new \stdClass();
$record->id = $type . '-' . $id;
$record->hubtype = $type;
$record->title = $title;
$record->description = $description;
$record->author = $authorNames;
$row->doi = $doi;
$record->tags = $tags;
$record->path = $path;
$record->access_level = $access_level;
$record->owner = $owners;
$record->owner_type = $owner_type;
// Return the formatted record
return $record;
} else {
$db = App::get('db');
$sql = "SELECT id FROM #__publications;";
$ids = $db->setQuery($sql)->query()->loadColumn();
return $ids;
}
}
}
示例4: listfilesTask
/**
* List all group files
*
* @return array
*/
public function listfilesTask()
{
// set the neeced layout
$this->view->setLayout('filelist');
//get request vars
$this->view->folders = array();
$this->view->files = array();
$this->view->type = \Hubzero\Utility\Sanitize::paranoid(Request::getWord('type', ''));
$this->view->relpath = Request::getVar('path', '/');
// make sure we default to uploads folder for non-super groups
if ($this->group->get('type') != 3 && (!$this->view->relpath || $this->view->relpath == '/')) {
$this->view->relpath = '/uploads';
}
$this->view->relpath = \Hubzero\Filesystem\Util::normalizePath($this->view->relpath);
$this->view->relpath = explode('/', $this->view->relpath);
foreach ($this->view->relpath as $i => $p) {
$this->view->relpath[$i] = preg_replace('/[^a-zA-Z0-9_\\-]/', '', $p);
}
$this->view->relpath = implode(DS, $this->view->relpath);
//build path to the group folder
$this->path = rtrim($this->path, DS) . $this->view->relpath;
// if we have a directory
if (is_dir($this->path)) {
//get list of files
$folders = Filesystem::directories($this->path, '.', false);
$files = Filesystem::files($this->path, '.', false);
// filter by type
if (isset($this->view->type) && $this->view->type != '') {
foreach ($files as $k => $file) {
$fileInfo = pathinfo($file);
$ext = strtolower($fileInfo['extension']);
if ($this->view->type == 'images' && !in_array($ext, array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'tiff'))) {
unset($files[$k]);
} else {
if ($this->view->type == 'files' && in_array($ext, array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'tiff'))) {
unset($files[$k]);
}
}
}
}
//reset array keys
$this->view->folders = array_values($folders);
$this->view->files = array_values($files);
}
// pass vars to view
//$this->view->config = $this->config;
$this->view->group = $this->group;
$this->view->path = $this->path;
// get view notifications
$this->view->notifications = $this->getNotifications() ? $this->getNotifications() : array();
//display view
$this->view->display();
}
示例5: saveParam
/**
* Save param
*
* @param string $param
* @param string $value
*
* @return void
*/
public function saveParam($param = '', $value = '')
{
// Clean up incoming
$param = \Hubzero\Utility\Sanitize::paranoid($param, array('-', '_'));
$value = \Hubzero\Utility\Sanitize::clean($value);
if (!$this->exists()) {
return false;
}
if (!$param || !$value) {
return false;
}
$this->version->saveParam($this->get('version_id'), trim($param), htmlentities($value));
return $value;
}
示例6: onIndex
/**
* onIndex
*
* @param string $type
* @param integer $id
* @param boolean $run
* @access public
* @return void
*/
public function onIndex($type, $id, $run = false)
{
if ($type == 'citation') {
if ($run === true) {
// Establish a db connection
$db = App::get('db');
// Sanitize the string
$id = \Hubzero\Utility\Sanitize::paranoid($id);
// Get the record
$sql = "SELECT * FROM #__citations WHERE id={$id};";
$row = $db->setQuery($sql)->query()->loadObject();
// Obtain list of related authors
$sql1 = "SELECT author FROM #__citations_authors WHERE cid={$id};";
$authors = $db->setQuery($sql1)->query()->loadColumn();
// Get any tags
$sql2 = "SELECT tag \n\t\t\t\t\tFROM #__tags\n\t\t\t\t\tLEFT JOIN #__tags_object\n\t\t\t\t\tON #__tags.id=#__tags_object.tagid\n\t\t\t\t\tWHERE #__tags_object.objectid = {$id} AND #__tags_object.tbl = 'citations';";
$tags = $db->setQuery($sql2)->query()->loadColumn();
// Determine the path
if ($row->scope == 'member') {
$path = '/members/' . $row->scope_id . '/citations';
} elseif ($row->scope == 'group') {
$group = \Hubzero\User\Group::getInstance($row->scope_id);
// Make sure group is valid.
if (is_object($group)) {
$cn = $group->get('cn');
$path = '/groups/' . $cn . '/citations';
} else {
$path = '';
}
} else {
$path = '/citations/view/' . $id;
}
$access_level = 'public';
if ($row->scope != 'group') {
$owner_type = 'user';
$owner = $row->uid;
} else {
$owner_type = 'group';
$owner = $row->scope_id;
}
// Get the title
$title = $row->title;
// Build the description, clean up text
$content = $row->address . ' ' . $row->author . ' ' . $row->booktitle . ' ' . $row->chapter . ' ' . $row->cite . ' ' . $row->edition . ' ' . $row->eprint . ' ' . $row->howpublished . ' ' . $row->institution . ' ' . $row->isbn . ' ' . $row->journal . ' ' . $row->month . ' ' . $row->note . ' ' . $row->number . ' ' . $row->organization . ' ' . $row->pages . ' ' . $row->publisher . ' ' . $row->series . ' ' . $row->school . ' ' . $row->title . ' ' . $row->url . ' ' . $row->volume . ' ' . $row->year . ' ' . $row->doi . ' ' . $row->ref_type . ' ' . $row->date_submit . ' ' . $row->date_accept . ' ' . $row->date_publish . ' ' . $row->software_use . ' ' . $row->notes . ' ' . $row->language . ' ' . $row->label . ' ';
$content = preg_replace('/<[^>]*>/', ' ', $content);
$content = preg_replace('/ {2,}/', ' ', $content);
$description = \Hubzero\Utility\Sanitize::stripAll($content);
// Create a record object
$record = new \stdClass();
$record->id = $type . '-' . $id;
$record->hubtype = $type;
$record->title = $title;
$record->description = $description;
$record->author = $authors;
$record->tags = $tags;
$record->path = $path;
$record->access_level = $access_level;
$record->owner = $owner;
$record->owner_type = $owner_type;
// Return the formatted record
return $record;
} else {
$db = App::get('db');
$sql = "SELECT id FROM #__citations;";
$ids = $db->setQuery($sql)->query()->loadColumn();
return $ids;
}
}
}
示例7: onIndex
/**
* onIndex
*
* @param string $type
* @param integer $id
* @param boolean $run
* @access public
* @return void
*/
public function onIndex($type, $id, $run = false)
{
if ($type == 'blog-entry') {
if ($run === true) {
// Establish a db connection
$db = App::get('db');
// Sanitize the string
$id = \Hubzero\Utility\Sanitize::paranoid($id);
// Get the record
$sql = "SELECT * FROM #__blog_entries WHERE id={$id} AND state != 2;";
$row = $db->setQuery($sql)->query()->loadObject();
// Get the name of the author
$sql1 = "SELECT name FROM #__users WHERE id={$row->created_by};";
$author = $db->setQuery($sql1)->query()->loadResult();
// Get any tags
$sql2 = "SELECT tag \n\t\t\t\t\tFROM #__tags\n\t\t\t\t\tLEFT JOIN #__tags_object\n\t\t\t\t\tON #__tags.id=#__tags_object.tagid\n\t\t\t\t\tWHERE #__tags_object.objectid = {$id} AND #__tags_object.tbl = 'blog';";
$tags = $db->setQuery($sql2)->query()->loadColumn();
// Determine the path
$year = Date::of(strtotime($row->publish_up))->toLocal('Y');
$month = Date::of(strtotime($row->publish_up))->toLocal('m');
$alias = $row->alias;
if ($row->scope == 'site') {
$path = '/blog/' . $year . '/' . $month . '/' . $alias;
} elseif ($row->scope == 'member') {
$path = '/members/' . $row->scope_id . '/blog/' . $year . '/' . $month . '/' . $alias;
} elseif ($row->scope == 'group') {
$group = Group::getInstance($row->scope_id);
// Make sure group is valid.
if (is_object($group)) {
$cn = $group->get('cn');
$path = '/groups/' . $cn . '/blog/' . $year . '/' . $month . '/' . $alias;
} else {
$path = '';
}
}
// Public condition
if ($row->state == 1 && $row->access == 1) {
$access_level = 'public';
} elseif ($row->state == 1 && $row->access == 2) {
$access_level = 'registered';
} else {
$access_level = 'private';
}
if ($row->scope != 'group') {
$owner_type = 'user';
$owner = $row->created_by;
} else {
$owner_type = 'group';
$owner = $row->scope_id;
}
// Get the title
$title = $row->title;
// Build the description, clean up text
$content = preg_replace('/<[^>]*>/', ' ', $row->content);
$content = preg_replace('/ {2,}/', ' ', $content);
$description = \Hubzero\Utility\Sanitize::stripAll($content);
// Create a record object
$record = new \stdClass();
$record->id = $type . '-' . $id;
$record->hubtype = $type;
$record->title = $title;
$record->description = $description;
$record->author = array($author);
$record->tags = $tags;
$record->path = $path;
$record->access_level = $access_level;
$record->owner = $owner;
$record->owner_type = $owner_type;
// Return the formatted record
return $record;
} else {
$db = App::get('db');
$sql = "SELECT id FROM #__blog_entries WHERE state != 2";
$ids = $db->setQuery($sql)->query()->loadColumn();
return $ids;
}
}
}
示例8: onIndex
/**
* onIndex
*
* @param string $type
* @param integer $id
* @param boolean $run
* @access public
* @return void
*/
public function onIndex($type, $id, $run = false)
{
if ($type == 'forum') {
if ($run === true) {
// Establish a db connection
$db = App::get('db');
// Sanitize the string
$id = \Hubzero\Utility\Sanitize::paranoid($id);
// Get the record
$sql = "SELECT #__forum_posts.title, \n\t\t\t\t#__forum_posts.id,\n\t\t\t\t#__forum_posts.comment,\n\t\t\t\t#__forum_posts.created,\n\t\t\t\t#__forum_posts.created_by,\n\t\t\t\t#__forum_posts.scope,\n\t\t\t\t#__forum_posts.scope_id,\n\t\t\t\t#__forum_posts.anonymous,\n\t\t\t\t#__forum_posts.thread,\n\t\t\t\t#__forum_posts.parent,\n\t\t\t\t#__forum_posts.category_id,\n\t\t\t\t#__forum_categories.alias as category,\n\t\t\t\t#__forum_categories.state,\n\t\t\t\t#__forum_categories.access,\n\t\t\t\t#__forum_sections.alias as section\n\t\t\t\tFROM #__forum_posts\n\t\t\t\tLEFT JOIN #__forum_categories\n\t\t\t\tON #__forum_posts.category_id = #__forum_categories.id\n\t\t\t\tLEFT JOIN #__forum_sections\n\t\t\t\tON #__forum_categories.section_id = #__forum_sections.id\n\t\t\t\tWHERE thread={$id}\n\t\t\t\tAND parent=0;";
$rows = $db->setQuery($sql)->query()->loadObjectList();
$titles = array();
$authors = array();
$tags = array();
$content = '';
foreach ($rows as $row) {
array_push($titles, $row->title);
if ($row->anonymous == 0) {
// Get the name of the author
$sql1 = "SELECT name FROM #__users WHERE id={$row->created_by};";
$author = $db->setQuery($sql1)->query()->loadResult();
array_push($authors, $author);
// Get any tags
$sql2 = "SELECT tag \n\t\t\t\t\t\t\tFROM #__tags\n\t\t\t\t\t\t\tLEFT JOIN #__tags_object\n\t\t\t\t\t\t\tON #__tags.id=#__tags_object.tagid\n\t\t\t\t\t\t\tWHERE #__tags_object.objectid = {$row->id} AND #__tags_object.tbl = 'forum';";
$taglist = $db->setQuery($sql2)->query()->loadColumn();
foreach ($taglist as $t) {
array_push($tags, $t);
}
// Concatenate the comments.
$content = $content . ' ' . $row->comment;
} else {
$author = 'anonymous';
}
// Get the scope
if ($row->parent == 0) {
$scope = $row->scope;
$scope_id = $row->scope_id;
$access = $row->access;
$state = $row->state;
$category = $row->category;
$section = $row->section;
$owner = $row->created_by;
}
}
// Remove duplicates
$tags = array_unique($tags);
if ($scope == 'site' || $scope == '') {
$path = '/forum/' . $section . '/' . $category . '/' . $id;
} elseif ($scope == 'group') {
$group = \Hubzero\User\Group::getInstance($scope_id);
// Make sure group is valid.
if (is_object($group)) {
$cn = $group->get('cn');
$path = '/groups/' . $cn . '/forum/' . $section . '/' . $category . '/' . $id;
} else {
$path = '';
}
} elseif ($scope == 'course') {
$sql = "SELECT #__courses_offerings.alias AS offering, #__courses.alias AS course FROM #__courses_offerings\n\t\t\t\t\tLEFT JOIN #__courses\n\t\t\t\t\tON #__courses_offerings.course_id = #__courses.id\n\t\t\t\t\tWHERE #__courses_offerings.id = {$scope_id};";
$course = $db->setQuery($sql)->query()->loadAssoc();
$path = '/courses/' . $course['course'] . '/' . $course['offering'] . '/discussions/' . $row->category . '/' . $row->category_id . '?thread=' . $id;
} else {
$path = '';
}
// Public condition
if ($state == 1 && $access == 1 && $scope == 'site') {
$access_level = 'public';
} elseif ($state == 1 && $access == 2 && $scope == 'site') {
$access_level = 'registered';
} else {
$access_level = 'private';
}
if ($scope == 'group') {
$owner_type = 'group';
$owner = $scope_id;
} else {
$owner_type = 'user';
// Owner set above
}
// Build the description, clean up text
$content = preg_replace('/<[^>]*>/', ' ', $content);
$content = preg_replace('/ {2,}/', ' ', $content);
$description = \Hubzero\Utility\Sanitize::stripAll($content);
// Create a record object
$record = new \stdClass();
$record->id = $type . '-' . $id;
$record->hubtype = $type;
$record->title = $titles;
$record->description = $description;
$record->author = array($author);
$record->tags = $tags;
//.........这里部分代码省略.........
示例9: onIndex
/**
* onIndex
*
* @param string $type
* @param integer $id
* @param boolean $run
* @access public
* @return void
*/
public function onIndex($type, $id, $run = false)
{
if ($type == 'question') {
if ($run === true) {
// Establish a db connection
$db = App::get('db');
// Sanitize the string
$id = \Hubzero\Utility\Sanitize::paranoid($id);
// Get the record
$sql = "SELECT * FROM #__answers_questions WHERE id={$id};";
$row = $db->setQuery($sql)->query()->loadObject();
// Get the name of the author
if ($row->anonymous == 0) {
$sql1 = "SELECT name FROM #__users WHERE id={$row->created_by};";
$author = $db->setQuery($sql1)->query()->loadResult();
} else {
$author = 'anonymous';
}
// Get any tags
$sql2 = "SELECT tag \n\t\t\t\t\tFROM #__tags\n\t\t\t\t\tLEFT JOIN #__tags_object\n\t\t\t\t\tON #__tags.id=#__tags_object.tagid\n\t\t\t\t\tWHERE #__tags_object.objectid = {$id} AND #__tags_object.tbl = 'answers';";
$tags = $db->setQuery($sql2)->query()->loadColumn();
// Get the associated responses
$sql3 = "SELECT * FROM #__answers_responses WHERE question_id={$id};";
$responses = $db->setQuery($sql3)->query()->loadObjectList();
// Concatenate responses
$responseString = '';
foreach ($responses as $response) {
if ($response->state == 0) {
$responseString .= $response->answer . ' ';
}
}
// Determine the path
$path = '/answers/qustion/' . $id;
// Always public condition
$access_level = 'public';
$owner_type = 'user';
$owner = $row->created_by;
// Get the title
$title = $row->subject;
// Build the description, clean up text
$content = $row->question . ' ' . $responseString;
$content = preg_replace('/<[^>]*>/', ' ', $content);
$content = preg_replace('/ {2,}/', ' ', $content);
$description = \Hubzero\Utility\Sanitize::stripAll($content);
// Create a record object
$record = new \stdClass();
$record->id = $type . '-' . $id;
$record->hubtype = $type;
$record->title = $title;
$record->description = $description;
$record->author = array($author);
$record->tags = $tags;
$record->path = $path;
$record->access_level = $access_level;
$record->owner = $owner;
$record->owner_type = $owner_type;
// Return the formatted record
return $record;
} else {
$db = App::get('db');
$sql = "SELECT id FROM #__answers_questions;";
$ids = $db->setQuery($sql)->query()->loadColumn();
return $ids;
}
}
}
示例10: onIndex
/**
* onIndex
*
* @param string $type
* @param integer $id
* @param boolean $run
* @access public
* @return void
*/
public function onIndex($type, $id, $run = false)
{
if ($type == 'group') {
if ($run === true) {
// Establish a db connection
$db = App::get('db');
// Sanitize the string
$id = \Hubzero\Utility\Sanitize::paranoid($id);
// Get the record
$sql = "SELECT * FROM #__xgroups WHERE gidNumber={$id} AND type = 1 OR type = 3;";
$row = $db->setQuery($sql)->query()->loadObject();
// Get any tags
$sql2 = "SELECT tag \n\t\t\t\t\tFROM #__tags\n\t\t\t\t\tLEFT JOIN #__tags_object\n\t\t\t\t\tON #__tags.id=#__tags_object.tagid\n\t\t\t\t\tWHERE #__tags_object.objectid = {$id} AND #__tags_object.tbl = 'groups';";
$tags = $db->setQuery($sql2)->query()->loadColumn();
// Public condition
if ($row->discoverability == 0) {
$access_level = 'public';
} else {
$access_level = 'private';
}
// Members 'own' the group
$group = \Hubzero\User\Group::getInstance($id);
$members = $group->get('members');
$owner_type = 'user';
$owner = $members;
$path = '/groups/' . $row->cn;
// Get the title
$title = $row->description;
// Build the description, clean up text
$content = preg_replace('/<[^>]*>/', ' ', $row->public_desc);
$content = preg_replace('/ {2,}/', ' ', $content);
$description = \Hubzero\Utility\Sanitize::stripAll($content);
// Create a record object
$record = new \stdClass();
$record->id = $type . '-' . $id;
$record->hubtype = $type;
$record->title = $title;
$record->description = $description;
$record->tags = $tags;
$record->path = $path;
$record->access_level = $access_level;
$record->owner = $owner;
$record->owner_type = $owner_type;
// Return the formatted record
return $record;
} else {
$db = App::get('db');
$sql = "SELECT gidNumber FROM #__xgroups WHERE type=1 OR type=3;";
$ids = $db->setQuery($sql)->query()->loadColumn();
return $ids;
}
}
}
示例11: onIndex
/**
* onIndex
*
* @param string $type
* @param integer $id
* @param boolean $run
* @access public
* @return void
*/
public function onIndex($type, $id, $run = false)
{
if ($type == 'resource') {
if ($run === true) {
// Establish a db connection
$db = App::get('db');
// Sanitize the string
$id = \Hubzero\Utility\Sanitize::paranoid($id);
// Get the record
$sql = "SELECT #__resources.*, #__resource_types.type as typeName FROM #__resources\n\t\t\t\t\tLEFT JOIN #__resource_types\n\t\t\t\t\tON #__resource_types.id = #__resources.type\n\t\t\t\t\tWHERE #__resources.id = {$id};";
$sql = "SELECT * FROM #__resources WHERE id={$id};";
$row = $db->setQuery($sql)->query()->loadObject();
// Get the name of the author
$sql1 = "SELECT name, authorid FROM #__author_assoc WHERE subid={$id} AND subtable='resources';";
$authorList = $db->setQuery($sql1)->query()->loadAssocList();
$owners = array();
$authors = array();
foreach ($authorList as $author) {
if ($author['authorid'] > 0) {
array_push($owners, $author['authorid']);
}
array_push($authors, $author['name']);
}
// Get any tags
$sql2 = "SELECT tag \n\t\t\t\t\tFROM #__tags\n\t\t\t\t\tLEFT JOIN #__tags_object\n\t\t\t\t\tON #__tags.id=#__tags_object.tagid\n\t\t\t\t\tWHERE #__tags_object.objectid = {$id} AND #__tags_object.tbl = 'resources';";
$tags = $db->setQuery($sql2)->query()->loadColumn();
// Determine the path
if ($row->alias != '' && strtolower($row->type) != 'tool') {
$path = '/resources/' . $row->alias;
} elseif ($row->alias != '' && strtolower($row->type) == 'tool') {
$path = '/tool/' . $row->alias;
} else {
$path = '/resources/' . $row->id;
}
// Public condition
if ($row->published == 1 && $row->access == 0 && $row->standalone == 1) {
$access_level = 'public';
} elseif ($row->published == 1 && $row->access == 1 && $row->standalone == 1) {
$access_level = 'registered';
} else {
$access_level = 'private';
}
// Who is the owner
if (isset($row->group_owner) && $row->group_owner != '') {
$owner_type = 'group';
$owner = $row->group_owner;
} else {
$owner_type = 'user';
$owner = $owners;
}
// Get children
$sql3 = "SELECT title AS childTitle, path FROM jos_resources\n\t\t\t\tJOIN jos_resource_assoc\n\t\t\t\tON jos_resource_assoc.child_id = jos_resources.id\n\t\t\t\tWHERE jos_resource_assoc.parent_id = {$id} AND standalone = 0 AND published = 1;";
$children = $db->setQuery($sql3)->query()->loadAssocList();
$fileData = '';
$content = '';
foreach ($children as $child) {
if (isset($fileScan) && $fileScan == true) {
// Call the helper to read the file
//$fileData .= /Helper/FileScan::scan($child['path']) . ' ';
}
$content .= $child['childTitle'] . ' ';
}
// Get the title
$title = $row->title;
// Build the description, clean up text
$content .= $row->introtext . ' ' . $row->fulltxt . ' ' . $fileData;
$content = preg_replace('/<[^>]*>/', ' ', $content);
$content = preg_replace('/ {2,}/', ' ', $content);
$description = \Hubzero\Utility\Sanitize::stripAll($content);
// Create a record object
$record = new \stdClass();
$record->id = $type . '-' . $id;
$record->hubtype = $type;
$record->title = $title;
$record->description = $description;
$record->author = $authors;
$record->tags = $tags;
$record->path = $path;
$record->access_level = $access_level;
$record->owner = $owner;
$record->owner_type = $owner_type;
// Return the formatted record
return $record;
} else {
$db = App::get('db');
$sql = "SELECT id FROM #__resources WHERE standalone=1;";
$ids = $db->setQuery($sql)->query()->loadColumn();
return $ids;
}
}
}
示例12: onIndex
/**
* onIndex
*
* @param string $type
* @param integer $id
* @param boolean $run
* @access public
* @return void
*/
public function onIndex($type, $id, $run = false)
{
if ($type == 'project') {
if ($run === true) {
// Establish a db connection
$db = App::get('db');
// Sanitize the string
$id = \Hubzero\Utility\Sanitize::paranoid($id);
// Get the record
$sql = "SELECT * FROM #__projects WHERE id={$id} AND type=1;";
$row = $db->setQuery($sql)->query()->loadObject();
// Determine the path
$path = '/projects/' . $row->alias;
// Public condition
if ($row->state == 1 && $row->private == 0) {
$access_level = 'public';
} else {
$access_level = 'private';
}
if ($row->owned_by_group == 0) {
$owner_type = 'user';
$owner = $row->owned_by_user;
} else {
$owner_type = 'group';
$owner = $row->owned_by_group;
}
// Get the title
$title = $row->title;
// Build the description, clean up text
$content = preg_replace('/<[^>]*>/', ' ', $row->about);
$content = preg_replace('/ {2,}/', ' ', $content);
$description = \Hubzero\Utility\Sanitize::stripAll($content);
// Create a record object
$record = new \stdClass();
$record->id = $type . '-' . $id;
$record->hubtype = $type;
$record->title = $title;
$record->description = $description;
$record->path = $path;
$record->access_level = $access_level;
$record->owner = $owner;
$record->owner_type = $owner_type;
// Return the formatted record
return $record;
} else {
$db = App::get('db');
$sql = "SELECT id FROM #__projects WHERE type=1;";
$ids = $db->setQuery($sql)->query()->loadColumn();
return $ids;
}
}
}
示例13: onIndex
/**
* onIndex
*
* @param string $type
* @param integer $id
* @param boolean $run
* @access public
* @return void
*/
public function onIndex($type, $id, $run = false)
{
if ($type == 'course') {
if ($run === true) {
// Establish a db connection
$db = App::get('db');
// Sanitize the string
$id = \Hubzero\Utility\Sanitize::paranoid($id);
// Get the record
$sql = "SELECT * FROM #__courses WHERE id={$id};";
$row = $db->setQuery($sql)->query()->loadObject();
// Get the name of the author
$sql1 = "SELECT user_id, name, title, alias, student FROM #__courses_members\n\t\t\t\tLEFT JOIN #__courses_roles\n\t\t\t\tON #__courses_members.role_id = #__courses_roles.id\n\t\t\t\tLEFT JOIN #__users\n\t\t\t\tON #__courses_members.user_id = #__users.id;";
$members = $db->setQuery($sql1)->query()->loadObjectList();
$authors = array();
$author_ids = array();
$students = array();
foreach ($members as $member) {
if ($member->student == 0) {
array_push($authors, $member->name);
array_push($author_ids, $member->user_id);
} else {
array_push($students, $member->user_id);
}
}
// Get any tags
$sql2 = "SELECT tag \n\t\t\t\t\tFROM #__tags\n\t\t\t\t\tLEFT JOIN #__tags_object\n\t\t\t\t\tON #__tags.id=#__tags_object.tagid\n\t\t\t\t\tWHERE #__tags_object.objectid = {$id} AND #__tags_object.tbl = 'courses';";
$tags = $db->setQuery($sql2)->query()->loadColumn();
// Determine the path
$path = '/courses/' . $row->alias;
// Public condition
if ($row->state == 1 && $row->access == 1) {
$access_level = 'public';
} elseif ($row->state == 1 && $row->access == 2) {
$access_level = 'registered';
} else {
$access_level = 'private';
}
$owner_type = 'user';
$owner = array_merge($students, $author_ids);
// Get the title
$title = $row->title;
// Build the description, clean up text
$content = $row->blurb . ' ' . $row->description;
$content = preg_replace('/<[^>]*>/', ' ', $content);
$content = preg_replace('/ {2,}/', ' ', $content);
$description = \Hubzero\Utility\Sanitize::stripAll($content);
// Create a record object
$record = new \stdClass();
$record->id = $type . '-' . $id;
$record->hubtype = $type;
$record->title = $title;
$record->description = $description;
$record->author = $authors;
$record->tags = $tags;
$record->path = $path;
$record->access_level = $access_level;
$record->owner = $owner;
$record->owner_type = $owner_type;
// Return the formatted record
return $record;
} else {
$db = App::get('db');
$sql = "SELECT id FROM #__courses;";
$ids = $db->setQuery($sql)->query()->loadColumn();
return $ids;
}
}
}
示例14: onIndex
/**
* onIndex
*
* @param string $type
* @param integer $id
* @param boolean $run
* @access public
* @return void
*/
public function onIndex($type, $id, $run = false)
{
if ($type == 'member') {
if ($run === true) {
// Establish a db connection
$db = App::get('db');
// Sanitize the string
$id = \Hubzero\Utility\Sanitize::paranoid($id);
// Get the record
$sql = "SELECT * FROM #__users WHERE id={$id};";
$row = $db->setQuery($sql)->query()->loadObject();
// Determine the path
$path = '/members/' . $id;
// Public condition
if ($row->approved != 0 && $row->access == 1) {
$access_level = 'public';
} else {
$access_level = 'private';
}
// Owner is self
$owner_type = 'user';
$owner = $row->id;
// Get the title
$title = $row->name;
// Get any tags
$sql2 = "SELECT tag \n\t\t\t\t\tFROM #__tags\n\t\t\t\t\tLEFT JOIN #__tags_object\n\t\t\t\t\tON #__tags.id=#__tags_object.tagid\n\t\t\t\t\tWHERE #__tags_object.objectid = {$id} AND #__tags_object.tbl = 'xprofiles';";
$tags = $db->setQuery($sql2)->query()->loadColumn();
// Get any profile fields that are public
$sql3 = "SELECT profile_key, profile_value FROM #__user_profiles WHERE user_id={$id} AND access=1;";
$profileFields = $db->setQuery($sql3)->query()->loadAssocList();
$profile = '';
foreach ($profileFields as $field) {
$profile .= $field['profile_value'] . ' ';
}
// Build the description, clean up text
$content = $row->email . ' ' . $profile;
$content = preg_replace('/<[^>]*>/', ' ', $content);
$content = preg_replace('/ {2,}/', ' ', $content);
$description = \Hubzero\Utility\Sanitize::stripAll($content);
// Create a record object
$record = new \stdClass();
$record->id = $type . '-' . $id;
$record->hubtype = $type;
$record->title = $title;
$record->description = $description;
$record->tags = $tags;
$record->path = $path;
$record->access_level = $access_level;
$record->owner = $owner;
$record->owner_type = $owner_type;
// Return the formatted record
return $record;
} else {
$db = App::get('db');
$sql = "SELECT id FROM #__users;";
$ids = $db->setQuery($sql)->query()->loadColumn();
return $ids;
}
}
}
示例15: onIndex
/**
* onIndex
*
* @param string $type
* @param integer $id
* @param boolean $run
* @access public
* @return void
*/
public function onIndex($type, $id, $run = false)
{
if ($type == 'content') {
if ($run === true) {
// Establish a db connection
$db = App::get('db');
// Sanitize the string
$id = \Hubzero\Utility\Sanitize::paranoid($id);
// Get the record
$sql = "SELECT * FROM #__content WHERE id={$id};";
$row = $db->setQuery($sql)->query()->loadObject();
// Build the path
$sql1 = "SELECT path FROM #__categories WHERE id={$row->catid};";
$path = $db->setQuery($sql1)->query()->loadResult();
if ($path != 'uncategorised') {
$path = '/' . $path . '/' . $row->alias;
} else {
$path = $row->alias;
}
if ($row->state == 1 && $row->access == 1) {
$access_level = 'public';
} elseif ($row->state == 1 && $row->access == 2) {
$access_level = 'registered';
} else {
$access_level = 'private';
}
$owner_type = 'user';
$owner = $row->created_by;
// Get the title
$title = $row->title;
// Build the description, clean up text
$content = $row->fulltext . ' ' . $row->introtext;
$content = preg_replace('/<[^>]*>/', ' ', $content);
$content = preg_replace('/ {2,}/', ' ', $content);
$description = \Hubzero\Utility\Sanitize::stripAll($content);
// Create a record object
$record = new \stdClass();
$record->id = $type . '-' . $id;
$record->hubtype = $type;
$record->title = $title;
$record->description = $description;
//$record->author = array($author);
//$record->tags = $tags;
$record->path = $path;
$record->access_level = $access_level;
$record->owner = $owner;
$record->owner_type = $owner_type;
// Return the formatted record
return $record;
} else {
$db = App::get('db');
$sql = "SELECT id FROM #__content;";
$ids = $db->setQuery($sql)->query()->loadColumn();
return $ids;
}
}
}