Example #1
0
 /**
  * Initialize Galette relevant objects
  *
  * @param I18n $i18n I18n
  * @param Db   $zdb  Database instance
  *
  * @return boolean
  */
 public function initObjects($i18n, $zdb)
 {
     if ($this->isInstall()) {
         $preferences = new Preferences($zdb, false);
         $ct = new \Galette\Entity\ContributionsTypes();
         $status = new \Galette\Entity\Status();
         include_once '../includes/fields_defs/members_fields.php';
         include_once '../includes/fields_defs/members_fields_cats.php';
         $fc = new \Galette\Entity\FieldsConfig(\Galette\Entity\Adherent::TABLE, $members_fields, $members_fields_cats, true);
         //$fc = new \Galette\Entity\FieldsCategories();
         include_once GALETTE_ROOT . 'includes/fields_defs/texts_fields.php';
         $texts = new \Galette\Entity\Texts($texts_fields, $preferences);
         $titles = new \Galette\Repository\Titles();
         include_once GALETTE_ROOT . 'includes/fields_defs/pdfmodels_fields.php';
         $models = new \Galette\Repository\PdfModels($zdb, $preferences);
         $this->_error = false;
         //Install preferences
         $res = $preferences->installInit($i18n->getID(), $this->getAdminLogin(), $this->getAdminPass());
         $this->_proceedReport(_T("Preferences"), $res);
         //Install contributions types
         $res = $ct->installInit();
         $this->_proceedReport(_T("Contributions types"), $res);
         //Install statuses
         $res = $status->installInit();
         $this->_proceedReport(_T("Status"), $res);
         //Install fields configuration and categories
         $res = $fc->installInit($zdb);
         $this->_proceedReport(_T("Fields config and categories"), $res);
         //Install texts
         $res = $texts->installInit(false);
         $this->_proceedReport(_T("Mails texts"), $res);
         //Install titles
         $res = $titles->installInit($zdb);
         $this->_proceedReport(_T("Titles"), $res);
         //Install PDF models
         $res = $models->installInit($pdfmodels_fields, false);
         $this->_proceedReport(_T("PDF Models"), $res);
         return !$this->_error;
     } else {
         if ($this->isUpgrade()) {
             $preferences = new Preferences($zdb);
             $preferences->store();
             $this->_proceedReport(_T("Update preferences"), true);
             return true;
         }
     }
 }
Example #2
0
         $errs[] = '<li class="install-bad">' . _T("Default fields configuration cannot be initialized.") . '</li>';
     } else {
         $oks[] = '<li class="install-ok">' . _T("Default fields configuration was successfully stored.") . '</li>';
     }
     $res = $titles->installInit($zdb);
     if ($res !== true) {
         $errs[] = '<li class="install-bad">' . _T("Titles cannot be initialized.") . '<span>' . $res->getMessage() . '</span></li>';
     } else {
         $oks[] = '<li class="install-ok">' . _T("Titles were successfully stored.") . '</li>';
     }
 } else {
     if ($step == 'u9') {
         $_to_ver = substr($_POST['install_type'], 8);
         if ((double) $_to_ver <= 0.74) {
             include_once '../includes/fields_defs/members_fields.php';
             $fc = new Galette\Entity\FieldsConfig(Galette\Entity\Adherent::TABLE, $members_fields, true);
             //titles has been initialized by SQL upgrade script
             //but in english. If install language is not english,
             //we have to translate those values.
             $titles = new Galette\Repository\Titles();
             if ($i18n->getID() != 'en_US') {
                 $titles_list = $titles->getList($zdb);
                 $res = true;
                 $zdb->db->beginTransaction();
                 foreach ($titles_list as $title) {
                     if ($res == true) {
                         switch ($title->short) {
                             case 'Mr.':
                                 $title->short = _T("Mr.");
                                 break;
                             case 'Mrs.':