Beispiel #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $account = new Account();
     $account->setDomain(Input::get('domain'));
     $account->setNit(Input::get('nit'));
     $account->setName(Input::get('name'));
     $account->setEmail(Input::get('email'));
     // return $account->getErrorMessage();
     if ($account->Guardar()) {
         //redireccionar con el mensaje a la siguiente vista
         Session::flash('mensaje', $account->getErrorMessage());
         $direccion = "http://" . $account->domain . ".emizor.com";
         //enviando correo de bienvenida
         global $correo;
         $correo = $account->getEmail();
         // return Response::json($correo);
         Mail::send('emails.bienvenida', array('direccion' => $direccion, 'name' => $account->getName(), 'nit' => $account->getNit()), function ($message) {
             global $correo;
             $message->to($correo, '')->subject('Emizor');
         });
         //
         // $direccion = "/crear/sucursal";
         return Redirect::to($direccion);
     }
     Session::flash('error', $account->getErrorMessage());
     return Redirect::to('crear');
 }
Beispiel #2
0
 /**
  * Adds a new acccount
  *
  * @param string $strName
  * @param int $intDomainId
  * @param string $strPassword
  * @return int The user ID
  */
 public function do_add($strName, $intDomainId, $strPassword)
 {
     $strName = strtolower($strName);
     // Only letters, numbers and the dash symbol are allowed!
     if (preg_match('/[^a-z0-9\\-]/', $strName) !== 0 || strlen($strName) > 45) {
         throw new Exception('Invalid account name');
     }
     $account = new Account();
     $account->setName($strName)->save();
     return $account->getId();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     // return Response::json(Input::all());
     $account = new Account();
     // $account->ip = Request::getClientIp();
     // $account->account_key = str_random(RANDOM_KEY_LENGTH);
     //$account->setDomain(Input::get('domain'));
     $account->setNit(Input::get('nit'));
     $account->setName(Input::get('name'));
     if ($account->Guardar()) {
         $direccion = "http://cascada.ipx";
         // $direccion = "/crear/sucursal";
         return Redirect::to($direccion);
     }
     return Response::json(Input::all());
     // Session::put('error',$account->getErrorMessage());
     // return Redirect::('crear');
     // $account->language_id = 1;
     // $account->save();
     // $user = new User;
     // $username = trim(Input::get('username'));
     // $user->username = $username . "@" . $account->domain;
     // $user->password = Hash::make(trim(Input::get('password')));
     // $user->public_id = 1;
     // $user->confirmation_code = '';
     // $user->is_admin = true;
     // $account->users()->save($user);
     // $category = new Category;
     // $category->user_id =$user->getId();
     // $category->name = "General";
     // $category->public_id = 1;
     // $account->categories()->save($category);
     // $InvoiceDesign = new InvoiceDesign;
     // $InvoiceDesign->user_id =$user->getId();
     // $InvoiceDesign->logo = "";
     // $InvoiceDesign->x = "5";
     // $InvoiceDesign->y = "5";
     // $InvoiceDesign->javascript = "";
     // $account->invoice_designs()->save($InvoiceDesign);
     // $admin = User::find($user->id);
     // Auth::login($admin);
     // $data = array('guardado exitoso' => ' se registro correctamente hasta aqui todo blue :)' ,'datos'=>Input::all());
     // Session::put('account_id',$user->account_id);
     // // return View::make('sucursales.edit')->with(array('account_id' => $user->account_id));
     // return Redirect::to('cuentas');
 }
function create_ecp_PaymentMethod()
{
    $uniqueValue = get_unique_value();
    $merchantAccountId = 'account-' . $uniqueValue;
    $merchantPaymentMethodId = 'pm-' . $uniqueValue;
    $email = get_unique_value() . '@nomail.com';
    $successUrl = 'http://good.com/';
    //need a trailing slash
    $errorUrl = 'http://bad.com/';
    //need a trailing slash
    $name = 'John Vindicia';
    $addr1 = '303 Twin Dolphin Drive';
    $city = 'Redwood City';
    $district = 'CA';
    $postalCode = '94065';
    $country = 'US';
    $address = new Address();
    $address->setName($name);
    $address->setAddr1($addr1);
    $address->setCity($city);
    $address->setDistrict($district);
    $address->setPostalCode($postalCode);
    $address->setCountry($country);
    $paymentmethod = new PaymentMethod();
    $paymentmethod->setType('ECP');
    $paymentmethod->setAccountHolderName($name);
    $paymentmethod->setBillingAddress($address);
    $paymentmethod->setMerchantPaymentMethodId($merchantPaymentMethodId);
    $paymentmethod->setCurrency('USD');
    $ecp = new ECP();
    $ecp->setAccount('495958930');
    $ecp->setRoutingNumber('611111111');
    $ecp->setAllowedTransactionType('Inbound');
    $ecp->setAccountType('ConsumerChecking');
    $paymentmethod->setECP($ecp);
    $account = new Account();
    $account->setMerchantAccountId($merchantAccountId);
    $account->setEmailAddress($email);
    $account->setShippingAddress($address);
    $account->setEmailTypePreference('html');
    $account->setName($name);
    $account->setPaymentMethods(array($paymentmethod));
    return $account;
}
  static public function retrieveByClient($client_id = null)
  {
    if(!$client_id)
      die('Should add case for all clients!');
    // sql here for retrieve info from db by $client_id
    $accounts = array();
    $query="SELECT a.id, a.name, a.amount, c.abbreviation cname FROM account a, currency c WHERE id_client = '$client_id' AND c.id = a.id_currency";
//echo $query;
    $qres=mysql_query($query);
    while($row=mysql_fetch_assoc($qres))
    {
      $account = new Account();
      $account->setId($row['id']);
      $account->setName($row['name']);
      $account->setAmount($row['amount']);
      $account->setCurrency($row['cname']);
      $accounts[] = $account;
    }

    return $accounts;
  }
Beispiel #6
0
 public function __construct($arrayAccounts)
 {
     // browse through list
     $collection = array();
     if ($arrayAccounts) {
         foreach ($arrayAccounts as $arrayAccount) {
             $account = new Account();
             $account->setId($arrayAccount['name_value_list']['id']);
             $account->setName(htmlspecialchars_decode($arrayAccount['name_value_list']['name'], ENT_QUOTES));
             $account->setAssignedAt($arrayAccount['name_value_list']['assigned_user_name']);
             $account->setidLMB($arrayAccount['name_value_list']['id_compte_lundi_matin_c']);
             $collection[$account->getId()] = $account;
         }
         // Sort accounts by name
         usort($collection, function ($a, $b) {
             return strcmp($a->getName(), $b->getName());
         });
     }
     // build ArrayObject using collection
     return parent::__construct($collection);
 }
function CreateAccount($merchantAccountId, $email)
{
    $account = new Account();
    $account->setName('Migrated Customer');
    $account->setMerchantAccountId($merchantAccountId);
    // Be conscious that using real email addresses in ProdTest depending on configuration will
    // have live emails triggered and sent on billing events for the Account.
    // It is recommended that when testing in ProdTest be certain to mask real email addresses.
    $account->setEmailAddress($email);
    $account->setEmailTypePreference('html');
    $account->setWarnBeforeAutoBilling(true);
    $anyOtherHelpfulDataForCSRsWhenLookingUpAccount = new NameValuePair();
    $anyOtherHelpfulDataForCSRsWhenLookingUpAccount->setName('HelpfulData');
    $anyOtherHelpfulDataForCSRsWhenLookingUpAccount->setValue('BestCustomerEver');
    $account->setNameValues(array($anyOtherHelpfulDataForCSRsWhenLookingUpAccount));
    $address = new Address();
    $address->setAddr1('303 Twin Dolphin Drive');
    $address->setAddr2('Suite 200');
    $address->setCity('Redwood City');
    $address->setDistrict('CA');
    $address->setPostalCode('94065');
    $address->setCountry('US');
    $address->setPhone('123-456-7890');
    $srd = '';
    $account->setShippingAddress($address);
    $response = $account->update($srd);
    // Log soap id for each API call.
    //    $log->addDebug('Method = Account.update' . PHP_EOL);
    //    $log->addDebug('Soap Id = ' . $response['data']->return->soapId . PHP_EOL);
    //    $log->addDebug('Return Code = ' . $response['returnCode'] . PHP_EOL);
    //    $log->addDebug('Return String = ' . $response['returnString'] . PHP_EOL);
    if ($response['returnCode'] == 200) {
        print "Call succeeded" . PHP_EOL;
    } else {
        print "Call failed" . PHP_EOL;
        print_r($response);
    }
}
function create_paypal_PaymentMethod()
{
    $uniqueValue = get_unique_value();
    $merchantAccountId = 'account-' . $uniqueValue;
    $merchantPaymentMethodId = 'pm-' . $uniqueValue;
    $email = get_unique_value() . '@nomail.com';
    $successUrl = 'http://good.com/';
    //need a trailing slash
    $errorUrl = 'http://bad.com/';
    //need a trailing slash
    $name = 'John Vindicia';
    $addr1 = '303 Twin Dolphin Drive';
    $city = 'Redwood City';
    $district = 'CA';
    $postalCode = '94065';
    $country = 'US';
    $address = new Address();
    $address->setName($name);
    $address->setAddr1($addr1);
    $address->setCity($city);
    $address->setDistrict($district);
    $address->setPostalCode($postalCode);
    $address->setCountry($country);
    $paymentmethod = new PaymentMethod();
    $paymentmethod->setType('PayPal');
    $paymentmethod->setAccountHolderName($name);
    $paymentmethod->setBillingAddress($address);
    $paymentmethod->setMerchantPaymentMethodId($merchantPaymentMethodId);
    $paymentmethod->setCurrency('USD');
    $paypal = new PayPal();
    $paypal->setReturnUrl($successUrl);
    $paypal->setCancelUrl($errorUrl);
    $paymentmethod->setPaypal($paypal);
    $account = new Account();
    $account->setMerchantAccountId($merchantAccountId);
    $account->setEmailAddress($email);
    $account->setShippingAddress($address);
    $account->setEmailTypePreference('html');
    $account->setName($name);
    //$account->setPaymentMethods(array($paymentmethod));
    //return $account;
    return array('account' => $account, 'paymentmethod' => $paymentmethod);
}
Beispiel #9
0
		<tr><td>Name:</td><td>		<input size=20 type=text name=name value=".$_POST['name']."><br></td></tr>
		<tr><td>Surname:</td><td>	<input size=20 type=text name=surname value=".$_POST['surname']."><br></td></tr>
		<tr><td>Phone Number:</td><td>	<input type=text name=number value=".$_POST['number']."><br></td></tr>
		<tr><td>Region:</td><td>	<input type=text name=region value=".$_POST['region']."><br></td></tr>
		<tr><td></td><td><input type=submit value='Register'></td></tr>
		</form>
		</table>
		</font>
	 	";
	}elseif( $_POST['password'] == $_POST['repassword'] && strlen($_POST['password'])>0 )
	{
		//account creation
		$account = new Account();
		$account->setEmail($_POST['email']);
		$account->setPassword($_POST['password']);
		$account->setName($_POST['name']);
		$account->setSurname($_POST['surname']);
		$account->setNumber($_POST['number']);
		//$account->showVariable(); //this is for debugger
		//echo $_POST['email'];
		$account->checkemail($_POST['email']);
		$account->addAccount( $account->checkemailflag,$_POST['email'],$_POST['password'],$_POST['name'],$_POST['surname'],$_POST['number'],$_POST['region'] );
	//password didn't match
	}else{
	echo " <font size=4>Your account has not been created. Please fill out the form correctly.</font><br>";
	}

}else{
?>
<center><h2>SIGN UP</h2></center>
<font size=4>
Beispiel #10
0
 include_once './system/load.compat.php';
 $newpass = trim($_POST['newpass']);
 if (!check_password($newpass)) {
     echo 'Password contains illegal characters. Please use only a-Z and 0-9. <a href="install.php?page=step&step=5">GO BACK</a> and write other password.';
 } else {
     //create / set pass to admin account
     $account = new Account(1, Account::LOADTYPE_NAME);
     if ($account->isLoaded()) {
         $account->setPassword($newpass);
         // setPassword encrypt it to ots encryption
         $account->setPageAccess(3);
         $account->setFlag('unknown');
         $account->save();
     } else {
         $newAccount = new Account();
         $newAccount->setName(1);
         $newAccount->setPassword($newpass);
         // setPassword encrypt it to ots encryption
         $newAccount->setMail(rand(0, 999999) . '@gmail.com');
         $newAccount->setPageAccess(3);
         $newAccount->setGroupID(1);
         $newAccount->setFlag('unknown');
         $newAccount->setCreateIP(Visitor::getIP());
         $newAccount->setCreateDate(time());
     }
     $_SESSION['account'] = 1;
     $_SESSION['password'] = $newpass;
     $logged = TRUE;
     echo '<h1>Admin account login: 1<br>Admin account password: '******'</h1><br/><h3>It\'s end of installation. Installation is blocked!</h3>';
     if (!unlink('install.txt')) {
         new Error_Critic('', 'Cannot remove file <i>install.txt</i>. You must remove it to disable installer. I recommend you to go to step <i>0</i> and check if any other file got problems with WRITE permission.');
$state = "CA";
$postalcode = "94002";
$country = "US";
$email = "childAccount" . rand(10000, 99999) . "@vindicia.com";
$address = new Address();
$address->setName($name);
$address->setAddr1($addr1);
$address->setCity($city);
$address->setDistrict($state);
$address->setPostalCode($postalcode);
$address->setCountry($country);
$accountID = "childAccount" . rand(1000, 9999) . "-" . rand(1000, 999999);
$child1 = new Account();
$child1->setMerchantAccountId($accountID);
$child1->setEmailAddress($email);
$child1->setShippingAddress($address);
$child1->setEmailTypePreference('html');
$child1->setWarnBeforeAutoBilling(false);
$child1->setName($name);
$parent = new Account();
$parent->setMerchantAccountId($parentID);
// use the force flag to remove these children from a previous parent
// and assign them to this new one
//$force=true;
$force = false;
// use payerReplace to determine if any existing autobills of these children
// should use the parents payment method, or only autobills created from here in should.
//$payerReplacementBehavior='ReplaceOnAllAutoBills';
$payerReplacementBehavior = 'ReplaceOnlyFutureAutoBills';
$response = $parent->addChildren(array($child1), $force, $payerReplacementBehavior);
print_r($response);
Beispiel #12
0
        if ($account_db->isLoaded()) {
            $reg_form_errors[] = 'Account with this name already exist.';
        }
    }
    // ----------creates account-------------(save in database)
    if (empty($reg_form_errors)) {
        //create object 'account' and generate new acc. number
        if ($config['site']['create_account_verify_mail']) {
            $reg_password = '';
            for ($i = 1; $i <= 6; $i++) {
                $reg_password .= mt_rand(0, 9);
            }
        }
        $reg_account = new Account();
        // saves account information in database
        $reg_account->setName($reg_name);
        $reg_account->setPassword($reg_password);
        $reg_account->setEMail($reg_email);
        $reg_account->setCreateDate(time());
        $reg_account->setCreateIP(Visitor::getIP());
        $reg_account->setFlag(Website::getCountryCode(long2ip(Visitor::getIP())));
        if (isset($config['site']['newaccount_premdays']) && $config['site']['newaccount_premdays'] > 0) {
            $reg_account->set("premdays", $config['site']['newaccount_premdays']);
            $reg_account->set("lastday", time());
        }
        $reg_account->save();
        //show information about registration
        if ($config['site']['send_emails'] && $config['site']['create_account_verify_mail']) {
            $mailBody = '<html>
			<body>
			<h3>Your account name and password!</h3>
Beispiel #13
0
 public static function import($strXml, $blnOverwrite = false, $blnKeepSettings = false)
 {
     global $objLiveAdmin, $intDefaultLanguage, $_CONF;
     $objReturn = NULL;
     $objSettings = NULL;
     $blnZip = false;
     //*** Init DOM object.
     $objDoc = new DOMDocument("1.0", "UTF-8");
     $objDoc->formatOutput = false;
     $objDoc->preserveWhiteSpace = true;
     if (is_file($strXml)) {
         $objZip = new dUnzip2($strXml);
         if (is_object($objZip)) {
             //*** Zip file.
             $strXml = $objZip->unzip('data.xml');
             if ($strXml !== false) {
                 //*** Fix a unicode bug. Replace forbidden characters (The first 8).
                 for ($intCount = 1; $intCount < 9; $intCount++) {
                     $strHex = str_pad(dechex($intCount), 4, "0", STR_PAD_LEFT);
                     $strXml = preg_replace('/\\x{' . $strHex . '}/u', "", $strXml);
                 }
                 $strXml = preg_replace('/\\x{001f}/u', "", $strXml);
                 $objDoc->loadXML($strXml);
                 $blnZip = true;
             }
         } else {
             //*** XML file.
             $objDoc->load($strXml);
         }
     } else {
         $objDoc->loadXML($strXml);
     }
     //*** Build data structure.
     foreach ($objDoc->childNodes as $rootNode) {
         if ($rootNode->nodeName == "Punch") {
             //*** Valid Punch XML.
             foreach ($rootNode->childNodes as $accountNode) {
                 if ($accountNode->nodeName == "account") {
                     //*** Account node.
                     if ($blnOverwrite) {
                         $objAccount = Account::getByPunchId($accountNode->getAttribute("punchId"));
                         if (is_object($objAccount) && $blnKeepSettings) {
                             //*** Save settings.
                             $objSettings = Settings::getByAccount($objAccount->getId());
                         }
                         //*** Remove account.
                         if (is_object($objAccount)) {
                             $objAccount->delete();
                         }
                     }
                     //*** Create account.
                     $objAccount = new Account();
                     $objAccount->setPunchId($accountNode->getAttribute("punchId"));
                     $objAccount->setName($accountNode->getAttribute("name"));
                     $objAccount->setUri($accountNode->getAttribute("uri"));
                     $objAccount->setTimeZoneId(42);
                     $objAccount->save();
                     //*** Create temporary account object.
                     $_CONF['app']['account'] = $objAccount;
                     foreach ($accountNode->childNodes as $childNode) {
                         $arrUserIds = array();
                         $arrGroupIds = array();
                         switch ($childNode->nodeName) {
                             case "acl":
                                 self::importAcl($childNode, $objAccount->getId(), $arrUserIds, $arrGroupIds);
                                 break;
                             case "products":
                                 //*** Add products to the account.
                                 foreach ($childNode->childNodes as $productNode) {
                                     switch ($productNode->nodeName) {
                                         case "pcms":
                                             //*** Add PunchCMS product to the account.
                                             $objAccountProduct = new AccountProduct();
                                             $objAccountProduct->setAccountId($objAccount->getId());
                                             $objAccountProduct->setProductId(PRODUCT_PCMS);
                                             $objAccountProduct->setExpires($productNode->getAttribute("expires"));
                                             $objAccountProduct->save();
                                             $arrStorageIds[0] = 0;
                                             $arrFeedIds[0] = 0;
                                             //*** Add PunchCMS data to the account.
                                             foreach ($productNode->childNodes as $pcmsNode) {
                                                 switch ($pcmsNode->nodeName) {
                                                     case "settings":
                                                         //*** Add settings to the account.
                                                         if ($blnKeepSettings && is_object($objSettings)) {
                                                             foreach ($objSettings as $objSetting) {
                                                                 $objSetting->setId(0);
                                                                 $objSetting->setAccountId($objAccount->getId());
                                                                 $objSetting->save();
                                                             }
                                                         } else {
                                                             foreach ($pcmsNode->childNodes as $settingNode) {
                                                                 $objSettingTemplate = SettingTemplate::selectByName($settingNode->getAttribute("name"));
                                                                 if (is_object($objSettingTemplate)) {
                                                                     $objSetting = new Setting();
                                                                     $objSetting->setAccountId($objAccount->getId());
                                                                     $objSetting->setSettingId($objSettingTemplate->getId());
                                                                     $objSetting->setValue($settingNode->getAttribute("value"));
                                                                     $objSetting->save();
                                                                 }
                                                             }
                                                         }
                                                         break;
                                                     case "languages":
                                                         //*** Add languages to the account.
                                                         $arrLanguageIds[0] = 0;
                                                         foreach ($pcmsNode->childNodes as $languageNode) {
                                                             $objLanguage = new ContentLanguage();
                                                             $objLanguage->setAccountId($objAccount->getId());
                                                             $objLanguage->setName($languageNode->getAttribute("name"));
                                                             $objLanguage->setAbbr($languageNode->getAttribute("abbr"));
                                                             $objLanguage->default = $languageNode->getAttribute("default");
                                                             $objLanguage->setActive($languageNode->getAttribute("active"));
                                                             $objLanguage->setSort($languageNode->getAttribute("sort"));
                                                             $objLanguage->setUsername($languageNode->getAttribute("username"));
                                                             $objLanguage->save();
                                                             $arrLanguageIds[$languageNode->getAttribute("id")] = $objLanguage->getId();
                                                             if ($languageNode->getAttribute("default") == 1) {
                                                                 $intDefaultLanguage = $objLanguage->getId();
                                                             }
                                                         }
                                                         break;
                                                     case "feeds":
                                                         //*** Add feeds to the account.
                                                         $arrFeedIds[0] = 0;
                                                         foreach ($pcmsNode->childNodes as $feedNode) {
                                                             $objFeed = new Feed();
                                                             $objFeed->setAccountId($objAccount->getId());
                                                             $objFeed->setName($feedNode->getAttribute("name"));
                                                             $objFeed->setFeed($feedNode->getAttribute("feed"));
                                                             $objFeed->setBasePath($feedNode->getAttribute("basepath"));
                                                             $objFeed->setRefresh($feedNode->getAttribute("refresh"));
                                                             $objFeed->setLastUpdate($feedNode->getAttribute("lastUpdate"));
                                                             $objFeed->setActive($feedNode->getAttribute("active"));
                                                             $objFeed->setSort($feedNode->getAttribute("sort"));
                                                             $objFeed->save();
                                                             $arrFeedIds[$feedNode->getAttribute("id")] = $objFeed->getId();
                                                         }
                                                         break;
                                                     case "storage":
                                                         //*** Add media items to the account.
                                                         self::importStorage($pcmsNode, $objAccount->getId(), $arrStorageIds);
                                                         break;
                                                     case "templates":
                                                         //*** Add templates to the account.
                                                         $arrTemplateIds[0] = 0;
                                                         $arrTemplateFieldIds[0] = 0;
                                                         $arrLinkFieldIds = array();
                                                         self::importTemplates($pcmsNode, $objAccount->getId(), $arrTemplateIds, $arrTemplateFieldIds, $arrLinkFieldIds);
                                                         break;
                                                     case "elements":
                                                         //*** Add elements to the account.
                                                         $arrElementIds[0] = 0;
                                                         $arrElementFieldIds["link"][0] = 0;
                                                         $arrElementFieldIds["largeText"][0] = 0;
                                                         self::importElements($pcmsNode, $objAccount->getId(), $arrTemplateIds, $arrTemplateFieldIds, $arrElementIds, $arrElementFieldIds, $arrLinkFieldIds, $arrLanguageIds, $arrUserIds, $arrGroupIds, $arrStorageIds, $arrFeedIds);
                                                         break;
                                                     case "aliases":
                                                         //*** Add aliases to the account.
                                                         foreach ($pcmsNode->childNodes as $aliasNode) {
                                                             $objAlias = new Alias();
                                                             $objAlias->setAccountId($objAccount->getId());
                                                             $objAlias->setAlias($aliasNode->getAttribute("alias"));
                                                             if (array_key_exists($aliasNode->getAttribute("url"), $arrElementIds)) {
                                                                 $objAlias->setUrl($arrElementIds[$aliasNode->getAttribute("url")]);
                                                             } else {
                                                                 $objAlias->setUrl(0);
                                                             }
                                                             if (array_key_exists($aliasNode->getAttribute("language"), $arrLanguageIds)) {
                                                                 $objAlias->setLanguageId($arrLanguageIds[$aliasNode->getAttribute("language")]);
                                                             } else {
                                                                 $objAlias->setLanguageId(0);
                                                             }
                                                             $objAlias->setCascade($aliasNode->getAttribute("cascade"));
                                                             $objAlias->setActive($aliasNode->getAttribute("active"));
                                                             $objAlias->setSort($aliasNode->getAttribute("sort"));
                                                             $objAlias->setCreated($aliasNode->getAttribute("created"));
                                                             $objAlias->setModified($aliasNode->getAttribute("modified"));
                                                             $objAlias->save();
                                                         }
                                                         break;
                                                 }
                                             }
                                             //*** Adjust the links for deeplink fields.
                                             self::adjustDeeplinks($arrElementFieldIds["link"], $arrElementIds, $arrLanguageIds);
                                             //*** Adjust the links in large text fields.
                                             self::adjustTextlinks($arrElementFieldIds["largeText"], $arrElementIds, $arrLanguageIds, $arrStorageIds);
                                             break;
                                     }
                                 }
                                 break;
                         }
                     }
                     //*** Destroy temporary account object.
                     unset($_CONF['app']['account']);
                     $objReturn = $objAccount;
                 }
             }
         }
     }
     //*** Files.
     if ($blnZip && is_object($objReturn)) {
         self::importFiles($objZip, $objReturn);
         if ($blnKeepSettings) {
             //*** Move files to remote server.
             self::moveImportedFiles($objReturn);
         }
     }
     return $objReturn;
 }
$address->setDistrict($state);
$address->setPostalCode($postalcode);
$address->setCountry($country);
$accountID = "map-" . rand(1000, 9999) . "-" . rand(1000, 999999);
$map = new MerchantAcceptedPayment();
$pm = new PaymentMethod();
$pm->setType('MerchantAcceptedPayment');
$pm->setMerchantAcceptedPayment($map);
$pm_array = array($pm);
$account = new Account();
$account->setMerchantAccountId($accountID);
$account->setEmailAddress($email);
$account->setShippingAddress($address);
$account->setEmailTypePreference('html');
$account->setWarnBeforeAutoBilling(false);
$account->setName($name);
$account->setPaymentMethods($pm_array);
// must be an existing Product
$productID = $argv[1];
print "productID is {$productID} \n";
$product = new Product();
$product->setMerchantProductId($productID);
// AutoBills may have multiple products
// each in an AutoBillItem as an array:
$item = new AutoBillItem();
// set the Product in the AutoBillItem
$item->setProduct($product);
$item->setMerchantAutoBillItemId('myAutoBillItem-' . rand(00, 99999));
// must be an existing BillingPlan
$billingplanID = $argv[2];
print "billingplanID is {$billingplanID} \n";
Beispiel #15
0
function parseAccount($eId, $cmd)
{
    global $_PATHS, $_CONF, $objUpload, $objLiveAdmin;
    $objTpl = new HTML_Template_IT($_PATHS['templates']);
    $objTpl->loadTemplatefile("account.tpl.htm");
    switch ($cmd) {
        case CMD_EDIT:
            $strDispatch = Request::get('dispatch');
            $intPermId = Request::get('frm_userid');
            $strPunchId = Request::get('frm_punchid');
            $strName = Request::get('frm_name');
            $strDomain = Request::get('frm_uri');
            $strUserName = Request::get('frm_account_name');
            $strUserPass = Request::get('frm_account_pass');
            $strUserEmail = Request::get('frm_account_email');
            //$arrProducts 	= Request::get('frm_account_product', array());
            $objAccount = Account::selectByPk($eId);
            if ($strDispatch == "editAccount") {
                if (is_object($objAccount)) {
                    $objAccount->setName($strName);
                    $objAccount->setUri($strDomain);
                    $objAccount->save();
                    //*** Set products.
                    $objAccount->clearProducts();
                    /*
                    foreach ($arrProducts as $intProduct) {
                    	$objAccount->addProduct($intProduct);
                    }
                    */
                    $objAccount->addProduct(1);
                    //*** Edit Admin user.
                    $data = array('name' => $strUserName, 'email' => $strUserEmail);
                    if (!empty($strUserPass)) {
                        $data['passwd'] = $strUserPass;
                    }
                    $objLiveAdmin->updateUser($data, $intPermId);
                    $objTpl->setCurrentBlock("text");
                    $objTpl->setVariable('BODY', "<p>Account saved successfully.</p>");
                    $objTpl->parseCurrentBlock();
                }
            } else {
                if (is_object($objAccount)) {
                    $strAdminName = "";
                    $strAdminEmail = "";
                    //*** Admin user.
                    $filters = array('container' => 'auth', 'filters' => array('account_id' => array($objAccount->getId())));
                    $objUsers = $objLiveAdmin->getUsers($filters);
                    if (is_array($objUsers)) {
                        foreach ($objUsers as $objUser) {
                            if ($objUser["perm_type"] == 4) {
                                $strAdminName = $objUser["name"];
                                $strAdminEmail = $objUser["email"];
                                $intPermId = $objUser["perm_user_id"];
                                break;
                            }
                        }
                    }
                    $objTpl->setCurrentBlock("form.field.punchid");
                    $objTpl->setVariable('PUNCH_ID_VALUE', $objAccount->getPunchId());
                    $objTpl->parseCurrentBlock();
                    /*
                    $objProducts = Product::getProducts();
                    $objAccountProducts = AccountProduct::getByAccountId($objAccount->getId());
                    foreach ($objProducts as $objProduct) {
                    	$objTpl->setCurrentBlock("form.field.product");
                    	$objTpl->setVariable('ID', $objProduct->getId());
                    	$objTpl->setVariable('LABEL', $objProduct->getName());
                    	$objTpl->setVariable('VALUE', $objProduct->getId());
                    	
                    	foreach ($objAccountProducts as $objAccountProduct) {
                    		if ($objAccountProduct->getProductId() == $objProduct->getId()) {
                    			$objTpl->setVariable('CHECKED', "checked=\"checked\"");
                    		}
                    	}
                    	
                    	$objTpl->parseCurrentBlock();
                    }
                    */
                    $objTpl->setCurrentBlock("form.edit");
                    $objTpl->setVariable('NAME_VALUE', $objAccount->getName());
                    $objTpl->setVariable('URI_VALUE', $objAccount->getUri());
                    $objTpl->setVariable('ACCOUNT_NAME_VALUE', $strAdminName);
                    $objTpl->setVariable('ACCOUNT_EMAIL_VALUE', $strAdminEmail);
                    $objTpl->setVariable('USER_ID', $intPermId);
                    $objTpl->setVariable('CID', NAV_ACCOUNT);
                    $objTpl->setVariable('EID', $eId);
                    $objTpl->setVariable('CMD', $cmd);
                    $objTpl->parseCurrentBlock();
                }
            }
            break;
        case CMD_ADD:
            $strDispatch = Request::get('dispatch');
            $strName = Request::get('frm_name');
            $strDomain = Request::get('frm_uri');
            $strUserName = Request::get('frm_account_name');
            $strUserPass = Request::get('frm_account_pass');
            $strUserEmail = Request::get('frm_account_email');
            //$arrProducts 	= Request::get('frm_account_product');
            if ($strDispatch == "editAccount") {
                //*** Generate new punchId.
                $strPunchId = Account::generateId();
                $objAccount = new Account();
                $objAccount->setPunchId($strPunchId);
                $objAccount->setName($strName);
                $objAccount->setUri($strDomain);
                $objAccount->setTimeZoneId(42);
                $objAccount->save();
                //*** Set products.
                $objAccount->clearProducts();
                /*
                foreach ($arrProducts as $intProduct) {
                	$objAccount->addProduct($intProduct);
                }
                */
                $objAccount->addProduct(1);
                //*** Add Admin user to the account.
                $data = array('handle' => 'admin', 'name' => $strUserName, 'passwd' => $strUserPass, 'is_active' => true, 'email' => $strUserEmail, 'account_id' => $objAccount->getId(), 'perm_type' => 4);
                $intPermId = $objLiveAdmin->addUser($data);
                $strOutput = "<p>Account successfully created.</p>\n";
                $strOutput .= "<p>PunchId: <b>{$objAccount->PunchId}</b></p>\n";
                $objTpl->setCurrentBlock("text");
                $objTpl->setVariable('BODY', $strOutput);
                $objTpl->parseCurrentBlock();
            } else {
                /*
                $objProducts = Product::getProducts();
                foreach ($objProducts as $objProduct) {
                	$objTpl->setCurrentBlock("form.field.product");
                	$objTpl->setVariable('ID', $objProduct->getId());
                	$objTpl->setVariable('LABEL', $objProduct->getName());
                	$objTpl->setVariable('VALUE', $objProduct->getId());
                	$objTpl->parseCurrentBlock();
                }
                */
                $objTpl->setCurrentBlock("form.edit");
                $objTpl->setVariable('CID', NAV_ACCOUNT);
                $objTpl->setVariable('EID', $eId);
                $objTpl->setVariable('CMD', $cmd);
                $objTpl->parseCurrentBlock();
            }
            break;
        case CMD_IMPORT:
            $strDispatch = Request::get('dispatch');
            $blnOverwrite = Request::get('frm_import_overwrite') == "true" ? true : false;
            $blnKeepSettings = Request::get('frm_import_keep_settings') == "true" ? true : false;
            if ($strDispatch == "importAccount") {
                if (empty($_FILES['frm_file']['name'])) {
                    $strOutput = "<p>Error importing the file. It's empty...</p>";
                } else {
                    if (is_uploaded_file($_FILES['frm_file']['tmp_name'])) {
                        $objAccount = ImpEx::import($_FILES['frm_file']['tmp_name'], $blnOverwrite, $blnKeepSettings);
                        if (is_object($objAccount)) {
                            $strOutput = "<p>Account for <b>{$objAccount->getName()}</b> has been imported successfully with PunchId <b>{$objAccount->PunchId}</b>.</p>\n";
                        } else {
                            $strOutput = "<p>Import failed! Check the XML and try again.</p>\n";
                        }
                    }
                }
                $objTpl->setCurrentBlock("text");
                $objTpl->setVariable('BODY', $strOutput);
                $objTpl->parseCurrentBlock();
            } else {
                $objTpl->setCurrentBlock("form.import");
                $objTpl->setVariable('CID', NAV_ACCOUNT);
                $objTpl->setVariable('CMD', $cmd);
                $objTpl->parseCurrentBlock();
            }
            break;
        case CMD_EXPORT:
            $strDispatch = Request::get('dispatch');
            $blnFiles = Request::get('frm_export_files') == "true" ? "1" : "0";
            if ($strDispatch == "exportAccount" && $eId > 0) {
                Request::redirect("/export.php?eid=" . $eId . "&files=" . $blnFiles);
            } else {
                $objTpl->setCurrentBlock("form.export");
                $objTpl->setVariable('CID', NAV_ACCOUNT);
                $objTpl->setVariable('CMD', $cmd);
                $objTpl->setVariable('EID', $eId);
                $objTpl->parseCurrentBlock();
            }
            break;
        case CMD_RESTORE:
            $strDispatch = Request::get('dispatch');
            $strBackupName = Request::get('frm_backup');
            $objAccount = Account::selectByPk($eId);
            if ($strDispatch == "restoreAccount") {
                if (is_object($objAccount)) {
                    if ($objAccount->restoreBackup($_PATHS['backup'] . $strBackupName)) {
                        $strOutput = "<p>Account successfully restored.</p>\n";
                    } else {
                        $strOutput = "<p>Errors occured while restoring the account.</p>\n";
                    }
                    $objTpl->setCurrentBlock("text");
                    $objTpl->setVariable('BODY', $strOutput);
                    $objTpl->parseCurrentBlock();
                }
            } else {
                if (is_object($objAccount)) {
                    $objBackups = $objAccount->getBackups();
                    foreach ($objBackups as $objBackup) {
                        $objTpl->setCurrentBlock("form.field.backup");
                        $objTpl->setVariable('VALUE', $objBackup["file"]);
                        $objTpl->setVariable('LABEL', $objBackup["label"]);
                        $objTpl->parseCurrentBlock();
                    }
                    $objTpl->setCurrentBlock("form.restore");
                    $objTpl->setVariable('ACCOUNT_VALUE', $objAccount->getName());
                    $objTpl->setVariable('CID', NAV_ACCOUNT);
                    $objTpl->setVariable('EID', $eId);
                    $objTpl->setVariable('CMD', $cmd);
                    $objTpl->parseCurrentBlock();
                }
            }
            break;
    }
    //*** Return the output.
    return $objTpl->get();
}