Example #1
0
 /**
  * Controller
  */
 public function process()
 {
     $oAdmincpMenu = Admincp_Service_Menu_Menu::instance();
     $bIsEdit = false;
     $bIsPage = false;
     if (Phpfox::isModule('page') && ($sPage = $this->request()->get('page'))) {
         $aPage = Phpfox::getService('page')->getPage($sPage, true);
         if (isset($aPage['page_id'])) {
             $bIsPage = true;
             $this->template()->assign(array('aPage' => $aPage, 'sModuleValue' => $aPage['module_id'] ? $aPage['module_id'] . '|' . $aPage['module_id'] : 'page|page', 'aAccess' => empty($aPage['disallow_access']) ? null : unserialize($aPage['disallow_access'])));
         }
     }
     if (($iEditId = $this->request()->getInt('id')) || ($iEditId = $this->request()->getInt('menu_id'))) {
         $aRow = $oAdmincpMenu->getForEdit($iEditId);
         $aLanguages = Phpfox::getService('language')->getWithPhrase($aRow['var_name']);
         $bIsEdit = true;
         $aTypes = Admincp_Service_Menu_Menu::instance()->getTypes();
         if (!in_array($aRow['m_connection'], $aTypes)) {
             $aRow['m_connection'] = $aRow['m_connection'];
         }
         $this->template()->assign(array('aForms' => $aRow, 'aAccess' => empty($aRow['disallow_access']) ? null : unserialize($aRow['disallow_access'])));
     } else {
         $aLanguages = Phpfox::getService('language')->get();
     }
     if ($aVals = $this->request()->getArray('val')) {
         if ($bIsEdit) {
             $sMessage = Phpfox::getPhrase('admincp.menu_successfully_updated');
             Admincp_Service_Menu_Process::instance()->update($aRow['menu_id'], $aVals);
         } else {
             $sMessage = Phpfox::getPhrase('admincp.menu_successfully_added');
             Admincp_Service_Menu_Process::instance()->add($aVals);
         }
         if (isset($aVals['is_page'])) {
             $this->url()->send($aVals['url_value'], null, Phpfox::getPhrase('admincp.page_menu_successfully_added'));
         }
         if ($bIsEdit) {
             $this->url()->send('admincp.menu', null, $sMessage);
         } else {
             $this->url()->send('admincp.menu', null, $sMessage);
         }
     }
     $this->template()->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aModules' => Phpfox::getService('admincp.module')->getModules(), 'aParents' => Admincp_Service_Menu_Menu::instance()->get(array('menu.parent_id = 0 AND menu.m_connection IN(\'main\', \'main_right\')'), false), 'aControllers' => Phpfox::getService('admincp.component')->get(true), 'aPages' => Phpfox::getService('page')->getCache(), 'aLanguages' => $aLanguages, 'aUserGroups' => Phpfox::getService('user.group')->get(), 'aTypes' => $oAdmincpMenu->getTypes(), 'bIsEdit' => $bIsEdit, 'bIsPage' => $bIsPage))->setBreadcrumb(Phpfox::getPhrase('admincp.add_new_menu'), $this->url()->makeUrl('current'), true)->setTitle(Phpfox::getPhrase('admincp.add_new_menu'));
 }
Example #2
0
 /**
  * Controller
  */
 public function process()
 {
     if ($iDeleteId = $this->request()->getInt('delete')) {
         if (Admincp_Service_Menu_Process::instance()->delete($iDeleteId)) {
             $this->url()->send('admincp.menu', null, Phpfox::getPhrase('admincp.menu_successfully_deleted'));
         }
     }
     if ($aVals = $this->request()->getArray('val')) {
         if (Admincp_Service_Menu_Process::instance()->updateOrder($aVals)) {
             // $this->url()->send('admincp.menu', array('parent' => $this->request()->getInt('parent')), Phpfox::getPhrase('admincp.menu_order_successfully_updated'));
             return ['updated' => true];
         }
     }
     $iParentId = $this->request()->getInt('parent');
     if ($iParentId > 0) {
         $aMenu = Admincp_Service_Menu_Menu::instance()->getForEdit($iParentId);
         if (isset($aMenu['menu_id'])) {
             $this->template()->assign('aParentMenu', $aMenu);
         } else {
             $iParentId = 0;
         }
     }
     $aTypes = Admincp_Service_Menu_Menu::instance()->getTypes();
     $aRows = Admincp_Service_Menu_Menu::instance()->get($iParentId > 0 ? array('menu.parent_id = ' . (int) $iParentId) : array('menu.parent_id = 0 AND menu.m_connection IN(\'main\', \'footer\')'));
     $aMenus = array();
     $aModules = array();
     foreach ($aRows as $iKey => $aRow) {
         if (Phpfox::isModule($aRow['module_id'])) {
             if (!$iParentId && in_array($aRow['m_connection'], $aTypes)) {
                 $aMenus[$aRow['m_connection']][] = $aRow;
             } else {
                 $aModules[$aRow['m_connection']][] = $aRow;
             }
         }
     }
     unset($aRows);
     $this->template()->setBreadcrumb(Phpfox::getPhrase('admincp.menu_manager'), $this->url()->makeUrl('admincp.menu'))->setTitle(Phpfox::getPhrase('admincp.menu_manager'))->setSectionTitle('Menus')->setActionMenu(['Add Menu' => ['class' => 'popup', 'url' => $this->url()->makeUrl('admincp.menu.add')]])->setHeader(array('drag.js' => 'static_script', '<script type="text/javascript">$Behavior.coreDragInit = function() { Core_drag.init({table: \'#js_drag_drop\', ajax: \'' . $this->url()->makeUrl('admincp.menu') . '\'}); }</script>'))->assign(array('aMenus' => $aMenus, 'aModules' => $aModules, 'iParentId' => $iParentId));
 }
Example #3
0
 public function processJson($json)
 {
     if (isset($json->menu)) {
         \Admincp_Service_Menu_Process::instance()->add(['m_connection' => 'main', 'product_id' => 'phpfox', 'allow_all' => true, 'mobile_icon' => isset($json->menu->icon) ? $json->menu->icon : null, 'url_value' => $json->menu->url, 'text' => ['en' => $json->menu->name]]);
     }
 }
Example #4
0
<?php

return function (Phpfox_Installer $Installer) {
    $Installer->db->query("DELETE FROM " . Phpfox::getT('setting') . " WHERE `module_id`='share' AND `var_name`='share_on_facebook';");
    $Installer->db->query("DELETE FROM " . Phpfox::getT('block') . " WHERE `module_id`='pages' AND `m_connection`='pages.view' AND `component` = 'photo';");
    //https://github.com/moxi9/phpfox/issues/633
    $Installer->db->query("UPDATE " . Phpfox::getT('setting') . " SET `group_id` = 'registration' WHERE `module_id` = 'core' AND `var_name`='global_genders';");
    $Installer->db->query("DELETE FROM " . Phpfox::getT('setting') . " WHERE `module_id`='friend' AND `var_name`='birthdays_cache_time_out';");
    //UPDATE `core_default`.`phpfox_language_phrase` SET `text` = '{full_name} liked a comment you made on the page "{title}"' WHERE `phpfox_language_phrase`.`phrase_id` = 6250;
    //https://github.com/moxi9/phpfox/issues/406
    $Installer->db->query("UPDATE `" . Phpfox::getT('setting') . "` SET `value_actual`=1, `value_default`=1 WHERE `var_name`='hide_denied_requests_from_pending_list' AND `module_id`='friend';");
    $Installer->db->query("UPDATE `" . Phpfox::getT('language_phrase') . "` SET `text`='{full_name} liked a comment you made on the page \"{title}\"', `text_default`='{full_name} liked a comment you made on the page \"{title}\"' WHERE `var_name`='full_name_liked_a_comment_you_made_on_the_page_title' AND `module_id`='pages';");
    //Add pages menu
    $iCnt = 0;
    $iCnt = $Installer->db->select('COUNT(*)')->from(':menu')->where('m_connection="main" AND url_value="pages"')->count();
    if ($iCnt == 0 || empty($iCnt)) {
        $aVals = array('product_id' => 'phpfox', 'module_id' => 'core|core', 'm_connection' => 'main', 'url_value' => 'pages', 'mobile_icon' => 'th', 'text' => array('en' => 'Pages'), 'allow_all' => true);
        Admincp_Service_Menu_Process::instance()->add($aVals);
    }
};
Example #5
0
 public function delete($iId)
 {
     $aPage = Phpfox::getService('page')->getPage($iId);
     if (isset($aPage['page_id'])) {
         $this->database()->delete($this->_sTable, 'page_id = ' . $aPage['page_id']);
         $this->database()->delete(Phpfox::getT('page_log'), 'page_id = ' . $aPage['page_id']);
         $this->database()->delete(Phpfox::getT('page_text'), 'page_id = ' . $aPage['page_id']);
         Admincp_Service_Menu_Process::instance()->delete($aPage['title_url'], true);
         if (Phpfox::isModule('attachment')) {
             Phpfox::getService('attachment.process')->deleteForItem(null, $aPage['page_id'], 'page');
         }
         Phpfox::isModule('tag') ? Phpfox::getService('tag.process')->deleteForItem($aPage['user_id'], $aPage['page_id'], 'page') : null;
         $this->cache()->remove('page', 'substr');
         $this->cache()->remove('menu', 'substr');
     }
     return true;
 }
Example #6
0
 public function processJson($json, $base)
 {
     if (isset($json->menu)) {
         \Admincp_Service_Menu_Process::instance()->add(['m_connection' => 'main', 'product_id' => 'phpfox', 'allow_all' => true, 'mobile_icon' => isset($json->menu->icon) ? $json->menu->icon : null, 'url_value' => $json->menu->url, 'text' => ['en' => $json->menu->name]]);
     }
     if (file_exists($base . 'installer.php')) {
         \Core\App\Installer::$method = 'onInstall';
         \Core\App\Installer::$basePath = $base;
         require_once $base . 'installer.php';
     }
 }
Example #7
0
 public function delete()
 {
     if ($this->menu && isset($this->menu->url)) {
         \Phpfox_Database::instance()->delete(':menu', ['m_connection' => 'main', 'url_value' => $this->menu->url]);
     }
     (new \Core\Home(PHPFOX_LICENSE_ID, PHPFOX_LICENSE_KEY))->uninstall(['product_id' => $this->internal_id]);
     $path = $this->path;
     /*https://github.com/moxi9/phpfox/issues/523*/
     $json_path = $path . 'app.json';
     if (file_exists($json_path)) {
         $json = json_decode(file_get_contents($json_path));
         //remove menu if exist
         if (isset($json->menu)) {
             \Admincp_Service_Menu_Process::instance()->delete($json->menu->url, true);
         }
     }
     if (is_dir($path)) {
         \Phpfox_File::instance()->delete_directory($path);
     }
     \Phpfox_Cache::instance()->remove();
 }