Вход Регистрация
Файл: upload/module/pages/include/component/ajax/ajax.class.php
Строк: 150
<?php
/**
 * [PHPFOX_HEADER]
 */

defined('PHPFOX') or exit('NO DICE!');

/**
 * 
 * 
 * @copyright        [PHPFOX_COPYRIGHT]
 * @author          Raymond_Benc
 * @package         Phpfox_Ajax
 * @version         $Id: ajax.class.php 3654 2011-12-05 08:29:00Z Raymond_Benc $
 */
class Pages_Component_Ajax_Ajax extends Phpfox_Ajax
{
    public function 
deleteWidget()
    {
        if (
Phpfox::getService('pages.process')->deleteWidget($this->get('widget_id')))
        {
            
$this->slideUp('#js_pages_widget_' $this->get('widget_id'));
        }
    }
    
    public function 
addWidget()
    {
        
$this->error(false);        
        if ((
$this->get('widget_id') ? Phpfox::getService('pages.process')->updateWidget($this->get('widget_id'), $this->get('val')) : Phpfox::getService('pages.process')->addWidget($this->get('val'))))
        {
            
$aVals $this->get('val');
            
$this->call('window.location.href = '' . Phpfox::getLib('url')->makeUrl('pages.add.widget', array('id' => $aVals['page_id'])) . '';');            
        }
        else
        {
            
$this->call('$Core.processForm('#js_pages_widget_submit_button', true);');
            
$this->html('#js_pages_widget_error''<div class="error_message">' implode(''Phpfox_Error::get()) . '</div>');
            
$this->show('#js_pages_widget_error');
        }
    }
    
    public function 
widget()
    {
        
$this->setTitle(Phpfox::getPhrase('pages.widgets'));
        
Phpfox::getComponent('pages.widget', array(), 'controller');            
        
        ((
$sPlugin Phpfox_Plugin::get('pages.component_ajax_widget')) ? eval($sPlugin) : false);
        
        echo 
'<script type="text/javascript">$Core.loadInit();</script>';
    }
    
    public function 
add()
    {
        
Phpfox::isUser(true);
        if ((
$iId Phpfox::getService('pages.process')->add($this->get('val'))))
        {
            
$aPage Phpfox::getService('pages')->getPage($iId);
            
            
$this->call('window.location.href = '' . Phpfox::getLib('url')->makeUrl('pages.add', array('id' => $aPage['page_id'])) . '';');
        }
        else
        {
            
$sError Phpfox_Error::get();
            
$sError implode('<br />'$sError);
            
$this->alert($sError);
            
$this->call('$Core.processForm('#js_pages_add_submit_button', true);');
        
}
    }
    
    public function 
addFeedComment()
    {
        
Phpfox::isUser(true);
        
        
$aVals = (array) $this->get('val');    
        
        if (
Phpfox::getLib('parse.format')->isEmpty($aVals['user_status']))
        {
            
$this->alert(Phpfox::getPhrase('user.add_some_text_to_share'));
            
$this->call('$Core.activityFeedProcess(false);');
            return;            
        }            
        
        
$aPage Phpfox::getService('pages')->getPage($aVals['callback_item_id']);

        if (!isset(
$aPage['page_id']))
        {
            
$this->alert(Phpfox::getPhrase('pages.unable_to_find_the_page_you_are_trying_to_comment_on'));
            
$this->call('$Core.activityFeedProcess(false);');
            return;
        }
        
        
$sLink Phpfox::getService('pages')->getUrl($aPage['page_id'], $aPage['title'], $aPage['vanity_url']);
        
$aCallback = array(
            
'module' => 'pages',
            
'table_prefix' => 'pages_',
            
'link' => $sLink,
            
'email_user_id' => $aPage['user_id'],
            
'subject' => Phpfox::getPhrase('pages.full_name_wrote_a_comment_on_your_page_title', array('full_name' => Phpfox::getUserBy('full_name'), 'title' => $aPage['title'])),
            
'message' => Phpfox::getPhrase('pages.full_name_wrote_a_comment_link', array('full_name' => Phpfox::getUserBy('full_name'), 'link' => $sLink'title' => $aPage['title'])),
            
'notification' => ($this->get('custom_pages_post_as_page') ? null 'pages_comment'),
            
'feed_id' => 'pages_comment',
            
'item_id' => $aPage['page_id']
        );
        
        
$aVals['parent_user_id'] = $aVals['callback_item_id'];
        
        if (isset(
$aVals['user_status']) && ($iId Phpfox::getService('feed.process')->callback($aCallback)->addComment($aVals)))
        {
            
Phpfox::getLib('database')->updateCounter('pages''total_comment''page_id'$aPage['page_id']);        
            
            
Phpfox::getService('feed')->callback($aCallback)->processAjax($iId);
        }
        else 
        {
            
$this->call('$Core.activityFeedProcess(false);');
        }        
    }    
    
    public function 
changeUrl()
    {
        
Phpfox::isUser(true);
        
        if ((
$aPage Phpfox::getService('pages')->getForEdit($this->get('id'))))
        {
            
$aVals $this->get('val');
            
            
$sNewTitle Phpfox::getLib('parse.input')->cleanTitle($aVals['vanity_url']);
            
            if (
Phpfox::getLib('parse.input')->allowTitle($sNewTitlePhpfox::getPhrase('pages.page_name_not_allowed_please_select_another_name')))
            {
                if (
Phpfox::getService('pages.process')->updateTitle($this->get('id'), $sNewTitle))
                {
                    
$this->alert(Phpfox::getPhrase('pages.successfully_updated_your_pages_url'), Phpfox::getPhrase('pages.url_updated'), 300150true);
                }
            }        
        }
        
        
$this->call('$Core.processForm('#js_pages_vanity_url_button', true);');
    
}
    
    public function 
signup()
    {
        
Phpfox::isUser(true);
        if (
Phpfox::getService('pages.process')->register($this->get('page_id')))
        {
            
$this->alert(Phpfox::getPhrase('pages.successfully_registered_for_this_page'));
        }
    }
    
    public function 
moderation()
    {
        
Phpfox::isUser(true);
        if (
Phpfox::getService('pages.process')->moderation($this->get('item_moderate'), $this->get('action')))
        {
            foreach ((array) 
$this->get('item_moderate') as $iId)
            {
                
$this->remove('#js_pages_user_entry_' $iId);    
            }
            
            
$this->updateCount();
            
            
$this->alert(Phpfox::getPhrase('pages.successfully_moderated_user_s'), Phpfox::getPhrase('pages.moderation'), 300150true);
        }        
        
        
$this->hide('.moderation_process');            
    }    
    
    public function 
logBackUser()
    {
        
$this->error(false);
        
Phpfox::isUser(true);
        
$aUser Phpfox::getService('pages')->getLastLogin();
        list (
$bPass$aReturn) = Phpfox::getService('user.auth')->login($aUser['email'], $this->get('password'), true$sType 'email');
        if (
$bPass)            
        {
            
Phpfox::getService('pages.process')->clearLogin($aUser['user_id']);
            
            
$this->call('window.location.href = '' . Phpfox::getLib('url')->makeUrl('') . '';');
        }
        else
        {
            
$this->html('#js_error_pages_login_user''<div class="error_message">' implode('<br />'Phpfox_Error::get()) . '</div>');
        }        
    }
    
    public function 
logBackIn()
    {
        
// Phpfox::isUser(true);
        
        
if (($aUser Phpfox::getService('pages')->getLastLogin()))
        {        
            if (isset(
$aUser['fb_user_id']) && $aUser['fb_user_id'])
            {
                
$bPass true;
                
Phpfox::getService('pages.process')->clearLogin($aUser['user_id']);
                
Phpfox::getService('user.auth')->logout();
            }
            else
            {
                list (
$bPass$aReturn) = Phpfox::getService('user.auth')->login($aUser['email'], $aUser['password'], true'email'true);
            }            
        }
        
        
$this->call('window.location.href = '' . Phpfox::getLib('url')->makeUrl('') . '';');
        
// $this->setTitle('Login');
        // Phpfox::getBlock('pages.login-user');        
    
}
    
    public function 
login()
    {
        
Phpfox::isUser(true);
        
$this->setTitle(Phpfox::getPhrase('pages.login_as_a_page'));
        
Phpfox::getBlock('pages.login');
    }
    
    public function 
processLogin()
    {
        if (
Phpfox::getService('pages.process')->login($this->get('page_id')))
        {
            
$this->call('window.location.href = '' . Phpfox::getLib('url')->makeUrl('') . '';');
        }
    }
    
    public function 
pageModeration()
    {
        
Phpfox::isUser(true);
        
Phpfox::getUserParam('pages.can_moderate_pages'true);
        
        switch (
$this->get('action'))
        {
            case 
'approve':
                foreach ((array) 
$this->get('item_moderate') as $iId)
                {
                    
Phpfox::getService('pages.process')->approve($iId);
                    
$this->remove('#js_pages_' $iId);                    
                }                                
                
$sMessage Phpfox::getPhrase('pages.pages_s_successfully_approved');
                break;            
            case 
'delete':
                foreach ((array) 
$this->get('item_moderate') as $iId)
                {
                    
Phpfox::getService('pages.process')->delete($iId);
                    
$this->slideUp('#js_pages_' $iId);
                }                
                
$sMessage Phpfox::getPhrase('pages.pages_s_successfully_deleted');
                break;
        }
        
        
$this->updateCount();
        
        
$this->alert($sMessagePhpfox::getPhrase('pages.moderation'), 300150true);
        
$this->hide('.moderation_process');                    
    }
    
    public function 
approve()
    {
        if (
Phpfox::getService('pages.process')->approve($this->get('page_id')))
        {
            
$this->alert(Phpfox::getPhrase('pages.page_has_been_approved'), Phpfox::getPhrase('pages.page_approved'), 300100true);
            
$this->hide('#js_item_bar_approve_image');
            
$this->hide('.js_moderation_off'); 
            
$this->show('.js_moderation_on');
        }
    }    
    
    public function 
updateActivity()
    {
        if (
Phpfox::getService('pages.process')->updateActivity($this->get('id'), $this->get('active'), $this->get('sub')))
        {

        }
    }    
    
    public function 
categoryOrdering()
    {
        
$aVals $this->get('val');
        
Phpfox::getService('core.process')->updateOrdering(array(
                
'table' => 'pages_type',
                
'key' => 'type_id',
                
'values' => $aVals['ordering']
            )
        );        
        
        
Phpfox::getLib('cache')->remove('pages''substr');
    }    
    
    public function 
categorySubOrdering()
    {
        
$aVals $this->get('val');
        
Phpfox::getService('core.process')->updateOrdering(array(
                
'table' => 'pages_category',
                
'key' => 'category_id',
                
'values' => $aVals['ordering']
            )
        );        
        
        
Phpfox::getLib('cache')->remove('pages''substr');
    }        
}

?>
Онлайн: 0
Реклама