Example #1
0
 /**
  * Reset user password
  */
 public static function reset_password($po_opts = null)
 {
     if ($vs_user_name = (string) $po_opts->getOption('user')) {
         if (!($vs_password = (string) $po_opts->getOption('password'))) {
             CLIUtils::addError(_t("You must specify a password"));
             return false;
         }
         $t_user = new ca_users();
         if (!$t_user->load(array("user_name" => $vs_user_name))) {
             CLIUtils::addError(_t("User name %1 does not exist", $vs_user_name));
             return false;
         }
         $t_user->setMode(ACCESS_WRITE);
         $t_user->set('password', $vs_password);
         $t_user->update();
         if ($t_user->numErrors()) {
             CLIUtils::addError(_t("Password change for user %1 failed: %2", $vs_user_name, join("; ", $t_user->getErrors())));
             return false;
         }
         CLIUtils::addMessage(_t('Changed password for user %1', $vs_user_name), array('color' => 'bold_green'));
         return true;
     }
     CLIUtils::addError(_t("You must specify a user"));
     return false;
 }
Example #2
0
 /**
  * Process queued tasks
  */
 public static function fix_permissions($po_opts = null)
 {
     // Guess web server user
     if (!($vs_user = $po_opts->getOption("user"))) {
         $vs_user = caDetermineWebServerUser();
         if (!$po_opts->getOption("quiet") && $vs_user) {
             CLIUtils::addMessage(_t("Determined web server user to be \"%1\"", $vs_user));
         }
     }
     if (!$vs_user) {
         $vs_user = caGetProcessUserName();
         CLIUtils::addError(_t("Cannot determine web server user. Using %1 instead.", $vs_user));
     }
     if (!$vs_user) {
         CLIUtils::addError(_t("Cannot determine the user. Please specify one with the --user option."));
         return false;
     }
     if (!($vs_group = $po_opts->getOption("group"))) {
         $vs_group = caGetProcessGroupName();
         if (!$po_opts->getOption("quiet") && $vs_group) {
             CLIUtils::addMessage(_t("Determined web server group to be \"%1\"", $vs_group));
         }
     }
     if (!$vs_group) {
         CLIUtils::addError(_t("Cannot determine the group. Please specify one with the --group option."));
         return false;
     }
     if (!$po_opts->getOption("quiet")) {
         CLIUtils::addMessage(_t("Fixing permissions for the temporary directory (app/tmp) for ownership by \"%1\"...", $vs_user));
     }
     $va_files = caGetDirectoryContentsAsList($vs_path = __CA_APP_DIR__ . '/tmp', true, false, false, true);
     foreach ($va_files as $vs_path) {
         chown($vs_path, $vs_user);
         chgrp($vs_path, $vs_group);
         chmod($vs_path, 0770);
     }
     if (!$po_opts->getOption("quiet")) {
         CLIUtils::addMessage(_t("Fixing permissions for the media directory (media) for ownership by \"%1\"...", $vs_user));
     }
     $va_files = caGetDirectoryContentsAsList($vs_path = __CA_BASE_DIR__ . '/media', true, false, false, true);
     foreach ($va_files as $vs_path) {
         chown($vs_path, $vs_user);
         chgrp($vs_path, $vs_group);
         chmod($vs_path, 0775);
     }
     if (!$po_opts->getOption("quiet")) {
         CLIUtils::addMessage(_t("Fixing permissions for the HTMLPurifier definition cache directory (app/lib/core/Parsers/htmlpurifier/standalone/HTMLPurifier/DefinitionCache) for ownership by \"%1\"...", $vs_user));
     }
     $va_files = caGetDirectoryContentsAsList($vs_path = __CA_LIB_DIR__ . '/core/Parsers/htmlpurifier/standalone/HTMLPurifier/DefinitionCache', true, false, false, true);
     foreach ($va_files as $vs_path) {
         chown($vs_path, $vs_user);
         chgrp($vs_path, $vs_group);
         chmod($vs_path, 0770);
     }
     return true;
 }
Example #3
0
 /**
  *
  */
 public static function do_configuration_check($po_opts = null)
 {
     include_once __CA_LIB_DIR__ . "/core/Search/SearchEngine.php";
     include_once __CA_LIB_DIR__ . "/core/Media.php";
     include_once __CA_LIB_DIR__ . "/ca/ApplicationPluginManager.php";
     include_once __CA_LIB_DIR__ . "/ca/ConfigurationCheck.php";
     require_once __CA_LIB_DIR__ . "/core/Configuration.php";
     // Media
     $t_media = new Media();
     $va_plugin_names = $t_media->getPluginNames();
     CLIUtils::addMessage(_t("Checking media processing plugins..."), array('color' => 'bold_blue'));
     foreach ($va_plugin_names as $vs_plugin_name) {
         if ($va_plugin_status = $t_media->checkPluginStatus($vs_plugin_name)) {
             CLIUtils::addMessage("\t" . _t("Found %1", $vs_plugin_name));
         }
     }
     CLIUtils::addMessage("\n");
     // Application plugins
     CLIUtils::addMessage(_t("Checking application plugins..."), array('color' => 'bold_blue'));
     $va_plugin_names = ApplicationPluginManager::getPluginNames();
     $va_plugins = array();
     foreach ($va_plugin_names as $vs_plugin_name) {
         if ($va_plugin_status = ApplicationPluginManager::checkPluginStatus($vs_plugin_name)) {
             CLIUtils::addMessage("\t" . _t("Found %1", $vs_plugin_name));
         }
     }
     CLIUtils::addMessage("\n");
     // Barcode generation
     CLIUtils::addMessage(_t("Checking for barcode dependencies..."), array('color' => 'bold_blue'));
     $vb_gd_is_available = caMediaPluginGDInstalled(true);
     CLIUtils::addMessage("\t(" . _t('GD is a graphics processing library required for all barcode generation.') . ")");
     if (!$vb_gd_is_available) {
         CLIUtils::addError("\t\t" . _t('GD is not installed; barcode printing will not be possible.'));
     } else {
         CLIUtils::addMessage("\t\t" . _t('GD is installed; barcode printing will be available.'));
     }
     CLIUtils::addMessage("\n");
     // General system configuration issues
     CLIUtils::addMessage(_t("Checking system configuration... this may take a while."), array('color' => 'bold_blue'));
     ConfigurationCheck::performExpensive();
     if (ConfigurationCheck::foundErrors()) {
         CLIUtils::addMessage("\t" . _t('Errors were found:'), array('color' => 'bold_red'));
         foreach (ConfigurationCheck::getErrors() as $vn_i => $vs_error) {
             CLIUtils::addError("\t\t[" . ($vn_i + 1) . "] {$vs_error}");
         }
     }
     return true;
 }
Example #4
0
 /**
  * 
  */
 public static function reload_object_current_locations($po_opts = null)
 {
     require_once __CA_LIB_DIR__ . "/core/Db.php";
     require_once __CA_MODELS_DIR__ . "/ca_objects.php";
     $o_db = new Db();
     $t_object = new ca_objects();
     $qr_res = $o_db->query("SELECT * FROM ca_objects");
     print CLIProgressBar::start($qr_res->numRows(), _t('Starting...'));
     $vn_c = 0;
     while ($qr_res->nextRow()) {
         $vn_object_id = $qr_res->get('object_id');
         if ($t_object->load($vn_object_id)) {
             print CLIProgressBar::next(1, _t('Processing %1', $t_object->getWithTemplate("^ca_objects.preferred_labels.name (^ca_objects.idno)")));
             $t_object->deriveCurrentLocationForBrowse();
         } else {
             print CLIProgressBar::next(1, _t('Cannot load object %1', $vn_object_id));
         }
         $vn_c++;
     }
     print CLIProgressBar::finish();
     CLIUtils::addMessage(_t('Processed %1 objects', $vn_c));
     return true;
 }