convertIds() public static méthode

public static convertIds ( $ids, $columnName = 'id', $equal = true )
Exemple #1
0
 private function _getExtraType($extraName)
 {
     if (is_null(self::$_extraTypes)) {
         $iaCore = iaCore::instance();
         $iaCore->factory('item');
         self::$_extraTypes = $iaCore->iaDb->keyvalue(array('name', 'type'), iaDb::convertIds(iaCore::STATUS_ACTIVE, 'status'), iaItem::getExtrasTable());
     }
     return isset(self::$_extraTypes[$extraName]) ? self::$_extraTypes[$extraName] : null;
 }
 public function deleteCorrespondingInvoice($transactionId)
 {
     if ($invoice = $this->getBy('transaction_id', $transactionId)) {
         $result1 = (bool) $this->iaDb->delete(iaDb::convertIds($invoice['id']), self::getTable());
         $result2 = (bool) $this->iaDb->delete(iaDb::convertIds($invoice['id'], 'invoice_id'), self::$_tableItems);
         return $result1 && $result2;
     }
     return true;
 }
Exemple #3
0
 protected function _entryDelete($entryId)
 {
     $row = $this->_iaDb->row(array('name', 'item'), iaDb::convertIds($entryId));
     $result = parent::_entryDelete($entryId);
     if ($result && $row) {
         $stmt = iaDb::printf("`key` = 'fieldgroup_:name' OR `key` = 'fieldgroup_description_:item_:name'", $row);
         $this->_iaDb->delete($stmt, iaLanguage::getTable());
     }
     return $result;
 }
Exemple #4
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;
 }
 protected function _gridUpdate($params)
 {
     $template = $params['id'];
     $this->_iaCore->set($template . '_subject', $params['subject'], true);
     $this->_iaCore->set($template . '_body', $params['body'], true);
     $this->_iaCore->set($template, (int) $params['enable_template'], true);
     $signature = $params['enable_signature'] ? '1' : '';
     $this->_iaDb->update(array('show' => $signature), iaDb::convertIds($template, 'name'));
     $result = 0 == $this->_iaDb->getErrorNumber();
     return array('result' => $result);
 }
 private function _approveClaim(array $data)
 {
     $claim = $this->getById($data['id']);
     $iaItem = $this->_iaCore->factory('item');
     $result = (bool) $this->_iaDb->update(array('member_id' => $claim['member_id']), iaDb::convertIds($claim['item_id']), null, $iaItem->getItemTable($claim['item']));
     $this->_iaDb->update(array('status' => 'approved'), iaDb::convertIds($claim['id']));
     if ($result && $this->_iaCore->get('claim_approved')) {
         $iaMailer = $this->_iaCore->factory('mailer');
         $iaMailer->loadTemplate('claim_approved');
         $iaMailer->addAddress($claim['email'], $claim['name']);
         $iaMailer->setReplacements(array('listing_title' => $claim['item_title'], 'listing_url' => $claim['item_url']));
         $iaMailer->send();
     }
 }
 public function updateTrackingRecords($trackingSalt, $memberId, $productId, $visitorReferrer)
 {
     // set cookie for 10 years
     setcookie('IA_AFF_TRACKING', $trackingSalt, time() + 315360000, '', $visitorReferrer, 0);
     $tracking = array('salt' => $trackingSalt, 'member_id' => $memberId, 'product_id' => $productId, 'referrer' => $visitorReferrer);
     // log visitor
     $this->iaDb->setTable(self::getTable());
     if ($this->iaDb->exists('`salt` = :salt', array('salt' => $trackingSalt))) {
         $this->iaDb->update($tracking, iaDb::convertIds($trackingSalt, 'salt'), array('datetime' => iaDb::FUNCTION_NOW));
     } else {
         $this->iaDb->insert($tracking, array('datetime' => iaDb::FUNCTION_NOW));
     }
     $this->iaDb->resetTable();
     return true;
 }
Exemple #8
0
 protected function _gridRead($params)
 {
     if (isset($_POST['action'])) {
         $output = array();
         switch ($_POST['action']) {
             case 'get':
                 $output['code'] = $this->_iaDb->one_bind('`code`', iaDb::convertIds((int) $_POST['id']));
                 break;
             case 'set':
                 $output['result'] = (bool) $this->_iaDb->update(array('code' => $_POST['code']), iaDb::convertIds($_POST['id']));
                 $output['message'] = iaLanguage::get($output['result'] ? 'saved' : 'db_error');
         }
         return $output;
     }
     return parent::_gridRead($params);
 }
Exemple #9
0
 protected function _gridRead($params)
 {
     $output = array();
     switch ($this->_iaCore->requestPath[0]) {
         case 'get':
             $output['code'] = $this->_iaDb->one_bind('`code`', iaDb::convertIds((int) $_GET['id']));
             break;
         case 'set':
             $this->_iaDb->update(array('code' => $_POST['code']), iaDb::convertIds($_POST['id']));
             $output['result'] = 0 == $this->_iaDb->getErrorNumber();
             $output['message'] = iaLanguage::get($output['result'] ? 'saved' : 'db_error');
             break;
         default:
             $output = parent::_gridRead($params);
     }
     return $output;
 }
Exemple #10
0
 /**
  * Execute cron job with the given id (optional)
  *
  * @param int $jobId job id
  *
  * @return array
  */
 public function run($jobId = null)
 {
     $this->iaDb->setTable(self::getTable());
     $stmt = is_null($jobId) ? '`active` = 1 AND `date_next_launch` <= UNIX_TIMESTAMP() ORDER BY `date_next_launch`' : iaDb::convertIds($jobId);
     $job = $this->iaDb->row(iaDb::ALL_COLUMNS_SELECTION, $stmt);
     if (!$job) {
         return;
     }
     $data = $this->_parse($job['data']);
     if (is_file(IA_HOME . $data[self::C_CMD])) {
         if ($this->iaDb->update(array('date_next_launch' => $data['lastScheduled']), iaDb::convertIds($job['id']), array('date_prev_launch' => 'UNIX_TIMESTAMP()'))) {
             $this->_launchFile($data[self::C_CMD]);
         }
     } else {
         $this->iaDb->update(array('active' => false), iaDb::convertIds($job['id']));
     }
     $this->iaDb->resetTable();
 }
 public function delete($id)
 {
     $result = false;
     $this->iaDb->setTable(self::getTable());
     // if item exists, then remove it
     if ($row = $this->iaDb->row_bind(array('title', 'image'), '`id` = :id', array('id' => $id))) {
         $result = (bool) $this->iaDb->delete(iaDb::convertIds($id), self::getTable());
         if ($row['image'] && $result) {
             $iaPicture = $this->iaCore->factory('picture');
             $iaPicture->delete($row['image']);
         }
         if ($result) {
             $this->iaCore->factory('log')->write(iaLog::ACTION_DELETE, array('module' => 'portfolio', 'item' => 'portfolio', 'name' => $row['title'], 'id' => (int) $id));
         }
     }
     $this->iaDb->resetTable();
     return $result;
 }
Exemple #12
0
 private function _getSettings()
 {
     $settings = array('target' => 'all', 'id' => 0, 'action' => 2, 'user' => 0, 'group' => 0, 'item' => null);
     if (isset($_GET['user'])) {
         $settings['action'] = 0;
         $settings['target'] = iaAcl::USER;
         $settings['user'] = $settings['id'] = isset($_GET[$settings['target']]) ? (int) $_GET[$settings['target']] : 0;
         $settings['item'] = $this->_iaDb->row(iaDb::ALL_COLUMNS_SELECTION, iaDb::convertIds($settings['id']), iaUsers::getTable());
         if (!empty($settings['item']['usergroup_id'])) {
             $settings['group'] = (int) $settings['item']['usergroup_id'];
         }
     } elseif (isset($_GET['group'])) {
         $settings['action'] = 1;
         $settings['target'] = iaAcl::GROUP;
         $settings['group'] = $settings['id'] = isset($_GET[$settings['target']]) ? (int) $_GET[$settings['target']] : 0;
         $settings['item'] = $this->_iaDb->row(iaDb::ALL_COLUMNS_SELECTION, iaDb::convertIds($settings['id']), iaUsers::getUsergroupsTable());
     }
     return $settings;
 }
Exemple #13
0
 public function delete($id)
 {
     $result = false;
     $this->iaDb->setTable(self::getTable());
     // if item exists, then remove it
     if ($row = $this->iaDb->row_bind(array('title', 'image'), '`id` = :id', array('id' => $id))) {
         $result[] = (bool) $this->iaDb->delete(iaDb::convertIds($id), self::getTable());
         if ($row['image'] && $result) {
             $iaPicture = $this->iaCore->factory('picture');
             $iaPicture->delete($row['image']);
         }
         $result[] = (bool) $this->iaDb->delete(iaDb::convertIds($id, 'blog_id'), $this->_tableBlogEntriesTags);
         $sql = 'DELETE ' . 'FROM `:prefix:table_blog_tags` ' . 'WHERE `id` NOT IN (' . 'SELECT DISTINCT `tag_id` ' . 'FROM `:prefix:table_blog_entries_tags`)';
         $sql = iaDb::printf($sql, array('prefix' => $this->_iaDb->prefix, 'table_blog_entries_tags' => $this->_tableBlogEntriesTags, 'table_blog_tags' => $this->_tableBlogTags));
         $result[] = (bool) $this->iaDb->query($sql);
         if ($result) {
             $this->iaCore->factory('log')->write(iaLog::ACTION_DELETE, array('module' => 'blog', 'item' => 'blog', 'name' => $row['title'], 'id' => (int) $id));
         }
     }
     $this->iaDb->resetTable();
     return $result;
 }
 public function getBy($key, $id)
 {
     return $this->iaDb->row(iaDb::ALL_COLUMNS_SELECTION, iaDb::convertIds($id, $key), self::getTable());
 }
Exemple #15
0
             } else {
                 $messages[] = iaLanguage::get('db_error');
             }
         }
         $iaView->setMessages($messages);
     }
     $tags = iaCore::ACTION_ADD == $pageAction ? '' : $iaBlog->getTagsString($id);
     $iaView->assign('item', $entry);
     $iaView->assign('tags', $tags);
     break;
 case iaCore::ACTION_DELETE:
     if (1 != count($iaCore->requestPath)) {
         return iaView::errorPage(iaView::ERROR_NOT_FOUND);
     }
     $id = (int) $iaCore->requestPath[0];
     $entry = $iaDb->row(iaDb::ALL_COLUMNS_SELECTION, iaDb::convertIds($id));
     if (!$entry) {
         return iaView::errorPage(iaView::ERROR_NOT_FOUND);
     }
     $result = $iaBlog->delete($id);
     $iaView->setMessages(iaLanguage::get($result ? 'deleted' : 'db_error'), $result ? iaView::SUCCESS : iaView::ERROR);
     iaUtil::go_to($baseUrl);
     break;
 default:
     $iaView->display('index');
     $pageActions = array();
     if (isset($iaCore->requestPath[0])) {
         $id = (int) $iaCore->requestPath[0];
         if (!$id) {
             return iaView::errorPage(iaView::ERROR_NOT_FOUND);
         }
Exemple #16
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Subrion. If not, see <http://www.gnu.org/licenses/>.
 *
 *
 * @link http://www.subrion.org/
 *
 ******************************************************************************/
if ($iaCore->get('cron')) {
    $iaCron = $iaCore->factory('cron');
    $iaDb->setTable(iaCron::getTable());
    if ($job = $iaDb->row(iaDb::ALL_COLUMNS_SELECTION, '`active` = 1 AND `nextrun` <= UNIX_TIMESTAMP() ORDER BY `nextrun`')) {
        $data = $iaCron->parseCron($job['data']);
        if (is_file(IA_HOME . $data[iaCron::C_CMD])) {
            if ($iaDb->update(array('nextrun' => $data['lastScheduled']), iaDb::convertIds($job['id']))) {
                ignore_user_abort(1);
                @set_time_limit(0);
                include IA_HOME . $data[iaCron::C_CMD];
            }
        } else {
            // disable cron job
            $iaDb->update(array('active' => false), iaDb::convertIds($job['id']));
        }
    }
    $iaDb->resetTable();
}
$iaView->set('nodebug', true);
header('Content-type: image/gif');
die(base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='));
Exemple #17
0
 protected function _entryUpdate(array $entryData, $entryId)
 {
     return $this->_iaDb->update($entryData, iaDb::convertIds($entryId), null, iaLanguage::getLanguagesTable());
 }
Exemple #18
0
 protected function _entryDelete($entryId)
 {
     $this->_iaCore->startHook('phpAdminBeforePlanDelete', array('entryId' => $entryId));
     $result = parent::_entryDelete($entryId);
     if ($result) {
         // here we should drop the "for_plan" column of fields
         // if there are no more plans exist
         if (0 === (int) $this->_iaDb->one(iaDb::STMT_COUNT_ROWS)) {
             $this->_iaDb->update(array('for_plan' => 0), iaDb::convertIds(1, 'for_plan'), null, iaField::getTable());
         }
         iaLanguage::delete(self::PATTERN_TITLE . $entryId);
         iaLanguage::delete(self::PATTERN_DESCRIPTION . $entryId);
     }
     return $result;
 }
Exemple #19
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);
 }
Exemple #20
0
 protected function _indexPage(&$iaView)
 {
     $iaView->display('index');
     $iaCore =& $this->_iaCore;
     $iaDb =& $this->_iaDb;
     if (isset($_GET['reset']) || isset($_GET['save'])) {
         $data = isset($_GET['list']) ? $_GET['list'] : '';
         if ($iaDb->update(array('admin_columns' => $data), iaDb::convertIds(iaUsers::getIdentity()->id), null, iaUsers::getTable())) {
             iaUsers::reloadIdentity();
         }
         $iaView->setMessages(iaLanguage::get('saved'), iaView::SUCCESS);
         iaUtil::go_to(IA_SELF);
     }
     $disabledWidgets = iaUsers::getIdentity()->admin_columns;
     $disabledWidgets = empty($disabledWidgets) ? array() : explode(',', trim($disabledWidgets, ','));
     $iaView->assign('disabled_widgets', $disabledWidgets);
     $customizationMode = isset($_GET['customize']) && empty($_GET['customize']);
     if ($customizationMode) {
         $iaView->setMessages(iaLanguage::get('customization_mode_alert'));
         $iaView->assign('customization_mode', true);
     }
     // populate statistics
     $iaItem = $iaCore->factory('item');
     $itemsList = $iaItem->getPackageItems();
     $validSizes = array('small', 'medium', 'package');
     $iaCore->startHook('adminDashboardStatistics', array('items' => &$itemsList));
     natcasesort($itemsList);
     $statistics = array();
     foreach ($validSizes as $size) {
         $statistics[$size] = array();
     }
     foreach ($itemsList as $itemName => $pluginType) {
         $itemName = substr($itemName, 0, -1);
         switch ($pluginType) {
             case 'core':
                 $classInstance = $iaCore->factory('member' == $itemName ? 'users' : $itemName);
                 break;
             case 'plugin':
                 $array = explode(':', $itemName);
                 $itemName = isset($array[1]) ? $array[1] : $itemName;
                 $classInstance = $iaCore->factoryPlugin($array[0], iaCore::ADMIN, isset($array[1]) ? $array[1] : null);
                 break;
             default:
                 $classInstance = $iaCore->factoryPackage($itemName, $pluginType, iaCore::ADMIN);
         }
         if (!$customizationMode && in_array($itemName, $disabledWidgets)) {
             continue;
         }
         if ($classInstance) {
             if (method_exists($classInstance, self::STATISTICS_GETTER_METHOD)) {
                 if ($classInstance->dashboardStatistics) {
                     $data = $classInstance->{self::STATISTICS_GETTER_METHOD}();
                     isset($data['icon']) || ($data['icon'] = $itemName);
                     isset($data['caption']) || ($data['caption'] = $itemName);
                     $data['caption'] = iaLanguage::get($data['caption'], $data['caption']);
                     $widgetFormat = isset($data['_format']) && in_array($data['_format'], $validSizes) ? $data['_format'] : $validSizes[0];
                     $statistics[$widgetFormat][$itemName] = $data;
                 }
             }
         }
     }
     $iaView->assign('statistics', $statistics);
     //
     if (($customizationMode || !in_array('changelog', $disabledWidgets)) && $iaCore->get('display_changelog') && is_file(IA_HOME . 'changelog.txt')) {
         $index = 0;
         $log = array();
         $titles = array();
         $lines = file(IA_HOME . 'changelog.txt');
         foreach ($lines as $line_num => $line) {
             $line = trim($line);
             if ($line) {
                 if ($line[0] == '>') {
                     $index++;
                     $log[$index] = array('title' => trim($line, '<> '), 'added' => '', 'modified' => '', 'bugfixes' => '', 'other' => '');
                     $titles[trim($line, '<> ')] = $index;
                 } elseif ($index > 0) {
                     switch ($line[0]) {
                         case '+':
                             $class = 'added';
                             break;
                         case '-':
                             $class = 'bugfixes';
                             break;
                         case '*':
                             $class = 'modified';
                             break;
                         default:
                             $class = 'other';
                     }
                     $issue = preg_replace('/#(\\d+)/', '<a href="http://dev.subrion.org/issues/$1" target="_blank">#$1</a>', ltrim($line, '+-* '));
                     $log[$index][$class] .= '<li>' . $issue . '</li>';
                 }
             }
         }
         unset($log[0]);
         ksort($titles);
         $titles = array_reverse($titles);
         $iaView->assign('changelog_titles', $titles);
         $iaView->assign('changelog', $log);
     }
     // twitter widget
     if ($customizationMode || !in_array('twitter', $disabledWidgets)) {
         $data = iaUtil::getPageContent('http://tools.intelliants.com/timeline/');
         $iaView->assign('timeline', iaUtil::jsonDecode($data));
     }
     if ($customizationMode || !in_array('recent-activity', $disabledWidgets)) {
         $data = $iaCore->factory('log')->get();
         $iaView->assign('activity_log', $data);
     }
     if ($customizationMode || !in_array('website-visits', $disabledWidgets)) {
         $data = $iaCore->factory('users')->getVisitorsInfo();
         $iaView->assign('online_members', $data);
     }
     if ($iaCore->get('check_for_updates')) {
         $this->_checkForUpdates();
     }
 }
Exemple #21
0
 private function _resendRegistrationEmail()
 {
     $output = array('message' => iaLanguage::get('invalid_params'), 'result' => false);
     if (isset($_POST['id']) && is_numeric($_POST['id'])) {
         $member = $this->_iaDb->row(iaDb::ALL_COLUMNS_SELECTION, iaDb::convertIds($_POST['id']));
         if ($member && iaUsers::STATUS_UNCONFIRMED == $member['status']) {
             $password = $this->getHelper()->createPassword();
             $passwordHash = $this->getHelper()->encodePassword($password);
             if ($this->_iaDb->update(array('password' => $passwordHash), iaDb::convertIds($member['id']))) {
                 $this->getHelper()->sendRegistrationEmail($member['id'], $password, $member);
                 $output['message'] = iaLanguage::get('registration_email_resent');
                 $output['result'] = true;
             }
         }
     }
     return $output;
 }
Exemple #22
0
 private function _save(&$iaView)
 {
     $iaAcl = $this->_iaCore->factory('acl');
     if (!$iaAcl->checkAccess($iaView->name() . iaAcl::SEPARATOR . iaCore::ACTION_EDIT)) {
         return iaView::accessDenied();
     }
     $where = "`type` != 'hidden' " . ($this->_type ? 'AND `custom` = 1' : '');
     $params = $this->_iaDb->keyvalue(array('name', 'type'), $where, iaCore::getConfigTable());
     // correct admin dashboard URL generation
     $adminPage = $this->_iaCore->get('admin_page');
     iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
     $messages = array();
     $error = false;
     if ($_POST['v'] && is_array($_POST['v'])) {
         $values = $_POST['v'];
         $this->_iaCore->startHook('phpConfigurationChange', array('configurationValues' => &$values));
         $this->_iaDb->setTable(iaCore::getConfigTable());
         foreach ($values as $key => $value) {
             $s = strpos($key, '_items_enabled');
             if ($s !== false) {
                 $p = $this->_iaCore->get($key, '', !is_null($this->_type));
                 $array = $p ? explode(',', $p) : array();
                 $data = array();
                 array_shift($value);
                 if ($diff = array_diff($value, $array)) {
                     foreach ($diff as $item) {
                         array_push($data, array('action' => '+', 'item' => $item));
                     }
                 }
                 if ($diff = array_diff($array, $value)) {
                     foreach ($diff as $item) {
                         array_push($data, array('action' => '-', 'item' => $item));
                     }
                 }
                 $extra = substr($key, 0, $s);
                 $this->_iaCore->startHook('phpPackageItemChangedForPlugin', array('data' => $data), $extra);
             }
             if (is_array($value)) {
                 $value = implode(',', $value);
             }
             if (!utf8_is_valid($value)) {
                 $value = utf8_bad_replace($value);
                 trigger_error('Bad UTF-8 detected (replacing with "?") in configuration', E_USER_NOTICE);
             }
             if (self::TYPE_IMAGE == $params[$key]) {
                 if (isset($_POST['delete'][$key])) {
                     $value = '';
                 } elseif (!empty($_FILES[$key]['name'])) {
                     if (!(bool) $_FILES[$key]['error']) {
                         if (@is_uploaded_file($_FILES[$key]['tmp_name'])) {
                             $ext = strtolower(utf8_substr($_FILES[$key]['name'], -3));
                             // if jpeg
                             if ($ext == 'peg') {
                                 $ext = 'jpg';
                             }
                             if (!array_key_exists(strtolower($_FILES[$key]['type']), $this->_imageTypes) || !in_array($ext, $this->_imageTypes, true) || !getimagesize($_FILES[$key]['tmp_name'])) {
                                 $error = true;
                                 $messages[] = iaLanguage::getf('file_type_error', array('extension' => implode(', ', array_unique($this->_imageTypes))));
                             } else {
                                 if ($this->_iaCore->get($key) && file_exists(IA_UPLOADS . $this->_iaCore->get($key))) {
                                     iaUtil::deleteFile(IA_UPLOADS . $this->_iaCore->get($key));
                                 }
                                 $value = $fileName = $key . '.' . $ext;
                                 @move_uploaded_file($_FILES[$key]['tmp_name'], IA_UPLOADS . $fileName);
                                 @chmod(IA_UPLOADS . $fileName, 0777);
                             }
                         }
                     }
                 } else {
                     $value = $this->_iaCore->get($key, '', !is_null($this->_type));
                 }
             }
             if ($this->_type) {
                 $where = sprintf("`name` = '%s' AND `type` = '%s' AND `type_id` = %d", $key, $this->_type, $this->_typeId);
                 $this->_iaDb->setTable(iaCore::getCustomConfigTable());
                 if ($_POST['c'][$key]) {
                     $values = array('name' => $key, 'value' => $value, 'type' => $this->_type, 'type_id' => $this->_typeId);
                     if ($this->_iaDb->exists($where)) {
                         unset($values['value']);
                         $this->_iaDb->bind($where, $values);
                         $this->_iaDb->update(array('value' => $value), $where);
                     } else {
                         $this->_iaDb->insert($values);
                     }
                 } else {
                     $this->_iaDb->delete($where);
                 }
                 $this->_iaDb->resetTable();
             } else {
                 $this->_iaDb->update(array('value' => $value), iaDb::convertIds($key, 'name'));
             }
         }
         $this->_iaDb->resetTable();
         $this->_iaCore->iaCache->clearAll();
     }
     if (!$error) {
         $iaView->setMessages(iaLanguage::get('saved'), iaView::SUCCESS);
         if (isset($_POST['param']['admin_page']) && $_POST['param']['admin_page'] != $adminPage) {
             iaUtil::go_to(IA_URL . $_POST['param']['admin_page'] . '/configuration/general/');
         }
     } elseif ($messages) {
         $iaView->setMessages($messages);
     }
 }
Exemple #23
0
 protected function _entryUpdate(array $entryData, $entryId)
 {
     $result = $this->getHelper()->update($entryData, iaDb::convertIds($entryId), array('date_update' => iaDb::FUNCTION_NOW));
     if ($result && $entryId == iaUsers::getIdentity()->id) {
         iaUsers::reloadIdentity();
     }
     return $result;
 }
Exemple #24
0
 protected function _assignValues(&$iaView, array &$entryData)
 {
     $pageGroups = array();
     $visibleOn = array();
     // get groups
     $groups = $this->_iaDb->onefield('`group`', '1 GROUP BY `group`', null, null, 'pages');
     $rows = $this->_iaDb->all(array('id', 'name', 'title'), null, null, null, 'admin_pages_groups');
     foreach ($rows as $row) {
         if (in_array($row['id'], $groups)) {
             $pageGroups[$row['id']] = $row;
         }
     }
     if (iaCore::ACTION_EDIT == $iaView->get('action')) {
         if ($array = $this->_iaDb->onefield('page_name', "`object_type` = 'blocks' && " . iaDb::convertIds($this->getEntryId(), 'object'), null, null, 'objects_pages')) {
             $visibleOn = $array;
         }
     } elseif (!empty($_POST['pages'])) {
         $visibleOn = $_POST['pages'];
     }
     if (!empty($_POST['menus'])) {
         $iaView->assign('treeData', iaSanitize::html(iaUtil::jsonEncode($_POST['menus'])));
     }
     $iaView->assign('visibleOn', $visibleOn);
     $iaView->assign('pages', $this->_getPages());
     $iaView->assign('pagesGroup', $pageGroups);
     $iaView->assign('positions', $this->getHelper()->getPositions());
 }
 private function _processCategory(array $entryData, $action = self::ACTION_INSTALL)
 {
     switch ($entryData['category']) {
         case 'payments':
             $iaTransaction = $this->iaCore->factory('transaction');
             if (self::ACTION_INSTALL == $action) {
                 $entry = array('name' => $entryData['name'], 'title' => $entryData['title']);
                 $this->iaDb->insert($entry, null, $iaTransaction->getTableGateways());
             } elseif (self::ACTION_UNINSTALL == $action) {
                 $this->iaDb->delete('`name` = :name', $iaTransaction->getTableGateways(), $entryData);
             }
             break;
         case 'lightbox':
         case 'captchas':
             $configName = 'lightbox' == $entryData['category'] ? 'lightbox_name' : 'captcha_name';
             $stmt = iaDb::convertIds($configName, 'name');
             $this->iaDb->setTable(iaCore::getConfigTable());
             if (self::ACTION_INSTALL == $action) {
                 if ($currentValues = $this->iaDb->one('`multiple_values`', $stmt)) {
                     $values = explode(',', $currentValues);
                 }
                 $values[] = $entryData['name'];
                 $this->iaDb->update(array('multiple_values' => implode(',', $values)), $stmt);
                 if (1 == count($values)) {
                     $this->iaCore->set($configName, $entryData['name'], true);
                 }
             } elseif (self::ACTION_UNINSTALL == $action) {
                 // get possible values
                 if ($values = explode(',', $this->iaDb->one('`multiple_values`', $stmt))) {
                     $installed = array_diff($values, array($entryData['name']));
                     $this->iaDb->update(array('multiple_values' => implode(',', $installed)), $stmt);
                     if ($this->iaCore->get($configName) == $entryData['name']) {
                         $value = empty($installed) ? '' : array_shift($installed);
                         if (in_array($entryData['name'], $this->_builtinPlugins)) {
                             $value = $entryData['name'];
                         }
                         $this->iaCore->set($configName, $value, true);
                     }
                 }
             }
             $this->iaDb->resetTable();
             break;
     }
 }
 public function getByReferenceId($referenceId)
 {
     return $this->iaDb->row(iaDb::ALL_COLUMNS_SELECTION, iaDb::convertIds($referenceId, 'reference_id'), self::getTable());
 }
Exemple #27
0
 protected function _jsonAction()
 {
     $output = array('error' => false, 'message' => array());
     $transaction = array('member_id' => (int) $_POST['member'], 'plan_id' => (int) $_POST['plan'], 'email' => $_POST['email'], 'item_id' => (int) $_POST['itemid'], 'gateway' => (string) $_POST['gateway'], 'sec_key' => uniqid('t'), 'reference_id' => empty($_POST['reference_id']) ? date('mdyHis') : $_POST['reference_id'], 'amount' => (double) $_POST['amount'], 'currency' => $this->_iaCore->get('currency'), 'date' => $_POST['date'] . ' ' . $_POST['time']);
     if ($transaction['plan_id']) {
         $this->_iaCore->factory('plan');
         if ($plan = $this->_iaDb->row(iaDb::ALL_COLUMNS_SELECTION, iaDb::convertIds($transaction['plan_id']), iaPlan::getTable())) {
             $transaction['item'] = $plan['item'];
             $transaction['operation'] = iaLanguage::get('plan_title_' . $plan['id']);
         } else {
             $output['error'] = true;
             $output['message'][] = iaLanguage::get('error_plan_not_exists');
         }
     } else {
         $transaction['item'] = iaTransaction::TRANSACTION_MEMBER_BALANCE;
         $transaction['operation'] = iaLanguage::get('funds');
     }
     if (isset($_POST['username']) && $_POST['username']) {
         if ($memberId = $this->_iaDb->one_bind(iaDb::ID_COLUMN_SELECTION, '`username` = :user', array('user' => $_POST['username']), iaUsers::getTable())) {
             $transaction['member_id'] = $memberId;
         } else {
             $output['error'] = true;
             $output['message'][] = iaLanguage::get('incorrect_username');
         }
     }
     if ($transaction['email'] && !iaValidate::isEmail($transaction['email'])) {
         $output['error'] = true;
         $output['message'][] = iaLanguage::get('error_email_incorrect');
     }
     if (isset($transaction['item']) && in_array($transaction['item'], array(iaTransaction::TRANSACTION_MEMBER_BALANCE, 'members'))) {
         $transaction['item_id'] = $transaction['member_id'];
     }
     if (!$output['error']) {
         $output['success'] = (bool) $this->_iaDb->insert($transaction);
         $output['message'] = $output['success'] ? iaLanguage::get('transaction_added') : iaLanguage::get('invalid_parameters');
     }
     return $output;
 }
Exemple #28
0
 /**
  * Set a given configuration value
  *
  * @param string $key configuration key
  * @param string $value configuration value
  * @param bool|false $permanent saves permanently in db
  *
  * @return bool
  */
 public function set($key, $value, $permanent = false)
 {
     if ($permanent && !is_scalar($value)) {
         trigger_error(__METHOD__ . '() Could not write a non-scalar value to the database.', E_USER_ERROR);
     }
     $result = true;
     $this->_config[$key] = $value;
     if ($permanent) {
         $result = (bool) $this->iaDb->update(array('value' => $value), iaDb::convertIds($key, 'name'), null, self::getConfigTable());
         $this->iaCache->createJsCache(array('config'));
         $this->iaCache->remove('config.inc');
     }
     return $result;
 }
 public function setVisibility($blockId, $visibility, array $pages = array(), $reset = true)
 {
     $this->iaDb->setTable(self::getPagesTable());
     if ($reset) {
         $this->iaDb->delete("`object_type` = 'blocks' && " . iaDb::convertIds($blockId, 'object'));
         // set global visibility for non-sticky blocks
         if (!$visibility) {
             $this->iaDb->insert(array('object_type' => 'blocks', 'object' => $blockId, 'page_name' => '', 'access' => 0));
         }
     }
     if ($pages) {
         $entry = array('object_type' => 'blocks', 'object' => $blockId, 'access' => $reset ? !$visibility : $visibility);
         foreach ($pages as $pageName) {
             if ($pageName = trim($pageName)) {
                 $entry['page_name'] = $pageName;
                 $this->iaDb->insert($entry);
             }
         }
     }
     $this->iaDb->resetTable();
 }
Exemple #30
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;
 }