Browse Source

Get default work directory to automatically create profile, a=chris

tags/v3.0.0
Chris Pollett 6 years ago
parent
commit
3de1c2bb71

+ 1
- 0
.gitignore View File

@@ -2,3 +2,4 @@ local_config.php
2 2
 LocalConfig.php
3 3
 .DS_Store
4 4
 /vendor/
5
+/work_directory/

+ 2
- 3
src/configs/Config.php View File

@@ -96,8 +96,7 @@ nsdefine('YIOOP_VERSION', 33);
96 96
 function computeBaseUrl()
97 97
 {
98 98
     $pathinfo = pathinfo($_SERVER['SCRIPT_NAME']);
99
-    $http = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) ?
100
-        "https://" : "http://";
99
+    $http = !empty($_SERVER['HTTPS']) ? "https://" : "http://";
101 100
     $port = (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80) ?
102 101
         ":".$_SERVER['SERVER_PORT'] : "";
103 102
     $server_name = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] :
@@ -211,7 +210,7 @@ nsdefine('DEFAULT_WORK_DIRECTORY', PARENT_DIR . "/work_directory");
211 210
 if (!nsdefined('WORK_DIRECTORY')) {
212 211
 /*+++ The next block of code is machine edited, change at 
213 212
 your own risk, please use configure web page instead +++*/
214
-nsdefine('WORK_DIRECTORY', DEFAULT_WORK_DIRECTORY);
213
+nsdefine('WORK_DIRECTORY', '/Applications/MAMP/htdocs/git/yioop/work_directory');
215 214
 /*++++++*/
216 215
 // end machine edited code
217 216
 }

+ 2
- 2
src/configs/ConfigureTool.php View File

@@ -503,7 +503,7 @@ class ConfigureTool
503 503
             $choice_nums[$i] = $name;
504 504
             $i++;
505 505
         }
506
-        if (isset($_REQUEST["MESSAGE"]) && $_REQUEST["MESSAGE"] != "") {
506
+        if (!empty($_REQUEST["MESSAGE"])) {
507 507
             e("\n+++ ".$_REQUEST["MESSAGE"]." +++\n");
508 508
             unset($_REQUEST["MESSAGE"]);
509 509
         }
@@ -557,7 +557,7 @@ class ConfigureTool
557 557
         $_REQUEST["arg"] = "profile";
558 558
         $_REQUEST['YIOOP_TOKEN'] = "";
559 559
         if (!isset($_SERVER['REQUEST_URI'])) {
560
-            if (isset($data['WEB_URI']) && $data['WEB_URI'] !="") {
560
+            if (!empty($data['WEB_URI'])) {
561 561
                 $_SERVER['REQUEST_URI'] = $data['WEB_URI'];
562 562
             } else {
563 563
                 e("Enter web path for Yioop instance:\n");

+ 1
- 1
src/configs/Createdb.php View File

@@ -39,7 +39,7 @@ use seekquarry\yioop\models\Model;
39 39
 use seekquarry\yioop\models\ProfileModel;
40 40
 use seekquarry\yioop\models\GroupModel;
41 41
 
42
-if (isset($_SERVER['DOCUMENT_ROOT']) && strlen($_SERVER['DOCUMENT_ROOT']) > 0) {
42
+if (!empty($_SERVER['DOCUMENT_ROOT'])) {
43 43
     echo "BAD REQUEST";
44 44
     exit();
45 45
 }

+ 1
- 2
src/configs/ExportPublicHelpDb.php View File

@@ -36,8 +36,7 @@ namespace seekquarry\yioop\configs;
36 36
 
37 37
 use seekquarry\yioop\library as L;
38 38
 
39
- if (isset($_SERVER['DOCUMENT_ROOT']) &&
40
-    strlen($_SERVER['DOCUMENT_ROOT']) > 0) {
39
+ if (!empty($_SERVER['DOCUMENT_ROOT'])) {
41 40
     echo "BAD REQUEST";
42 41
     exit();
43 42
 }

+ 1
- 1
src/controllers/AdminController.php View File

@@ -410,7 +410,7 @@ class AdminController extends Controller implements CrawlConstants
410 410
         }
411 411
         $data = array_merge($data, $status);
412 412
         $data["CRAWL_RUNNING"] = false;
413
-        if (isset($data['CRAWL_TIME']) && $data["CRAWL_TIME"] != 0) {
413
+        if (!empty($data['CRAWL_TIME'])) {
414 414
             //erase from previous crawl list any active crawl
415 415
             $num_crawls = count($data['RECENT_CRAWLS']);
416 416
             for ($i = 0; $i < $num_crawls; $i++) {

+ 1
- 1
src/controllers/components/AccountaccessComponent.php View File

@@ -98,7 +98,7 @@ class AccountaccessComponent extends Component
98 98
             $data = array_merge($data, $status);
99 99
             $data["CRAWLS_RUNNING"] = 0;
100 100
             $data["NUM_CLOSED_CRAWLS"] = count($recent_crawls);
101
-            if (isset($data['CRAWL_TIME']) && $data["CRAWL_TIME"] != 0) {
101
+            if (!empty($data['CRAWL_TIME'])) {
102 102
                 $data["CRAWLS_RUNNING"] = 1;
103 103
                 $data["NUM_CLOSED_CRAWLS"]--;
104 104
             }

+ 7
- 2
src/controllers/components/SystemComponent.php View File

@@ -811,12 +811,17 @@ EOD;
811 811
                     ['advanced', 'lang']);
812 812
             }
813 813
             $data['WORK_DIRECTORY'] = $dir;
814
-        } else if (C\nsdefined("WORK_DIRECTORY") && 
814
+        } else if (C\nsdefined("WORK_DIRECTORY") &&
815 815
             strlen(C\WORK_DIRECTORY) > 0 &&
816 816
             strcmp(realpath(C\WORK_DIRECTORY), realpath(C\BASE_DIR)) != 0 &&
817 817
             (is_dir(C\WORK_DIRECTORY) || is_dir(C\WORK_DIRECTORY."../"))) {
818 818
             $data['WORK_DIRECTORY'] = C\WORK_DIRECTORY;
819 819
             $data['PROFILE'] = true;
820
+            if(C\WORK_DIRECTORY == C\DEFAULT_WORK_DIRECTORY &&
821
+                is_writable(C\WORK_DIRECTORY) &&
822
+                !file_exists(C\WORK_DIRECTORY. C\PROFILE_FILE_NAME) ) {
823
+                $_REQUEST['arg'] = 'directory';
824
+            }
820 825
         }
821 826
         $arg = "";
822 827
         if (isset($_REQUEST['arg'])) {
@@ -828,7 +833,7 @@ EOD;
828 833
                 if (!isset($data['WORK_DIRECTORY'])) {break;}
829 834
                 if ($data['PROFILE'] &&
830 835
                     file_exists($data['WORK_DIRECTORY']."/".
831
-                        C\PROFILE_FILE_NAME)){
836
+                        C\PROFILE_FILE_NAME)) {
832 837
                     $data = array_merge($data, $profile_model->getProfile(
833 838
                             $data['WORK_DIRECTORY']));
834 839
                     $profile_model->setWorkDirectoryConfigFile(

+ 2
- 3
src/views/AdminView.php View File

@@ -59,14 +59,13 @@ class AdminView extends View
59 59
         if (C\MOBILE) {
60 60
             $logo = C\M_LOGO;
61 61
         }
62
-        if (C\PROFILE) {
63 62
         ?>
64 63
         <div class="top-bar"><?php
64
+        if (C\PROFILE) {
65 65
             $this->element("signin")->render($data);
66
-        ?>
67
-        </div><?php
68 66
         }
69 67
         ?>
68
+        </div>
70 69
         <h1 class="admin-heading logo"><a href="./?<?=
71 70
             C\CSRF_TOKEN."=".$data[C\CSRF_TOKEN] ?>"><img
72 71
             src="<?= $logo ?>" alt="<?= $this->logo_alt_text

work_directory/PlaceHolder.php → work_directory/_placeholder.php View File


Loading…
Cancel
Save