diff --git a/application/modules/default/Bootstrap.php b/application/modules/default/Bootstrap.php index 862c3ffff..1ff8eed6b 100644 --- a/application/modules/default/Bootstrap.php +++ b/application/modules/default/Bootstrap.php @@ -1,1268 +1,1267 @@ . **/ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { /** * @return Zend_Application_Module_Autoloader * @throws Zend_Loader_Exception */ protected function _initAutoload() { $autoloader = new Zend_Application_Module_Autoloader(array( 'namespace' => 'Default', 'basePath' => realpath(dirname(__FILE__)), )); $autoloader->addResourceType('formelements', 'forms/elements', 'Form_Element'); $autoloader->addResourceType('formvalidators', 'forms/validators', 'Form_Validator'); return $autoloader; } /** * @throws Zend_Exception * @throws Zend_Session_Exception */ protected function _initSessionManagement() { $config = $this->getOption('settings')['session']; $domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false; if ($config['saveHandler']['replace']['enabled']) { $cacheClass = 'Zend_Cache_Backend_' . $config['saveHandler']['cache']['type']; $_cache = new $cacheClass($config['saveHandler']['options']); Zend_Loader::loadClass($config['saveHandler']['class']); Zend_Session::setSaveHandler(new $config['saveHandler']['class']($_cache)); Zend_Session::setOptions(array( 'cookie_domain' => $domain, 'cookie_path' => $config['auth']['cookie_path'], 'cookie_lifetime' => $config['auth']['cookie_lifetime'], 'cookie_httponly' => $config['auth']['cookie_httponly']) ); Zend_Session::start(); } $session_namespace = new Zend_Session_Namespace($config['auth']['name']); $session_namespace->setExpirationSeconds($config['auth']['cookie_lifetime']); Zend_Auth::getInstance()->setStorage(new Zend_Auth_Storage_Session($session_namespace->getNamespace())); } protected function _initConfig() { /** $config Zend_Config */ $config = $this->getApplication()->getApplicationConfig(); Zend_Registry::set('config', $config); return $config; } /** * @return mixed|null|Zend_Cache_Core|Zend_Cache_Frontend * @throws Zend_Cache_Exception * @throws Zend_Exception */ protected function _initCache() { if (Zend_Registry::isRegistered('cache')) { return Zend_Registry::get('cache'); } $cache = null; $options = $this->getOption('settings'); if (true == $options['cache']['enabled']) { $cache = Zend_Cache::factory( $options['cache']['frontend']['type'], $options['cache']['backend']['type'], $options['cache']['frontend']['options'], $options['cache']['backend']['options'] ); } else { // Fallback settings for some (maybe development) environments which have no cache management installed. if (false === is_writeable(APPLICATION_CACHE)) { error_log('directory for cache files does not exists or not writable: ' . APPLICATION_CACHE); exit('directory for cache files does not exists or not writable: ' . APPLICATION_CACHE); } $frontendOptions = array( 'lifetime' => 600, 'automatic_serialization' => true, 'cache_id_prefix' => 'front_cache', 'cache' => true ); $backendOptions = array( 'cache_dir' => APPLICATION_CACHE, 'file_locking' => true, 'read_control' => true, 'read_control_type' => 'crc32', 'hashed_directory_level' => 1, 'hashed_directory_perm' => 0700, 'file_name_prefix' => 'ocs', 'cache_file_perm' => 0700 ); $cache = Zend_Cache::factory( 'Core', 'File', $frontendOptions, $backendOptions ); } Zend_Registry::set('cache', $cache); Zend_Locale::setCache($cache); Zend_Locale_Data::setCache($cache); Zend_Currency::setCache($cache); Zend_Translate::setCache($cache); Zend_Translate_Adapter::setCache($cache); Zend_Db_Table_Abstract::setDefaultMetadataCache($cache); Zend_Paginator::setCache($cache); return $cache; } /** * @throws Zend_Application_Bootstrap_Exception */ protected function _initViewConfig() { $view = $this->bootstrap('view')->getResource('view'); $view->addHelperPath(APPLICATION_PATH . '/modules/default/views/helpers', 'Default_View_Helper_'); $view->addHelperPath(APPLICATION_LIB . '/Zend/View/Helper', 'Zend_View_Helper_'); $options = $this->getOptions(); $docType = $options['resources']['view']['doctype'] ? $options['resources']['view']['doctype'] : 'XHTML1_TRANSITIONAL'; $view->doctype($docType); } /** * @throws Zend_Locale_Exception */ protected function _initLocale() { $configResources = $this->getOption('resources'); Zend_Locale::setDefault($configResources['locale']['default']); Zend_Registry::set($configResources['locale']['registry_key'], $configResources['locale']['default']); } /** * @return Zend_Translate * @throws Zend_Application_Resource_Exception * @throws Zend_Form_Exception * @throws Zend_Session_Exception * @throws Zend_Translate_Exception * @throws Zend_Validate_Exception */ protected function _initTranslate() { $options = $this->getOption('resources'); $options = $options['translate']; if (!isset($options['data'])) { throw new Zend_Application_Resource_Exception( 'not found the file'); } $adapter = isset($options['adapter']) ? $options['adapter'] : Zend_Translate::AN_ARRAY; $session = new Zend_Session_Namespace('aa'); if ($session->locale) { $locale = $session->locale; } else { $locale = isset($options['locale']) ? $options['locale'] : null; } $data = ''; if (isset($options['data'][$locale])) { $data = $options['data'][$locale]; } $translateOptions = isset($options['options']) ? $options['options'] : array(); $translate = new Zend_Translate($adapter, $data, $locale, $translateOptions); Zend_Form::setDefaultTranslator($translate); Zend_Validate_Abstract::setDefaultTranslator($translate); Zend_Registry::set('Zend_Translate', $translate); return $translate; } /** * @throws Zend_Application_Bootstrap_Exception */ protected function _initDbAdapter() { $db = $this->bootstrap('db')->getResource('db'); //( if ((APPLICATION_ENV == 'development') OR (APPLICATION_ENV == 'testing')) { // $profiler = new Zend_Db_Profiler_Firebug('All DB Queries'); // $profiler->setEnabled(true); // // // Attach the profiler to your db adapter // $db->setProfiler($profiler); // } Zend_Registry::set('db', $db); Zend_Db_Table::setDefaultAdapter($db); Zend_Db_Table_Abstract::setDefaultAdapter($db); } /** * @throws Zend_Log_Exception */ protected function _initLogger() { $settings = $this->getOption('settings'); $log = new Zend_Log(); $writer = new Zend_Log_Writer_Stream($settings['log']['path'] . 'all_' . date("Y-m-d")); $writer->addFilter(new Local_Log_Filter_MinMax(Zend_Log::WARN, Zend_Log::DEBUG)); $log->addWriter($writer); $errorWriter = new Zend_Log_Writer_Stream($settings['log']['path'] . 'err_' . date('Y-m-d')); $errorWriter->addFilter(new Zend_Log_Filter_Priority(Zend_Log::ERR)); $log->addWriter($errorWriter); Zend_Registry::set('logger', $log); if ((APPLICATION_ENV == 'development') OR (APPLICATION_ENV == 'testing')) { $firebugWriter = new Zend_Log_Writer_Firebug(); $firebugLog = new Zend_Log($firebugWriter); Zend_Registry::set('firebug_log', $firebugLog); } } protected function _initGlobals() { Zend_Paginator::setDefaultScrollingStyle('Elastic'); Zend_View_Helper_PaginationControl::setDefaultViewPartial('paginationControl.phtml'); Zend_Filter::addDefaultNamespaces('Local_Filter'); $version = $this->getOption('version'); defined('APPLICATION_VERSION') || define('APPLICATION_VERSION', $version); } /** * @return Default_Plugin_AclRules|false|mixed * @throws Zend_Cache_Exception */ protected function _initAclRules() { /** @var Zend_Cache_Core $appCache */ $appCache = $this->getResource('cache'); if (false == ($aclRules = $appCache->load('AclRules'))) { $aclRules = new Default_Plugin_AclRules(); Zend_Registry::set('acl', $aclRules); $appCache->save($aclRules, 'AclRules', array('AclRules'), 14400); } return $aclRules; } /** * @throws Zend_Application_Bootstrap_Exception * @throws Zend_Loader_PluginLoader_Exception */ protected function _initPlugins() { /** @var $front Zend_Controller_Front */ $front = $this->bootstrap('frontController')->getResource('frontController'); $aclRules = $this->bootstrap('aclRules')->getResource('aclRules'); $front->unregisterPlugin('Zend_Controller_Plugin_ErrorHandler'); $front->registerPlugin(new Default_Plugin_ErrorHandler()); $front->registerPlugin(new Default_Plugin_RememberMe(Zend_Auth::getInstance())); $front->registerPlugin(new Default_Plugin_SignOn(Zend_Auth::getInstance())); $front->registerPlugin(new Default_Plugin_Acl(Zend_Auth::getInstance(), $aclRules)); $loader = new Zend_Loader_PluginLoader(); $loader->addPrefixPath('Zend_View_Helper', APPLICATION_LIB . '/Zend/View/Helper/') ->addPrefixPath('Zend_Form_Element', APPLICATION_LIB . '/Zend/Form/Element') ->addPrefixPath('Default_View_Helper', APPLICATION_PATH . '/modules/default/views/helpers') ->addPrefixPath('Default_Form_Helper', APPLICATION_PATH . '/modules/default/forms/helpers') ->addPrefixPath('Default_Form_Element', APPLICATION_PATH . '/modules/default/forms/elements') ->addPrefixPath('Default_Form_Decorator', APPLICATION_PATH . '/modules/default/forms/decorators') ->addPrefixPath('Default_Form_Validator', APPLICATION_PATH . '/modules/default/forms/validators'); } /** * @throws Zend_Session_Exception */ //protected function _initAuthSessionNamespace() //{ // $config = $this->getResource('config'); // $auth_config = $config->settings->auth_session; // // $objSessionNamespace = new Zend_Session_Namespace($auth_config->name); // $objSessionNamespace->setExpirationSeconds($auth_config->timeout); // // Zend_Auth::getInstance()->setStorage(new Zend_Auth_Storage_Session($auth_config->name)); //} protected function _initThirdParty() { $appConfig = $this->getResource('config'); $imageConfig = $appConfig->images; defined('IMAGES_UPLOAD_PATH') || define('IMAGES_UPLOAD_PATH', $imageConfig->upload->path); defined('IMAGES_MEDIA_SERVER') || define('IMAGES_MEDIA_SERVER', $imageConfig->media->server); // ppload $pploadConfig = $appConfig->third_party->ppload; defined('PPLOAD_API_URI') || define('PPLOAD_API_URI', $pploadConfig->api_uri); defined('PPLOAD_CLIENT_ID') || define('PPLOAD_CLIENT_ID', $pploadConfig->client_id); defined('PPLOAD_SECRET') || define('PPLOAD_SECRET', $pploadConfig->secret); defined('PPLOAD_DOWNLOAD_SECRET') || define('PPLOAD_DOWNLOAD_SECRET', $pploadConfig->download_secret); } /** * @return false|mixed|Zend_Controller_Router_Rewrite * @throws Zend_Application_Bootstrap_Exception * @throws Zend_Cache_Exception * @throws Zend_Controller_Exception * @throws Zend_Exception */ protected function _initRouter() { $this->bootstrap('frontController'); /** @var $front Zend_Controller_Front */ $front = $this->getResource('frontController'); /** @var Zend_Cache_Core $cache */ $cache = Zend_Registry::get('cache'); if (($router = $cache->load('ProjectRouter'))) { $front->setRouter($router); return $router; } /** @var $router Zend_Controller_Router_Rewrite */ $router = $front->getRouter(); /** RSS Feed */ $router->addRoute( 'rdf_store', new Zend_Controller_Router_Route( '/content.rdf', array( 'module' => 'default', 'controller' => 'rss', 'action' => 'rdf' ) ) ); $router->addRoute( 'rdf_events_hive', new Zend_Controller_Router_Route_Regex( '.*-events.rss', array( 'module' => 'default', 'controller' => 'rss', 'action' => 'rss' ) ) ); $router->addRoute( 'rdf_store_hive', new Zend_Controller_Router_Route_Regex( '.*-content.rdf', array( 'module' => 'default', 'controller' => 'rss', 'action' => 'rdf' ) ) ); $router->addRoute( 'rdf_store_hive_rss', new Zend_Controller_Router_Route_Regex( 'rss/.*-content.rdf', array( 'module' => 'default', 'controller' => 'rss', 'action' => 'rdf' ) ) ); /** new store dependent routing rules */ $router->addRoute( 'store_home', new Zend_Controller_Router_Route( '/s/:domain_store_id/', array( 'module' => 'default', 'controller' => 'home', 'action' => 'index' ) ) ); $router->addRoute( 'store_browse', new Zend_Controller_Router_Route( '/s/:domain_store_id/browse/*', array( 'module' => 'default', 'controller' => 'explore', 'action' => 'index' ) ) ); $router->addRoute( 'store_product', new Zend_Controller_Router_Route( '/s/:domain_store_id/p/:project_id/:action/*', array( 'module' => 'default', 'controller' => 'product', 'action' => 'show' ) ) ); $router->addRoute( 'store_user', new Zend_Controller_Router_Route( '/s/:domain_store_id/member/:member_id/:action/*', array( 'module' => 'default', 'controller' => 'user', 'action' => 'index' ) ) ); $router->addRoute( 'store_user_name', new Zend_Controller_Router_Route( '/s/:domain_store_id/u/:user_name/:action/*', array( 'module' => 'default', 'controller' => 'user', 'action' => 'index' ) ) ); /** general routing rules */ $router->addRoute( 'home', new Zend_Controller_Router_Route( '/', array( 'module' => 'default', 'controller' => 'home', 'action' => 'index' ) ) ); $router->addRoute( 'home_ajax', new Zend_Controller_Router_Route( '/showfeatureajax/*', array( 'module' => 'default', 'controller' => 'home', 'action' => 'showfeatureajax' ) ) ); $router->addRoute( 'backend', new Zend_Controller_Router_Route( '/backend/:controller/:action/*', array( 'module' => 'backend', 'controller' => 'index', 'action' => 'index' ) ) ); $router->addRoute( 'browse', new Zend_Controller_Router_Route( '/browse/*', array( 'module' => 'default', 'controller' => 'explore', 'action' => 'index' ) ) ); $router->addRoute( 'button_render', new Zend_Controller_Router_Route( '/button/:project_id/:size/', array( 'module' => 'default', 'controller' => 'button', 'action' => 'render', 'size' => 'large' ) ) ); $router->addRoute( 'button_action', new Zend_Controller_Router_Route( '/button/a/:action/', array( 'module' => 'default', 'controller' => 'button', 'action' => 'index' ) ) ); /* $router->addRoute( 'supporter_box_show', new Zend_Controller_Router_Route( '/supporterbox/:project_uuid/', array( 'module' => 'default', 'controller' => 'supporterbox', 'action' => 'render' ) ) ); */ $router->addRoute( 'pling_box_show', new Zend_Controller_Router_Route( '/supporterbox/:memberid/', array( 'module' => 'default', 'controller' => 'plingbox', 'action' => 'index' ) ) ); $router->addRoute( 'external_donation_list', new Zend_Controller_Router_Route( '/donationlist/:project_id/', array( 'module' => 'default', 'controller' => 'donationlist', 'action' => 'render' ) ) ); $router->addRoute( 'external_widget', new Zend_Controller_Router_Route( '/widget/:project_id/', array( 'module' => 'default', 'controller' => 'widget', 'action' => 'render' ) ) ); $router->addRoute( 'external_widget_save', new Zend_Controller_Router_Route( '/widget/save/*', array( 'module' => 'default', 'controller' => 'widget', 'action' => 'save' ) ) ); $router->addRoute( 'external_widget_save', new Zend_Controller_Router_Route( '/widget/config/:project_id/', array( 'module' => 'default', 'controller' => 'widget', 'action' => 'config' ) ) ); $router->addRoute( 'external_widget_save_default', new Zend_Controller_Router_Route( '/widget/savedefault/*', array( 'module' => 'default', 'controller' => 'widget', 'action' => 'savedefault' ) ) ); /** * Project/Product */ $router->addRoute( 'product_short_url', new Zend_Controller_Router_Route( '/p/:project_id/:action/*', array( 'module' => 'default', 'controller' => 'product', 'action' => 'show' ) ) ); $router->addRoute( 'product_referrer_url', new Zend_Controller_Router_Route( '/p/:project_id/er/:er/*', array( 'module' => 'default', 'controller' => 'product', 'action' => 'show' ) ) ); $router->addRoute( 'product_collectionid_url', new Zend_Controller_Router_Route( '/c/:collection_id', array( 'module' => 'default', 'controller' => 'product', 'action' => 'show' ) ) ); $router->addRoute( 'product_add', new Zend_Controller_Router_Route( '/product/add', array( 'module' => 'default', 'controller' => 'product', 'action' => 'add' ) ) ); $router->addRoute( 'search', new Zend_Controller_Router_Route( '/search/*', array( 'module' => 'default', 'controller' => 'product', 'action' => 'search' ) ) ); $router->addRoute( 'product_save', new Zend_Controller_Router_Route( '/p/save/*', array( 'module' => 'default', 'controller' => 'product', 'action' => 'saveproduct' ) ) ); /** * Member */ $router->addRoute( 'member_settings_old', new Zend_Controller_Router_Route( '/settings/:action/*', array( 'module' => 'default', 'controller' => 'settings', 'action' => 'index' ) ) ); $router->addRoute( 'user_show', new Zend_Controller_Router_Route( '/member/:member_id/:action/*', array( 'module' => 'default', 'controller' => 'user', 'action' => 'index' ) ) ); - $router->addRoute( 'user_avatar', new Zend_Controller_Router_Route( '/member/avatar/:emailhash/:size', array( 'module' => 'default', 'controller' => 'user', 'action' => 'avatar' ) ) ); $router->addRoute( 'user_show_with_name', new Zend_Controller_Router_Route( '/u/:user_name/:action/*', array( 'module' => 'default', 'controller' => 'user', 'action' => 'index' ) ) ); $router->addRoute( 'user_recification', new Zend_Controller_Router_Route( '/r/:action/*', array( 'module' => 'default', 'controller' => 'rectification', 'action' => 'index' ) ) ); $router->addRoute( 'user_show_short', new Zend_Controller_Router_Route( '/me/:member_id/:action/*', array( 'module' => 'default', 'controller' => 'user', 'action' => 'index' ) ) ); $router->addRoute( 'register', new Zend_Controller_Router_Route_Static( '/register', array( 'module' => 'default', 'controller' => 'authorization', 'action' => 'register' ) ) ); $router->addRoute( 'register_validate', new Zend_Controller_Router_Route_Static( '/register/validate', array( 'module' => 'default', 'controller' => 'authorization', 'action' => 'validate' ) ) ); $router->addRoute( 'verification', new Zend_Controller_Router_Route( '/verification/:vid', array( 'module' => 'default', 'controller' => 'authorization', 'action' => 'verification' ) ) ); $router->addRoute( 'logout', new Zend_Controller_Router_Route_Static( '/logout', array( 'module' => 'default', 'controller' => 'logout', 'action' => 'logout' ) ) ); $router->addRoute( 'propagatelogout', new Zend_Controller_Router_Route_Static( '/logout/propagate', array( 'module' => 'default', 'controller' => 'authorization', 'action' => 'propagatelogout' ) ) ); $router->addRoute( 'checkuser', new Zend_Controller_Router_Route_Static( '/checkuser', array( 'module' => 'default', 'controller' => 'authorization', 'action' => 'checkuser' ) ) ); $router->addRoute( 'login', new Zend_Controller_Router_Route( '/login', array( 'module' => 'default', 'controller' => 'authorization', 'action' => 'login' ) ) ); $router->addRoute( 'login', new Zend_Controller_Router_Route( '/login/:action/*', array( 'module' => 'default', 'controller' => 'authorization', 'action' => 'login' ) ) ); $router->addRoute( 'LoginController', new Zend_Controller_Router_Route( '/l/:action/*', array( 'module' => 'default', 'controller' => 'login', 'action' => 'login' ) ) ); $router->addRoute( 'content', new Zend_Controller_Router_Route( '/content/:page', array( 'module' => 'default', 'controller' => 'content', 'action' => 'index' ) ) ); $router->addRoute( 'categories_about', new Zend_Controller_Router_Route( '/cat/:page/about', array( 'module' => 'default', 'controller' => 'categories', 'action' => 'about' ) ) ); // **** static routes $router->addRoute( 'static_faq', new Zend_Controller_Router_Route_Static( '/faq', array( 'module' => 'default', 'controller' => 'content', 'action' => 'index', 'page' => 'faq' ) ) ); $router->addRoute( 'static_terms', new Zend_Controller_Router_Route_Static( '/terms', array( 'module' => 'default', 'controller' => 'content', 'action' => 'index', 'page' => 'terms' ) ) ); $router->addRoute( 'static_terms_general', new Zend_Controller_Router_Route_Static( '/terms/general', array( 'module' => 'default', 'controller' => 'content', 'action' => 'index', 'page' => 'terms-general' ) ) ); $router->addRoute( 'static_terms_publish', new Zend_Controller_Router_Route_Static( '/terms/publishing', array( 'module' => 'default', 'controller' => 'content', 'action' => 'index', 'page' => 'terms-publishing' ) ) ); $router->addRoute( 'static_terms_dmca', new Zend_Controller_Router_Route_Static( '/terms/dmca', array( 'module' => 'default', 'controller' => 'content', 'action' => 'index', 'page' => 'terms-dmca' ) ) ); $router->addRoute( 'static_privacy', new Zend_Controller_Router_Route_Static( '/privacy', array( 'module' => 'default', 'controller' => 'content', 'action' => 'index', 'page' => 'privacy' ) ) ); $router->addRoute( 'static_contact', new Zend_Controller_Router_Route_Static( '/contact', array( 'module' => 'default', 'controller' => 'content', 'action' => 'index', 'page' => 'contact' ) ) ); // **** ppload $router->addRoute( 'pploadlogin', new Zend_Controller_Router_Route( '/pploadlogin/*', array( 'module' => 'default', 'controller' => 'authorization', 'action' => 'pploadlogin' ) ) ); // OCS API $router->addRoute( 'ocs_providers_xml', new Zend_Controller_Router_Route( '/ocs/providers.xml', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'providers' ) ) ); $router->addRoute( 'ocs_v1_config', new Zend_Controller_Router_Route( '/ocs/v1/config', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'config' ) ) ); $router->addRoute( 'ocs_v1_person_check', new Zend_Controller_Router_Route( '/ocs/v1/person/check', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'personcheck' ) ) ); $router->addRoute( 'ocs_v1_person_data', new Zend_Controller_Router_Route( '/ocs/v1/person/data', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'persondata' ) ) ); $router->addRoute( 'ocs_v1_person_data_personid', new Zend_Controller_Router_Route( '/ocs/v1/person/data/:personid', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'persondata' ) ) ); $router->addRoute( 'ocs_v1_person_self', new Zend_Controller_Router_Route( '/ocs/v1/person/self', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'personself' ) ) ); $router->addRoute( 'ocs_v1_content_categories', new Zend_Controller_Router_Route( '/ocs/v1/content/categories', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'contentcategories' ) ) ); $router->addRoute( 'ocs_v1_content_data_contentid', new Zend_Controller_Router_Route( '/ocs/v1/content/data/:contentid', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'contentdata', 'contentid' => null ) ) ); $router->addRoute( 'ocs_v1_content_download_contentid_itemid', new Zend_Controller_Router_Route( '/ocs/v1/content/download/:contentid/:itemid', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'contentdownload' ) ) ); $router->addRoute( 'ocs_v1_content_previewpic_contentid', new Zend_Controller_Router_Route( '/ocs/v1/content/previewpic/:contentid', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'contentpreviewpic' ) ) ); $router->addRoute('ocs_v1_comments', new Zend_Controller_Router_Route( '/ocs/v1/comments/data/:comment_type/:content_id/:second_id', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'comments', 'comment_type' => -1, 'content_id' => null, 'second_id' => null )) ); // embed $router->addRoute( 'embed_v1_member_projects', new Zend_Controller_Router_Route( '/embed/v1/member/:memberid', array( 'module' => 'default', 'controller' => 'embedv1', 'action' => 'memberprojects' ) ) ); $router->addRoute( 'embed_v1_member_projects_files', new Zend_Controller_Router_Route( '/embed/v1/ppload/:ppload_collection_id', array( 'module' => 'default', 'controller' => 'embedv1', 'action' => 'ppload' ) ) ); $router->addRoute( 'embed_v1_member_projectscomments', new Zend_Controller_Router_Route( '/embed/v1/comments/:id', array( 'module' => 'default', 'controller' => 'embedv1', 'action' => 'comments' ) ) ); $router->addRoute( 'embed_v1_member_projectdetail', new Zend_Controller_Router_Route( '/embed/v1/project/:projectid', array( 'module' => 'default', 'controller' => 'embedv1', 'action' => 'projectdetail' ) ) ); $router->addRoute( 'clones', new Zend_Controller_Router_Route( '/clones', array( 'module' => 'default', 'controller' => 'credits', 'action' => 'index' ) ) ); $cache->save($router, 'ProjectRouter', array('router'), 14400); return $router; } /** * @throws Zend_Cache_Exception * @throws Zend_Exception * @throws exception */ protected function _initCss() { if (APPLICATION_ENV != "development" && APPLICATION_ENV != "staging") { return; } $appConfig = $this->getResource('config'); if ((boolean)$appConfig->settings->noLESScompile === true) { return; } $sLess = realpath(APPLICATION_PATH . '/../httpdocs/theme/flatui/less/stylesheet.less'); $sCss = realpath(APPLICATION_PATH . '/../httpdocs/theme/flatui/css/stylesheet.css'); /** * @var Zend_Cache_Core $cache */ $cache = Zend_Registry::get('cache'); if (md5_file($sLess) !== $cache->load('md5Less')) { require_once APPLICATION_PATH . "/../library/lessphp/lessc.inc.php"; $oLessc = new lessc($sLess); $oLessc->setFormatter('compressed'); file_put_contents($sCss, $oLessc->parse()); $cache->save(md5_file($sLess), 'md5Less'); } } protected function _initGlobalApplicationVars() { $modelDomainConfig = new Default_Model_DbTable_ConfigStore(); Zend_Registry::set('application_store_category_list', $modelDomainConfig->fetchAllStoresAndCategories()); Zend_Registry::set('application_store_config_list', $modelDomainConfig->fetchAllStoresConfigArray()); Zend_Registry::set('application_store_config_id_list', $modelDomainConfig->fetchAllStoresConfigByIdArray()); } /** * @throws Zend_Application_Bootstrap_Exception */ protected function _initStoreDependentVars() { /** @var $front Zend_Controller_Front */ $front = $this->bootstrap('frontController')->getResource('frontController'); $front->registerPlugin(new Default_Plugin_InitGlobalStoreVars()); } } \ No newline at end of file diff --git a/application/modules/default/controllers/UserController.php b/application/modules/default/controllers/UserController.php index c9f74dde8..83a6635e3 100644 --- a/application/modules/default/controllers/UserController.php +++ b/application/modules/default/controllers/UserController.php @@ -1,715 +1,794 @@ . **/ class UserController extends Local_Controller_Action_DomainSwitch { protected $_memberId; protected $_userName; /** @var Zend_Db_Table_Row */ protected $_memberSettings; public function init() { parent::init(); if ($this->hasParam('user_name')) { $this->_userName = $this->getParam('user_name'); $this->_userName = urldecode($this->_userName); $modelMember = new Default_Model_Member(); $this->_memberId = $modelMember->fetchActiveUserByUsername($this->_userName); } else { $this->_memberId = (int)$this->getParam('member_id'); } } public function indexAction() { $this->_helper->viewRenderer('aboutme'); $this->aboutmeAction(); } public function aboutmeAction() { $tableMember = new Default_Model_Member(); $tableProject = new Default_Model_Project(); $earnModel = new Default_Model_StatDownload(); $helperUserRole = new Backend_View_Helper_UserRole(); $pageLimit = 500; $projectpage = (int)$this->getParam('projectpage', 1); $this->view->authMember = $this->_authMember; //$this->view->member = $tableMember->find($this->_memberId)->current(); $this->view->member = $tableMember->fetchMemberData($this->_memberId); if (null == $this->view->member) { $this->redirect("/"); } if ($this->view->member->is_deleted == 1 or $this->view->member->is_active == 0) { $this->redirect("/"); } $this->view->mainProject = $this->view->member->findDependentRowset($tableProject, 'MainProject')->current(); $this->view->userProjectCategories = $tableProject->getUserCreatingCategorys($this->_memberId); $this->view->aboutmeUserInfo = $this->getAboutmeUserInfo($this->_memberId,$this->view->member->username); $userRoleName = $helperUserRole->userRole(); if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { $amount = $earnModel->getMonthEarn($this->_memberId,201812); if($amount && $amount['amount']) { $this->view->earnInfo = ' Last month I earned $'.$amount['amount'].'.'; }else { $this->view->earnInfo=' Last month I earned 0.'; } }else{ $this->view->earnInfo=''; } // ajax load more products if ($this->getParam('projectpage', null)) { $total_records = $tableProject->countAllProjectsForMemberCatFilter($this->_memberId, true, null); $this->view->pageLimit = $pageLimit; $this->view->projectpage = $projectpage; $this->view->total_records = $total_records; // get last project category id $lastproject = $tableProject->getUserActiveProjects($this->_memberId, 1, (($projectpage - 1) * $pageLimit-1)); foreach ($lastproject as $value) { $this->view->lastcatid = $value['project_category_id']; } $this->view->userProducts = $tableProject->getUserActiveProjects($this->_memberId, $pageLimit, ($projectpage - 1) * $pageLimit); $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer('partials/aboutmeProducts'); //$this->forward('showmoreproductsajax', 'user', null, $this->getAllParams()); return; } else { $total_records = $tableProject->countAllProjectsForMemberCatFilter($this->_memberId, true, null); $this->view->pageLimit = $pageLimit; $this->view->projectpage = $projectpage; $this->view->total_records = $total_records; //$this->view->userProducts = $tableProject->fetchAllProjectsForMember($this->_memberId, $pageLimit, ($projectpage - 1) * $pageLimit,true); $this->view->userProducts = $tableProject->getUserActiveProjects($this->_memberId, $pageLimit, ($projectpage - 1) * $pageLimit); $this->view->userFeaturedProducts = $tableProject->fetchAllFeaturedProjectsForMember($this->_memberId); $paginationComments = $tableMember->fetchComments($this->_memberId); if ($paginationComments) { $offset = (int)$this->getParam('page'); $paginationComments->setItemCountPerPage(50); $paginationComments->setCurrentPageNumber($offset); $this->view->comments = $paginationComments; } // favs Currently no paging... $this->view->paramLikePageId = (int)$this->getParam('likepage'); $model = new Default_Model_DbTable_ProjectFollower(); $offset = $this->view->paramLikePageId; $list = $model->fetchLikesForMember($this->_memberId); $list->setItemCountPerPage(1000); $list->setCurrentPageNumber($offset); $this->view->likes = $list; // plings Currently no paging... $plingmodel = new Default_Model_ProjectPlings(); $offset = null; $plist = $plingmodel->fetchPlingsForMember($this->_memberId); $plist->setItemCountPerPage(1000); $plist->setCurrentPageNumber($offset); $this->view->plings = $plist; // plings Currently no paging... $plingmodel = new Default_Model_ProjectPlings(); $offset = null; $pslist = $plingmodel->fetchPlingsForSupporter($this->_memberId); $pslist->setItemCountPerPage(1000); $pslist->setCurrentPageNumber($offset); $this->view->supportersplings = $pslist; // rated $ratemodel = new Default_Model_DbTable_ProjectRating(); $this->view->rated = $ratemodel->getRatedForMember($this->_memberId); $stat = array(); $stat['cntProducts'] = $total_records; if ($this->view->userFeaturedProducts) { $cnt = 0; foreach ($this->view->userFeaturedProducts as $tmp) { $cnt++; } $stat['cntFProducts'] = $cnt; } else { $stat['cntFProducts'] = 0; } $stat['cntComments'] = $paginationComments->getTotalItemCount(); $tblFollower = new Default_Model_DbTable_ProjectFollower(); $stat['cntLikesHeGave'] = $tblFollower->countLikesHeGave($this->_memberId); $stat['cntLikesHeGot'] = $tblFollower->countLikesHeGot($this->_memberId); $tblPling = new Default_Model_DbTable_ProjectPlings(); $stat['cntPlingsHeGave'] = $tblPling->countPlingsHeGave($this->_memberId); $stat['cntPlingsHeGot'] = $tblPling->countPlingsHeGot($this->_memberId); $donationinfo = $tableMember->fetchSupporterDonationInfo($this->_memberId); if ($donationinfo) { $stat['donationIssupporter'] = $donationinfo['issupporter']; $stat['donationMax'] = $donationinfo['active_time_max']; $stat['donationMin'] = $donationinfo['active_time_min']; $stat['donationCnt'] = $donationinfo['cnt']; } // $cntmb = $tableMember->fetchCntSupporters($this->_memberId); // $stat['cntSupporters'] = $cntmb; $stat['userLastActiveTime'] = $tableMember->fetchLastActiveTime($this->_memberId); $userRoleName = $helperUserRole->userRole(); if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { $stat['cntDuplicateSourceurl'] = $tableProject->getCountProjectsDuplicateSourceurl($this->_memberId); } $this->view->stat = $stat; } } public function getAboutmeUserInfo($member_id,$username) { $tableProject = new Default_Model_Project(); $userProjectCategories = $tableProject->getUserCreatingCategorys($member_id); $cnt = sizeof($userProjectCategories ); $userinfo=''; $isAdmin = false; $helperUserRole = new Backend_View_Helper_UserRole(); $userRoleName = $helperUserRole->userRole(); if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName){ $isAdmin= true; } if($cnt>0) { $userinfo = "Hi, I am ".$username." and I'm creating "; if($cnt==1) { $userinfo = $userinfo.' '.$userProjectCategories[0]['category1'].''; if($isAdmin) { $userinfo = $userinfo.'['.$userProjectCategories[0]['cnt'].'].'; } }else if($cnt==2) { $userinfo = $userinfo.' '.$userProjectCategories[0]['category1'].''; if($isAdmin) { $userinfo = $userinfo.'['.$userProjectCategories[0]['cnt'].']'; } $userinfo = $userinfo.' and '.$userProjectCategories[1]['category1'].''; if($isAdmin) { $userinfo = $userinfo.'['.$userProjectCategories[1]['cnt'].'].'; } }else if($cnt==3) { $userinfo = $userinfo.' '.$userProjectCategories[0]['category1'].''; if($isAdmin) { $userinfo = $userinfo.'['.$userProjectCategories[0]['cnt'].']'; } $userinfo = $userinfo.', '.$userProjectCategories[1]['category1'].''; if($isAdmin) { $userinfo = $userinfo.'['.$userProjectCategories[1]['cnt'].']'; } $userinfo = $userinfo.' and '.$userProjectCategories[2]['category1'].''; if($isAdmin) { $userinfo = $userinfo.'['.$userProjectCategories[2]['cnt'].'].'; } }else if($cnt>3) { $userinfo = $userinfo.' '.$userProjectCategories[0]['category1'].''; if($isAdmin) { $userinfo = $userinfo.'['.$userProjectCategories[0]['cnt'].']'; } $userinfo = $userinfo.', '.$userProjectCategories[1]['category1'].''; if($isAdmin) { $userinfo = $userinfo.'['.$userProjectCategories[1]['cnt'].']'; } $userinfo = $userinfo.', '.$userProjectCategories[2]['category1'].''; if($isAdmin) { $userinfo = $userinfo.'['.$userProjectCategories[2]['cnt'].']'; } $userinfo = $userinfo.' and more.'; } } return $userinfo; } public function avatarAction() { $this->_helper->layout->disableLayout(); $size = (int)$this->getParam("size", 200); $width = (int)$this->getParam("width", ($size / 2)); $this->view->size = (int)$size / 2; $emailHash = $this->getParam("emailhash", null); if ($emailHash) { $memberTable = new Default_Model_Member(); $member = $memberTable->findMemberForMailHash($emailHash); if ($member) { $helperImage = new Default_View_Helper_Image(); $imgUrl = $helperImage->Image($member['profile_image_url'], array('width' => $width, 'height' => $width)); $this->view->avatar = $imgUrl; $this->redirect($imgUrl); return; } } $this->view->avatar = ""; $helperImage = new Default_View_Helper_Image(); $imgUrl = $helperImage->Image("default-profile.png", array('width' => $width, 'height' => $width)); $this->redirect($imgUrl); } public function aboutAction() { $modelMember = new Default_Model_Member(); $this->view->member = $modelMember->fetchMember($this->_memberId)->toArray(); $this->view->currentPageOffset = (int)$this->getParam('page'); } public function showmoreproductsajaxAction() { $this->_helper->layout->disableLayout(); $tableProject = new Default_Model_Project(); $pageLimit = 21; $page = (int)$this->getParam('page', 1); $total_records = $tableProject->countAllProjectsForMemberCatFilter($this->_memberId, true, null); $this->view->pageLimit = $pageLimit; $this->view->page = $page; $this->view->total_records = $total_records; $this->view->userProducts = $tableProject->fetchAllProjectsForMember($this->_memberId, $pageLimit, ($page - 1) * $pageLimit, true); $this->_helper->viewRenderer('/partials/aboutmeProducts'); } public function userdataajaxAction() { $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $resultArray = array(); header('Access-Control-Allow-Origin: *'); $this->getResponse()->setHeader('Access-Control-Allow-Origin', '*')->setHeader('Access-Control-Allow-Credentials', 'true') ->setHeader('Access-Control-Allow-Methods', 'POST, GET, OPTIONS') ->setHeader('Access-Control-Allow-Headers', 'origin, content-type, accept') ; $userid = $this->getParam('id'); $modelMember = new Default_Model_Member(); $user = $modelMember->find($userid)->current(); if (Zend_Auth::getInstance()->hasIdentity()) { $auth = Zend_Auth::getInstance(); $user = $auth->getStorage()->read(); $resultArray['member_id'] = $user->member_id; $resultArray['username'] = $user->username; $resultArray['mail'] = $user->mail; $resultArray['avatar'] = $user->profile_image_url; } else if (null != $userid && null != $user) { $resultArray['member_id'] = $user['member_id']; $resultArray['username'] = $user['username']; $resultArray['mail'] = $user['mail']; $resultArray['avatar'] = $user['profile_image_url']; } else { $resultArray['member_id'] = null; $resultArray['username'] = null; $resultArray['mail'] = null; $resultArray['avatar'] = null; } $resultAll = array(); $resultAll['status'] = "success"; $resultAll['data'] = $resultArray; $this->_helper->json($resultAll); } public function followsAction() { $this->redirect($this->_helper->url('follows', 'member', null, $this->getAllParams())); } public function followAction() { $this->_helper->layout->disableLayout(); $this->view->authMember = $this->_authMember; $this->view->member_id = $this->_memberId; if ($this->_memberId == $this->_authMember->member_id) { return; } $memberFollowTable = new Default_Model_DbTable_MemberFollower(); $newVals = array('member_id' => $this->_memberId, 'follower_id' => (int)$this->_authMember->member_id); $where = $memberFollowTable->select()->where('member_id = ?', $this->_memberId) ->where('follower_id = ?', $this->_authMember->member_id, 'INTEGER') ; $result = $memberFollowTable->fetchRow($where); if (null === $result) { $memberFollowTable->createRow($newVals)->save(); } } public function unfollowAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer('follow'); $memberFollowTable = new Default_Model_DbTable_MemberFollower(); $memberFollowTable->delete('member_id=' . $this->_memberId . ' AND follower_id=' . $this->_authMember->member_id); $this->view->authMember = $this->_authMember; $this->view->member_id = $this->_memberId; } public function newsAction() { $this->productsAction(); $this->render('products'); } public function productsAction() { $pageLimit = 25; $page = (int)$this->getParam('page', 1); //create ppload download hash: secret + collection_id + expire-timestamp $salt = PPLOAD_DOWNLOAD_SECRET; $timestamp = time() + 3600; // one hour valid $hash = md5($salt . $timestamp); // order isn't important at all... just do the same when verifying $this->view->download_hash = $hash; $this->view->download_timestamp = $timestamp; $this->view->member_id = null; if (null != $this->_authMember && null != $this->_authMember->member_id) { $this->view->member_id = $this->_authMember->member_id; } $modelProject = new Default_Model_Project(); $userProjects = $modelProject->fetchAllProjectsForMember($this->_authMember->member_id, $pageLimit, ($page - 1) * $pageLimit); $paginator = Local_Paginator::factory($userProjects); $paginator->setItemCountPerPage($pageLimit); $paginator->setCurrentPageNumber($page); $paginator->setTotalItemCount($modelProject->countAllProjectsForMember($this->_authMember->member_id)); $this->view->products = $paginator; $modelMember = new Default_Model_Member(); $this->view->member = $modelMember->fetchMemberData($this->_authMember->member_id); } public function activitiesAction() { $modelInfo = new Default_Model_Info(); $this->view->member = $this->_authMember; $this->view->comments = $modelInfo->getLastCommentsForUsersProjects($this->_authMember->member_id); $this->view->votes = $modelInfo->getLastVotesForUsersProjects($this->_authMember->member_id); $this->view->donations = $modelInfo->getLastDonationsForUsersProjects($this->_authMember->member_id); } public function settingsAction() { $this->_helper->layout()->setLayout('settings'); } public function reportAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer('product/add'); $this->forward('report', 'product', null, $this->getAllParams()); } public function paymentsAction() { $this->view->headScript()->setFile(''); $this->view->headLink()->setStylesheet(''); $member_id = $this->_authMember->member_id; $this->view->member = $this->_authMember; $tableMember = new Default_Model_Member(); $this->view->hits = $tableMember->fetchPlingedProjects($member_id); } public function incomeAction() { $this->view->member = $this->_authMember; $tableMember = new Default_Model_Member(); $modelPlings = new Default_Model_Pling(); $this->view->donations = $modelPlings->fetchRecentDonationsForUser($this->_authMember->member_id); } public function tooltipAction() { $this->_helper->layout->disableLayout(); $info = new Default_Model_Info(); $data = $info->getTooptipForMember($this->_memberId); $this->_helper->json(array('status' => 'ok', 'data' => $data)); } public function shareAction() { $this->_helper->layout->disableLayout(); $modelProduct = new Default_Model_Member(); $memberInfo = $modelProduct->fetchMemberData($this->_memberId); $form = new Default_Form_ProjectShare(); $form->setAction('/member/' . $this->_memberId . '/share/'); // $helperBaseUrl = new Default_View_Helper_BaseUrl(); // $helperServerUrl = new Zend_View_Helper_ServerUrl(); $helpMemberUrl = new Default_View_Helper_BuildMemberUrl(); $this->view->permaLink = $helpMemberUrl->buildMemberUrl($memberInfo->username); // $this->view->permaLink = $helperServerUrl->serverUrl() . $helperBaseUrl->baseUrl() . '/member/' . $this->_memberId . '/'; if ($this->_request->isGet()) { $this->view->form = $form; $this->renderScript('product/share.phtml'); return; } if (false === $form->isValid($_POST)) { // form not valid $this->view->form = $form; $dummy = $this->view->render('product/share.phtml'); $this->_helper->json(array('status' => 'ok', 'message' => $dummy)); return; } $values = $form->getValues(); if (empty($memberInfo->firstname) and empty($memberInfo->lastname)) { $username = $memberInfo->username; } else { $username = $memberInfo->firstname . ' ' . $memberInfo->lastname; } $shareMail = new Default_Plugin_SendMail('tpl_social_mail_user'); $shareMail->setTemplateVar('sender', $values['sender_mail']); $shareMail->setTemplateVar('username', $username); $shareMail->setTemplateVar('permalink', $this->view->permaLink); $shareMail->setTemplateVar('permalinktext', 'View user\'s page'); $shareMail->setReceiverMail($values['mail']); $shareMail->send(); $this->_helper->json(array('status' => 'ok', 'redirect' => $this->view->permaLink)); } public function plingsAction() { $tableMember = new Default_Model_Member(); $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); $this->view->paypal_valid_status = $paypalValidStatus; //backdoor for admins $helperUserRole = new Backend_View_Helper_UserRole(); $userRoleName = $helperUserRole->userRole(); if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { $this->view->member = $this->view->view_member; } else { $this->view->member = $this->_authMember; } } + + + public function plingsoldAction() + { + $tableMember = new Default_Model_Member(); + $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); + + $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); + $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); + $this->view->paypal_valid_status = $paypalValidStatus; + + //backdoor for admins + $helperUserRole = new Backend_View_Helper_UserRole(); + $userRoleName = $helperUserRole->userRole(); + if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { + $this->view->member = $this->view->view_member; + } else { + $this->view->member = $this->_authMember; + } + } + + + public function plingsajaxAction() + { + $this->_helper->layout->disableLayout(); + + $tableMember = new Default_Model_Member(); + $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); + + $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); + $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); + $this->view->paypal_valid_status = $paypalValidStatus; + + //backdoor for admins + $helperUserRole = new Backend_View_Helper_UserRole(); + $userRoleName = $helperUserRole->userRole(); + if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { + $this->view->member = $this->view->view_member; + } else { + $this->view->member = $this->_authMember; + } + + $year = null; + if($this->hasParam('year')) { + $year = $this->getParam('year'); + } + $this->view->year = $year; + + $this->_helper->viewRenderer('/plingsajax'); + } + + public function plingsmonthajaxAction() + { + $this->_helper->layout->disableLayout(); + + $tableMember = new Default_Model_Member(); + $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); + + $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); + $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); + $this->view->paypal_valid_status = $paypalValidStatus; + + //backdoor for admins + $helperUserRole = new Backend_View_Helper_UserRole(); + $userRoleName = $helperUserRole->userRole(); + if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { + $this->view->member = $this->view->view_member; + } else { + $this->view->member = $this->_authMember; + } + + $yearmonth = null; + if($this->hasParam('yearmonth')) { + $yearmonth = $this->getParam('yearmonth'); + } + $this->view->yearmonth = $yearmonth; + + $this->_helper->viewRenderer('/plingsmonthajax'); + } public function downloadhistoryAction() { $tableMember = new Default_Model_Member(); $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); //backdore for admins $helperUserRole = new Backend_View_Helper_UserRole(); $userRoleName = $helperUserRole->userRole(); if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { $this->view->member = $this->view->view_member; } else { $this->view->member = $this->_authMember; } if ($this->view->member) { $this->view->paramPageId = (int)$this->getParam('page'); //TODO do really sql paging instead of Zend_Paginator $dhistory = new Default_Model_DbTable_MemberDownloadHistory(); $offset = $this->view->paramPageId; $list = $dhistory->getDownloadhistory($this->view->member->member_id); $list->setItemCountPerPage(250); $list->setCurrentPageNumber($offset); $this->view->downloadhistory = $list; } else { $this->view->downloadhistory = array(); } } public function likesAction() { $tableMember = new Default_Model_Member(); $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); //backdore for admins $helperUserRole = new Backend_View_Helper_UserRole(); $userRoleName = $helperUserRole->userRole(); if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { $this->view->member = $this->view->view_member; } else { $this->view->member = $this->_authMember; } if ($this->view->member) { $this->view->paramPageId = (int)$this->getParam('page'); $model = new Default_Model_DbTable_ProjectFollower(); $offset = $this->view->paramPageId; $list = $model->fetchLikesForMember($this->view->member->member_id); $list->setItemCountPerPage(250); $list->setCurrentPageNumber($offset); $this->view->likes = $list; } else { $this->view->likes = array(); } } public function payoutAction() { $tableMember = new Default_Model_Member(); $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); //backdore for admins $helperUserRole = new Backend_View_Helper_UserRole(); $userRoleName = $helperUserRole->userRole(); if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { $this->view->member = $this->view->view_member; } else { $this->view->member = $this->_authMember; } } /** * @return Default_Form_Settings * @throws Zend_Form_Exception */ private function formPassword() { $form = new Default_Form_Settings(); $form->setMethod("POST")->setAttrib("id", "settingsPasswordForm")->setAction('/member/' . $this->_memberId . '/changepass'); $passOld = $form->createElement('password', 'passwordOld')->setLabel('Enter old Password:')->setRequired(true) ->removeDecorator('HtmlTag')->addValidator(new Local_Validate_OldPasswordConfirm())->setDecorators(array( 'ViewHelper', 'Label', 'Errors', array( 'ViewScript', array( 'viewScript' => 'settings/viewscripts/flatui_input.phtml', 'placement' => false ) ) )) ; $pass1 = $form->createElement('password', 'password1')->setLabel('Enter new Password:')->setRequired(true) ->addValidator(new Zend_Validate_NotEmpty(Zend_Validate_NotEmpty::STRING))->removeDecorator('HtmlTag') ->setDecorators(array( 'ViewHelper', 'Label', 'Errors', array( 'ViewScript', array( 'viewScript' => 'settings/viewscripts/flatui_input.phtml', 'placement' => false ) ) )) ; $pass2 = $form->createElement('password', 'password2')->setLabel('Re-enter new Password:')->setRequired(true) ->addValidator(new Zend_Validate_NotEmpty(Zend_Validate_NotEmpty::STRING))->removeDecorator('HtmlTag') ->setDecorators(array( 'ViewHelper', 'Label', 'Errors', array( 'ViewScript', array( 'viewScript' => 'settings/viewscripts/flatui_input.phtml', 'placement' => false ) ) )) ; $passValid = new Local_Validate_PasswordConfirm($pass2->getValue()); $pass1->addValidator($passValid); $form->addElement($passOld)->addElement($pass1)->addElement($pass2); return $form; } } \ No newline at end of file diff --git a/application/modules/default/models/StatDownload.php b/application/modules/default/models/StatDownload.php index e10de3d12..e75a9a116 100644 --- a/application/modules/default/models/StatDownload.php +++ b/application/modules/default/models/StatDownload.php @@ -1,86 +1,192 @@ . * * Created: 16.12.2016 **/ class Default_Model_StatDownload { public function getUserDownloads($member_id) { $sql = " SELECT `member_dl_plings`.*, CASE WHEN (SELECT count(1) AS `sum_plings` FROM `project_plings` `pp` WHERE `pp`.`project_id` = `member_dl_plings`.`project_id` AND `pp`.`is_deleted` = 0 AND `is_active` = 1 GROUP BY `pp`.`project_id`) > 0 THEN (SELECT count(1) AS `sum_plings` FROM `project_plings` `pp` WHERE `pp`.`project_id` = `member_dl_plings`.`project_id` AND `pp`.`is_deleted` = 0 AND `is_active` = 1 GROUP BY `pp`.`project_id`) + 1 ELSE 1 END AS `num_plings_now`, `project`.`title`, `project`.`image_small`, `project_category`.`title` AS `cat_title`, laplace_score(`project`.`count_likes`, `project`.`count_dislikes`)/100 AS `laplace_score`, `member_payout`.`amount`, `member_payout`.`status`, `member_payout`.`payment_transaction_id`, CASE WHEN `tag_object`.`tag_item_id` IS NULL THEN 1 ELSE 0 END AS `is_license_missing_now`, CASE WHEN ((`project_category`.`source_required` = 1 AND `project`.`source_url` IS NOT NULL AND LENGTH(`project`.`source_url`) > 0) OR (`project_category`.`source_required` = 0)) THEN 0 ELSE 1 END AS `is_source_missing_now`, `project`.`pling_excluded` AS `is_pling_excluded_now` FROM `member_dl_plings` STRAIGHT_JOIN `project` ON `project`.`project_id` = `member_dl_plings`.`project_id` STRAIGHT_JOIN `project_category` ON `project_category`.`project_category_id` = `member_dl_plings`.`project_category_id` LEFT JOIN `member_payout` ON `member_payout`.`member_id` = `member_dl_plings`.`member_id` AND `member_payout`.`yearmonth` = `member_dl_plings`.`yearmonth` LEFT JOIN `tag_object` ON `tag_object`.`tag_type_id` = 1 AND `tag_object`.`tag_group_id` = 7 AND `tag_object`.`is_deleted` = 0 AND `tag_object`.`tag_object_id` = `project`.`project_id` WHERE `member_dl_plings`.`member_id` = :member_id ORDER BY `member_dl_plings`.`yearmonth` DESC, `project_category`.`title`, `project`.`title` "; $result = Zend_Db_Table::getDefaultAdapter()->query($sql, array('member_id' => $member_id)); if ($result->rowCount() > 0) { return $result->fetchAll(); } else { return array(); } } + + + public function getUserDownloadsForMonth($member_id, $yearmonth) + { + $sql = " + SELECT + `member_dl_plings`.*, + CASE WHEN (SELECT count(1) AS `sum_plings` FROM `project_plings` `pp` WHERE `pp`.`project_id` = `member_dl_plings`.`project_id` AND `pp`.`is_deleted` = 0 AND `is_active` = 1 GROUP BY `pp`.`project_id`) > 0 THEN (SELECT count(1) AS `sum_plings` FROM `project_plings` `pp` WHERE `pp`.`project_id` = `member_dl_plings`.`project_id` AND `pp`.`is_deleted` = 0 AND `is_active` = 1 GROUP BY `pp`.`project_id`) + 1 ELSE 1 END AS `num_plings_now`, + `project`.`title`, + `project`.`image_small`, + `project_category`.`title` AS `cat_title`, + laplace_score(`project`.`count_likes`, `project`.`count_dislikes`)/100 AS `laplace_score`, + `member_payout`.`amount`, + `member_payout`.`status`, + `member_payout`.`payment_transaction_id`, + CASE WHEN `tag_object`.`tag_item_id` IS NULL THEN 1 ELSE 0 END AS `is_license_missing_now`, + CASE WHEN ((`project_category`.`source_required` = 1 AND `project`.`source_url` IS NOT NULL AND LENGTH(`project`.`source_url`) > 0) OR (`project_category`.`source_required` = 0)) THEN 0 ELSE 1 END AS `is_source_missing_now`, + `project`.`pling_excluded` AS `is_pling_excluded_now` + FROM + `member_dl_plings` + STRAIGHT_JOIN + `project` ON `project`.`project_id` = `member_dl_plings`.`project_id` + STRAIGHT_JOIN + `project_category` ON `project_category`.`project_category_id` = `member_dl_plings`.`project_category_id` + LEFT JOIN + `member_payout` ON `member_payout`.`member_id` = `member_dl_plings`.`member_id` + AND `member_payout`.`yearmonth` = `member_dl_plings`.`yearmonth` + LEFT JOIN `tag_object` ON `tag_object`.`tag_type_id` = 1 AND `tag_object`.`tag_group_id` = 7 AND `tag_object`.`is_deleted` = 0 AND `tag_object`.`tag_object_id` = `project`.`project_id` + WHERE + `member_dl_plings`.`member_id` = :member_id + AND `member_dl_plings`.`yearmonth` = :yearmonth + + ORDER BY `member_dl_plings`.`yearmonth` DESC, `project_category`.`title`, `project`.`title` + "; + $result = Zend_Db_Table::getDefaultAdapter()->query($sql, array('member_id' => $member_id, 'yearmonth' => $yearmonth)); + + if ($result->rowCount() > 0) { + return $result->fetchAll(); + } else { + return array(); + + } + } + + public function getUserDownloadMonths($member_id, $year) + { + $sql = " + SELECT + DISTINCT `member_dl_plings`.`yearmonth`, `member_payout`.payment_transaction_id, `member_payout`.`status` + FROM + `member_dl_plings` + STRAIGHT_JOIN + `project` ON `project`.`project_id` = `member_dl_plings`.`project_id` + STRAIGHT_JOIN + `project_category` ON `project_category`.`project_category_id` = `member_dl_plings`.`project_category_id` + LEFT JOIN + `member_payout` ON `member_payout`.`member_id` = `member_dl_plings`.`member_id` + AND `member_payout`.`yearmonth` = `member_dl_plings`.`yearmonth` + LEFT JOIN `tag_object` ON `tag_object`.`tag_type_id` = 1 AND `tag_object`.`tag_group_id` = 7 AND `tag_object`.`is_deleted` = 0 AND `tag_object`.`tag_object_id` = `project`.`project_id` + WHERE + `member_dl_plings`.`member_id` = :member_id + AND SUBSTR(`member_dl_plings`.`yearmonth`,1,4) = :year + ORDER BY `member_dl_plings`.`yearmonth` DESC + "; + $result = Zend_Db_Table::getDefaultAdapter()->query($sql, array('member_id' => $member_id, 'year' => $year)); + + if ($result->rowCount() > 0) { + return $result->fetchAll(); + } else { + return array(); + + } + } + + public function getUserDownloadYears($member_id) + { + $sql = " + SELECT + + SUBSTR(`member_dl_plings`.`yearmonth`,1,4) as year, + MAX(`member_dl_plings`.`yearmonth`) as max_yearmonth, + SUM(`member_payout`.amount) as sum_amount + FROM + `member_dl_plings` + STRAIGHT_JOIN + `project` ON `project`.`project_id` = `member_dl_plings`.`project_id` + STRAIGHT_JOIN + `project_category` ON `project_category`.`project_category_id` = `member_dl_plings`.`project_category_id` + LEFT JOIN + `member_payout` ON `member_payout`.`member_id` = `member_dl_plings`.`member_id` + AND `member_payout`.`yearmonth` = `member_dl_plings`.`yearmonth` + LEFT JOIN `tag_object` ON `tag_object`.`tag_type_id` = 1 AND `tag_object`.`tag_group_id` = 7 AND `tag_object`.`is_deleted` = 0 AND `tag_object`.`tag_object_id` = `project`.`project_id` + WHERE + `member_dl_plings`.`member_id` = :member_id + GROUP BY SUBSTR(`member_dl_plings`.`yearmonth`,1,4) + ORDER BY SUBSTR(`member_dl_plings`.`yearmonth`,1,4) DESC + "; + $result = Zend_Db_Table::getDefaultAdapter()->query($sql, array('member_id' => $member_id)); + + if ($result->rowCount() > 0) { + return $result->fetchAll(); + } else { + return array(); + + } + } public function getMonthEarn($member_id,$yyyymm) { $sql = " select sum(probably_payout_amount) amount from member_dl_plings where member_id=:member_id and yearmonth=:yyyymm and is_pling_excluded = 0 and is_license_missing = 0"; $resultSet = Zend_Db_Table::getDefaultAdapter()->fetchAll($sql, array('member_id' => $member_id,'yyyymm' =>$yyyymm)); return array_pop($resultSet); } } \ No newline at end of file diff --git a/application/modules/default/plugins/AclRules.php b/application/modules/default/plugins/AclRules.php index f1cc4ae54..2cdc54328 100644 --- a/application/modules/default/plugins/AclRules.php +++ b/application/modules/default/plugins/AclRules.php @@ -1,343 +1,346 @@ . **/ class Default_Plugin_AclRules extends Zend_Acl { const ROLENAME_GUEST = 'guest'; const ROLENAME_COOKIEUSER = 'cookieuser'; const ROLENAME_FEUSER = 'feuser'; const ROLENAME_MODERATOR = 'moderator'; const ROLENAME_STAFF = 'staff'; const ROLENAME_ADMIN = 'admin'; const ROLENAME_SYSUSER = 'sysuser'; function __construct() { $this->addRole(new Zend_Acl_Role (self::ROLENAME_GUEST)); $this->addRole(new Zend_Acl_Role (self::ROLENAME_COOKIEUSER), self::ROLENAME_GUEST); $this->addRole(new Zend_Acl_Role (self::ROLENAME_FEUSER), self::ROLENAME_COOKIEUSER); $this->addRole(new Zend_Acl_Role (self::ROLENAME_MODERATOR), self::ROLENAME_FEUSER); $this->addRole(new Zend_Acl_Role (self::ROLENAME_STAFF), self::ROLENAME_FEUSER); $this->addRole(new Zend_Acl_Role (self::ROLENAME_ADMIN)); $this->addRole(new Zend_Acl_Role (self::ROLENAME_SYSUSER)); $this->addResource(new Zend_Acl_Resource ('default_logout')); $this->addResource(new Zend_Acl_Resource ('default_oauth')); $this->addResource(new Zend_Acl_Resource ('default_authorization')); $this->addResource(new Zend_Acl_Resource ('default_button')); $this->addResource(new Zend_Acl_Resource ('default_categories')); $this->addResource(new Zend_Acl_Resource ('default_community')); $this->addResource(new Zend_Acl_Resource ('default_content')); $this->addResource(new Zend_Acl_Resource ('default_discovery')); $this->addResource(new Zend_Acl_Resource ('default_donationlist')); $this->addResource(new Zend_Acl_Resource ('default_support')); $this->addResource(new Zend_Acl_Resource ('default_error')); $this->addResource(new Zend_Acl_Resource ('default_explore')); $this->addResource(new Zend_Acl_Resource ('default_gateway')); $this->addResource(new Zend_Acl_Resource ('default_hive')); $this->addResource(new Zend_Acl_Resource ('default_home')); $this->addResource(new Zend_Acl_Resource ('default_ocsv1')); // OCS API $this->addResource(new Zend_Acl_Resource ('default_embedv1')); // embed API $this->addResource(new Zend_Acl_Resource ('default_productcategory')); $this->addResource(new Zend_Acl_Resource ('default_productcomment')); $this->addResource(new Zend_Acl_Resource ('default_product')); $this->addResource(new Zend_Acl_Resource ('default_report')); $this->addResource(new Zend_Acl_Resource ('default_rectification')); $this->addResource(new Zend_Acl_Resource ('default_rss')); $this->addResource(new Zend_Acl_Resource ('default_settings')); $this->addResource(new Zend_Acl_Resource ('default_supporterbox')); $this->addResource(new Zend_Acl_Resource ('default_plingbox')); $this->addResource(new Zend_Acl_Resource ('default_user')); $this->addResource(new Zend_Acl_Resource ('default_widget')); $this->addResource(new Zend_Acl_Resource ('default_file')); $this->addResource(new Zend_Acl_Resource ('default_plings')); $this->addResource(new Zend_Acl_Resource ('default_gitfaq')); $this->addResource(new Zend_Acl_Resource ('default_spam')); $this->addResource(new Zend_Acl_Resource ('default_moderation')); $this->addResource(new Zend_Acl_Resource ('default_duplicates')); $this->addResource(new Zend_Acl_Resource ('default_misuse')); $this->addResource(new Zend_Acl_Resource ('default_credits')); $this->addResource(new Zend_Acl_Resource ('default_ads')); $this->addResource(new Zend_Acl_Resource ('default_dl')); $this->addResource(new Zend_Acl_Resource ('default_password')); $this->addResource(new Zend_Acl_Resource ('default_verify')); $this->addResource(new Zend_Acl_Resource ('default_login')); $this->addResource(new Zend_Acl_Resource ('default_stati')); $this->addResource(new Zend_Acl_Resource ('default_tag')); $this->addResource(new Zend_Acl_Resource ('backend_categories')); $this->addResource(new Zend_Acl_Resource ('backend_vcategories')); $this->addResource(new Zend_Acl_Resource ('backend_categorytag')); $this->addResource(new Zend_Acl_Resource ('backend_categorytaggroup')); $this->addResource(new Zend_Acl_Resource ('backend_claim')); $this->addResource(new Zend_Acl_Resource ('backend_comments')); $this->addResource(new Zend_Acl_Resource ('backend_content')); $this->addResource(new Zend_Acl_Resource ('backend_faq')); $this->addResource(new Zend_Acl_Resource ('backend_hive')); $this->addResource(new Zend_Acl_Resource ('backend_hiveuser')); $this->addResource(new Zend_Acl_Resource ('backend_index')); $this->addResource(new Zend_Acl_Resource ('backend_mail')); $this->addResource(new Zend_Acl_Resource ('backend_member')); $this->addResource(new Zend_Acl_Resource ('backend_memberpayout')); $this->addResource(new Zend_Acl_Resource ('backend_memberpaypaladdress')); $this->addResource(new Zend_Acl_Resource ('backend_paypalvalidstatus')); $this->addResource(new Zend_Acl_Resource ('backend_payoutstatus')); $this->addResource(new Zend_Acl_Resource ('backend_operatingsystem')); $this->addResource(new Zend_Acl_Resource ('backend_project')); $this->addResource(new Zend_Acl_Resource ('backend_ranking')); $this->addResource(new Zend_Acl_Resource ('backend_reportcomments')); $this->addResource(new Zend_Acl_Resource ('backend_reportproducts')); $this->addResource(new Zend_Acl_Resource ('backend_search')); $this->addResource(new Zend_Acl_Resource ('backend_storecategories')); $this->addResource(new Zend_Acl_Resource ('backend_vstorecategories')); $this->addResource(new Zend_Acl_Resource ('backend_store')); $this->addResource(new Zend_Acl_Resource ('backend_tag')); $this->addResource(new Zend_Acl_Resource ('backend_user')); $this->addResource(new Zend_Acl_Resource ('backend_tags')); $this->addResource(new Zend_Acl_Resource ('backend_ghnsexcluded')); $this->addResource(new Zend_Acl_Resource ('backend_letteravatar')); $this->addResource(new Zend_Acl_Resource ('backend_group')); $this->addResource(new Zend_Acl_Resource ('backend_spamkeywords')); $this->addResource(new Zend_Acl_Resource ('backend_cdiscourse')); $this->addResource(new Zend_Acl_Resource ('backend_cgitlab')); $this->addResource(new Zend_Acl_Resource ('backend_cldap')); $this->addResource(new Zend_Acl_Resource ('backend_coauth')); $this->addResource(new Zend_Acl_Resource ('backend_cexport')); $this->addResource(new Zend_Acl_Resource ('statistics_data')); $this->allow(self::ROLENAME_GUEST, array( 'statistics_data' )); $this->allow(self::ROLENAME_GUEST, array( 'default_logout', 'default_authorization', 'default_button', 'default_categories', 'default_content', 'default_community', 'default_donationlist', 'default_error', 'default_explore', 'default_gateway', 'default_hive', 'default_home', 'default_ocsv1', // OCS API 'default_embedv1', // embed API 'default_productcategory', 'default_rss', 'default_supporterbox', 'default_plingbox', 'default_oauth', 'default_plings', 'default_gitfaq', 'default_ads', 'default_dl', 'default_stati', 'default_password', 'default_verify', 'default_login' )); $this->allow(self::ROLENAME_SYSUSER, array( 'default_authorization', 'default_button', 'default_categories', 'default_content', 'default_community', 'default_donationlist', 'default_error', 'default_explore', 'default_gateway', 'default_hive', 'default_home', 'default_ocsv1', // OCS API 'default_embedv1', // embed API 'default_productcategory', 'default_report', 'default_rss', 'default_supporterbox', 'default_plingbox', 'default_oauth', 'default_plings', 'default_ads', 'default_dl', 'default_stati', 'default_password' )); $this->allow(self::ROLENAME_COOKIEUSER, array( 'default_logout', 'default_productcomment', 'default_settings', 'default_support', 'default_tag', 'default_rectification' )); $this->allow(self::ROLENAME_STAFF, array( 'backend_index', 'backend_categories', 'backend_categorytag', 'backend_claim', 'backend_comments', 'backend_content', 'backend_store', 'backend_storecategories', 'backend_operatingsystem', 'backend_reportcomments', 'backend_reportproducts', 'backend_search', 'backend_group' )); $this->allow(self::ROLENAME_ADMIN); // resource access rights in detail $this->allow(self::ROLENAME_GUEST, 'backend_group', array('newgroup')); // resource default_product $this->allow(self::ROLENAME_GUEST, 'default_product', array( 'index', 'show', 'getupdatesajax', 'updates', 'follows', 'fetch', 'search', 'startdownload', 'ppload', 'loadratings', 'loadinstallinstruction' )); // resource default_product $this->allow(self::ROLENAME_SYSUSER, 'default_product', array( 'index', 'show', 'getupdatesajax', 'updates', 'follows', 'fetch', 'search', 'startdownload', 'ppload', 'loadratings' )); $this->allow(self::ROLENAME_COOKIEUSER, 'default_product', array( 'add', 'rating', 'follow', 'unfollow', 'plingproject', 'followproject', 'unplingproject', 'add', 'pling', 'pay', 'dwolla', 'paymentok', 'paymentcancel', 'saveproduct', 'claim' )); $this->allow(self::ROLENAME_MODERATOR, 'backend_project', array( 'doghnsexclude' )); $this->allow(self::ROLENAME_MODERATOR, 'default_moderation', array( 'index','list' )); $this->allow(self::ROLENAME_MODERATOR, 'default_duplicates', array( 'index' )); $this->allow(self::ROLENAME_COOKIEUSER, 'default_product', array( 'edit', 'saveupdateajax', 'deleteupdateajax', 'update', 'preview', 'delete', 'unpublish', 'publish', 'verifycode', 'makerconfig', 'addpploadfile', 'updatepploadfile', 'deletepploadfile', 'deletepploadfiles', 'updatepackagetype', 'updatearchitecture', ), new Default_Plugin_Acl_IsProjectOwnerAssertion()); // resource default_support $this->allow(self::ROLENAME_COOKIEUSER, 'default_support', array('index', 'pay', 'paymentok', 'paymentcancel')); // resource default_support $this->allow(self::ROLENAME_COOKIEUSER, 'default_report', array('comment', 'product', 'productfraud', 'productclone')); // resource default_widget $this->allow(self::ROLENAME_GUEST, 'default_widget', array('index', 'render')); $this->allow(self::ROLENAME_COOKIEUSER, 'default_widget', array('save', 'savedefault', 'config'), new Default_Plugin_Acl_IsProjectOwnerAssertion()); $this->allow(self::ROLENAME_COOKIEUSER, 'default_file', array( 'gitlink', 'link', ), new Default_Plugin_Acl_IsProjectOwnerAssertion()); // resource default_user $this->allow(self::ROLENAME_GUEST, 'default_home', array('baseurlajax','forumurlajax','blogurlajax','storenameajax','domainsajax', 'userdataajax', 'loginurlajax', 'metamenujs','metamenubundlejs','fetchforgit')); // resource default_user $this->allow(self::ROLENAME_GUEST, 'default_user', array('index', 'aboutme', 'share', 'report', 'about', 'tooltip', 'avatar', 'userdataajax')); $this->allow(self::ROLENAME_COOKIEUSER, 'default_user', array( 'follow', 'unfollow', 'settings', 'products', 'news', 'activities', 'payments', 'income', 'payout', 'plings', + 'plingsold', + 'plingsajax', + 'plingsmonthajax', 'downloadhistory', 'likes' )); $this->allow(self::ROLENAME_COOKIEUSER, 'default_tag', array('filter', 'add', 'del', 'assign', 'remove')); } } diff --git a/application/modules/default/views/scripts/user/partials/loopPlings.phtml b/application/modules/default/views/scripts/user/partials/loopPlings.phtml index 22899f6bb..b333b157f 100644 --- a/application/modules/default/views/scripts/user/partials/loopPlings.phtml +++ b/application/modules/default/views/scripts/user/partials/loopPlings.phtml @@ -1,482 +1,177 @@ . **/ ?> -"; - - if($showErrMsg) { - echo '
'; - } else { - print($currency->toCurrency($product['num_downloads'] * $product['dl_pling_factor'] / 100)); - } - ?> - - - - -hasIdentity() AND Zend_Auth::getInstance()->getIdentity()->roleName == 'admin') { -?> -
- -
-
- toCurrency( ($product['num_downloads'] * $product['dl_pling_factor'] / 100) * $product['laplace_score'])); ?> -
- - -
- - -
-
- 0) { - $show_payout_new_sum = $show_payout_new_sum ; - - } else { - $show_payout_new_sum = $payout_sum_new; - } - ?> - toCurrency($show_payout_new_sum) ?> - -   - - -
- - - toCurrency($sum_total_month_score); - if(!$showErrMsg) { - $sum_total_month += $payout_sum; - $sum_total_payout = $currency->toCurrency($sum_total_month); - $sum_total_month_new += $show_payout_new_sum; - $sum_total_payout_new = $currency->toCurrency($sum_total_month_new); - } - - $sum_total_text = 'Possible payout for this month (*):'; - - $payout_success = false; - if ($product['status'] == Default_Model_DbTable_MemberPayout::$PAYOUT_STATUS_COMPLETED) { - $payout_success = true; - $sum_total_payout_success = $currency->toCurrency($product['amount']); - $sum_total_text_success = 'Actually successfully paid amount: '; - } - $has_paypal = $product['paypal_mail'] ? true : false; - } - - $sum_total_month_view = number_format($sum_total_month); - ?> -
-hasIdentity() AND Zend_Auth::getInstance()->getIdentity()->roleName == 'admin') { -?> -
- -
- - -
- -hasIdentity() AND Zend_Auth::getInstance()->getIdentity()->roleName == 'admin') { -?> -
-
- -
-
- -
- - - - view_member; - if(!isset($member['paypal_mail']) || $member['paypal_mail'] == '') { - $has_paypal = false; - $paypalWarning = 'You have no PayPal account configured. Please go to your settings page here.'; - } else { - $has_paypal = true; - } - } else { - $paypalWarning = 'We found no valid Paypal account for this month. That\'s why we could not pay you any money. In order to receive money for the current month, please make sure that a paypal account is registered. Go to your settings page here.'; - } - if (false == $has_paypal) { - echo ''; - } - - if (($sum_total_month/100) < 1) { - echo ''; - } -?> - - -'; - echo '
No Data
'; - echo '
'; - echo '
Possible payout for this month (*):
$0.00
'; - echo '
'; - echo ''; -} - - -?> - - - - - -inlineScript()->appendScript( - ' $(document).ready(function(){ - $(\'[data-toggle="popover"]\').popover(); - }); - '); \ No newline at end of file +
\ No newline at end of file diff --git a/application/modules/default/views/scripts/user/partials/loopPlings.phtml b/application/modules/default/views/scripts/user/partials/loopPlingsForMonth.phtml similarity index 56% copy from application/modules/default/views/scripts/user/partials/loopPlings.phtml copy to application/modules/default/views/scripts/user/partials/loopPlingsForMonth.phtml index 22899f6bb..797bf26bf 100644 --- a/application/modules/default/views/scripts/user/partials/loopPlings.phtml +++ b/application/modules/default/views/scripts/user/partials/loopPlingsForMonth.phtml @@ -1,482 +1,326 @@ . **/ ?> +$modelDownload = new Default_Model_StatDownload(); +$yearmonth = null; -
-
-
-hasIdentity() AND Zend_Auth::getInstance()->getIdentity()->roleName == 'admin') { -?> -
Products
-yearmonth)) { + $yearmonth = $this->yearmonth; +} ?> -
Products
- -
Downloads
-
Pling-Factor
-
Payout
-hasIdentity() AND Zend_Auth::getInstance()->getIdentity()->roleName == 'admin') { -?> -
Score-Factor
-
Payout
- - -
Plings
-
Potential Payout**
-
-
countDownloadsOverall > 0) { - foreach ($allDownloads as $month => $products) { - $printMonth = new DateTime($month.'01'); + +$currentDate = date("Ym",time()); +$printCurrentMonth = new DateTime($currentDate.'01'); + +$printMonth = new DateTime($yearmonth.'01'); +$printDate = $printMonth->format('M Y'); + +$allDownloads = $modelDownload->getUserDownloadsForMonth($this->member->member_id, $yearmonth); +$countDownloadsOverall = count($allDownloads); + +if ($countDownloadsOverall > 0) { + $firstProduct = $allDownloads[0]; + if ($firstProduct) { + $printMonth = new DateTime($firstProduct['yearmonth'].'01'); $printCurrentMonth = new DateTime($currentDate.'01'); if($printMonth == $printCurrentMonth) { $isCurrentMonth = true; } else { $isCurrentMonth = false; } $sum_total_month_score = 0; $sum_total_month = 0; $sum_total_month_new = 0; $sum_total_text = ''; $sum_total_payout = 0; $sum_total_payout_new = 0; ?> -
+
+ foreach ($allDownloads as $product) { ?>
-hasIdentity() AND Zend_Auth::getInstance()->getIdentity()->roleName == 'admin') { -?> -
- -
- - - +
- - - -
*/ ?>
"; $showErrMsg = false; if($isCurrentMonth) { if($product['is_license_missing_now'] == 1) { $errorMsg .= "
  • Please specify a License
  • "; $showErrMsg = true; } if($product['is_source_missing_now'] == 1) { $errorMsg .= "
  • Please specify a link to the online source repository
  • "; $showErrMsg = true; } if($product['is_pling_excluded_now'] == 1) { $errorMsg .= "
  • This Product has been excluded from plings
  • "; $showErrMsg = true; } $sum_plings = $product['num_plings_now']; } else { if($product['is_license_missing'] == 1) { $errorMsg .= "
  • License was not specified
  • "; $showErrMsg = true; } if($product['is_source_missing'] == 1) { $errorMsg .= "
  • Link to the online source repository was not specified
  • "; $showErrMsg = true; } if($product['is_pling_excluded'] == 1) { $errorMsg .= "
  • This Product has been excluded from plings
  • "; $showErrMsg = true; } $sum_plings = $product['num_plings']; } $errorMsg .= ""; if($showErrMsg) { echo '
    '; } else { print($currency->toCurrency($product['num_downloads'] * $product['dl_pling_factor'] / 100)); } ?>
    - -hasIdentity() AND Zend_Auth::getInstance()->getIdentity()->roleName == 'admin') { -?> -
    - -
    -
    - toCurrency( ($product['num_downloads'] * $product['dl_pling_factor'] / 100) * $product['laplace_score'])); ?> -
    - - -
    - - -
    -
    - 0) { - $show_payout_new_sum = $show_payout_new_sum ; - - } else { - $show_payout_new_sum = $payout_sum_new; - } - ?> - toCurrency($show_payout_new_sum) ?> - -   - + + if($sum_plings && $sum_plings < $payout_sum) { + $show_payout_new_sum = $sum_plings; + $payout_sum_new = $sum_plings; + } + if($sum_plings && $sum_plings>0) { + $show_payout_new_sum = $show_payout_new_sum ; + } else { + $show_payout_new_sum = $payout_sum_new; + } + ?> +
    toCurrency($sum_total_month_score); if(!$showErrMsg) { $sum_total_month += $payout_sum; $sum_total_payout = $currency->toCurrency($sum_total_month); $sum_total_month_new += $show_payout_new_sum; $sum_total_payout_new = $currency->toCurrency($sum_total_month_new); } $sum_total_text = 'Possible payout for this month (*):'; $payout_success = false; if ($product['status'] == Default_Model_DbTable_MemberPayout::$PAYOUT_STATUS_COMPLETED) { $payout_success = true; $sum_total_payout_success = $currency->toCurrency($product['amount']); $sum_total_text_success = 'Actually successfully paid amount: '; } $has_paypal = $product['paypal_mail'] ? true : false; } $sum_total_month_view = number_format($sum_total_month); ?>
    -hasIdentity() AND Zend_Auth::getInstance()->getIdentity()->roleName == 'admin') { -?> -
    - -
    - - +
    - -hasIdentity() AND Zend_Auth::getInstance()->getIdentity()->roleName == 'admin') { -?> -
    -
    - -
    -
    -
    view_member; if(!isset($member['paypal_mail']) || $member['paypal_mail'] == '') { $has_paypal = false; $paypalWarning = 'You have no PayPal account configured. Please go to your settings page here.'; } else { $has_paypal = true; } } else { $paypalWarning = 'We found no valid Paypal account for this month. That\'s why we could not pay you any money. In order to receive money for the current month, please make sure that a paypal account is registered. Go to your settings page here.'; } if (false == $has_paypal) { echo ''; } if (($sum_total_month/100) < 1) { echo ''; } ?>
    '; echo '
    No Data
    '; echo '
    '; echo '
    Possible payout for this month (*):
    $0.00
    '; echo '
    '; echo '
    '; } ?> + + -
    - +
    + inlineScript()->appendScript( ' $(document).ready(function(){ $(\'[data-toggle="popover"]\').popover(); }); '); \ No newline at end of file diff --git a/application/modules/default/views/scripts/user/partials/loopPlings.phtml b/application/modules/default/views/scripts/user/partials/loopPlingsOld.phtml similarity index 100% copy from application/modules/default/views/scripts/user/partials/loopPlings.phtml copy to application/modules/default/views/scripts/user/partials/loopPlingsOld.phtml diff --git a/application/modules/default/views/scripts/user/plings.phtml b/application/modules/default/views/scripts/user/plings.phtml index 9ee899f4e..1767383b1 100644 --- a/application/modules/default/views/scripts/user/plings.phtml +++ b/application/modules/default/views/scripts/user/plings.phtml @@ -1,89 +1,264 @@ . **/ $this->tab = 'plings'; $this->countDownloadsOverall = 0; -$modelDownload = new Default_Model_StatDownload(); -$this->downloads = $modelDownload->getUserDownloads($this->member->member_id); +$currentDate = date("Ym",time()); +$currentYear = date("Y",time()); -$this->countDownloadsOverall = count($this->downloads); +$modelDownload = new Default_Model_StatDownload(); +$downloadYears = $modelDownload->getUserDownloadYears($this->member->member_id); +#$this->countDownloadsOverall = count($this->downloads); ?> + +
    render('user/partials/userHeader_top.phtml'); ?>
    render('user/partials/userHeader.phtml'); ?>

    translate('Payout') ?>

    view_member; if($member->pling_excluded == 1) { echo "


    This account has been excluded from receiving plings, due to various misuses.

    "; } ?>
    view_member; if($member->paypal_valid_status > 100) { $status = $this->paypal_valid_status; if($status->color == 'red') { echo ''; } if($status->color == 'yellow') { echo ''; } if($status->color == 'blue') { echo ''; } if($status->color == 'green') { echo ''; } } ?>
    pling_excluded == 0 || (Zend_Auth::getInstance()->hasIdentity() AND Zend_Auth::getInstance()->getIdentity()->roleName == 'admin')) { + echo ""; ?>
    - countDownloadsOverall > 0) { - echo $this->render('user/partials/loopPlings.phtml'); - //} else { - // echo ''; - //} - ?> + +
    + +
    + +
    + +
    + + \ No newline at end of file diff --git a/application/modules/default/views/scripts/user/plingsajax.phtml b/application/modules/default/views/scripts/user/plingsajax.phtml new file mode 100644 index 000000000..ea6f96b95 --- /dev/null +++ b/application/modules/default/views/scripts/user/plingsajax.phtml @@ -0,0 +1,28 @@ +. + **/ + +//if ($this->countDownloadsOverall > 0) { +echo $this->render('user/partials/loopPlings.phtml'); +//} else { +// echo ''; +//} +?> diff --git a/application/modules/default/views/scripts/user/plingsmonthajax.phtml b/application/modules/default/views/scripts/user/plingsmonthajax.phtml new file mode 100644 index 000000000..49f30fa03 --- /dev/null +++ b/application/modules/default/views/scripts/user/plingsmonthajax.phtml @@ -0,0 +1,47 @@ +. + **/ + +$this->tab = 'plings'; +$this->countDownloadsOverall = 0; + +#$modelDownload = new Default_Model_StatDownload(); +#$this->downloads = $modelDownload->getUserDownloads($this->member->member_id); +#$this->countDownloadsOverall = count($this->downloads); + +$member = $this->view_member; +?> +pling_excluded == 0 || (Zend_Auth::getInstance()->hasIdentity() AND Zend_Auth::getInstance()->getIdentity()->roleName == 'admin')) { +?> +
    + + countDownloadsOverall > 0) { + echo $this->render('user/partials/loopPlingsForMonth.phtml'); + //} else { + // echo ''; + //} + ?> +
    + diff --git a/application/modules/default/views/scripts/user/plings.phtml b/application/modules/default/views/scripts/user/plingsold.phtml similarity index 99% copy from application/modules/default/views/scripts/user/plings.phtml copy to application/modules/default/views/scripts/user/plingsold.phtml index 9ee899f4e..bb2364921 100644 --- a/application/modules/default/views/scripts/user/plings.phtml +++ b/application/modules/default/views/scripts/user/plingsold.phtml @@ -1,89 +1,88 @@ . **/ $this->tab = 'plings'; $this->countDownloadsOverall = 0; $modelDownload = new Default_Model_StatDownload(); $this->downloads = $modelDownload->getUserDownloads($this->member->member_id); - $this->countDownloadsOverall = count($this->downloads); ?>
    render('user/partials/userHeader_top.phtml'); ?>
    render('user/partials/userHeader.phtml'); ?>

    translate('Payout') ?>

    view_member; if($member->pling_excluded == 1) { echo "


    This account has been excluded from receiving plings, due to various misuses.

    "; } ?>
    view_member; if($member->paypal_valid_status > 100) { $status = $this->paypal_valid_status; if($status->color == 'red') { echo ''; } if($status->color == 'yellow') { echo ''; } if($status->color == 'blue') { echo ''; } if($status->color == 'green') { echo ''; } } ?>
    pling_excluded == 0 || (Zend_Auth::getInstance()->hasIdentity() AND Zend_Auth::getInstance()->getIdentity()->roleName == 'admin')) { ?>
    countDownloadsOverall > 0) { - echo $this->render('user/partials/loopPlings.phtml'); + echo $this->render('user/partials/loopPlingsOld.phtml'); //} else { // echo ''; //} ?>