本文整理汇总了PHP中iaUsers::getIdentity方法的典型用法代码示例。如果您正苦于以下问题:PHP iaUsers::getIdentity方法的具体用法?PHP iaUsers::getIdentity怎么用?PHP iaUsers::getIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iaUsers
的用法示例。
在下文中一共展示了iaUsers::getIdentity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public function create($planId)
{
$entry = array('plan_id' => (int) $planId, 'member_id' => iaUsers::hasIdentity() ? iaUsers::getIdentity()->id : 0, 'status' => self::PENDING);
if ($id = $this->iaDb->insert($entry, array('date_created' => iaDb::FUNCTION_NOW), self::getTable())) {
$entry['id'] = $id;
return $entry;
}
return false;
}
示例2: _deleteFile
private function _deleteFile($params)
{
$result = array('error' => true, 'message' => iaLanguage::get('invalid_parameters'));
$item = isset($params['item']) ? iaSanitize::sql($params['item']) : null;
$field = isset($params['field']) ? iaSanitize::sql($params['field']) : null;
$path = isset($params['path']) ? iaSanitize::sql($params['path']) : null;
$itemId = isset($params['itemid']) ? (int) $params['itemid'] : null;
if ($itemId && $item && $field && $path) {
$tableName = $this->_iaCore->factory('item')->getItemTable($item);
$itemValue = $this->_iaDb->one($field, iaDb::convertIds($itemId), $tableName);
$iaAcl = $this->_iaCore->factory('acl');
if ($iaAcl->isAdmin() && $itemValue) {
$pictures = $itemValue[1] == ':' ? unserialize($itemValue) : $itemValue;
$key = null;
if (is_array($pictures)) {
if ($primitive = !is_array($pictures[key($pictures)])) {
$pictures = array($pictures);
}
foreach ($pictures as $k => $v) {
if ($path == $v['path']) {
$key = $k;
break;
}
}
if (!is_null($key)) {
unset($pictures[$key]);
}
$newItemValue = $primitive ? '' : serialize($pictures);
} else {
// single image
$newItemValue = '';
if ($pictures == $path) {
$key = true;
}
}
if (!is_null($key)) {
if ($this->_iaCore->factory('picture')->delete($path)) {
if ($this->_iaDb->update(array($field => $newItemValue), iaDb::convertIds($itemId), null, $tableName)) {
if (iaUsers::getItemName() == $item) {
// update current profile data
if ($itemId == iaUsers::getIdentity()->id) {
iaUsers::reloadIdentity();
}
}
}
$result['error'] = false;
$result['message'] = iaLanguage::get('deleted');
} else {
$result['message'] = iaLanguage::get('error');
}
}
}
}
return $result;
}
示例3: getAddress
public function getAddress($transactionId)
{
$invoice = $this->getBy('transaction_id', $transactionId);
if ($invoice && $invoice['address1']) {
return $invoice;
}
// else return an address of the latest populated transaction
$iaTransaction = $this->iaCore->factory('transaction');
$sql = 'SELECT SQL_CALC_FOUND_ROWS i.`address1`, i.`address2`, i.`zip`, i.`country` ' . 'FROM `:prefix:table_transactions` t ' . 'LEFT JOIN `:prefix:table_invoices` i ON (i.`transaction_id` = t.`id`) ' . 'WHERE t.`member_id` = :member AND i.`address1` != "" ' . 'ORDER BY t.`date` DESC ' . 'LIMIT 1';
$sql = iaDb::printf($sql, array('prefix' => $this->iaDb->prefix, 'table_transactions' => $iaTransaction::getTable(), 'table_invoices' => self::getTable(), 'member' => iaUsers::getIdentity()->id));
$row = $this->iaDb->getRow($sql);
return $row ? $row : array('address1' => '', 'address2' => '', 'zip' => '', 'country' => '');
}
示例4: _debugInfo
protected function _debugInfo()
{
$iaCore = iaCore::instance();
$iaCore->factory('users');
self::dump(iaCore::ACCESS_FRONT == $iaCore->getAccessType() ? iaCore::FRONT : iaCore::ADMIN, 'Access Type');
self::dump($iaCore->iaView->getParams(), 'Page', 'info');
self::dump($iaCore->iaView->get('action'), 'Action', 'info');
self::dump($iaCore->iaView->get('filename'), 'Module');
self::dump($iaCore->iaView->language, 'Language');
self::dump(iaUsers::hasIdentity() ? iaUsers::getIdentity(true) : null, 'Identity');
self::dump();
// process blocks
$blocks = array();
if ($blocksData = $iaCore->iaView->blocks) {
foreach ($blocksData as $position => $blocksList) {
$blocks[$position] = array();
foreach ($blocksList as $block) {
$blocks[$position][] = $block['name'];
}
}
}
// process constants
$constantsList = get_defined_constants(true);
foreach ($constantsList['user'] as $key => $value) {
if (strpos($key, 'IA_') === 0 && 'IA_SALT' != $key) {
$constants[$key] = $value;
}
}
self::dump($iaCore->requestPath, 'URL Params');
self::dump($blocks, 'Blocks List');
self::dump($iaCore->packagesData, 'Installed Packages');
self::dump($iaCore->getConfig(), 'Configuration Params');
self::dump($constants, 'Constants List');
if (!empty(self::$_data['info'])) {
foreach (self::$_data['info'] as $key => $val) {
self::dump($val, !is_int($key) ? $key : '');
}
}
self::dump();
self::dump($_POST, '$_POST');
self::dump($_FILES, '$_FILES');
self::dump($_GET, '$_GET');
self::dump();
self::dump(PHP_VERSION, 'PHP version');
self::dump($_SERVER, '$_SERVER');
self::dump($_SESSION, '$_SESSION');
self::dump($_COOKIE, '$_COOKIE');
return '[' . $iaCore->iaView->name() . ']';
}
示例5: accountActions
public static function accountActions($params)
{
if (!iaUsers::hasIdentity() || empty($params['item']) || empty($params['itemtype']) || 'members' == $params['itemtype'] && iaUsers::getIdentity()->id != $params['item']['id'] || 'members' != $params['itemtype'] && isset($params['item']['member_id']) && iaUsers::getIdentity()->id != $params['item']['member_id']) {
return '';
}
$iaCore = iaCore::instance();
$iaItem = $iaCore->factory('item');
$params['img'] = $img = IA_CLEAR_URL . 'templates/' . $iaCore->iaView->theme . '/img/';
$classname = isset($params['classname']) ? $params['classname'] : '';
$upgradeUrl = '';
$editUrl = '';
$extraActions = '';
$output = '';
if ('members' == $params['itemtype']) {
$editUrl = IA_URL . 'profile/';
} else {
$item = $iaItem->getPackageByItem($params['itemtype']);
if (empty($item)) {
return '';
}
$iaPackage = $iaCore->factoryPackage('item', $item, iaCore::FRONT, $params['itemtype']);
if (empty($iaPackage)) {
return '';
}
if (method_exists($iaPackage, __FUNCTION__)) {
list($editUrl, $upgradeUrl) = $iaPackage->{__FUNCTION__}($params);
}
if (method_exists($iaPackage, 'extraActions')) {
$extraActions = $iaPackage->extraActions($params['item']);
}
}
$iaCore->startHook('phpSmartyAccountActionsBeforeShow', array('params' => &$params, 'type' => $params['itemtype'], 'upgrade_url' => &$upgradeUrl, 'edit_url' => &$editUrl, 'output' => &$output));
if ($editUrl) {
$output .= '<a rel="nofollow" href="' . $editUrl . '" class="btn btn-small ' . $classname . '" title="' . iaLanguage::get('edit') . '"><i class="icon-pencil"></i></a>';
}
return $output . $extraActions;
}
示例6: checkAccess
/**
* Checks access for user and groups
* @param string $params
* @param int $userId
* @param int $groupId
* @param bool $objectId
* @param bool $custom
* @return bool
*/
public function checkAccess($params = '', $objectId = null, $userId = 0, $groupId = 0, $custom = false)
{
$array = explode(self::SEPARATOR, $params);
$object = $array[0];
$action = iaCore::ACTION_READ;
if (isset($array[1])) {
$action = $array[1];
}
if (false === $custom) {
$this->iaCore->factory('users');
$user = iaUsers::hasIdentity() ? iaUsers::getIdentity()->id : 0;
$group = iaUsers::hasIdentity() ? iaUsers::getIdentity()->usergroup_id : 0;
$perms = $this->_permissions;
} else {
$user = isset($custom['user']) ? $custom['user'] : 0;
$group = isset($custom['group']) ? $custom['group'] : 0;
if (isset($custom['perms'])) {
$perms = $custom['perms'];
} elseif ($custom) {
$perms = array();
} else {
$perms = $this->getPermissions($user, $group);
}
}
// 1. Administrators
if (iaUsers::MEMBERSHIP_ADMINISTRATOR == $group) {
$this->_lastStep = 1;
return true;
}
// 2. Owner (user)
if ($userId != 0 && $userId == $user) {
$this->_lastStep = 2;
return true;
}
// 3. Owner (user)
if ($groupId != 0 && $groupId == $group) {
$this->_lastStep = 3;
return true;
}
if ($objectId) {
$name = $this->encodeAction($object, $action, $objectId);
if (isset($perms[$name])) {
$perms = $perms[$name];
ksort($perms);
// 4. Object privileges check (user = 0)
// 5. Object privileges check (group = 1)
// 6. Object privileges check (plan = 2)
foreach ($perms as $type => $values) {
$this->_lastStep = 4 + $type;
/* if ($type == 2)
{
if ($values['type_id'] == $this->_planId)
{
return (bool)$values['access'];
}
}
else
{*/
return (bool) $values['access'];
// }
}
}
}
// 7. All privileges check (user = 0)
// 8. All privileges check (group = 1)
// 9. All privileges check (plan = 2)
$name = $object . self::DELIMITER . $action . self::DELIMITER . '0';
if (isset($perms[$name])) {
$perms = $perms[$name];
ksort($perms);
foreach ($perms as $type => $values) {
$this->_lastStep = 7 + $type;
/* if ($type == 2)
{
if ($values['type_id'] == $this->_planId)
{
return (bool)$values['access'];
}
}
else
{*/
return (bool) $values['access'];
// }
}
}
// 10. Default object value
$key = $object . ($objectId ? '-' . $objectId : '') . self::DELIMITER . $action;
if (isset($this->_objects[$key])) {
$this->_lastStep = 10;
return (bool) $this->_objects[$key];
}
//.........这里部分代码省略.........
示例7: _sendEmailNotification
protected function _sendEmailNotification(array $transaction)
{
// first, do check if gateway has its own email submission
if ($result = $this->_doGatewayCallback($transaction['gateway'], $transaction)) {
return $result;
}
$result1 = true;
$notification = 'transaction_paid';
if ($this->iaCore->get($notification)) {
$iaUsers = $this->iaCore->factory('users');
$member = $iaUsers->getById($transaction['member_id']);
if (!$member) {
return false;
}
$iaMailer = $this->iaCore->factory('mailer');
$iaMailer->loadTemplate('transaction_paid');
$iaMailer->addAddress($member['email']);
$iaMailer->setReplacements($transaction);
$iaMailer->setReplacements(array('email' => $member['username'], 'username' => $member['username'], 'fullname' => $member['fullname']));
$result1 = $iaMailer->send();
}
// notify admin
$result2 = true;
$notification .= '_admin';
if ($this->iaCore->get($notification)) {
$iaMailer->loadTemplate($notification);
$iaMailer->addAddress($this->iaCore->get('site_email'));
$iaMailer->setReplacements(array('username' => iaUsers::getIdentity()->username, 'amount' => $transaction['amount'], 'operation' => $transaction['operation']));
$result2 = $iaMailer->send();
}
return $result1 && $result2;
}
示例8: extractFunds
/**
* Write funds off from member balance.
*
* @param array $transactionData data about transaction
*
* @return bool true on success
*/
public function extractFunds(array $transactionData)
{
if (!iaUsers::hasIdentity()) {
return false;
}
$iaUsers = $this->iaCore->factory('users');
$iaTransaction = $this->iaCore->factory('transaction');
$userInfo = $iaUsers->getInfo(iaUsers::getIdentity()->id);
$remainingBalance = $userInfo['funds'] - $transactionData['amount'];
if ($remainingBalance >= 0) {
$result = (bool) $iaUsers->update(array('funds' => $remainingBalance), iaDb::convertIds(iaUsers::getIdentity()->id));
if ($result) {
iaUsers::reloadIdentity();
$updatedValues = array('status' => iaTransaction::PASSED, 'gateway' => iaTransaction::TRANSACTION_MEMBER_BALANCE, 'reference_id' => date('YmdHis'), 'member_id' => iaUsers::getIdentity()->id);
$iaTransaction->update($updatedValues, $transactionData['id']);
}
return $result;
}
return false;
}
示例9: array
if ($iaUsers->hasIdentity()) {
$iaDb->delete('`id` = :item_id AND `member_id` = :user AND `item` = :item', $iaItem->getFavoritesTable(), array('item_id' => $itemId, 'user' => iaUsers::getIdentity()->id, 'item' => $itemName));
} else {
unset($_SESSION[iaUsers::SESSION_FAVORITES_KEY][$itemName]['items'][$itemId]);
}
$output['error'] = false;
$output['message'] = iaLanguage::get('favorites_action_deleted');
}
}
$iaView->assign($output);
}
if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
$itemInfo = $fields = array();
$iaField = $iaCore->factory('field');
if ($iaUsers->hasIdentity()) {
if ($favorites = $iaItem->getFavoritesByMemberId(iaUsers::getIdentity()->id)) {
foreach ($favorites as $itemName => $ids) {
$fields = array('id');
$class = iaCore::CORE != $itemsList[$itemName] ? $iaCore->factoryPackage('item', $itemsList[$itemName], iaCore::FRONT, $itemName) : $iaCore->factory('members' == $itemName ? 'users' : $itemName);
if ($class && method_exists($class, iaUsers::METHOD_NAME_GET_FAVORITES)) {
$favorites[$itemName]['items'] = $class->{iaUsers::METHOD_NAME_GET_FAVORITES}($ids);
} else {
if ($itemName == $iaUsers->getItemName()) {
$fields[] = 'username';
$fields[] = 'fullname';
$fields[] = 'avatar';
$fields[] = 'id` `member_id';
} else {
$fields[] = 'member_id';
}
$stmt = iaDb::printf("`id` IN (:ids) && `status` = ':status'", array('ids' => implode(',', $ids), 'status' => iaCore::STATUS_ACTIVE));
示例10: _setActions
private function _setActions()
{
$result = array();
if (self::REQUEST_HTML != $this->getRequestType()) {
return $result;
}
$iaCore =& $this->iaCore;
if (false !== strpos($iaCore->iaView->name(), 'view')) {
$iaItem = $iaCore->factory('item');
$iaCore->startHook('smartyItemTools');
$iaItem->setItemTools(array('id' => 'action-print', 'title' => iaLanguage::get('print_preview'), 'attributes' => array('href' => '#', 'class' => 'js-print-page')));
$itemData = $iaCore->iaView->iaSmarty->getTemplateVars('item');
if (iaUsers::hasIdentity() && $itemData) {
if (iaUsers::getItemName() != $itemData['item'] && isset($itemData['member_id']) && iaUsers::getIdentity()->id != $itemData['member_id'] || $itemData['item'] == iaUsers::getItemName() && iaUsers::getIdentity()->id != $itemData['id']) {
$isAlreadyFavorited = isset($itemData['favorite']) && $itemData['favorite'] == 1;
$iaItem->setItemTools(array('id' => 'action-favorites', 'title' => iaLanguage::get($isAlreadyFavorited ? 'favorites_action_delete' : 'favorites_action_add'), 'attributes' => array('href' => '#', 'class' => 'js-favorites', 'data-id' => $itemData['id'], 'data-item' => $itemData['item'], 'data-action' => $isAlreadyFavorited ? iaCore::ACTION_DELETE : iaCore::ACTION_ADD)));
}
}
$result = $iaItem->setItemTools();
}
return $result;
}
示例11: _resetPage
private function _resetPage(&$iaView)
{
if (isset($_POST['reset'])) {
if ($options = iaUtil::checkPostParam('options', array())) {
if (in_array(iaUsers::getItemName(), $options)) {
$iaUsers = $this->_iaCore->factory('users');
$currentMember = $this->_iaDb->row(iaDb::ALL_COLUMNS_SELECTION, iaDb::convertIds(iaUsers::getIdentity()->id), iaUsers::getTable());
$this->getHelper()->truncate(iaUsers::getTable());
$this->_iaDb->insert($currentMember, null, iaUsers::getTable());
$options = array_diff($options, array($iaUsers->getItemName()));
}
foreach ($options as $option) {
$this->_iaCore->startHook('phpDbControlBeforeReset', array('option' => $option));
}
$this->addMessage('reset_success');
} else {
$this->_error = true;
$this->addMessage('reset_choose_table');
}
} else {
$iaView->setMessages(iaLanguage::get('reset_backup_alert'), iaView::ALERT);
}
$resetOptions = array('members' => iaLanguage::get('reset') . ' ' . iaLanguage::get('members'));
$this->_iaCore->startHook('phpAdminDatabaseBeforeAll', array('reset_options' => &$resetOptions));
$iaView->assign('options', $resetOptions);
}
示例12: updateItemsFavorites
/**
* Return list of items with favorites field
*
* @param array $listings listings to be processed
* @param $itemName item name
*
* @return mixed
*/
public function updateItemsFavorites($listings, $itemName)
{
if (empty($itemName)) {
return $listings;
}
if (!iaUsers::hasIdentity()) {
if (isset($_SESSION[iaUsers::SESSION_FAVORITES_KEY][$itemName]['items'])) {
$itemsFavorites = array_keys($_SESSION[iaUsers::SESSION_FAVORITES_KEY][$itemName]['items']);
}
} else {
$itemsList = array();
foreach ($listings as $entry) {
if ('members' == $itemName && $entry['id'] != iaUsers::getIdentity()->id || isset($entry['member_id']) && $entry['member_id'] != iaUsers::getIdentity()->id) {
$itemsList[] = $entry['id'];
}
}
if (empty($itemsList)) {
return $listings;
}
// get favorites
$itemsFavorites = $this->iaDb->onefield('`id`', "`id` IN ('" . implode("','", $itemsList) . "') && `item` = '{$itemName}' && `member_id` = " . iaUsers::getIdentity()->id, 0, null, $this->getFavoritesTable());
}
if (empty($itemsFavorites)) {
return $listings;
}
// process listing and set flag is in favorites array
foreach ($listings as &$listing) {
$listing['favorite'] = (int) in_array($listing['id'], $itemsFavorites);
}
return $listings;
}
示例13: _renderResults
protected function _renderResults($rows)
{
$iaView =& $this->iaView;
$iaSmarty =& $iaView->iaSmarty;
if (!$this->_smartyVarsAssigned) {
$core = array('config' => $this->iaCore->getConfig(), 'customConfig' => $this->iaCore->getCustomConfig(), 'language' => $this->iaCore->languages[$iaView->language], 'languages' => $this->iaCore->languages, 'packages' => $this->iaCore->packagesData, 'page' => array('info' => $iaView->getParams(), 'name' => $iaView->name(), 'nonProtocolUrl' => $iaView->assetsUrl, 'title' => $iaView->get('caption', $iaView->get('title'))));
$iaSmarty->assign('core', $core);
$iaSmarty->assign('member', iaUsers::getIdentity(true));
$this->_smartyVarsAssigned = true;
}
if (iaUsers::getItemName() == $this->_itemName) {
$array = array();
$fields = $this->iaCore->factory('field')->filter($array, $this->_itemName, array('page' => 'members'));
$result = $this->_render('search.members' . iaView::TEMPLATE_FILENAME_EXT, array('fields' => $fields, 'listings' => $rows));
} else {
$result = $this->_render(sprintf('extra:%s/search.%s', $this->_packageName, $this->_itemName), array('listings' => $rows));
}
return $result;
}
示例14: list
} else {
$iaView->setMessages($messages);
}
}
if (isset($_POST['plan_id']) && $_POST['plan_id'] != iaUsers::getIdentity()->sponsored_plan_id) {
if ($plan = $iaPlan->getById((int) $_POST['plan_id'])) {
$url = $iaPlan->prePayment($itemName, iaUsers::getIdentity(true), $plan['id'], IA_SELF);
iaUtil::redirect(iaLanguage::get('thanks'), iaLanguage::get('plan_added'), $url);
} else {
$iaPlan->setUnpaid(iaUsers::getItemName(), iaUsers::getIdentity()->id);
}
}
}
$iaCore->startHook('phpFrontAfterProfileProcessData');
$item = iaUsers::getIdentity(true);
// get fieldgroups
list($tabs, $fieldgroups) = $iaField->generateTabs($iaField->filterByGroup($item, $itemName));
// compose tabs
$sections = array_merge(array('common' => $fieldgroups), $tabs);
$extraTabs = array();
$iaCore->startHook('phpFrontEditProfileExtraTabs', array('tabs' => &$extraTabs, 'item' => &$item));
$sections = array_merge($sections, $extraTabs);
if (iaUsers::MEMBERSHIP_ADMINISTRATOR != iaUsers::getIdentity()->usergroup_id) {
$iaView->assign('assignableGroups', $assignableGroups);
}
$iaView->assign('sections', $sections);
$iaView->assign('plans_count', (int) $iaDb->one(iaDb::STMT_COUNT_ROWS, null, iaPlan::getTable()));
$iaView->assign('item', $item);
$iaView->assign('plans', $plans);
$iaDb->resetTable();
}
示例15: array
$output = array();
$iaCore->startHook('phpActionsJsonHandle', array('action' => $_POST['action'], 'output' => &$output));
}
$iaView->assign($output);
}
if (isset($_GET) && isset($_GET['action'])) {
switch ($_GET['action']) {
case 'ckeditor_upload':
$iaView->disableLayout();
$iaView->set('nodebug', 1);
$err = 0;
if (isset($_GET['Type']) && 'Image' == $_GET['Type'] && isset($_FILES['upload'])) {
$oFile = $_FILES['upload'];
$sErrorNumber = '0';
$imgTypes = array('image/gif' => 'gif', 'image/jpeg' => 'jpg', 'image/pjpeg' => 'jpg', 'image/png' => 'png');
$_user = iaUsers::hasIdentity() ? iaUsers::getIdentity()->username : false;
$sFileUrl = 'uploads/' . iaUtil::getAccountDir($_user);
$ext = array_key_exists($oFile['type'], $imgTypes) ? $imgTypes[$oFile['type']] : false;
if (!$ext) {
$err = '202 error';
}
$tok = iaUtil::generateToken();
$fname = $tok . '.' . $ext;
if (!$err) {
move_uploaded_file($oFile['tmp_name'], IA_HOME . $sFileUrl . $fname);
chmod(IA_HOME . $sFileUrl . $fname, 0777);
}
// fix windows URLs
$fileUrl = $sFileUrl . $fname;
$fileUrl = str_replace('\\', '/', $fileUrl);
$callback = (int) $_GET['CKEditorFuncNum'];