/**
  * Создать счет с набором свойств
  */
 public function testMakeWithProperties()
 {
     $data = array('user_id' => $this->helper->makeUser()->getId(), 'name' => 'Название счета', 'type_id' => 5, 'currency_id' => 1, 'Properties' => array($prop1 = array('field_id' => 10, 'field_value' => 'Значение 1'), $prop2 = array('field_id' => 20, 'field_value' => 'Значение 2')));
     $acc = new Account();
     $acc->fromArray($data, $deep = true);
     $acc->save();
     $prop1['account_id'] = $prop2['account_id'] = $acc->getId();
     $this->assertEquals(1, $this->queryFind('AccountProperty', $prop1)->count(), 'Prop 1');
     $this->assertEquals(1, $this->queryFind('AccountProperty', $prop2)->count(), 'Prop 1');
 }
Exemple #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();
 }
 public static function all_stats(Account $account, $ids, $metricGroups, $params = [])
 {
     $endTime = isset($params['end_time']) ? $params['end_time'] : new \DateTime('now');
     $endTime->setTime($endTime->format('H'), 0, 0);
     $startTime = isset($params['start_time']) ? $params['start_time'] : new \DateTime($endTime->format('c') . " - 7 days");
     $startTime->setTime($startTime->format('H'), 0, 0);
     $granularity = isset($params['granularity']) ? $params['granularity'] : Enumerations::GRANULARITY_HOUR;
     $placement = isset($params['placement']) ? $params['placement'] : Enumerations::PLACEMENT_ALL_ON_TWITTER;
     $segmentationType = isset($params['segmentation_type']) ? $params['segmentation_type'] : null;
     $params = ['metric_groups' => implode(",", $metricGroups), 'start_time' => $startTime->format('c'), 'end_time' => $endTime->format('c'), 'granularity' => $granularity, 'entity' => static::ENTITY, 'entity_ids' => implode(",", $ids), 'placement' => $placement];
     if (!is_null($segmentationType)) {
         $params['segmentation_type'] = $segmentationType;
     }
     $resource = str_replace(static::RESOURCE_REPLACE, $account->getId(), static::RESOURCE_STATS);
     $response = $account->getTwitterAds()->get($resource, $params);
     return $response->getBody()->data;
 }
 function __construct(Schema $schema, Account $account)
 {
     $this->accountId = $account->getId();
     $mySQLi = $schema->getMySQLi();
     $queryString = "INSERT " . DbConstants::TABLE_AUDIT . " (id_account) VALUES('" . $this->accountId . "')";
     $queryResult = $mySQLi->query($queryString);
     if (!$queryResult) {
         throw new Exception("Error creating audit object for account[" . $this->accountId . "] - " . $mySQLi->error . "\n<!--\n{$queryString}\n-->");
     }
     $this->id = $mySQLi->insert_id;
     // Get the timestamp of the created audit object.
     $queryString = "SELECT a.at FROM " . DbConstants::TABLE_AUDIT . " a WHERE a.id = {$this->id}";
     $queryResult = $mySQLi->query($queryString);
     if (!$queryResult) {
         throw new Exception("Error fetching audit[" . $this->accountId . "] - " . $mySQLi->error . "\n<!--\n{$queryString}\n-->");
     }
     $audit = $queryResult->fetch_assoc();
     $this->at = $audit['at'];
     $queryResult->close();
 }
Exemple #5
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);
 }
 /**
  * sets account_id
  *
  * @param Account|int|null $account
  *
  * @return $this
  */
 public function setAccountId($account)
 {
     $this->account_id = $account instanceof Account ? $account->getId() : $account;
     return $this;
 }
<?php

require "account.php";
if (!empty($_POST['id']) && !empty($_POST['value'])) {
    if (is_numeric($_POST['id']) && is_numeric($_POST['value'])) {
        $acc = new Account($_POST['id']);
        $acc->setTotal($_POST['value']);
        echo "Values updated: \n";
        echo "ID: " . $acc->getId() . "\n";
        echo "Name: " . $acc->getAccName() . "\n";
        echo "Value: " . $acc->getTotal() . "\n";
        echo "Last Update: " . $acc->getLastUpdate() . "\n";
    }
}
 /**
  * Создать массив свойств балансовой операции
  */
 public function _makeBlanceOpeationArray(User $user, Account $account, $balance = 0)
 {
     return array('user_id' => $user->getId(), 'account_id' => $account->getId(), 'category_id' => null, 'amount' => $balance, 'date' => '0000-00-00', 'type' => Operation::TYPE_BALANCE, 'comment' => 'Начальный остаток', 'accepted' => 1);
 }
Exemple #9
0
        $parsedBody = $request->getParsedBody();
        if ($parsedBody == null) {
            return err_general_error($response, "Provide a body to create a new account");
        }
        $account = new Account();
        $account->fromArray($parsedBody);
        $account->setSalt(openssl_random_pseudo_bytes(32));
        #$account->salt = "123";
        $account->setPassword(hash('sha512', $account->getPassword() . $account->getSalt()));
        if ($account->validate()) {
            if ($account->save()) {
                session_start();
                #session_unset();
                #session_regenerate_id(true);
                $_SESSION['Username'] = $account->getUsername();
                $_SESSION['Id'] = $account->getId();
                $_SESSION['loggedin'] = true;
                /* Response with resulting account */
                $response->getBody()->write($account->toJSON());
                return $response;
            }
        } else {
            return err_general_error($response, "Validation failed");
        }
        /* Response with resulting account */
        $response->getBody()->write($account->toJSON());
        return $response;
    });
})->add('HeaderMiddleware');
// Define the private group */
$app->group('/public', function () use($app) {
Exemple #10
0
 public function testAccountHasAnId()
 {
     $account = new Account($this->testAccountId);
     $this->assertGreaterThan(0, $account->getId());
 }
Exemple #11
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Account $obj A Account object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         AccountPeer::$instances[$key] = $obj;
     }
 }
Exemple #12
0
 /**
  * Returns an associative array of defined properties.
  *
  * If a property has no value specified, its default value is returned.
  *
  * @param Account $account
  * @param Domain $domain Optional. Default is NULL.
  * @param User $user Optional. Default is NULL.
  * @param array $filter Optional. An array with names of properties to
  *     retrieve values for. If NULL, all values will be returned.
  *     Default is NULL.
  * @param PropelPDO $con Optional. The database connection to use.
  *     Default is NULL.
  * @return array An associative array mapping property names to values as
  *     obtained by {@link PropertyValue::get()}.
  */
 public static function getAll(Account $account, Domain $domain = null, User $user = null, array $filter = null, PropelPDO $con = null)
 {
     $accountId = $account->getId();
     $domainId = $domain === null ? null : $domain->getId();
     $userId = $user === null ? null : $user->getId();
     $query = self::createPropertyValueQuery($accountId, $domainId, $userId);
     if ($filter !== null) {
         $query->add(PropertyPeer::NAME, $filter, Criteria::IN);
     }
     $values = $query->find($con);
     $values->populateRelation('Property', null, $con);
     $accountValues = self::getDefaults($account, $con);
     $domainValues = array();
     $userValues = array();
     foreach ($values as $value) {
         $property = $value->getProperty($con);
         $name = $property->getName();
         if ($value->getUserId() === $userId) {
             $userValues[$name] = $value->get($con);
         } elseif ($value->getDomainId() === $domainId and $domainId !== null) {
             $domainValues[$name] = $value->get($con);
         } elseif ($property->getAccountId() === $accountId and $accountId !== null) {
             $accountValues[$name] = $value->get($con);
         }
     }
     $result = $userValues + $domainValues + $accountValues;
     ksort($result);
     return $result;
 }
Exemple #13
0
 ///// パスワードの確認
 $login = false;
 if ($autologin) {
     if ($password == $account->getCookieLock()) {
         $login = true;
     }
 } else {
     if (Utils::encrpytPassword($password, $account->getSalt()) == $account->getEncryptedPassword()) {
         $login = true;
     }
 }
 ///// パスワードの確認が完了し、 ログインができます。 
 if ($login) {
     // 認証済み?
     if (!$account->isValidated()) {
         header('Location: /account/verifyplease?accountid=' . $account->getId());
         die;
     }
     if ($rememberMe || $autologin) {
         setAutoLogin($account);
     }
     $data = $account->throwData();
     unset($data['salt']);
     unset($data['password']);
     unset($data['validate_code']);
     unset($data['validated']);
     $_SESSION[KEY_SESSION] = $data;
     // successfully login
     // logging login here
     $text1 = "pc";
     if (Utils::is_mobile()) {
Exemple #14
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();
}
Exemple #15
0
 /**
  * Filter the query by a related Account object
  *
  * @param   Account|PropelObjectCollection $account The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 PropertyQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByAccount($account, $comparison = null)
 {
     if ($account instanceof Account) {
         return $this->addUsingAlias(PropertyPeer::ACCOUNT_ID, $account->getId(), $comparison);
     } elseif ($account instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(PropertyPeer::ACCOUNT_ID, $account->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByAccount() only accepts arguments of type Account or PropelCollection');
     }
 }
Exemple #16
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;
 }
Exemple #17
0
 /**
  * Declares an association between this object and a Account object.
  *
  * @param             Account $v
  * @return Plugin The current object (for fluent API support)
  * @throws PropelException
  */
 public function setAccount(Account $v = null)
 {
     if ($v === null) {
         $this->setAccountId(NULL);
     } else {
         $this->setAccountId($v->getId());
     }
     $this->aAccount = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Account object, it will not be re-added.
     if ($v !== null) {
         $v->addPlugin($this);
     }
     return $this;
 }
Exemple #18
0
 public function addAccount(Account $account)
 {
     $this->accounts[$account->getId()] = $account;
 }
Exemple #19
0
 public static function forgetPassword()
 {
     $error_message = "";
     if (!empty($_POST)) {
         if (!empty($_POST["studentid"])) {
             $studentId = $_POST["studentid"];
             if (empty($studentId)) {
                 $error_message .= "<li>学籍番号を空白にしないでください。</li>";
             } else {
                 if (!preg_match("/^[0-9]{7}\$/", $studentId)) {
                     $error_message .= "<li>学籍番号は正しくありません。</li>";
                 } else {
                     if (!in_array($studentId, getAllowableStudentIdList())) {
                         $error_message .= "<li>この学籍番号は使えません。</li>";
                     }
                 }
             }
             // if success continue to process forgetpassowrd (Student Id)
             if (strlen($error_message) == 0) {
                 try {
                     $account = Account::query("SELECT * FROM account_list WHERE " . Account::KEY_STUDENTID . "='{$studentId}' LIMIT 1");
                     $validate_code = Utils::generateValidationCode();
                     $studentId = $account->getStudentId();
                     TempValidationCode::create($studentId, $validate_code);
                     self::sendForgetPasswordMail($account->getId(), $studentId, $validate_code);
                     $content = "forgetpassword_mailsent.php";
                 } catch (Exception $ex) {
                     $content = "forgetpassword_username.php";
                 }
             } else {
                 $content = "forgetpassword_studentid.php";
             }
             // end of process forgetpassword (Student Id)
         } else {
             if (!empty($_POST["username"])) {
                 $username = $_POST["username"];
                 $studentId = $_POST["username_studentid"];
                 if (empty($username)) {
                     $error_message .= "<li>ログイン名を空白にしないでください。</li>";
                 }
                 if (strlen($error_message) == 0) {
                     $account = new Account();
                     $account->initWithUsername($username);
                     if ($account->getUsername() != NULL) {
                         // success to process forgetpassword (Username)
                         $account->setStudentId($studentId);
                         $validate_code = Utils::generateValidationCode();
                         TempValidationCode::create($studentId, $validate_code);
                         self::sendForgetPasswordMail($account->getId(), $studentId, $validate_code);
                         $content = "forgetpassword_mailsent.php";
                         include VIEWS_PATH . "account/public.php";
                         return;
                     } else {
                         // failed to get username
                         $error_message .= "<li>正しいログイン名を入力してください。</li>";
                     }
                 }
                 $content = "forgetpassword_username.php";
                 // end to process forgetpassword (Username)
             } else {
                 $error_message .= "<li>学籍番号を空白にしないでください。</li>";
                 $content = "forgetpassword_studentid.php";
             }
         }
     } else {
         // get request
         $content = "forgetpassword_studentid.php";
     }
     include VIEWS_PATH . "account/public.php";
 }
Exemple #20
0
 /**
  * Exclude object from result
  *
  * @param   Account $account Object to remove from the list of results
  *
  * @return AccountQuery The current query, for fluid interface
  */
 public function prune($account = null)
 {
     if ($account) {
         $this->addUsingAlias(AccountPeer::ID, $account->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }