Subrion - open source content management system Copyright (C) 2016 Intelliants, LLC This file is part of Subrion. Subrion is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Subrion is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 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 .
Inheritance: extends abstractUtil, implements iaInterfaceDbAdapter
Exemplo n.º 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;
 }
Exemplo n.º 2
0
 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;
 }
 public function url($action, $data = array(), $generate = false)
 {
     $data['action'] = $action;
     $data['alias'] = isset($data['album_alias']) ? $data['album_alias'] : $data['title_alias'];
     if (!isset($this->patterns[$action])) {
         $action = 'view';
     }
     $url = iaDb::printf($this->patterns[$action], $data);
     return self::get('url') . $url;
 }
 public function url($action, $data = array())
 {
     $data['action'] = $action;
     $data['alias'] = isset($data['genre_alias']) ? $data['genre_alias'] : $data['title_alias'];
     if (!isset($this->_patterns[$action])) {
         $action = 'view';
     }
     $url = iaDb::printf($this->_patterns[$action], $data);
     return $this->iaCore->packagesData[self::PACKAGE_NAME]['url'] . $url;
 }
Exemplo n.º 5
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;
 }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
0
 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);
 }
Exemplo n.º 8
0
 protected function _gridQuery($columns, $where, $order, $start, $limit)
 {
     foreach (array('amount', 'gateway', 'status') as $joinedColumnName) {
         if (false !== stripos($order, $joinedColumnName)) {
             $order = str_replace(' i.`', ' t.`', $order);
             break;
         }
     }
     $sql = 'SELECT SQL_CALC_FOUND_ROWS ' . 'i.`id`, i.`date_created`, i.`fullname`, ' . 't.`plan_id`, t.`operation`, ' . 't.`status`, CONCAT(t.`amount`, " ", t.`currency`) `amount`, t.`currency`, t.`gateway`, ' . "1 `pdf`, 1 `update`, IF(t.`status` != 'passed', 1, 0) `delete` " . 'FROM `:prefix:table_invoices` i ' . 'LEFT JOIN `:prefix:table_transactions` t ON (t.`id` = i.`transaction_id`) ' . 'LEFT JOIN `:prefix:table_members` m ON (m.`id` = t.`member_id`) ' . ($where ? 'WHERE ' . $where . ' ' : '') . $order . ' ' . 'LIMIT :start, :limit';
     $sql = iaDb::printf($sql, array('prefix' => $this->_iaDb->prefix, 'table_invoices' => self::getTable(), 'table_members' => iaUsers::getTable(), 'table_transactions' => 'payment_transactions', 'start' => $start, 'limit' => $limit));
     return $this->_iaDb->getAll($sql);
 }
 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;
 }
Exemplo n.º 11
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);
 }
Exemplo n.º 12
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;
 }
Exemplo n.º 13
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;
 }
Exemplo n.º 15
0
 public function url($action, $data = array(), $generate = false)
 {
     $data['action'] = $action;
     $data['alias'] = isset($data['genre_alias']) ? $data['genre_alias'] : $data['title_alias'];
     if (!isset($this->patterns[$action])) {
         $action = 'view';
     }
     if ($generate) {
         iaCore::util();
         if (!defined('IA_NOUTF')) {
             iaUtf8::loadUTF8Core();
             iaUtf8::loadUTF8Util('ascii', 'validation', 'bad', 'utf8_to_ascii');
         }
         if (!utf8_is_ascii($data['alias'])) {
             $data['alias'] = $iaCore->convertStr(utf8_to_ascii($data['alias']));
         }
     }
     $url = iaDb::printf($this->patterns[$action], $data);
     return $this->iaCore->packagesData[self::PACKAGE_NAME]['url'] . $url;
 }
Exemplo n.º 16
0
 public function url($action, $data = array(), $generate = false)
 {
     $data['action'] = $action;
     $data['alias'] = isset($data['artist_alias']) ? $data['artist_alias'] : $data['title_alias'];
     if (!isset($this->patterns[$action])) {
         $action = 'view';
     }
     if ($generate) {
         $iaUtil = $iaCore->factory('core', 'util');
         if (!defined('IA_NOUTF')) {
             iaUtf8::loadUTF8Core();
             iaUtf8::loadUTF8Util('ascii', 'validation', 'bad', 'utf8_to_ascii');
         }
         if (!utf8_is_ascii($data['alias'])) {
             $data['alias'] = $iaCore->convertStr(utf8_to_ascii($data['alias']));
         }
     }
     $url = iaDb::printf($this->patterns[$action], $data);
     return self::get('url') . $url;
 }
Exemplo n.º 17
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' => 'blog_entries_tags', 'table_blog_tags' => 'blog_tags'));
         $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;
 }
Exemplo n.º 18
0
 public function getTags($id)
 {
     $sql = 'SELECT GROUP_CONCAT(`title`) ' . 'FROM `:prefix:table_blog_tags` bt ' . 'WHERE `id` IN (' . 'SELECT `tag_id` ' . 'FROM `:prefix:table_blog_entries_tags` ' . 'WHERE `blog_id` = :id)';
     $sql = iaDb::printf($sql, array('prefix' => $this->_iaDb->prefix, 'table_blog_tags' => $this->_tableBlogTags, 'table_blog_entries_tags' => $this->_tableBlogEntriesTags, 'id' => $id));
     return $this->_iaDb->getOne($sql);
 }
Exemplo n.º 19
0
        $iaView->assign('tags', $blogTags);
        $iaView->assign('blog_entry', $blogEntry);
    } else {
        $page = empty($_GET['page']) ? 0 : (int) $_GET['page'];
        $page = $page < 1 ? 1 : $page;
        $pageUrl = $iaCore->factory('page', iaCore::FRONT)->getUrlByName('blog');
        $pagination = array('start' => ($page - 1) * $iaCore->get('blog_number'), 'limit' => (int) $iaCore->get('blog_number'), 'template' => $pageUrl . '?page={page}');
        $order = 'date' == $iaCore->get('blog_order') ? 'ORDER BY `date_added` DESC' : 'ORDER BY `title` ASC';
        $stmt = '`status` = :status AND `lang` = :language';
        $iaDb->bind($stmt, array('status' => iaCore::STATUS_ACTIVE, 'language' => $iaView->language));
        $sql = 'SELECT SQL_CALC_FOUND_ROWS ' . 'b.`id`, b.`title`, b.`date_added`, b.`body`, b.`alias`, b.`image`, m.`fullname` ' . 'FROM `:prefix:table_blog_entries` b ' . 'LEFT JOIN `:prefix:table_members` m ON (b.`member_id` = m.`id`) ' . 'WHERE b.' . $stmt . $order . ' LIMIT :start, :limit';
        $sql = iaDb::printf($sql, array('prefix' => $iaDb->prefix, 'table_blog_entries' => 'blog_entries', 'table_members' => 'members', 'start' => $pagination['start'], 'limit' => $pagination['limit']));
        $rows = $iaDb->getAll($sql);
        $pagination['total'] = $iaDb->foundRows();
        $sql = 'SELECT bt.`title`, bt.`alias`, bet.`blog_id` ' . 'FROM `:prefix:table_blog_tags` bt ' . 'LEFT JOIN `:prefix:table_blog_entries_tags` bet ON (bt.`id` = bet.`tag_id`) ' . 'ORDER BY bt.`title`';
        $sql = iaDb::printf($sql, array('prefix' => $iaDb->prefix, 'table_blog_entries_tags' => 'blog_entries_tags', 'table_blog_tags' => 'blog_tags'));
        $blogTags = $iaDb->getAll($sql);
        $iaView->assign('tags', $blogTags);
        $iaView->assign('blog_entries', $rows);
        $iaView->assign('pagination', $pagination);
    }
    $pageActions[] = array('icon' => 'rss', 'title' => '', 'url' => IA_URL . 'blog.xml', 'classes' => 'btn-warning');
    $iaView->set('actions', $pageActions);
    $iaView->display('index');
}
if (iaView::REQUEST_XML == $iaView->getRequestType()) {
    $output = array('title' => $iaCore->get('site') . ' :: ' . $iaView->title(), 'description' => '', 'url' => IA_URL . 'blog', 'item' => array());
    $listings = $iaDb->all(iaDb::ALL_COLUMNS_SELECTION, "`lang`= '" . $iaView->language . "'", 0, 20);
    $pageUrl = $iaCore->factory('page', iaCore::FRONT)->getUrlByName('blog');
    foreach ($listings as $entry) {
        $output['item'][] = array('title' => $entry['title'], 'link' => $pageUrl . $entry['id'] . '-' . $entry['alias'], 'pubDate' => date('D, d M Y H:i:s T', strtotime($entry['date_modified'])), 'description' => iaSanitize::tags($entry['body']));
Exemplo n.º 20
0
 * Subrion is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * 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 (iaView::REQUEST_HTML == $iaView->getRequestType()) {
    if ($iaView->blockExists('blogroll') || $iaView->blockExists('new_blog_posts')) {
        $stmt = 'b.`status` = :status AND `lang` = :language ORDER BY b.`date_added` DESC';
        $iaDb->bind($stmt, array('status' => iaCore::STATUS_ACTIVE, 'language' => $iaView->language));
        $sql = 'SELECT b.`id`, b.`title`, b.`date_added`, b.`alias`, b.`body`, b.`image`, m.`fullname` ' . 'FROM `:prefix:table_blog_entries` b ' . 'LEFT JOIN `:prefix:table_members` m ON (b.`member_id` = m.`id`) ' . 'WHERE :condition ' . 'LIMIT :start, :limit';
        $sql = iaDb::printf($sql, array('prefix' => $iaDb->prefix, 'table_blog_entries' => 'blog_entries', 'table_members' => 'members', 'condition' => $stmt, 'start' => 0, 'limit' => $iaCore->get('blog_number_block')));
        $array = $iaDb->getAll($sql);
        $iaView->assign('block_blog_entries', $array);
    }
    if ($iaView->blockExists('blogs_archive')) {
        $data = array();
        if ($array = $iaDb->all('DISTINCT(MONTH(`date_added`)) `month`, YEAR(`date_added`) `year`', "`status` = 'active' GROUP BY `date_added` ORDER BY `date_added` DESC", 0, 6, 'blog_entries')) {
            foreach ($array as $date) {
                $data[] = array('url' => IA_URL . 'blog/date/' . $date['year'] . IA_URL_DELIMITER . $date['month'] . IA_URL_DELIMITER, 'month' => $date['month'], 'year' => $date['year']);
            }
        }
        $iaView->assign('blogs_archive', $data);
    }
}
Exemplo n.º 21
0
 protected function _gridQuery($columns, $where, $order, $start, $limit)
 {
     $sql = 'SELECT SQL_CALC_FOUND_ROWS ' . 'b.`id`, b.`title`, b.`alias`, b.`date_added`, b.`status`, m.`fullname` `owner`, 1 `update`, 1 `delete` ' . 'FROM `:prefix:table_blog_entries` b ' . 'LEFT JOIN `:prefix:table_members` m ON (b.`member_id` = m.`id`) ' . ($where ? "WHERE " . $where : '') . $order . ' ' . 'LIMIT :start, :limit';
     $sql = iaDb::printf($sql, array('prefix' => $this->_iaDb->prefix, 'table_blog_entries' => $this->getTable(), 'table_members' => iaUsers::getTable(), 'start' => $start, 'limit' => $limit));
     return $this->_iaDb->getAll($sql);
 }
Exemplo n.º 22
0
                }
            }
            if (isset($iaCore->requestPath[0]) && !isset($iaCore->requestPath[1])) {
                iaBreadcrumb::preEnd('Blog Archive', 'blog/date');
                iaBreadcrumb::replaceEnd($iaCore->requestPath[0], IA_SELF);
                $iaView->title($iaCore->requestPath[0]);
            }
            $iaView->assign('show', $show);
            $iaView->assign('years', $years);
            $iaView->assign('months', $months);
        } else {
            $iaView->setMessages(iaLanguage::get('no_blog_entries'), iaView::ALERT);
        }
    } elseif (isset($iaCore->requestPath[0]) && isset($iaCore->requestPath[1])) {
        $page = empty($_GET['page']) ? 0 : (int) $_GET['page'];
        $page = $page < 1 ? 1 : $page;
        $pageUrl = $iaCore->factory('page', iaCore::FRONT)->getUrlByName('blog_date');
        $pagination = array('start' => ($page - 1) * $iaCore->get('blog_number'), 'limit' => (int) $iaCore->get('blog_number'), 'template' => $pageUrl . '?page={page}');
        $stmt = "`status` = 'active' AND MONTH(b.`date_added`) = '" . $iaCore->requestPath[1] . "' AND YEAR(b.`date_added`) = '" . $iaCore->requestPath[0] . "' ";
        $order = 'date' == $iaCore->get('blog_order') ? 'ORDER BY b.`date_added` DESC' : 'ORDER BY b.`title` ASC';
        $sql = 'SELECT SQL_CALC_FOUND_ROWS ' . 'b.`id`, b.`title`, b.`date_added`, b.`body`, b.`alias`, b.`image`, m.`fullname` ' . 'FROM `:prefix:table_blog_entries` b ' . 'LEFT JOIN `:prefix:table_members` m ON (b.`member_id` = m.`id`) ' . 'WHERE b.' . $stmt . $order . ' LIMIT :start, :limit';
        $sql = iaDb::printf($sql, array('prefix' => $iaDb->prefix, 'table_blog_entries' => 'blog_entries', 'table_members' => 'members', 'start' => $pagination['start'], 'limit' => $pagination['limit']));
        $blogs = $iaDb->getAll($sql);
        iaBreadcrumb::toEnd(date("F", mktime(0, 0, 0, $iaCore->requestPath[1], 10)));
        $pagination['total'] = $iaDb->foundRows();
        $iaView->assign('blogs', $blogs);
        $iaView->assign('pagination', $pagination);
        $iaView->title(date("F", mktime(0, 0, 0, $iaCore->requestPath[1], 10)));
    }
    $iaView->display('date');
}
Exemplo n.º 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;
 }
Exemplo n.º 24
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);
         }
Exemplo n.º 25
0
 public function getBy($key, $id)
 {
     return $this->iaDb->row(iaDb::ALL_COLUMNS_SELECTION, iaDb::convertIds($id, $key), self::getTable());
 }
Exemplo n.º 26
0
 protected function _entryUpdate(array $entryData, $entryId)
 {
     return $this->_iaDb->update($entryData, iaDb::convertIds($entryId), null, iaLanguage::getLanguagesTable());
 }
Exemplo n.º 27
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=='));
Exemplo n.º 28
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);
 }
Exemplo n.º 29
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;
 }
Exemplo n.º 30
0
 private function _getAdminToolbarActions()
 {
     $result = array();
     $stmt = "`pages` REGEXP('[[:<:]]:page(::action)?(,|\$)') AND `type` = 'regular' ORDER BY `order` DESC";
     $stmt = iaDb::printf($stmt, array('page' => $this->name(), 'action' => $this->get('action')));
     $iaAcl = $this->iaCore->factory('acl');
     $rows = $this->iaCore->iaDb->all(array('attributes', 'name', 'icon', 'text', 'url'), $stmt, null, null, 'admin_actions');
     foreach ($rows as $entry) {
         if ($iaAcl->checkAccess(iaAcl::OBJECT_ADMIN_PAGE, $entry['name'])) {
             $result[] = array('attributes' => $entry['attributes'], 'icon' => empty($entry['icon']) ? '' : 'i-' . $entry['icon'], 'title' => iaLanguage::get($entry['text'], $entry['text']), 'url' => iaDb::printf($entry['url'], $this->iaCore->iaView->get('toolbarActionsReplacements', array())));
         }
     }
     return $result;
 }