viewgit/inc/functions.php:22 Function utf8_encode() is deprecated [8192]

Add initial ad setup to CreateDb, slightly tweaks diff privacy for to eliminate a function call, a=chrs

Chris Pollett [2022-11-23 18:Nov:rd]
Add initial ad setup to CreateDb, slightly tweaks diff privacy for to eliminate a function call, a=chrs
Filename
src/configs/Createdb.php
src/controllers/components/SocialComponent.php
src/controllers/components/SystemComponent.php
diff --git a/src/configs/Createdb.php b/src/configs/Createdb.php
index 3b2d2810f..2414cfb04 100755
--- a/src/configs/Createdb.php
+++ b/src/configs/Createdb.php
@@ -904,6 +904,16 @@ foreach ($activities as $activity => $translation_info) {
             $db->execute("INSERT INTO ROLE_ACTIVITY VALUES (" .
                 ADMIN_ROLE . ", $i, 'all')");
         }
+    } else if (in_array(MONETIZATION_TYPE, ['group_fees',
+        'keyword_advertisements', 'fees_and_keywords']) &&
+        $activity == "manageCredits") {
+        $db->execute("INSERT INTO ROLE_ACTIVITY VALUES (" .
+            ADMIN_ROLE . ", $i, 'all')");
+    } else if (in_array(MONETIZATION_TYPE, [
+        'keyword_advertisements', 'fees_and_keywords']) &&
+        $activity == "manageAdvertisements") {
+        $db->execute("INSERT INTO ROLE_ACTIVITY VALUES (" .
+            ADMIN_ROLE . ", $i, 'all')");
     }
     $db->execute("INSERT INTO TRANSLATION
         VALUES($i, '{$translation_info[0]}')");
@@ -920,6 +930,16 @@ $new_user_activities = [
     "groupFeeds",
     "userMessages",
 ];
+if (in_array(MONETIZATION_TYPE, ['group_fees',
+    'keyword_advertisements', 'fees_and_keywords']) &&
+    $activity == "manageCredits") {
+    $new_user_activities[] = "manageCredits";
+}
+if (in_array(MONETIZATION_TYPE, [
+    'keyword_advertisements', 'fees_and_keywords']) &&
+    $activity == "manageAdvertisements") {
+    $new_user_activities[] = "manageAdvertisements";
+}
 foreach ($new_user_activities as $new_activity) {
     $i = 1;
     foreach ($activities as $key => $value) {
diff --git a/src/controllers/components/SocialComponent.php b/src/controllers/components/SocialComponent.php
index 1be951abd..8de687785 100644
--- a/src/controllers/components/SocialComponent.php
+++ b/src/controllers/components/SocialComponent.php
@@ -1181,7 +1181,8 @@ class SocialComponent extends Component implements CrawlConstants
         $data['USER_FILTER'] = $user_filter;
         $num_users =  $group_model->countGroupUsers($group_id, $user_filter);
         if (C\DIFFERENTIAL_PRIVACY) {
-            $data['NUM_USERS_GROUP'] = $this->groupUserPrivacy($num_users);
+            $data['NUM_USERS_GROUP'] = $parent->addDifferentialPrivacy(
+                $num_users);
         } else {
             $data['NUM_USERS_GROUP'] = $num_users;
         }
@@ -1197,20 +1198,6 @@ class SocialComponent extends Component implements CrawlConstants
             $group_model->getGroupUsers($group_id, $user_filter,
             $data['USER_SORTS'], $group_limit);
     }
-
-    /**
-     * Used to add Differential Privacy to fuzzify number of users in each group
-     *
-     * @param object $num_users contains number of users per group,
-     *        returned from the database
-     * @return object $fuzzy_users returns number of users per group, now masked
-     */
-    public function groupUserPrivacy($num_users)
-    {
-        $parent = $this->parent;
-        $fuzzy_users = $parent->addDifferentialPrivacy($num_users);
-        return $fuzzy_users;
-    }
     /**
      * Used by $this->manageGroups to check and clean $_REQUEST variables
      * related to groups, to check that a user has the correct permissions
@@ -2710,6 +2697,9 @@ class SocialComponent extends Component implements CrawlConstants
                     $page['NUM_VIEWS'] = $page['FUZZY_NUM_VIEWS'];
                 }
             }
+            if (empty($page['NUM_VIEWS'])) {
+                $page['NUM_VIEWS'] = 0;
+            }
             $page['USER_ICON'] = $user_model->getUserIconUrl($page['USER_ID']);
             $page[self::TITLE] = $page['TITLE'];
             unset($page['TITLE']);
diff --git a/src/controllers/components/SystemComponent.php b/src/controllers/components/SystemComponent.php
index 8c9cb6d67..fa8b7f1d6 100755
--- a/src/controllers/components/SystemComponent.php
+++ b/src/controllers/components/SystemComponent.php
@@ -844,7 +844,8 @@ EOD;
         $not_null_fields = [
             'TIMEZONE' => 'America/Los_Angeles',
             'SESSION_NAME' => "yioopbiscuit",
-            'CSRF_TOKEN' => "YIOOP_TOKEN"
+            'CSRF_TOKEN' => "YIOOP_TOKEN",
+            'DIFFERENTIAL_PRIVACY' => false
         ];
         $data = [];
         $data['AUTOLOGOUT_TIMES'] = [
@@ -925,7 +926,8 @@ EOD;
                             $profile[$field] = $clean_value;
                             $change = true;
                         }
-                        if (empty($profile[$field])) {
+                        if (!isset($profile[$field]) ||
+                            $profile[$field] === "") {
                             $profile[$field] = $value;
                             $change = true;
                         }
ViewGit