HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


ocPortal Support Credits Add-on Conversion

Login / Search

 [ Join | More ]
 Add topic 
Posted
Item has a rating of 5 (Liked by Chris GrahamLiked by sholzyLiked by Jean)  
Rating:
#95927 (In Topic #19068)
Avatar

Community saint

I've begun making it more portable

@Chris if scanning please see questions at end if you can thanks!

Just letting everyone know I have begun conversion of this Add-on to be more portable. Chris has been kind enough to release this addon even though it was only built primarily for ocProducts own purposes therefore most of the integration is hard-coded for ocPortal.coms needs.

So far I have converted all the Mantis files to replace all hard-coded values into variables and language string definitions.

I have put all the new variables into the config_inc file and now anyone can install this add-on and simply change the appropriate settings in that one file and all Mantis areas will work seamlessly as they do here on ocPortal.com. All text output was also converted to language definitions and are now in the Mantis English language file with each set of changes Commented Above the changes as "ocPortal Additions" to make for easy search and replace if someone would like to define them in other languages ;-)

So far my local tests seem to be proving to work out ok but I have only just finished the Mantis file conversions. Note I had to add a Custom Field called "
Time estimation (hours)" in mantis and a custom profile field called "Support Credits" ( which I can define in the Mantis config_inc file) in ocPortal. I still have to see what is involved in changing all the actual ocPortal source files to be portable as well which I am assuming means I will probably have to create some template files and such.

I will add everything to the Tracker and Git when it is ready.

Anyway, on of my purposes to announcing this and explaining it is so i can ask Chris (if he can afford the few minutes of explanation) some questions.

@CHRIS -

1. If you can, would you please provide me with a quick list of ocPortal members Custom Profile fields and how they are defined as related to the tracker? ie: I made a custom profile field called support_credits and set to owner can view but not set (is this right?) and should I add more?

2. When I add to git would you like me to rename the add-on so as not to conflict with your personal version (and/or would you be willing to test my version to see if it all works fine for you?)

3. Currently all the conversion is directly to the ocPortal Support Credits addon /tracker (ie mantis) files as is. I do intend to hopefully try and apply those conversions to the latest Mantis (1.2.14) possibly. If I succeed and that works fine would you prefer I just upload that version or both? The current is based on Mantis 1.2.0 according to your notes.

4. Lastly as a continued part to Question 1 is there anything else you can think of that I will need to do that you can give me a quick pointer on to save some time as file compares and such took a considerable amount of time to sort through to find all changes I had to make especially since I seemed to have 2 different copies of "Traker" files for some reason and the first set I had made all changes to weren't the correct ones from the ocPort Support Credits add-on?

lol. Sheesh it was a bummmer cause the one I had first, had a bunch of links to more learning etc in one of the files that I converted to a Multidimensional array defined in the config file and looped through added all the Language definitions too and then discovered you'd removed all those links in the actual add-ons files (duno where i got the extra version of tracker from? lol\)

Thanks Chris for any help you can offer!
Back to the top
 
Posted
Rating:
#95929
Avatar

This is cool. Feel free to commit your version over what we have in git :).

and/or would you be willing to test my version to see if it all works fine for you?

Kinda. I'll fix it if it doesn't work, next time I need it :lol:.

So, the ocPortal.com addons go back all the way to v1 really. But because they were originally just quick&dirty code mods, rather than publicly maintained, things may be messy. Theoretically there is installed code, in adminzone/pages/modules_custom/admin_customers.php:

Code

ocf_make_custom_field('ocp_support_credits',1,'','',0,0,0,0,'integer');
But of course it's not something we exactly need to test a lot!

Btw, it would be helpful to people if you can put a clean Mantis SQL dump into git. I presume you would have had to separately install Mantis to get the DB.

I do intend to hopefully try and apply those conversions to the latest Mantis (1.2.14) possibly.

I'd advise against trying this. We've actually done quite a few modifications to Mantis, and you'd need to do extensive diffing to see what they are and then reapply. Probably it would take even me a couple of days. Some were to make it more user-friendly, because out-of-the-box it's a bit of a monster. Some will have been to make the sponsorship system play better with our support credits.

We've separately been applying relevant Mantis security fixes, or deleting parts of Mantis which were unused but insecure. Fixes that aren't relevant (e.g. relating to complex permission schemes we don't use) aren't applied.

In the ideal world, I would have joined the Mantis team on some level and submitted patches. But the tracker evolved quite a bit, it wasn't really planned for it to diverge as it did. I learnt my lesson and when we recently deployed ISPConfig for our own purposes, I actually made a proper patch to give back to them ;).

I seemed to have 2 different copies of "Traker" files for some reason and the first set I had made all changes to weren't the correct ones from the ocPort Support Credits add-on?

Erm, not sure what this'd be.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#95935
Avatar

Community saint

Awesome thanks for the pointers Chris. I will avoid the 1.2.14 upgrade then.

When I first started out converting I couldn't remember what version of Mantis you used and that first copy of tracker I was working on had no note of it so I downloaded latest version and guessed at 2 older version 1.0.7 and 1.1.2 I think anyway as you can imagine it sure made file comparisons a headache for a while and wasted alot of my time lol. Once I had the 1.2.0 v things were alot clearer but I had to then start remerging my changes from the one tracker to the other and I don't know either how I got the to different sets? Some of the files are very similar but the proper one has quite a few differences.

I'll be sure to get a clean SQL to pack with it too.
I did install from mantis (I think mabe the 1.2.14 actually) and then deleted and copied over the support credits files.

Only thing I see I need to fix so far is I used the URL you used for Currency conversion link (and left it semi hard-coded) but I had changed the section to cycle through Alternate Currencies (set in the config as an array along with primary currency as independant config option) so it can output links to more than one alternate currency for conversion but that link fails as the site has changed its urls I believe so I have to change that and may update it to also be a config option (the url for conversion)

I am out of town and only have litmited inet access via phone tethering that's already over the monthly limit lol so any uploads will have to wait till I am home again in a few days.

Will keep you posted

Thanks again!
Back to the top
 
Posted
Rating:
#95936
Avatar

Community saint

Another Quick Question Chris:

Do you use the regular ecomerce addon to handle the purchasing of support credits? and if so did you make any modifications to it for the purposes of the saving (or assigning) support credits to the users? and if so do you know off hand what files under which add-on I should look for that (ie ocportalcom addon or support credits itself?)
Back to the top
 
Posted
Rating:
#95937
Avatar

Community saint

Sorry to bug Chris but I am playing trying to figure out what I can on my own and sometimes I get lost lol.

Ok so is there somewhere I can see what I have sponsored already? I just bought a support credit (to test things out a little here) and my profile says 3 (I remember buying 2 before but I was sure I spent them on a feature but can't remember what) then inside the tracker here I notice it says I have 1 credit to spend (should my profile here not also say 1?)



EDIT found the feature I sponsored before with 2 credits I was right. ok I think I get this now. Profile here lists the total I have bought inside tracker it subtracts from that what I have committed to sponsorship.
Back to the top
 
Posted
Rating:
#95940
Avatar

Duck said

Another Quick Question Chris:

Do you use the regular ecomerce addon to handle the purchasing of support credits? and if so did you make any modifications to it for the purposes of the saving (or assigning) support credits to the users? and if so do you know off hand what files under which add-on I should look for that (ie ocportalcom addon or support credits itself?)

ocportalcom_support_credits addon (same as tracker is in); sources_custom/hooks/systems/ecommerce/support_credits.php.
i.e. we wrote a hook that defines products.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#95941
Avatar

Duck said

Sorry to bug Chris but I am playing trying to figure out what I can on my own and sometimes I get lost lol.

Ok so is there somewhere I can see what I have sponsored already? I just bought a support credit (to test things out a little here) and my profile says 3 (I remember buying 2 before but I was sure I spent them on a feature but can't remember what) then inside the tracker here I notice it says I have 1 credit to spend (should my profile here not also say 1?)



EDIT found the feature I sponsored before with 2 credits I was right. ok I think I get this now. Profile here lists the total I have bought inside tracker it subtracts from that what I have committed to sponsorship.

Yes. You could have asked without paying us to to do a check, but I won't complain :lol:.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#95953
Avatar

Community saint

Well Mantis side of things appears to work well but boy the ocPortal side of things is not going to be so easy me thinks lol. I sure get lost in there.

It is something made even more difficult without inet access to try and compare how things happen here and stuff but i will keep plugging away.

Thanks again for pointers Chris.
Back to the top
 
Posted
Rating:
#96050
Avatar

Community saint

@Chris

How do I get the Tabs part of the Trackerlist to show?

I am looking at the main_mantis_tracker.php block and I see nothing that references the tabs for Popular Hard Easy etc as you see on here.

here is the code of that file

Expand:

Back to the top
 
Posted
Rating:
#96060
Avatar

Yeah, that's just Comcode. A number of block instances are called up, each with different block parameters, each put in a different tab.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#96071
Avatar

Community saint

Ah ha! Darn that comcode keeps surprising me! Love it.
Back to the top
 
Posted
Rating:
#96078
Avatar

Community saint

Just adding link in this topic to anouncement in other topic to make easier finding later for those reading this thread.

View topic: Tracker side of support credits addon committed - ocPortal.com
Back to the top
 
Posted
Rating:
#96142
Avatar

Community saint

@Chris

Ok I've been pulling out my hair forever on this one would you mind terribly scanning this over quickly and telling me what I am doing wrong?

Forgive some of the sloppy parts that are unfinished and as well I changed things a hundred times trying to figure out what is wrong but final code will be better but first I want to know why this won't output?
 
Things to Note: The Query is working and returning the results so its not the query (everything works up till there fine) it is something to do with the outputting to the tempcode portion. I am testing this on 8.1.7 but all the functions I have searched exist there as well as 9.06 so I don't think that is it?

Here is code:

Code

$start=get_param_integer('start',0);
$max=get_param_integer('max',50);
$csv=get_param_integer('csv',0);
if ($csv)
{
   if (function_exists('set_time_limit')) @set_time_limit(0);
   $start=0; $max=10000;
}

require_code('ocf_members');
require_code('mantis');
require_code('tempcode');

$field_id = get_credits_profile_field_id();
if(!is_null($field_id)){
   require_lang('ocf');
   require_lang('customers');

   $title = do_lang_tempcode('UNSPENT_SUPPORT_CREDITS');
   $uname = do_lang_tempcode('USERNAME');
   $ucredits = do_lang_tempcode('CREDITS');
   $ujoin = do_lang_tempcode('JOIN_DATE');
   $ulast = do_lang_tempcode('LAST_VISIT_TIME');

   $sortables=array('username'=>$uname,'credits'=>$ucredits,'join_date'=>$ujoin,'last_visit'=>$ulast);
   $test=explode(' ',get_param('sort','username DESC'),2);
   if (count($test)==1) $test[1]='DESC';
   list($sortable,$sort_order)=$test;
   if (((strtoupper($sort_order)!='ASC') && (strtoupper($sort_order)!='DESC')) || (!array_key_exists($sortable,$sortables)))
   log_hack_attack_and_exit('ORDERBY_HACK');
   global $NON_CANONICAL_PARAMS;
   $NON_CANONICAL_PARAMS[]='sort';
   $orderby = 'CAST(field_'.$field_id.' AS UNSIGNED)';
   switch ($sortable) {
      case 'username':
         $orderby = 'm_username';
         break;
      case 'join_date':
         $orderby = 'm_join_time';
         break;
      case 'last_visit':
         $orderby = 'm_last_visit_time';
         break;
      case 'credits':
      default:
         $orderby = 'CAST(field_'.$field_id.' AS UNSIGNED)';
         break;
   }
   //$csv_data = array();
   require_code('templates_results_table');
   $fields_title=results_field_title(array($uname,$ucredits,$ujoin,$ulast),$sortables,'sort',$sortable.' '.$sort_order);
   $fields_values=new ocp_tempcode();

   $members=$GLOBALS['FORUM_DB']->query('SELECT a.m_username AS m_username, a.m_join_time AS m_join_time, a.m_last_visit_time AS m_last_visit_time, b.mf_member_id, CAST(field_'.$field_id.' AS UNSIGNED) FROM '.$GLOBALS['FORUM_DB']->get_table_prefix().'f_member_custom_fields b JOIN '.$GLOBALS['FORUM_DB']->get_table_prefix().'f_members a ON a.id = b.mf_member_id WHERE '.db_string_not_equal_to('field_'.$field_id,'').' AND CAST(field_'.$field_id.' AS UNSIGNED)>0 ORDER BY '.$orderby.' '.$sort_order);
   if (count($members)<1) warn_exit('NO Results Sorry!');
   //if (count($members)>2) warn_exit('Wow we found some!');
   $total=0;
   $i = 0;
   foreach ($members as $member)
   {
      $credits=$member['field_'.$field_id];
      $member_id = intval($member['mf_member_id']);
      $member_name = $member['m_username'];
      $member_join_date = get_timezoned_date($member['m_join_time']);
      $member_visit_date = get_timezoned_date($member['m_last_visit_time']);
/*
      $csv_data[] = array(
         'Ůsername'=>$member_name,
         'Credits'=>$credits,
         'Join Date'=>$member_join_date,
         'Last Visited'=>$member_visit_date
      );
   */
      $member_linked = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($member_id);
      $fields_values->attach(results_entry(array($member_linked,integer_format($credits),$member_join_date,$member_visit_date)));
      $total+=$credits;
      $i++;
   }
   //if ($csv) make_csv($real_data,'users_online.csv');
   $msg = do_lang_tempcode('TOTAL_UNSPENT_SUPPORT_CREDITS', strval($total));
   $list=results_table(do_lang_tempcode('UNSPENT_SUPPORT_CREDITS'),$start,'start',$max,'max',$i,$fields_title,$fields_values,$sortables,$sortable,$sort_order,'sort',$msg);
   //$out=new ocp_tempcode();
   breadcrumb_set_parents(array(array('_SELF:_SELF:',do_lang_tempcode('UNSPENT_SUPPORT_CREDITS'))));
   return do_template('SUPPORT_CREDITS_OUTSTANDING_SCREEN',array('TITLE'=>$title,'DATA'=>$list));
   //$out->evaluate_echo(do_template('SUPPORT_CREDITS_OUTSTANDING_SCREEN',array('TITLE'=>$title,'DATA'=>$list)));
}
else
{
warn_exit(do_lang_tempcode('INVALID_FIELD_ID'));
}
Back to the top
 
Posted
Rating:
#96145
Avatar

Hi,

A bit tired tonight now but will take a look tomorrow.

Could you tell me what the code's for though just so I can double check against that explanation. Particularly, what is the query designed to return?


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#96146
Avatar

Community saint

This is a rewrite of admin_zone/pages/miniblocks_custom/outstanding_credits

(part of the Support Credits add-on)

Language Definitions exist.

The template SUPPORT_CREDITS_OUTSTANDING_SCREEN was added to the templates_custom directory and contains this:

Code

<h2>{TITLE}</h2>

<div class="link_exempt_wrap">
   {DATA}
</div>
I wrote a function in mantis.php to look up the ocp_support_credits profile field and return the id (and it works fine) here is code:

EDIT - Well to say "I" wrote a function in mantis.php is probably unfair wording, as with much of the rest of the code in that miniblock, I really just copied the routine already written. I then moved it out of the block into mantis.php (which I figured will become the model for the addon) and turned it into a function adding only slightly to it. But I figured it is better there in the model so that it can (and likely will) be re-used from other places.

Code

function get_credits_profile_field_id($field_name='ocp_support_credits')
{
   if(preg_match("/\W/", $field_name)) log_hack_attack_and_exit('HACK_ATTACK');
   $fields=ocf_get_all_custom_fields_match(NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,NULL);
   $field_id=NULL;
   foreach ($fields as $field)
   {
      if ($field['trans_name']==$field_name)
      {
         $field_id=$field['id'];
         break;
      }
   }
   return $field_id;
}

I have 3 users in my test db with unspent credits and it should list Their name (as link to profile) , Their unspent Credits, their join date and last visited date. Query run manually works perfect in phpmyadmin (even though I tried modifying it to see if it made chages) and if I uncomment the line I added in that sends a warning if $members has more than 2 rows I get the warning screen so I know it is getting the query results. But with it commented out the Screen flashes real quick with a message like "Requested Page doesn't exist" or something like that before it quickly redirects to 404


Last edit: by Duck
Back to the top
 
Posted
Rating:
#96158
Avatar

I did just find that:

Code

CAST(field_'.$field_id.' AS UNSIGNED)
needs to be:

Code

CAST(field_'.$field_id.' AS UNSIGNED) AS field_'.$field_id.'
i.e.

Code

      $members=$GLOBALS['FORUM_DB']->query('SELECT a.m_username AS m_username, a.m_join_time AS m_join_time, a.m_last_visit_time AS m_last_visit_time, b.mf_member_id, CAST(field_'.$field_id.' AS UNSIGNED) AS field_'.$field_id.' FROM '.$GLOBALS['FORUM_DB']->get_table_prefix().'f_member_custom_fields b JOIN '.$GLOBALS['FORUM_DB']->get_table_prefix().'f_members a ON a.id = b.mf_member_id WHERE '.db_string_not_equal_to('field_'.$field_id,'').' AND CAST(field_'.$field_id.' AS UNSIGNED)>0 ORDER BY '.$orderby.' '.$sort_order);

This got it to the point where it was trying to render the template. If there's still a problem after fixing this, please let me know.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#96159
Avatar

Community saint

NOPE it is not the query. I did make the change you suggested (as matter of fact I had it that way once already I believe I have changed the query several times lol and I shouldn't need all the AS's I believe)

But to be sure I put the query as you said and put it into the old file just echoing out the table and it worked fine.

My guess is the problem is one of these areas:

Code

$fields_values->attach(results_entry(array($member_linked,integer_format($credits),$member_join_date,$member_visit_date)));

Code

$msg = do_lang_tempcode('TOTAL_UNSPENT_SUPPORT_CREDITS');

Code

$list=results_table(do_lang_tempcode('UNSPENT_SUPPORT_CREDITS'),$start,'start',$max,'max',$i,$fields_title,$fields_values,$sortables,$sortable,$sort_order,'sort',$msg);

Code

do_template('SUPPORT_CREDITS_OUTSTANDING_SCREEN',array('TITLE'=>$title,'DATA'=>$list));
I don't get any errors so don't know what is wrong?
Back to the top
 
Posted
Rating:
#96160
Avatar

Will take another look then, prob this evening (buried in code at mo).


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#96161
Avatar

Community saint

Just so you know this outputs fine:

Code

require_code('ocf_members');
$fields=ocf_get_all_custom_fields_match(NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,NULL);

$field_id=NULL;
foreach ($fields as $field)
{
   if ($field['trans_name']=='ocp_support_credits')
   {
      $field_id=$field['id'];
      break;
   }
}
   require_lang('ocf');
   require_lang('customers');

   $title = do_lang_tempcode('UNSPENT_SUPPORT_CREDITS');
   $uname = do_lang_tempcode('USERNAME');
   $ucredits = do_lang_tempcode('CREDITS');
   $ujoin = do_lang_tempcode('JOIN_DATE');
   $ulast = do_lang_tempcode('LAST_VISIT_TIME');

   $sortables=array('username'=>$uname,'credits'=>$ucredits,'join_date'=>$ujoin,'last_visit'=>$ulast);
   $test=explode(' ',get_param('sort','username DESC'),2);
   if (count($test)==1) $test[1]='DESC';
   list($sortable,$sort_order)=$test;
   if (((strtoupper($sort_order)!='ASC') && (strtoupper($sort_order)!='DESC')) || (!array_key_exists($sortable,$sortables)))
   log_hack_attack_and_exit('ORDERBY_HACK');
   global $NON_CANONICAL_PARAMS;
   $NON_CANONICAL_PARAMS[]='sort';
   $orderby = 'CAST(field_'.$field_id.' AS UNSIGNED)';
   switch ($sortable) {
      case 'username':
         $orderby = 'm_username';
         break;
      case 'join_date':
         $orderby = 'm_join_time';
         break;
      case 'last_visit':
         $orderby = 'm_last_visit_time';
         break;
      case 'credits':
      default:
         $orderby = 'CAST(field_'.$field_id.' AS UNSIGNED)';
         break;
   }
echo '<h1>Unspent credits</h1>';

echo '<div class="wide_table_wrap"><table class="solidborder wide_table"><thead><tr><th>Username</th><th>Credits</th><th>Join date</th><th>Visit</th></tr></thead><tbody>';

   $members=$GLOBALS['FORUM_DB']->query('SELECT a.m_username AS m_username, a.m_join_time AS m_join_time, a.m_last_visit_time AS m_last_visit_time, b.mf_member_id, CAST(field_'.$field_id.' AS UNSIGNED) FROM '.$GLOBALS['FORUM_DB']->get_table_prefix().'f_member_custom_fields b JOIN '.$GLOBALS['FORUM_DB']->get_table_prefix().'f_members a ON a.id = b.mf_member_id WHERE '.db_string_not_equal_to('field_'.$field_id,'').' AND CAST(field_'.$field_id.' AS UNSIGNED)>0 ORDER BY '.$orderby.' '.$sort_order);
$total=0;
foreach ($members as $member)
{
   $credits=$member['field_'.strval($field_id)];
         $member_id = intval($member['mf_member_id']);
         $member_name = $member['m_username'];
         $member_join_date = get_timezoned_date($member['m_join_time']);
      $member_visit_date = get_timezoned_date($member['m_last_visit_time']);
      $member_linked = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($member_id);

   echo '<tr>';
   echo '<td>'.static_evaluate_tempcode($member_linked).'</td>';
   echo '<td>'.$credits.'</td>';
   echo '<td>'.$member_join_date.'</td>';
   echo '<td>'.$member_visit_date.'</td>';
   echo '</tr>';

   $total+=$credits;
}

echo '<tfoot><tr><td></td><td style="font-weight: bold">'.number_format($total).'</td><td></td></tr></tfoot>';

echo '</tbody></table>';
Back to the top
 
Posted
Rating:
#96162
Avatar

It actually runs on ocportal.com when I try it. Are you testing on your machine, or is it on somewhere online I can debug?


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Expand