Adds a link to edit search callouts if belong to search group, a=chris

Chris Pollett [2022-07-13 00:Jul:th]
Adds a link to edit search callouts if belong to search group, a=chris
Filename
src/controllers/SearchController.php
src/css/search.css
src/executables/QueryTool.php
src/models/GroupModel.php
src/views/elements/SearchcalloutElement.php
diff --git a/src/controllers/SearchController.php b/src/controllers/SearchController.php
index 88feab0b5..c8a48a255 100755
--- a/src/controllers/SearchController.php
+++ b/src/controllers/SearchController.php
@@ -447,6 +447,8 @@ class SearchController extends Controller implements CrawlConstants
                 $changed_settings_flag = true;
             }
         }
+        $data["SEARCH_GROUP_MEMBER"] = $this->model("group")->checkUserGroup(
+            $user, C\SEARCH_GROUP_ID, C\ACTIVE_STATUS);
         $data['LOCALE_TAG'] = L\getLocaleTag();
         $data['LANGUAGES_TO_SHOW'] = 1;
         $n = C\NUM_RESULTS_PER_PAGE;
diff --git a/src/css/search.css b/src/css/search.css
index e4b95265e..a75f189cb 100755
--- a/src/css/search.css
+++ b/src/css/search.css
@@ -2118,6 +2118,7 @@ span[aria-label]:hover:after
     border: 3px solid #DDD;
     padding: 5px;
     margin-top: 65px;
+    min-height: 45px;
     width:2.5in;
 }
 .mobile .search-callout
diff --git a/src/executables/QueryTool.php b/src/executables/QueryTool.php
index 1593e7806..1ab1f7a9f 100755
--- a/src/executables/QueryTool.php
+++ b/src/executables/QueryTool.php
@@ -90,6 +90,7 @@ class QueryTool implements CrawlConstants
             var_dump($data);
             exit();
         }
+        ini_set("memory_limit", C\INDEX_FILE_MEMORY_LIMIT);
         $data = $controller->queryRequest($query, $results_per_page, $limit);
         if (isset($argv[2]) && ($argv[2] == "plan" || $argv[2] == "explain")) {
             echo "\n" . $controller->model("phrase")->db->query_log[0]["PLAN"]
diff --git a/src/models/GroupModel.php b/src/models/GroupModel.php
index 99885a5ae..2954b80de 100644
--- a/src/models/GroupModel.php
+++ b/src/models/GroupModel.php
@@ -732,7 +732,7 @@ class GroupModel extends Model implements MediaConstants
         return ($row['NUM'] ?? 0)  + $subtract_personal;
     }
     /**
-     * Get the key of the group.
+     * Get the key of a private/encrypted group.
      *
      * @param int $group_id to get key for
      * @return string key of the group
diff --git a/src/views/elements/SearchcalloutElement.php b/src/views/elements/SearchcalloutElement.php
index b2c7179e0..1857a4ca0 100644
--- a/src/views/elements/SearchcalloutElement.php
+++ b/src/views/elements/SearchcalloutElement.php
@@ -30,6 +30,8 @@
  */
 namespace seekquarry\yioop\views\elements;

+use seekquarry\yioop as B;
+use seekquarry\yioop\configs as C;
 /**
  * Element responsible for drawing search wiki callouts for search results
  *
@@ -43,9 +45,22 @@ class SearchcalloutElement extends Element
      */
     public function render($data)
     {
-        if (!empty($data['SEARCH_CALLOUT'])) { ?>
-            <div class="search-callout">
-            <?=$data['SEARCH_CALLOUT'] ?>
+        $logged_in = isset($data["ADMIN"]) && $data["ADMIN"];
+        $belongs_search_group = !empty($data["SEARCH_GROUP_MEMBER"]);
+        $token_string = ($logged_in) ? C\CSRF_TOKEN ."=". $data[C\CSRF_TOKEN] :
+            "";
+        if (!empty($data['SEARCH_CALLOUT']) ||
+            ($belongs_search_group && $logged_in &&
+            empty($data["IS_LANDING"]))) { ?>
+            <div class="search-callout"><?php
+            if ($logged_in && $belongs_search_group) {
+                $edit_url = B\wikiUrl(preg_replace("/-|\s/u", "_",
+                    $data['QUERY']), true, "group", C\SEARCH_GROUP_ID).
+                    $token_string . "&amp;noredirect=true&amp;arg=edit";
+                $this->view->helper("iconlink")->renderButton($edit_url, "edit",
+                    false, "float-opposite", "", false, "_blank");
+            }
+            ?><?=$data['SEARCH_CALLOUT'] ?>
             </div>
             <?php
         }
ViewGit