Пример #1
0
 protected function _gridRead($params)
 {
     $action = 1 == count($this->_iaCore->requestPath) ? $this->_iaCore->requestPath[0] : null;
     switch ($action) {
         case 'items':
             $output = array('data' => null);
             if ($items = $this->_iaCore->factory('item')->getItems(true)) {
                 foreach ($items as $key => $item) {
                     $output['data'][] = array('title' => iaLanguage::get($item), 'value' => $item);
                 }
             }
             break;
         case 'plans':
             $output = array('data' => null);
             $stmt = '';
             if (!isset($params['itemname']) || isset($params['itemname']) && iaUsers::getItemName() == $params['itemname']) {
                 $stmt = iaDb::convertIds(iaUsers::getItemName(), 'item');
                 $output['data'][] = array('title' => iaLanguage::get('funds'), 'value' => 0);
             } elseif (!empty($params['itemname'])) {
                 $stmt = iaDb::convertIds($params['itemname'], 'item');
             }
             $this->_iaCore->factory('plan');
             if ($planIds = $this->_iaDb->onefield(iaDb::ID_COLUMN_SELECTION, $stmt, null, null, iaPlan::getTable())) {
                 foreach ($planIds as $planId) {
                     $output['data'][] = array('title' => iaLanguage::get('plan_title_' . $planId), 'value' => $planId);
                 }
             }
             break;
         case 'gateways':
             $output = array('data' => null);
             if ($items = $this->getHelper()->getPaymentGateways()) {
                 foreach ($items as $name => $title) {
                     $output['data'][] = array('value' => $name, 'title' => $title);
                 }
             }
             break;
         case 'members':
             $output = array('data' => null);
             if (!empty($params['query'])) {
                 $where[] = 'CONCAT(`username`, `fullname`) LIKE :username';
                 $values['username'] = '******' . iaSanitize::sql($params['query']) . '%';
             }
             $where || ($where[] = iaDb::EMPTY_CONDITION);
             $where = implode(' AND ', $where);
             $this->_iaDb->bind($where, $values);
             if ($members = $this->_iaDb->all(array('id', 'username', 'fullname'), $where, null, null, iaUsers::getTable())) {
                 foreach ($members as $member) {
                     $output['data'][] = array('title' => $member['username'], 'value' => $member['id']);
                 }
             }
             break;
         default:
             $output = parent::_gridRead($params);
     }
     return $output;
 }
Пример #2
0
 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
0
 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);
 }
Пример #4
0
 private function _getItemsStatuses()
 {
     $result = array();
     $iaItem = $this->_iaCore->factory('item');
     foreach ($this->_items as $itemName) {
         $statuses = array();
         $className = ucfirst(substr($itemName, 0, -1));
         $itemClassInstance = iaUsers::getItemName() == $itemName ? $this->_iaCore->factory('users') : $this->_iaCore->factoryPackage($className, $iaItem->getPackageByItem($itemName));
         if ($itemClassInstance && method_exists($itemClassInstance, 'getStatuses')) {
             $statuses = $itemClassInstance->getStatuses();
         }
         $result[$itemName] = implode(',', $statuses);
     }
     return $result;
 }
Пример #5
0
 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;
 }
Пример #6
0
 protected function _loadItemInstance($itemName)
 {
     $this->_itemName = $itemName;
     if (iaUsers::getItemName() == $this->_itemName) {
         $this->_itemInstance = $this->iaCore->factory('users');
         $this->_packageName = null;
         $this->_options = $this->_itemInstance->{self::ITEM_SEARCH_PROPERTY_OPTIONS};
         return true;
     }
     $itemData = $this->iaDb->row(array('package'), iaDb::convertIds($this->_itemName, 'item'), iaItem::getTable());
     if ($itemData && iaCore::CORE != $itemData['package']) {
         $instance = $this->iaCore->factoryPackage('item', $itemData['package'], iaCore::FRONT, $this->_itemName);
         if (isset($instance->{self::ITEM_SEARCH_PROPERTY_ENABLED}) && true === $instance->{self::ITEM_SEARCH_PROPERTY_ENABLED}) {
             $this->_itemInstance =& $instance;
             $this->_packageName = $itemData['package'];
             $this->_options = isset($instance->{self::ITEM_SEARCH_PROPERTY_OPTIONS}) ? $instance->{self::ITEM_SEARCH_PROPERTY_OPTIONS} : array();
             return true;
         }
     }
     return false;
 }
Пример #7
0
                     unset($pictures[$key]);
                 }
                 $newValue = is_array($value) ? serialize($pictures) : implode(',', $pictures);
             } else {
                 // single image
                 $newValue = '';
                 if ($pictures == $path) {
                     $key = true;
                 }
             }
             if ($key !== false) {
                 $iaDb->update(array($field => $newValue), iaDb::convertIds($itemId), null, $tableName);
                 $iaPicture = $iaCore->factory('picture');
                 $iaPicture->delete($path);
                 $output = array('error' => false, 'message' => iaLanguage::get('deleted'));
                 if (iaUsers::getItemName() == $item) {
                     // update current profile data
                     if ($itemId == iaUsers::getIdentity()->id) {
                         iaUsers::reloadIdentity();
                     }
                 }
             }
         }
     }
     break;
 case 'send_email':
     $output['message'] = array();
     $memberInfo = $iaCore->factory('users')->getInfo((int) $_POST['author_id']);
     if (empty($memberInfo) || $memberInfo['status'] != iaCore::STATUS_ACTIVE) {
         $output['message'][] = iaLanguage::get('member_doesnt_exist');
     }
Пример #8
0
                 $iaCore->startHook('phpUserProfileUpdate', array('userInfo' => iaUsers::getIdentity(true), 'data' => $item));
                 iaUsers::reloadIdentity();
                 $iaView->setMessages(iaLanguage::get('saved'), iaView::SUCCESS);
             } else {
                 $iaView->setMessages(iaLanguage::get('db_error'));
             }
         } 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);
 }
Пример #9
0
 public static function accountActions($params)
 {
     if (!iaUsers::hasIdentity() || empty($params['item']) || empty($params['itemtype']) || iaUsers::getItemName() == $params['itemtype'] && iaUsers::getIdentity()->id != $params['item']['id'] || iaUsers::getItemName() != $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 (iaUsers::getItemName() == $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="' . $classname . '" title="' . iaLanguage::get('edit') . '"><span class="fa fa-pencil"></span> ' . iaLanguage::get('edit') . '</a>';
     }
     return $output . $extraActions;
 }
Пример #10
0
 private function _logStatistics()
 {
     if (!$this->blockExists('common_statistics')) {
         return;
     }
     $iaDb =& $this->iaCore->iaDb;
     $commonStatistics = array('members' => array(array('title' => iaLanguage::get('members'), 'value' => (int) $iaDb->one_bind(iaDb::STMT_COUNT_ROWS, '`status` = :status', array('status' => iaCore::STATUS_ACTIVE), iaUsers::getTable()))));
     $this->iaCore->startHook('populateCommonStatisticsBlock', array('statistics' => &$commonStatistics));
     $iaDb->setTable('online');
     $commonStatistics['online'] = array();
     $commonStatistics['online'][] = array('title' => iaLanguage::get('active_users'), 'value' => (int) $iaDb->one(iaDb::STMT_COUNT_ROWS, "`status` = 'active' AND `is_bot` = 0"));
     if ($this->iaCore->get('members_enabled')) {
         $commonStatistics['online'][] = array('title' => iaLanguage::get('members'), 'value' => (int) $iaDb->one(iaDb::STMT_COUNT_ROWS, "`username` != '' AND `status` = 'active' AND `is_bot` = '0'"));
         $commonStatistics['online'][] = array('title' => iaLanguage::get('guests'), 'value' => $commonStatistics['online'][0]['value'] - $commonStatistics['online'][1]['value']);
     }
     $commonStatistics['online'][] = array('title' => iaLanguage::get('bots'), 'value' => (int) $iaDb->one(iaDb::STMT_COUNT_ROWS, "`status` = 'active' AND `is_bot` = 1"));
     $commonStatistics['online'][] = array('title' => iaLanguage::get('live_visits'), 'value' => (int) $iaDb->one(iaDb::STMT_COUNT_ROWS, '`is_bot` = 0 AND `date` + INTERVAL 1 DAY > NOW()'));
     $commonStatistics['online'][] = array('title' => iaLanguage::get('bots_visits'), 'value' => (int) $iaDb->one(iaDb::STMT_COUNT_ROWS, '`is_bot` = 1 AND `date` + INTERVAL 1 DAY > NOW()'));
     if ($this->iaCore->get('members_enabled', true)) {
         $outputHtml = '';
         if ($array = $iaDb->all("`username`, IF(`fullname` != '', `fullname`, `username`) `fullname`, COUNT(`id`) `count`", "`username` != '' AND `status` = 'active' GROUP BY `username`")) {
             foreach ($array as $item) {
                 $outputHtml .= $this->iaSmarty->ia_url(array('item' => iaUsers::getItemName(), 'type' => 'link', 'text' => $item['fullname'], 'data' => $item)) . ', ';
             }
             $outputHtml = substr($outputHtml, 0, -2);
             $commonStatistics['online'][count($commonStatistics['online']) - 1]['html'] = $outputHtml;
         }
     }
     $this->iaSmarty->assignGlobal('common_statistics', $commonStatistics);
     $iaDb->resetTable();
 }