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();
         }
     }
 }
 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;
 }