function populateSubscriptions() { $subTable = new SubscriptionsTable($this->db); $sub = $subTable->getRowObject(); $sub->rxFeatures = 1; $sub->rxMode = 'notification'; // query gets all user table entries that aren't in subscriptions table - never should happen any more now that create is hooked into session class $q = $this->db->query("SELECT User.userid FROM User LEFT JOIN Subscriptions ON User.userid=Subscriptions.userid WHERE Subscriptions.userid IS NULL"); while ($data = $this->db->readQ($q)) { $sub->userid = $data->userid; $qDup = $subTable->checkExists($data->userid); if (!$qDup) { $sub->insert(); } } }
$userInfo = $userInfoTable->getRowObject(); // create new users $user->name = SITE_TITLE . ' Administrator'; $user->isAppAuthorized = 1; $user->votePower = 1; $user->isAdmin = 1; $user->authLevel = 'member'; $user->eligibility = 'team'; $user->email = SUPPORT_ADMIN; $user->ncUid = rand(0, 99999); // deprecated column, but must be set if ($user->insert()) { // inserted ok if ($userInfo->createFromUser($user, 0)) { require_once PATH_CORE . '/classes/subscriptions.class.php'; $subTable = new SubscriptionsTable($db); $sub = $subTable->getRowObject(); $sub->userid = $user->userid; $sub->rxFeatures = 1; $sub->rxMode = 'notification'; $sub->insert(); } } } // Add stories require_once PATH_CORE . '/classes/content.class.php'; $cObj = new content($db); // load admin $q = $db->queryC("SELECT * FROM User,UserInfo WHERE User.userid=UserInfo.userid AND isAdmin=1 LIMIT 1;"); if ($q !== false) { $ui = $db->readQ($q);
function initializeUserInfo($fbId = 0, $isAppAuthorized = 0) { // adds a record for this user in the Facebook app userinfo table require_once PATH_CORE . '/classes/user.class.php'; $userTable = new UserTable($this->db); // TODO: cache instances of the tables globally $userInfoTable = new UserInfoTable($this->db); $user = $userTable->getRowObject(); $userInfo = $userInfoTable->getRowObject(); //dbRowObject::$debug = true; $debug = false; if ($debug) { echo 'entered session::initializeUserInfo()\\n'; } // create new users $user->isAppAuthorized = $isAppAuthorized; $user->votePower = 1; if ($user->insert()) { // inserted ok if ($debug) { echo '<p>created $user:<pre>' . print_r($user, true) . '</pre>'; } if ($userInfo->createFromUser($user, $fbId)) { //* if ($debug) { echo 'Created new user info\\n'; echo '<p>$userInfo:<pre>' . print_r($userInfo, true) . '</pre>'; } //*/ $userInfoTest = $userInfoTable->getRowObject(); $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) { echo "Failed to create UserInfo row:<br>"; echo '<p>$userInfo:<pre>' . print_r($userInfo, true) . '</pre>'; } return false; } } else { if ($debug) { echo "Failed to insert user!\n"; } return false; } // merge necessary session data into a results object and return it $data->isMember = $user->isMember; $data->isBlocked = $user->isBlocked; $data->isAdmin = $user->isAdmin; $data->name = $userInfo->name; $data->userid = $userInfo->userid; // .. etc return $data; /* echo "<p>session->fbId: {$this->app->session->fbId}</p>"; $userInfo->loadFromFbId($this->app->session->fbId); echo '<p>$userInfo:<pre>'. print_r($userInfo).'</pre>'; if ($userInfo->userid && $user->load($userInfo->userid)) { $code .= 'Found a user...'; */ }
// create UserBlogs require_once PATH_CORE . '/classes/userBlogs.class.php'; UserBlogsTable::createTable($manageObj); } if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'widgets.class.php')) { // create Widgets require_once PATH_CORE . '/classes/widgets.class.php'; WidgetsTable::createTable($manageObj); FeaturedWidgetsTable::createTable($manageObj); } if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'adCode.class.php')) { // create AdCode Table require_once PATH_CORE . '/classes/adCode.class.php'; AdCodeTable::createTable($manageObj); } if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'subscriptions.class.php')) { require_once PATH_CORE . '/classes/subscriptions.class.php'; SubscriptionsTable::createTable($manageObj); } if (defined('ENABLE_WALL') and ENABLE_WALL === true) { if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'forum.class.php')) { // create ForumTopics Table require_once PATH_CORE . '/classes/forum.class.php'; ForumTopicsTable::createTable($manageObj); $wall = new ForumTopicsTable($manageObj->db); $wall->initialize(); } } if (defined('MODULE_FACEBOOK') and MODULE_FACEBOOK === true) { include_once PATH_FACEBOOK . '/utilities/initDatabase.php'; }
function initializeUserInfo($fbId = 0) { global $db; // adds a record for this user in the Facebook app userinfo table require_once PATH_CORE . '/classes/user.class.php'; $userTable = new UserTable($db); // TODO: cache instances of the tables globally $userInfoTable = new UserInfoTable($db); $user = $userTable->getRowObject(); $userInfo = $userInfoTable->getRowObject(); //dbRowObject::$debug = true; $debug = true; if ($debug) { echo 'entered postAuth::initializeUserInfo()\\n'; } // create new users $user->isAppAuthorized = 1; $user->votePower = 1; if ($user->insert()) { // inserted ok if ($debug) { echo '<p>created $user:<pre>' . print_r($user, true) . '</pre>'; } if ($userInfo->createFromUser($user, $fbId)) { //* if ($debug) { echo 'Created new user info\\n'; echo '<p>$userInfo:<pre>' . print_r($userInfo, true) . '</pre>'; } //*/ $userInfoTest = $userInfoTable->getRowObject(); $userInfoTest->loadFromFbId($fbId); // populate subscription settings for the new user require_once PATH_CORE . '/classes/subscriptions.class.php'; $subTable = new SubscriptionsTable($db); $sub = $subTable->getRowObject(); $sub->userid = $user->userid; $sub->rxFeatures = 1; $sub->rxMode = 'notification'; $sub->insert(); if ($debug) { echo '<p>fetched user info debug: $userInfo:<pre>' . print_r($userInfoTest, true) . '</pre>'; } } else { if ($debug) { echo "Failed to create UserInfo row:<br>"; echo '<p>$userInfo:<pre>' . print_r($userInfo, true) . '</pre>'; } } } else { if ($debug) { echo "Failed to insert user!\n"; } } }
function initFormDataFromDatabase($userid) { $fdata = new stdClass(); require_once PATH_CORE . '/classes/user.class.php'; $userTable = new UserTable($this->db); $userInfoTable = new UserInfoTable($this->db); $user = $userTable->getRowObject(); $userinfo = $userInfoTable->getRowObject(); //dbRowObject::$debug = 1; 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; } $fdata->age = $userinfo->age; $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 $fdata->name = $user->name; $fdata->email = $user->email; $fdata->optInStudy = $user->optInStudy; $fdata->optInEmail = $user->optInEmail; $fdata->optInSMS = $user->optInSMS; $fdata->optInProfile = $user->optInProfile; $fdata->optInFeed = $user->optInFeed; $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; }