Ejemplo n.º 1
0
 public function up_1()
 {
     if (!ADMIN_PLUGIN_RUNNING_ON_APPLICATION_SCOPE) {
         self::setTokenKey();
     }
     $this->createTable('users', '
       id,
       login string(40) not null idx,
       email string(50) not null idx,
       password string(40) not null,
       password_salt string(16) not null,
       last_login_at,
       is_enabled bool default 1
     ');
     $this->createTable('roles', '
       id,
       name,
       description,
       is_enabled bool default 1,
       parent_id,
       lft integer(8) index,
       rgt integer(8) index,
     ');
     $this->createTable('roles_users', 'id, role_id, user_id', array('timestamp' => false));
     $this->createTable('permissions_roles', 'id, permission_id, role_id', array('timestamp' => false));
     $this->createTable('extensions', 'id, name, is_core, is_enabled');
     $this->createTable('permissions', 'id, name, extension_id');
     if (AK_ENVIRONMENT != 'testing' && empty($this->root_details)) {
         $this->root_details = array('login' => AkConsole::promptUserVar('Master account login.', array('default' => 'admin')), 'email' => AkConsole::promptUserVar('Master account email.', array('default' => '*****@*****.**')), 'password' => AkConsole::promptUserVar('Root password.', array('default' => 'admin')));
     }
     $this->addDefaults();
 }
Ejemplo n.º 2
0
 function hasCollisions()
 {
     $this->collisions = array();
     foreach (array_merge(array_values($this->files), array_values($this->user_actions)) as $file_name) {
         $user_answer = 5;
         if ($user_answer != 3 && file_exists($file_name)) {
             $message = Ak::t('%file_name file already exists', array('%file_name' => $file_name));
             $user_answer = AkConsole::promptUserVar($message . "\n" . "Would you like to:\n" . " 1) overwrite file\n" . " 2) keep existing file\n" . " 3) overwrite all\n" . " 4) keep all\n" . " 5) abort\n", array('default' => 5));
             if ($user_answer == 2 || $user_answer == 4) {
                 $this->_skip_files[] = $file_name;
             } elseif ($user_answer == 5) {
                 $this->collisions[] = $message;
             }
         }
     }
     return count($this->collisions) > 0;
 }
Ejemplo n.º 3
0
 public function install()
 {
     $core_dir = AK_CORE_DIR;
     $src_path = $this->getSrcPath() . '/akelos';
     $bin_path = $this->getBinaryPath();
     if (is_dir($src_path)) {
         if (AkConsole::promptUserVar("The directory {$src_path} is not empty. Do you want to override its contents? (y/n)", 'n') != 'y') {
             die("Aborted.\n");
         }
     }
     $this->ensureCanWriteOnDirectory($src_path);
     $this->ensureCanWriteOnDirectory($bin_path . '/akelos');
     $this->log("Copying souce files from {$core_dir} to {$src_path}.");
     $this->run("cp -R {$core_dir}/ {$src_path}/");
     $this->log("Linking binaries");
     $this->run(array('rm ' . $bin_path . '/akelos', "ln -s {$src_path}/akelos {$bin_path}/akelos"));
     $this->run(array('rm ' . $bin_path . '/makelos', "ln -s {$src_path}/makelos {$bin_path}/makelos"));
     $this->log("Done.");
 }
Ejemplo n.º 4
0
    public function relativizeStylesheetPaths()
    {
        $url_suffix = AkConsole::promptUserVar('The admin plugin comes with some fancy CSS background images.

Your application might be accessible at /myapp, 
and your images folder might be at /myapp/public

Insert the relative path where your images folder is
so you don\'t need to manually edit the CSS files', array('default' => '/'));
        $url_suffix = trim(preg_replace('/\\/?images\\/admin\\/?$/', '', $url_suffix), '/');
        if (!empty($url_suffix)) {
            $stylesheets = array('admin/admin', 'admin/menu');
            foreach ($stylesheets as $stylesheet) {
                $filename = AK_PUBLIC_DIR . DS . 'stylesheets' . DS . $stylesheet . '.css';
                $relativized_css = preg_replace("/url\\((\\'|\")?\\/images/", "url(\$1/{$url_suffix}/images", @AkFileSystem::file_get_contents($filename));
                !empty($relativized_css) && @AkFileSystem::file_put_contents($filename, $relativized_css);
            }
        }
    }
Ejemplo n.º 5
0
 protected function _checkForModified(&$directory_structure, $base_path = null, $src_path = null)
 {
     foreach ($directory_structure as $k => $node) {
         if (!empty($this->skip_all)) {
             return;
         }
         if (is_array($node)) {
             foreach ($node as $dir => $items) {
                 $path = $base_path . DS . $dir;
                 if (is_dir($path)) {
                     if ($this->_checkForModified($directory_structure[$k][$dir], $path, $src_path) === false) {
                         $this->skip_all = true;
                         return;
                     }
                 }
             }
         } else {
             $original_file = $base_path . DS . $node;
             $new_file_location = $this->app_base_dir . str_replace($src_path, '', $original_file);
             if (!file_exists($new_file_location)) {
                 unset($directory_structure[$k]);
             } elseif (md5_file($new_file_location) != md5_file($original_file)) {
                 $message = Ak::t('The file %file exists has local modifications.', array('%file' => $new_file_location));
                 $user_response = AkConsole::promptUserVar($message . "\n k (keep mine), d (delete), a (abort), D (delete all), K (keep all)", 'k');
                 if ($user_response == 'k') {
                     unset($directory_structure[$k]);
                 } elseif ($user_response == 'd') {
                 } elseif ($user_response == 'D') {
                     return false;
                 } elseif ($user_response == 'K') {
                     $directory_structure = array();
                     return false;
                 } elseif ($user_response != 'd') {
                     echo "\nAborting\n";
                     exit;
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
 static function displayComment($message)
 {
     AkConsole::display($message, 'comment');
 }
Ejemplo n.º 7
0
 private function _updateUsingLocalDirectory($name)
 {
     AkConsole::displayError(Ak::t('Updating from local targets it\'s not supported yet. Please use install --force instead.'), true);
 }
Ejemplo n.º 8
0
 protected function _checkUninstallDependencies()
 {
     $dependencyFile = $this->app_plugins_dir . DS . $this->plugin_name . DS . 'dependent_plugins';
     if (file_exists($dependencyFile)) {
         $dependendPlugins = file($dependencyFile);
         if (!empty($dependendPlugins)) {
             if (empty($this->options['force'])) {
                 echo "\n";
                 echo Ak::t("The following %plugin %dependent depend on the plugin you are about to uninstall.", array('%plugin' => AkT('plugin', 'quantify(' . count($dependendPlugins) . ')'), '%dependent' => AkT($dependendPlugins, 'toSentence')));
                 echo Ak::t("Please uninstall the dependent %plugin first.", array('%plugin' => AkT('plugin', 'quantify(' . count($dependendPlugins) . ')')));
                 echo "\n";
                 $this->transactionFail();
                 die;
             } else {
                 echo "\n";
                 echo Ak::t("The following %plugin %dependent depend on the plugin you are about to uninstall.", array('%plugin' => AkT('plugin', 'quantify(' . count($dependendPlugins) . ')'), '%dependent' => AkT($dependendPlugins, 'toSentence')));
                 echo "\n";
                 $uninstall = AkConsole::promptUserVar('Are you sure you want to continue uninstalling (Answer with Yes)? The other plugins will malfunction.', array('default' => 'N'));
                 if ($uninstall != 'Yes') {
                     echo Ak::t('Uninstall cancelled.');
                     echo "\n";
                     $this->transactionFail();
                     die;
                 } else {
                     return true;
                 }
             }
         }
         return true;
     }
 }
Ejemplo n.º 9
0
if ($command == 'test') {
    $options = get_console_options_for('Test plugin', array(CONSOLE_GETARGS_PARAMS => array('min' => 1, 'max' => 1, 'short' => 'p', 'desc' => "Specify the plugin name you wish to test"), 'phpbin' => array('short' => 'b', 'max' => 1, 'min' => 1, 'desc' => 'Path to the php binary', 'default' => '/usr/bin/env php')));
    if (empty($options['parameters'])) {
        AkConsole::displayError("You must supply a plugin name.", true);
    }
    $plugin = $options['parameters'];
    $plugin_name = basename($plugin);
    $test_file = AK_PLUGINS_DIR . DS . $plugin_name . DS . 'test' . DS . $plugin_name . '.php';
    if (file_exists($test_file)) {
        $exec_command = $options['phpbin'] . ' ' . $test_file;
        passthru($exec_command);
    } else {
        echo "The test file {$test_file} does not exist.";
        die("\n");
    }
}
if ($command == 'help') {
    $options = get_console_options_for('Plugin help', array(CONSOLE_GETARGS_PARAMS => array('min' => 1, 'max' => 1, 'short' => 'p', 'desc' => "Specify a plugin name."), 'phpbin' => array('short' => 'b', 'max' => 1, 'min' => 1, 'desc' => 'Path to the php binary', 'default' => '/usr/bin/env php')));
    if (empty($options['parameters'])) {
        AkConsole::displayError("You must supply a plugin name.", true);
    }
    $plugin = $options['parameters'];
    $plugin_name = basename($plugin);
    $help_file = AK_PLUGINS_DIR . DS . $plugin_name . DS . 'README';
    if (file_exists($help_file)) {
        echo file_get_contents($help_file) . "\n";
    } else {
        echo "Could not find a README help file for the {$plugin_name} plugin.";
        die("\n");
    }
}
Ejemplo n.º 10
0
function prompt_var($question, $default_value = null, $cli_value = null)
{
    global $options;
    if (empty($options['interactive']) && isset($cli_value)) {
        return $cli_value;
    } else {
        return AkConsole::promptUserVar($question, array('default' => $default_value, 'optional' => true));
    }
}
Ejemplo n.º 11
0
        $directory_candidate = $v;
    }
}
$directory = AkelosAppInstaller::getAbsolutePath(get_command_value($options, 'd', 'directory', $directory_candidate, 'Destination directory can\'t be blank'));
$public_html = get_command_value($options, 'p', 'public_html', false);
$public_html = empty($public_html) ? false : AkelosAppInstaller::getAbsolutePath($public_html);
$force = get_command_value($options, 'f', 'force', false);
$quiet = get_command_value($options, 'q', 'quiet', false);
$skip = get_command_value($options, 's', 'skip', false);
$prompt = get_command_value($options, 'prompt', 'prompt', true);
if ($prompt) {
    echo "\nCreate an Akelos " . AKELOS_VERSION . " application in {$directory}\n";
    if ($public_html) {
        echo "symlink the public directory to {$public_html}\n";
    }
    if ($force) {
        "OVERWRITE EXISTING FILES in {$directory}\n";
    }
    AkConsole::promptUserVar("Shall web proceed installing? \nPress enter to continue", array('optional' => true));
}
$Installer = new AkelosAppInstaller(array('directory' => $directory, 'public_html' => $public_html, 'public_html' => $public_html, 'force' => $force, 'quiet' => $quiet, 'skip' => $skip, 'prompt' => $prompt));
$Installer->install();
if (!$quiet) {
    if ($Installer->hasErrors()) {
        echo "\nThere where some errors during the installation process:\n";
        echo "\n * " . join("\n    * ", $Installer->getErrors());
    } elseif (empty($Installer->options['force'])) {
        echo "\n    In order to create the config.php file and setup a database...\n\n" . " change to \n\n    {$directory}\n" . " and run \n\n    ./script/configure \n\nto configure the database details\n";
    }
    echo "\n";
}