Esempio n. 1
0
 /**
  * Disable plugin
  *
  * @param \Difra\Param\AnyString $name
  */
 public function disableAjaxAction(\Difra\Param\AnyString $name)
 {
     if (!\Difra\Plugger::turnOff($name->val())) {
         \Difra\Ajaxer::notify(\Difra\Locales::get('adm/plugins/failed'));
     }
     \Difra\Ajaxer::refresh();
 }
Esempio n. 2
0
 public function savesettingsAjaxAction(\Difra\Param\AjaxString $consumerKey, \Difra\Param\AjaxString $consumerSecret, \Difra\Param\AjaxString $oauthToken, \Difra\Param\AjaxString $oauthSecret, \Difra\Param\AjaxCheckbox $postToTwitter)
 {
     $oAuthArray = ['consumerKey' => $consumerKey->val(), 'consumerSecret' => $consumerSecret->val(), 'accessToken' => $oauthToken->val(), 'accessTokenSecret' => $oauthSecret->val(), 'postToTwitter' => $postToTwitter->val()];
     \Difra\Config::getInstance()->set('oAuth', $oAuthArray);
     \Difra\Ajaxer::refresh();
     \Difra\Ajaxer::notify(\Difra\Locales::getInstance()->getXPath('twitter/adm/oAuth/settingsSaved'));
 }
Esempio n. 3
0
 /**
  * Edit user (submit)
  * @param Param\AnyInt $id
  * @param Param\AjaxEmail $email
  * @param Param\AjaxCheckbox $change_pw
  * @param Param\AjaxString|null $new_pw
  * @param Param\AjaxData|null $fieldName
  * @param Param\AjaxData|null $fieldValue
  */
 public function saveAjaxAction(Param\AnyInt $id, Param\AjaxEmail $email, Param\AjaxCheckbox $change_pw, Param\AjaxString $new_pw = null, Param\AjaxData $fieldName = null, Param\AjaxData $fieldValue = null)
 {
     $user = User::getById($id->val());
     $user->setEmail($email->val());
     //        $userData['addonFields'] = !is_null($fieldName) ? $fieldName->val() : null;
     //        $userData['addonValues'] = !is_null($fieldValue) ? $fieldValue->val() : null;
     if ($change_pw->val() and $new_pw and $new_pw->val()) {
         $user->setPassword($new_pw->val());
         Ajaxer::notify(Locales::get('auth/adm/userDataSavedPassChanged'));
     } else {
         Ajaxer::notify(Locales::get('auth/adm/userDataSaved'));
     }
     Ajaxer::refresh();
 }
Esempio n. 4
0
 /**
  * Alter table for Unify object
  *
  * @param \Difra\Param\AnyString $name
  */
 public function alterAjaxAction(\Difra\Param\AnyString $name)
 {
     try {
         /** @var \Difra\Unify\Item $class */
         $class = \Difra\Unify\Storage::getClass($name->val());
         $status = $class::getObjDbStatus();
         if ($status['status'] == 'alter') {
             \Difra\MySQL::getInstance()->query($status['sql']);
         }
     } catch (\Difra\Exception $ex) {
         \Difra\Ajaxer::notify($ex->getMessage());
     }
     \Difra\Ajaxer::refresh();
 }
Esempio n. 5
0
 /**
  * @backupGlobals enabled
  */
 public function test_actions()
 {
     \Difra\Debugger::disable();
     \Difra\Ajaxer::clean();
     $actions = [];
     \Difra\Ajaxer::notify('notification message');
     $actions[] = ['action' => 'notify', 'message' => 'notification message', 'lang' => ['close' => \Difra\Locales::get('notifications/close')]];
     \Difra\Ajaxer::display('<span>test</span>');
     $actions[] = ['action' => 'display', 'html' => '<span>test</span>'];
     \Difra\Ajaxer::error('error message <span>test</span>');
     $actions[] = ['action' => 'error', 'message' => 'error message &lt;span&gt;test&lt;/span&gt;', 'lang' => ['close' => \Difra\Locales::get('notifications/close')]];
     \Difra\Ajaxer::required('element');
     $actions[] = ['action' => 'require', 'name' => 'element'];
     \Difra\Ajaxer::invalid('inv1');
     $actions[] = ['action' => 'invalid', 'name' => 'inv1'];
     \Difra\Ajaxer::invalid('inv2');
     $actions[] = ['action' => 'invalid', 'name' => 'inv2'];
     \Difra\Ajaxer::status('field1', 'bad value', 'problem');
     $actions[] = ['action' => 'status', 'name' => 'field1', 'message' => 'bad value', 'classname' => 'problem'];
     \Difra\Ajaxer::redirect('/some/page');
     $actions[] = ['action' => 'redirect', 'url' => '/some/page'];
     $_SERVER['HTTP_REFERER'] = '/current/page';
     \Difra\Ajaxer::refresh();
     $actions[] = ['action' => 'redirect', 'url' => '/current/page'];
     \Difra\Ajaxer::reload();
     $actions[] = ['action' => 'reload'];
     \Difra\Ajaxer::load('someid', 'some <b>content</b>');
     $actions[] = ['action' => 'load', 'target' => 'someid', 'html' => 'some <b>content</b>'];
     \Difra\Ajaxer::close();
     $actions[] = ['action' => 'close'];
     \Difra\Ajaxer::reset();
     $actions[] = ['action' => 'reset'];
     \Difra\Envi::setUri('/current/page');
     \Difra\Ajaxer::confirm('Are you sure?');
     $actions[] = ['action' => 'display', 'html' => '<form action="/current/page" class="ajaxer"><input type="hidden" name="confirm" value="1"/>' . '<div>Are you sure?</div>' . '<input type="submit" value="' . \Difra\Locales::get('ajaxer/confirm-yes') . '"/>' . '<input type="button" value="' . \Difra\Locales::get('ajaxer/confirm-no') . '" onclick="ajaxer.close(this)"/>' . '</form>'];
     $this->assertEquals(\Difra\Ajaxer::getResponse(), json_encode(['actions' => $actions], \Difra\Ajaxer::getJsonFlags()));
     \Difra\Ajaxer::clean();
     $this->assertEquals(\Difra\Ajaxer::getResponse(), '[]');
     $this->assertFalse(\Difra\Ajaxer::hasProblem());
     \Difra\Ajaxer::reload();
     \Difra\Ajaxer::clean(true);
     $this->assertEquals(\Difra\Ajaxer::getResponse(), '[]');
     $this->assertTrue(\Difra\Ajaxer::hasProblem());
 }
Esempio n. 6
0
 /**
  * After ajax password change stuff
  */
 protected function afterPasswordChangeAjax()
 {
     Ajaxer::notify(Locales::get('auth/password/changed'));
     Ajaxer::reset();
 }
Esempio n. 7
0
 /**
  * Change password using recovery link
  * @param AnyString $code
  * @param AjaxString $password1
  * @param AjaxString $password2
  * @throws Exception
  */
 public function submitAjaxAction(AnyString $code, AjaxString $password1, AjaxString $password2)
 {
     try {
         Recover::verify($code->val());
     } catch (\Difra\Plugins\Users\UsersException $ex) {
         Ajaxer::notify(Locales::get('auth/recover/' . $ex->getMessage()));
         return;
     }
     // verify passwords
     $register = new \Difra\Plugins\Users\Register();
     $register->setPassword1($password1->val());
     $register->setPassword2($password2->val());
     if (!$register->validatePasswords()) {
         $register->callAjaxerEvents();
         return;
     }
     Recover::recoverSetPassword($code->val(), $password1->val());
     Cookies::getInstance()->notify(Locales::get('auth/recover/done'));
     Ajaxer::redirect('/');
 }
Esempio n. 8
0
 /**
  * After success actions
  * @param $redirect
  */
 protected function afterSuccess($redirect = false)
 {
     if ($redirect) {
         Cookies::getInstance()->notify(Locales::get('auth/register/complete-' . Users::getActivationMethod()));
         View::redirect('/');
     } else {
         Ajaxer::notify(Locales::get('auth/register/complete-' . Users::getActivationMethod()));
         Ajaxer::close();
     }
 }
Esempio n. 9
0
 public function resetAjaxAction()
 {
     \Difra\Config::getInstance()->reset();
     \Difra\Ajaxer::notify(\Difra\Locales::get('adm/config/reset-done'));
     \Difra\Ajaxer::refresh();
 }