/**
  * special handling - if password is empty, don't save it
  * 
  * @service myprofile write
  * @param $fields
  * @return Gpf_Rpc_Form
  */
 public function save(Gpf_Rpc_Params $params)
 {
     $form = new Gpf_Rpc_Form($params);
     $dbRow = $this->createDbRowObject();
     $dbRow->setPrimaryKeyValue($this->getId($form));
     try {
         $dbRow->load();
     } catch (Gpf_DbEngine_NoRow $e) {
         $form->setErrorMessage($this->getDbRowObjectName() . $this->_(" does not exist"));
         return $form;
     }
     $oldPassword = $dbRow->getPassword();
     $oldUsername = $dbRow->getUsername();
     $form->fill($dbRow);
     $newPassword = $dbRow->getPassword();
     if ($newPassword == '') {
         $dbRow->setPassword($oldPassword);
     }
     if (Gpf_Application::isDemo()) {
         $dbRow->setPassword($oldPassword);
         $dbRow->setUsername($oldUsername);
     }
     if (!$this->checkBeforeSave($dbRow, $form, self::EDIT)) {
         return $form;
     }
     try {
         $dbRow->save();
     } catch (Exception $e) {
         $form->setErrorMessage($e->getMessage());
         return $form;
     }
     Gpf_Plugins_Engine::extensionPoint('Gpf_Auth_UserForm.save', $dbRow);
     $form->load($dbRow);
     $form->setInfoMessage($this->_("%s saved", $this->getDbRowObjectName()));
     return $form;
 }
 /**
  * Send all scheduled mails from outbox
  */
 public function execute($outboxids = false)
 {
     if (Gpf_Application::isDemo()) {
         $this->interrupt(30);
     }
     do {
         $mails = $this->getPendingEmail($outboxids);
         if ($mails->getSize() > 0) {
             foreach ($mails as $mail) {
                 $this->debug('got some emails (' . $mails->getSize() . ')... processing');
                 $this->sendScheduledMail($mail);
             }
         } else {
             $this->debug('No mails to send by me... ');
             break;
         }
         $this->checkInterruption();
     } while ($outboxids == false);
 }
Exemple #3
0
 public function delete()
 {
     if (Gpf_Application::isDemo() && Gpf_Application::isDemoEntryId($this->getId())) {
         throw new Gpf_Exception("Demo banner can not be deleted");
     }
     return parent::delete();
 }
Exemple #4
0
 public function delete($moveChildAffiliates = false) {
     if (Gpf_Application::isDemo() && Gpf_Application::isDemoEntryId($this->getId())) {
         throw new Gpf_Exception("Demo affiliate can not be deleted");
     }
     $this->load();
     if ($moveChildAffiliates) {
         $this->moveChildAffiliatesTo($this->getParentUserId());
     } else {
         $this->clearParentAffiliate();
     }
     return parent::delete();
 }
 /**
  * @service merchant delete
  * @param $ids
  * @return Gpf_Rpc_Action
  */
 public function deleteRows(Gpf_Rpc_Params $params) {
     $action = new Gpf_Rpc_Action($params);
     $action->setErrorMessage($this->_('Failed to delete %s %s(s)', '%s', $this->getDbRowObjectName()));
     $action->setInfoMessage($this->_('%s %s(s) successfully deleted', '%s', $this->getDbRowObjectName()));
     
     foreach ($action->getIds() as $id) {
         try {
             $row = $this->createDbRowObject();
             $row->setPrimaryKeyValue($id);
             $row->load();
             if ($row->getId() == Gpf_Session::getAuthUser()->getPapUserId()) {
                 $action->setErrorMessage($this->_('Could not delete logged %s', 
                    $this->getDbRowObjectName()));
             	throw new Gpf_Exception('');
             }
             if (Gpf_Application::isDemo() && $row->getUserName() == Pap_Branding::DEMO_MERCHANT_USERNAME) {
                 $action->setErrorMessage($this->_('Could not delete %s', 
                    $row->getUserName()));
                 throw new Gpf_Exception('');
             }
             $row->delete();
             $action->addOk();
         } catch (Exception $e) {
             $action->addError();
         }
     }
     return $action;
 }
 /**
  * Load default username and password in login form
  *
  * @return Gpf_Rpc_Form
  */
 public function loadNoRpc()
 {
     $form = new Gpf_Rpc_Form(new Gpf_Rpc_Params());
     $form->setField(self::REMEMBER_ME, Gpf::YES);
     if (Gpf_Application::isDemo()) {
         $form->setField(self::USERNAME, Gpf_Session::getInstance()->getModule()->getDemoUsername());
         $form->setField(self::PASSWORD, Gpf_Session::getInstance()->getModule()->getDemoPassword());
     }
     $langage = Gpf_Http::getCookie(self::COOKIE_LANGUAGE);
     $form->setField(self::LANGUAGE, $langage, $this->setDefaultLanguage(Gpf_Lang_Languages::getInstance()->getActiveLanguagesNoRpc())->toObject());
     return $form;
 }
 protected function loadSetting() {
     parent::loadSetting();
     $this->addValue("DEMO_MODE", Gpf_Application::isDemo() ? "Y" : "N");
     $this->addValue(Pap_Settings::BRANDING_TEXT_POST_AFFILIATE_PRO, Gpf_Settings::get(Pap_Settings::BRANDING_TEXT_POST_AFFILIATE_PRO));
 }