示例#1
0
 public function browse($resource = '', $itemID = 0, $total = false, $page = false, $post = true, $info = true, $static = false)
 {
     // Get vars
     if (input::isAjaxRequest() && !$static) {
         $resource = input::post_get('resource');
         $itemID = (int) input::post_get('item_id');
         $post = (bool) input::post_get('post');
         $info = (bool) input::post_get('info');
     }
     $split = (int) input::post_get('split') && (int) input::post_get('split') <= config::item('comments_per_page', 'comments') ? (int) input::post_get('split') : config::item('comments_per_page', 'comments');
     // Get resource ID
     $resourceID = config::item('resources', 'core', $resource, 'resource_id');
     if (!$resourceID || !$itemID) {
         return false;
     }
     // Do we have the number of comments?
     if ($total === false) {
         // Count comments
         $total = $this->comments_model->countComments(array(), array(), array('resource' => $resource, 'item_id' => $itemID));
     }
     // Post comment
     if (input::post('do_save_comment') && session::permission('comments_post', 'comments')) {
         if ($this->_saveComment($resource, $itemID)) {
             $total++;
         }
     } elseif (input::post('delete') && session::permission('comments_delete', 'comments')) {
         if ($this->_deleteComment($resource, $itemID, (int) input::post('delete'))) {
             $total--;
         }
     }
     // Current page
     $page = $page ? $page : (int) input::post_get('page', 1);
     $page = $page > 0 ? $page : 1;
     // Limit
     $limit = ($page - 1) * $split . ', ' . $split;
     // Get comments
     $comments = $this->comments_model->getComments($resource, $itemID, array(), '`c`.`post_date` desc', $limit);
     // If no comments were found, try to fetch from from the previous page
     if (!$comments && $page > 1) {
         $page--;
         // Limit
         $from = ($page - 1) * $split;
         $limit = $from . ', ' . $split;
         $comments = $this->comments_model->getComments($resource, $itemID, array(), '`c`.`post_date` desc', $limit);
     }
     // Pagination config
     $config = array('base_url' => 'comments/browse?', 'total_items' => $total, 'items_per_page' => $split, 'current_page' => $page, 'uri_segment' => 'page', 'link_attr' => array('onclick' => "runAjax(this.href,{'resource':'" . $resource . "','item_id':" . $itemID . ",'split':" . $split . ",'post':" . ($post ? 1 : 0) . ",'info':" . ($info ? 1 : 0) . "},'replaceContent','comments-container-" . $resource . "-" . $itemID . "','pagination-" . $resource . "-" . $itemID . "');return false;"));
     $pagination = loader::library('pagination', $config, null);
     // Assign vars
     view::assign(array('resource' => $resource, 'itemID' => $itemID, 'comments' => $comments, 'pagination' => $pagination, 'split' => $split, 'post' => users_helper::isLoggedin() && $post ? true : false, 'info' => $info), '', 'comments/index');
     if (input::isAjaxRequest() && !$static) {
         $output = view::load('comments/index', array(), true);
         view::ajaxResponse($output);
     } else {
         view::load('comments/index');
     }
 }
示例#2
0
 public function recent()
 {
     // Load view
     if (input::isAjaxRequest()) {
         // Get notices
         $notices = $this->timeline_notices_model->getNotices(session::item('user_id'), 0, 5);
         $output = view::load('timeline/notices/recent', array('notices' => $notices), true);
         // Dow we have new notifications?
         if (session::item('total_notices_new')) {
             // Reset new notifications counter
             $this->timeline_notices_model->resetCounter();
         }
         view::ajaxResponse($output);
     }
 }
示例#3
0
 public function view()
 {
     // Get URI vars
     $listID = uri::segment(6);
     // Get list
     if (!$listID || !($list = $this->lists_model->getList($listID))) {
         router::redirect('cp/system/config/system');
     }
     // Did we submit the form?
     if (input::post('action') == 'reorder' && input::post('ids')) {
         $this->_reorderItems();
     }
     // Get items
     if (!($items = $this->lists_model->getItems($listID))) {
         router::redirect('cp/system/config/system');
     }
     // Create table grid
     $grid = array('uri' => 'cp/system/templates/navigation', 'keyword' => 'templates', 'header' => array('name' => array('html' => __('name', 'system'), 'class' => 'name'), 'active' => array('html' => __('active', 'system'), 'class' => 'status')), 'content' => array());
     // Create grid content
     foreach ($items as $item) {
         $grid['content'][] = array('name' => array('html' => $item['name']), 'status' => array('html' => html_helper::anchor('cp/system/templates/navigation/togglestatus/' . $item['item_id'], $item['active'] ? __('yes', 'system') : __('no', 'system'), array('class' => $item['active'] ? 'label success small' : 'label important small'))));
     }
     // Filter hooks
     hook::filter('cp/system/templates/navigation/browse/grid', $grid);
     // Assign vars
     view::assign(array('grid' => $grid, 'items' => $items, 'listID' => $listID));
     // Set title
     view::setTitle(__('system_templates_navigation_manage', 'system_navigation'));
     // Set trail
     view::setTrail('cp/system/templates/navigation/view/' . $listID, $list['name']);
     // Set actions
     view::setAction('#', __('done', 'system'), array('class' => 'icon-text icon-system-done', 'onclick' => 'saveSortable();return false;', 'id' => 'actions_link_save'));
     view::setAction('#', __('cancel', 'system'), array('class' => 'icon-text icon-system-cancel', 'onclick' => 'cancelSortable();return false;', 'id' => 'actions_link_cancel'));
     view::setAction('#', __('reorder', 'system'), array('class' => 'icon-text icon-system-sort', 'onclick' => 'switchSortable();return false;', 'id' => 'actions_link_reorder'));
     // Include sortable vendor files
     view::includeJavascript('externals/html5sortable/html5sortable.js');
     view::includeStylesheet('externals/html5sortable/style.css');
     // Load view
     if (input::isAjaxRequest()) {
         view::load('cp/system/templates/navigation/items/browse_' . (input::post('view') == 'list' ? 'list' : 'grid'));
     } else {
         view::load('cp/system/templates/navigation/items/browse');
     }
 }
示例#4
0
 public function browse()
 {
     // Did we submit the form?
     if (input::post('action') == 'reorder' && input::post('ids')) {
         $this->_reorderPlans();
     }
     // Get plans
     if (!($plans = $this->plans_model->getPlans(false))) {
         view::setInfo(__('no_plans', 'billing_plans'));
     }
     // Set cycles
     $cycles = array_map('strtolower', array(1 => __('day', 'date'), 2 => __('week', 'date'), 3 => __('month', 'date'), 4 => __('year', 'date')));
     $cyclesMulti = array_map('strtolower', array(1 => __('days', 'date'), 2 => __('weeks', 'date'), 3 => __('months', 'date'), 4 => __('years', 'date')));
     // Create table grid
     $grid = array('uri' => 'cp/billing/plans/browse', 'keyword' => 'billing_plans', 'header' => array('name' => array('html' => __('name', 'system'), 'class' => 'name'), 'group' => array('html' => __('plan_group', 'billing_plans'), 'class' => 'group'), 'cycle' => array('html' => __('plan_cycle', 'billing_plans'), 'class' => 'cycle'), 'price' => array('html' => __('price', 'billing'), 'class' => 'price'), 'signup' => array('html' => __('plan_signup', 'billing_plans'), 'class' => 'signup'), 'status' => array('html' => __('active', 'system'), 'class' => 'status'), 'actions' => array('html' => __('actions', 'system'), 'class' => 'actions')), 'content' => array());
     // Create grid content
     foreach ($plans as $plan) {
         $grid['content'][] = array('name' => array('html' => html_helper::anchor('cp/billing/plans/edit/' . $plan['plan_id'], $plan['name'])), 'group' => array('html' => config::item('usergroups', 'core', $plan['group_id'])), 'cycle' => array('html' => $plan['duration'] . ' ' . ($plan['duration'] == 1 ? $cycles[$plan['cycle']] : $cyclesMulti[$plan['cycle']])), 'price' => array('html' => money_helper::symbol(config::item('currency', 'billing')) . $plan['price']), 'signup' => array('html' => $plan['signup'] ? '<span class="label success small">' . __('yes', 'system') . '</span>' : '<span class="label important small">' . __('no', 'system') . '</span>'), 'status' => array('html' => $plan['active'] ? '<span class="label success small">' . __('yes', 'system') . '</span>' : '<span class="label important small">' . __('no', 'system') . '</span>'), 'actions' => array('html' => array('edit' => html_helper::anchor('cp/billing/plans/edit/' . $plan['plan_id'], __('edit', 'system'), array('class' => 'edit')), 'delete' => html_helper::anchor('cp/billing/plans/delete/' . $plan['plan_id'], __('delete', 'system'), array('data-html' => __('plan_delete?', 'billing_plans'), 'data-role' => 'confirm', 'class' => 'delete')))));
     }
     // Filter hooks
     hook::filter('cp/billing/plans/browse/grid', $grid);
     // Assign vars
     view::assign(array('grid' => $grid, 'plans' => $plans));
     // Set title
     view::setTitle(__('billing_plans_manage', 'system_navigation'));
     // Assign actions
     view::setAction('cp/billing/plans/edit', __('plan_new', 'billing_plans'), array('class' => 'icon-text icon-billing-plans-new'));
     view::setAction('#', __('done', 'system'), array('class' => 'icon-text icon-system-done', 'onclick' => 'saveSortable();return false;', 'id' => 'actions_link_save'));
     view::setAction('#', __('cancel', 'system'), array('class' => 'icon-text icon-system-cancel', 'onclick' => 'cancelSortable();return false;', 'id' => 'actions_link_cancel'));
     view::setAction('#', __('reorder', 'system'), array('class' => 'icon-text icon-system-sort', 'onclick' => 'switchSortable();return false;', 'id' => 'actions_link_reorder'));
     // Include sortable vendor files
     view::includeJavascript('externals/html5sortable/html5sortable.js');
     view::includeStylesheet('externals/html5sortable/style.css');
     // Load view
     if (input::isAjaxRequest()) {
         view::load('cp/billing/plans/browse_' . (input::post('view') == 'list' ? 'list' : 'grid'));
     } else {
         view::load('cp/billing/plans/browse');
     }
 }
示例#5
0
 protected function browseFields($plugin, $table, $categoryID = 0)
 {
     // Did we submit the form?
     if (input::post('action') == 'reorder' && input::post('ids')) {
         $this->_reorderFields($plugin, $table, $categoryID);
     }
     // Get fields
     if (!($fields = $this->fields_model->getFields($plugin, $categoryID, 'grid'))) {
         view::setInfo(__('no_fields', 'system_fields'));
     }
     // Field types
     $types = $this->fieldsdb_model->getTypes(true);
     // Create table grid
     $grid = array('uri' => 'cp/usersgroups/browse', 'keyword' => 'usersgroups', 'header' => array('name' => array('html' => __('name', 'system'), 'class' => 'name'), 'keyword' => array('html' => __('keyword', 'system'), 'class' => 'keyword'), 'type' => array('html' => __('field_type', 'system_fields'), 'class' => 'type'), 'actions' => array('html' => __('actions', 'system'), 'class' => 'actions')), 'content' => array());
     // Create grid content
     foreach ($fields as $field) {
         $grid['content'][] = array('name' => array('html' => html_helper::anchor('cp/system/fields/' . $plugin . '/edit/' . $field['category_id'] . '/' . $field['field_id'], text_helper::entities($field['name'])), 'class' => $field['type']), 'keyword' => array('html' => $field['keyword']), 'type' => array('html' => '<span>' . $types[$field['type']] . '</span>', 'class' => $field['type']), 'actions' => array('html' => array('edit' => html_helper::anchor('cp/system/fields/' . $plugin . '/edit/' . $field['category_id'] . '/' . $field['field_id'], __('edit', 'system'), array('class' => 'edit')), 'delete' => html_helper::anchor('cp/system/fields/' . $plugin . '/delete/' . $field['category_id'] . '/' . $field['field_id'], __('delete', 'system'), array('data-html' => __('delete_field?', 'system_fields'), 'data-role' => 'confirm', 'class' => 'delete')))));
     }
     // Filter hooks
     hook::filter('cp/usersgroups/browse/grid', $grid);
     // Assign vars
     view::assign(array('grid' => $grid));
     // Assign vars
     view::assign(array('plugin' => $plugin, 'categoryID' => $categoryID, 'fields' => $fields, 'types' => $types));
     // Assign actions
     view::setAction('cp/system/fields/' . $plugin . '/edit' . ($categoryID ? '/' . $categoryID : ''), __('new_field', 'system_fields'), array('class' => 'icon-text icon-system-fields-new'));
     view::setAction('#', __('done', 'system'), array('class' => 'icon-text icon-system-done', 'onclick' => 'saveSortable();return false;', 'id' => 'actions_link_save'));
     view::setAction('#', __('cancel', 'system'), array('class' => 'icon-text icon-system-cancel', 'onclick' => 'cancelSortable();return false;', 'id' => 'actions_link_cancel'));
     view::setAction('#', __('reorder', 'system'), array('class' => 'icon-text icon-system-sort', 'onclick' => 'switchSortable();return false;', 'id' => 'actions_link_reorder'));
     // Include sortable vendor files
     view::includeJavascript('externals/html5sortable/html5sortable.js');
     view::includeStylesheet('externals/html5sortable/style.css');
     // Load view
     if (input::isAjaxRequest()) {
         view::load('cp/system/fields/browse_' . (input::post('view') == 'list' ? 'list' : 'grid'));
     } else {
         view::load('cp/system/fields/browse');
     }
 }
示例#6
0
 public function update()
 {
     // Get URI vars
     $plugin = uri::segment(5);
     // Get plugins
     if (!($plugins = $this->recalculate_model->getPlugins())) {
         view::setInfo(__('no_plugins', 'system_plugins'));
         router::redirect('cp/system/config/system');
     }
     // Get captcha
     if (!$plugin || !isset($plugins[$plugin])) {
         view::setError(__('no_plugin', 'utilities_counters'));
         router::redirect('cp/utilities/counters');
     }
     // Load plugin model
     $model = loader::model($plugin . '/' . $plugin, array(), null);
     // Update counters
     $result = $model->updateDbCounters();
     // Do we have redirect uri?
     if (isset($result['output']) && isset($result['redirect'])) {
         $result['redirect'] = $result['redirect'] ? 'update/' . $plugin . '/' . $result['redirect'] : '';
         $result['output'] .= '<br/>' . __('progress_redirect', 'utilities_counters', array(), array('%' => html_helper::anchor('cp/utilities/counters/' . $result['redirect'], '\\1')));
         if (!$result['redirect']) {
             view::setInfo(__('progress_done', 'utilities_counters', array('%1' => $plugins[$plugin])));
         }
         // Assign vars
         view::assign(array('output' => $result['output'], 'redirect' => $result['redirect']));
         if (input::isAjaxRequest()) {
             view::ajaxResponse(array('output' => $result['output'], 'redirect' => $result['redirect']));
         }
     }
     // Set title
     view::setTitle(__('utilities_counters_manage', 'system_navigation') . ' - ' . $plugins[$plugin]);
     // Load view
     view::load('cp/utilities/counters/update');
 }
示例#7
0
		<article class="item">
			<?php 
    echo html_helper::anchor('timeline/notices', __('actions_load', 'timeline'), array('id' => 'ajax-timeline-load', 'class' => 'icon icon-text icon-timeline-load', 'onclick' => "timelineNoticesUpdate(this.href," . $noticeID . ");return false;"));
    ?>
			<span class="icon icon-system-ajax ajax" id="ajax-timeline-load" style="display:none"></span>
		</article>

	</li>

<?php 
} else {
    ?>

	<?php 
    if (input::isAjaxRequest()) {
        ?>

		<li class="clearfix <?php 
        echo text_helper::alternate('odd', 'even');
        ?>
 shift" id="row-action-0">

			<article class="item">
				<?php 
        echo __('actions_load_last', 'timeline');
        ?>
			</article>

		</li>
示例#8
0
?>
<meta name="description" content="<?php 
echo view::getMetaDescription();
?>
" />
<meta name="keywords" content="<?php 
echo view::getMetaKeywords();
?>
" />
</head>
<body <?php 
echo input::isAjaxRequest() || input::get('modal') ? 'class="modal"' : '';
?>
>
	<?php 
if (input::isAjaxRequest() || input::get('modal')) {
    ?>
	<?php 
} else {
    ?>
		<header id="header">
			<div class="inner clearfix">
				<?php 
    echo html_helper::anchor('', '<span>' . text_helper::entities(config::item('site_title', 'system')) . '</span>', array('class' => 'title'));
    ?>
				<div class="float-right">
					<?php 
    echo banners_helper::showBanner('header');
    ?>
				</div>
			</div>
示例#9
0
 public function send()
 {
     // Get URI vars
     $newsletterID = (int) uri::segment(5);
     $counter = (int) uri::segment(6, 0);
     $test = uri::segment(7) == 'test' ? 1 : 0;
     $step = config::item('emails_batch', 'newsletters');
     // Get newsletter
     if (!$newsletterID || !($newsletter = $this->newsletters_model->getNewsletter($newsletterID, false))) {
         view::setError(__('no_newsletter', 'newsletters'));
         router::redirect('cp/content/newsletters');
     }
     // Do we have recipients?
     if (!$newsletter['total_users']) {
         router::redirect('cp/content/newsletters/recipients/' . $newsletterID);
     }
     // Is this the first step?
     if (!$test && !$counter) {
         // Update total user count
         $searchID = $this->search_model->searchData('profile', array(), $newsletter['params']['conditions'], $newsletter['params']['values'], array('type_id' => isset($newsletter['params']['values']['type_id']) ? $newsletter['params']['values']['type_id'] : 0));
         // Do we have any search terms?
         if ($searchID == 'no_terms' || $searchID == 'no_results' || !($search = $this->search_model->getSearch($searchID))) {
             router::redirect('cp/content/newsletters/recipients/' . $newsletterID);
         }
         // Did total user count change?
         if ($search['results'] != $newsletter['total_users']) {
             $newsletter = array('total_users' => $search['results']);
             $this->newsletters_model->saveNewsletter($newsletterID, $newsletter);
         }
     } elseif ($test && !config::item('email_test', 'newsletters')) {
         view::setError(__('newsletters_test_none', 'newsletters', array(), array('%' => html_helper::anchor('cp/system/config/newsletters', '\\1'))));
         router::redirect('cp/content/newsletters/review/' . $newsletterID);
     }
     // Load email library
     loader::library('email');
     // Is this a test?
     if ($test) {
         $this->email->sendEmail(config::item('email_test', 'newsletters'), $newsletter['subject'], $newsletter['message_text'], $newsletter['message_html']);
         view::setInfo(__('newsletter_sent', 'newsletters'));
         router::redirect('cp/content/newsletters/review/' . $newsletterID);
     }
     // Get users
     $users = $this->users_model->getUsers('in_view', isset($newsletter['params']['values']['type_id']) ? $newsletter['params']['values']['type_id'] : 0, $newsletter['params']['conditions']['columns'], $newsletter['params']['conditions']['items'], false, $counter . ',' . $step);
     foreach ($users as $user) {
         if (!input::demo(0)) {
             $this->email->sendEmail($user['email'], $newsletter['subject'], $newsletter['message_text'], $newsletter['message_html'], $user);
         }
         $counter++;
     }
     // Do we have any users?
     if (!$users) {
         view::setInfo(__('newsletter_sent', 'newsletters'));
         $next = '';
     } else {
         $next = $counter;
     }
     // Update total sent
     $this->newsletters_model->saveNewsletter($newsletterID, array('total_sent' => $next ? $counter : 0));
     // Did total number of users change?
     if ($counter > $newsletter['total_users'] || !$next && $counter < $newsletter['total_users']) {
         $newsletter['total_users'] = $counter;
         $this->newsletters_model->saveNewsletter($newsletterID, array('total_users' => $counter));
     }
     $message = __('newsletter_sending_status', 'newsletters', array('%1' => $counter, '%2' => $newsletter['total_users']));
     $message .= '<br/>' . __('newsletter_sending_redirect', 'newsletters', array(), array('%' => html_helper::anchor('cp/content/newsletters/send/' . $newsletterID . '/' . $next, '\\1')));
     // Assign vars
     view::assign(array('newsletterID' => $newsletterID, 'newsletter' => $newsletter, 'counter' => $counter, 'redirect' => $next, 'output' => $message));
     if (input::isAjaxRequest()) {
         view::ajaxResponse(array('output' => $message, 'redirect' => $next));
     }
     // Set title
     view::setTitle(__('newsletter_sending', 'newsletters'));
     // Set trail
     view::setTrail('cp/content/newsletters/send/' . $newsletterID, __('newsletter_send', 'newsletters') . ' - ' . text_helper::entities($newsletter['subject']));
     // Load view
     view::load('cp/content/newsletters/send');
 }
示例#10
0
 public function user()
 {
     // Get user and last action ID
     $slugID = urldecode(utf8::trim(uri::segment(3)));
     $lastID = (int) input::post_get('last_id', 0);
     // Get user
     if (!($user = $this->users_model->getUser($slugID)) || !$user['active'] || !$user['verified']) {
         error::show404();
     }
     // Does user have permission to view this user group/type?
     if (!in_array($user['group_id'], session::permission('users_groups_browse', 'users')) || !in_array($user['type_id'], session::permission('users_types_browse', 'users'))) {
         view::noAccess();
     } elseif (!$this->users_model->getPrivacyAccess($user['user_id'], isset($user['config']['privacy_profile']) ? $user['config']['privacy_profile'] : 1)) {
         view::noAccess($user['slug']);
     }
     // Get actions
     $actions = $this->timeline_model->getActions($user['user_id'], 1, $lastID, config::item('actions_per_page', 'timeline'));
     $ratings = array();
     // Do we have actions and are we logged in?
     if ($actions && users_helper::isLoggedin()) {
         foreach ($actions as $action) {
             if ($action['rating']) {
                 $ratings[$action['relative_resource']][] = $action['item_id'];
             } else {
                 $ratings['timeline'][] = $action['action_id'];
             }
         }
         // Load votes and like models
         loader::model('comments/votes');
         loader::model('comments/likes');
         // Get likes and votes
         $likes = $this->likes_model->getMultiLikes($ratings);
         $votes = $this->votes_model->getMultiVotes($ratings);
         $ratings = $likes + $votes;
     }
     // Can we post messages?
     $post = session::permission('messages_post', 'timeline') && $this->users_model->getPrivacyAccess($user['user_id'], isset($user['config']['privacy_timeline_messages']) ? $user['config']['privacy_timeline_messages'] : 1, false) ? true : false;
     // Update comments pagination
     config::set('comments_per_page', config::item('comments_per_page', 'timeline'), 'comments');
     // Set meta tags
     $this->metatags_model->set('timeline', 'timeline_user', array('user' => $user));
     // Set title
     view::setTitle(__('timeline_recent', 'system_navigation'), false);
     // Set trail
     view::setTrail($user['slug'], $user['name']);
     // Load view
     if (input::isAjaxRequest()) {
         $output = view::load('timeline/actions', array('actions' => $actions, 'user' => $user, 'post' => $post, 'ratings' => $ratings), true);
         view::ajaxResponse($output);
     } else {
         view::load('timeline/index', array('actions' => $actions, 'user' => $user, 'post' => $post, 'ratings' => $ratings));
     }
 }
示例#11
0
 protected function _uploadPicture()
 {
     // Create rules
     $rules = array('file' => array('label' => __('file_select', 'system_files'), 'rules' => array('required_file' => 'file')));
     // Assign rules
     validate::setRules($rules);
     // Validate form values
     if (!validate::run()) {
         return false;
     }
     // Thumbnails config
     $thumbs = array(array('suffix' => 'x'), array('dimensions' => config::item('picture_dimensions', 'users'), 'method' => 'preserve', 'suffix' => ''), array('dimensions' => config::item('picture_dimensions_p', 'users'), 'method' => 'crop', 'suffix' => 'p'), array('dimensions' => config::item('picture_dimensions_l', 'users'), 'method' => 'crop', 'suffix' => 'l'), array('dimensions' => config::item('picture_dimensions_t', 'users'), 'method' => 'crop', 'suffix' => 't'));
     // Upload picture
     if (!($fileID = $this->storage_model->upload('user', session::item('user_id'), 'file', 'jpg|jpeg|gif|png', config::item('picture_max_size', 'users'), config::item('picture_dimensions_max', 'users'), $thumbs))) {
         if (input::isAjaxRequest()) {
             view::ajaxError(config::item('devmode', 'system') ? $this->storage_model->getError() : __('file_upload_error', 'system_files'));
         } else {
             validate::setFieldError('file', config::item('devmode', 'system') ? $this->storage_model->getError() : __('file_upload_error', 'system_files'));
         }
         return false;
     }
     // Delete old picture if it exists
     if (session::item('picture_id')) {
         // Delete picture
         $this->users_model->deletePicture(session::item('user_id'), session::item('picture_id'), false);
     }
     // Save new picture ID
     if (!$this->users_model->savePicture(session::item('user_id'), $fileID)) {
         if (input::isAjaxRequest()) {
             view::ajaxError(__('save_error', 'system'));
         } else {
             validate::setFieldError('file', __('save_error', 'system'));
             return false;
         }
     }
     // Was this an ajax request?
     if (input::isAjaxRequest()) {
         view::ajaxResponse(array('redirect' => html_helper::siteURL(session::item('slug'))));
     }
     // Success
     view::setInfo(__('picture_uploaded', 'users_picture'));
     router::redirect(session::item('slug'));
 }
示例#12
0
 protected function _uploadPicture($adID, $ad)
 {
     // Create rules
     $rules = array('file' => array('label' => __('file_select', 'system_files'), 'rules' => array('required_file' => 'file')));
     // Assign rules
     validate::setRules($rules);
     // Validate form values
     if (!validate::run()) {
         return false;
     }
     // Thumbnails config
     $thumbs = array(array('suffix' => 'x'), array('dimensions' => config::item('picture_dimensions', 'classifieds'), 'method' => 'preserve', 'suffix' => ''), array('dimensions' => config::item('picture_dimensions_t', 'classifieds'), 'method' => 'crop', 'suffix' => 't'));
     // Upload picture
     if (!($fileID = $this->storage_model->upload('classified_picture', session::item('user_id'), 'file', 'jpg|jpeg|gif|png', config::item('picture_max_size', 'classifieds'), config::item('picture_dimensions_max', 'classifieds'), $thumbs))) {
         if (input::isAjaxRequest()) {
             view::ajaxError(config::item('devmode', 'system') ? $this->storage_model->getError() : __('file_upload_error', 'system_files'));
         } else {
             validate::setFieldError('file', config::item('devmode', 'system') ? $this->storage_model->getError() : __('file_upload_error', 'system_files'));
             return false;
         }
     }
     // Extras
     $extra = array();
     // Save picture file
     if (!($pictureID = $this->classifieds_pictures_model->savePictureFile($fileID, $adID, $ad, $extra))) {
         if (input::isAjaxRequest()) {
             view::ajaxError(__('save_error', 'system'));
         } else {
             validate::setFieldError('file', __('save_error', 'system'));
             return false;
         }
     }
     // Update current album counters
     $ad[session::permission('pictures_approve', 'classifieds') ? 'total_pictures' : 'total_pictures_i']++;
     // Update album's modification date
     $this->classifieds_model->updateModifyDate($adID);
     // Was this an ajax request?
     if (input::isAjaxRequest()) {
         //view::ajaxResponse(__('picture_uploaded', 'pictures'));
         view::ajaxResponse(array('redirect' => html_helper::siteURL('classifieds/pictures/index/' . $adID)));
     }
     // Success
     view::setInfo(__('picture_uploaded', 'classifieds'));
     router::redirect('classifieds/pictures/index/' . $adID);
 }
示例#13
0
 protected function _uploadPicture()
 {
     if (input::files('file')) {
         // Create rules
         $rules = array('file' => array('label' => __('file_select', 'system_files'), 'rules' => array('required_file' => 'file')));
         // Assign rules
         validate::setRules($rules);
         // Validate form values
         if (!validate::run()) {
             return false;
         }
         // Resize config
         $thumbs = array(array('suffix' => 'x'), array('dimensions' => config::item('picture_dimensions', 'users'), 'method' => 'preserve', 'suffix' => ''), array('dimensions' => config::item('picture_dimensions_p', 'users'), 'method' => 'crop', 'suffix' => 'p'), array('dimensions' => config::item('picture_dimensions_l', 'users'), 'method' => 'crop', 'suffix' => 'l'), array('dimensions' => config::item('picture_dimensions_t', 'users'), 'method' => 'crop', 'suffix' => 't'));
         // Upload picture
         if (!($fileID = $this->storage_model->upload('user', 0, 'file', 'jpg|jpeg|gif|png', config::item('picture_max_size', 'users'), config::item('picture_dimensions_max', 'users'), $thumbs))) {
             if (input::isAjaxRequest()) {
                 view::ajaxError(config::item('devmode', 'system') ? $this->storage_model->getError() : __('file_upload_error', 'system_files'));
             } else {
                 validate::setFieldError('file', config::item('devmode', 'system') ? $this->storage_model->getError() : __('file_upload_error', 'system_files'));
                 return false;
             }
         }
         // Delete old picture if it exists
         if (session::item('picture', 'signup', 'file_id')) {
             $this->storage_model->deleteFiles(session::item('picture', 'signup', 'file_id'), 5);
         }
         // Get file details
         $file = $this->storage_model->getFile($fileID);
         // Set user session data
         session::set(array('picture' => $file), '', 'signup');
         // Was this an ajax request?
         if (input::isAjaxRequest()) {
             view::ajaxResponse(array('redirect' => html_helper::siteURL('users/signup/picture')));
         }
         router::redirect('users/signup/picture');
     }
     // Redirect to the next step
     $this->_nextStep();
 }