Using the bit of code for logged in user

Permalink Browser Info Environment
Hi John,
I am ina situation where a logged in user should be executing the code and I see you included what looks like a very handy piece of code to do just that.

Problem is, I don't see how to use it in the context of the job.

Could you help please?

Thank you

Type: Discussion
Status: Archived
mnakalay
View Replies:
JohntheFish replied on at Permalink Reply
JohntheFish
Its not code I have used, just a reference to code that mkly posted in the forum, a sort of 'note to self, this may come in useful later'. So at this point in time, I don't know any more about it than you do :-(

If you find out more, please post whatever you find. I suspect it will come in useful to others.

http://www.concrete5.org/community/forums/jobs1/using-fileimporter-...
mnakalay replied on at Permalink Reply
mnakalay
:/ OK, If I figure out how to do that, I'll let you know.

Thank you.
mnakalay replied on at Permalink Reply
mnakalay
Actually there's a function in the library that uses that bit of code. It is commented out, I don't know why.

The function is
public function getPageContent(Page $c) {
      ob_start();
      $v = View::getInstance();
      $v->disableEditing();
      $v->setCollectionObject($c);
      $req = Request::get();
      $req->setCustomRequestUser(false);            
      $req->setCurrentPage($c);
      $v->render($c);
      $contents = ob_get_contents();
      ob_end_clean();
      return $contents;
   }

As it is written here, If I try t get content from a page only visible to a particular group of users, I won't be able to see it since it uses $req->setCustomRequestUser(false);

Even if I'm logged in as admin, I won't see it.

concrete5 Environment Information

# concrete5 Version
5.6.3.1

# concrete5 Packages
Hidden Reference Field For Proforms (0.9), Pro Forms (7.5.9), Xmas Theme (1.0.2), YTC Pricing Table (1.6.3).

# concrete5 Overrides
languages/ar, languages/cs_CZ, languages/da_DK, languages/de_DE, languages/el_GR, languages/es_AR, languages/es_ES, languages/es_MX, languages/es_PE, languages/fa_IR, languages/fi_FI, languages/fr_FR, languages/he_IL, languages/it_IT, languages/ja_JP, languages/nb_NO, languages/nl_NL, languages/pt_PT, languages/ro_RO, languages/ru_RU, languages/sk_SK, languages/sl_SI, languages/sv_SE, languages/tr_TR, languages/vi_VN, languages/zh_CN, languages/zh_TW

# concrete5 Cache Settings
Block Cache - On
Overrides Cache - On
Full Page Caching - Off

# Server Software
Apache/2.4.9 (Win32) OpenSSL/0.9.8y PHP/5.4.27

# Server API
apache2handler

# PHP Version
5.4.27

# PHP Extensions
apache2handler, bcmath, bz2, calendar, Core, ctype, curl, date, dom, ereg, exif, fileinfo, filter, ftp, gd, gettext, hash, iconv, json, libxml, mbstring, mcrypt, mhash, mysql, mysqli, mysqlnd, odbc, openssl, pcre, PDO, pdo_mysql, pdo_sqlite, Phar, Reflection, session, SimpleXML, soap, sockets, SPL, sqlite3, standard, tokenizer, wddx, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, zlib.

# PHP Settings
max_execution_time - 30
log_errors_max_len - 1024
max_file_uploads - 20
max_input_nesting_level - 64
max_input_time - 60
max_input_vars - 1000
memory_limit - 128M
post_max_size - 8M
sql.safe_mode - Off
upload_max_filesize - 2M
mysql.max_links - Unlimited
mysql.max_persistent - Unlimited
mysqli.max_links - Unlimited
mysqli.max_persistent - Unlimited
odbc.max_links - Unlimited
odbc.max_persistent - Unlimited
pcre.backtrack_limit - 1000000
pcre.recursion_limit - 100000
session.cache_limiter - nocache
session.gc_maxlifetime - 7200
soap.wsdl_cache_limit - 5

Browser User-Agent String

Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.