Exemplo n.º 1
0
 public function afterUninstall()
 {
     //Удаляем таблицу модуля
     Yii::app()->db->createCommand()->dropTable(Page::model()->tableName());
     Yii::app()->db->createCommand()->dropTable(PageTranslate::model()->tableName());
     return parent::afterUninstall();
 }
 protected function getModuleDefaultData()
 {
   return array_merge(parent::getModuleDefaultData(), array(
       'url'=>''
       )
   );
 }
Exemplo n.º 3
0
 public function afterUninstall()
 {
     Yii::app()->settings->clear('exchange1c');
     $db = Yii::app()->db;
     $db->createCommand()->dropTable('{{exchange1c}}');
     return parent::afterUninstall();
 }
Exemplo n.º 4
0
 /**
  * Module constructor - Builds the initial module data
  *
  * @author vadim
  */
 public function init()
 {
     // Set error handler
     Yii::app()->errorHandler->errorAction = 'site/error/error';
     /* Make sure we run the master module init function */
     parent::init();
 }
  protected function prepareAdminForSection($section, &$adminModule) {
    switch ($section) {
      case 'primary_modules':
      case 'secondary_modules':
        
        $adminModule->setTemplatePage('module_order', $this->id);
        $adminModule->addInternalJavascript("/modules/{$this->id}/javascript/admin.js");
        $adminModule->addInternalCSS("/modules/{$this->id}/css/admin.css");

        $allModules = $this->getAllModules();
        $navigationModules = $this->getNavigationModules();

        foreach ($allModules as $moduleID=>$module) {
          $allModules[$moduleID] = $module->getModuleName();
        }

        foreach ($navigationModules[rtrim($section,'_modules')] as $moduleID=>$module) {
          $sectionModules[$moduleID] = $module['title'];
        }
        
        $adminModule->assign('allModules', $allModules);
        $adminModule->assign('sectionModules', $sectionModules);
        break;
      default:
        return parent::prepareAdminForSection($section, $adminModule);
    }
  }
Exemplo n.º 6
0
 public function beforeControllerAction($controller, $action)
 {
     if (parent::beforeControllerAction($controller, $action)) {
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 7
0
 public function afterUninstall()
 {
     //Удаляем таблицу модуля
     Yii::app()->settings->clear('news');
     Yii::app()->db->createCommand()->dropTable(News::model()->tableName());
     Yii::app()->db->createCommand()->dropTable(NewsTranslate::model()->tableName());
     return parent::afterUninstall();
 }
Exemplo n.º 8
0
 public function initializeForCommand()
 {
     switch ($this->command) {
         case 'notice':
             $response = null;
             $responseVersion = 1;
             if ($this->getOptionalModuleVar('BANNER_ALERT', false, 'notice')) {
                 $noticeData = $this->getOptionalModuleSection('notice');
                 if ($noticeData) {
                     $response = array('notice' => '', 'moduleID' => null, 'link' => $this->getOptionalModuleVar('BANNER_ALERT_MODULE_LINK', false, 'notice'));
                     // notice can either take a module or data model class or retriever class. The section is passed on. It must implement the HomeAlertInterface interface
                     if (isset($noticeData['BANNER_ALERT_MODULE'])) {
                         $moduleID = $noticeData['BANNER_ALERT_MODULE'];
                         $controller = WebModule::factory($moduleID);
                         $response['moduleID'] = $moduleID;
                         $string = "Module {$moduleID}";
                     } elseif (isset($noticeData['BANNER_ALERT_MODEL_CLASS'])) {
                         $controller = DataModel::factory($noticeData['BANNER_ALERT_MODEL_CLASS'], $noticeData);
                         $string = $noticeData['BANNER_ALERT_MODEL_CLASS'];
                     } elseif (isset($noticeData['BANNER_ALERT_RETRIEVER_CLASS'])) {
                         $controller = DataRetriever::factory($noticeData['BANNER_ALERT_RETRIEVER_CLASS'], $noticeData);
                         $string = $noticeData['BANNER_ALERT_RETRIEVER_CLASS'];
                     } else {
                         throw new KurogoConfigurationException("Banner alert not properly configured");
                     }
                     if (!$controller instanceof HomeAlertInterface) {
                         throw new KurogoConfigurationException("{$string} does not implement HomeAlertModule interface");
                     }
                     $response['notice'] = $controller->getHomeScreenAlert();
                 }
             }
             $this->setResponse($response);
             $this->setResponseVersion($responseVersion);
             break;
         case 'modules':
             if ($setcontext = $this->getArg('setcontext')) {
                 Kurogo::sharedInstance()->setUserContext($setcontext);
             }
             $responseVersion = 2;
             $response = array('primary' => array(), 'secondary' => array(), 'customize' => $this->getOptionalModuleVar('ALLOW_CUSTOMIZE', true), 'displayType' => $this->getOptionalModuleVar('display_type', 'springboard'));
             $allmodules = $this->getAllModules();
             $navModules = Kurogo::getSiteSections('navigation', Config::APPLY_CONTEXTS_NAVIGATION);
             foreach ($navModules as $moduleID => $moduleData) {
                 if ($module = Kurogo::arrayVal($allmodules, $moduleID)) {
                     $title = Kurogo::arrayVal($moduleData, 'title', $module->getModuleVar('title'));
                     $type = Kurogo::arrayVal($moduleData, 'type', 'primary');
                     $visible = Kurogo::arrayVal($moduleData, 'visible', 1);
                     $response[$type][] = array('tag' => $moduleID, 'title' => $title, 'visible' => (bool) $visible);
                 }
             }
             $this->setResponse($response);
             $this->setResponseVersion($responseVersion);
             break;
         default:
             $this->invalidCommand();
     }
 }
Exemplo n.º 9
0
 public function afterUninstall()
 {
     $db = Yii::app()->db;
     $tablesArray = array(Wishlist::model()->tableName(), WishlistProducts::model()->tableName());
     foreach ($tablesArray as $table) {
         $db->createCommand()->dropTable($table);
     }
     return parent::afterUninstall();
 }
Exemplo n.º 10
0
 public function afterInstall()
 {
     if (Yii::app()->hasModule('shop')) {
         return parent::afterInstall();
     } else {
         Yii::app()->controller->addFlashMessage('Ошибка, Модуль интернет-магазин не устрановлен.');
         return false;
     }
 }
Exemplo n.º 11
0
 public function afterUninstall()
 {
     Yii::app()->settings->clear('contacts');
     $db = Yii::app()->db;
     $db->createCommand()->dropTable(ContactsMaps::model()->tableName());
     $db->createCommand()->dropTable(ContactsMarkers::model()->tableName());
     $db->createCommand()->dropTable(ContactsRouter::model()->tableName());
     $db->createCommand()->dropTable(ContactsRouterTranslate::model()->tableName());
     return parent::afterUninstall();
 }
Exemplo n.º 12
0
 public function afterUninstall()
 {
     $db = Yii::app()->db;
     $tablesArray = array(ShopDiscount::model()->tableName(), $db->tablePrefix . 'shop_discount_category', $db->tablePrefix . 'shop_discount_manufacturer');
     foreach ($tablesArray as $table) {
         $db->createCommand()->dropTable($table);
     }
     GridColumns::model()->deleteAll("grid_id='shopdiscount-grid'");
     return parent::afterUninstall();
 }
Exemplo n.º 13
0
 public function afterUninstall()
 {
     Yii::app()->settings->clear($this->id);
     $db = Yii::app()->db;
     $tablesArray = array(PollChoice::model()->tableName(), PollVote::model()->tableName(), Poll::model()->tableName());
     foreach ($tablesArray as $table) {
         $db->createCommand()->truncateTable($table);
         $db->createCommand()->dropTable($table);
     }
     return parent::afterUninstall();
 }
Exemplo n.º 14
0
 public function afterUninstall()
 {
     Yii::app()->settings->clear($this->id);
     //Yii::app()->unintallComponent('cart');
     $db = Yii::app()->db;
     $tablesArray = array(Order::model()->tableName(), OrderHistory::model()->tableName(), OrderProduct::model()->tableName(), OrderStatus::model()->tableName(), OrderProductHistroy::model()->tableName(), ShopPaymentMethod::model()->tableName(), ShopPaymentMethodTranslate::model()->tableName(), ShopDeliveryMethod::model()->tableName(), ShopDeliveryMethodTranslate::model()->tableName(), ShopDeliveryPayment::model()->tableName(), ProductNotifications::model()->tableName());
     foreach ($tablesArray as $table) {
         $db->createCommand()->dropTable($table);
     }
     return parent::afterInstall();
 }
Exemplo n.º 15
0
 /**
  * Module constructor - Builds the initial module data
  *
  * @author vadim
  */
 public function init()
 {
     Yii::app()->theme = $this->theme;
     // Set theme url
     Yii::app()->themeManager->setBaseUrl(Yii::app()->theme->baseUrl);
     Yii::app()->themeManager->setBasePath(Yii::app()->theme->basePath);
     // Set error handler
     Yii::app()->errorHandler->errorAction = 'admin/error/error';
     /* Make sure we run the master module init function */
     parent::init();
 }
  protected function prepareAdminForSection($section, &$adminModule) {
      switch ($section)
      {
          case 'feeds':
              $feeds = $this->loadFeedData();
              $adminModule->assign('feeds', $feeds);
              $adminModule->setTemplatePage('feedAdmin', $this->id);
              break;
          default:
              return parent::prepareAdminForSection($section, $adminModule);
      }
 }
Exemplo n.º 17
0
 protected function getCreditsHTML()
 {
     //get original device
     $device = Kurogo::deviceClassifier()->getDevice();
     //set browser to unknown so we don't get AppQ HTML
     Kurogo::deviceClassifier()->setBrowser('unknown');
     $module = WebModule::factory($this->configModule, 'credits_html');
     $html = $module->fetchPage();
     //restore device
     Kurogo::deviceClassifier()->setDevice($device);
     return $html;
 }
Exemplo n.º 18
0
 protected function getModuleAdminConfig() {
     $configData = parent::getModuleAdminConfig();
     
     foreach ($this->getFeedGroups() as $feedgroup=>$data) {
         $feedData = $configData['feed'];
         $feedData['title'] = $data['title'];
         $feedData['config'] = 'feeds-' . $feedgroup;
         $configData['feeds-'.$feedgroup] = $feedData;
     }
     unset($configData['feed']);
     
     return $configData;
 }
Exemplo n.º 19
0
 public function afterUninstall()
 {
     Yii::app()->settings->clear('shop');
     Yii::app()->unintallComponent('currency');
     $db = Yii::app()->db;
     $tablesArray = array(ShopTypeAttribute::model()->tableName(), ShopAttribute::model()->tableName(), ShopAttributeOption::model()->tableName(), ShopAttributeOptionTranslate::model()->tableName(), ShopAttributeTranslate::model()->tableName(), ShopCategory::model()->tableName(), ShopCategoryTranslate::model()->tableName(), ShopCurrency::model()->tableName(), ShopManufacturer::model()->tableName(), ShopManufacturerTranslate::model()->tableName(), ShopProduct::model()->tableName(), ShopProductCategoryRef::model()->tableName(), ShopProductImage::model()->tableName(), ShopProductTranslate::model()->tableName(), ShopProductType::model()->tableName(), ShopProductVariant::model()->tableName(), ShopRelatedProduct::model()->tableName(), ShopSuppliers::model()->tableName(), $db->tablePrefix . 'shop_product_attribute_eav', $db->tablePrefix . 'shop_product_configurable_attributes', $db->tablePrefix . 'shop_product_configurations');
     foreach ($tablesArray as $table) {
         $db->createCommand()->dropTable($table);
     }
     CFileHelper::removeDirectory(Yii::getPathOfAlias('webroot.uploads.product'), array('traverseSymlinks' => true));
     CFileHelper::removeDirectory(Yii::getPathOfAlias('webroot.uploads.categories'), array('traverseSymlinks' => true));
     CFileHelper::removeDirectory(Yii::getPathOfAlias('webroot.uploads.manufacturer'), array('traverseSymlinks' => true));
     return parent::afterUninstall();
 }
Exemplo n.º 20
0
 protected function prepareAdminForSection($section, &$adminModule) {
   switch ($section) {
     case 'links':
       $adminModule->setTemplatePage('admin_links', $this->id);
       $adminModule->addInternalJavascript("/modules/{$this->id}/javascript/admin.js");
       $adminModule->addInternalCSS("/modules/{$this->id}/css/admin.css");
       $links = $this->getModuleArray('links');
       $adminModule->assign('links', $links);
       break;
     default:
       return parent::prepareAdminForSection($section, $adminModule);
       break;
   }
 }
    protected function prepareAdminForSection($section, &$adminModule) {
        switch ($section)
        {
            case 'feeds':
                $feeds = $this->loadFeedData();
                $adminModule->addInternalJavascript("/modules/content/javascript/admin.js");
//                $adminModule->addInternalCSS("/modules/content/css/admin.css");
                $adminModule->assign('feeds', $feeds);
                $adminModule->assign('showFeedLabels', true);
                $adminModule->assign('showNew', true);
                $adminModule->assign('content_types', array(
                    'html'=>'HTML (editable)',
                    'html_url'=>'HTML (remote)',
                    'rss'=>'RSS (remote)'
                ));
                $adminModule->setTemplatePage('feedAdmin', 'content');
                break;
            default:
                return parent::prepareAdminForSection($section, $adminModule);
        }
   }
  protected function getModuleItemForKey($key, $value) {
    $item = array(
        'label'=>ucfirst($key),
        'name'=>"moduleData[$key]",
        'typename'=>"moduleData][$key",
        'value'=>$value,
        'type'=>'text'
    );

    switch ($key) {
        case 'ABOUT_HTML':
        case 'SITE_ABOUT_HTML':
            $item['type'] = 'paragraph';
            break;
        default:
            return parent::getModuleItemForKey($key, $value);
            break;
    }
    
    return $item;
  }
Exemplo n.º 23
0
 public function initializeForCommand()
 {
     switch ($this->command) {
         case 'notice':
             $response = null;
             $responseVersion = 1;
             if ($this->getOptionalModuleVar('BANNER_ALERT', false, 'notice')) {
                 $noticeData = $this->getOptionalModuleSection('notice');
                 if ($noticeData) {
                     $response = array('notice' => '', 'moduleID' => null, 'link' => $this->getOptionalModuleVar('BANNER_ALERT_MODULE_LINK', false, 'notice'));
                     // notice can either take a module or data model class or retriever class. The section is passed on. It must implement the HomeAlertInterface interface
                     if (isset($noticeData['BANNER_ALERT_MODULE'])) {
                         $moduleID = $noticeData['BANNER_ALERT_MODULE'];
                         $controller = WebModule::factory($moduleID);
                         $response['moduleID'] = $moduleID;
                         $string = "Module {$moduleID}";
                     } elseif (isset($noticeData['BANNER_ALERT_MODEL_CLASS'])) {
                         $controller = DataModel::factory($noticeData['BANNER_ALERT_MODEL_CLASS'], $noticeData);
                         $string = $noticeData['BANNER_ALERT_MODEL_CLASS'];
                     } elseif (isset($noticeData['BANNER_ALERT_RETRIEVER_CLASS'])) {
                         $controller = DataRetriever::factory($noticeData['BANNER_ALERT_RETRIEVER_CLASS'], $noticeData);
                         $string = $noticeData['BANNER_ALERT_RETRIEVER_CLASS'];
                     } else {
                         throw new KurogoConfigurationException("Banner alert not properly configured");
                     }
                     if (!$controller instanceof HomeAlertInterface) {
                         throw new KurogoConfigurationException("{$string} does not implement HomeAlertModule interface");
                     }
                     $response['notice'] = $controller->getHomeScreenAlert();
                 }
             }
             $this->setResponse($response);
             $this->setResponseVersion($responseVersion);
             break;
         default:
             $this->invalidCommand();
     }
 }
Exemplo n.º 24
0
  protected function createDefaultFile($file, $type)
  {
    switch ($type)
    {
        case 'site':
            $_file = $this->getFileByType($file, $type);
            $defaultFile = $this->getFileByType($file, $type.'-default');
            if (file_exists($defaultFile)) {
                $this->createDirIfNotExists(dirname($_file));
                return @copy($defaultFile, $_file);
            }
            
            return false;
            break;
            
        case 'module':
            //check to see if the module has a default config file first
            $_file = $this->getFileByType($file, $type);
            $defaultFile = $this->getFileByType($file, $type.'-default');
            if (file_exists($defaultFile)) {
                $this->createDirIfNotExists(dirname($_file));
                return @copy($defaultFile, $_file);
            } elseif ($module = WebModule::factory($file)) {
                return $module->createDefaultConfigFile();
            } else {
                throw new Exception("Module $file not found");
            }
            break;
        case 'file':
            $defaultFile = $this->getFileByType($file, $type.'-default');
            if (file_exists($defaultFile)) {
                $this->createDirIfNotExists(dirname($file));
                return @copy($defaultFile, $file);
            }

            return false;            
            break;
    }
  }
Exemplo n.º 25
0
  protected function initializeForPage() {
        $this->addJQuery();
        switch ($this->page)
        {
             case 'module':
                $moduleID = $this->getArg('moduleID');
                if (empty($moduleID)) {
                    $this->redirectTo('modules');
                }

                $module = WebModule::factory($moduleID);
                $moduleData = $module->getModuleData();
                $moduleSections = array();
                
                if ($section = $this->getArg('section')) {
                    
                    if ($section=='feeds' && $module->hasFeeds()) {
                        if (strlen($this->getArg('removeFeed'))>0) {
                            $index = $this->getArg('removeFeed');
                            $module->removeFeed($index);
                        }

                        if ($this->getArg('addFeed')) {
                            $feedData = $this->getArg('addFeedData');
                            if (!$module->addFeed($feedData, $error)) {
                                $this->assign('errorMessage', $error);
                            }
                        }

                        $moduleData['feeds'] = $module->loadFeedData();
                        if (!$moduleData['feeds']) {
                            $moduleData['feeds'] = array();
                        }
                        $this->assign('feedURL', $this->buildBreadcrumbURL('module', array(
                                'moduleID'=>$moduleID,
                                'section'=>$section),false
                            ));
                        $this->assign('feedFields', $module->getFeedFields());
                    } elseif (!isset($moduleData[$section])) {
                        $this->redirectTo('module', array('moduleID'=>$moduleID), false);
                    }
                }

                if ($this->getArg('submit')) {
                    $merge = $this->getArg('merge', true);
                    if ($merge) {
                        $moduleData = $this->prepareSubmitData('moduleData');
                        $moduleData = array_merge($module->getModuleDefaultData(), $moduleData);
                    } else {
                        $moduleData = $this->prepareSubmitData('moduleData');
                    }

                    if ($section) {
                        $moduleData = array($section=>$moduleData[$section]);
                    } else {
                        /* only include the scalar values since array values come from sections */
                        $_data = array();
                        foreach ($moduleData as $var=>$val) {
                            if (is_scalar($val)) {
                                $_data[$var] = $val;
                            }
                            $moduleData = $_data;
                        }
                    }

                    $module->saveConfig($moduleData, $section);
                    if ($section) {
                        $this->redirectTo('module', array('moduleID'=>$moduleID), false);
                    } else {
                        $this->redirectTo('modules', false, false);
                    }
                } 
                
                $this->setPageTitle(sprintf("Administering %s module", $moduleData['title']));
                $this->setBreadcrumbTitle($moduleData['title']);
                $this->setBreadcrumbLongTitle($moduleData['title']);
                
                
                $formListItems = array();

                if ($section) {
                    $moduleData = $moduleData[$section];
                } else {
                   $formListItems[] = $this->getModuleItemForKey('id', $moduleID);
                }
                
                foreach ($moduleData as $key=>$value) {
                    if (is_scalar($value)) {
                        $formListItems[] = $module->getModuleItemForKey($key, $value);
                    } else {
                        $moduleSections[$key] = $module->getSectionTitleForKey($key);
                    }
                }
                
                if (!$section) {
                    foreach ($moduleSections as $key=>$title) {
                        $formListItems[] = array(
                            'type'=>'url',
                            'name'=>$title,
                            'value'=>$this->buildBreadcrumbURL('module', array(
                                'moduleID'=>$moduleID,
                                'section'=>$key)
                            )
                        );
                    }

                    if ($module->hasFeeds()) {
                        $formListItems[] = array(
                            'type'=>'url',
                            'name'=>'Data Configuration',
                            'value'=>$this->buildBreadcrumbURL('module', array(
                                'moduleID'=>$moduleID,
                                'section'=>'feeds')
                            )
                        );
                    }

                    $formListItems[] = array(
                        'type'=>'url',
                        'name'=>'Page Data',
                        'value'=>$this->buildBreadcrumbURL('pageData', array(
                            'moduleID'=>$moduleID
                            )
                        )
                    );
                } 
                
                $_module = array(
                    'id'=>$moduleID
                );

                $this->assign('formListItems', $formListItems);
                $this->assign('module'       , $_module);
                $this->assign('section'      , $section);

                if ($section) {
                    $module->prepareAdminForSection($section, $this);
                }
                break;

            case 'modules':
                $allModules = $this->getAllModules();
                $moduleList = array();

                foreach ($allModules as $moduleID=>$moduleData) {
                    try {
                        $moduleList[] = array(
                            'img'=>"/modules/home/images/{$moduleID}.png",
                            'title'=>$moduleData->getModuleName(),
                            'url'=>$this->buildBreadcrumbURL('module', array(
                                'moduleID'=>$moduleID
                                )
                            )
                        );
                        $this->assign('moduleList', $moduleList);
                        
                    } catch(Exception $e) {}
                }
            
                break;
            case 'pageData':
                $moduleID = $this->getArg('moduleID');
                if (empty($moduleID)) {
                    $this->redirectTo('modules');
                }

                $module = WebModule::factory($moduleID);
                $pageData = $module->getPageData();

                if ($this->getArg('submit')) {
                    $pageData = $this->prepareSubmitData('pageData');
                    $module->saveConfig(array('nav'=>$pageData), 'nav');
                } 
                
                $this->setPageTitle(sprintf("Administering Page Data for %s", $module->getModuleName()));
                $pages = array();

                foreach ($pageData as $page=>$_pageData) {
                    $item = array();
                    $item[] = array(
                        'label'=>'Page',
                        'type'=>'label',
                        'value'=>$page
                    );
                    $item[] = array(
                        'label'=>'Title',
                        'type'=>'text',
                        'name'=>"pageData[$page][pageTitle]",
                        'typename'=>"pageData][$page][pageTitle",
                        'value'=>isset($_pageData['pageTitle']) ? $_pageData['pageTitle'] : ''
                    );
                    $item[] = array(
                        'label'=>'Breadcrumb Title',
                        'type'=>'text',
                        'name'=>"pageData[$page][breadcrumbTitle]",
                        'typename'=>"pageData][$page][breadcrumbTitle",
                        'value'=>isset($_pageData['breadcrumbTitle']) ? $_pageData['breadcrumbTitle'] : ''
                    );
                    $item[] = array(
                        'label'=>'Breadcrumb Long Title',
                        'type'=>'text',
                        'name'=>"pageData[$page][breadcrumbLongTitle]",
                        'typename'=>"pageData][$page][breadcrumbLongTitle",
                        'value'=>isset($_pageData['breadcrumbLongTitle']) ? $_pageData['breadcrumbLongTitle'] : ''
                    );
                    $pages[$page] = $item;
                }
                
                $_module = array(
                    'id'=>$moduleID
                );

                $this->assign('pages'        , $pages);
                $this->assign('module'       , $_module);

                break;
            case 'strings':
                $configFile = ConfigFile::factory('strings', 'site', ConfigFile::OPTION_CREATE_WITH_DEFAULT | ConfigFile::OPTION_IGNORE_LOCAL);

                if ($this->getArg('submit')) {
                    $strings = $this->prepareSubmitData('strings');
                    $configFile->addSectionVars($strings, false);
                    $configFile->saveFile();
                    $this->redirectTo('index', false, false);
                } 

                $strings = $configFile->getSectionVars(true);
                $formListItems = array();
                foreach ($strings as $key=>$value) {
                    if (is_scalar($value)) {
                        $formListItems[] = array(
                        'label'=>implode(" ", array_map("ucfirst", explode("_", strtolower($key)))),
                        'name'=>"strings[$key]",
                        'typename'=>"strings][$key",
                        'value'=>$value,
                        'type'=>'text'
                        );
                    } else {
                        $formListItems[] = array(
                        'label'=>implode(" ", array_map("ucfirst", explode("_", strtolower($key)))),
                        'name'=>"strings[$key]",
                        'typename'=>"strings][$key",
                        'value'=>implode("\n\n", $value),
                        'type'=>'paragraph'
                        );
                    }
                }

                $this->assign('localFile'    , $configFile->localFile());
                $this->assign('strings', $strings);
                $this->assign('formListItems', $formListItems);
                break;

            case 'site':
                $configFile = ConfigFile::factory('config', 'site', ConfigFile::OPTION_IGNORE_LOCAL);
                $siteVars = $configFile->getSectionVars();

                if ($section = $this->getArg('section')) {
                
                    if (!isset($siteVars[$section])) {
                        $section = null;
                    }
                }
                
                $formListItems = array();

                if ($section) {

                    if ($this->getArg('submit')) {
                        $sectionVars = $this->prepareSubmitData('siteData');
                        $configFile->addSectionVars($sectionVars, true);
                        $configFile->saveFile();
                        $this->redirectTo('site', false, false);
                    }

                    $formListItems = array();
                    $sectionVars = $configFile->getSection($section);

                    foreach ($sectionVars as $key=>$value) {
                        $formListItems[] = $this->getSiteItemForKey($section, $key, $value);
                    }

                } else {
                    foreach ($siteVars as $sectionName=>$sectionVars){
                        $formListItems[] = array(
                            'type'=>'url',
                            'name'=>$this->getSectionTitleForKey($sectionName),
                            'value'=>$this->buildBreadcrumbURL('site', array(
                                'section'=>$sectionName
                                )
                            )
                        );
                    }
                }
                                            
                $this->assign('localFile'    , $configFile->localFile());
                $this->assign('section'      , $section);
                $this->assign('formListItems', $formListItems);
                
                break;

            case 'sessions';
                $session = $this->getSession();
                
                if ($this->getArg('deleteSession')) {
                    $sessionID = key($this->getArg('deleteSession'));
                    // you can't delete your own session
                    if ($sessionID != $session->getSessionID()) {
                        $session->deleteSession($sessionID);
                    }
                }
                
                $activeSessions = $session->getActiveSessions();
                $sessions = array();

                foreach ($activeSessions as $sessionID=>$sessionData) {
                    $sessionItem = array(
                        'label'=>$sessionData['userID'] . " (" . $sessionData['auth'] . ")",
                        'subtitle'=>'Last Access: ' . date('m/d/y H:i:s', $sessionData['ping'])
                    );
                    
                    // you can't delete your own session
                    if ($sessionID != $session->getSessionID()) {
                        $sessionItem['name'] ='deleteSession[' . $sessionID . ']';
                        $sessionItem['type'] ='submit';
                        $sessionItem['confirm'] = true;
                        $sessionItem['value'] = 'Delete';
                    }

                    $sessions[] = $sessionItem;
                }
                
                $this->assign('sessions', $sessions);
                break;

            case 'index':
                $adminList = array();
                $adminList[] = array(
                    'title'=>'Modules',
                    'url'=>$this->buildBreadcrumbURL('modules', array()),
                    'subtitle'=>'Manage module configuration and data'
                );
                $adminList[] = array(
                    'title'=>'Site Configuration',
                    'url'=>$this->buildBreadcrumbURL('site', array()),
                    'subtitle'=>'Manage site-wide configuration'
                );
                $adminList[] = array(
                    'title'=>'String Configuration',
                    'url'=>$this->buildBreadcrumbURL('strings', array()),
                    'subtitle'=>'Update textual strings used throughout the site'
                );
                if ($this->getSiteVar('AUTHENTICATION_ENABLED')) {
                    $adminList[] = array(
                        'title'=>'User Sessions',
                        'url'=>$this->buildBreadcrumbURL('sessions', array()),
                        'subtitle'=>'View and manage active user sessions'
                    );
                }
                $this->assign('adminList', $adminList);
                break;
  
        }  
        
  }
Exemplo n.º 26
0
 public function initializeForCommand()
 {
     $this->requiresAdmin();
     switch ($this->command) {
         case 'checkversion':
             $current = Kurogo::sharedInstance()->checkCurrentVersion();
             Kurogo::log(LOG_INFO, sprintf("Checking version. This site: %s Current Kurogo Version: %s", $current, KUROGO_VERSION), 'admin');
             $uptodate = version_compare(KUROGO_VERSION, $current, ">=");
             $messageKey = $uptodate ? 'KUROGO_VERSION_MESSAGE_UPTODATE' : 'KUROGO_VERSION_MESSAGE_NOTUPDATED';
             $data = array('current' => $current, 'local' => KUROGO_VERSION, 'uptodate' => $uptodate, 'message' => $this->getLocalizedString($messageKey, $current, KUROGO_VERSION));
             $this->setResponse($data);
             $this->setResponseVersion(1);
             break;
         case 'getlocalizedstring':
             $key = $this->getArg('key');
             $data = array();
             if (is_array($key)) {
                 foreach ($key as $k) {
                     $data[$k] = $this->getLocalizedString($k);
                 }
             } else {
                 $data[$key] = $this->getLocalizedString($key);
             }
             $this->setResponse($data);
             $this->setResponseVersion(1);
             break;
         case 'clearcaches':
             Kurogo::log(LOG_NOTICE, "Clearing Site Caches", 'admin');
             $result = Kurogo::sharedInstance()->clearCaches();
             if ($result === 0) {
                 $this->setResponse(true);
                 $this->setResponseVersion(1);
             } else {
                 $this->throwError(new KurogoError(1, "Error clearing caches", "There was an error ({$result}) clearing the caches"));
             }
             break;
         case 'upload':
             $type = $this->getArg('type');
             $section = $this->getArg('section', '');
             $subsection = null;
             switch ($type) {
                 case 'module':
                     $moduleID = $this->getArg('module', '');
                     $module = WebModule::factory($moduleID);
                     $type = $module;
                     break;
                 case 'site':
                     break;
                 default:
                     throw new KurogoConfigurationException("Invalid type {$type}");
             }
             if (count($_FILES) == 0) {
                 throw new KurogoException("No files uploaded");
             }
             foreach ($_FILES as $key => $uploadData) {
                 $this->uploadFile($type, $section, $subsection, $key, $uploadData);
             }
             $this->setResponseVersion(1);
             $this->setResponse(true);
             break;
         case 'getconfigsections':
             $type = $this->getArg('type');
             switch ($type) {
                 case 'module':
                     $moduleID = $this->getArg('module', '');
                     $module = WebModule::factory($moduleID);
                     $sections = $module->getModuleAdminSections();
                     break;
                 case 'site':
                     throw new KurogoConfigurationException("getconfigsections for site not handled yet");
             }
             $this->setResponse($sections);
             $this->setResponseVersion(1);
             break;
         case 'getconfigdata':
             $type = $this->getArg('type');
             $section = $this->getArg('section', '');
             switch ($type) {
                 case 'module':
                     $moduleID = $this->getArg('module', '');
                     $module = WebModule::factory($moduleID);
                     $adminData = $this->getAdminData($module, $section);
                     break;
                 case 'site':
                     $adminData = $this->getAdminData('site', $section);
                     break;
             }
             $this->setResponse($adminData);
             $this->setResponseVersion(1);
             break;
         case 'setconfigdata':
             $type = $this->getArg('type');
             $data = $this->getArg('data', array());
             $section = $this->getArg('section', '');
             $subsection = null;
             if (empty($data)) {
                 $data = array();
             } elseif (!is_array($data)) {
                 throw new KurogoConfigurationException("Invalid data for {$type} {$section}");
             }
             switch ($type) {
                 case 'module':
                     if ($section == 'overview') {
                         foreach ($data as $moduleID => $props) {
                             $module = WebModule::factory($moduleID);
                             if (!is_array($props)) {
                                 throw new KurogoConfigurationException("Invalid properties for {$type} {$section}");
                             }
                             $valid_props = array('protected', 'secure', 'disabled', 'search');
                             foreach ($props as $key => $value) {
                                 if (!in_array($key, $valid_props)) {
                                     throw new KurogoConfigurationException("Invalid property {$key} for module {$module}");
                                 }
                                 $this->setConfigVar($module, 'general', $subsection, $key, $value);
                             }
                         }
                         foreach ($this->changedConfigs as $config) {
                             $config->saveFile();
                         }
                         $this->setResponse(true);
                         $this->setResponseVersion(1);
                         break 2;
                     } else {
                         $moduleID = $this->getArg('module', '');
                         $module = WebModule::factory($moduleID);
                         $type = $module;
                     }
                     break;
                 case 'site':
                     break;
                 default:
                     throw new KurogoConfigurationException("Invalid type {$type}");
             }
             foreach ($data as $section => $fields) {
                 $adminData = $this->getAdminData($type, $section);
                 if ($adminData['sectiontype'] == 'sections') {
                     $subsection = key($fields);
                     $fields = current($fields);
                     $adminData = $this->getAdminData($type, $section, $subsection);
                 }
                 $fields = is_array($fields) ? $fields : array();
                 foreach ($fields as $key => $value) {
                     if ($adminData['sectiontype'] == 'section' && isset($adminData['sectionclearvalues']) && $adminData['sectionclearvalues']) {
                         if ($config = $this->getAdminConfig($type, $adminData['config'], ConfigFile::OPTION_DO_NOT_CREATE)) {
                             $config->removeSection($key);
                         }
                     }
                     // ignore prefix values. We'll put it back together later
                     if (preg_match("/^(.*?)_prefix\$/", $key, $bits)) {
                         continue;
                     }
                     $prefix = isset($fields[$key . '_prefix']) ? $fields[$key . '_prefix'] : '';
                     if ($prefix && defined($prefix)) {
                         $value = constant($prefix) . '/' . $value;
                     }
                     $this->setConfigVar($type, $section, $subsection, $key, $value);
                 }
             }
             if ($sectionorder = $this->getArg('sectionorder')) {
                 foreach ($sectionorder as $section => $order) {
                     $this->setSectionOrder($type, $section, $subsection, $order);
                 }
             }
             foreach ($this->changedConfigs as $config) {
                 $config->saveFile();
             }
             $this->setResponse(true);
             $this->setResponseVersion(1);
             break;
         case 'removeconfigsection':
             $type = $this->getArg('type');
             $section = $this->getArg('section', '');
             $key = $this->getArg('key', null);
             switch ($type) {
                 case 'site':
                     $subsection = $this->getArg('subsection', null);
                     $sectionData = $this->getAdminData($type, $section, $subsection);
                     $config = ConfigFile::factory($sectionData['config'], 'site');
                     break;
                 case 'module':
                     $moduleID = $this->getArg('module', '');
                     $module = WebModule::factory($moduleID);
                     $sectionData = $this->getAdminData($module, $section);
                     $config = $module->getConfig($sectionData['config']);
                     break;
                 default:
                     throw new KurogoConfigurationException("Invalid type {$type}");
             }
             if (!isset($sectionData['sections']) || (!isset($sectionData['sectiondelete']) || !$sectionData['sectiondelete'])) {
                 throw new KurogoConfigurationException("Config '{$section}' of module '{$moduleID}' does not permit removal of items");
             }
             if (!isset($sectionData['sections'][$key])) {
                 throw new KurogoConfigurationException("Section {$key} not found in config '{$section}' of module '{$moduleID}'");
             }
             Kurogo::log(LOG_NOTICE, "Removing section {$section} from " . $this->getTypeStr($type) . " {$subsection}", 'admin');
             if (!($result = $config->removeSection($key))) {
                 throw new KurogoException("Error removing item {$key} from config '" . $sectionData['config'] . "'");
             } else {
                 $config->saveFile();
             }
             $this->setResponse(true);
             $this->setResponseVersion(1);
             break;
         case 'setmodulelayout':
             Kurogo::log(LOG_NOTICE, "Updating module layout", 'admin');
             $data = $this->getArg('data', array());
             $config = ModuleConfigFile::factory('home', 'module');
             if (!isset($data['primary_modules'])) {
                 $data['primary_modules'] = array();
             }
             $config->setSection('primary_modules', $data['primary_modules']);
             if (!isset($data['secondary_modules'])) {
                 $data['secondary_modules'] = array();
             }
             $config->setSection('secondary_modules', $data['secondary_modules']);
             $config->saveFile();
             $this->setResponse(true);
             $this->setResponseVersion(1);
             break;
         default:
             $this->invalidCommand();
             break;
     }
 }
Exemplo n.º 27
0
<?php

$lines = array('User-agent: *', 'Allow: ' . URL_BASE, 'Disallow: ' . URL_BASE . 'rest/');
foreach (WebModule::getAllModules() as $module) {
    if (!$module->allowRobots()) {
        $lines[] = 'Disallow: ' . URL_BASE . $module->getConfigModule() . '/';
    }
}
$output = implode("\n", $lines) . "\n";
header('Content-type: text/plain');
print $output;
Exemplo n.º 28
0
 public static function searchItems($moduleID, $searchTerms, $limit = null, $options = null)
 {
     $module = WebModule::factory($moduleID);
     return $module->searchItems($searchTerms, $limit, $options);
 }
Exemplo n.º 29
0
 public function isEnabled()
 {
     return Kurogo::getSiteVar('AUTHENTICATION_ENABLED') && parent::isEnabled();
 }
Exemplo n.º 30
0
          $parts[0] = $url_redirects[$id];
          $url = URL_PREFIX . implode("/", $parts);
        }
        header("Location: " . $url);
        exit;
      }
    }
    
    // find the page part
    if (isset($parts[1])) {
      if (strlen($parts[1])) {
        $page = basename($parts[1], '.php');
      }
      
    } else {
      // redirect with trailing slash for completeness
      header("Location: ./$id/");
      exit;
    }

    if ($module = WebModule::factory($id, $page, $args)) {
        /* log this page view */
        PageViews::increment($id, Kurogo::deviceClassifier()->getPlatform());
        
        $module->displayPage();
    } else {
        throw new Exception("Module $id cannot be loaded");
    }
}
exit;