Skip to content
Browse files

jun09 branch

  • Loading branch information...
1 parent 0da2d3f commit 0eb47e5294cd794c3ac59ac3914b1c9706305f1f Jeff Reifman committed Jun 9, 2009
Showing with 2,412 additions and 5,989 deletions.
  1. +1 −1 core/classes/adCode.class.php
  2. +1 −1 core/classes/challenges.class.php
  3. +1 −1 core/classes/comments.class.php
  4. +7 −5 core/classes/content.class.php
  5. +139 −35 core/classes/cron.class.php
  6. +2 −0 core/classes/dbConsoleModel.class.php
  7. +4 −2 core/classes/dynamicTemplate.class.php
  8. +24 −0 core/classes/newswire.class.php
  9. +8 −0 core/classes/researchLogDump.class.php
  10. +64 −5 core/classes/researchUserCollective.class.php
  11. +3 −0 core/classes/template.class.php
  12. +4 −0 core/engine.php
  13. +9 −50 core/utilities/initDatabase.php
  14. +2 −1 docs/setup.txt
  15. +37 −2 facebook/Social Media Toolkit.tmproj
  16. +22 −1 facebook/ajax.php
  17. +231 −80 facebook/classes/account.class.php
  18. +0 −3 facebook/classes/actionTeam.class.php
  19. +0 −10 facebook/classes/facebookCron.class.php
  20. +0 −43 facebook/classes/pageWall.class.php
  21. +17 −10 facebook/classes/pages.class.php
  22. +1 −1 facebook/classes/profileBoxes.class.php
  23. +9 −2 facebook/classes/session.class.php
  24. +0 −31 facebook/emailAttach.php
  25. +3 −0 facebook/index.php
  26. +125 −26 facebook/lib/facebook.php
  27. +1 −1 facebook/lib/facebook_desktop.php
  28. +828 −97 facebook/lib/facebookapi_php5_restlib.php
  29. +64 −16 facebook/pages/pageAccount.class.php
  30. +34 −0 facebook/pages/pagePostStory.class.php
  31. +8 −0 facebook/postAuth.php
  32. +15 −2 facebook/scripts/newsroom.js
  33. +53 −53 facebook/styles/default.css
  34. +5 −19 facebook/utilities/initDatabase.php
  35. +7 −0 php/config.php
  36. +0 −9 php/console/actions/assign_widget.php
  37. +0 −14 php/console/actions/deleteFeedTemplates.php
  38. +0 −21 php/console/actions/downloadSettings.php
  39. +0 −3 php/console/actions/editTemplates.php
  40. +0 −11 php/console/actions/flushFeedList.php
  41. +0 −11 php/console/actions/initCronJobs.php
  42. +0 −13 php/console/actions/initProfileBox.php
  43. +0 −14 php/console/actions/registerFeedTemplates.php
  44. +0 −13 php/console/actions/remove_widget_from_stories.php
  45. +0 −11 php/console/actions/reset_widget_cover.php
  46. +0 −11 php/console/actions/reset_widget_sidebar.php
  47. +0 −16 php/console/actions/runCronJobs.php
  48. +0 −22 php/console/actions/siteStatus.php
  49. +0 −11 php/console/actions/syncAllocations.php
  50. +0 −16 php/console/actions/update_widget_location.php
  51. +0 −19 php/console/actions/uploadSettings.php
  52. +84 −2,315 php/console/console.php
  53. +15 −0 php/console/footer.php
  54. +31 −8 php/console/global.php
  55. +337 −57 php/console/header.php
  56. +91 −51 php/console/index.php
  57. +8 −1 php/console/save_template.php
  58. +0 −29 php/console/views/add_story_widget.php
  59. +0 −57 php/console/views/assign_prize.php
  60. +0 −463 php/console/views/award_prize.php
  61. +0 −89 php/console/views/challenge_fields.php
  62. +0 −53 php/console/views/challenges.php
  63. +0 −27 php/console/views/comment_fields.php
  64. +0 −38 php/console/views/comments.php
  65. +0 −39 php/console/views/completed_challenge_fields.php
  66. +0 −53 php/console/views/completed_challenges.php
  67. +0 −37 php/console/views/cronJobs.php
  68. +0 −43 php/console/views/dashboard.php
  69. +0 −43 php/console/views/friend_invite_credits.php
  70. +0 −73 php/console/views/leaders.php
  71. +0 −38 php/console/views/member_emails.php
  72. +0 −75 php/console/views/member_fields.php
  73. +0 −54 php/console/views/members.php
  74. +0 −15 php/console/views/modify_challenge.php
  75. +0 −14 php/console/views/modify_comment.php
  76. +0 −14 php/console/views/modify_completed_challenge.php
  77. +0 −14 php/console/views/modify_member.php
  78. +0 −14 php/console/views/modify_order.php
  79. +0 −14 php/console/views/modify_outboundmessage.php
  80. +0 −15 php/console/views/modify_prize.php
  81. +0 −14 php/console/views/modify_story.php
  82. +0 −14 php/console/views/modify_test.php
  83. +0 −14 php/console/views/modify_video.php
  84. +0 −14 php/console/views/modify_widget.php
  85. +0 −13 php/console/views/new_challenge.php
  86. +0 −13 php/console/views/new_comment.php
  87. +0 −13 php/console/views/new_completed_challenge.php
  88. +0 −13 php/console/views/new_member.php
  89. +0 −13 php/console/views/new_order.php
  90. +0 −13 php/console/views/new_outboundmessage.php
  91. +0 −13 php/console/views/new_prize.php
  92. +0 −13 php/console/views/new_story.php
  93. +0 −13 php/console/views/new_test.php
  94. +0 −13 php/console/views/new_video.php
  95. +0 −13 php/console/views/new_widget.php
  96. +0 −74 php/console/views/order_fields.php
  97. +0 −55 php/console/views/orders.php
  98. +0 −59 php/console/views/outboundmessage_fields.php
  99. +0 −45 php/console/views/outboundmessages.php
  100. +0 −25 php/console/views/place_widget.php
  101. +0 −104 php/console/views/prize_fields.php
  102. +0 −60 php/console/views/prizes.php
  103. +0 −10 php/console/views/send_outboundmessage.php
  104. +0 −52 php/console/views/story_fields.php
  105. +0 −36 php/console/views/story_posts.php
  106. +0 −19 php/console/views/test_fields.php
  107. +0 −8 php/console/views/video_fields.php
  108. +0 −31 php/console/views/video_posts.php
  109. +0 −36 php/console/views/view_challenge.php
  110. +0 −33 php/console/views/view_comment.php
  111. +0 −129 php/console/views/view_completed_challenge.php
  112. +0 −95 php/console/views/view_member.php
  113. +0 −21 php/console/views/view_member_email.php
  114. +0 −30 php/console/views/view_order.php
  115. +0 −54 php/console/views/view_outboundmessage.php
  116. +0 −42 php/console/views/view_prize.php
  117. +0 −46 php/console/views/view_story.php
  118. +0 −23 php/console/views/view_test.php
  119. +0 −19 php/console/views/view_video.php
  120. +0 −37 php/console/views/view_widget.php
  121. +0 −55 php/console/views/widget_fields.php
  122. +0 −30 php/console/views/widgets.php
  123. +2 −0 php/index.php
  124. +1 −1 php/scripts/statistics.js
  125. +5 −2 readme
  126. +12 −8 sites/climate/constants.php
  127. +4 −4 sites/climate/facebook/templates/bookmarklet.php
  128. +1 −1 sites/climate/facebook/templates/designHome.html
  129. +1 −1 sites/climate/facebook/templates/designParts.html
  130. +6 −6 sites/climate/facebook/templates/designProfileBox2.html
  131. +5 −5 sites/climate/facebook/templates/designRead.html
  132. +1 −1 sites/climate/facebook/templates/designTeam.html
  133. +1 −1 sites/climate/facebook/templates/designTeamFix.html
  134. +1 −1 sites/climate/facebook/templates/footer.php
  135. +9 −7 sites/minn/constants.php
  136. +44 −44 sites/minn/facebook/styles/default.css
  137. +4 −4 sites/minn/facebook/templates/bookmarklet.php
  138. +1 −1 sites/minn/facebook/templates/designBlocks.html
  139. +1 −1 sites/minn/facebook/templates/designChallenges.html
  140. +1 −1 sites/minn/facebook/templates/designHome.html
  141. +1 −1 sites/minn/facebook/templates/designParts.html
  142. +6 −6 sites/minn/facebook/templates/designProfileBox2.html
  143. +5 −5 sites/minn/facebook/templates/designRead.html
  144. +1 −1 sites/minn/facebook/templates/designResources.html
  145. +1 −1 sites/minn/facebook/templates/designTeam.html
  146. +1 −1 sites/minn/facebook/templates/designTeam2.html
  147. +1 −1 sites/minn/facebook/templates/designTeamFix.html
  148. +1 −1 sites/minn/facebook/templates/footer.php
View
2 core/classes/adCode.class.php
@@ -1 +1 @@
-<?php
+<?php
View
2 core/classes/challenges.class.php
@@ -172,7 +172,6 @@ function populateCommonChallenges()
array("automatic","optInSMS","Receive SMS updates from ".SITE_TITLE."","Receive announcements and feature updates via SMS (aka text messages). Click on \"Settings\" and then \"Would you like to receive sms notifications from us through facebook? (50 pts)\" and follow the instructions.","0","0","50","1","1","0","enabled"),
array("automatic","levelIncrease","Level up!","As you accumulate points, your User Level increases. When you reach a new level, we give you bonus points!","0","0","200","6","6","0","enabled"),
array("automatic","referReader","Reader referral","Earn points when someone reads a story you shared!","0","0","5","300","10","0","enabled"),
- array("automatic","betaTest","Beta Test ".SITE_TITLE."","This special challenge is awarded only to the beta-testers of ".SITE_TITLE.".","0","0","250","1","1","0","disabled"),
array("automatic","chatStory","Chat about a story in ".SITE_TITLE."","Strike up a conversation about a story with one of your Facebook friends using the chat widget on the story page sidebar. This is a great way to introduce friends to climate change issues! Fine print: Your friend must click through to read the story. If they are not ".SITE_TITLE." members, they will be required to authorize the application for you to receive credit.","0","0","25","1000","10","0","enabled"),
array("submission","addAppTab","Add App Tab to profile","Add the ".SITE_TITLE." application tab to your Facebook profile so your friends can see what you've been up to. See <a href=\"".URL_CANVAS."?p=faq\">the FAQ</a> for details. Then send us a screenshot of the tab on your profile! File size must be under 2mb. (Don't know how to take a screenshot? Once again, <a href=\"".URL_CANVAS."?p=faq\">hit up the FAQ</a>.)","0","0","100","1","0","0","disabled"),
@@ -181,6 +180,7 @@ function populateCommonChallenges()
array("submission","blog","Blog about ".SITE_TITLE."","Forget blogging about what you had for lunch. We know you love ".SITE_TITLE." -- so why not write a post about it on your blog and send us the link?","0","0","75","25","1","0","disabled"),
);
+// array("automatic","betaTest","Beta Test ".SITE_TITLE."","This special challenge is awarded only to the beta-testers of ".SITE_TITLE.".","0","0","250","1","1","0","disabled"),
echo "Populating common challenges if missing...<br />";
foreach ($challenges as $cfields)
View
2 core/classes/comments.class.php
@@ -205,7 +205,7 @@ function notifyOthers($comment,$story,&$app=NULL) {
$siteContentId=$comment['siteContentId'];
$storyPoster=$story->userid;
//$ignoreLink="http://www.newscloud.com/ver/igCom/{safeEmail}/{actCode}/".$commentid;
- $profileLink='<a href="'.URL_CANVAS.'?p=account&o=settings">Stop comment notifications?</a>';
+ $profileLink='<a href="'.URL_CANVAS.'?p=account&o=subscribe">Change notifications?</a>';
$storyLink='<a href="'.URL_CANVAS.'?p=read&cid='.$siteContentId.'&nc">'.$story->title.'</a>'; // nc for no cache
$app->loadFacebookLibrary();
// check that commenter is not the poster
View
12 core/classes/content.class.php
@@ -38,7 +38,8 @@ class ContentTable
"isBlocked" => "TINYINT(1) default 0",
"videoid" => "INT(11) default 0",
"widgetid" => "INT(11) default 0",
- "isBlogEntry" => "TINYINT(1) default 0"
+ "isBlogEntry" => "TINYINT(1) default 0",
+ "isFeatureCandidate" => "TINYINT(1) default 0"
);
static $keydefinitions = array();
@@ -140,7 +141,7 @@ function createStoryContent($userinfo=NULL,$info=NULL,$mode='link') {
$isBlogEntry=0;
else
$isBlogEntry=1;
- $story=$this->serialize(0,$info->title,$info->caption,$info->source,$info->url,$info->permalink,$userinfo->ncUid,$userinfo->u->name,$userinfo->userid,'',$userinfo->votePower,0,0,$info->imageUrl,0,$isBlogEntry);
+ $story=$this->serialize(0,$info->title,$info->caption,$info->source,$info->url,$info->permalink,$userinfo->ncUid,$userinfo->u->name,$userinfo->userid,'',$userinfo->votePower,0,0,$info->imageUrl,0,$isBlogEntry,$info->isFeatureCandidate);
// post wire story to content
$siteContentId=$this->add($story);
if ($info->videoEmbed<>'') {
@@ -188,8 +189,8 @@ function add($story) {
$chkDup=$this->db->queryC("SELECT siteContentId FROM Content WHERE permalink='$story->permalink';");
if (!$chkDup) {
// insert the story into the table
- $this_query=$this->db->insert("Content","contentid,title,caption,source,url,permalink,postedById,PostedByName,userid,date,score,isFeatured,imageid,videoid,isBlogEntry",
- "$story->contentid,'$story->title','$story->caption','$story->source','$story->url','$story->permalink',$story->postedById,'$story->postedByName',$story->userid,'$story->date',$story->score,$story->isFeatured,$story->imageid,$story->videoid,$story->isBlogEntry");
+ $this_query=$this->db->insert("Content","contentid,title,caption,source,url,permalink,postedById,PostedByName,userid,date,score,isFeatured,imageid,videoid,isBlogEntry,isFeatureCandidate",
+ "$story->contentid,'$story->title','$story->caption','$story->source','$story->url','$story->permalink',$story->postedById,'$story->postedByName',$story->userid,'$story->date',$story->score,$story->isFeatured,$story->imageid,$story->videoid,$story->isBlogEntry,$story->isFeatureCandidate");
$q=$this->db->query("SELECT siteContentId FROM Content WHERE url='$story->url' AND permalink='$story->permalink';");
$data=$this->db->readQ($q);
$contentImageQuery = $this->db->insert("ContentImages", "url, siteContentId, date", "'$story->imageUrl', $data->siteContentId, NOW()");
@@ -226,7 +227,7 @@ function updateCommentCount($siteContentId) {
$this->db->update("Content","numComments=numComments+1","siteContentId=$siteContentId");
}
- function serialize($contentid=0,$title='',$caption='',$source='',$url='',$permalink='',$postedById=0,$postedByName='',$userid=0,$date='',$score=0,$isFeatured=0,$imageid=0, $imageUrl='',$videoid=0,$isBlogEntry=0) {
+ function serialize($contentid=0,$title='',$caption='',$source='',$url='',$permalink='',$postedById=0,$postedByName='',$userid=0,$date='',$score=0,$isFeatured=0,$imageid=0, $imageUrl='',$videoid=0,$isBlogEntry=0,$isFeatureCandidate=0) {
// creates an object for an action
$data= new stdClass;
$data->contentid = $contentid;
@@ -247,6 +248,7 @@ function serialize($contentid=0,$title='',$caption='',$source='',$url='',$permal
$data->imageid=$imageid;
$data->videoid=$videoid;
$data->isBlogEntry=$isBlogEntry;
+ $data->isFeatureCandidate=$isFeatureCandidate;
if (!is_numeric($data->score)) $data->score=1;
if (!is_numeric($data->postedById)) $data->postedById=0;
return $data;
View
174 core/classes/cron.class.php
@@ -1,4 +1,6 @@
<?php
+
+define ("PHP_MAX_SCRIPT",90); // # of seconds to limit jobs to
class CronJobsTable
{
@@ -12,20 +14,21 @@ class CronJobsTable
static $dbRowObjectClass = "CronJob";
static $fields = array(
- "freqMinutes" => "INT(2) default 0",
"task" => "VARCHAR(64) default ''",
"comments" => "VARCHAR(150) default ''",
"nextRun" => "timestamp",
"status" => "enum ('enabled','disabled') default 'enabled'",
- "dayOfWeek" => "VARCHAR(3) default ''",
- "hourOfDay" => "VARCHAR(2) default ''",
- "lastExecTime" => "INT(10) default 0",
+ "freqMinutes" => "INT(2) default 0", // run at a specific interval
+ "dayOfWeek" => "VARCHAR(3) default ''", // run on a specific day only
+ "hourOfDay" => "VARCHAR(2) default ''", // run at a specific hour only
+ "lastExecTime" => "INT(10) default 0",
"isRunning" => "TINYINT(1) default 0",
"lastStart" => "DATETIME",
"lastItemTime" => "DATETIME",
"failureNoticeSent" => "TINYINT(1) default 0"
);
static $keydefinitions = array();
+
///////////////////////////////////////////////////////////////////////////////////////////////////////
// standard table functions
function __construct(&$db=NULL)
@@ -69,6 +72,9 @@ class cron {
var $dayOfWeek;
var $cloudid;
var $apiKey;
+ var $startTime;
+ var $history;
+ var $cntJobs;
function cron($apiKey='') {
require_once (PATH_CORE.'/classes/db.class.php');
@@ -77,55 +83,129 @@ function cron($apiKey='') {
$this->dayOfWeek=date("D");
$this->hourOfDay=date("H");
require_once ('systemStatus.class.php');
- //$ssObj=new systemStatus($this->db);
- //$info=$ssObj->getProperties();
- //$this->cloudid=$info->cloudid;
$this->cloudid=SITE_CLOUDID;
+ $this->cntJobs=0;
+ $this->history=array();
}
+ function checkTime() {
+ if ((time()-$this->startTime)>PHP_MAX_SCRIPT) {
+ // time is up
+ $this->notifyAdmins('Alert: '.SITE_TITLE.' Cron tasks ran out of time','Cron exceeded '.PHP_MAX_SCRIPT.' seconds.');
+ return false;
+ } else
+ return true;
+ }
+
function fetchJobs() {
// log time of day
- $entryTime=time();
+ $entryTime=time();
+ $this->startTime=$entryTime;
+ // FIRST - run any jobs that are set for this particular day of week and time of day
+ if ($this->checkTime()) {
+ $jobList=$this->db->query("SELECT * FROM cronJobs WHERE hourOfDay='".$this->hourOfDay."' AND dayOfWeek='".$this->dayOfWeek."' AND nextRun<=now() AND status='enabled';");
+ $this->runJobList($jobList);
+ } else
+ return;
+
+ // SECOND - run any jobs that are set for this particular time of day
+ if ($this->checkTime()) {
+ $jobList=$this->db->query("SELECT * FROM cronJobs WHERE hourOfDay='".$this->hourOfDay."' AND dayOfWeek='' AND nextRun<=now() AND status='enabled';");
+ $this->runJobList($jobList);
+ } else
+ return;
+
+ // THIRD - run any jobs that are due to be run
//$this->log(date('g:i a \a\t D M n, Y',$entryTime));
// fetch jobs that need to be run
- $jobList=$this->db->query("SELECT * FROM cronJobs WHERE nextRun<now() AND status='enabled' ORDER BY freqMinutes ASC;");
- while ($job=$this->db->readQ($jobList)) {
- // reset next run timestamp to a later timestamp based on frequency in minutes
- echo '<b>Cron: '.$job->task.'</b><br/>';
- // if job must be run on a certain day, check for the right day
- if (($job->dayOfWeek=='' OR $job->dayOfWeek==$this->dayOfWeek)
- && ($job->hourOfDay=='' OR $this->hourOfDay > $job->hourOfDay))
- {
- //$this->log('Run '.$job->task);
- $startTime=time();
- try {
- $this->runJob($job);
- } catch (Exception $e) {
- $this->log('Failed running '.$job->task.', Error: '.$e);
- }
- $endTime=time();
- //$this->log(' exec time: '.(($endTime-$startTime)/60).' seconds');
- }
- }
+ if ($this->checkTime()) {
+ $jobList=$this->db->query("SELECT * FROM cronJobs WHERE hourOfDay='' AND dayOfWeek='' AND nextRun<=now() AND status='enabled' ORDER BY nextRun ASC;");
+ $this->runJobList($jobList);
+ } else
+ return;
+
+ // check for tasks running behind
+ $this->hasDelayedTasks();
+
+ // check for dead tasks
$this->hasDeadTasks();
+ // reboot dead tasks
+ $this->resetDeadTasks();
$exitTime=time();
//$this->log('Execution time total: '.(($exitTime-$entryTime)/60).' seconds');
+ //mail('newscloud@gmail.com', 'Job history: '.SITE_TITLE, $this->showHistory(), 'From: support@newscloud.com'."\r\n");
+ }
+
+ function runJobList($jobList) {
+ // processes a query of a list of cron jobs to run
+ while ($job=$this->db->readQ($jobList)) {
+ if ($this->checkTime()) {
+ // reset next run timestamp to a later timestamp based on frequency in minutes
+ echo '<b>Cron: '.$job->task.'</b><br/>';
+ //$this->log('Run '.$job->task);
+ $startTime=time();
+ try {
+ $this->runJob($job);
+ } catch (Exception $e) {
+ $this->log('Failed running '.$job->task.', Error: '.$e);
+ }
+ $endTime=time();
+ //$this->log(' exec time: '.(($endTime-$startTime)/60).' seconds');
+ } else
+ break;
+ }
+ }
+
+ function resetDeadTasks() {
+ $whereStr="isRunning=1 AND failureNoticeSent=1 AND status='enabled' AND lastStart<date_sub(NOW(), INTERVAL (freqMinutes+120) MINUTE)";
+ $resultStr=$this->db->buildIdList("SELECT task as id FROM cronJobs WHERE ".$whereStr);
+ if ($result<>'') {
+ $result=$this->db->query("SELECT * FROM cronJobs WHERE ".$whereStr);
+ while ($data=$this->db->readQ($result)) {
+ $this->db->update("UPDATE cronJobs SET isRunning=0,failureNoticeSent=0 WHERE id=".$data->id);
+ }
+ $subject='Alert'.SITE_TITLE.' Cron Jobs Auto Reset';
+ $msg='The following cronJobs have been reset: '.$resultStr.' ';
+ mail('newscloud@gmail.com', $subject, $msg, 'From: support@newscloud.com'."\r\n");
+ }
}
function hasDeadTasks() {
// looks for dead tasks and emails the admin
// task labeled as running but last started more than 15 minutes ago
- $result=$this->db->buildIdList("SELECT task as id FROM cronJobs WHERE isRunning=1 AND failureNoticeSent=0 AND status='enabled' AND lastStart<date_sub(NOW(), INTERVAL (freqMinutes+15) MINUTE);");
+ $whereStr="isRunning=1 AND failureNoticeSent=0 AND status='enabled' AND lastStart<date_sub(NOW(), INTERVAL (freqMinutes+15) MINUTE)";
+ $result=$this->db->buildIdList("SELECT task as id FROM cronJobs WHERE ".$whereStr);
if ($result<>'') {
- $q=$this->db->query("select email from User where isAdmin=1;");
- while ($data=$this->db->readQ($q)) {
- // Notify the admins
- mail($data->email, SITE_TITLE.' Cron Job Alert', 'Dave, this is Hal, I am noticing the following cronJobs are dead: '.$result.' When are you coming back to check on them?', 'From: support@newscloud.com'."\r\n");
- }
- $result=$this->db->update("cronJobs","failureNoticeSent=1", "isRunning=1 AND failureNoticeSent=0 AND status='enabled' AND lastStart<date_sub(NOW(), INTERVAL (freqMinutes+15) MINUTE)");
+ $subject='Alert'.SITE_TITLE.' Cron Job Failure';
+ $msg='The following cronJobs are dead: '.$result.' Please check on them.';
+ $this->notifyAdmins($subject,$msg);
+ $result=$this->db->update("cronJobs","failureNoticeSent=1", $whereStr);
+ }
+ }
+
+ function hasDelayedTasks() {
+ // looks for tasks missing their deadline by two hours and emails the admin
+ $whereStr="isRunning=0 AND failureNoticeSent=0 AND status='enabled' AND nextRun<date_sub(NOW(), INTERVAL (freqMinutes+120) MINUTE)";
+ $result=$this->db->buildIdList("SELECT task as id FROM cronJobs WHERE ".$whereStr);
+ if ($result<>'') {
+ $subject='Alert'.SITE_TITLE.' Cron Job Delayed Tasks Exist';
+ $msg='The following cronJobs are delay by more than two hours: '.$result.' Please check on them.';
+ $this->notifyAdmins($subject,$msg);
+ $result=$this->db->update("cronJobs","failureNoticeSent=1", $whereStr);
}
}
+ function notifyAdmins($subject='Alert: Cron',$msg='This is the sample cron alert message') {
+ $q=$this->db->query("select email from User where isAdmin=1;");
+ // add cron history
+ $msg.="\r\n".$this->showHistory();
+ while ($data=$this->db->readQ($q)) {
+ // Notify the admins
+ mail($data->email, $subject, $msg, 'From: support@newscloud.com'."\r\n");
+ }
+
+ }
+
function forceJob($task='') {
$entryTime=time();
//$this->log(date('g:i a \a\t D M n, Y',$entryTime));
@@ -144,6 +224,7 @@ function forceJob($task='') {
}
function runJob($job,$force=false) {
+ $stopAfterJob=false;
$startTime=microtime(true);
$this->log($job->task.', started '.date('g:i a \a\t D M n, Y',$startTime));
@@ -420,7 +501,7 @@ function runJob($job,$force=false) {
$proObj->updateProfileBoxes();
break;
case 'facebookEmailEngine':
- // invoke facebookCron class
+ // tbd
break;
case 'facebookAllocations':
// check nightly facebook allocations
@@ -454,6 +535,8 @@ function runJob($job,$force=false) {
require_once PATH_CORE."/classes/researchRawSession.class.php";
require_once PATH_CORE."/classes/researchRawExtLink.class.php";
require_once PATH_CORE."/classes/researchSessionLength.class.php";
+ require_once PATH_CORE."/classes/researchLogDump.class.php";
+ require_once PATH_CORE."/classes/researchUserCollective.class.php";
$rawExtLinkTable = new RawExtLinkTable($this->db);
$rawExtLinkTable->insertNewestData();
@@ -463,6 +546,15 @@ function runJob($job,$force=false) {
$sessionLengthTable = new SessionLengthTable($this->db);
$sessionLengthTable->insertNewestData();
+
+ $logDumpTable = new LogDumpTable($this->db);
+ $logDumpTable->insertNewestData();
+
+ $userCollectiveTable = new UserCollectiveTable($this->db);
+ $userCollectiveTable->assimilateUsers();
+
+ $stopAfterJob=true;
+
break;
case 'cleanup':
require_once ('cleanup.class.php');
@@ -471,9 +563,21 @@ function runJob($job,$force=false) {
}
$execTime=microtime(true)-$startTime;
$this->log('...completed in '.$execTime.' seconds.');
+ $this->history[$this->cntJobs]['task']=$job->task;
+ $this->history[$this->cntJobs]['time']=$execTime;
+ $this->cntJobs+=1;
$this->db->update("cronJobs","nextRun=date_sub(NOW(), INTERVAL (0-$job->freqMinutes) MINUTE),lastExecTime=$execTime,lastStart='".date('Y-m-d H:i:s',$startTime)."',isRunning=0","id=$job->id");
+ if ($stopAfterJob) exit;
}
+ function showHistory() {
+ $code='';
+ for ($i = 0; $i < $this->cntJobs; $i++) {
+ $code.=$this->history[$i]['task'].' -> '.$this->history[$i]['time'].' seconds'."\r\n";
+ }
+ return $code;
+ }
+
function listJobs() {
$jobList=$this->db->query("SELECT * FROM cronJobs ORDER BY freqMinutes ASC;");
return $jobList;
View
2 core/classes/dbConsoleModel.class.php
@@ -136,6 +136,8 @@ function load_all($sql = false) // option to override idname useful when cross-r
while ($row = mysql_fetch_assoc($res))
$results[] = $row;
+ if (dbConsoleModel::$debug) echo "<p>Found ".count($results)." results!</p>";
+
return $results;
}
View
6 core/classes/dynamicTemplate.class.php
@@ -162,11 +162,13 @@ function authEnableEditMode($session=null)
//echo 'Authorized editors: <pre>'.print_r($authorizedEditors, true).'</pre>';
if (array_search($fbId, $authorizedEditors) !== false)
- {
-
+ {
$this->editEnabled = true;
//echo '...Editing enabled!';
return true;
+ } else if (1==2) {
+ // to do - check if these fbIds are in the userinfo table as admins
+
} else
{
//echo '...Sorry, editing not enabled.';
View
24 core/classes/newswire.class.php
@@ -109,6 +109,30 @@ function fetchStoryFilter($filter='all') {
return $code;
}
+ function fetchRawStories() {
+ require_once(PATH_CORE.'/classes/template.class.php');
+ $this->templateObj=new template($this->db);
+ $this->templateObj->registerTemplates(MODULE_ACTIVE,'newswire');
+ require_once(PATH_CORE.'/classes/utilities.class.php');
+ $this->utilObj=new utilities($this->db);
+ $this->templateObj->db->result=$this->templateObj->db->query("SELECT SQL_CALC_FOUND_ROWS * FROM Newswire WHERE date<now() AND date > date_sub(NOW(), INTERVAL ".AGE_STORY_MAX_DAYS." DAY) ORDER BY date DESC LIMIT 50;");
+ $rowTotal=$this->templateObj->db->countFoundRows();
+ $this->templateObj->db->setTemplateCallback('timeSince', array($this->utilObj, 'time_since'), 'date');
+ $this->templateObj->db->setTemplateCallback('caption', array($this->templateObj, 'cleanString'), array('caption', 500));
+ $this->templateObj->db->setTemplateCallback('safeCaption', array($this, 'encodeCleanString'), array('caption', 500));
+ $this->templateObj->db->setTemplateCallback('safeUrl', array($this, 'encodeUrl'), 'url');
+ $code=$this->templateObj->mergeTemplate($this->templateObj->templates['rawList'],$this->templateObj->templates['autoItem']);
+ return $code;
+ }
+
+ function encodeCleanString($str,$cnt) {
+ return urlencode(substr(strip_tags($str), 0, ($cnt - 1)));
+ }
+
+ function encodeUrl($url) {
+ return urlencode($url);
+ }
+
function fetchNewswirePage($option='all',$filter='all',$memberFriends='',$currentPage=1) {
// filter = show posted stories or rss feeds
// sort for posted stories: sort by votes, sort by date
View
8 core/classes/researchLogDump.class.php
@@ -121,13 +121,21 @@ function dumpLogs() {
$row['isFeedPublished'],
$siteid
);
+ if ($log_count % 10000 == 0) {
+ $insert_sql = substr($insert_sql, 0, -1);
+ $this->db->selectDB('research');
+ $this->db->query($insert_sql);
+ $insert_sql = "REPLACE INTO LogDumps (userid1, action, itemid, itemid2, userid2, ncUid, t, dateCreated, status, isFeedPublished, siteid) VALUES ";
+ }
}
$insert_sql = substr($insert_sql, 0, -1);
if ($log_count > 0) {
$this->db->selectDB('research');
$this->db->query($insert_sql);
}
+
+ echo "\n Dumped $log_count log records.\n";
}
}
View
69 core/classes/researchUserCollective.class.php
@@ -23,6 +23,7 @@ class UserCollectiveTable
"userid" => "BIGINT(20) unsigned default 0",
"siteid" => "BIGINT(20) unsigned default 0",
"optInStudy" => "TINYINT(1) default 1", // user OKs conditions of data collection for study
+ "dateRegistered" => "DATETIME",
"researchImportance" => "TINYINT(1) default 0",
"gender" => "ENUM('male','female','other') ",
"age" => "TINYINT(1) default 0",
@@ -32,7 +33,22 @@ class UserCollectiveTable
"zip" => "VARCHAR(255) default ''",
"cachedPointTotal" => "INT(4) default 0" ,
"email" => "varchar(255) default ''",
- "isMember" => "TINYINT(1) default 0" // User has signed up with the local site
+ "isMember" => "TINYINT(1) default 0", // User has signed up with the local site
+ "rxConsentForm" => "TINYINT(1) default 0",
+ // Precalculated stats
+ "bookmarkToolAdded" => "VARCHAR(10) default ''",
+ "postStoryCount" => "INT(4) default 0",
+ "postCommentCount" => "INT(4) default 0",
+ "postBlogCount" => "INT(4) default 0",
+ "readStoryCount" => "INT(4) default 0",
+ "completedChallengeCount" => "INT(4) default 0",
+ "wonPrizeCount" => "INT(4) default 0",
+ "chatStoryCount" => "INT(4) default 0",
+ "inviteFriendsCount" => "INT(4) default 0",
+ "shareStoryCount" => "INT(4) default 0",
+ "tweetCount" => "INT(4) default 0",
+ "voteCount" => "INT(4) default 0",
+ "friendsSignUpCount" => "INT(4) default 0"
);
static $keydefinitions = array();
@@ -88,20 +104,41 @@ function assimilateUsers() {
$dbname = $dbinfo['dbname'];
$siteid = $dbinfo['siteid'];
$this->db->selectDB($dbname);
- $insert_sql = "REPLACE INTO UserCollectives (userid, siteid, eligibility, optInStudy, isMember, cachedPointTotal, email, researchImportance, gender, age, city, state, country, zip) VALUES ";
+ $insert_sql = "REPLACE INTO UserCollectives (userid, siteid, eligibility, optInStudy, dateRegistered,isMember, cachedPointTotal, email, researchImportance, gender, age, city, state, country, zip, rxConsentForm, bookmarkToolAdded, postStoryCount, postCommentCount, postBlogCount, readStoryCount, completedChallengeCount, wonPrizeCount, chatStoryCount, inviteFriendsCount, shareStoryCount, tweetCount, voteCount, friendsSignUpCount) VALUES ";
- $sql = "SELECT User.userid, User.eligibility, User.optInStudy, User.isMember, User.cachedPointTotal, User.email, UserInfo.researchImportance, UserInfo.gender, UserInfo.age, UserInfo.city, UserInfo.state, UserInfo.country, UserInfo.zip FROM User LEFT JOIN UserInfo ON User.userid = UserInfo.userid";
+
+ $sql = "SELECT User.userid, User.eligibility, User.optInStudy,User.dateRegistered, User.isMember, User.cachedPointTotal, User.email, UserInfo.researchImportance, UserInfo.gender, UserInfo.age, UserInfo.city, UserInfo.state, UserInfo.country, UserInfo.zip, UserInfo.rxConsentForm FROM User LEFT JOIN UserInfo ON User.userid = UserInfo.userid WHERE User.eligibility != 'ineligible'";
$user_results = $this->db->query($sql);
$user_count = 0;
while(($row = mysql_fetch_assoc($user_results)) !== false) {
+ $userid = $row['userid'];
+ $calc_sql = "SELECT
+ count(CASE WHEN action='postStory' THEN 1 ELSE null END) as postStoryCount,
+ count(CASE WHEN action='comment' THEN 1 else null end) as postCommentCount,
+ count(CASE WHEN action='postBlog' THEN 1 else null end) as postBlogCount,
+ count(CASE WHEN action='readStory' THEN 1 else null end) as readStoryCount,
+ count(CASE WHEN action='completedChallenge' THEN 1 else null end) as completedChallengeCount,
+ count(CASE WHEN action='wonPrize' THEN 1 else null end) as wonPrizeCount,
+ count(CASE WHEN action='chatStory' THEN 1 else null end) as chatStoryCount,
+ count(CASE WHEN action='invite' THEN 1 else null end) as inviteFriendsCount,
+ count(CASE WHEN action='shareStory' THEN 1 else null end) as shareStoryCount,
+
+ (SELECT count(1) FROM ChallengesCompleted WHERE challengeid = 48 AND userid = $userid) as tweetCount,
+ (SELECT count(1) FROM Log WHERE action = 'vote' AND userid1 = $userid) as voteCount,
+ if ( (select count(userid) from ChallengesCompleted where challengeid=10 AND ChallengesCompleted.userid = $userid) IS NOT NULL, 'Yes', 'No') as bookmarkToolAdded,
+ (SELECT count(1) FROM ChallengesCompleted WHERE challengeid = 15 AND userid = $userid) AS friendsSignUpCount
+ FROM Log WHERE Log.userid1 = $userid";
+ $calc_results = $this->db->query($calc_sql);
+ $calc_data = mysql_fetch_assoc($calc_results);
$row = array_map('mysql_real_escape_string', $row);
$user_count++;
- $insert_sql .= sprintf("('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'),",
+ $insert_sql .= sprintf("('%s','%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'),",
$row['userid'],
$siteid,
$row['eligibility'],
$row['optInStudy'],
+ $row['dateRegistered'],
$row['isMember'],
$row['cachedPointTotal'],
$row['email'],
@@ -111,8 +148,30 @@ function assimilateUsers() {
$row['city'],
$row['state'],
$row['country'],
- $row['zip']
+ $row['zip'],
+ $row['rxConsentForm'],
+ $calc_data['bookmarkToolAdded'],
+ $calc_data['postStoryCount'],
+ $calc_data['postCommentCount'],
+ $calc_data['postBlogCount'],
+ $calc_data['readStoryCount'],
+ $calc_data['completedChallengeCount'],
+ $calc_data['wonPrizeCount'],
+ $calc_data['chatStoryCount'],
+ $calc_data['inviteFriendsCount'],
+ $calc_data['shareStoryCount'],
+ $calc_data['tweetCount'],
+ $calc_data['voteCount'],
+ $calc_data['friendsSignUpCount']
);
+
+ if ($user_count % 1000 == 0) {
+ $insert_sql = substr($insert_sql, 0, -1);
+ $this->db->selectDB('research');
+ $this->db->query($insert_sql);
+ $insert_sql = "REPLACE INTO UserCollectives (userid, siteid, eligibility, optInStudy, dateRegistered,isMember, cachedPointTotal, email, researchImportance, gender, age, city, state, country, zip, rxConsentForm, bookmarkToolAdded, postStoryCount, postCommentCount, postBlogCount, readStoryCount, completedChallengeCount, wonPrizeCount, chatStoryCount, inviteFriendsCount, shareStoryCount, tweetCount, voteCount, friendsSignUpCount) VALUES ";
+ $this->db->selectDB($dbname);
+ }
}
$insert_sql = substr($insert_sql, 0, -1);
View
3 core/classes/template.class.php
@@ -86,6 +86,9 @@ function registerTemplates($module='',$group='') {
case 'teamactivity':
include PATH_TEMPLATES.'/teamactivity.php';
break;
+ case 'forum':
+ include PATH_TEMPLATES.'/forum.php';
+ break;
case 'signup':
include PATH_TEMPLATES.'/signup.php';
break;
View
4 core/engine.php
@@ -13,6 +13,10 @@
echo 'Invalid access!';
die();
}
+
+ // override default time limit
+ set_time_limit(300);
+
require_once(PATH_CORE.'/classes/cron.class.php');
$cObj=new cron($init['apiKey']);
// when you set init variable, we populate the job list for the first time
View
59 core/utilities/initDatabase.php
@@ -1,6 +1,5 @@
<?php
echo 'Beginning database initialization<br />';
- //include_once(PATH_SITE.'/constants.php');
// Set up clouds architecture local database
require_once(PATH_CORE.'/classes/dbManage.class.php');
$manageObj=new dbManage(false);
@@ -38,54 +37,10 @@
require_once(PATH_CORE.'/classes/content.class.php');
ContentTable::createTable($manageObj);
-
-
-/* // set up Content table
- $manageObj->addTable("Content","siteContentId","INT(11) unsigned NOT NULL auto_increment","MyISAM");
- $manageObj->addColumn("Content","contentid","INT(11) default 0");
- $manageObj->addColumn("Content","title","VARCHAR(255) default ''");
- $manageObj->addColumn("Content","caption","TEXT default ''");
- $manageObj->addColumn("Content","source","VARCHAR (150) default ''");
- $manageObj->addColumn("Content","url","VARCHAR(255) default ''");
- $manageObj->addColumn("Content","permalink","VARCHAR(255) default ''");
- $manageObj->addColumn("Content","postedById","INT(11) default 0");
- $manageObj->addColumn("Content","postedByName","VARCHAR(255) default ''");
- $manageObj->addColumn("Content","date","DATETIME");
- $manageObj->addColumn("Content","score","INT(4) default 0");
- $manageObj->addColumn("Content","numComments","INT(2) default 0");
- $manageObj->addColumn("Content","isFeatured","TINYINT(1) default 0");
- $manageObj->addColumn("Content","userid","INT(11) default 0");
- $manageObj->addColumn("Content","imageid","INT(11) default 0");
- */
- /*
- // set up the Comments table
- $manageObj->addTable("Comments","siteCommentId","INT(11) unsigned NOT NULL auto_increment","MyISAM");
- $manageObj->addColumn("Comments","commentid","INT(11) default 0");
- $manageObj->addColumn("Comments","siteContentId","INT(11) default 0");
- $manageObj->addColumn("Comments","contentid","INT(11) default 0");
- $manageObj->addColumn("Comments","comments","TEXT default ''");
- $manageObj->addColumn("Comments","postedByName","VARCHAR(255) default ''");
- $manageObj->addColumn("Comments","postedById","INT(11) default 0");
- $manageObj->addColumn("Comments","userid","INT(11) default 0");
- $manageObj->addColumn("Comments","date","DATETIME");
- */
require_once(PATH_CORE.'/classes/comments.class.php');
CommentTable::createTable($manageObj);
-/*
- // set up cronJobs table
- $manageObj->addTable("cronJobs","id","INT(11) unsigned NOT NULL auto_increment","MyISAM");
- $manageObj->addColumn("cronJobs","freqMinutes","INT(2) default 0");
- $manageObj->addColumn("cronJobs","task","VARCHAR(25) default ''");
- $manageObj->addColumn("cronJobs","comments","VARCHAR(150) default ''");
- $manageObj->addColumn("cronJobs","nextRun","timestamp");
- $manageObj->addColumn("cronJobs","status","enum ('enabled','disabled') default 'enabled'");
- $manageObj->addColumn("cronJobs","dayOfWeek","VARCHAR(3) default ''");
- $manageObj->addColumn("cronJobs","lastExecTime","INT(10) default 0");
- $manageObj->addColumn("cronJobs","isRunning","TINYINT(1) default 0");
- $manageObj->addColumn("cronJobs","lastStart","DATETIME");
- $manageObj->addColumn("cronJobs","lastItemTime","DATETIME");
-*/
+
require_once(PATH_CORE.'/classes/cron.class.php');
CronJobsTable::createTable($manageObj);
@@ -97,10 +52,7 @@
require_once(PATH_CORE.'/classes/log.class.php');
LogTable::createTable($manageObj);
-
- // $lt = new LogTable($manageObj->db);
- // $lt->testPopulate();
-
+
// Resources for Folders and Links
$manageObj->addTable("Folders","id","INT(11) unsigned NOT NULL auto_increment","MyISAM");
$manageObj->addColumn("Folders","folderid","INT(11) NOT NULL default 0");
@@ -162,6 +114,13 @@
// create AdCode Table
require_once(PATH_CORE.'/classes/adCode.class.php');
AdCodeTable::createTable($manageObj);
+
+ require_once(PATH_CORE.'/classes/subscriptions.class.php');
+ SubscriptionsTable::createTable($manageObj);
+
+ // create ForumTopics Table
+ require_once(PATH_CORE.'/classes/forum.class.php');
+ ForumTopicsTable::createTable($manageObj);
if (MODULE_FACEBOOK) {
include_once(PATH_FACEBOOK.'/utilities/initDatabase.php');
View
3 docs/setup.txt
@@ -240,4 +240,5 @@ e.g. 'reader','contributor','bronze','silver','gold','platinum'
Notes:
----------------------------------------------------------------------------------------
-* Caching does not operate when ENABLE_TEMPLATE_EDITS is on. So, some user interface features may not update when this mode is active
+* Caching does not operate when ENABLE_TEMPLATE_EDITS is on. So, some user interface features may not update when this mode is active
+* ENABLE_TEMPLATE_EDITS does not save changes unless a list of Facebook ids by admins is in the SystemStatus table with name template_editor_fbIds and strValue=comma separated list of admin FBIds
View
39 facebook/Social Media Toolkit.tmproj
@@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
+ <key>currentDocument</key>
+ <string>../sites/chitown/constants.php</string>
<key>documents</key>
<array>
<dict>
@@ -18,10 +20,43 @@
<key>fileHierarchyDrawerWidth</key>
<integer>288</integer>
<key>metaData</key>
- <dict/>
+ <dict>
+ <key>../sites/all/constants.php</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>2</integer>
+ <key>line</key>
+ <integer>21</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ </dict>
+ <key>../sites/chitown/constants.php</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>18</integer>
+ <key>line</key>
+ <integer>7</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ </dict>
+ </dict>
+ <key>openDocuments</key>
+ <array>
+ <string>../sites/chitown/constants.php</string>
+ </array>
<key>showFileHierarchyDrawer</key>
<true/>
<key>windowFrame</key>
- <string>{{353, 23}, {1492, 1155}}</string>
+ <string>{{353, 22}, {1492, 1155}}</string>
</dict>
</plist>
View
23 facebook/ajax.php
@@ -16,7 +16,14 @@
// session not required
switch ($method) {
case 'wall':
- $code='<fb:comments xid="'.CACHE_PREFIX.'_wall" canpost="true" candelete="true" numposts="25" callbackurl="'.URL_CALLBACK.'?p=ajax&m=wall"></fb:comments>';
+ $topic=requestInt('topic');
+ if ($topic==0)
+ $code='<fb:comments xid="'.CACHE_PREFIX.'_wall" canpost="true" candelete="true" numposts="25" callbackurl="'.URL_CALLBACK.'?p=ajax&m=wall"></fb:comments>';
+ else {
+ $app=setupAppFramework();
+ $code='<fb:comments xid="'.CACHE_PREFIX.'_wall_'.$topic.'" canpost="true" candelete="true" numposts="25" callbackurl="'.URL_CALLBACK.'?p=ajax&m=wall&topic='.$topic.'"></fb:comments>';
+ $db->update("ForumTopics","lastChanged=NOW(),numPostsToday=numPostsToday+1","id=$topic");
+ }
break;
case 'fetchDynamicDialog':
require_once(PATH_CORE ."/classes/template.class.php");
@@ -462,6 +469,20 @@
$code = "Error clearing template.";
break;
+ case 'previewPublish':
+ require_once(PATH_FACEBOOK.'/classes/autoPost.class.php');
+ $apObj=new autoPost($app);
+ $id=requestInt('id');
+ $code=$apObj->fetchPostForm($id);
+ $code.='end of form';
+ break;
+ case 'postPublish':
+ require_once(PATH_FACEBOOK.'/classes/autoPost.class.php');
+ $apObj=new autoPost($app);
+ $id=requestInt('id');
+ //$code=$apObj->fetchPostForm($id);
+ $code='all done';
+ break;
case 'addRawToJournal':
$error = false;
$limitSql = "SELECT COUNT(1) AS total FROM Log WHERE action = 'publishWire' AND userid1 = $userid AND t > '".date("Y-m-d H:i:s", time() - (12 * 60 * 60))."'";
View
311 facebook/classes/account.class.php
@@ -46,6 +46,8 @@ function initFormData() // init form structure filling in what we can from sessi
else
$fdata->showResearchImportance=false;
$fdata->noCommentNotify=0;
+ $fdata->rxFeatures=0;
+ $fdata->rxMode='notification';
if ($this->session->age<>'unknown')
$fdata->age=$this->session->age;
else
@@ -60,7 +62,7 @@ function initFormData() // init form structure filling in what we can from sessi
$fdata->city=$fbInfo[0]['current_location']['city'];
$fdata->state=$fbInfo[0]['current_location']['state'];
$fdata->country=$fbInfo[0]['current_location']['country'];
-
+ $fdata->zip=$fbInfo[0]['current_location']['zip'];
}
if ($this->debug) echo 'fbInfo:<pre>'.print_r($fbInfo,true).'</pre>';
@@ -124,43 +126,7 @@ function buildAccountInfoFormFields($fdata=null, $message='', $canChangePopulate
if ($this->accountTemplate->collectLocation)
{
- // location
- $code .= (!strlen($fdata->city) || $canChangePopulated) ?
- '<fb:editor-text label="City" name="city" value="'.$fdata->city.'"/>' :
- ('<fb:editor-custom label="City" name="city">'.$fdata->city.'</fb:editor-custom>'.
- '<input type="hidden" name="city" value="'.$fdata->city.'"/>') ;
- /* $code .= !strlen($fdata->state) ?
- '<fb:editor-text label="State" name="state" value="'.$fdata->state.'"/>' :
- '<fb:editor-custom label="State" name="state">'.$fdata->state.'</fb:editor-custom>';
- $code .= !strlen($fdata->country) ?
- '<fb:editor-text label="Country" name="country" value="'.$fdata->country.'"/>' :
- '<fb:editor-custom label="Country" name="country">'.$fdata->country.'</fb:editor-custom>';
- */
- if (!strlen($fdata->state) || $canChangePopulated)
- {
- $code .='<fb:editor-custom label="State/Province">'.
- '<select name="state"> '.
- $this->makeSelDrop('provinces', $fdata->state);
- '</select>';
- $code.= '</fb:editor-custom> ';
- } else
- {
- $code .= '<fb:editor-custom label="State" name="city">'.$fdata->state.'</fb:editor-custom>'.
- '<input type="hidden" name="state" value="'.$fdata->state.'"/>' ;
- }
-
- $code .='<fb:editor-custom label="Country">';
- if (!strlen($fdata->country) || $canChangePopulated)
- {
- $code .= '<select name="country"> '.
- $this->makeSelDrop('countries', 'United States');
- '</select>';
- } else
- {
- $code .= $fdata->country . '<input type="hidden" name="country" value="'.$fdata->country.'"/>' ;
- }
- $code.= '</fb:editor-custom> ';
-
+ $code.=$this->getLocationFields($fdata,$canChangePopulated);
}
/*if ($fdata->showOptIn)
@@ -205,6 +171,39 @@ function buildAccountInfoFormFields($fdata=null, $message='', $canChangePopulate
}
+ function getLocationFields($fdata,$canChangePopulated) {
+ // location
+ $temp .= (!strlen($fdata->city) || $canChangePopulated) ?
+ '<fb:editor-text label="City" name="city" value="'.$fdata->city.'"/>' :
+ ('<fb:editor-custom label="City" name="city">'.$fdata->city.'</fb:editor-custom>'.
+ '<input type="hidden" name="city" value="'.$fdata->city.'"/>') ;
+ if (!strlen($fdata->state) || $canChangePopulated)
+ {
+ $temp .='<fb:editor-custom label="State/Province">'.
+ '<select name="state"> '.
+ $this->makeSelDrop('provinces', $fdata->state);
+ '</select>';
+ $temp.= '</fb:editor-custom> ';
+ } else
+ {
+ $temp .= '<fb:editor-custom label="State" name="city">'.$fdata->state.'</fb:editor-custom>'.
+ '<input type="hidden" name="state" value="'.$fdata->state.'"/>' ;
+ }
+
+ $temp .='<fb:editor-custom label="Country">';
+ if (!strlen($fdata->country) || $canChangePopulated)
+ {
+ $temp .= '<select name="country"> '.
+ $this->makeSelDrop('countries', 'United States');
+ '</select>';
+ } else
+ {
+ $temp .= $fdata->country . '<input type="hidden" name="country" value="'.$fdata->country.'"/>' ;
+ }
+ $temp.= '</fb:editor-custom> ';
+ return $temp;
+
+ }
// signup specific wrapping and extra fields outside of core block
function buildSignupForm($fdata=null, $message='', $canChangePopulated=false)
{
@@ -226,16 +225,10 @@ function buildSignupForm($fdata=null, $message='', $canChangePopulated=false)
$code.=$this->buildOptInStudyText();
$code.=$this->buildAcceptRulesText();
- $facebookEmailPermitted=$this->facebook->api_client->users_hasAppPermission('email', $this->session->fbId);
-
+ $facebookEmailPermitted=$this->facebook->api_client->users_hasAppPermission('email', $this->session->fbId);
if (!$facebookEmailPermitted)
$code.='<fb:editor-custom><fb:prompt-permission perms="email">Would you like to receive email from us through facebook? (50 pts)</fb:prompt-permission></fb:editor-custom>';
- // $code.= '</fb:editor-custom> ';
-
-
-
-
$code.='<fb:editor-buttonset>
<fb:editor-button value="Submit"/> <fb:editor-cancel href="'.URL_CANVAS.'"/> </fb:editor-buttonset>';
$code.='</fb:editor>';
@@ -269,34 +262,18 @@ function buildAccountSettingsForm($fdata=null, $message='')
$fdata->showResearchImportance=false;
}
$code='';
- // $code="Welcome <fb:name uid=\"".$this->session->fbId."\"/>,";
$code.='<fb:editor action="?p=account&settings&step=submit" labelwidth="100">';
-
$code .= $this->buildAccountInfoFormFields($fdata, $message, true);
if ($fdata->showOptIn) {
$code.=$this->buildOptInStudyText($fdata->optInStudy );
} else {
$code.='<input type="hidden" name="optInStudy" value="on" />';
}
-
- $facebookEmailPermitted=$this->facebook->api_client->users_hasAppPermission('email');
- if (!$facebookEmailPermitted)
- $code.='<fb:editor-custom><fb:prompt-permission perms="email">Would you like to receive email from us through facebook? (50 pts)</fb:prompt-permission><br></fb:editor-custom>';
-
- $facebookSMSPermitted=$this->facebook->api_client->users_hasAppPermission('sms');
- if (!$facebookSMSPermitted)
- $code.='<fb:editor-custom><fb:prompt-permission perms="sms">Would you like to receive sms notifications from us through facebook? (50 pts)</fb:prompt-permission><br /></fb:editor-custom>';
-
- $facebookOfflinePermitted=$this->facebook->api_client->users_hasAppPermission('offline_access');
- if (!$facebookOfflinePermitted)
- $code.='<fb:editor-custom><fb:prompt-permission perms="offline_access">Would you like Facebook to keep you permanently signed in to '.SITE_TITLE.'</fb:prompt-permission>? This will prevent timeout messages from appearing.</fb:editor-custom>';
-
- $code .= '<fb:editor-custom><fb:add-section-button section="profile" /><fb:editor-custom>';
-
- $code.='<fb:editor-custom><input type="checkbox" name="noCommentNotify" '.($fdata->noCommentNotify==1?'CHECKED':'').'> Do not send me notifications when people reply to my comments and stories</fb:editor-custom>';
-
+/*
+ $code.=$this->buildPermissions();
+*/
$code.='<fb:editor-buttonset>
<fb:editor-button value="Update"/> <fb:editor-cancel href="'.URL_CANVAS.'"/> </fb:editor-buttonset>';
$code.='</fb:editor>';
@@ -314,6 +291,48 @@ function buildAccountSettingsForm($fdata=null, $message='')
return $code;
}
+ function validateLocationData() {
+ // used by address form
+ $fdata->result = true;
+ $fdata->alert = '';
+
+ // the stuff we get from facebook or user but might be invalid anyway
+ $fdata->address1 = stripslashes($_POST['address1']);
+ $fdata->address2 = stripslashes($_POST['address2']);
+ $fdata->city = stripslashes($_POST['city']);
+ $fdata->state = stripslashes($_POST['state']);
+ $fdata->country = stripslashes($_POST['country']);
+ if (isset($_POST['zip']))
+ $fdata->zip = stripslashes($_POST['zip']);
+ else
+ $fdata->zip='';
+ if ($fdata->address1 == '')
+ {
+ $fdata->alert .= 'Please enter at least the first line of your mailing address.<br />';
+ $fdata->result = false;
+ }
+ if ($fdata->city == '')
+ {
+ $fdata->alert .= 'Please enter your city.<br />';
+ $fdata->result = false;
+ }
+ if ($fdata->state == '')
+ {
+ $fdata->alert .= 'Please select the state where you live.<br />';
+ $fdata->result = false;
+ }
+ if ($fdata->country == '')
+ {
+ $fdata->alert .= 'Please select the country where you live.<br />';
+ $fdata->result = false;
+ }
+ if ($fdata->zip == '')
+ {
+ $fdata->alert .= 'Please enter your postal code.<br />';
+ $fdata->result = false;
+ }
+ return $fdata;
+ }
function validateFormData($isNewRegistration=true)
{
@@ -332,12 +351,18 @@ function validateFormData($isNewRegistration=true)
$fdata->city = stripslashes($_POST['city']);
$fdata->state = stripslashes($_POST['state']);
$fdata->country = stripslashes($_POST['country']);
+ if (isset($_POST['zip']))
+ $fdata->zip = stripslashes($_POST['zip']);
+ else
+ $fdata->zip='';
/*$fdata->researchImportance= $_POST['researchImportance']; // tentatively moved into templates since this field may be site-specific
if ($isNewRegistration OR $fdata->researchImportance==0)
$fdata->showResearchImportance=true;*/
$fdata->optInStudy = stripslashes($_POST['optInStudy']) == 'on' ? 1 : 0;
$fdata->acceptRules = stripslashes($_POST['acceptRules']) == 'on' ? 1 : 0;
$fdata->noCommentNotify = stripslashes($_POST['noCommentNotify']) == 'on' ? 1 : 0;
+ $fdata->rxFeatures = stripslashes($_POST['rxFeatures']) == 'on' ? 1 : 0;
+ $fdata->rxMode = stripslashes($_POST['rxMode']);
// TODO:optInEmail, etc
@@ -415,6 +440,83 @@ function validateFormData($isNewRegistration=true)
}
+ function processLocationUpdate($fdata) {
+ require_once(PATH_CORE.'/classes/user.class.php');
+ $userTable = new UserTable($this->db);
+ $userInfoTable = new UserInfoTable($this->db);
+
+ $userinfo = $userInfoTable->getRowObject();
+
+ dbRowObject::$debug = 0; // NEVER TURN ON FOR LIVE SITE
+
+ if (
+ !$userinfo->load($this->session->userid))
+ {
+ $fdata->alert = 'Fatal error: userid not found in database';
+ $fdata->result = false;
+ echo 'Error loading user table entries.';
+ return $fdata;
+ }
+ $userinfo->address1 = $fdata->address1;
+ $userinfo->address2 = $fdata->address2;
+ $userinfo->city = $fdata->city;
+ $userinfo->state = $fdata->state;
+ $userinfo->country = $fdata->country;
+ if ($fdata->zip<>'')
+ $userinfo->zip=$fdata->zip; // safe overwrite only if not empty string
+
+ $userinfo->update();
+ return $fdata;
+
+ }
+
+ function updateSubscriptions($fdata) {
+ require_once(PATH_CORE.'/classes/user.class.php');
+ $userTable = new UserTable($this->db);
+ $userInfoTable = new UserInfoTable($this->db);
+
+ $user = $userTable->getRowObject();
+ $userinfo = $userInfoTable->getRowObject();
+
+ if (!$user->load($this->session->userid) ||
+ !$userinfo->load($this->session->userid)) {
+ $fdata->alert = 'Fatal error: userid not found in database';
+ $fdata->result = false;
+ echo 'Error loading user table entries.';
+ return $fdata;
+ }
+
+ $userinfo->noCommentNotify=$fdata->noCommentNotify;
+ // $user->update();
+ $userinfo->update();
+
+ require_once(PATH_CORE.'/classes/subscriptions.class.php');
+ $subTable = new SubscriptionsTable($this->db);
+ $sub = $subTable->getRowObject();
+ $sub->userid=$this->session->userid;
+ $sub->rxFeatures=$fdata->rxFeatures;
+ $sub->rxMode=$fdata->rxMode;
+ if ($sub->rxMode=='sms') {
+ if (!$facebookSMSPermitted=$this->facebook->api_client->users_hasAppPermission('sms')) {
+ $sub->rxMode='notification';
+ }
+ } else if ($sub->rxMode=='email') {
+ if (!$facebookSMSPermitted=$this->facebook->api_client->users_hasAppPermission('email')) {
+ $sub->rxMode='notification';
+ }
+ }
+ $qDup=$subTable->checkExists($this->session->userid);
+ if (!$qDup) {
+ $sub->insert();
+ } else {
+ $data=$this->db->readQ($qDup);
+ $sub->id=$data->id;
+ $this->db->log($sub);
+ $sub->update();
+ }
+ return $fdata;
+ }
+
function processFormUpdateDatabase($fdata)
{
// TODO: update data tables based on form data which is presumably now validated
@@ -448,6 +550,8 @@ function processFormUpdateDatabase($fdata)
$userinfo->city = $fdata->city;
$userinfo->state = $fdata->state;
$userinfo->country = $fdata->country;
+ if ($fdata->zip<>'')
+ $userinfo->zip=$fdata->zip; // safe overwrite only if not empty string
$userinfo->researchImportance=$fdata->researchImportance;
$userinfo->noCommentNotify=$fdata->noCommentNotify;
//$userinfo->birthdate = ''; // TODO
@@ -470,8 +574,6 @@ function processFormUpdateDatabase($fdata)
$user->update();
$userinfo->update();
-
-
return $fdata;
}
@@ -501,6 +603,9 @@ function initFormDataFromDatabase($userid)
$fdata->city= $userinfo->city;
$fdata->state= $userinfo->state;
$fdata->country= $userinfo->country;
+ $fdata->address1 = $userinfo->address1;
+ $fdata->address2 = $userinfo->address2;
+ $fdata->zip = $userinfo->zip;
$fdata->gender = $userinfo->gender;
//$userinfo->birthdate = ''; // TODO
@@ -514,12 +619,21 @@ function initFormDataFromDatabase($userid)
$fdata->noCommentNotify = $userinfo->noCommentNotify;
$fdata->acceptRules = $user->acceptRules;
+
+ require_once(PATH_CORE.'/classes/subscriptions.class.php');
+ $subTable = new SubscriptionsTable($this->db);
+ $sub = $subTable->getRowObject();
+ if ($sub->loadWhere("userid=".$this->session->userid)) {
+ $fdata->rxFeatures=$sub->rxFeatures;
+ $fdata->rxMode=$sub->rxMode;
+ } else {
+ $fdata->rxFeatures=1;
+ $fdata->rxMode='notification';
+ }
return $fdata;
}
-
-
function checkEligibility($user, $userinfo)
{
if ($user->eligibility=='ineligible') return 'ineligible'; // users marked ineligible are not allowed to change
@@ -833,14 +947,60 @@ function buildAcceptRulesText($acceptRules=false)
return $this->accountTemplate->buildAcceptRulesText($acceptRules);
}
+ function buildAccountAddressForm($fdata=null, $message='') {
+ if (!$fdata) {
+ // $fdata = initFormData();
+ }
+ $code='';
+ if (strlen($message))
+ {
+ $code.='<fb:editor-custom label="" name="message"><fb:error><fb:message>There was a problem</fb:message>Please correct the following items: '.$message.'</fb:error>'.
+ '</fb:editor-custom>';
+ }
+ $code.='<fb:editor action="?p=account&o=address&step=submit" labelwidth="100">';
+ $code .= '<fb:editor-text label="Address line 1" name="address1" value="'.$fdata->address1.'"/>';
+ $code .= '<fb:editor-text label="Address line 2" name="address2" value="'.$fdata->address2.'"/>';
+ $code.=$this->getLocationFields($fdata,true);
+ $code .= '<fb:editor-text label="Postal code" name="zip" value="'.$fdata->zip.'"/>';
+ $code.='<fb:editor-buttonset>
+ <fb:editor-button value="Update"/> <fb:editor-cancel href="'.URL_CANVAS.'"/> </fb:editor-buttonset>';
+ $code.='</fb:editor>';
+ return $code;
+ }
+
function buildAccountSubscribeForm($fdata=null, $message='')
{
if (!$fdata) {
- // $fdata = initFormData();
+ $fdata = initFormData();
}
$code='';
$code.='<fb:editor action="?p=account&o=subscribe&step=submit" labelwidth="100">';
+ $code.=$this->buildPermissions();
+ $code.='<fb:editor-custom><input type="checkbox" name="noCommentNotify" '.($fdata->noCommentNotify==1?'CHECKED':'').'> Do not send me notifications when people reply to my comments and stories</fb:editor-custom>';
+
+ $code.='<fb:editor-custom><input type="checkbox" name="rxFeatures" '.($fdata->rxFeatures==1?'CHECKED':'').'> Notify me when featured stories are updated</fb:editor-custom>';
+
+ $code .='<fb:editor-custom label="Contact preference">'.
+ '<select name="rxMode">
+ <option value="notification" '.(($fdata->rxMode=='notification')?'SELECTED':'').'>Facebook Notification</option>
+ <option value="email" '.(($fdata->rxMode=='email')?'SELECTED':'').'>Email - Requires authorization above</option>
+ <option value="sms" '.(($fdata->rxMode=='sms')?'SELECTED':'').'>Text Message (SMS) - Requires authorization above</option>
+ </select>';
+ $code.= '</fb:editor-custom> ';
+
+ $code.='<fb:editor-buttonset>
+ <fb:editor-button value="Update"/> <fb:editor-cancel href="'.URL_CANVAS.'"/> </fb:editor-buttonset>';
+ $code.='</fb:editor>';
+ return $code;
+ }
+
+ function buildPermissions() {
+ $code='';
+ $facebookPublishStream=$this->facebook->api_client->users_hasAppPermission('publish_stream');
+ if (!$facebookPublishStream)
+ $code.='<fb:editor-custom><fb:prompt-permission perms="publish_stream">Would you like to grant us permission to publish to your Facebook profile stream? (100 pts)</fb:prompt-permission><br></fb:editor-custom>';
+
$facebookEmailPermitted=$this->facebook->api_client->users_hasAppPermission('email');
if (!$facebookEmailPermitted)
$code.='<fb:editor-custom><fb:prompt-permission perms="email">Would you like to receive email from us through facebook? (50 pts)</fb:prompt-permission><br></fb:editor-custom>';
@@ -854,16 +1014,7 @@ function buildAccountSubscribeForm($fdata=null, $message='')
$code.='<fb:editor-custom><fb:prompt-permission perms="offline_access">Would you like Facebook to keep you permanently signed in to '.SITE_TITLE.'</fb:prompt-permission>? This will prevent timeout messages from appearing.</fb:editor-custom>';
$code .= '<fb:editor-custom><fb:add-section-button section="profile" /><fb:editor-custom>';
-
- $code.='<fb:editor-custom><input type="checkbox" name="noCommentNotify" '.($fdata->noCommentNotify==1?'CHECKED':'').'> Do not send me notifications when people reply to my comments and stories</fb:editor-custom>';
-
- $code.='<fb:editor-buttonset>
- <fb:editor-button value="Update"/> <fb:editor-cancel href="'.URL_CANVAS.'"/> </fb:editor-buttonset>';
- $code.='</fb:editor>';
- // perms: email, offline_access, status_update, photo_upload, create_listing, create_event, rsvp_event, sms.
- return $code;
- }
-
-
+ return $code;
+ }
}
?>
View
3 facebook/classes/actionTeam.class.php
@@ -45,9 +45,6 @@ function buildSubNav($currentSub='team')
if (ENABLE_ACTION_CHALLENGES) $pages['challenges']='Challenges';
$pages['leaders']='Leaders';
if (ENABLE_ACTION_REWARDS) $pages['rewards']='Rewards';
- if (defined('ENABLE_ACTION_WALL') AND ENABLE_ACTION_WALL==true) {
- $pages['wall']='Forum';
- }
$pages['rules']='Rules';
$tabs='<div id="subNav" class="tabs clearfix"><div class="left_tabs"><ul class="toggle_tabs clearfix" id="toggle_tabs_unused">';
View
10 facebook/classes/facebookCron.class.php
@@ -1,10 +0,0 @@
-<?php
-
- class facebookCron {
- var $db;
-
- function facebookCron($facebook,$app='climate') {
- }
-
- }
-?>
View
43 facebook/classes/pageWall.class.php
@@ -1,43 +0,0 @@
-<?php
-
-/* Provides Facebook-client specific action team help */
-class pageWall {
-
- var $page;
- var $db;
- var $session;
- var $teamObj;
- var $templateObj;
- var $isAppTab=false;
-
- function __construct(&$page) {
- $this->page=&$page;
- $this->db=&$page->db;
- $this->facebook=&$page->facebook;
- $this->setupLibraries();
- }
-
- function setupLibraries() {
- require_once(PATH_CORE.'/classes/template.class.php');
- $this->templateObj=new template($this->db);
- $this->templateObj->registerTemplates(MODULE_ACTIVE,'teamactivity');
- require_once(PATH_FACEBOOK.'/classes/actionTeam.class.php');
- $this->teamObj=new actionTeam($this->page);
- }
-
- function fetch($mode='fullPage',$option='alltime') {
- $tabs.=$this->teamObj->buildSubNav('wall');
- $inside.='<div id="col_left"><!-- begin left side -->';
- $inside.='<fb:comments xid="'.CACHE_PREFIX.'_wall" canpost="true" candelete="true" numposts="25" callbackurl="'.URL_CALLBACK.'?p=ajax&m=wall"></fb:comments>';
- $inside.='</div><!-- end left side --><div id="col_right">';
- $inside.=$this->teamObj->fetchSidePanel('leaders');
- $inside.='</div> <!-- end right side -->';
- if ($mode=='teamWrap') return $inside;
- $inside=$tabs.'<div id="teamWrap">'.$inside.'<!-- end teamWrap --></div>';
- if ($this->page->isAjax) return $inside;
- $code=$this->page->constructPage('team',$inside);
- return $code;
- }
-
-}
-?>
View
27 facebook/classes/pages.class.php
@@ -134,6 +134,11 @@ function fetch($page='home',$option='',$arg3='') {
$inviteObj=new pageInvite($this);
$code=$inviteObj->fetch();
break;
+ case 'cards':
+ require_once(PATH_FACEBOOK.'/pages/pageCards.class.php');
+ $cardsObj=new pageCards($this);
+ $code=$cardsObj->fetch($option);
+ break;
case 'signup':
// check auth for not anonymous
require_once(PATH_FACEBOOK.'/pages/pageSignup.class.php');
@@ -188,11 +193,6 @@ function fetch($page='home',$option='',$arg3='') {
else
$code = $contactObj->fetch();
break;
- case 'dbtest':
- require_once(PATH_FACEBOOK.'/pages/pageDBTest.class.php');
- $dbtestObj=new pageDBTest($this);
- $code=$dbtestObj->fetch();
- break;
case '404':
require_once(PATH_FACEBOOK.'/pages/page404.class.php');
$pObj=new page404($this);
@@ -211,7 +211,11 @@ function fetch($page='home',$option='',$arg3='') {
$pObj=new pageAdmin($this);
$code=$pObj->fetch($option);
break;
-
+ case 'dbtest':
+ require_once(PATH_FACEBOOK.'/pages/pageDBTest.class.php');
+ $dbtestObj=new pageDBTest($this);
+ $code=$dbtestObj->fetch();
+ break;
}
//$after = memory_get_usage();
@@ -251,7 +255,7 @@ function fetchTeam($mode='fullPage',$page='',$option='') {
break;
case 'wall':
require_once(PATH_FACEBOOK.'/pages/pageWall.class.php');
- $wallObj=new pageWall($this);
+ $wallObj=new pageWall($this);
$code=$wallObj->fetch($mode,$option);
break;
case 'rewards':
@@ -296,9 +300,6 @@ function fetchTeam($mode='fullPage',$page='',$option='') {
$ordersObj=new pageOrders($this);
$code=$ordersObj->fetch($mode);
break;
- ;
-
-
}
return $code;
}
@@ -393,6 +394,12 @@ function buildPageTabs($current='home',$includeWrap=true,$includeScript=true) {
$tabs='<div class="tabs clearfix"><div class="right_tabs"><ul class="toggle_tabs clearfix" id="toggle_tabs_unused">';
$tabs.='<li class="first"><a id="tabHome" href="?p=home" onclick="switchPage(\'home\');return false;" class="'.($current=='home'?'selected':'').'">Home</a></li>';
$tabs.='<li ><a id="tabTeam" href="?p=team" class="'.($current=='team'?'selected':'').'" onclick="switchPage(\'team\');return false;" >'.SITE_TEAM_TITLE.'</a></li>';
+ if (defined('ENABLE_WALL')) {
+ $tabs.='<li ><a id="tabWall" href="?p=wall" class="'.($current=='wall'?'selected':'').'" onclick="switchPage(\'wall\');return false;" >'.SITE_WALL_TITLE.'</a></li>';
+ }
+ if (defined('ENABLE_CARDS')) {
+ $tabs.='<li ><a id="tabCards" href="?p=cards" class="'.($current=='cards'?'selected':'').'" onclick="switchPage(\'cards\');return false;" >'.TAB_CARDS.'</a></li>';
+ }
$tabs.='<li ><a id="tabStories" href="?p=stories" onclick="switchPage(\'stories\');return false;" class="'.($current=='stories'?'selected':'').'">Stories</a></li>';
$tabs.='<li ><a id="tabPostStory" href="?p=postStory" onclick="switchPage(\'postStory\');return false;" class="'.($current=='postStory'?'selected':'').'">Post a Story</a></li>';
$tabs.='<li ><a id="tabProfile" href="?p=profile&memberid='.$this->session->fbId.'" class="'.($current=='profile'?'selected':'').'" onclick="switchPage(\'profile\',\'\','.$this->session->fbId.');return false;">My profile</a></li>';
View
2 facebook/classes/profileBoxes.class.php
@@ -42,7 +42,7 @@ function initRefHandle() {
}
function updateProfileBoxes(){
- $q="select fbId from UserInfo where isAppAuthorized=1 and (lastProfileUpdate='0000-00-00 00:00:00' or lastProfileUpdate IS NULL or lastProfileUpdate<NOW() - INTERVAL 1 DAY) order by dateCreated DESC limit 15;";
+ $q="select fbId from UserInfo where isAppAuthorized=1 and (lastProfileUpdate='0000-00-00 00:00:00' or lastProfileUpdate IS NULL or lastProfileUpdate<NOW() - INTERVAL 7 DAY) order by dateCreated DESC limit 15;";
$query=$this->db->query($q);
while ($users=$this->db->readQ($query)){
$errors=$this->updateProfileBox($users->fbId);
View
11 facebook/classes/session.class.php
@@ -324,8 +324,15 @@ function initializeUserInfo($fbId=0,$isAppAuthorized=0) {
$userInfoTest->loadFromFbId($fbId);
if ($debug) echo '<p>fetched user info debug: $userInfo:<pre>'. print_r($userInfoTest, true).'</pre>';
-
-
+
+ // populate subscription settings for the new user
+ require_once(PATH_CORE.'/classes/subscriptions.class.php');
+ $subTable = new SubscriptionsTable($this->db);
+ $sub = $subTable->getRowObject();
+ $sub->userid=$user->userid;
+ $sub->rxFeatures=1;
+ $sub->rxMode='notification';
+ $sub->insert();
} else
{
if ($debug)
View
31 facebook/emailAttach.php
@@ -1,31 +0,0 @@
-<?php
- /* Manage email attachments */
- $init=parse_ini_file($_SERVER['DOCUMENT_ROOT'].'../genomics.ini');
- $api_key = $init['fbAPIKey'];
- $secret = $init['fbSecretKey'];
- // the facebook client library
- include_once '../facebook/facebook.php';
- $fbLib = new Facebook($api_key, $secret);
- require_once "../classes/fbApp.class.php";
- $fbApp=new fbApp($fbLib);
-
- $code='';
- if (!array_key_exists('message_sent', $_POST) || $_POST['message_sent'] < 1)
- {
- //if attaching, display the gene selector
- if (isset($_POST['giftid']))
- $giftid=$_POST['giftid'];
- else
- $giftid=0;
- $code.=$fbApp->buildAttchmentSelector($giftid);
- }
-
- //display attachment for live and preview
- if (array_key_exists('giftid', $_POST)) {
- $giftid=$_POST['giftid'];
- $code.=$fbApp->buildAttachment($giftid);
- $code.='<div style="float:left;font-weight:bold;"><fb:if-user-has-added-app>'.$fbApp->makeFancyTitle('<a href="'.$fbApp->home.'?page=send">Send a Gene Now!</a>','100%').'<fb:else><p><a href="'.$fbApp->home.'?page=postAdd">'.$fbApp->makeFancyTitle('Add the Genomics application to your profile','100%').'</a></p></fb:else> </fb:if-user-has-added-app></div>';
- }
-
- echo $code;
-?>
View
3 facebook/index.php
@@ -168,6 +168,9 @@
case 'wall':
$code=$pagesObj->fetch('wall');
break;
+ case 'cards':
+ $code=$pagesObj->fetch('cards',$o);
+ break;
case 'rules':
$code=$pagesObj->fetch('rules');