Example #1
0
 function afterUpdate()
 {
     $session = SessionWrapper::getInstance();
     # check if user is being invited during update
     if (!isEmptyString($this->getDefaultUserID()) && isEmptyString($this->getDefaultUser()->getCompanyID())) {
         $this->getDefaultUser()->setCompanyID($this->getID());
         $startdate = DEFAULT_DATETIME;
         $expirydate = date("Y-m-d", strtotime(date("Y-m-d", strtotime($startdate)) . " +" . getTrialDays() . " days "));
         if (isEmptyString($this->getStartDate()) && $this->getID() != DEFAULT_COMPANYID) {
             $this->setStartDate($startdate);
         }
         if (isEmptyString($this->getEndDate()) && $this->getID() != DEFAULT_COMPANYID) {
             $this->setEndDate($expirydate);
         }
         $this->save();
     }
     // invite via email
     if ($this->getIsBeinginvited() == 1) {
         $this->getDefaultUser()->inviteViaEmail();
     }
     if ($this->getID() == DEFAULT_ID) {
         $config_collection = new Doctrine_Collection(Doctrine_Core::getTable("AppConfig"));
         $appconfig = new AppConfig();
         $appconfig->populate(61);
         $appconfig->setOptionValue($this->getAppName());
         $config_collection->add($appconfig);
         $appconfig = new AppConfig();
         $appconfig->populate(62);
         $appconfig->setOptionValue($this->getName());
         $config_collection->add($appconfig);
         if ($config_collection->count() > 0) {
             $config_collection->save();
         }
     }
     return true;
 }
 function processglobalconfigAction()
 {
     $session = SessionWrapper::getInstance();
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $formvalues = $this->_getAllParams();
     $successurl = decode($formvalues[URL_SUCCESS]);
     // debugMessage($formvalues);
     $postarray = array();
     for ($i = 1; $i <= $formvalues['t']; $i++) {
         $postarray[$i]['id'] = $formvalues['id_' . $i];
         $postarray[$i]['displayname'] = $formvalues['displayname_' . $i];
         $postarray[$i]['optionvalue'] = $formvalues['optionvalue_' . $i];
     }
     $config_collection = new Doctrine_Collection(Doctrine_Core::getTable("AppConfig"));
     foreach ($postarray as $line) {
         $appconfig = new AppConfig();
         $appconfig->populate($line['id']);
         $appconfig->processPost($line);
         /*debugMessage('error is '.$appconfig->getErrorStackAsString());
         		debugMessage($appconfig->toArray());*/
         if ($appconfig->isValid()) {
             $config_collection->add($appconfig);
         }
     }
     // check for atleast one option and save
     if ($config_collection->count() > 0) {
         try {
             // debugMessage($config_collection->toArray());
             $config_collection->save();
             $session->setVar(SUCCESS_MESSAGE, $formvalues[SUCCESS_MESSAGE]);
             # clear cache after updating options
             $temppath = APPLICATION_PATH . DIRECTORY_SEPARATOR . 'temp' . DIRECTORY_SEPARATOR;
             // debugMessage($temppath);
             $files = glob($temppath . 'zend_cache---config*');
             foreach ($files as $file) {
                 debugMessage($file);
                 if (is_file($file)) {
                     unlink($file);
                 }
             }
         } catch (Exception $e) {
             $session->setVar(ERROR_MESSAGE, "An error occured in updating the parameters. " . $e->getMessage());
         }
     }
     // debugMessage($successurl);
     $this->_helper->redirector->gotoUrl($successurl);
     // exit();
 }