mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 19:43:16 +00:00
many comments of last pull request applied
This commit is contained in:
@@ -15,7 +15,6 @@
|
|||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
|
|
||||||
@@ -95,12 +94,12 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
return $this->version;
|
return $this->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of phraseanet tasks
|
* Get a list of phraseanet tasks
|
||||||
*
|
*
|
||||||
* @param \Silex\Application $app The API silex application
|
* @param \Silex\Application $app The API silex application
|
||||||
* @return \API_V1_result
|
* @return \API_V1_result
|
||||||
*/
|
*/
|
||||||
public function get_task_list(Application $app)
|
public function get_task_list(Application $app)
|
||||||
{
|
{
|
||||||
$result = new \API_V1_result($app['request'], $this);
|
$result = new \API_V1_result($app['request'], $this);
|
||||||
@@ -112,10 +111,10 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$ret = array();
|
$ret = array();
|
||||||
foreach ($tasks as $task) {
|
foreach ($tasks as $task) {
|
||||||
$ret[$task->getID()] = array(
|
$ret[$task->getID()] = array(
|
||||||
'id' => $task->getID(),
|
'id' => $task->getID(),
|
||||||
'state' => $task->getState(),
|
'state' => $task->getState(),
|
||||||
'pid' => $task->getPID(),
|
'pid' => $task->getPID(),
|
||||||
'title' => $task->getTitle(),
|
'title' => $task->getTitle(),
|
||||||
'last_exec_time' => $task->getLastExecTime()
|
'last_exec_time' => $task->getLastExecTime()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -177,7 +176,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$ret = array('success' => true);
|
$ret = array('success' => true);
|
||||||
try {
|
try {
|
||||||
$task = $taskManager->getTask($taskId);
|
$task = $taskManager->getTask($taskId);
|
||||||
$task->setState(\task_abstract::STATUS_TOSTART);
|
$task->setState(\task_abstract::STATE_TOSTART);
|
||||||
} catch (\Exception_NotFound $e) {
|
} catch (\Exception_NotFound $e) {
|
||||||
$result->set_error_code(404);
|
$result->set_error_code(404);
|
||||||
$ret = array('success' => false);
|
$ret = array('success' => false);
|
||||||
@@ -209,7 +208,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$ret = array();
|
$ret = array();
|
||||||
try {
|
try {
|
||||||
$task = $taskManager->getTask($taskId);
|
$task = $taskManager->getTask($taskId);
|
||||||
$task->setState(\task_abstract::STATUS_TOSTOP);
|
$task->setState(\task_abstract::STATE_TOSTOP);
|
||||||
} catch (\Exception_NotFound $e) {
|
} catch (\Exception_NotFound $e) {
|
||||||
$result->set_error_code(404);
|
$result->set_error_code(404);
|
||||||
$ret = array('success' => false);
|
$ret = array('success' => false);
|
||||||
@@ -279,12 +278,12 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Information the cache system used by the instance
|
* Get Information the cache system used by the instance
|
||||||
*
|
*
|
||||||
* @param \Silex\Application $app the silex application
|
* @param \Silex\Application $app the silex application
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function get_cache_info(Application $app)
|
protected function get_cache_info(Application $app)
|
||||||
{
|
{
|
||||||
$mainCache = $app['Core']['Cache'];
|
$mainCache = $app['Core']['Cache'];
|
||||||
@@ -294,7 +293,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
|
|
||||||
if ($mainCache instanceof \Alchemy\Phrasea\Cache\Cache) {
|
if ($mainCache instanceof \Alchemy\Phrasea\Cache\Cache) {
|
||||||
$ret['cache']['main'] = array(
|
$ret['cache']['main'] = array(
|
||||||
'type' => $mainCache->getName(),
|
'type' => $mainCache->getName(),
|
||||||
'stats' => $mainCache->getStats()
|
'stats' => $mainCache->getStats()
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -303,7 +302,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
|
|
||||||
if ($opCodeCache instanceof \Alchemy\Phrasea\Cache\Cache) {
|
if ($opCodeCache instanceof \Alchemy\Phrasea\Cache\Cache) {
|
||||||
$ret['cache']['op_code'] = array(
|
$ret['cache']['op_code'] = array(
|
||||||
'type' => $mainCache->getName(),
|
'type' => $mainCache->getName(),
|
||||||
'stats' => $opCodeCache->getStats()
|
'stats' => $opCodeCache->getStats()
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -324,7 +323,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$ret = array();
|
$ret = array();
|
||||||
|
|
||||||
$ret['phraseanet']['version'] = array(
|
$ret['phraseanet']['version'] = array(
|
||||||
'name' => $app['Core']['Version']::getName(),
|
'name' => $app['Core']['Version']::getName(),
|
||||||
'number' => $app['Core']['Version']::getNumber(),
|
'number' => $app['Core']['Version']::getNumber(),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -350,158 +349,158 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
|
|
||||||
return array(
|
return array(
|
||||||
'global_values' => array(
|
'global_values' => array(
|
||||||
'serverName' => $registry->get('GV_ServerName'),
|
'serverName' => $registry->get('GV_ServerName'),
|
||||||
'title' => $registry->get('GV_homeTitle'),
|
'title' => $registry->get('GV_homeTitle'),
|
||||||
'keywords' => $registry->get('GV_metaKeywords'),
|
'keywords' => $registry->get('GV_metaKeywords'),
|
||||||
'description' => $registry->get('GV_metaDescription'),
|
'description' => $registry->get('GV_metaDescription'),
|
||||||
'httpServer' => array(
|
'httpServer' => array(
|
||||||
'logErrors' => $registry->get('GV_log_errors'),
|
'logErrors' => $registry->get('GV_log_errors'),
|
||||||
'phpTimezone' => $registry->get('GV_timezone'),
|
'phpTimezone' => $registry->get('GV_timezone'),
|
||||||
'siteId' => $registry->get('GV_sit'),
|
'siteId' => $registry->get('GV_sit'),
|
||||||
'staticUrl' => $registry->get('GV_STATIC_URL'),
|
'staticUrl' => $registry->get('GV_STATIC_URL'),
|
||||||
'defaultLanguage' => $registry->get('id_GV_default_lng'),
|
'defaultLanguage' => $registry->get('id_GV_default_lng'),
|
||||||
'allowIndexing' => $registry->get('GV_allow_search_engine'),
|
'allowIndexing' => $registry->get('GV_allow_search_engine'),
|
||||||
'modes' => array(
|
'modes' => array(
|
||||||
'XsendFile' => $registry->get('GV_modxsendfile'),
|
'XsendFile' => $registry->get('GV_modxsendfile'),
|
||||||
'nginxXAccelRedirect' => $registry->get('GV_X_Accel_Redirect'),
|
'nginxXAccelRedirect' => $registry->get('GV_X_Accel_Redirect'),
|
||||||
'nginxXAccelRedirectMountPoint' => $registry->get('GV_X_Accel_Redirect_mount_point'),
|
'nginxXAccelRedirectMountPoint' => $registry->get('GV_X_Accel_Redirect_mount_point'),
|
||||||
'h264Streaming' => $registry->get('GV_h264_streaming'),
|
'h264Streaming' => $registry->get('GV_h264_streaming'),
|
||||||
'authTokenDirectory' => $registry->get('GV_mod_auth_token_directory'),
|
'authTokenDirectory' => $registry->get('GV_mod_auth_token_directory'),
|
||||||
'authTokenDirectoryPath' => $registry->get('GV_mod_auth_token_directory_path'),
|
'authTokenDirectoryPath' => $registry->get('GV_mod_auth_token_directory_path'),
|
||||||
'authTokenPassphrase' => $registry->get('GV_mod_auth_token_passphrase'),
|
'authTokenPassphrase' => $registry->get('GV_mod_auth_token_passphrase'),
|
||||||
),
|
),
|
||||||
'files' => array(
|
'files' => array(
|
||||||
'owner' => $registry->get('GV_filesOwner'),
|
'owner' => $registry->get('GV_filesOwner'),
|
||||||
'group' => $registry->get('GV_filesOwner'),
|
'group' => $registry->get('GV_filesOwner'),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'maintenance' => array(
|
'maintenance' => array(
|
||||||
'alertMessage' => $registry->get('GV_message'),
|
'alertMessage' => $registry->get('GV_message'),
|
||||||
'displayMessage' => $registry->get('GV_message_on'),
|
'displayMessage' => $registry->get('GV_message_on'),
|
||||||
),
|
),
|
||||||
'webServices' => array(
|
'webServices' => array(
|
||||||
'googleApi' => $registry->get('GV_google_api'),
|
'googleApi' => $registry->get('GV_google_api'),
|
||||||
'googleAnalyticsId' => $registry->get('GV_googleAnalytics'),
|
'googleAnalyticsId' => $registry->get('GV_googleAnalytics'),
|
||||||
'googleChromeFrameDisclaimer' => $registry->get('GV_display_gcf'),
|
'googleChromeFrameDisclaimer' => $registry->get('GV_display_gcf'),
|
||||||
'i18nWebService' => $registry->get('GV_i18n_service'),
|
'i18nWebService' => $registry->get('GV_i18n_service'),
|
||||||
'recaptacha' => array(
|
'recaptacha' => array(
|
||||||
'active' => $registry->get('GV_captchas'),
|
'active' => $registry->get('GV_captchas'),
|
||||||
'publicKey' => $registry->get('GV_captcha_public_key'),
|
'publicKey' => $registry->get('GV_captcha_public_key'),
|
||||||
'privateKey' => $registry->get('GV_captcha_private_key'),
|
'privateKey' => $registry->get('GV_captcha_private_key'),
|
||||||
),
|
),
|
||||||
'youtube' => array(
|
'youtube' => array(
|
||||||
'active' => $registry->get('GV_youtube_api'),
|
'active' => $registry->get('GV_youtube_api'),
|
||||||
'clientId' => $registry->get('GV_youtube_client_id'),
|
'clientId' => $registry->get('GV_youtube_client_id'),
|
||||||
'clientSecret' => $registry->get('GV_youtube_client_secret'),
|
'clientSecret' => $registry->get('GV_youtube_client_secret'),
|
||||||
'devKey' => $registry->get('GV_youtube_dev_key'),
|
'devKey' => $registry->get('GV_youtube_dev_key'),
|
||||||
),
|
),
|
||||||
'flickr' => array(
|
'flickr' => array(
|
||||||
'active' => $registry->get('GV_flickr_api'),
|
'active' => $registry->get('GV_flickr_api'),
|
||||||
'clientId' => $registry->get('GV_flickr_client_id'),
|
'clientId' => $registry->get('GV_flickr_client_id'),
|
||||||
'clientSecret' => $registry->get('GV_flickr_client_secret'),
|
'clientSecret' => $registry->get('GV_flickr_client_secret'),
|
||||||
),
|
),
|
||||||
'dailymtotion' => array(
|
'dailymtotion' => array(
|
||||||
'active' => $registry->get('GV_dailymotion_api'),
|
'active' => $registry->get('GV_dailymotion_api'),
|
||||||
'clientId' => $registry->get('GV_dailymotion_client_id'),
|
'clientId' => $registry->get('GV_dailymotion_client_id'),
|
||||||
'clientSecret' => $registry->get('GV_dailymotion_client_secret'),
|
'clientSecret' => $registry->get('GV_dailymotion_client_secret'),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'navigator' => array(
|
'navigator' => array(
|
||||||
'active' => $registry->get('GV_client_navigator'),
|
'active' => $registry->get('GV_client_navigator'),
|
||||||
),
|
),
|
||||||
'homepage' => array(
|
'homepage' => array(
|
||||||
'viewType' => $registry->get('GV_home_publi'),
|
'viewType' => $registry->get('GV_home_publi'),
|
||||||
),
|
),
|
||||||
'report' => array(
|
'report' => array(
|
||||||
'anonymous' => $registry->get('GV_anonymousReport'),
|
'anonymous' => $registry->get('GV_anonymousReport'),
|
||||||
),
|
),
|
||||||
'events' => array(
|
'events' => array(
|
||||||
'events' => $registry->get('GV_events'),
|
'events' => $registry->get('GV_events'),
|
||||||
'notifications' => $registry->get('GV_notifications'),
|
'notifications' => $registry->get('GV_notifications'),
|
||||||
),
|
),
|
||||||
'upload' => array(
|
'upload' => array(
|
||||||
'allowedFileExtension' => $registry->get('GV_appletAllowedFileEx'),
|
'allowedFileExtension' => $registry->get('GV_appletAllowedFileEx'),
|
||||||
),
|
),
|
||||||
'filesystem' => array(
|
'filesystem' => array(
|
||||||
'web' => $registry->get('GV_base_datapath_web'),
|
'web' => $registry->get('GV_base_datapath_web'),
|
||||||
'noWeb' => $registry->get('GV_base_datapath_noweb'),
|
'noWeb' => $registry->get('GV_base_datapath_noweb'),
|
||||||
'thumbnail' => $registry->get('GV_base_dataurl'),
|
'thumbnail' => $registry->get('GV_base_dataurl'),
|
||||||
),
|
),
|
||||||
'searchEngine' => array(
|
'searchEngine' => array(
|
||||||
'configuration' => array(
|
'configuration' => array(
|
||||||
'defaultQuery' => $registry->get('GV_defaultQuery'),
|
'defaultQuery' => $registry->get('GV_defaultQuery'),
|
||||||
'defaultQueryType' => $registry->get('GV_defaultQuery_type'),
|
'defaultQueryType' => $registry->get('GV_defaultQuery_type'),
|
||||||
),
|
),
|
||||||
'sphinx' => array(
|
'sphinx' => array(
|
||||||
'active' => $registry->get('GV_sphinx'),
|
'active' => $registry->get('GV_sphinx'),
|
||||||
'host' => $registry->get('GV_sphinx_host'),
|
'host' => $registry->get('GV_sphinx_host'),
|
||||||
'port' => $registry->get('GV_sphinx_port'),
|
'port' => $registry->get('GV_sphinx_port'),
|
||||||
'realtimeHost' => $registry->get('GV_sphinx_rt_host'),
|
'realtimeHost' => $registry->get('GV_sphinx_rt_host'),
|
||||||
'realtimePort' => $registry->get('GV_sphinx_rt_port'),
|
'realtimePort' => $registry->get('GV_sphinx_rt_port'),
|
||||||
),
|
),
|
||||||
'phrasea' => array(
|
'phrasea' => array(
|
||||||
'minChar' => $registry->get('GV_min_letters_truncation'),
|
'minChar' => $registry->get('GV_min_letters_truncation'),
|
||||||
'sort' => $registry->get('GV_phrasea_sort'),
|
'sort' => $registry->get('GV_phrasea_sort'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'binary' => array(
|
'binary' => array(
|
||||||
'phpCli' => $registry->get('GV_cli'),
|
'phpCli' => $registry->get('GV_cli'),
|
||||||
'phpIni' => $registry->get('GV_PHP_INI'),
|
'phpIni' => $registry->get('GV_PHP_INI'),
|
||||||
'imagick' => $registry->get('GV_imagick'),
|
'imagick' => $registry->get('GV_imagick'),
|
||||||
'swfExtract' => $registry->get('GV_swf_extract'),
|
'swfExtract' => $registry->get('GV_swf_extract'),
|
||||||
'pdf2swf' => $registry->get('GV_pdf2swf'),
|
'pdf2swf' => $registry->get('GV_pdf2swf'),
|
||||||
'swfRender' => $registry->get('GV_swf_render'),
|
'swfRender' => $registry->get('GV_swf_render'),
|
||||||
'unoconv' => $registry->get('GV_unoconv'),
|
'unoconv' => $registry->get('GV_unoconv'),
|
||||||
'ffmpeg' => $registry->get('GV_ffmpeg'),
|
'ffmpeg' => $registry->get('GV_ffmpeg'),
|
||||||
'mp4box' => $registry->get('GV_mp4box'),
|
'mp4box' => $registry->get('GV_mp4box'),
|
||||||
'pdftotext' => $registry->get('GV_pdftotext'),
|
'pdftotext' => $registry->get('GV_pdftotext'),
|
||||||
'pdfmaxpages' => $registry->get('GV_pdfmaxpages'),),
|
'pdfmaxpages' => $registry->get('GV_pdfmaxpages'),),
|
||||||
'mainConfiguration' => array(
|
'mainConfiguration' => array(
|
||||||
'adminMail' => $registry->get('GV_adminMail'),
|
'adminMail' => $registry->get('GV_adminMail'),
|
||||||
'viewBasAndCollName' => $registry->get('GV_view_bas_and_coll'),
|
'viewBasAndCollName' => $registry->get('GV_view_bas_and_coll'),
|
||||||
'chooseExportTitle' => $registry->get('GV_choose_export_title'),
|
'chooseExportTitle' => $registry->get('GV_choose_export_title'),
|
||||||
'defaultExportTitle' => $registry->get('GV_default_export_title'),
|
'defaultExportTitle' => $registry->get('GV_default_export_title'),
|
||||||
'socialTools' => $registry->get('GV_social_tools'),),
|
'socialTools' => $registry->get('GV_social_tools'),),
|
||||||
'modules' => array(
|
'modules' => array(
|
||||||
'thesaurus' => $registry->get('GV_thesaurus'),
|
'thesaurus' => $registry->get('GV_thesaurus'),
|
||||||
'storyMode' => $registry->get('GV_multiAndReport'),
|
'storyMode' => $registry->get('GV_multiAndReport'),
|
||||||
'docSubsitution' => $registry->get('GV_seeOngChgDoc'),
|
'docSubsitution' => $registry->get('GV_seeOngChgDoc'),
|
||||||
'subdefSubstitution' => $registry->get('GV_seeNewThumb'),),
|
'subdefSubstitution' => $registry->get('GV_seeNewThumb'),),
|
||||||
'email' => array(
|
'email' => array(
|
||||||
'defaultMailAddress' => $registry->get('GV_defaulmailsenderaddr'),
|
'defaultMailAddress' => $registry->get('GV_defaulmailsenderaddr'),
|
||||||
'smtp' => array(
|
'smtp' => array(
|
||||||
'active' => $registry->get('GV_smtp'),
|
'active' => $registry->get('GV_smtp'),
|
||||||
'auth' => $registry->get('GV_smtp_auth'),
|
'auth' => $registry->get('GV_smtp_auth'),
|
||||||
'host' => $registry->get('GV_smtp_host'),
|
'host' => $registry->get('GV_smtp_host'),
|
||||||
'port' => $registry->get('GV_smtp_port'),
|
'port' => $registry->get('GV_smtp_port'),
|
||||||
'secure' => $registry->get('GV_smtp_secure'),
|
'secure' => $registry->get('GV_smtp_secure'),
|
||||||
'user' => $registry->get('GV_smtp_user'),
|
'user' => $registry->get('GV_smtp_user'),
|
||||||
'password' => $registry->get('GV_smtp_password'),
|
'password' => $registry->get('GV_smtp_password'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'ftp' => array(
|
'ftp' => array(
|
||||||
'active' => $registry->get('GV_activeFTP'),
|
'active' => $registry->get('GV_activeFTP'),
|
||||||
'activeForUser' => $registry->get('GV_ftp_for_user'),),
|
'activeForUser' => $registry->get('GV_ftp_for_user'),),
|
||||||
'client' => array(
|
'client' => array(
|
||||||
'maxSizeDownload' => $registry->get('GV_download_max'),
|
'maxSizeDownload' => $registry->get('GV_download_max'),
|
||||||
'tabSearchMode' => $registry->get('GV_ong_search'),
|
'tabSearchMode' => $registry->get('GV_ong_search'),
|
||||||
'tabAdvSearchPosition' => $registry->get('GV_ong_advsearch'),
|
'tabAdvSearchPosition' => $registry->get('GV_ong_advsearch'),
|
||||||
'tabTopicsPosition' => $registry->get('GV_ong_topics'),
|
'tabTopicsPosition' => $registry->get('GV_ong_topics'),
|
||||||
'tabOngActifPosition' => $registry->get('GV_ong_actif'),
|
'tabOngActifPosition' => $registry->get('GV_ong_actif'),
|
||||||
'renderTopicsMode' => $registry->get('GV_client_render_topics'),
|
'renderTopicsMode' => $registry->get('GV_client_render_topics'),
|
||||||
'displayRolloverPreview' => $registry->get('GV_rollover_reg_preview'),
|
'displayRolloverPreview' => $registry->get('GV_rollover_reg_preview'),
|
||||||
'displayRolloverBasket' => $registry->get('GV_rollover_chu'),
|
'displayRolloverBasket' => $registry->get('GV_rollover_chu'),
|
||||||
'collRenderMode' => $registry->get('GV_client_coll_ckbox'),
|
'collRenderMode' => $registry->get('GV_client_coll_ckbox'),
|
||||||
'viewSizeBaket' => $registry->get('GV_viewSizeBaket'),
|
'viewSizeBaket' => $registry->get('GV_viewSizeBaket'),
|
||||||
'clientAutoShowProposals' => $registry->get('GV_clientAutoShowProposals'),
|
'clientAutoShowProposals' => $registry->get('GV_clientAutoShowProposals'),
|
||||||
'needAuth2DL' => $registry->get('GV_needAuth2DL'),),
|
'needAuth2DL' => $registry->get('GV_needAuth2DL'),),
|
||||||
'inscription' => array(
|
'inscription' => array(
|
||||||
'autoSelectDB' => $registry->get('GV_autoselectDB'),
|
'autoSelectDB' => $registry->get('GV_autoselectDB'),
|
||||||
'autoRegister' => $registry->get('GV_autoregister'),
|
'autoRegister' => $registry->get('GV_autoregister'),
|
||||||
),
|
),
|
||||||
'push' => array(
|
'push' => array(
|
||||||
'validationReminder' => $registry->get('GV_validation_reminder'),
|
'validationReminder' => $registry->get('GV_validation_reminder'),
|
||||||
'expirationValue' => $registry->get('GV_val_expiration'),
|
'expirationValue' => $registry->get('GV_val_expiration'),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -649,8 +648,8 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
$ret[$field->get_meta_struct_id()] = array(
|
$ret[$field->get_meta_struct_id()] = array(
|
||||||
'meta_structure_id' => $field->get_meta_struct_id(),
|
'meta_structure_id' => $field->get_meta_struct_id(),
|
||||||
'name' => $field->get_name(),
|
'name' => $field->get_name(),
|
||||||
'value' => $field->get_serialized_values(";"),
|
'value' => $field->get_serialized_values(";"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$result->set_datas($ret);
|
$result->set_datas($ret);
|
||||||
@@ -689,16 +688,16 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
'status' => is_array($request->get('status')) ? $request->get('status') : array(),
|
'status' => is_array($request->get('status')) ? $request->get('status') : array(),
|
||||||
'bases' => is_array($request->get('bases')) ? $request->get('bases') : array(),
|
'bases' => is_array($request->get('bases')) ? $request->get('bases') : array(),
|
||||||
'search_type' => $search_type,
|
'search_type' => $search_type,
|
||||||
'recordtype' => $record_type,
|
'recordtype' => $record_type,
|
||||||
'datemin' => $request->get('datemin') ? : '',
|
'datemin' => $request->get('datemin') ? : '',
|
||||||
'datemax' => $request->get('datemax') ? : '',
|
'datemax' => $request->get('datemax') ? : '',
|
||||||
'datefield' => $request->get('datefield') ? : '',
|
'datefield' => $request->get('datefield') ? : '',
|
||||||
'sort' => $request->get('sort') ? : '',
|
'sort' => $request->get('sort') ? : '',
|
||||||
'ord' => $request->get('ord') ? : '',
|
'ord' => $request->get('ord') ? : '',
|
||||||
'stemme' => $request->get('stemme') ? : '',
|
'stemme' => $request->get('stemme') ? : '',
|
||||||
'per_page' => $request->get('per_page') ? : 10,
|
'per_page' => $request->get('per_page') ? : 10,
|
||||||
'query' => $request->get('query') ? : '',
|
'query' => $request->get('query') ? : '',
|
||||||
'page' => (int) ($request->get('page') ? : 0),
|
'page' => (int) ($request->get('page') ? : 0),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (is_array($request->get('bases')) === false) {
|
if (is_array($request->get('bases')) === false) {
|
||||||
@@ -763,16 +762,16 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$search_result = $search_engine->query_per_page($params['query'], $params["page"], $perPage);
|
$search_result = $search_engine->query_per_page($params['query'], $params["page"], $perPage);
|
||||||
|
|
||||||
$ret = array(
|
$ret = array(
|
||||||
'total_pages' => $search_result->get_total_pages(),
|
'total_pages' => $search_result->get_total_pages(),
|
||||||
'current_page' => $search_result->get_current_page(),
|
'current_page' => $search_result->get_current_page(),
|
||||||
'available_results' => $search_result->get_count_available_results(),
|
'available_results' => $search_result->get_count_available_results(),
|
||||||
'total_results' => $search_result->get_count_total_results(),
|
'total_results' => $search_result->get_count_total_results(),
|
||||||
'error' => $search_result->get_error(),
|
'error' => $search_result->get_error(),
|
||||||
'warning' => $search_result->get_warning(),
|
'warning' => $search_result->get_warning(),
|
||||||
'query_time' => $search_result->get_query_time(),
|
'query_time' => $search_result->get_query_time(),
|
||||||
'search_indexes' => $search_result->get_search_indexes(),
|
'search_indexes' => $search_result->get_search_indexes(),
|
||||||
'suggestions' => $search_result->get_suggestions(),
|
'suggestions' => $search_result->get_suggestions(),
|
||||||
'results' => array(),
|
'results' => array(),
|
||||||
'query' => $search_engine->get_query(),
|
'query' => $search_engine->get_query(),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1179,9 +1178,9 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
{
|
{
|
||||||
$ret = array(
|
$ret = array(
|
||||||
'basket_element_id' => $basket_element->getId(),
|
'basket_element_id' => $basket_element->getId(),
|
||||||
'order' => $basket_element->getOrd(),
|
'order' => $basket_element->getOrd(),
|
||||||
'record' => $this->list_record($basket_element->getRecord()),
|
'record' => $this->list_record($basket_element->getRecord()),
|
||||||
'validation_item' => ! ! $basket_element->getValidationDatas(),
|
'validation_item' => ! ! $basket_element->getValidationDatas(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($basket_element->getValidationDatas()) {
|
if ($basket_element->getValidationDatas()) {
|
||||||
@@ -1192,12 +1191,12 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$user = $validation_datas->getParticipant()->getUser();
|
$user = $validation_datas->getParticipant()->getUser();
|
||||||
/* @var $validation_datas Entities\ValidationData */
|
/* @var $validation_datas Entities\ValidationData */
|
||||||
$choices[$user->get_id()] = array(
|
$choices[$user->get_id()] = array(
|
||||||
'usr_id' => $user->get_id(),
|
'usr_id' => $user->get_id(),
|
||||||
'usr_name' => $user->get_display_name(),
|
'usr_name' => $user->get_display_name(),
|
||||||
'is_mine' => $user->get_id() == $this->core->getAuthenticatedUser()->get_id(),
|
'is_mine' => $user->get_id() == $this->core->getAuthenticatedUser()->get_id(),
|
||||||
'agreement' => $validation_datas->getAgreement(),
|
'agreement' => $validation_datas->getAgreement(),
|
||||||
'updated_on' => $validation_datas->getUpdated()->format(DATE_ATOM),
|
'updated_on' => $validation_datas->getUpdated()->format(DATE_ATOM),
|
||||||
'note' => $validation_datas->getNote(),
|
'note' => $validation_datas->getNote(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($user->get_id() == $this->core->getAuthenticatedUser()->get_id()) {
|
if ($user->get_id() == $this->core->getAuthenticatedUser()->get_id()) {
|
||||||
@@ -1340,10 +1339,10 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$per_page = (($per_page >= 1) && ($per_page <= 20)) ? $per_page : 5;
|
$per_page = (($per_page >= 1) && ($per_page <= 20)) ? $per_page : 5;
|
||||||
|
|
||||||
$datas = array(
|
$datas = array(
|
||||||
'feed' => $this->list_publication($feed, $user),
|
'feed' => $this->list_publication($feed, $user),
|
||||||
'offset_start' => $offset_start,
|
'offset_start' => $offset_start,
|
||||||
'per_page' => $per_page,
|
'per_page' => $per_page,
|
||||||
'entries' => $this->list_publications_entries($feed, $offset_start, $per_page),
|
'entries' => $this->list_publications_entries($feed, $offset_start, $per_page),
|
||||||
);
|
);
|
||||||
|
|
||||||
$result->set_datas($datas);
|
$result->set_datas($datas);
|
||||||
@@ -1361,15 +1360,15 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
protected function list_publication(Feed_Adapter $feed, $user)
|
protected function list_publication(Feed_Adapter $feed, $user)
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'id' => $feed->get_id(),
|
'id' => $feed->get_id(),
|
||||||
'title' => $feed->get_title(),
|
'title' => $feed->get_title(),
|
||||||
'subtitle' => $feed->get_subtitle(),
|
'subtitle' => $feed->get_subtitle(),
|
||||||
'total_entries' => $feed->get_count_total_entries(),
|
'total_entries' => $feed->get_count_total_entries(),
|
||||||
'icon' => $feed->get_icon_url(),
|
'icon' => $feed->get_icon_url(),
|
||||||
'public' => $feed->is_public(),
|
'public' => $feed->is_public(),
|
||||||
'is_mine' => $feed->is_owner($user),
|
'is_mine' => $feed->is_owner($user),
|
||||||
'created_on' => $feed->get_created_on()->format(DATE_ATOM),
|
'created_on' => $feed->get_created_on()->format(DATE_ATOM),
|
||||||
'updated_on' => $feed->get_updated_on()->format(DATE_ATOM),
|
'updated_on' => $feed->get_updated_on()->format(DATE_ATOM),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1393,7 +1392,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
|
|
||||||
return array(
|
return array(
|
||||||
'offset_start' => $offset_start
|
'offset_start' => $offset_start
|
||||||
, 'entries' => $out
|
, 'entries' => $out
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1412,12 +1411,12 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
|
|
||||||
return array(
|
return array(
|
||||||
'author_email' => $entry->get_author_email(),
|
'author_email' => $entry->get_author_email(),
|
||||||
'author_name' => $entry->get_author_name(),
|
'author_name' => $entry->get_author_name(),
|
||||||
'created_on' => $entry->get_created_on()->format(DATE_ATOM),
|
'created_on' => $entry->get_created_on()->format(DATE_ATOM),
|
||||||
'updated_on' => $entry->get_updated_on()->format(DATE_ATOM),
|
'updated_on' => $entry->get_updated_on()->format(DATE_ATOM),
|
||||||
'title' => $entry->get_title(),
|
'title' => $entry->get_title(),
|
||||||
'subtitle' => $entry->get_subtitle(),
|
'subtitle' => $entry->get_subtitle(),
|
||||||
'items' => $items,
|
'items' => $items,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1431,7 +1430,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
{
|
{
|
||||||
$datas = array(
|
$datas = array(
|
||||||
'item_id' => $item->get_id()
|
'item_id' => $item->get_id()
|
||||||
, 'record' => $this->list_record($item->get_record())
|
, 'record' => $this->list_record($item->get_record())
|
||||||
);
|
);
|
||||||
|
|
||||||
return $datas;
|
return $datas;
|
||||||
@@ -1479,13 +1478,13 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$permalink = null;
|
$permalink = null;
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'permalink' => $permalink,
|
'permalink' => $permalink,
|
||||||
'height' => $media->get_height(),
|
'height' => $media->get_height(),
|
||||||
'width' => $media->get_width(),
|
'width' => $media->get_width(),
|
||||||
'filesize' => $media->get_size(),
|
'filesize' => $media->get_size(),
|
||||||
'devices' => $media->getDevices(),
|
'devices' => $media->getDevices(),
|
||||||
'player_type' => $media->get_type(),
|
'player_type' => $media->get_type(),
|
||||||
'mime_type' => $media->get_mime(),
|
'mime_type' => $media->get_mime(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1499,13 +1498,13 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
protected function list_permalink(media_Permalink_Adapter &$permalink, registryInterface &$registry)
|
protected function list_permalink(media_Permalink_Adapter &$permalink, registryInterface &$registry)
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'created_on' => $permalink->get_created_on()->format(DATE_ATOM),
|
'created_on' => $permalink->get_created_on()->format(DATE_ATOM),
|
||||||
'id' => $permalink->get_id(),
|
'id' => $permalink->get_id(),
|
||||||
'is_activated' => $permalink->get_is_activated(),
|
'is_activated' => $permalink->get_is_activated(),
|
||||||
'label' => $permalink->get_label(),
|
'label' => $permalink->get_label(),
|
||||||
'last_modified' => $permalink->get_last_modified()->format(DATE_ATOM),
|
'last_modified' => $permalink->get_last_modified()->format(DATE_ATOM),
|
||||||
'page_url' => $permalink->get_page($registry),
|
'page_url' => $permalink->get_page($registry),
|
||||||
'url' => $permalink->get_url($registry)
|
'url' => $permalink->get_url($registry)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1521,7 +1520,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$status = strrev($status);
|
$status = strrev($status);
|
||||||
$ret = array();
|
$ret = array();
|
||||||
foreach ($databox->get_statusbits() as $bit => $status_datas) {
|
foreach ($databox->get_statusbits() as $bit => $status_datas) {
|
||||||
$ret[$bit] = array('bit' => $bit, 'state' => ! ! substr($status, ($bit - 1), 1));
|
$ret[$bit] = array('bit' => $bit, 'state' => ! ! substr($status, ($bit - 1), 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
@@ -1558,10 +1557,10 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
* dans un cas multi
|
* dans un cas multi
|
||||||
*/
|
*/
|
||||||
return array(
|
return array(
|
||||||
'meta_id' => $value->getId(),
|
'meta_id' => $value->getId(),
|
||||||
'meta_structure_id' => $field->get_meta_struct_id(),
|
'meta_structure_id' => $field->get_meta_struct_id(),
|
||||||
'name' => $field->get_name(),
|
'name' => $field->get_name(),
|
||||||
'value' => $value->getValue(),
|
'value' => $value->getValue(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1574,13 +1573,13 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
protected function list_basket(\Entities\Basket $basket)
|
protected function list_basket(\Entities\Basket $basket)
|
||||||
{
|
{
|
||||||
$ret = array(
|
$ret = array(
|
||||||
'created_on' => $basket->getCreated()->format(DATE_ATOM),
|
'created_on' => $basket->getCreated()->format(DATE_ATOM),
|
||||||
'description' => (string) $basket->getDescription(),
|
'description' => (string) $basket->getDescription(),
|
||||||
'name' => $basket->getName(),
|
'name' => $basket->getName(),
|
||||||
'pusher_usr_id' => $basket->getPusherId(),
|
'pusher_usr_id' => $basket->getPusherId(),
|
||||||
'ssel_id' => $basket->getId(),
|
'ssel_id' => $basket->getId(),
|
||||||
'updated_on' => $basket->getUpdated()->format(DATE_ATOM),
|
'updated_on' => $basket->getUpdated()->format(DATE_ATOM),
|
||||||
'unread' => ! $basket->getIsRead(),
|
'unread' => ! $basket->getIsRead(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($basket->getValidation()) {
|
if ($basket->getValidation()) {
|
||||||
@@ -1591,10 +1590,10 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$user = $participant->getUser();
|
$user = $participant->getUser();
|
||||||
|
|
||||||
$users[$user->get_id()] = array(
|
$users[$user->get_id()] = array(
|
||||||
'usr_id' => $user->get_id(),
|
'usr_id' => $user->get_id(),
|
||||||
'usr_name' => $user->get_display_name(),
|
'usr_name' => $user->get_display_name(),
|
||||||
'confirmed' => $participant->getIsConfirmed(),
|
'confirmed' => $participant->getIsConfirmed(),
|
||||||
'can_agree' => $participant->getCanAgree(),
|
'can_agree' => $participant->getCanAgree(),
|
||||||
'can_see_others' => $participant->getCanSeeOthers(),
|
'can_see_others' => $participant->getCanSeeOthers(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1608,11 +1607,11 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
|
|
||||||
$ret = array_merge(
|
$ret = array_merge(
|
||||||
array(
|
array(
|
||||||
'validation_users' => $users,
|
'validation_users' => $users,
|
||||||
'validation_end_date' => $expires_on_atom,
|
'validation_end_date' => $expires_on_atom,
|
||||||
'validation_infos' => $basket->getValidation()->getValidationString($user),
|
'validation_infos' => $basket->getValidation()->getValidationString($user),
|
||||||
'validation_confirmed' => $basket->getValidation()->getParticipant($user)->getIsConfirmed(),
|
'validation_confirmed' => $basket->getValidation()->getParticipant($user)->getIsConfirmed(),
|
||||||
'mine' => $basket->getValidation()->isInitiator($user),
|
'mine' => $basket->getValidation()->isInitiator($user),
|
||||||
), $ret
|
), $ret
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1629,21 +1628,21 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
protected function list_record(record_adapter $record)
|
protected function list_record(record_adapter $record)
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'databox_id' => $record->get_sbas_id(),
|
'databox_id' => $record->get_sbas_id(),
|
||||||
'record_id' => $record->get_record_id(),
|
'record_id' => $record->get_record_id(),
|
||||||
'mime_type' => $record->get_mime(),
|
'mime_type' => $record->get_mime(),
|
||||||
'title' => $record->get_title(),
|
'title' => $record->get_title(),
|
||||||
'original_name' => $record->get_original_name(),
|
'original_name' => $record->get_original_name(),
|
||||||
'last_modification' => $record->get_modification_date()->format(DATE_ATOM),
|
'last_modification' => $record->get_modification_date()->format(DATE_ATOM),
|
||||||
'created_on' => $record->get_creation_date()->format(DATE_ATOM),
|
'created_on' => $record->get_creation_date()->format(DATE_ATOM),
|
||||||
'collection_id' => phrasea::collFromBas($record->get_base_id()),
|
'collection_id' => phrasea::collFromBas($record->get_base_id()),
|
||||||
'sha256' => $record->get_sha256(),
|
'sha256' => $record->get_sha256(),
|
||||||
'thumbnail' => $this->list_embedable_media(
|
'thumbnail' => $this->list_embedable_media(
|
||||||
$record->get_thumbnail(), registry::get_instance()
|
$record->get_thumbnail(), registry::get_instance()
|
||||||
),
|
),
|
||||||
'technical_informations' => $record->get_technical_infos(),
|
'technical_informations' => $record->get_technical_infos(),
|
||||||
'phrasea_type' => $record->get_type(),
|
'phrasea_type' => $record->get_type(),
|
||||||
'uuid' => $record->get_uuid(),
|
'uuid' => $record->get_uuid(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1672,7 +1671,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
{
|
{
|
||||||
$ret = array();
|
$ret = array();
|
||||||
foreach ($databox->get_cgus() as $locale => $array_terms) {
|
foreach ($databox->get_cgus() as $locale => $array_terms) {
|
||||||
$ret[$locale] = array('locale' => $locale, 'terms' => $array_terms['value']);
|
$ret[$locale] = array('locale' => $locale, 'terms' => $array_terms['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
@@ -1720,9 +1719,9 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
protected function list_collection(collection $collection)
|
protected function list_collection(collection $collection)
|
||||||
{
|
{
|
||||||
$ret = array(
|
$ret = array(
|
||||||
'base_id' => $collection->get_base_id(),
|
'base_id' => $collection->get_base_id(),
|
||||||
'coll_id' => $collection->get_coll_id(),
|
'coll_id' => $collection->get_coll_id(),
|
||||||
'name' => $collection->get_name(),
|
'name' => $collection->get_name(),
|
||||||
'record_amount' => $collection->get_record_amount(),
|
'record_amount' => $collection->get_record_amount(),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1740,13 +1739,13 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$ret = array();
|
$ret = array();
|
||||||
foreach ($status as $n => $datas) {
|
foreach ($status as $n => $datas) {
|
||||||
$ret[$n] = array(
|
$ret[$n] = array(
|
||||||
'bit' => $n,
|
'bit' => $n,
|
||||||
'label_on' => $datas['labelon'],
|
'label_on' => $datas['labelon'],
|
||||||
'label_off' => $datas['labeloff'],
|
'label_off' => $datas['labeloff'],
|
||||||
'img_on' => $datas['img_on'],
|
'img_on' => $datas['img_on'],
|
||||||
'img_off' => $datas['img_off'],
|
'img_off' => $datas['img_off'],
|
||||||
'searchable' => $datas['searchable'],
|
'searchable' => $datas['searchable'],
|
||||||
'printable' => $datas['printable'],
|
'printable' => $datas['printable'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1778,18 +1777,18 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
protected function list_databox_metadata_field_properties(databox_field $databox_field)
|
protected function list_databox_metadata_field_properties(databox_field $databox_field)
|
||||||
{
|
{
|
||||||
$ret = array(
|
$ret = array(
|
||||||
'id' => $databox_field->get_id(),
|
'id' => $databox_field->get_id(),
|
||||||
'namespace' => $databox_field->get_metadata_namespace(),
|
'namespace' => $databox_field->get_metadata_namespace(),
|
||||||
'source' => $databox_field->get_metadata_source(),
|
'source' => $databox_field->get_metadata_source(),
|
||||||
'tagname' => $databox_field->get_metadata_tagname(),
|
'tagname' => $databox_field->get_metadata_tagname(),
|
||||||
'name' => $databox_field->get_name(),
|
'name' => $databox_field->get_name(),
|
||||||
'separator' => $databox_field->get_separator(),
|
'separator' => $databox_field->get_separator(),
|
||||||
'thesaurus_branch' => $databox_field->get_tbranch(),
|
'thesaurus_branch' => $databox_field->get_tbranch(),
|
||||||
'type' => $databox_field->get_type(),
|
'type' => $databox_field->get_type(),
|
||||||
'indexable' => $databox_field->is_indexable(),
|
'indexable' => $databox_field->is_indexable(),
|
||||||
'multivalue' => $databox_field->is_multi(),
|
'multivalue' => $databox_field->is_multi(),
|
||||||
'readonly' => $databox_field->is_readonly(),
|
'readonly' => $databox_field->is_readonly(),
|
||||||
'required' => $databox_field->is_required(),
|
'required' => $databox_field->is_required(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
|
@@ -38,7 +38,6 @@ class module_console_schedulerState extends Command
|
|||||||
, 'print short result, ie: <info>stopped</info> | <info>started(12345)</info> | <info>stopping</info>'
|
, 'print short result, ie: <info>stopped</info> | <info>started(12345)</info> | <info>stopping</info>'
|
||||||
, NULL
|
, NULL
|
||||||
);
|
);
|
||||||
// $this->setHelp("");
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,6 @@ use Symfony\Component\Console\Command\Command;
|
|||||||
class module_console_taskrun extends Command
|
class module_console_taskrun extends Command
|
||||||
{
|
{
|
||||||
private $task;
|
private $task;
|
||||||
|
|
||||||
private $shedulerPID;
|
private $shedulerPID;
|
||||||
|
|
||||||
public function __construct($name = null)
|
public function __construct($name = null)
|
||||||
@@ -125,7 +124,7 @@ class module_console_taskrun extends Command
|
|||||||
if (method_exists($this->task, 'signal'))
|
if (method_exists($this->task, 'signal'))
|
||||||
$this->task->signal('SIGNAL_SCHEDULER_DIED');
|
$this->task->signal('SIGNAL_SCHEDULER_DIED');
|
||||||
else
|
else
|
||||||
$this->task->setState(task_abstract::STATUS_TOSTOP);
|
$this->task->setState(task_abstract::STATE_TOSTOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of Phraseanet
|
* This file is part of Phraseanet
|
||||||
*
|
*
|
||||||
* (c) 2005-2010 Alchemy
|
* (c) 2005-2012 Alchemy
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
@@ -20,16 +20,12 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||||||
class task_Scheduler
|
class task_Scheduler
|
||||||
{
|
{
|
||||||
const TASKDELAYTOQUIT = 60;
|
const TASKDELAYTOQUIT = 60;
|
||||||
|
|
||||||
// how to schedule tasks (choose in 'run' method)
|
// how to schedule tasks (choose in 'run' method)
|
||||||
const METHOD_FORK = 'METHOD_FORK';
|
const METHOD_FORK = 'METHOD_FORK';
|
||||||
const METHOD_PROC_OPEN = 'METHOD_PROC_OPEN';
|
const METHOD_PROC_OPEN = 'METHOD_PROC_OPEN';
|
||||||
|
|
||||||
const ERR_ALREADY_RUNNING = 114; // aka EALREADY (Operation already in progress)
|
const ERR_ALREADY_RUNNING = 114; // aka EALREADY (Operation already in progress)
|
||||||
private $method;
|
private $method;
|
||||||
|
|
||||||
private $input;
|
private $input;
|
||||||
|
|
||||||
protected $output;
|
protected $output;
|
||||||
|
|
||||||
protected function log($message)
|
protected function log($message)
|
||||||
@@ -47,6 +43,7 @@ class task_Scheduler
|
|||||||
if ($this->input && ! ($this->input->getOption('nolog'))) {
|
if ($this->input && ! ($this->input->getOption('nolog'))) {
|
||||||
file_put_contents($logdir . "scheduler_l.log", $message . "\n", FILE_APPEND);
|
file_put_contents($logdir . "scheduler_l.log", $message . "\n", FILE_APPEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +52,7 @@ class task_Scheduler
|
|||||||
return appbox::get_instance(\bootstrap::getCore())->get_connection();
|
return appbox::get_instance(\bootstrap::getCore())->get_connection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run($input=null, OutputInterface $output = null) //, $log = true, $log_tasks = true)
|
public function run($input=null, OutputInterface $output = null)
|
||||||
{
|
{
|
||||||
require_once dirname(__FILE__) . '/../../bootstrap.php';
|
require_once dirname(__FILE__) . '/../../bootstrap.php';
|
||||||
$this->input = $input;
|
$this->input = $input;
|
||||||
@@ -134,7 +131,7 @@ class task_Scheduler
|
|||||||
if ( ! $task->getPID()) {
|
if ( ! $task->getPID()) {
|
||||||
/* @var $task task_abstract */
|
/* @var $task task_abstract */
|
||||||
$task->resetCrashCounter();
|
$task->resetCrashCounter();
|
||||||
$task->setState(task_abstract::STATUS_TOSTART);
|
$task->setState(task_abstract::STATE_TOSTART);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -313,7 +310,7 @@ class task_Scheduler
|
|||||||
$this->log(sprintf('Unknow status `%s`', $status));
|
$this->log(sprintf('Unknow status `%s`', $status));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case task_abstract::STATUS_TORESTART:
|
case task_abstract::STATE_TORESTART:
|
||||||
if ( ! $taskPoll[$tkey]['task']->getPID()) {
|
if ( ! $taskPoll[$tkey]['task']->getPID()) {
|
||||||
if ($this->method == self::METHOD_PROC_OPEN) {
|
if ($this->method == self::METHOD_PROC_OPEN) {
|
||||||
@fclose($taskPoll[$tkey]["pipes"][1]);
|
@fclose($taskPoll[$tkey]["pipes"][1]);
|
||||||
@@ -323,7 +320,7 @@ class task_Scheduler
|
|||||||
$taskPoll[$tkey]["process"] = null;
|
$taskPoll[$tkey]["process"] = null;
|
||||||
}
|
}
|
||||||
if ($schedstatus == 'started') {
|
if ($schedstatus == 'started') {
|
||||||
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_TOSTART);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_TOSTART);
|
||||||
}
|
}
|
||||||
// trick to start the task immediatly : DON'T break if ending with 'tostart'
|
// trick to start the task immediatly : DON'T break if ending with 'tostart'
|
||||||
// so it will continue with 'tostart' case !
|
// so it will continue with 'tostart' case !
|
||||||
@@ -331,7 +328,7 @@ class task_Scheduler
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case task_abstract::STATUS_TOSTART:
|
case task_abstract::STATE_TOSTART:
|
||||||
// if scheduler is 'tostop', don't launch a new task !
|
// if scheduler is 'tostop', don't launch a new task !
|
||||||
if ($schedstatus != 'started')
|
if ($schedstatus != 'started')
|
||||||
break;
|
break;
|
||||||
@@ -384,21 +381,17 @@ class task_Scheduler
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5)
|
if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5)
|
||||||
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_STOPPED);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_STOPPED);
|
||||||
else
|
else
|
||||||
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_TOSTART);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_TOSTART);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($this->method == self::METHOD_FORK) {
|
elseif ($this->method == self::METHOD_FORK) {
|
||||||
// printf("forking pid %d\n", getmypid());
|
|
||||||
$pid = pcntl_fork();
|
$pid = pcntl_fork();
|
||||||
if ($pid == -1) {
|
if ($pid == -1) {
|
||||||
die("failed to fork");
|
die("failed to fork");
|
||||||
} elseif ($pid == 0) {
|
} elseif ($pid == 0) {
|
||||||
// child
|
|
||||||
// printf("hello i am child pid=%d\n", getmypid());
|
|
||||||
// printf("%s %s \n", $taskPoll[$tkey]["cmd"], implode(' ', $taskPoll[$tkey]["args"]));
|
|
||||||
umask(0);
|
umask(0);
|
||||||
if (posix_setsid() < 0)
|
if (posix_setsid() < 0)
|
||||||
die("Forked process could not detach from terminal\n");
|
die("Forked process could not detach from terminal\n");
|
||||||
@@ -413,25 +406,18 @@ class task_Scheduler
|
|||||||
$this->log(sprintf("exec('%s %s')", $taskPoll[$tkey]["cmd"], implode(' ', $taskPoll[$tkey]["args"])));
|
$this->log(sprintf("exec('%s %s')", $taskPoll[$tkey]["cmd"], implode(' ', $taskPoll[$tkey]["args"])));
|
||||||
pcntl_exec($taskPoll[$tkey]["cmd"], $taskPoll[$tkey]["args"]);
|
pcntl_exec($taskPoll[$tkey]["cmd"], $taskPoll[$tkey]["args"]);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// parent
|
|
||||||
// sleep(2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case task_abstract::STATUS_STARTED:
|
case task_abstract::STATE_STARTED:
|
||||||
$crashed = false;
|
$crashed = false;
|
||||||
// If no process, the task is probably manually ran
|
// If no process, the task is probably manually ran
|
||||||
|
|
||||||
if ($this->method == self::METHOD_PROC_OPEN) {
|
if ($this->method == self::METHOD_PROC_OPEN) {
|
||||||
// printf("=== %d ===\n", __LINE__);
|
|
||||||
if ($taskPoll[$tkey]["process"]) {
|
if ($taskPoll[$tkey]["process"]) {
|
||||||
// printf("=== %d ===\n", __LINE__);
|
|
||||||
$taskPoll[$tkey]["killat"] = NULL;
|
$taskPoll[$tkey]["killat"] = NULL;
|
||||||
|
|
||||||
if (is_resource($taskPoll[$tkey]["process"])) {
|
if (is_resource($taskPoll[$tkey]["process"])) {
|
||||||
// printf("=== %d ===\n", __LINE__);
|
|
||||||
$proc_status = proc_get_status($taskPoll[$tkey]["process"]);
|
$proc_status = proc_get_status($taskPoll[$tkey]["process"]);
|
||||||
if ($proc_status['running'])
|
if ($proc_status['running'])
|
||||||
$runningtask ++;
|
$runningtask ++;
|
||||||
@@ -439,14 +425,12 @@ class task_Scheduler
|
|||||||
$crashed = true;
|
$crashed = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// printf("=== %d ===\n", __LINE__);
|
|
||||||
$crashed = true;
|
$crashed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $crashed && ! $taskPoll[$tkey]['task']->getPID()) {
|
if ( ! $crashed && ! $taskPoll[$tkey]['task']->getPID()) {
|
||||||
// printf("=== %d ===\n", __LINE__);
|
|
||||||
$crashed = true;
|
$crashed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,7 +438,6 @@ class task_Scheduler
|
|||||||
$taskPoll[$tkey]["killat"] = NULL;
|
$taskPoll[$tkey]["killat"] = NULL;
|
||||||
$runningtask ++;
|
$runningtask ++;
|
||||||
} else {
|
} else {
|
||||||
// printf("=== %d ===\n", __LINE__);
|
|
||||||
// crashed !
|
// crashed !
|
||||||
$taskPoll[$tkey]["task"]->incrementCrashCounter();
|
$taskPoll[$tkey]["task"]->incrementCrashCounter();
|
||||||
|
|
||||||
@@ -473,13 +456,13 @@ class task_Scheduler
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5)
|
if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5)
|
||||||
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_STOPPED);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_STOPPED);
|
||||||
else
|
else
|
||||||
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_TOSTART);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_TOSTART);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case task_abstract::STATUS_TOSTOP:
|
case task_abstract::STATE_TOSTOP:
|
||||||
|
|
||||||
if ($taskPoll[$tkey]["killat"] === NULL)
|
if ($taskPoll[$tkey]["killat"] === NULL)
|
||||||
$taskPoll[$tkey]["killat"] = time() + self::TASKDELAYTOQUIT;
|
$taskPoll[$tkey]["killat"] = time() + self::TASKDELAYTOQUIT;
|
||||||
@@ -525,13 +508,6 @@ class task_Scheduler
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
unlink($lockdir . 'task_' . $taskPoll[$tkey]['task']->getID() . '.lock');
|
|
||||||
|
|
||||||
$taskPoll[$tkey]["task"]->incrementCrashCounter();
|
|
||||||
// $taskPoll[$tkey]["task"]->set_pid(null);
|
|
||||||
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_STOPPED);
|
|
||||||
*/
|
|
||||||
} else {
|
} else {
|
||||||
$this->log(
|
$this->log(
|
||||||
sprintf(
|
sprintf(
|
||||||
@@ -549,13 +525,13 @@ class task_Scheduler
|
|||||||
, $taskPoll[$tkey]["task"]->getID()
|
, $taskPoll[$tkey]["task"]->getID()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_STOPPED);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case task_abstract::STATUS_STOPPED:
|
case task_abstract::STATE_STOPPED:
|
||||||
case task_abstract::STATUS_TODELETE:
|
case task_abstract::STATE_TODELETE:
|
||||||
if ($this->method == self::METHOD_PROC_OPEN) {
|
if ($this->method == self::METHOD_PROC_OPEN) {
|
||||||
if ($taskPoll[$tkey]["process"]) {
|
if ($taskPoll[$tkey]["process"]) {
|
||||||
@fclose($taskPoll[$tkey]["pipes"][1]);
|
@fclose($taskPoll[$tkey]["pipes"][1]);
|
||||||
|
@@ -5,12 +5,12 @@ abstract class task_abstract
|
|||||||
const LAUCHED_BY_BROWSER = 1;
|
const LAUCHED_BY_BROWSER = 1;
|
||||||
const LAUCHED_BY_COMMANDLINE = 2;
|
const LAUCHED_BY_COMMANDLINE = 2;
|
||||||
|
|
||||||
const STATUS_TOSTOP = 'tostop';
|
const STATE_TOSTOP = 'tostop';
|
||||||
const STATUS_STARTED = 'started';
|
const STATE_STARTED = 'started';
|
||||||
const STATUS_TOSTART = 'tostart';
|
const STATE_TOSTART = 'tostart';
|
||||||
const STATUS_TORESTART = 'torestart';
|
const STATE_TORESTART = 'torestart';
|
||||||
const STATUS_STOPPED = 'stopped';
|
const STATE_STOPPED = 'stopped';
|
||||||
const STATUS_TODELETE = 'todelete';
|
const STATE_TODELETE = 'todelete';
|
||||||
|
|
||||||
const RUNNER_MANUAL = 'manual';
|
const RUNNER_MANUAL = 'manual';
|
||||||
const RUNNER_SCHEDULER = 'scheduler';
|
const RUNNER_SCHEDULER = 'scheduler';
|
||||||
@@ -24,7 +24,6 @@ abstract class task_abstract
|
|||||||
|
|
||||||
const ERR_ALREADY_RUNNING = 114; // aka EALREADY (Operation already in progress)
|
const ERR_ALREADY_RUNNING = 114; // aka EALREADY (Operation already in progress)
|
||||||
protected $suicidable = false;
|
protected $suicidable = false;
|
||||||
|
|
||||||
protected $launched_by = 0;
|
protected $launched_by = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,11 +74,8 @@ abstract class task_abstract
|
|||||||
* @var <type>
|
* @var <type>
|
||||||
*/
|
*/
|
||||||
protected $maxmegs;
|
protected $maxmegs;
|
||||||
|
|
||||||
protected $runner;
|
protected $runner;
|
||||||
|
|
||||||
private $input;
|
private $input;
|
||||||
|
|
||||||
private $output;
|
private $output;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,25 +84,15 @@ abstract class task_abstract
|
|||||||
* @var <type>
|
* @var <type>
|
||||||
*/
|
*/
|
||||||
protected $title;
|
protected $title;
|
||||||
|
|
||||||
protected $settings;
|
protected $settings;
|
||||||
|
|
||||||
protected $crash_counter;
|
protected $crash_counter;
|
||||||
|
|
||||||
protected $status;
|
protected $status;
|
||||||
|
|
||||||
protected $active;
|
protected $active;
|
||||||
|
|
||||||
protected $debug = false;
|
protected $debug = false;
|
||||||
|
|
||||||
protected $completed_percentage;
|
protected $completed_percentage;
|
||||||
|
|
||||||
protected $period = 60;
|
protected $period = 60;
|
||||||
|
|
||||||
protected $taskid = NULL;
|
protected $taskid = NULL;
|
||||||
|
|
||||||
protected $system = ''; // "DARWIN", "WINDOWS" , "LINUX"...
|
protected $system = ''; // "DARWIN", "WINDOWS" , "LINUX"...
|
||||||
|
|
||||||
protected $argt = array(
|
protected $argt = array(
|
||||||
"--help" => array("set" => false, "values" => array(), "usage" => " (no help available)")
|
"--help" => array("set" => false, "values" => array(), "usage" => " (no help available)")
|
||||||
);
|
);
|
||||||
@@ -114,13 +100,14 @@ abstract class task_abstract
|
|||||||
public function getState()
|
public function getState()
|
||||||
{
|
{
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
$sql = 'SELECT status FROM task2 WHERE task_id = :taskid LIMIT 1';
|
$sql = 'SELECT status FROM task2 WHERE task_id = :taskid';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':taskid' => $this->taskid));
|
$stmt->execute(array(':taskid' => $this->taskid));
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
if ( ! $row)
|
if ( ! $row)
|
||||||
throw new Exception('Unknown task id');
|
throw new Exception('Unknown task id');
|
||||||
|
|
||||||
return $row['status'];
|
return $row['status'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,12 +129,12 @@ abstract class task_abstract
|
|||||||
public function setState($status)
|
public function setState($status)
|
||||||
{
|
{
|
||||||
$av_status = array(
|
$av_status = array(
|
||||||
self::STATUS_STARTED
|
self::STATE_STARTED
|
||||||
, self::STATUS_TOSTOP
|
, self::STATE_TOSTOP
|
||||||
, self::STATUS_STOPPED
|
, self::STATE_STOPPED
|
||||||
, self::STATUS_TORESTART
|
, self::STATE_TORESTART
|
||||||
, self::STATUS_TOSTART
|
, self::STATE_TOSTART
|
||||||
, self::STATUS_TODELETE
|
, self::STATE_TODELETE
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( ! in_array($status, $av_status)) {
|
if ( ! in_array($status, $av_status)) {
|
||||||
@@ -293,7 +280,7 @@ abstract class task_abstract
|
|||||||
return('');
|
return('');
|
||||||
}
|
}
|
||||||
$sql = 'SELECT crashed, pid, status, active, settings, name, completed, runner
|
$sql = 'SELECT crashed, pid, status, active, settings, name, completed, runner
|
||||||
FROM task2 WHERE task_id = :taskid LIMIT 1';
|
FROM task2 WHERE task_id = :taskid';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':taskid' => $this->getID()));
|
$stmt->execute(array(':taskid' => $this->getID()));
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
@@ -394,6 +381,7 @@ abstract class task_abstract
|
|||||||
}
|
}
|
||||||
fclose($fd);
|
fclose($fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $pid;
|
return $pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,13 +396,10 @@ abstract class task_abstract
|
|||||||
if ($this->running) {// && $this->records_done == 0)
|
if ($this->running) {// && $this->records_done == 0)
|
||||||
$when_started = time() - $when_started;
|
$when_started = time() - $when_started;
|
||||||
if ($when_started < $this->period) {
|
if ($when_started < $this->period) {
|
||||||
// $conn = connection::getPDOConnection();
|
|
||||||
// $conn->close();
|
|
||||||
// unset($conn);
|
|
||||||
for ($t = $this->period - $when_started; $this->running && $t > 0; $t -- ) { // DON'T do sleep($this->period - $when_started) because it prevents ticks !
|
for ($t = $this->period - $when_started; $this->running && $t > 0; $t -- ) { // DON'T do sleep($this->period - $when_started) because it prevents ticks !
|
||||||
$s = $this->getState();
|
$s = $this->getState();
|
||||||
if ($s == self::STATUS_TOSTOP) {
|
if ($s == self::STATE_TOSTOP) {
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
} else {
|
} else {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
@@ -456,7 +441,7 @@ abstract class task_abstract
|
|||||||
flock($tasklock, LOCK_SH);
|
flock($tasklock, LOCK_SH);
|
||||||
|
|
||||||
$this->setRunner($runner);
|
$this->setRunner($runner);
|
||||||
$this->setState(self::STATUS_STARTED);
|
$this->setState(self::STATE_STARTED);
|
||||||
|
|
||||||
// run the real code of the task -into the task's class- (may throw an exception)
|
// run the real code of the task -into the task's class- (may throw an exception)
|
||||||
$exception = NULL;
|
$exception = NULL;
|
||||||
@@ -473,11 +458,11 @@ abstract class task_abstract
|
|||||||
@unlink($lockfile);
|
@unlink($lockfile);
|
||||||
|
|
||||||
switch ($this->getState()) {
|
switch ($this->getState()) {
|
||||||
case self::STATUS_TODELETE:
|
case self::STATE_TODELETE:
|
||||||
$this->delete();
|
$this->delete();
|
||||||
break;
|
break;
|
||||||
case self::STATUS_TOSTOP:
|
case self::STATE_TOSTOP:
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -509,8 +494,7 @@ abstract class task_abstract
|
|||||||
{
|
{
|
||||||
if ($this->getRunner() == self::RUNNER_SCHEDULER && ++ $this->loop >= $this->maxloops) {
|
if ($this->getRunner() == self::RUNNER_SCHEDULER && ++ $this->loop >= $this->maxloops) {
|
||||||
$this->log(sprintf(('%d loops done, restarting'), $this->loop));
|
$this->log(sprintf(('%d loops done, restarting'), $this->loop));
|
||||||
$this->setState(self::STATUS_TORESTART);
|
$this->setState(self::STATE_TORESTART);
|
||||||
// $this->return_xxxvalue = self::RETURNSTATUS_TORESTART;
|
|
||||||
|
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
}
|
}
|
||||||
@@ -529,7 +513,6 @@ abstract class task_abstract
|
|||||||
|
|
||||||
$lastt = $t;
|
$lastt = $t;
|
||||||
echo "\n" . memory_get_usage() . " -- " . memory_get_usage(true) . "\n";
|
echo "\n" . memory_get_usage() . " -- " . memory_get_usage(true) . "\n";
|
||||||
// print($s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function log($message)
|
public function log($message)
|
||||||
@@ -609,7 +592,6 @@ abstract class task_abstract
|
|||||||
return($t);
|
return($t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getID()
|
public function getID()
|
||||||
{
|
{
|
||||||
return $this->taskid;
|
return $this->taskid;
|
||||||
|
@@ -34,8 +34,10 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
||||||
$this->log(("Warning : abox connection lost, restarting in 10 min."));
|
$this->log(("Warning : abox connection lost, restarting in 10 min."));
|
||||||
|
|
||||||
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
// DON'T do sleep(600) because it prevents ticks !
|
||||||
|
for ($t = 60 * 10; $this->running && $t; $t -- ) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
}
|
||||||
// because connection is lost we cannot change status to 'torestart'
|
// because connection is lost we cannot change status to 'torestart'
|
||||||
// anyway the current status 'running' with no pid
|
// anyway the current status 'running' with no pid
|
||||||
// will enforce the scheduler to restart the task
|
// will enforce the scheduler to restart the task
|
||||||
@@ -50,7 +52,7 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
$this->setLastExecTime();
|
$this->setLastExecTime();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$sql = 'SELECT task2.* FROM task2 WHERE task_id = :taskid LIMIT 1';
|
$sql = 'SELECT settings FROM task2 WHERE task_id = :taskid';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':taskid' => $this->getID()));
|
$stmt->execute(array(':taskid' => $this->getID()));
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
@@ -82,18 +84,18 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
case self::STATE_MAXMEGSREACHED:
|
case self::STATE_MAXMEGSREACHED:
|
||||||
case self::STATE_MAXRECSDONE:
|
case self::STATE_MAXRECSDONE:
|
||||||
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
||||||
$this->setState(self::STATUS_TORESTART);
|
$this->setState(self::STATE_TORESTART);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::STATUS_TOSTOP:
|
case self::STATE_TOSTOP:
|
||||||
$this->setState(self::STATUS_TOSTOP);
|
$this->setState(self::STATE_TOSTOP);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::STATUS_TODELETE: // formal 'suicidable'
|
case self::STATE_TODELETE: // formal 'suicidable'
|
||||||
$this->setState(self::STATUS_TODELETE);
|
$this->setState(self::STATE_TODELETE);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -164,9 +166,9 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
// $this->check_task_status();
|
// $this->check_task_status();
|
||||||
try {
|
try {
|
||||||
$status = $this->getState();
|
$status = $this->getState();
|
||||||
if ($status == self::STATUS_TOSTOP) {
|
if ($status == self::STATE_TOSTOP) {
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
$ret = self::STATUS_TOSTOP;
|
$ret = self::STATE_TOSTOP;
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
@@ -174,11 +176,11 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
|
|
||||||
if ( ! $this->running)
|
if ( ! $this->running)
|
||||||
break;
|
break;
|
||||||
} // foreach($rs as $row)
|
}
|
||||||
//
|
//
|
||||||
// if nothing was done, at least check the status
|
// if nothing was done, at least check the status
|
||||||
if (count($rs) == 0 && $this->running) {
|
if (count($rs) == 0 && $this->running) {
|
||||||
// $this->check_memory_usage();
|
|
||||||
$current_memory = memory_get_usage();
|
$current_memory = memory_get_usage();
|
||||||
if ($current_memory >> 20 >= $this->maxmegs) {
|
if ($current_memory >> 20 >= $this->maxmegs) {
|
||||||
$this->log(sprintf("Max memory (%s M) reached (current is %s M)", $this->maxmegs, $current_memory));
|
$this->log(sprintf("Max memory (%s M) reached (current is %s M)", $this->maxmegs, $current_memory));
|
||||||
@@ -192,12 +194,11 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
$ret = self::STATE_MAXRECSDONE;
|
$ret = self::STATE_MAXRECSDONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->check_task_status();
|
|
||||||
try {
|
try {
|
||||||
$status = $this->getState();
|
$status = $this->getState();
|
||||||
if ($status == self::STATUS_TOSTOP) {
|
if ($status == self::STATE_TOSTOP) {
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
$ret = self::STATUS_TOSTOP;
|
$ret = self::STATE_TOSTOP;
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
|
@@ -37,13 +37,15 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
while ($this->running) {
|
while ($this->running) {
|
||||||
try {
|
try {
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
} catch (Exception $e) {
|
} catch (PDOException $e) {
|
||||||
$this->log($e->getMessage());
|
$this->log($e->getMessage());
|
||||||
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
||||||
$this->log(("Warning : abox connection lost, restarting in 10 min."));
|
$this->log(("Warning : abox connection lost, restarting in 10 min."));
|
||||||
|
|
||||||
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
// DON'T do sleep(600) because it prevents ticks !
|
||||||
|
for ($t = 60 * 10; $this->running && $t; $t -- ) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
}
|
||||||
// because connection is lost we cannot change status to 'torestart'
|
// because connection is lost we cannot change status to 'torestart'
|
||||||
// anyway the current status 'running' with no pid
|
// anyway the current status 'running' with no pid
|
||||||
// will enforce the scheduler to restart the task
|
// will enforce the scheduler to restart the task
|
||||||
@@ -51,6 +53,7 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
// runner = manual : can't restart so simply quit
|
// runner = manual : can't restart so simply quit
|
||||||
}
|
}
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,27 +94,22 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
|
|
||||||
$process_ret = $this->processSbas();
|
$process_ret = $this->processSbas();
|
||||||
|
|
||||||
// printf("%s (%d) process_ret=%s \n", __FILE__, __LINE__, var_export($process_ret, true));
|
|
||||||
// $this->check_current_xxxstate();
|
|
||||||
switch ($process_ret) {
|
switch ($process_ret) {
|
||||||
case self::STATE_MAXMEGSREACHED:
|
case self::STATE_MAXMEGSREACHED:
|
||||||
case self::STATE_MAXRECSDONE:
|
case self::STATE_MAXRECSDONE:
|
||||||
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
||||||
$this->setState(self::STATUS_TORESTART);
|
$this->setState(self::STATE_TORESTART);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::STATUS_TOSTOP:
|
case self::STATE_TOSTOP:
|
||||||
$this->setState(self::STATUS_TOSTOP);
|
$this->setState(self::STATE_TOSTOP);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::STATUS_TODELETE: // formal 'suicidable'
|
case self::STATE_TODELETE: // formal 'suicidable'
|
||||||
// DO NOT SUICIDE IN THE LOOP, may have to work on other sbas !!!
|
// DO NOT SUICIDE IN THE LOOP, may have to work on other sbas !!!
|
||||||
// $this->setState(self::STATUS_TODELETE);
|
|
||||||
// $this->log('task will self delete');
|
|
||||||
// $this->running = FALSE;
|
|
||||||
$task_must_delete = TRUE;
|
$task_must_delete = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -120,16 +118,17 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->flushRecordsSbas();
|
$this->flushRecordsSbas();
|
||||||
} // foreach sbas
|
}
|
||||||
|
|
||||||
$this->incrementLoops();
|
$this->incrementLoops();
|
||||||
$this->pause($duration);
|
$this->pause($duration);
|
||||||
} // while($this->running)
|
}
|
||||||
|
|
||||||
if ($task_must_delete) {
|
if ($task_must_delete) {
|
||||||
$this->setState(self::STATUS_TODELETE);
|
$this->setState(self::STATE_TODELETE);
|
||||||
$this->log('task will self delete');
|
$this->log('task will self delete');
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +173,6 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
// post-process
|
// post-process
|
||||||
$this->postProcessOneContent($databox, $row);
|
$this->postProcessOneContent($databox, $row);
|
||||||
|
|
||||||
// $this->check_memory_usage();
|
|
||||||
$current_memory = memory_get_usage();
|
$current_memory = memory_get_usage();
|
||||||
if ($current_memory >> 20 >= $this->maxmegs) {
|
if ($current_memory >> 20 >= $this->maxmegs) {
|
||||||
$this->log(sprintf("Max memory (%s M) reached (actual is %s M)", $this->maxmegs, $current_memory));
|
$this->log(sprintf("Max memory (%s M) reached (actual is %s M)", $this->maxmegs, $current_memory));
|
||||||
@@ -188,29 +186,23 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
$ret = self::STATE_MAXRECSDONE;
|
$ret = self::STATE_MAXRECSDONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->check_task_status();
|
|
||||||
try {
|
try {
|
||||||
$status = $this->getState();
|
$status = $this->getState();
|
||||||
// printf("%s (%d) status=%s \n", __FILE__, __LINE__, var_export($status, true));
|
if ($status == self::STATE_TOSTOP) {
|
||||||
if ($status == self::STATUS_TOSTOP) {
|
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
$ret = self::STATUS_TOSTOP;
|
$ret = self::STATE_TOSTOP;
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
// $this->task_status = self::STATUS_TOSTOP;
|
|
||||||
// $this->return_xxxvalue = self::RETURNSTATUS_STOPPED;
|
|
||||||
}
|
}
|
||||||
// if($this->task_status == self::STATUS_TOSTOP)
|
|
||||||
// $this->running = false;
|
|
||||||
|
|
||||||
|
|
||||||
if ( ! $this->running)
|
if ( ! $this->running)
|
||||||
break;
|
break;
|
||||||
} // foreach($rs as $row)
|
}
|
||||||
|
//
|
||||||
// if nothing was done, at least check the status
|
// if nothing was done, at least check the status
|
||||||
if (count($rs) == 0 && $this->running) {
|
if (count($rs) == 0 && $this->running) {
|
||||||
// $this->check_memory_usage();
|
|
||||||
$current_memory = memory_get_usage();
|
$current_memory = memory_get_usage();
|
||||||
if ($current_memory >> 20 >= $this->maxmegs) {
|
if ($current_memory >> 20 >= $this->maxmegs) {
|
||||||
$this->log(sprintf("Max memory (%s M) reached (current is %s M)", $this->maxmegs, $current_memory));
|
$this->log(sprintf("Max memory (%s M) reached (current is %s M)", $this->maxmegs, $current_memory));
|
||||||
@@ -224,20 +216,14 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
$ret = self::STATE_MAXRECSDONE;
|
$ret = self::STATE_MAXRECSDONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->check_task_status();
|
|
||||||
try {
|
try {
|
||||||
$status = $this->getState();
|
$status = $this->getState();
|
||||||
// printf("%s (%d) status=%s \n", __FILE__, __LINE__, var_export($status, true));
|
if ($status == self::STATE_TOSTOP) {
|
||||||
if ($status == self::STATUS_TOSTOP) {
|
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
$ret = self::STATUS_TOSTOP;
|
$ret = self::STATE_TOSTOP;
|
||||||
// $this->task_status = self::STATUS_TOSTOP;
|
|
||||||
// $this->return_xxxvalue = self::RETURNSTATUS_STOPPED;
|
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
// $this->task_status = self::STATUS_TOSTOP;
|
|
||||||
// $this->return_xxxvalue = self::RETURNSTATUS_STOPPED;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +236,7 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
if ($rowstodo > 0)
|
if ($rowstodo > 0)
|
||||||
$this->setProgress(0, 0);
|
$this->setProgress(0, 0);
|
||||||
|
|
||||||
return($ret);
|
return $ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,7 +22,6 @@ class task_manager
|
|||||||
const STATUS_SCHED_TOSTOP = 'tostop';
|
const STATUS_SCHED_TOSTOP = 'tostop';
|
||||||
|
|
||||||
protected $appbox;
|
protected $appbox;
|
||||||
|
|
||||||
protected $tasks;
|
protected $tasks;
|
||||||
|
|
||||||
public function __construct(appbox &$appbox)
|
public function __construct(appbox &$appbox)
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of Phraseanet
|
* This file is part of Phraseanet
|
||||||
*
|
*
|
||||||
* (c) 2005-2010 Alchemy
|
* (c) 2005-2012 Alchemy
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package task_manager
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
@@ -102,7 +101,7 @@ class task_period_archive extends task_abstract
|
|||||||
$ptype = substr($pname, 0, 3);
|
$ptype = substr($pname, 0, 3);
|
||||||
$pname = substr($pname, 4);
|
$pname = substr($pname, 4);
|
||||||
$pvalue = $parm2[$pname];
|
$pvalue = $parm2[$pname];
|
||||||
if ($ns = $dom->getElementsByTagName($pname)->item(0)) {
|
if (($ns = $dom->getElementsByTagName($pname)->item(0))) {
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild))
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
@@ -234,13 +233,13 @@ class task_period_archive extends task_abstract
|
|||||||
</select>
|
</select>
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo _('task::_common_:hotfolder') ?>
|
<?php echo _('task::_common_:hotfolder') ?>
|
||||||
<input type="text" name="hotfolder" style="width:400px;" onchange="chgxmltxt(this, 'hotfolder');" value=""><br/>
|
<input type="text" name="hotfolder" style="width:400px;" onchange="chgxmltxt(this, 'hotfolder');" value=""><br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo _('task::_common_:periodicite de la tache') ?> :
|
<?php echo _('task::_common_:periodicite de la tache') ?> :
|
||||||
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');" value=""> <?php echo _('task::_common_:secondes (unite temporelle)') ?><br/>
|
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');" value=""> <?php echo _('task::_common_:secondes (unite temporelle)') ?><br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo _('task::archive:delai de \'repos\' avant traitement') ?> :
|
<?php echo _('task::archive:delai de \'repos\' avant traitement') ?> :
|
||||||
<input type="text" name="cold" style="width:40px;" onchange="chgxmltxt(this, 'cold');" value=""> <?php echo _('task::_common_:secondes (unite temporelle)') ?><br/>
|
<input type="text" name="cold" style="width:40px;" onchange="chgxmltxt(this, 'cold');" value=""> <?php echo _('task::_common_:secondes (unite temporelle)') ?><br/>
|
||||||
<br/>
|
<br/>
|
||||||
<input type="checkbox" name="move_archived" onchange="chgxmlck(this, 'move_archived');"> <?php echo _('task::archive:deplacer les fichiers archives dans _archived') ?>
|
<input type="checkbox" name="move_archived" onchange="chgxmlck(this, 'move_archived');"> <?php echo _('task::archive:deplacer les fichiers archives dans _archived') ?>
|
||||||
@@ -386,11 +385,11 @@ class task_period_archive extends task_abstract
|
|||||||
|
|
||||||
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
||||||
sleep(1);
|
sleep(1);
|
||||||
$this->setState(self::STATUS_TORESTART);
|
$this->setState(self::STATE_TORESTART);
|
||||||
} else {
|
} else {
|
||||||
$this->log(sprintf(('Error : missing hotfolder \'%s\', stopping.'), $path_in));
|
$this->log(sprintf(('Error : missing hotfolder \'%s\', stopping.'), $path_in));
|
||||||
// runner = manual : can't restart so simply quit
|
// runner = manual : can't restart so simply quit
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
}
|
}
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
return;
|
return;
|
||||||
@@ -426,17 +425,17 @@ class task_period_archive extends task_abstract
|
|||||||
|
|
||||||
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
||||||
sleep(1);
|
sleep(1);
|
||||||
$this->setState(self::STATUS_TORESTART);
|
$this->setState(self::STATE_TORESTART);
|
||||||
} else {
|
} else {
|
||||||
$this->log(sprintf(('Error : error fetching task \'%d\', stopping.'), $this->getID()));
|
$this->log(sprintf(('Error : error fetching task \'%d\', stopping.'), $this->getID()));
|
||||||
// runner = manual : can't restart so simply quit
|
// runner = manual : can't restart so simply quit
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
}
|
}
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($row['status'] == self::STATUS_TOSTOP) {
|
if ($row['status'] == self::STATE_TOSTOP) {
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -449,39 +448,27 @@ class task_period_archive extends task_abstract
|
|||||||
|
|
||||||
switch ($r) {
|
switch ($r) {
|
||||||
case 'TOSTOP':
|
case 'TOSTOP':
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
break;
|
break;
|
||||||
case 'WAIT':
|
case 'WAIT':
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
break;
|
break;
|
||||||
case 'BAD':
|
case 'BAD':
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
break;
|
break;
|
||||||
case 'NORECSTODO':
|
case 'NORECSTODO':
|
||||||
$duration = time() - $duration;
|
$duration = time() - $duration;
|
||||||
if ($duration < ($period + $cold)) {
|
if ($duration < ($period + $cold)) {
|
||||||
/*
|
|
||||||
printf("will close a conn in 5sec...\n");
|
|
||||||
sleep(5);
|
|
||||||
$conn->close();
|
|
||||||
unset($conn);
|
|
||||||
printf("conn closed, waiting 5sec\n");
|
|
||||||
sleep(5);
|
|
||||||
*/
|
|
||||||
for ($i = 0; $i < (($period + $cold) - $duration) && $this->running; $i ++ ) {
|
for ($i = 0; $i < (($period + $cold) - $duration) && $this->running; $i ++ ) {
|
||||||
$s = $this->getState();
|
$s = $this->getState();
|
||||||
if ($s == self::STATUS_TOSTOP) {
|
if ($s == self::STATE_TOSTOP) {
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// $conn->close();
|
|
||||||
// unset($conn);
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
// $conn = connection::getPDOConnection();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -489,14 +476,14 @@ class task_period_archive extends task_abstract
|
|||||||
case 'MAXRECSDONE':
|
case 'MAXRECSDONE':
|
||||||
case 'MAXMEMORY':
|
case 'MAXMEMORY':
|
||||||
case 'MAXLOOP':
|
case 'MAXLOOP':
|
||||||
if ($row['status'] == self::STATUS_STARTED && $this->getRunner() !== self::RUNNER_MANUAL) {
|
if ($row['status'] == self::STATE_STARTED && $this->getRunner() !== self::RUNNER_MANUAL) {
|
||||||
$this->setState(self::STATUS_TORESTART);
|
$this->setState(self::STATE_TORESTART);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if ($row['status'] == self::STATUS_STARTED) {
|
if ($row['status'] == self::STATE_STARTED) {
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -513,8 +500,6 @@ class task_period_archive extends task_abstract
|
|||||||
*/
|
*/
|
||||||
function archiveHotFolder($server_coll_id)
|
function archiveHotFolder($server_coll_id)
|
||||||
{
|
{
|
||||||
// $this->filesToIgnore = array('.', '..', 'Thumbs.db', '');
|
|
||||||
|
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
@@ -570,7 +555,7 @@ class task_period_archive extends task_abstract
|
|||||||
|
|
||||||
while ($cold > 0) {
|
while ($cold > 0) {
|
||||||
$s = $this->getState();
|
$s = $this->getState();
|
||||||
if ($s == self::STATUS_TOSTOP)
|
if ($s == self::STATE_TOSTOP)
|
||||||
return('TOSTOP');
|
return('TOSTOP');
|
||||||
sleep(2);
|
sleep(2);
|
||||||
$cold -= 2;
|
$cold -= 2;
|
||||||
@@ -724,7 +709,7 @@ class task_period_archive extends task_abstract
|
|||||||
while (($file = $listFolder->read()) !== NULL) {
|
while (($file = $listFolder->read()) !== NULL) {
|
||||||
if (time() - $time0 >= 2) { // each 2 secs, check the status of the task
|
if (time() - $time0 >= 2) { // each 2 secs, check the status of the task
|
||||||
$s = $this->getState();
|
$s = $this->getState();
|
||||||
if ($s == self::STATUS_TOSTOP) {
|
if ($s == self::STATE_TOSTOP) {
|
||||||
$nnew = 'TOSTOP'; // since we will return a string...
|
$nnew = 'TOSTOP'; // since we will return a string...
|
||||||
break; // ...we can check it against numerical result
|
break; // ...we can check it against numerical result
|
||||||
}
|
}
|
||||||
@@ -779,7 +764,7 @@ class task_period_archive extends task_abstract
|
|||||||
* @param <type> $depth
|
* @param <type> $depth
|
||||||
* @return <type>
|
* @return <type>
|
||||||
*/
|
*/
|
||||||
function listFilesPhase2($dom, $node, $path, $depth=0)
|
function listFilesPhase2($dom, $node, $path, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0)
|
||||||
@@ -877,7 +862,7 @@ class task_period_archive extends task_abstract
|
|||||||
* @param <type> $depth
|
* @param <type> $depth
|
||||||
* @return <type>
|
* @return <type>
|
||||||
*/
|
*/
|
||||||
function makePairs($dom, $node, $path, $path_archived, $path_error, $inGrp=false, $depth=0)
|
function makePairs($dom, $node, $path, $path_archived, $path_error, $inGrp = false, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0)
|
||||||
@@ -903,7 +888,6 @@ class task_period_archive extends task_abstract
|
|||||||
if ($n->getAttribute('isdir') == '1') {
|
if ($n->getAttribute('isdir') == '1') {
|
||||||
if (($grpSettings = $this->getGrpSettings($name)) !== FALSE) { // get 'caption', 'representation'
|
if (($grpSettings = $this->getGrpSettings($name)) !== FALSE) { // get 'caption', 'representation'
|
||||||
// this is a grp folder, we check it
|
// this is a grp folder, we check it
|
||||||
|
|
||||||
$dnl = $xpath->query('./file[@name=".grouping.xml"]', $n);
|
$dnl = $xpath->query('./file[@name=".grouping.xml"]', $n);
|
||||||
if ($dnl->length == 1) {
|
if ($dnl->length == 1) {
|
||||||
// this group is old (don't care about any linked files), just flag it
|
// this group is old (don't care about any linked files), just flag it
|
||||||
@@ -1010,7 +994,7 @@ class task_period_archive extends task_abstract
|
|||||||
* @param <type> $depth
|
* @param <type> $depth
|
||||||
* @return <type>
|
* @return <type>
|
||||||
*/
|
*/
|
||||||
function removeBadGroups($dom, $node, $path, $path_archived, $path_error, $depth=0)
|
function removeBadGroups($dom, $node, $path, $path_archived, $path_error, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0)
|
||||||
@@ -1033,11 +1017,6 @@ class task_period_archive extends task_abstract
|
|||||||
|
|
||||||
if ($n->getAttribute('isdir')) {
|
if ($n->getAttribute('isdir')) {
|
||||||
// a dir
|
// a dir
|
||||||
// if($n->getAttribute('error') && $this->move_error)
|
|
||||||
// {
|
|
||||||
// @mkdir($path_error . '/' . $name);
|
|
||||||
// }
|
|
||||||
|
|
||||||
$ret |= $this->removeBadGroups($dom, $n, $path . '/' . $name
|
$ret |= $this->removeBadGroups($dom, $n, $path . '/' . $name
|
||||||
, $path_archived . '/' . $name
|
, $path_archived . '/' . $name
|
||||||
, $path_error . '/' . $name
|
, $path_error . '/' . $name
|
||||||
@@ -1086,7 +1065,7 @@ class task_period_archive extends task_abstract
|
|||||||
* @param <type> $depth
|
* @param <type> $depth
|
||||||
* @return <type>
|
* @return <type>
|
||||||
*/
|
*/
|
||||||
function archive($dom, $node, $path, $path_archived, $path_error, $depth=0)
|
function archive($dom, $node, $path, $path_archived, $path_error, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0)
|
||||||
@@ -1125,7 +1104,6 @@ class task_period_archive extends task_abstract
|
|||||||
$this->archiveFile($dom, $n, $path, $path_archived, $path_error, $nodesToDel, 0); // 0 = no grp
|
$this->archiveFile($dom, $n, $path, $path_archived, $path_error, $nodesToDel, 0); // 0 = no grp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// printf("========== %s === %s ====== \n", __LINE__, var_export($nodesToDel, true));
|
|
||||||
foreach ($nodesToDel as $n)
|
foreach ($nodesToDel as $n)
|
||||||
$n->parentNode->removeChild($n);
|
$n->parentNode->removeChild($n);
|
||||||
|
|
||||||
@@ -1153,7 +1131,7 @@ class task_period_archive extends task_abstract
|
|||||||
* @param <type> $depth
|
* @param <type> $depth
|
||||||
* @return <type>
|
* @return <type>
|
||||||
*/
|
*/
|
||||||
function bubbleResults($dom, $node, $path, $depth=0)
|
function bubbleResults($dom, $node, $path, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0)
|
||||||
@@ -1212,7 +1190,7 @@ class task_period_archive extends task_abstract
|
|||||||
* @param <type> $depth
|
* @param <type> $depth
|
||||||
* @return <type>
|
* @return <type>
|
||||||
*/
|
*/
|
||||||
function moveFiles($dom, $node, $path, $path_archived, $path_error, $depth=0)
|
function moveFiles($dom, $node, $path, $path_archived, $path_error, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0)
|
||||||
@@ -1567,7 +1545,7 @@ class task_period_archive extends task_abstract
|
|||||||
* @param <type> $grp_rid
|
* @param <type> $grp_rid
|
||||||
* @return <type>
|
* @return <type>
|
||||||
*/
|
*/
|
||||||
function archiveFile($dom, $node, $path, $path_archived, $path_error, &$nodesToDel, $grp_rid=0)
|
function archiveFile($dom, $node, $path, $path_archived, $path_error, &$nodesToDel, $grp_rid = 0)
|
||||||
{
|
{
|
||||||
$match = $node->getAttribute('match');
|
$match = $node->getAttribute('match');
|
||||||
if ($match == '*')
|
if ($match == '*')
|
||||||
@@ -1823,7 +1801,7 @@ class task_period_archive extends task_abstract
|
|||||||
* @param <type> $attributes
|
* @param <type> $attributes
|
||||||
* @param <type> $depth
|
* @param <type> $depth
|
||||||
*/
|
*/
|
||||||
function setAllChildren($dom, $node, $attributes, $depth=0)
|
function setAllChildren($dom, $node, $attributes, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0)
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of Phraseanet
|
* This file is part of Phraseanet
|
||||||
*
|
*
|
||||||
* (c) 2005-2010 Alchemy
|
* (c) 2005-2012 Alchemy
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
@@ -381,7 +381,7 @@ class task_period_cindexer extends task_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( ! file_exists($cmd) || ! is_executable($cmd)) {
|
if ( ! file_exists($cmd) || ! is_executable($cmd)) {
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->log(sprintf(_('task::cindexer:file \'%s\' does not exists'), $cmd));
|
$this->log(sprintf(_('task::cindexer:file \'%s\' does not exists'), $cmd));
|
||||||
throw new Exception('cindexer executable not found', self::ERR_EXECUTABLE_NOT_FOUND);
|
throw new Exception('cindexer executable not found', self::ERR_EXECUTABLE_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
@@ -442,8 +442,6 @@ class task_period_cindexer extends task_abstract
|
|||||||
$nullfile = $this->system == 'WINDOWS' ? 'NUL' : '/dev/null';
|
$nullfile = $this->system == 'WINDOWS' ? 'NUL' : '/dev/null';
|
||||||
|
|
||||||
$descriptors = array();
|
$descriptors = array();
|
||||||
// $descriptors[1] = array("file", $logdir . "/phraseanet_indexer_" . $this->getID() . ".log", "a+");
|
|
||||||
// $descriptors[2] = array("file", $logdir . "/phraseanet_indexer_" . $this->getID() . ".error.log", "a+");
|
|
||||||
$descriptors[1] = array("file", $nullfile, "a+");
|
$descriptors[1] = array("file", $nullfile, "a+");
|
||||||
$descriptors[2] = array("file", $nullfile, "a+");
|
$descriptors[2] = array("file", $nullfile, "a+");
|
||||||
|
|
||||||
@@ -465,7 +463,7 @@ class task_period_cindexer extends task_abstract
|
|||||||
$this->running = true;
|
$this->running = true;
|
||||||
|
|
||||||
while ($this->running) {
|
while ($this->running) {
|
||||||
if ($this->getState() == self::STATUS_TOSTOP && $this->socket > 0) {
|
if ($this->getState() == self::STATE_TOSTOP && $this->socket > 0) {
|
||||||
// must quit task, so send 'Q' to port 127.0.0.1:XXXX to cindexer
|
// must quit task, so send 'Q' to port 127.0.0.1:XXXX to cindexer
|
||||||
if ( ! $qsent && (($sock = socket_create(AF_INET, SOCK_STREAM, 0)) !== false)) {
|
if ( ! $qsent && (($sock = socket_create(AF_INET, SOCK_STREAM, 0)) !== false)) {
|
||||||
if (socket_connect($sock, '127.0.0.1', $this->socket) === true) {
|
if (socket_connect($sock, '127.0.0.1', $this->socket) === true) {
|
||||||
@@ -487,10 +485,10 @@ class task_period_cindexer extends task_abstract
|
|||||||
// the cindexer died
|
// the cindexer died
|
||||||
if ($qsent == 'Q') {
|
if ($qsent == 'Q') {
|
||||||
$this->log(_('task::cindexer:the cindexer clean-quit'));
|
$this->log(_('task::cindexer:the cindexer clean-quit'));
|
||||||
$this->new_status = self::STATUS_STOPPED;
|
$this->new_status = self::STATE_STOPPED;
|
||||||
} elseif ($qsent == 'K') {
|
} elseif ($qsent == 'K') {
|
||||||
$this->log(_('task::cindexer:the cindexer has been killed'));
|
$this->log(_('task::cindexer:the cindexer has been killed'));
|
||||||
$this->new_status = self::STATUS_STOPPED;
|
$this->new_status = self::STATE_STOPPED;
|
||||||
} else {
|
} else {
|
||||||
$this->log(_('task::cindexer:the cindexer crashed'));
|
$this->log(_('task::cindexer:the cindexer crashed'));
|
||||||
$this->exception = new Exception('cindexer crashed', self::ERR_CRASHED);
|
$this->exception = new Exception('cindexer crashed', self::ERR_CRASHED);
|
||||||
@@ -536,7 +534,6 @@ class task_period_cindexer extends task_abstract
|
|||||||
} elseif ($pid == 0) {
|
} elseif ($pid == 0) {
|
||||||
// child
|
// child
|
||||||
umask(0);
|
umask(0);
|
||||||
// openlog('MyLog', LOG_PID | LOG_PERROR, LOG_LOCAL0);
|
|
||||||
if (($err = posix_setsid()) < 0) {
|
if (($err = posix_setsid()) < 0) {
|
||||||
$this->exception = new Exception('cindexer can\'t detach from terminal', $err);
|
$this->exception = new Exception('cindexer can\'t detach from terminal', $err);
|
||||||
} else {
|
} else {
|
||||||
@@ -562,7 +559,7 @@ class task_period_cindexer extends task_abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getState() == self::STATUS_TOSTOP) {
|
if ($this->getState() == self::STATE_TOSTOP) {
|
||||||
posix_kill($pid, ($sigsent = SIGINT));
|
posix_kill($pid, ($sigsent = SIGINT));
|
||||||
sleep(2);
|
sleep(2);
|
||||||
}
|
}
|
||||||
@@ -572,10 +569,10 @@ class task_period_cindexer extends task_abstract
|
|||||||
// child (indexer) has exited
|
// child (indexer) has exited
|
||||||
if ($sigsent == SIGINT) {
|
if ($sigsent == SIGINT) {
|
||||||
$this->log(_('task::cindexer:the cindexer clean-quit'));
|
$this->log(_('task::cindexer:the cindexer clean-quit'));
|
||||||
$this->new_status = self::STATUS_STOPPED;
|
$this->new_status = self::STATE_STOPPED;
|
||||||
} elseif ($sigsent == SIGKILL) {
|
} elseif ($sigsent == SIGKILL) {
|
||||||
$this->log(_('task::cindexer:the cindexer has been killed'));
|
$this->log(_('task::cindexer:the cindexer has been killed'));
|
||||||
$this->new_status = self::STATUS_STOPPED;
|
$this->new_status = self::STATE_STOPPED;
|
||||||
} else {
|
} else {
|
||||||
$this->log(_('task::cindexer:the cindexer crashed'));
|
$this->log(_('task::cindexer:the cindexer crashed'));
|
||||||
$this->exception = new Exception('cindexer crashed', self::ERR_CRASHED);
|
$this->exception = new Exception('cindexer crashed', self::ERR_CRASHED);
|
||||||
@@ -601,5 +598,3 @@ class task_period_cindexer extends task_abstract
|
|||||||
sleep(2);
|
sleep(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// class
|
|
||||||
|
@@ -18,9 +18,7 @@
|
|||||||
class task_period_emptyColl extends task_appboxAbstract
|
class task_period_emptyColl extends task_appboxAbstract
|
||||||
{
|
{
|
||||||
protected $base_id;
|
protected $base_id;
|
||||||
|
|
||||||
protected $suicidable = true;
|
protected $suicidable = true;
|
||||||
|
|
||||||
protected $total_records = 0;
|
protected $total_records = 0;
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
@@ -47,9 +45,8 @@ class task_period_emptyColl extends task_appboxAbstract
|
|||||||
protected function retrieveContent(appbox $appbox)
|
protected function retrieveContent(appbox $appbox)
|
||||||
{
|
{
|
||||||
if ( ! $this->base_id) {
|
if ( ! $this->base_id) {
|
||||||
$this->current_state = self::STATE_FINISHED;
|
$this->setState(self::STATE_STOPPED);
|
||||||
|
return array();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
$collection = collection::get_from_base_id($this->base_id);
|
$collection = collection::get_from_base_id($this->base_id);
|
||||||
$this->total_records = $collection->get_record_amount();
|
$this->total_records = $collection->get_record_amount();
|
||||||
@@ -58,7 +55,7 @@ class task_period_emptyColl extends task_appboxAbstract
|
|||||||
$this->setProgress($this->records_done, $this->total_records);
|
$this->setProgress($this->records_done, $this->total_records);
|
||||||
|
|
||||||
if ($this->total_records == 0) {
|
if ($this->total_records == 0) {
|
||||||
$this->current_state = self::STATE_FINISHED;
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->log('Job finished');
|
$this->log('Job finished');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,9 +17,7 @@
|
|||||||
class task_period_ftp extends task_appboxAbstract
|
class task_period_ftp extends task_appboxAbstract
|
||||||
{
|
{
|
||||||
protected $proxy;
|
protected $proxy;
|
||||||
|
|
||||||
protected $proxyport;
|
protected $proxyport;
|
||||||
|
|
||||||
protected $debug;
|
protected $debug;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -566,8 +564,7 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
{
|
{
|
||||||
$conn = $appbox->get_connection();
|
$conn = $appbox->get_connection();
|
||||||
|
|
||||||
$sql = 'SELECT crash, nbretry FROM ftp_export'
|
$sql = 'SELECT crash, nbretry FROM ftp_export WHERE id = :export_id';
|
||||||
. ' WHERE id = :export_id';
|
|
||||||
|
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':export_id' => $id));
|
$stmt->execute(array(':export_id' => $id));
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of Phraseanet
|
* This file is part of Phraseanet
|
||||||
*
|
*
|
||||||
* (c) 2005-2010 Alchemy
|
* (c) 2005-2012 Alchemy
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
@@ -17,25 +17,15 @@
|
|||||||
class task_period_ftpPull extends task_appboxAbstract
|
class task_period_ftpPull extends task_appboxAbstract
|
||||||
{
|
{
|
||||||
protected $debug = false;
|
protected $debug = false;
|
||||||
|
|
||||||
protected $proxy;
|
protected $proxy;
|
||||||
|
|
||||||
protected $proxyport;
|
protected $proxyport;
|
||||||
|
|
||||||
protected $host;
|
protected $host;
|
||||||
|
|
||||||
protected $port;
|
protected $port;
|
||||||
|
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
protected $password;
|
protected $password;
|
||||||
|
|
||||||
protected $ssl;
|
protected $ssl;
|
||||||
|
|
||||||
protected $passive;
|
protected $passive;
|
||||||
|
|
||||||
protected $ftppath;
|
protected $ftppath;
|
||||||
|
|
||||||
protected $localpath;
|
protected $localpath;
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
@@ -108,6 +98,7 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
<?php echo $form ?>.ssl.checked = <?php echo p4field::isyes($sxml->ssl) ? "true" : 'false' ?>;
|
<?php echo $form ?>.ssl.checked = <?php echo p4field::isyes($sxml->ssl) ? "true" : 'false' ?>;
|
||||||
<?php echo $form ?>.passive.checked = <?php echo p4field::isyes($sxml->passive) ? "true" : 'false' ?>;
|
<?php echo $form ?>.passive.checked = <?php echo p4field::isyes($sxml->passive) ? "true" : 'false' ?>;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
return("");
|
return("");
|
||||||
} else { // ... so we NEVER come here
|
} else { // ... so we NEVER come here
|
||||||
@@ -134,6 +125,7 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
setDirty();
|
setDirty();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,11 +195,11 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
|
|
||||||
if ($parm["xml"] === null) {
|
if ($parm["xml"] === null) {
|
||||||
// pas de xml 'raw' : on accepte les champs 'graphic view'
|
// pas de xml 'raw' : on accepte les champs 'graphic view'
|
||||||
if ($domTaskSettings = DOMDocument::loadXML($taskrow["settings"])) {
|
if (($domTaskSettings = DOMDocument::loadXML($taskrow["settings"]))) {
|
||||||
$xmlchanged = false;
|
$xmlchanged = false;
|
||||||
foreach (array("proxy", "proxyport", "period", "host", "port", "user", "password", "ssl", "passive", "localpath", "ftppath") as $f) {
|
foreach (array("proxy", "proxyport", "period", "host", "port", "user", "password", "ssl", "passive", "localpath", "ftppath") as $f) {
|
||||||
if ($parm[$f] !== NULL) {
|
if ($parm[$f] !== NULL) {
|
||||||
if ($ns = $domTaskSettings->getElementsByTagName($f)->item(0)) {
|
if (($ns = $domTaskSettings->getElementsByTagName($f)->item(0))) {
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild))
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
@@ -228,8 +220,9 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
// si on doit changer le xml, on verifie qu'il est valide
|
// si on doit changer le xml, on verifie qu'il est valide
|
||||||
if ($parm["xml"] && ! DOMDocument::loadXML($parm["xml"]))
|
if ($parm["xml"] && ! DOMDocument::loadXML($parm["xml"])) {
|
||||||
return(false);
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "";
|
$sql = "";
|
||||||
$params = array(':task_id' => $taskid);
|
$params = array(':task_id' => $taskid);
|
||||||
@@ -295,7 +288,7 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
}
|
}
|
||||||
if ( ! $this->running) {
|
if ( ! $this->running) {
|
||||||
$this->set_status(self::STATUS_STOPPED);
|
$this->set_status(self::STATE_STOPPED);
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,14 +301,16 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
$todo = count($list_1);
|
$todo = count($list_1);
|
||||||
$this->setProgress($done, $todo);
|
$this->setProgress($done, $todo);
|
||||||
|
|
||||||
if ($this->debug)
|
if ($this->debug) {
|
||||||
echo "attente de 25sec pour avoir les fichiers froids...\n";
|
echo "attente de 25sec pour avoir les fichiers froids...\n";
|
||||||
|
}
|
||||||
|
|
||||||
for ($t = 25; $this->running && $t > 0; $t -- ) { // DON'T do sleep($this->period - $when_started) because it prevents ticks !
|
for ($t = 25; $this->running && $t > 0; $t -- ) { // DON'T do sleep($this->period - $when_started) because it prevents ticks !
|
||||||
$s = $this->getState();
|
$s = $this->getState();
|
||||||
if ($s == self::STATUS_TOSTOP) {
|
if ($s == self::STATE_TOSTOP) {
|
||||||
if (isset($ftp) && $ftp instanceof ftpclient)
|
if (isset($ftp) && $ftp instanceof ftpclient)
|
||||||
$ftp->close();
|
$ftp->close();
|
||||||
$this->set_status(self::STATUS_STOPPED);
|
$this->set_status(self::STATE_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
@@ -379,3 +374,4 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of Phraseanet
|
* This file is part of Phraseanet
|
||||||
*
|
*
|
||||||
* (c) 2005-2010 Alchemy
|
* (c) 2005-2012 Alchemy
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
@@ -448,11 +448,8 @@ class task_period_outofdate extends task_abstract
|
|||||||
// ======================================================================================================
|
// ======================================================================================================
|
||||||
|
|
||||||
protected $sxTaskSettings = null; // les settings de la tache en simplexml
|
protected $sxTaskSettings = null; // les settings de la tache en simplexml
|
||||||
|
|
||||||
private $connbas = null; // cnx a la base
|
private $connbas = null; // cnx a la base
|
||||||
|
|
||||||
private $msg = "";
|
private $msg = "";
|
||||||
|
|
||||||
private $sbas_id;
|
private $sbas_id;
|
||||||
|
|
||||||
protected function run2()
|
protected function run2()
|
||||||
@@ -529,11 +526,11 @@ class task_period_outofdate extends task_abstract
|
|||||||
|
|
||||||
switch ($r) {
|
switch ($r) {
|
||||||
case 'WAIT':
|
case 'WAIT':
|
||||||
$ret = self::STATUS_STOPPED;
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
break;
|
break;
|
||||||
case 'BAD':
|
case 'BAD':
|
||||||
$ret = self::STATUS_STOPPED;
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
break;
|
break;
|
||||||
case 'NORECSTODO':
|
case 'NORECSTODO':
|
||||||
@@ -546,21 +543,21 @@ class task_period_outofdate extends task_abstract
|
|||||||
case 'MAXRECSDONE':
|
case 'MAXRECSDONE':
|
||||||
case 'MAXMEMORY':
|
case 'MAXMEMORY':
|
||||||
case 'MAXLOOP':
|
case 'MAXLOOP':
|
||||||
if ($row['status'] == self::STATUS_STARTED && $this->getRunner() !== self::RUNNER_MANUAL) {
|
if ($row['status'] == self::STATE_STARTED && $this->getRunner() !== self::RUNNER_MANUAL) {
|
||||||
$ret = self::STATUS_TORESTART;
|
$this->setState(self::STATE_TORESTART);
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if ($row['status'] == self::STATUS_STARTED) {
|
if ($row['status'] == self::STATE_STARTED) {
|
||||||
$ret = self::STATUS_STOPPED;
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$ret = self::STATUS_STOPPED;
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
}
|
}
|
||||||
$loop ++;
|
$loop ++;
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of Phraseanet
|
* This file is part of Phraseanet
|
||||||
*
|
*
|
||||||
* (c) 2005-2010 Alchemy
|
* (c) 2005-2012 Alchemy
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
@@ -141,6 +141,7 @@ class task_period_subdef extends task_databoxAbstract
|
|||||||
<?php echo $form ?>.maxrecs.value = "<?php echo p4string::MakeString($sxml->maxrecs, "js", '"') ?>";
|
<?php echo $form ?>.maxrecs.value = "<?php echo p4string::MakeString($sxml->maxrecs, "js", '"') ?>";
|
||||||
<?php echo $form ?>.maxmegs.value = "<?php echo p4string::MakeString($sxml->maxmegs, "js", '"') ?>";
|
<?php echo $form ?>.maxmegs.value = "<?php echo p4string::MakeString($sxml->maxmegs, "js", '"') ?>";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
@@ -261,7 +262,7 @@ class task_period_subdef extends task_databoxAbstract
|
|||||||
, $this->sbas_id, $record_id));
|
, $this->sbas_id, $record_id));
|
||||||
$record = new record_adapter($this->sbas_id, $record_id);
|
$record = new record_adapter($this->sbas_id, $record_id);
|
||||||
|
|
||||||
$record->generate_subdefs($databox, null, $this->debug);
|
$record->generate_subdefs($databox, null);
|
||||||
|
|
||||||
$this->recs_to_write[] = $record->get_record_id();
|
$this->recs_to_write[] = $record->get_record_id();
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of Phraseanet
|
* This file is part of Phraseanet
|
||||||
*
|
*
|
||||||
* (c) 2005-2010 Alchemy
|
* (c) 2005-2012 Alchemy
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package task_manager
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
@@ -117,12 +116,12 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
<?php echo $form ?>.period.value = "<?php echo p4string::MakeString($sxml->period, "js", '"') ?>";
|
<?php echo $form ?>.period.value = "<?php echo p4string::MakeString($sxml->period, "js", '"') ?>";
|
||||||
parent.calccmd();
|
parent.calccmd();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
else { // ... so we NEVER come here
|
else { // ... so we NEVER come here
|
||||||
// bad xml
|
// bad xml
|
||||||
|
|
||||||
return("BAD XML");
|
return("BAD XML");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -283,16 +282,16 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
ob_start();
|
ob_start();
|
||||||
?>
|
?>
|
||||||
<form name="graphicForm" onsubmit="return(false);" method="post">
|
<form name="graphicForm" onsubmit="return(false);" method="post">
|
||||||
<?php echo _('task::outofdate:Base') ?> :
|
<?php echo _('task::outofdate:Base') ?> :
|
||||||
|
|
||||||
<select onchange="chgsbas(this);setDirty();" name="sbas_id">
|
<select onchange="chgsbas(this);setDirty();" name="sbas_id">
|
||||||
<option value="">...</option>
|
<option value="">...</option>
|
||||||
<?php
|
<?php
|
||||||
$sbas_ids = $user->ACL()->get_granted_sbas(array('bas_manage'));
|
$sbas_ids = $user->ACL()->get_granted_sbas(array('bas_manage'));
|
||||||
foreach ($sbas_ids as $databox) {
|
foreach ($sbas_ids as $databox) {
|
||||||
print('<option value="' . $databox->get_sbas_id() . '">' . p4string::MakeString($databox->get_viewname(), "form") . '</option>');
|
print('<option value="' . $databox->get_sbas_id() . '">' . p4string::MakeString($databox->get_viewname(), "form") . '</option>');
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
@@ -300,9 +299,9 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<?php echo _('task::_common_:periodicite de la tache') ?> :
|
<?php echo _('task::_common_:periodicite de la tache') ?> :
|
||||||
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');" value="">
|
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');" value="">
|
||||||
<?php echo _('task::_common_:minutes (unite temporelle)') ?><br/>
|
<?php echo _('task::_common_:minutes (unite temporelle)') ?><br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<table id="OUTOFDATETAB" style="margin-right:10px; ">
|
<table id="OUTOFDATETAB" style="margin-right:10px; ">
|
||||||
@@ -348,11 +347,8 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
return(_("task::outofdate:deplacement de docs suivant valeurs de champs 'date'"));
|
return(_("task::outofdate:deplacement de docs suivant valeurs de champs 'date'"));
|
||||||
}
|
}
|
||||||
protected $status_origine;
|
protected $status_origine;
|
||||||
|
|
||||||
protected $coll_origine;
|
protected $coll_origine;
|
||||||
|
|
||||||
protected $status_destination;
|
protected $status_destination;
|
||||||
|
|
||||||
protected $coll_destination;
|
protected $coll_destination;
|
||||||
|
|
||||||
protected function loadSettings(SimpleXMLElement $sx_task_settings)
|
protected function loadSettings(SimpleXMLElement $sx_task_settings)
|
||||||
@@ -382,28 +378,28 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
$sql_s = $sql_w = '';
|
$sql_s = $sql_w = '';
|
||||||
$sql_parms = array();
|
$sql_parms = array();
|
||||||
if ($this->coll_origine != '') {
|
if ($this->coll_origine != '') {
|
||||||
$sql_w .= ($sql_w ? ' AND ' : '')
|
$sql_w .= ($sql_w ? ' AND ' : '') . '(coll_id=:coll_org)';
|
||||||
. '(coll_id=:coll_org)';
|
|
||||||
$sql_parms[':coll_org'] = $this->coll_origine;
|
$sql_parms[':coll_org'] = $this->coll_origine;
|
||||||
}
|
}
|
||||||
if ($this->status_origine != '') {
|
if ($this->status_origine != '') {
|
||||||
$x = explode('_', $this->status_origine);
|
$x = explode('_', $this->status_origine);
|
||||||
if (count($x) !== 2)
|
if (count($x) !== 2) {
|
||||||
throw new Exception('Error in settings for status origine');
|
throw new Exception('Error in settings for status origin');
|
||||||
|
}
|
||||||
$sql_w .= ($sql_w ? ' AND ' : '')
|
$sql_w .= ($sql_w ? ' AND ' : '')
|
||||||
. '((status >> :stat_org_n & 1) = :stat_org_v)';
|
. '((status >> :stat_org_n & 1) = :stat_org_v)';
|
||||||
$sql_parms[':stat_org_n'] = $x[0];
|
$sql_parms[':stat_org_n'] = $x[0];
|
||||||
$sql_parms[':stat_org_v'] = $x[1];
|
$sql_parms[':stat_org_v'] = $x[1];
|
||||||
}
|
}
|
||||||
if ($this->coll_destination != '') {
|
if ($this->coll_destination != '') {
|
||||||
$sql_s .= ($sql_s ? ', ' : '')
|
$sql_s .= ($sql_s ? ', ' : '') . 'coll_id=:coll_dst';
|
||||||
. 'coll_id=:coll_dst';
|
|
||||||
$sql_parms[':coll_dst'] = $this->coll_destination;
|
$sql_parms[':coll_dst'] = $this->coll_destination;
|
||||||
}
|
}
|
||||||
if ($this->status_destination != '') {
|
if ($this->status_destination != '') {
|
||||||
$x = explode('_', $this->status_destination);
|
$x = explode('_', $this->status_destination);
|
||||||
if (count($x) !== 2)
|
if (count($x) !== 2) {
|
||||||
throw new Exception('Error in settings for status destination');
|
throw new Exception('Error in settings for status destination');
|
||||||
|
}
|
||||||
$sql_s .= ($sql_s ? ', ' : '');
|
$sql_s .= ($sql_s ? ', ' : '');
|
||||||
if ((int) $x[1] === 0)
|
if ((int) $x[1] === 0)
|
||||||
$sql_s .= 'status = status &~(1 << :stat_dst)';
|
$sql_s .= 'status = status &~(1 << :stat_dst)';
|
||||||
@@ -491,6 +487,7 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return p4string::jsonencode($retjs);
|
return p4string::jsonencode($retjs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,14 +16,12 @@ use PHPExiftool\Writer;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package task_manager
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
class task_period_writemeta extends task_databoxAbstract
|
class task_period_writemeta extends task_databoxAbstract
|
||||||
{
|
{
|
||||||
protected $clear_doc;
|
protected $clear_doc;
|
||||||
|
|
||||||
protected $metasubdefs = array();
|
protected $metasubdefs = array();
|
||||||
|
|
||||||
function help()
|
function help()
|
||||||
@@ -61,7 +59,7 @@ class task_period_writemeta extends task_databoxAbstract
|
|||||||
$ptype = substr($pname, 0, 3);
|
$ptype = substr($pname, 0, 3);
|
||||||
$pname = substr($pname, 4);
|
$pname = substr($pname, 4);
|
||||||
$pvalue = $parm2[$pname];
|
$pvalue = $parm2[$pname];
|
||||||
if ($ns = $dom->getElementsByTagName($pname)->item(0)) {
|
if (($ns = $dom->getElementsByTagName($pname)->item(0))) {
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild))
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
|
@@ -293,7 +293,7 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
|
|||||||
$this->evaluateMetaJson200($content);
|
$this->evaluateMetaJson200($content);
|
||||||
$task_manager->getTasks(true);
|
$task_manager->getTasks(true);
|
||||||
$task = $task_manager->getTask($idTask);
|
$task = $task_manager->getTask($idTask);
|
||||||
$this->assertEquals(\task_abstract::STATUS_TOSTART, $task->getState());
|
$this->assertEquals(\task_abstract::STATE_TOSTART, $task->getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -324,7 +324,7 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
|
|||||||
$this->evaluateMetaJson200($content);
|
$this->evaluateMetaJson200($content);
|
||||||
$task_manager->getTasks(true);
|
$task_manager->getTasks(true);
|
||||||
$task = $task_manager->getTask($idTask);
|
$task = $task_manager->getTask($idTask);
|
||||||
$this->assertEquals(\task_abstract::STATUS_TOSTOP, $task->getState());
|
$this->assertEquals(\task_abstract::STATE_TOSTOP, $task->getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -294,7 +294,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
|
|||||||
$this->evaluateMetaYaml200($content);
|
$this->evaluateMetaYaml200($content);
|
||||||
$task_manager->getTasks(true);
|
$task_manager->getTasks(true);
|
||||||
$task = $task_manager->getTask($idTask);
|
$task = $task_manager->getTask($idTask);
|
||||||
$this->assertEquals(\task_abstract::STATUS_TOSTART, $task->getState());
|
$this->assertEquals(\task_abstract::STATE_TOSTART, $task->getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -325,7 +325,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
|
|||||||
$this->evaluateMetaYaml200($content);
|
$this->evaluateMetaYaml200($content);
|
||||||
$task_manager->getTasks(true);
|
$task_manager->getTasks(true);
|
||||||
$task = $task_manager->getTask($idTask);
|
$task = $task_manager->getTask($idTask);
|
||||||
$this->assertEquals(\task_abstract::STATUS_TOSTOP, $task->getState());
|
$this->assertEquals(\task_abstract::STATE_TOSTOP, $task->getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of Phraseanet
|
* This file is part of Phraseanet
|
||||||
*
|
*
|
||||||
* (c) 2005-2010 Alchemy
|
* (c) 2005-2012 Alchemy
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
@@ -25,355 +24,315 @@ $parm = $request->get_parms('action', 'position', 'test', 'renew', 'path', 'test
|
|||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
switch ($parm['action'])
|
switch ($parm['action']) {
|
||||||
{
|
case 'TREE':
|
||||||
case 'TREE':
|
$output = module_admin::getTree($parm['position']);
|
||||||
$output = module_admin::getTree($parm['position']);
|
break;
|
||||||
break;
|
case 'APACHE':
|
||||||
case 'APACHE':
|
if ($parm['test'] == 'success')
|
||||||
if ($parm['test'] == 'success')
|
$output = '1';
|
||||||
$output = '1';
|
|
||||||
else
|
|
||||||
$output = '0';
|
|
||||||
break;
|
|
||||||
case 'SCHEDULERKEY':
|
|
||||||
$output = $registry->get('GV_ServerName') . 'admin/runscheduler.php?key=' . urlencode(phrasea::scheduler_key(!!$parm['renew']));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'TESTPATH':
|
|
||||||
$tests = true;
|
|
||||||
foreach ($parm['tests'] as $test)
|
|
||||||
{
|
|
||||||
switch ($test)
|
|
||||||
{
|
|
||||||
case 'writeable':
|
|
||||||
if (!is_writable($parm['path']))
|
|
||||||
{
|
|
||||||
$tests = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'readable':
|
|
||||||
default:
|
|
||||||
if (!is_readable($parm['path']))
|
|
||||||
{
|
|
||||||
$tests = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$output = p4string::jsonencode(array('results' => ($tests ? '1' : '0')));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'EMPTYBASE':
|
|
||||||
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
|
|
||||||
$message = _('Base empty successful');
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$sbas_id = (int) $parm['sbas_id'];
|
|
||||||
$databox = databox::get_instance($sbas_id);
|
|
||||||
$class_name = 'task_period_emptyColl';
|
|
||||||
foreach ($databox->get_collections() as $collection)
|
|
||||||
{
|
|
||||||
if($collection->get_record_amount() <= 500)
|
|
||||||
{
|
|
||||||
$collection->empty_collection(500);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
$output = '0';
|
||||||
$settings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><tasksettings><base_id>" . $collection->get_base_id() . "</base_id></tasksettings>";
|
break;
|
||||||
task_abstract::create($appbox, $class_name, $settings);
|
case 'SCHEDULERKEY':
|
||||||
$message = _('A task has been creted, please run it to complete empty collection');
|
$output = $registry->get('GV_ServerName') . 'admin/runscheduler.php?key=' . urlencode(phrasea::scheduler_key( ! ! $parm['renew']));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'TESTPATH':
|
||||||
|
$tests = true;
|
||||||
|
foreach ($parm['tests'] as $test) {
|
||||||
|
switch ($test) {
|
||||||
|
case 'writeable':
|
||||||
|
if ( ! is_writable($parm['path'])) {
|
||||||
|
$tests = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'readable':
|
||||||
|
default:
|
||||||
|
if ( ! is_readable($parm['path'])) {
|
||||||
|
$tests = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
$output = p4string::jsonencode(array('results' => ($tests ? '1' : '0')));
|
||||||
}
|
break;
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
$message = _('An error occurred');
|
|
||||||
}
|
|
||||||
$output = p4string::jsonencode(array('message'=>$message));
|
|
||||||
break;
|
|
||||||
case 'EMPTYCOLL':
|
|
||||||
$message = _('Collection empty successful');
|
|
||||||
$parm = $request->get_parms(
|
|
||||||
array(
|
|
||||||
"sbas_id" => http_request::SANITIZE_NUMBER_INT
|
|
||||||
, "coll_id" => http_request::SANITIZE_NUMBER_INT
|
|
||||||
)
|
|
||||||
);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$databox = databox::get_instance($parm['sbas_id']);
|
|
||||||
$collection = collection::get_from_coll_id($databox, $parm['coll_id']);
|
|
||||||
|
|
||||||
if($collection->get_record_amount() <= 500)
|
case 'EMPTYBASE':
|
||||||
{
|
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
|
||||||
$collection->empty_collection(500);
|
$message = _('Base empty successful');
|
||||||
}
|
try {
|
||||||
else
|
$sbas_id = (int) $parm['sbas_id'];
|
||||||
{
|
$databox = databox::get_instance($sbas_id);
|
||||||
$class_name = 'task_period_emptyColl';
|
$class_name = 'task_period_emptyColl';
|
||||||
$settings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tasksettings>\n<base_id>" . $collection->get_base_id() . "</base_id></tasksettings>";
|
foreach ($databox->get_collections() as $collection) {
|
||||||
|
if ($collection->get_record_amount() <= 500) {
|
||||||
|
$collection->empty_collection(500);
|
||||||
|
} else {
|
||||||
|
$settings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><tasksettings><base_id>" . $collection->get_base_id() . "</base_id></tasksettings>";
|
||||||
|
task_abstract::create($appbox, $class_name, $settings);
|
||||||
|
$message = _('A task has been creted, please run it to complete empty collection');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$message = _('An error occurred');
|
||||||
|
}
|
||||||
|
$output = p4string::jsonencode(array('message' => $message));
|
||||||
|
break;
|
||||||
|
case 'EMPTYCOLL':
|
||||||
|
$message = _('Collection empty successful');
|
||||||
|
$parm = $request->get_parms(
|
||||||
|
array(
|
||||||
|
"sbas_id" => http_request::SANITIZE_NUMBER_INT
|
||||||
|
, "coll_id" => http_request::SANITIZE_NUMBER_INT
|
||||||
|
)
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
$databox = databox::get_instance($parm['sbas_id']);
|
||||||
|
$collection = collection::get_from_coll_id($databox, $parm['coll_id']);
|
||||||
|
|
||||||
task_abstract::create($appbox, $class_name, $settings);
|
if ($collection->get_record_amount() <= 500) {
|
||||||
$message = _('A task has been creted, please run it to complete empty collection');
|
$collection->empty_collection(500);
|
||||||
}
|
} else {
|
||||||
}
|
$class_name = 'task_period_emptyColl';
|
||||||
catch (Exception $e)
|
$settings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tasksettings>\n<base_id>" . $collection->get_base_id() . "</base_id></tasksettings>";
|
||||||
{
|
|
||||||
$message = _('An error occurred');
|
|
||||||
}
|
|
||||||
$output = p4string::jsonencode(array('message'=>$message));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'SETTASKSTATUS':
|
task_abstract::create($appbox, $class_name, $settings);
|
||||||
$parm = $request->get_parms('task_id', 'status', 'signal');
|
$message = _('A task has been creted, please run it to complete empty collection');
|
||||||
try
|
}
|
||||||
{
|
} catch (Exception $e) {
|
||||||
$task_manager = new task_manager($appbox);
|
$message = _('An error occurred');
|
||||||
$task = $task_manager->getTask($parm['task_id']);
|
}
|
||||||
$pid = (int)($task->getPID());
|
$output = p4string::jsonencode(array('message' => $message));
|
||||||
$task->setState($parm["status"]);
|
break;
|
||||||
$signal = (int)($parm['signal']);
|
|
||||||
if( $signal > 0 && $pid )
|
|
||||||
posix_kill($pid, $signal);
|
|
||||||
}
|
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
case 'SETTASKSTATUS':
|
||||||
$output = json_encode($pid);
|
$parm = $request->get_parms('task_id', 'status', 'signal');
|
||||||
break;
|
try {
|
||||||
|
$task_manager = new task_manager($appbox);
|
||||||
|
$task = $task_manager->getTask($parm['task_id']);
|
||||||
|
$pid = (int) ($task->getPID());
|
||||||
|
$task->setState($parm["status"]);
|
||||||
|
$signal = (int) ($parm['signal']);
|
||||||
|
if ($signal > 0 && $pid)
|
||||||
|
posix_kill($pid, $signal);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
|
||||||
case 'SETSCHEDSTATUS':
|
}
|
||||||
$parm = $request->get_parms('status', 'signal');
|
$output = json_encode($pid);
|
||||||
try
|
break;
|
||||||
{
|
|
||||||
$task_manager = new task_manager($appbox);
|
|
||||||
|
|
||||||
$task_manager->setSchedulerState($parm['status']);
|
case 'SETSCHEDSTATUS':
|
||||||
}
|
$parm = $request->get_parms('status', 'signal');
|
||||||
catch (Exception $e)
|
try {
|
||||||
{
|
$task_manager = new task_manager($appbox);
|
||||||
|
|
||||||
}
|
$task_manager->setSchedulerState($parm['status']);
|
||||||
break;
|
} catch (Exception $e) {
|
||||||
|
|
||||||
case 'RESETTASKCRASHCOUNTER':
|
}
|
||||||
$parm = $request->get_parms("task_id");
|
break;
|
||||||
try
|
|
||||||
{
|
|
||||||
$task_manager = new task_manager($appbox);
|
|
||||||
$task = $task_manager->getTask($parm['task_id']);
|
|
||||||
$task->resetCrashCounter();
|
|
||||||
}
|
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
case 'RESETTASKCRASHCOUNTER':
|
||||||
$ret = new DOMDocument("1.0", "UTF-8");
|
$parm = $request->get_parms("task_id");
|
||||||
$ret->standalone = true;
|
try {
|
||||||
$ret->preserveWhiteSpace = false;
|
$task_manager = new task_manager($appbox);
|
||||||
$root = $ret->appendChild($ret->createElement("result"));
|
$task = $task_manager->getTask($parm['task_id']);
|
||||||
$root->appendChild($ret->createCDATASection(var_export($parm, true)));
|
$task->resetCrashCounter();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
|
||||||
$output = $ret->saveXML();
|
}
|
||||||
break;
|
$ret = new DOMDocument("1.0", "UTF-8");
|
||||||
|
$ret->standalone = true;
|
||||||
|
$ret->preserveWhiteSpace = false;
|
||||||
|
$root = $ret->appendChild($ret->createElement("result"));
|
||||||
|
$root->appendChild($ret->createCDATASection(var_export($parm, true)));
|
||||||
|
|
||||||
case 'CHANGETASK':
|
$output = $ret->saveXML();
|
||||||
$parm = $request->get_parms('act', 'task_id', "usr");
|
break;
|
||||||
$ret = new DOMDocument("1.0", "UTF-8");
|
|
||||||
$ret->standalone = true;
|
|
||||||
$ret->preserveWhiteSpace = false;
|
|
||||||
$root = $ret->appendChild($ret->createElement("result"));
|
|
||||||
$root->setAttribute("saved", "0");
|
|
||||||
$root->appendChild($ret->createCDATASection(var_export($parm, true)));
|
|
||||||
|
|
||||||
try
|
case 'CHANGETASK':
|
||||||
{
|
$parm = $request->get_parms('act', 'task_id', "usr");
|
||||||
$task_manager = new task_manager($appbox);
|
$ret = new DOMDocument("1.0", "UTF-8");
|
||||||
$task = $task_manager->getTask($parm["task_id"]);
|
$ret->standalone = true;
|
||||||
/**
|
$ret->preserveWhiteSpace = false;
|
||||||
* @todo checker, cette methode n'est pas implementee partout
|
$root = $ret->appendChild($ret->createElement("result"));
|
||||||
*/
|
$root->setAttribute("saved", "0");
|
||||||
$root->setAttribute("crashed", $task->getCrashCounter());
|
$root->appendChild($ret->createCDATASection(var_export($parm, true)));
|
||||||
if ($task->saveChanges($conn, $parm["task_id"], $row))
|
|
||||||
$root->setAttribute("saved", "1");
|
|
||||||
}
|
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
try {
|
||||||
|
$task_manager = new task_manager($appbox);
|
||||||
|
$task = $task_manager->getTask($parm["task_id"]);
|
||||||
|
/**
|
||||||
|
* @todo checker, cette methode n'est pas implementee partout
|
||||||
|
*/
|
||||||
|
$root->setAttribute("crashed", $task->getCrashCounter());
|
||||||
|
if ($task->saveChanges($conn, $parm["task_id"], $row))
|
||||||
|
$root->setAttribute("saved", "1");
|
||||||
|
} catch (Exception $e) {
|
||||||
|
|
||||||
$output = $ret->saveXML();
|
}
|
||||||
break;
|
|
||||||
case 'PINGSCHEDULER_JS':
|
|
||||||
$ret = array('time'=> date("H:i:s") );
|
|
||||||
|
|
||||||
$task_manager = new task_manager($appbox);
|
$output = $ret->saveXML();
|
||||||
$ret['scheduler'] = $task_manager->getSchedulerState();
|
break;
|
||||||
|
case 'PINGSCHEDULER_JS':
|
||||||
|
$ret = array('time' => date("H:i:s"));
|
||||||
|
|
||||||
$ret['tasks'] = array();
|
$task_manager = new task_manager($appbox);
|
||||||
|
$ret['scheduler'] = $task_manager->getSchedulerState();
|
||||||
|
|
||||||
foreach ($task_manager->getTasks(true) as $task)
|
$ret['tasks'] = array();
|
||||||
{
|
|
||||||
if($task->getState()==task_abstract::STATUS_TOSTOP && $task->getPID()===NULL)
|
|
||||||
{
|
|
||||||
// fix
|
|
||||||
$task->setState(task_abstract::STATUS_STOPPED);
|
|
||||||
}
|
|
||||||
$id = $task->getID();
|
|
||||||
$ret['tasks'][$id] = array(
|
|
||||||
'id'=>$id
|
|
||||||
, 'pid' =>$task->getPID()
|
|
||||||
, 'crashed'=>$task->getCrashCounter()
|
|
||||||
, 'completed'=>$task->getCompletedPercentage()
|
|
||||||
, 'status'=>$task->getState()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(1)
|
foreach ($task_manager->getTasks(true) as $task) {
|
||||||
{
|
if ($task->getState() == task_abstract::STATE_TOSTOP && $task->getPID() === NULL) {
|
||||||
$sql = 'SHOW PROCESSLIST';
|
// fix
|
||||||
$stmt = $appbox->get_connection()->prepare($sql);
|
$task->setState(task_abstract::STATE_STOPPED);
|
||||||
$stmt->execute();
|
}
|
||||||
$rows = $stmt->fetchALL(PDO::FETCH_ASSOC);
|
$id = $task->getID();
|
||||||
$stmt->closeCursor();
|
$ret['tasks'][$id] = array(
|
||||||
$ret['db_processlist'] = array();
|
'id' => $id
|
||||||
foreach($rows as $row)
|
, 'pid' => $task->getPID()
|
||||||
{
|
, 'crashed' => $task->getCrashCounter()
|
||||||
if($row['Info'] != $sql)
|
, 'completed' => $task->getCompletedPercentage()
|
||||||
$ret['db_processlist'][] = $row;
|
, 'status' => $task->getState()
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = p4string::jsonencode($ret);
|
if (1) {
|
||||||
break;
|
$sql = 'SHOW PROCESSLIST';
|
||||||
|
$stmt = $appbox->get_connection()->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
$rows = $stmt->fetchALL(PDO::FETCH_ASSOC);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
$ret['db_processlist'] = array();
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
if ($row['Info'] != $sql)
|
||||||
|
$ret['db_processlist'][] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case 'UNMOUNTBASE':
|
$output = p4string::jsonencode($ret);
|
||||||
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
|
break;
|
||||||
$ret = array('sbas_id' => null);
|
|
||||||
|
|
||||||
$databox = databox::get_instance((int) $parm['sbas_id']);
|
case 'UNMOUNTBASE':
|
||||||
$databox->unmount_databox($appbox);
|
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
|
||||||
|
$ret = array('sbas_id' => null);
|
||||||
|
|
||||||
$ret['sbas_id'] = $parm['sbas_id'];
|
$databox = databox::get_instance((int) $parm['sbas_id']);
|
||||||
$output = p4string::jsonencode($ret);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'P_BAR_INFO':
|
|
||||||
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
|
|
||||||
$ret = array(
|
|
||||||
'sbas_id' => null,
|
|
||||||
'indexable' => false,
|
|
||||||
'records' => 0,
|
|
||||||
'xml_indexed' => 0,
|
|
||||||
'thesaurus_indexed' => 0,
|
|
||||||
'viewname' => null,
|
|
||||||
'printLogoURL' => NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
$databox = databox::get_instance((int) $parm['sbas_id']);
|
|
||||||
|
|
||||||
$ret['indexable'] = $appbox->is_databox_indexable($databox);
|
|
||||||
$ret['viewname'] = (($databox->get_dbname() == $databox->get_viewname()) ? _('admin::base: aucun alias') : $databox->get_viewname());
|
|
||||||
|
|
||||||
$ret['records'] = $databox->get_record_amount();
|
|
||||||
|
|
||||||
$datas = $databox->get_indexed_record_amount();
|
|
||||||
|
|
||||||
$ret['sbas_id'] = $parm['sbas_id'];
|
|
||||||
$tot = $idxxml = $idxth = 0;
|
|
||||||
|
|
||||||
$ret['xml_indexed'] = $datas['xml_indexed'];
|
|
||||||
$ret['thesaurus_indexed'] = $datas['thesaurus_indexed'];
|
|
||||||
|
|
||||||
if (file_exists($registry->get('GV_RootPath') . 'config/minilogos/logopdf_' . $parm['sbas_id'] . '.jpg'))
|
|
||||||
$ret['printLogoURL'] = '/print/' . $parm['sbas_id'];
|
|
||||||
$output = p4string::jsonencode($ret);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'CHGVIEWNAME':
|
|
||||||
|
|
||||||
$parm = $request->get_parms('sbas_id', 'viewname');
|
|
||||||
$ret = array('sbas_id' => null, 'viewname' => null);
|
|
||||||
$sbas_id = (int) $parm['sbas_id'];
|
|
||||||
$databox = databox::get_instance($sbas_id);
|
|
||||||
$appbox->set_databox_viewname($databox, $parm['viewname']);
|
|
||||||
$output = p4string::jsonencode($ret);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'MAKEINDEXABLE':
|
|
||||||
|
|
||||||
$parm = $request->get_parms('sbas_id', 'INDEXABLE');
|
|
||||||
$ret = array('sbas_id' => null, 'indexable' => null);
|
|
||||||
$sbas_id = (int) $parm['sbas_id'];
|
|
||||||
$databox = databox::get_instance($sbas_id);
|
|
||||||
$appbox->set_databox_indexable($databox, $parm['INDEXABLE']);
|
|
||||||
$ret['sbas_id'] = $parm['sbas_id'];
|
|
||||||
$ret['indexable'] = $parm['INDEXABLE'];
|
|
||||||
$output = p4string::jsonencode($ret);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'REINDEX':
|
|
||||||
|
|
||||||
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
|
|
||||||
$ret = array('sbas_id' => null);
|
|
||||||
$sbas_id = (int) $parm['sbas_id'];
|
|
||||||
$databox = databox::get_instance($sbas_id);
|
|
||||||
$databox->reindex();
|
|
||||||
$output = p4string::jsonencode($ret);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'CLEARALLLOG':
|
|
||||||
|
|
||||||
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
|
|
||||||
$ret = array('sbas_id' => null);
|
|
||||||
$sbas_id = (int) $parm['sbas_id'];
|
|
||||||
$databox = databox::get_instance($sbas_id);
|
|
||||||
$databox->clear_logs();
|
|
||||||
$ret['sbas_id'] = $parm['sbas_id'];
|
|
||||||
$output = p4string::jsonencode($ret);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'DELLOGOPDF':
|
|
||||||
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
|
|
||||||
$ret = array('sbas_id' => null);
|
|
||||||
$sbas_id = (int) $parm['sbas_id'];
|
|
||||||
$databox = databox::get_instance($sbas_id);
|
|
||||||
$appbox->write_databox_pic($databox, null, databox::PIC_PDF);
|
|
||||||
$ret['sbas_id'] = $parm['sbas_id'];
|
|
||||||
|
|
||||||
$output = p4string::jsonencode($ret);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'DELETEBASE':
|
|
||||||
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
|
|
||||||
|
|
||||||
$ret = array('sbas_id' => null, 'err' => -1, 'errmsg' => null);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$sbas_id = (int) $parm['sbas_id'];
|
|
||||||
$databox = databox::get_instance($sbas_id);
|
|
||||||
if ($databox->get_record_amount() == 0)
|
|
||||||
{
|
|
||||||
$databox->unmount_databox($appbox);
|
$databox->unmount_databox($appbox);
|
||||||
$appbox->write_databox_pic($databox, null, databox::PIC_PDF);
|
|
||||||
$databox->delete();
|
|
||||||
$ret['sbas_id'] = $parm['sbas_id'];
|
$ret['sbas_id'] = $parm['sbas_id'];
|
||||||
$ret['err'] = 0;
|
$output = p4string::jsonencode($ret);
|
||||||
}
|
break;
|
||||||
else
|
|
||||||
{
|
case 'P_BAR_INFO':
|
||||||
$ret['errmsg'] = _('admin::base: vider la base avant de la supprimer');
|
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
|
||||||
}
|
$ret = array(
|
||||||
}
|
'sbas_id' => null,
|
||||||
catch (Exception $e)
|
'indexable' => false,
|
||||||
{
|
'records' => 0,
|
||||||
$ret['errmsg'] = $e->getMessage();
|
'xml_indexed' => 0,
|
||||||
}
|
'thesaurus_indexed' => 0,
|
||||||
$output = p4string::jsonencode($ret);
|
'viewname' => null,
|
||||||
break;
|
'printLogoURL' => NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
$databox = databox::get_instance((int) $parm['sbas_id']);
|
||||||
|
|
||||||
|
$ret['indexable'] = $appbox->is_databox_indexable($databox);
|
||||||
|
$ret['viewname'] = (($databox->get_dbname() == $databox->get_viewname()) ? _('admin::base: aucun alias') : $databox->get_viewname());
|
||||||
|
|
||||||
|
$ret['records'] = $databox->get_record_amount();
|
||||||
|
|
||||||
|
$datas = $databox->get_indexed_record_amount();
|
||||||
|
|
||||||
|
$ret['sbas_id'] = $parm['sbas_id'];
|
||||||
|
$tot = $idxxml = $idxth = 0;
|
||||||
|
|
||||||
|
$ret['xml_indexed'] = $datas['xml_indexed'];
|
||||||
|
$ret['thesaurus_indexed'] = $datas['thesaurus_indexed'];
|
||||||
|
|
||||||
|
if (file_exists($registry->get('GV_RootPath') . 'config/minilogos/logopdf_' . $parm['sbas_id'] . '.jpg'))
|
||||||
|
$ret['printLogoURL'] = '/print/' . $parm['sbas_id'];
|
||||||
|
$output = p4string::jsonencode($ret);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'CHGVIEWNAME':
|
||||||
|
|
||||||
|
$parm = $request->get_parms('sbas_id', 'viewname');
|
||||||
|
$ret = array('sbas_id' => null, 'viewname' => null);
|
||||||
|
$sbas_id = (int) $parm['sbas_id'];
|
||||||
|
$databox = databox::get_instance($sbas_id);
|
||||||
|
$appbox->set_databox_viewname($databox, $parm['viewname']);
|
||||||
|
$output = p4string::jsonencode($ret);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'MAKEINDEXABLE':
|
||||||
|
|
||||||
|
$parm = $request->get_parms('sbas_id', 'INDEXABLE');
|
||||||
|
$ret = array('sbas_id' => null, 'indexable' => null);
|
||||||
|
$sbas_id = (int) $parm['sbas_id'];
|
||||||
|
$databox = databox::get_instance($sbas_id);
|
||||||
|
$appbox->set_databox_indexable($databox, $parm['INDEXABLE']);
|
||||||
|
$ret['sbas_id'] = $parm['sbas_id'];
|
||||||
|
$ret['indexable'] = $parm['INDEXABLE'];
|
||||||
|
$output = p4string::jsonencode($ret);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'REINDEX':
|
||||||
|
|
||||||
|
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
|
||||||
|
$ret = array('sbas_id' => null);
|
||||||
|
$sbas_id = (int) $parm['sbas_id'];
|
||||||
|
$databox = databox::get_instance($sbas_id);
|
||||||
|
$databox->reindex();
|
||||||
|
$output = p4string::jsonencode($ret);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'CLEARALLLOG':
|
||||||
|
|
||||||
|
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
|
||||||
|
$ret = array('sbas_id' => null);
|
||||||
|
$sbas_id = (int) $parm['sbas_id'];
|
||||||
|
$databox = databox::get_instance($sbas_id);
|
||||||
|
$databox->clear_logs();
|
||||||
|
$ret['sbas_id'] = $parm['sbas_id'];
|
||||||
|
$output = p4string::jsonencode($ret);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'DELLOGOPDF':
|
||||||
|
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
|
||||||
|
$ret = array('sbas_id' => null);
|
||||||
|
$sbas_id = (int) $parm['sbas_id'];
|
||||||
|
$databox = databox::get_instance($sbas_id);
|
||||||
|
$appbox->write_databox_pic($databox, null, databox::PIC_PDF);
|
||||||
|
$ret['sbas_id'] = $parm['sbas_id'];
|
||||||
|
|
||||||
|
$output = p4string::jsonencode($ret);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'DELETEBASE':
|
||||||
|
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
|
||||||
|
|
||||||
|
$ret = array('sbas_id' => null, 'err' => -1, 'errmsg' => null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$sbas_id = (int) $parm['sbas_id'];
|
||||||
|
$databox = databox::get_instance($sbas_id);
|
||||||
|
if ($databox->get_record_amount() == 0) {
|
||||||
|
$databox->unmount_databox($appbox);
|
||||||
|
$appbox->write_databox_pic($databox, null, databox::PIC_PDF);
|
||||||
|
$databox->delete();
|
||||||
|
$ret['sbas_id'] = $parm['sbas_id'];
|
||||||
|
$ret['err'] = 0;
|
||||||
|
} else {
|
||||||
|
$ret['errmsg'] = _('admin::base: vider la base avant de la supprimer');
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$ret['errmsg'] = $e->getMessage();
|
||||||
|
}
|
||||||
|
$output = p4string::jsonencode($ret);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($appbox);
|
unset($appbox);
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of Phraseanet
|
* This file is part of Phraseanet
|
||||||
*
|
*
|
||||||
* (c) 2005-2010 Alchemy
|
* (c) 2005-2012 Alchemy
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
@@ -347,8 +346,6 @@ foreach ($tasks as $t) {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
||||||
<?php ?>
|
|
||||||
<iframe id="zsched" src="about:blank" style="position:absolute; top:0px; left:0px; width:50px; height:50px; visibility:hidden"></iframe>
|
<iframe id="zsched" src="about:blank" style="position:absolute; top:0px; left:0px; width:50px; height:50px; visibility:hidden"></iframe>
|
||||||
|
|
||||||
<h1><?php echo _('admin::tasks: planificateur de taches') ?>
|
<h1><?php echo _('admin::tasks: planificateur de taches') ?>
|
||||||
@@ -422,11 +419,7 @@ foreach ($tasks as $t) {
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div id="db_processlist"></div>
|
<div id="db_processlist"></div>
|
||||||
<!--
|
|
||||||
<a id="newTaskButton" href="#"><?php echo _('admin::tasks: Nouvelle tache') ?></a>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<?php ?>
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
function editTask(tid)
|
function editTask(tid)
|
||||||
|
@@ -124,21 +124,21 @@ try {
|
|||||||
$status_2 = databox_status::operation_and($mask_oui, $mask_non);
|
$status_2 = databox_status::operation_and($mask_oui, $mask_non);
|
||||||
if ( ! $filename->is_new_in_base(phrasea::sbasFromBas($base_id)) || count($error_file) > 0) {
|
if ( ! $filename->is_new_in_base(phrasea::sbasFromBas($base_id)) || count($error_file) > 0) {
|
||||||
// file already exists in base
|
// file already exists in base
|
||||||
if ( ! lazaretFile::copy_uploaded_to_lazaret($filename, $base_id, $_FILES['Filedata']["name"], implode("\n", $error_file), $status_2)) {
|
if ( ! lazaretFile::move_uploaded_to_lazaret($filename, $base_id, $_FILES['Filedata']["name"], implode("\n", $error_file), $status_2)) {
|
||||||
// copy in lazaret failed
|
// move in lazaret failed
|
||||||
if (UPLOADER == 'FLASH')
|
if (UPLOADER == 'FLASH')
|
||||||
header('HTTP/1.1 500 Internal Server Error');
|
header('HTTP/1.1 500 Internal Server Error');
|
||||||
else
|
else
|
||||||
echo '<script type="text/javascript">parent.classic_uploaded("' . _("erreur lors de l'archivage") . '")</script>';
|
echo '<script type="text/javascript">parent.classic_uploaded("' . _("erreur lors de l'archivage") . '")</script>';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// copy in lazaret succeed
|
// move in lazaret succeed
|
||||||
if (UPLOADER == 'HTML')
|
if (UPLOADER == 'HTML')
|
||||||
echo '<script type="text/javascript">parent.classic_uploaded("' . _('Document ajoute a la quarantaine') . '")</script>';
|
echo '<script type="text/javascript">parent.classic_uploaded("' . _('Document ajoute a la quarantaine') . '")</script>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (UPLOADER == 'HTML')
|
if (UPLOADER == 'HTML')
|
||||||
// echo '<script type="text/javascript">parent.classic_uploaded("' . _("Fichier uploade, en attente") . '")</script>';
|
echo '<script type="text/javascript">parent.classic_uploaded("' . _("Fichier uploade, en attente") . '")</script>';
|
||||||
|
|
||||||
unset($filename);
|
unset($filename);
|
||||||
unlink($_FILES['Filedata']['tmp_name']);
|
unlink($_FILES['Filedata']['tmp_name']);
|
||||||
|
Reference in New Issue
Block a user