예제 #1
0
 public function testSavingNewParentAccountSavesCorrectly()
 {
     $oldMetadata = Account::getMetadata();
     $newMetadata = $oldMetadata;
     $newMetadata['Account']['rules'][] = array('type', 'default', 'value' => 'Customer');
     Account::setMetadata($newMetadata);
     $account = new Account();
     $account->name = 'Account';
     $account->type->value = 'Customer';
     $account->account = $account;
     $saved = $account->save();
     $this->assertTrue($saved);
     $account->account = null;
     $saved = $account->save();
     $this->assertTrue($saved);
     $count = R::getCell('select count(*) from account');
     $this->assertEquals(1, $count);
     Account::setMetadata($oldMetadata);
     $this->assertTrue($account->delete());
 }
예제 #2
0
파일: card.php 프로젝트: Albertopf/prueba
        $result = $account->update($user);
        if ($result >= 0) {
            $_GET["id"] = $_POST["id"];
            // Force chargement page en mode visu
        } else {
            setEventMessages($account->error, $account->errors, 'errors');
            $action = 'edit';
            // Force chargement page edition
        }
    }
}
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->banque->configurer) {
    // Delete
    $account = new Account($db);
    $account->fetch($_GET["id"]);
    $account->delete();
    header("Location: " . DOL_URL_ROOT . "/compta/bank/index.php");
    exit;
}
/*
 * View
 */
$form = new Form($db);
$formbank = new FormBank($db);
$formcompany = new FormCompany($db);
$countrynotdefined = $langs->trans("ErrorSetACountryFirst") . ' (' . $langs->trans("SeeAbove") . ')';
llxHeader();
// Creation
if ($action == 'create') {
    $account = new Account($db);
    print load_fiche_titre($langs->trans("NewFinancialAccount"), '', 'title_bank.png');
예제 #3
0
 public function testDelete()
 {
     // the rows we are looking to update
     $where = 'amount > 99';
     $whereValues = array(1);
     // id=1
     $options = array('limitMax' => 1);
     // our mock adapter
     $adapter = $this->adapterMock;
     // prepare the mock to expect the variables passed, and return a row
     $adapter->expects($this->once())->method('delete')->with('accounts', $where, $whereValues, $options)->will($this->returnValue(true));
     $accountsTable = new Account($adapter);
     // getInstance doesn't work well in testing
     $result = $accountsTable->delete($where, $whereValues, $options);
     $this->assertTrue($result);
 }
 public function delete($id)
 {
     //get account_id nya dulu
     global $db;
     $this->getByID($id);
     //delete account
     $acc = new Account();
     $acc->delete($this->account_id);
     $acc->deleteRole($this->account_id);
     return parent::delete($id);
 }
 /**
  * @depends testGroupDeleted_Slide15
  */
 public function testUserDeleted_Slide16()
 {
     $u1 = User::getByUsername('u1.');
     $u99 = User::getByUsername('u99.');
     Yii::app()->user->userModel = $u99;
     $g1 = Group::getByName('G1.');
     $g2 = Group::getByName('G2.');
     $g3 = Group::getByName('G3.');
     $g1->users->add($u1);
     $this->assertTrue($g1->save());
     $g2->groups->add($g1);
     $this->assertTrue($g2->save());
     $g1->groups->add($g3);
     $this->assertTrue($g1->save());
     Yii::app()->user->userModel = $u1;
     $a1 = new Account();
     $a1->name = 'A1.';
     $this->assertTrue($a1->save());
     //Called in OwnedSecurableItem::afterSave();
     //ReadPermissionsOptimizationUtil::ownedSecurableItemCreated($a1);
     Yii::app()->user->userModel = $u99;
     $a2 = new Account();
     $a2->name = 'A2.';
     $a2->addPermissions($u1, Permission::READ);
     $this->assertTrue($a2->save());
     //Called in OwnedSecurableItem::afterSave();
     //ReadPermissionsOptimizationUtil::ownedSecurableItemCreated($a2);
     ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForUser($a2, $u1);
     $a3 = new Account();
     $a3->name = 'A3.';
     $a3->addPermissions($g1, Permission::READ);
     $this->assertTrue($a3->save());
     //Called in OwnedSecurableItem::afterSave();
     //ReadPermissionsOptimizationUtil::ownedSecurableItemCreated($a3);
     ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($a3, $g1);
     $this->assertEquals(array(array('A1', 'R2', 1), array('A1', 'R3', 1), array('A2', 'R2', 1), array('A2', 'R3', 1), array('A2', 'U1', 1), array('A3', 'G1', 1), array('A3', 'G3', 1), array('A3', 'R2', 1), array('A3', 'R3', 1)), self::getAccountMungeRows());
     $this->assertTrue(self::accountMungeDoesntChangeWhenRebuilt());
     $u1->testBeforeDelete();
     //Called in User->beforeDelete();
     //ReadPermissionsOptimizationUtil::userBeingDeleted($u1);
     // $u1->delete(); // Not really deleting it, to avoid messing up the ids.
     $this->assertEquals(array(array('A3', 'G1', 1), array('A3', 'G3', 1)), self::getAccountMungeRows());
     //$this->assertTrue(self::accountMungeDoesntChangeWhenRebuilt()); // Can't do this because
     // of not really deleting
     Yii::app()->user->userModel = $u1;
     // the group.
     $a1->delete();
     Yii::app()->user->userModel = $u99;
     $a2->delete();
     $a3->delete();
     $g1->users->removeAll();
     $g1->groups->removeAll();
     $this->assertTrue($g1->save());
     $g2->groups->removeall();
     $this->assertTrue($g2->save());
 }
예제 #6
0
 /**
  * Create admin page
  * 
  * @author Thibaud Rohmer
  */
 public function __construct()
 {
     /// Check that current user is an admin or an uploader
     if (!(CurrentUser::$admin || CurrentUser::$uploader)) {
         return;
     }
     /// Get actions available for Uploaders too
     if (isset($_GET['a'])) {
         switch ($_GET['a']) {
             case "Abo":
                 $this->page = new AdminAbout();
                 break;
             case "Upl":
                 if (isset($_POST['path'])) {
                     AdminUpload::upload();
                     CurrentUser::$path = File::r2a(stripslashes($_POST['path']));
                 }
                 break;
             case "Mov":
                 if (isset($_POST['pathFrom'])) {
                     try {
                         CurrentUser::$path = File::r2a(dirname(stripslashes($_POST['pathFrom'])));
                     } catch (Exception $e) {
                         CurrentUser::$path = Settings::$photos_dir;
                     }
                 }
                 Admin::move();
                 if (isset($_POST['move']) && $_POST['move'] == "rename") {
                     try {
                         if (is_dir(File::r2a(stripslashes($_POST['pathFrom'])))) {
                             CurrentUser::$path = dirname(File::r2a(stripslashes($_POST['pathFrom']))) . "/" . stripslashes($_POST['pathTo']);
                         }
                     } catch (Exception $e) {
                         CurrentUser::$path = Settings::$photos_dir;
                     }
                 }
                 break;
             case "Del":
                 if (isset($_POST['del'])) {
                     if (!is_array($_POST['del'])) {
                         CurrentUser::$path = dirname(File::r2a(stripslashes($_POST['del'])));
                     } else {
                         CurrentUser::$path = dirname(File::r2a(stripslashes($_POST['del'][0])));
                     }
                     Admin::delete();
                 }
                 break;
         }
     }
     /// Check that current user is an admin
     if (!CurrentUser::$admin) {
         return;
     }
     /// Get action
     if (isset($_GET['a'])) {
         switch ($_GET['a']) {
             case "Sta":
                 $this->page = new AdminStats();
                 break;
             case "VTk":
                 $this->page = new GuestToken();
                 break;
             case "DTk":
                 if (isset($_POST['tokenkey'])) {
                     GuestToken::delete($_POST['tokenkey']);
                 }
                 $this->page = new GuestToken();
                 break;
             case "Acc":
                 if (isset($_POST['edit'])) {
                     Account::edit($_POST['login'], $_POST['old_password'], $_POST['password'], $_POST['name'], $_POST['email'], NULL, $_POST['language']);
                 }
                 if (isset($_POST['login'])) {
                     $this->page = new Account($_POST['login']);
                 } else {
                     $this->page = CurrentUser::$account;
                 }
                 break;
             case "GC":
                 Group::create($_POST['group']);
                 $this->page = new Group();
                 break;
             case "AAc":
                 Account::create($_POST['login'], $_POST['password'], $_POST['verif']);
                 $this->page = new Group();
                 break;
             case "AGA":
                 $a = new Account($_POST['acc']);
                 $a->add_group($_POST['group']);
                 $a->save();
                 $this->page = CurrentUser::$account;
                 break;
             case "AGR":
                 $a = new Account($_POST['acc']);
                 $a->remove_group($_POST['group']);
                 $a->save();
                 $this->page = CurrentUser::$account;
                 break;
             case "ADe":
                 Account::delete($_POST['name']);
                 $this->page = new Group();
                 break;
             case "GEd":
                 Group::edit($_POST);
                 $this->page = new Group();
                 break;
             case "GDe":
                 Group::delete($_GET['g']);
                 $this->page = new Group();
                 break;
             case "CDe":
                 CurrentUser::$path = File::r2a($_POST['image']);
                 Comments::delete($_POST['id']);
                 $this->page = new MainPage();
                 break;
             case "JS":
                 break;
             case "EdA":
                 $this->page = new Group();
                 break;
             case "GAl":
                 if (isset($_POST['path'])) {
                     Settings::gener_all(File::r2a(stripslashes($_POST['path'])));
                 }
             case "Set":
                 if (isset($_POST['name'])) {
                     Settings::set();
                 }
                 $this->page = new Settings();
                 break;
         }
     }
     if (!isset($this->page)) {
         $this->page = new AdminAbout();
     }
     /// Create menu
     $this->menu = new AdminMenu();
 }
예제 #7
0
 public function testLogAuditEventsListWithShortFormat()
 {
     Yii::app()->user->userModel = User::getByUsername('jimmy');
     $beforeCount = AuditEvent::getCount();
     $account = new Account();
     $account->name = 'Yoddle';
     $this->assertTrue($account->save());
     $this->assertEquals($beforeCount + 1, AuditEvent::getCount());
     $account->delete();
     $this->assertEquals($beforeCount + 2, AuditEvent::getCount());
     $AuditEventsList = AuditEvent::getTailEvents(2);
     $this->assertEquals('Item Created', ZurmoModule::stringifyAuditEvent($AuditEventsList[0], 'short'));
     $this->assertEquals('Item Deleted', ZurmoModule::stringifyAuditEvent($AuditEventsList[1], 'short'));
 }
예제 #8
0
		{
			$_GET["id"]=$_POST["id"];   // Force chargement page en mode visu
		}
		else
		{
			$message='<div class="error">'.$account->error.'</div>';
			$_GET["action"]='edit';     // Force chargement page edition
		}
	}
}

if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->banque->configurer)
{
	// Modification
	$account = new Account($db, $_GET["id"]);
	$account->delete($_GET["id"]);

	header("Location: ".DOL_URL_ROOT."/compta/bank/index.php");
	exit;
}


/*
 * View
 */

llxHeader();

$form = new Form($db);

/* ************************************************************************** */
예제 #9
0
            $mail->Body = $mailBody;
            if ($mail->Send()) {
                $main_content .= 'Your account has been created. Check your e-mail. See you in Tibia!<BR><BR>';
                $main_content .= '<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
				<TR><TD BGCOLOR="' . $config['site']['vdarkborder'] . '" CLASS=white><B>Account Created</B></TD></TR>
				<TR><TD BGCOLOR="' . $config['site']['darkborder'] . '">
				  <TABLE BORDER=0 CELLPADDING=1><TR><TD>
				    <BR>Your account name is <b>' . $reg_name . '</b>.
					<BR><b><i>You will receive e-mail (<b>' . htmlspecialchars($reg_email) . '</b>) with your password.</b></i><br>';
                $main_content .= 'You will need the account name and your password to play on ' . htmlspecialchars($config['server']['serverName']) . '.
				    Please keep your account name and password in a safe place and
				    never give your account name or password to anybody.<BR><BR>';
                $main_content .= '<br /><small>These informations were send on email address <b>' . htmlspecialchars($reg_email) . '</b>. Please check your inbox/spam folder.';
            } else {
                $main_content .= '<br /><small>An error occorred while sending email! Account not created. Try again.</small>';
                $reg_account->delete();
            }
        } else {
            $main_content .= 'Your account has been created. Now you can login and create your first character. See you in Tibia!<BR><BR>';
            $main_content .= '<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
			<TR><TD BGCOLOR="' . $config['site']['vdarkborder'] . '" CLASS=white><B>Account Created</B></TD></TR>
			<TR><TD BGCOLOR="' . $config['site']['darkborder'] . '">
			  <TABLE BORDER=0 CELLPADDING=1><TR><TD>
			    <BR>Your account name is <b>' . htmlspecialchars($reg_name) . '</b><br>You will need the account name and your password to play on ' . htmlspecialchars($config['server']['serverName']) . '.
			    Please keep your account name and password in a safe place and
			    never give your account name or password to anybody.<BR><BR>';
            if ($config['site']['send_emails'] && $config['site']['send_register_email']) {
                $mailBody = '<html>
				<body>
				<h3>Your account name and password!</h3>
				<p>You or someone else registred on server <a href="' . $config['server']['url'] . '"><b>' . htmlspecialchars($config['server']['serverName']) . '</b></a> with this e-mail.</p>
예제 #10
0
 public function testDeleteSecurableItemDeletesItsPermissions()
 {
     $user = User::getByUsername('billy');
     $account = new Account();
     $account->name = 'Waxamatronic';
     $account->addPermissions($user, Permission::READ);
     $this->assertTrue($account->save());
     $this->assertEquals(1, count($account->permissions));
     $this->assertEquals(Permission::READ, $account->getEffectivePermissions($user));
     $account->delete();
     unset($account);
     $userId = $user->id;
     unset($user);
     RedBeanModel::forgetAll();
     $this->assertEquals(0, count(Permission::getAll()));
 }
예제 #11
0
 /**
  * testBankAccountDelete
  *
  * @param   int $id     Id of contract
  * @return  int
  *
  * @depends testBankAccountOther
  * The depends says test is run only if previous is ok
  */
 public function testBankAccountDelete($id)
 {
     global $conf, $user, $langs, $db;
     $conf = $this->savconf;
     $user = $this->savuser;
     $langs = $this->savlangs;
     $db = $this->savdb;
     $localobject = new Account($this->savdb);
     $result = $localobject->fetch($id);
     $result = $localobject->delete($id);
     print __METHOD__ . " id=" . $id . " result=" . $result . "\n";
     $this->assertLessThan($result, 0);
     return $result;
 }