many comments of last pull request applied

This commit is contained in:
jygaulier
2012-05-10 14:15:47 +02:00
parent 00df363964
commit 37adb06965
22 changed files with 686 additions and 837 deletions

View File

@@ -15,7 +15,6 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
use Symfony\Component\HttpFoundation\Request;
use Silex\Application;
@@ -95,12 +94,12 @@ class API_V1_adapter extends API_V1_Abstract
return $this->version;
}
/**
* Get a list of phraseanet tasks
*
* @param \Silex\Application $app The API silex application
* @return \API_V1_result
*/
/**
* Get a list of phraseanet tasks
*
* @param \Silex\Application $app The API silex application
* @return \API_V1_result
*/
public function get_task_list(Application $app)
{
$result = new \API_V1_result($app['request'], $this);
@@ -112,10 +111,10 @@ class API_V1_adapter extends API_V1_Abstract
$ret = array();
foreach ($tasks as $task) {
$ret[$task->getID()] = array(
'id' => $task->getID(),
'state' => $task->getState(),
'pid' => $task->getPID(),
'title' => $task->getTitle(),
'id' => $task->getID(),
'state' => $task->getState(),
'pid' => $task->getPID(),
'title' => $task->getTitle(),
'last_exec_time' => $task->getLastExecTime()
);
}
@@ -177,7 +176,7 @@ class API_V1_adapter extends API_V1_Abstract
$ret = array('success' => true);
try {
$task = $taskManager->getTask($taskId);
$task->setState(\task_abstract::STATUS_TOSTART);
$task->setState(\task_abstract::STATE_TOSTART);
} catch (\Exception_NotFound $e) {
$result->set_error_code(404);
$ret = array('success' => false);
@@ -209,7 +208,7 @@ class API_V1_adapter extends API_V1_Abstract
$ret = array();
try {
$task = $taskManager->getTask($taskId);
$task->setState(\task_abstract::STATUS_TOSTOP);
$task->setState(\task_abstract::STATE_TOSTOP);
} catch (\Exception_NotFound $e) {
$result->set_error_code(404);
$ret = array('success' => false);
@@ -279,12 +278,12 @@ class API_V1_adapter extends API_V1_Abstract
return $result;
}
/**
* Get Information the cache system used by the instance
*
* @param \Silex\Application $app the silex application
* @return array
*/
/**
* Get Information the cache system used by the instance
*
* @param \Silex\Application $app the silex application
* @return array
*/
protected function get_cache_info(Application $app)
{
$mainCache = $app['Core']['Cache'];
@@ -294,7 +293,7 @@ class API_V1_adapter extends API_V1_Abstract
if ($mainCache instanceof \Alchemy\Phrasea\Cache\Cache) {
$ret['cache']['main'] = array(
'type' => $mainCache->getName(),
'type' => $mainCache->getName(),
'stats' => $mainCache->getStats()
);
} else {
@@ -303,7 +302,7 @@ class API_V1_adapter extends API_V1_Abstract
if ($opCodeCache instanceof \Alchemy\Phrasea\Cache\Cache) {
$ret['cache']['op_code'] = array(
'type' => $mainCache->getName(),
'type' => $mainCache->getName(),
'stats' => $opCodeCache->getStats()
);
} else {
@@ -324,7 +323,7 @@ class API_V1_adapter extends API_V1_Abstract
$ret = array();
$ret['phraseanet']['version'] = array(
'name' => $app['Core']['Version']::getName(),
'name' => $app['Core']['Version']::getName(),
'number' => $app['Core']['Version']::getNumber(),
);
@@ -350,158 +349,158 @@ class API_V1_adapter extends API_V1_Abstract
return array(
'global_values' => array(
'serverName' => $registry->get('GV_ServerName'),
'title' => $registry->get('GV_homeTitle'),
'keywords' => $registry->get('GV_metaKeywords'),
'serverName' => $registry->get('GV_ServerName'),
'title' => $registry->get('GV_homeTitle'),
'keywords' => $registry->get('GV_metaKeywords'),
'description' => $registry->get('GV_metaDescription'),
'httpServer' => array(
'logErrors' => $registry->get('GV_log_errors'),
'phpTimezone' => $registry->get('GV_timezone'),
'siteId' => $registry->get('GV_sit'),
'staticUrl' => $registry->get('GV_STATIC_URL'),
'httpServer' => array(
'logErrors' => $registry->get('GV_log_errors'),
'phpTimezone' => $registry->get('GV_timezone'),
'siteId' => $registry->get('GV_sit'),
'staticUrl' => $registry->get('GV_STATIC_URL'),
'defaultLanguage' => $registry->get('id_GV_default_lng'),
'allowIndexing' => $registry->get('GV_allow_search_engine'),
'modes' => array(
'XsendFile' => $registry->get('GV_modxsendfile'),
'nginxXAccelRedirect' => $registry->get('GV_X_Accel_Redirect'),
'allowIndexing' => $registry->get('GV_allow_search_engine'),
'modes' => array(
'XsendFile' => $registry->get('GV_modxsendfile'),
'nginxXAccelRedirect' => $registry->get('GV_X_Accel_Redirect'),
'nginxXAccelRedirectMountPoint' => $registry->get('GV_X_Accel_Redirect_mount_point'),
'h264Streaming' => $registry->get('GV_h264_streaming'),
'authTokenDirectory' => $registry->get('GV_mod_auth_token_directory'),
'authTokenDirectoryPath' => $registry->get('GV_mod_auth_token_directory_path'),
'authTokenPassphrase' => $registry->get('GV_mod_auth_token_passphrase'),
'h264Streaming' => $registry->get('GV_h264_streaming'),
'authTokenDirectory' => $registry->get('GV_mod_auth_token_directory'),
'authTokenDirectoryPath' => $registry->get('GV_mod_auth_token_directory_path'),
'authTokenPassphrase' => $registry->get('GV_mod_auth_token_passphrase'),
),
'files' => array(
'owner' => $registry->get('GV_filesOwner'),
'group' => $registry->get('GV_filesOwner'),
'files' => array(
'owner' => $registry->get('GV_filesOwner'),
'group' => $registry->get('GV_filesOwner'),
)
),
'maintenance' => array(
'alertMessage' => $registry->get('GV_message'),
'alertMessage' => $registry->get('GV_message'),
'displayMessage' => $registry->get('GV_message_on'),
),
'webServices' => array(
'googleApi' => $registry->get('GV_google_api'),
'googleAnalyticsId' => $registry->get('GV_googleAnalytics'),
'webServices' => array(
'googleApi' => $registry->get('GV_google_api'),
'googleAnalyticsId' => $registry->get('GV_googleAnalytics'),
'googleChromeFrameDisclaimer' => $registry->get('GV_display_gcf'),
'i18nWebService' => $registry->get('GV_i18n_service'),
'recaptacha' => array(
'active' => $registry->get('GV_captchas'),
'publicKey' => $registry->get('GV_captcha_public_key'),
'i18nWebService' => $registry->get('GV_i18n_service'),
'recaptacha' => array(
'active' => $registry->get('GV_captchas'),
'publicKey' => $registry->get('GV_captcha_public_key'),
'privateKey' => $registry->get('GV_captcha_private_key'),
),
'youtube' => array(
'active' => $registry->get('GV_youtube_api'),
'clientId' => $registry->get('GV_youtube_client_id'),
'youtube' => array(
'active' => $registry->get('GV_youtube_api'),
'clientId' => $registry->get('GV_youtube_client_id'),
'clientSecret' => $registry->get('GV_youtube_client_secret'),
'devKey' => $registry->get('GV_youtube_dev_key'),
'devKey' => $registry->get('GV_youtube_dev_key'),
),
'flickr' => array(
'active' => $registry->get('GV_flickr_api'),
'clientId' => $registry->get('GV_flickr_client_id'),
'flickr' => array(
'active' => $registry->get('GV_flickr_api'),
'clientId' => $registry->get('GV_flickr_client_id'),
'clientSecret' => $registry->get('GV_flickr_client_secret'),
),
'dailymtotion' => array(
'active' => $registry->get('GV_dailymotion_api'),
'clientId' => $registry->get('GV_dailymotion_client_id'),
'active' => $registry->get('GV_dailymotion_api'),
'clientId' => $registry->get('GV_dailymotion_client_id'),
'clientSecret' => $registry->get('GV_dailymotion_client_secret'),
)
),
'navigator' => array(
'active' => $registry->get('GV_client_navigator'),
'navigator' => array(
'active' => $registry->get('GV_client_navigator'),
),
'homepage' => array(
'viewType' => $registry->get('GV_home_publi'),
),
'report' => array(
'report' => array(
'anonymous' => $registry->get('GV_anonymousReport'),
),
'events' => array(
'events' => $registry->get('GV_events'),
'events' => array(
'events' => $registry->get('GV_events'),
'notifications' => $registry->get('GV_notifications'),
),
'upload' => array(
'upload' => array(
'allowedFileExtension' => $registry->get('GV_appletAllowedFileEx'),
),
'filesystem' => array(
'web' => $registry->get('GV_base_datapath_web'),
'noWeb' => $registry->get('GV_base_datapath_noweb'),
'thumbnail' => $registry->get('GV_base_dataurl'),
'filesystem' => array(
'web' => $registry->get('GV_base_datapath_web'),
'noWeb' => $registry->get('GV_base_datapath_noweb'),
'thumbnail' => $registry->get('GV_base_dataurl'),
),
'searchEngine' => array(
'configuration' => array(
'defaultQuery' => $registry->get('GV_defaultQuery'),
'defaultQuery' => $registry->get('GV_defaultQuery'),
'defaultQueryType' => $registry->get('GV_defaultQuery_type'),
),
'sphinx' => array(
'active' => $registry->get('GV_sphinx'),
'host' => $registry->get('GV_sphinx_host'),
'port' => $registry->get('GV_sphinx_port'),
'sphinx' => array(
'active' => $registry->get('GV_sphinx'),
'host' => $registry->get('GV_sphinx_host'),
'port' => $registry->get('GV_sphinx_port'),
'realtimeHost' => $registry->get('GV_sphinx_rt_host'),
'realtimePort' => $registry->get('GV_sphinx_rt_port'),
),
'phrasea' => array(
'phrasea' => array(
'minChar' => $registry->get('GV_min_letters_truncation'),
'sort' => $registry->get('GV_phrasea_sort'),
'sort' => $registry->get('GV_phrasea_sort'),
),
),
'binary' => array(
'phpCli' => $registry->get('GV_cli'),
'phpIni' => $registry->get('GV_PHP_INI'),
'imagick' => $registry->get('GV_imagick'),
'swfExtract' => $registry->get('GV_swf_extract'),
'pdf2swf' => $registry->get('GV_pdf2swf'),
'swfRender' => $registry->get('GV_swf_render'),
'unoconv' => $registry->get('GV_unoconv'),
'ffmpeg' => $registry->get('GV_ffmpeg'),
'mp4box' => $registry->get('GV_mp4box'),
'pdftotext' => $registry->get('GV_pdftotext'),
'pdfmaxpages' => $registry->get('GV_pdfmaxpages'),),
'binary' => array(
'phpCli' => $registry->get('GV_cli'),
'phpIni' => $registry->get('GV_PHP_INI'),
'imagick' => $registry->get('GV_imagick'),
'swfExtract' => $registry->get('GV_swf_extract'),
'pdf2swf' => $registry->get('GV_pdf2swf'),
'swfRender' => $registry->get('GV_swf_render'),
'unoconv' => $registry->get('GV_unoconv'),
'ffmpeg' => $registry->get('GV_ffmpeg'),
'mp4box' => $registry->get('GV_mp4box'),
'pdftotext' => $registry->get('GV_pdftotext'),
'pdfmaxpages' => $registry->get('GV_pdfmaxpages'),),
'mainConfiguration' => array(
'adminMail' => $registry->get('GV_adminMail'),
'adminMail' => $registry->get('GV_adminMail'),
'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'),
'socialTools' => $registry->get('GV_social_tools'),),
'modules' => array(
'thesaurus' => $registry->get('GV_thesaurus'),
'storyMode' => $registry->get('GV_multiAndReport'),
'docSubsitution' => $registry->get('GV_seeOngChgDoc'),
'socialTools' => $registry->get('GV_social_tools'),),
'modules' => array(
'thesaurus' => $registry->get('GV_thesaurus'),
'storyMode' => $registry->get('GV_multiAndReport'),
'docSubsitution' => $registry->get('GV_seeOngChgDoc'),
'subdefSubstitution' => $registry->get('GV_seeNewThumb'),),
'email' => array(
'email' => array(
'defaultMailAddress' => $registry->get('GV_defaulmailsenderaddr'),
'smtp' => array(
'active' => $registry->get('GV_smtp'),
'auth' => $registry->get('GV_smtp_auth'),
'host' => $registry->get('GV_smtp_host'),
'port' => $registry->get('GV_smtp_port'),
'secure' => $registry->get('GV_smtp_secure'),
'user' => $registry->get('GV_smtp_user'),
'smtp' => array(
'active' => $registry->get('GV_smtp'),
'auth' => $registry->get('GV_smtp_auth'),
'host' => $registry->get('GV_smtp_host'),
'port' => $registry->get('GV_smtp_port'),
'secure' => $registry->get('GV_smtp_secure'),
'user' => $registry->get('GV_smtp_user'),
'password' => $registry->get('GV_smtp_password'),
),
),
'ftp' => array(
'active' => $registry->get('GV_activeFTP'),
'ftp' => array(
'active' => $registry->get('GV_activeFTP'),
'activeForUser' => $registry->get('GV_ftp_for_user'),),
'client' => array(
'maxSizeDownload' => $registry->get('GV_download_max'),
'tabSearchMode' => $registry->get('GV_ong_search'),
'tabAdvSearchPosition' => $registry->get('GV_ong_advsearch'),
'tabTopicsPosition' => $registry->get('GV_ong_topics'),
'tabOngActifPosition' => $registry->get('GV_ong_actif'),
'renderTopicsMode' => $registry->get('GV_client_render_topics'),
'displayRolloverPreview' => $registry->get('GV_rollover_reg_preview'),
'displayRolloverBasket' => $registry->get('GV_rollover_chu'),
'collRenderMode' => $registry->get('GV_client_coll_ckbox'),
'viewSizeBaket' => $registry->get('GV_viewSizeBaket'),
'client' => array(
'maxSizeDownload' => $registry->get('GV_download_max'),
'tabSearchMode' => $registry->get('GV_ong_search'),
'tabAdvSearchPosition' => $registry->get('GV_ong_advsearch'),
'tabTopicsPosition' => $registry->get('GV_ong_topics'),
'tabOngActifPosition' => $registry->get('GV_ong_actif'),
'renderTopicsMode' => $registry->get('GV_client_render_topics'),
'displayRolloverPreview' => $registry->get('GV_rollover_reg_preview'),
'displayRolloverBasket' => $registry->get('GV_rollover_chu'),
'collRenderMode' => $registry->get('GV_client_coll_ckbox'),
'viewSizeBaket' => $registry->get('GV_viewSizeBaket'),
'clientAutoShowProposals' => $registry->get('GV_clientAutoShowProposals'),
'needAuth2DL' => $registry->get('GV_needAuth2DL'),),
'inscription' => array(
'needAuth2DL' => $registry->get('GV_needAuth2DL'),),
'inscription' => array(
'autoSelectDB' => $registry->get('GV_autoselectDB'),
'autoRegister' => $registry->get('GV_autoregister'),
),
'push' => array(
'push' => array(
'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) {
$ret[$field->get_meta_struct_id()] = array(
'meta_structure_id' => $field->get_meta_struct_id(),
'name' => $field->get_name(),
'value' => $field->get_serialized_values(";"),
'name' => $field->get_name(),
'value' => $field->get_serialized_values(";"),
);
}
$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(),
'bases' => is_array($request->get('bases')) ? $request->get('bases') : array(),
'search_type' => $search_type,
'recordtype' => $record_type,
'datemin' => $request->get('datemin') ? : '',
'datemax' => $request->get('datemax') ? : '',
'datefield' => $request->get('datefield') ? : '',
'sort' => $request->get('sort') ? : '',
'ord' => $request->get('ord') ? : '',
'stemme' => $request->get('stemme') ? : '',
'per_page' => $request->get('per_page') ? : 10,
'query' => $request->get('query') ? : '',
'page' => (int) ($request->get('page') ? : 0),
'recordtype' => $record_type,
'datemin' => $request->get('datemin') ? : '',
'datemax' => $request->get('datemax') ? : '',
'datefield' => $request->get('datefield') ? : '',
'sort' => $request->get('sort') ? : '',
'ord' => $request->get('ord') ? : '',
'stemme' => $request->get('stemme') ? : '',
'per_page' => $request->get('per_page') ? : 10,
'query' => $request->get('query') ? : '',
'page' => (int) ($request->get('page') ? : 0),
);
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);
$ret = array(
'total_pages' => $search_result->get_total_pages(),
'current_page' => $search_result->get_current_page(),
'total_pages' => $search_result->get_total_pages(),
'current_page' => $search_result->get_current_page(),
'available_results' => $search_result->get_count_available_results(),
'total_results' => $search_result->get_count_total_results(),
'error' => $search_result->get_error(),
'warning' => $search_result->get_warning(),
'query_time' => $search_result->get_query_time(),
'search_indexes' => $search_result->get_search_indexes(),
'suggestions' => $search_result->get_suggestions(),
'results' => array(),
'total_results' => $search_result->get_count_total_results(),
'error' => $search_result->get_error(),
'warning' => $search_result->get_warning(),
'query_time' => $search_result->get_query_time(),
'search_indexes' => $search_result->get_search_indexes(),
'suggestions' => $search_result->get_suggestions(),
'results' => array(),
'query' => $search_engine->get_query(),
);
@@ -1179,9 +1178,9 @@ class API_V1_adapter extends API_V1_Abstract
{
$ret = array(
'basket_element_id' => $basket_element->getId(),
'order' => $basket_element->getOrd(),
'record' => $this->list_record($basket_element->getRecord()),
'validation_item' => ! ! $basket_element->getValidationDatas(),
'order' => $basket_element->getOrd(),
'record' => $this->list_record($basket_element->getRecord()),
'validation_item' => ! ! $basket_element->getValidationDatas(),
);
if ($basket_element->getValidationDatas()) {
@@ -1192,12 +1191,12 @@ class API_V1_adapter extends API_V1_Abstract
$user = $validation_datas->getParticipant()->getUser();
/* @var $validation_datas Entities\ValidationData */
$choices[$user->get_id()] = array(
'usr_id' => $user->get_id(),
'usr_name' => $user->get_display_name(),
'is_mine' => $user->get_id() == $this->core->getAuthenticatedUser()->get_id(),
'agreement' => $validation_datas->getAgreement(),
'usr_id' => $user->get_id(),
'usr_name' => $user->get_display_name(),
'is_mine' => $user->get_id() == $this->core->getAuthenticatedUser()->get_id(),
'agreement' => $validation_datas->getAgreement(),
'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()) {
@@ -1340,10 +1339,10 @@ class API_V1_adapter extends API_V1_Abstract
$per_page = (($per_page >= 1) && ($per_page <= 20)) ? $per_page : 5;
$datas = array(
'feed' => $this->list_publication($feed, $user),
'feed' => $this->list_publication($feed, $user),
'offset_start' => $offset_start,
'per_page' => $per_page,
'entries' => $this->list_publications_entries($feed, $offset_start, $per_page),
'per_page' => $per_page,
'entries' => $this->list_publications_entries($feed, $offset_start, $per_page),
);
$result->set_datas($datas);
@@ -1361,15 +1360,15 @@ class API_V1_adapter extends API_V1_Abstract
protected function list_publication(Feed_Adapter $feed, $user)
{
return array(
'id' => $feed->get_id(),
'title' => $feed->get_title(),
'subtitle' => $feed->get_subtitle(),
'id' => $feed->get_id(),
'title' => $feed->get_title(),
'subtitle' => $feed->get_subtitle(),
'total_entries' => $feed->get_count_total_entries(),
'icon' => $feed->get_icon_url(),
'public' => $feed->is_public(),
'is_mine' => $feed->is_owner($user),
'created_on' => $feed->get_created_on()->format(DATE_ATOM),
'updated_on' => $feed->get_updated_on()->format(DATE_ATOM),
'icon' => $feed->get_icon_url(),
'public' => $feed->is_public(),
'is_mine' => $feed->is_owner($user),
'created_on' => $feed->get_created_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(
'offset_start' => $offset_start
, 'entries' => $out
, 'entries' => $out
);
}
@@ -1412,12 +1411,12 @@ class API_V1_adapter extends API_V1_Abstract
return array(
'author_email' => $entry->get_author_email(),
'author_name' => $entry->get_author_name(),
'created_on' => $entry->get_created_on()->format(DATE_ATOM),
'updated_on' => $entry->get_updated_on()->format(DATE_ATOM),
'title' => $entry->get_title(),
'subtitle' => $entry->get_subtitle(),
'items' => $items,
'author_name' => $entry->get_author_name(),
'created_on' => $entry->get_created_on()->format(DATE_ATOM),
'updated_on' => $entry->get_updated_on()->format(DATE_ATOM),
'title' => $entry->get_title(),
'subtitle' => $entry->get_subtitle(),
'items' => $items,
);
}
@@ -1431,7 +1430,7 @@ class API_V1_adapter extends API_V1_Abstract
{
$datas = array(
'item_id' => $item->get_id()
, 'record' => $this->list_record($item->get_record())
, 'record' => $this->list_record($item->get_record())
);
return $datas;
@@ -1479,13 +1478,13 @@ class API_V1_adapter extends API_V1_Abstract
$permalink = null;
return array(
'permalink' => $permalink,
'height' => $media->get_height(),
'width' => $media->get_width(),
'filesize' => $media->get_size(),
'devices' => $media->getDevices(),
'permalink' => $permalink,
'height' => $media->get_height(),
'width' => $media->get_width(),
'filesize' => $media->get_size(),
'devices' => $media->getDevices(),
'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)
{
return array(
'created_on' => $permalink->get_created_on()->format(DATE_ATOM),
'id' => $permalink->get_id(),
'is_activated' => $permalink->get_is_activated(),
'label' => $permalink->get_label(),
'created_on' => $permalink->get_created_on()->format(DATE_ATOM),
'id' => $permalink->get_id(),
'is_activated' => $permalink->get_is_activated(),
'label' => $permalink->get_label(),
'last_modified' => $permalink->get_last_modified()->format(DATE_ATOM),
'page_url' => $permalink->get_page($registry),
'url' => $permalink->get_url($registry)
'page_url' => $permalink->get_page($registry),
'url' => $permalink->get_url($registry)
);
}
@@ -1521,7 +1520,7 @@ class API_V1_adapter extends API_V1_Abstract
$status = strrev($status);
$ret = array();
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;
@@ -1558,10 +1557,10 @@ class API_V1_adapter extends API_V1_Abstract
* dans un cas multi
*/
return array(
'meta_id' => $value->getId(),
'meta_id' => $value->getId(),
'meta_structure_id' => $field->get_meta_struct_id(),
'name' => $field->get_name(),
'value' => $value->getValue(),
'name' => $field->get_name(),
'value' => $value->getValue(),
);
}
@@ -1574,13 +1573,13 @@ class API_V1_adapter extends API_V1_Abstract
protected function list_basket(\Entities\Basket $basket)
{
$ret = array(
'created_on' => $basket->getCreated()->format(DATE_ATOM),
'description' => (string) $basket->getDescription(),
'name' => $basket->getName(),
'created_on' => $basket->getCreated()->format(DATE_ATOM),
'description' => (string) $basket->getDescription(),
'name' => $basket->getName(),
'pusher_usr_id' => $basket->getPusherId(),
'ssel_id' => $basket->getId(),
'updated_on' => $basket->getUpdated()->format(DATE_ATOM),
'unread' => ! $basket->getIsRead(),
'ssel_id' => $basket->getId(),
'updated_on' => $basket->getUpdated()->format(DATE_ATOM),
'unread' => ! $basket->getIsRead(),
);
if ($basket->getValidation()) {
@@ -1591,10 +1590,10 @@ class API_V1_adapter extends API_V1_Abstract
$user = $participant->getUser();
$users[$user->get_id()] = array(
'usr_id' => $user->get_id(),
'usr_name' => $user->get_display_name(),
'confirmed' => $participant->getIsConfirmed(),
'can_agree' => $participant->getCanAgree(),
'usr_id' => $user->get_id(),
'usr_name' => $user->get_display_name(),
'confirmed' => $participant->getIsConfirmed(),
'can_agree' => $participant->getCanAgree(),
'can_see_others' => $participant->getCanSeeOthers(),
);
}
@@ -1608,11 +1607,11 @@ class API_V1_adapter extends API_V1_Abstract
$ret = array_merge(
array(
'validation_users' => $users,
'validation_end_date' => $expires_on_atom,
'validation_infos' => $basket->getValidation()->getValidationString($user),
'validation_users' => $users,
'validation_end_date' => $expires_on_atom,
'validation_infos' => $basket->getValidation()->getValidationString($user),
'validation_confirmed' => $basket->getValidation()->getParticipant($user)->getIsConfirmed(),
'mine' => $basket->getValidation()->isInitiator($user),
'mine' => $basket->getValidation()->isInitiator($user),
), $ret
);
}
@@ -1629,21 +1628,21 @@ class API_V1_adapter extends API_V1_Abstract
protected function list_record(record_adapter $record)
{
return array(
'databox_id' => $record->get_sbas_id(),
'record_id' => $record->get_record_id(),
'mime_type' => $record->get_mime(),
'title' => $record->get_title(),
'original_name' => $record->get_original_name(),
'last_modification' => $record->get_modification_date()->format(DATE_ATOM),
'created_on' => $record->get_creation_date()->format(DATE_ATOM),
'collection_id' => phrasea::collFromBas($record->get_base_id()),
'sha256' => $record->get_sha256(),
'thumbnail' => $this->list_embedable_media(
'databox_id' => $record->get_sbas_id(),
'record_id' => $record->get_record_id(),
'mime_type' => $record->get_mime(),
'title' => $record->get_title(),
'original_name' => $record->get_original_name(),
'last_modification' => $record->get_modification_date()->format(DATE_ATOM),
'created_on' => $record->get_creation_date()->format(DATE_ATOM),
'collection_id' => phrasea::collFromBas($record->get_base_id()),
'sha256' => $record->get_sha256(),
'thumbnail' => $this->list_embedable_media(
$record->get_thumbnail(), registry::get_instance()
),
'technical_informations' => $record->get_technical_infos(),
'phrasea_type' => $record->get_type(),
'uuid' => $record->get_uuid(),
'phrasea_type' => $record->get_type(),
'uuid' => $record->get_uuid(),
);
}
@@ -1672,7 +1671,7 @@ class API_V1_adapter extends API_V1_Abstract
{
$ret = array();
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;
@@ -1720,9 +1719,9 @@ class API_V1_adapter extends API_V1_Abstract
protected function list_collection(collection $collection)
{
$ret = array(
'base_id' => $collection->get_base_id(),
'coll_id' => $collection->get_coll_id(),
'name' => $collection->get_name(),
'base_id' => $collection->get_base_id(),
'coll_id' => $collection->get_coll_id(),
'name' => $collection->get_name(),
'record_amount' => $collection->get_record_amount(),
);
@@ -1740,13 +1739,13 @@ class API_V1_adapter extends API_V1_Abstract
$ret = array();
foreach ($status as $n => $datas) {
$ret[$n] = array(
'bit' => $n,
'label_on' => $datas['labelon'],
'label_off' => $datas['labeloff'],
'img_on' => $datas['img_on'],
'img_off' => $datas['img_off'],
'bit' => $n,
'label_on' => $datas['labelon'],
'label_off' => $datas['labeloff'],
'img_on' => $datas['img_on'],
'img_off' => $datas['img_off'],
'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)
{
$ret = array(
'id' => $databox_field->get_id(),
'namespace' => $databox_field->get_metadata_namespace(),
'source' => $databox_field->get_metadata_source(),
'tagname' => $databox_field->get_metadata_tagname(),
'name' => $databox_field->get_name(),
'separator' => $databox_field->get_separator(),
'id' => $databox_field->get_id(),
'namespace' => $databox_field->get_metadata_namespace(),
'source' => $databox_field->get_metadata_source(),
'tagname' => $databox_field->get_metadata_tagname(),
'name' => $databox_field->get_name(),
'separator' => $databox_field->get_separator(),
'thesaurus_branch' => $databox_field->get_tbranch(),
'type' => $databox_field->get_type(),
'indexable' => $databox_field->is_indexable(),
'multivalue' => $databox_field->is_multi(),
'readonly' => $databox_field->is_readonly(),
'required' => $databox_field->is_required(),
'type' => $databox_field->get_type(),
'indexable' => $databox_field->is_indexable(),
'multivalue' => $databox_field->is_multi(),
'readonly' => $databox_field->is_readonly(),
'required' => $databox_field->is_required(),
);
return $ret;

View File

@@ -38,7 +38,6 @@ class module_console_schedulerState extends Command
, 'print short result, ie: <info>stopped</info> | <info>started(12345)</info> | <info>stopping</info>'
, NULL
);
// $this->setHelp("");
return $this;
}

View File

@@ -26,7 +26,6 @@ use Symfony\Component\Console\Command\Command;
class module_console_taskrun extends Command
{
private $task;
private $shedulerPID;
public function __construct($name = null)
@@ -125,7 +124,7 @@ class module_console_taskrun extends Command
if (method_exists($this->task, 'signal'))
$this->task->signal('SIGNAL_SCHEDULER_DIED');
else
$this->task->setState(task_abstract::STATUS_TOSTOP);
$this->task->setState(task_abstract::STATE_TOSTOP);
}
@@ -133,4 +132,4 @@ class module_console_taskrun extends Command
}
}
}
}
}

View File

@@ -3,7 +3,7 @@
/*
* 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
* file that was distributed with this source code.
@@ -20,16 +20,12 @@ use Symfony\Component\Console\Output\OutputInterface;
class task_Scheduler
{
const TASKDELAYTOQUIT = 60;
// how to schedule tasks (choose in 'run' method)
const METHOD_FORK = 'METHOD_FORK';
const METHOD_PROC_OPEN = 'METHOD_PROC_OPEN';
const ERR_ALREADY_RUNNING = 114; // aka EALREADY (Operation already in progress)
private $method;
private $input;
protected $output;
protected function log($message)
@@ -47,6 +43,7 @@ class task_Scheduler
if ($this->input && ! ($this->input->getOption('nolog'))) {
file_put_contents($logdir . "scheduler_l.log", $message . "\n", FILE_APPEND);
}
return $this;
}
@@ -55,7 +52,7 @@ class task_Scheduler
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';
$this->input = $input;
@@ -134,7 +131,7 @@ class task_Scheduler
if ( ! $task->getPID()) {
/* @var $task task_abstract */
$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));
break;
case task_abstract::STATUS_TORESTART:
case task_abstract::STATE_TORESTART:
if ( ! $taskPoll[$tkey]['task']->getPID()) {
if ($this->method == self::METHOD_PROC_OPEN) {
@fclose($taskPoll[$tkey]["pipes"][1]);
@@ -323,7 +320,7 @@ class task_Scheduler
$taskPoll[$tkey]["process"] = null;
}
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'
// so it will continue with 'tostart' case !
@@ -331,7 +328,7 @@ class task_Scheduler
break;
}
case task_abstract::STATUS_TOSTART:
case task_abstract::STATE_TOSTART:
// if scheduler is 'tostop', don't launch a new task !
if ($schedstatus != 'started')
break;
@@ -384,21 +381,17 @@ class task_Scheduler
);
if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5)
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_STOPPED);
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_STOPPED);
else
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_TOSTART);
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_TOSTART);
}
}
}
elseif ($this->method == self::METHOD_FORK) {
// printf("forking pid %d\n", getmypid());
$pid = pcntl_fork();
if ($pid == -1) {
die("failed to fork");
} 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);
if (posix_setsid() < 0)
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"])));
pcntl_exec($taskPoll[$tkey]["cmd"], $taskPoll[$tkey]["args"]);
}
else {
// parent
// sleep(2);
}
}
break;
case task_abstract::STATUS_STARTED:
case task_abstract::STATE_STARTED:
$crashed = false;
// If no process, the task is probably manually ran
if ($this->method == self::METHOD_PROC_OPEN) {
// printf("=== %d ===\n", __LINE__);
if ($taskPoll[$tkey]["process"]) {
// printf("=== %d ===\n", __LINE__);
$taskPoll[$tkey]["killat"] = NULL;
if (is_resource($taskPoll[$tkey]["process"])) {
// printf("=== %d ===\n", __LINE__);
$proc_status = proc_get_status($taskPoll[$tkey]["process"]);
if ($proc_status['running'])
$runningtask ++;
@@ -439,14 +425,12 @@ class task_Scheduler
$crashed = true;
}
else {
// printf("=== %d ===\n", __LINE__);
$crashed = true;
}
}
}
if ( ! $crashed && ! $taskPoll[$tkey]['task']->getPID()) {
// printf("=== %d ===\n", __LINE__);
$crashed = true;
}
@@ -454,7 +438,6 @@ class task_Scheduler
$taskPoll[$tkey]["killat"] = NULL;
$runningtask ++;
} else {
// printf("=== %d ===\n", __LINE__);
// crashed !
$taskPoll[$tkey]["task"]->incrementCrashCounter();
@@ -473,13 +456,13 @@ class task_Scheduler
);
if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5)
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_STOPPED);
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_STOPPED);
else
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_TOSTART);
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_TOSTART);
}
break;
case task_abstract::STATUS_TOSTOP:
case task_abstract::STATE_TOSTOP:
if ($taskPoll[$tkey]["killat"] === NULL)
$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 {
$this->log(
sprintf(
@@ -549,13 +525,13 @@ class task_Scheduler
, $taskPoll[$tkey]["task"]->getID()
)
);
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_STOPPED);
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_STOPPED);
}
break;
case task_abstract::STATUS_STOPPED:
case task_abstract::STATUS_TODELETE:
case task_abstract::STATE_STOPPED:
case task_abstract::STATE_TODELETE:
if ($this->method == self::METHOD_PROC_OPEN) {
if ($taskPoll[$tkey]["process"]) {
@fclose($taskPoll[$tkey]["pipes"][1]);

View File

@@ -5,12 +5,12 @@ abstract class task_abstract
const LAUCHED_BY_BROWSER = 1;
const LAUCHED_BY_COMMANDLINE = 2;
const STATUS_TOSTOP = 'tostop';
const STATUS_STARTED = 'started';
const STATUS_TOSTART = 'tostart';
const STATUS_TORESTART = 'torestart';
const STATUS_STOPPED = 'stopped';
const STATUS_TODELETE = 'todelete';
const STATE_TOSTOP = 'tostop';
const STATE_STARTED = 'started';
const STATE_TOSTART = 'tostart';
const STATE_TORESTART = 'torestart';
const STATE_STOPPED = 'stopped';
const STATE_TODELETE = 'todelete';
const RUNNER_MANUAL = 'manual';
const RUNNER_SCHEDULER = 'scheduler';
@@ -24,7 +24,6 @@ abstract class task_abstract
const ERR_ALREADY_RUNNING = 114; // aka EALREADY (Operation already in progress)
protected $suicidable = false;
protected $launched_by = 0;
/**
@@ -75,11 +74,8 @@ abstract class task_abstract
* @var <type>
*/
protected $maxmegs;
protected $runner;
private $input;
private $output;
/**
@@ -88,25 +84,15 @@ abstract class task_abstract
* @var <type>
*/
protected $title;
protected $settings;
protected $crash_counter;
protected $status;
protected $active;
protected $debug = false;
protected $completed_percentage;
protected $period = 60;
protected $taskid = NULL;
protected $system = ''; // "DARWIN", "WINDOWS" , "LINUX"...
protected $argt = array(
"--help" => array("set" => false, "values" => array(), "usage" => " (no help available)")
);
@@ -114,13 +100,14 @@ abstract class task_abstract
public function getState()
{
$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->execute(array(':taskid' => $this->taskid));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ( ! $row)
throw new Exception('Unknown task id');
return $row['status'];
}
@@ -142,12 +129,12 @@ abstract class task_abstract
public function setState($status)
{
$av_status = array(
self::STATUS_STARTED
, self::STATUS_TOSTOP
, self::STATUS_STOPPED
, self::STATUS_TORESTART
, self::STATUS_TOSTART
, self::STATUS_TODELETE
self::STATE_STARTED
, self::STATE_TOSTOP
, self::STATE_STOPPED
, self::STATE_TORESTART
, self::STATE_TOSTART
, self::STATE_TODELETE
);
if ( ! in_array($status, $av_status)) {
@@ -293,7 +280,7 @@ abstract class task_abstract
return('');
}
$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->execute(array(':taskid' => $this->getID()));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -394,6 +381,7 @@ abstract class task_abstract
}
fclose($fd);
}
return $pid;
}
@@ -408,13 +396,10 @@ abstract class task_abstract
if ($this->running) {// && $this->records_done == 0)
$when_started = time() - $when_started;
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 !
$s = $this->getState();
if ($s == self::STATUS_TOSTOP) {
$this->setState(self::STATUS_STOPPED);
if ($s == self::STATE_TOSTOP) {
$this->setState(self::STATE_STOPPED);
$this->running = FALSE;
} else {
sleep(1);
@@ -456,7 +441,7 @@ abstract class task_abstract
flock($tasklock, LOCK_SH);
$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)
$exception = NULL;
@@ -473,11 +458,11 @@ abstract class task_abstract
@unlink($lockfile);
switch ($this->getState()) {
case self::STATUS_TODELETE:
case self::STATE_TODELETE:
$this->delete();
break;
case self::STATUS_TOSTOP:
$this->setState(self::STATUS_STOPPED);
case self::STATE_TOSTOP:
$this->setState(self::STATE_STOPPED);
break;
}
@@ -509,8 +494,7 @@ abstract class task_abstract
{
if ($this->getRunner() == self::RUNNER_SCHEDULER && ++ $this->loop >= $this->maxloops) {
$this->log(sprintf(('%d loops done, restarting'), $this->loop));
$this->setState(self::STATUS_TORESTART);
// $this->return_xxxvalue = self::RETURNSTATUS_TORESTART;
$this->setState(self::STATE_TORESTART);
$this->running = false;
}
@@ -529,7 +513,6 @@ abstract class task_abstract
$lastt = $t;
echo "\n" . memory_get_usage() . " -- " . memory_get_usage(true) . "\n";
// print($s);
}
public function log($message)
@@ -609,7 +592,6 @@ abstract class task_abstract
return($t);
}
public function getID()
{
return $this->taskid;

View File

@@ -34,8 +34,10 @@ abstract class task_appboxAbstract extends task_abstract
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
$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);
}
// because connection is lost we cannot change status to 'torestart'
// anyway the current status 'running' with no pid
// will enforce the scheduler to restart the task
@@ -50,7 +52,7 @@ abstract class task_appboxAbstract extends task_abstract
$this->setLastExecTime();
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->execute(array(':taskid' => $this->getID()));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -82,18 +84,18 @@ abstract class task_appboxAbstract extends task_abstract
case self::STATE_MAXMEGSREACHED:
case self::STATE_MAXRECSDONE:
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
$this->setState(self::STATUS_TORESTART);
$this->setState(self::STATE_TORESTART);
$this->running = FALSE;
}
break;
case self::STATUS_TOSTOP:
$this->setState(self::STATUS_TOSTOP);
case self::STATE_TOSTOP:
$this->setState(self::STATE_TOSTOP);
$this->running = FALSE;
break;
case self::STATUS_TODELETE: // formal 'suicidable'
$this->setState(self::STATUS_TODELETE);
case self::STATE_TODELETE: // formal 'suicidable'
$this->setState(self::STATE_TODELETE);
$this->running = FALSE;
break;
@@ -164,9 +166,9 @@ abstract class task_appboxAbstract extends task_abstract
// $this->check_task_status();
try {
$status = $this->getState();
if ($status == self::STATUS_TOSTOP) {
if ($status == self::STATE_TOSTOP) {
$this->running = FALSE;
$ret = self::STATUS_TOSTOP;
$ret = self::STATE_TOSTOP;
}
} catch (Exception $e) {
$this->running = FALSE;
@@ -174,11 +176,11 @@ abstract class task_appboxAbstract extends task_abstract
if ( ! $this->running)
break;
} // foreach($rs as $row)
}
//
// if nothing was done, at least check the status
if (count($rs) == 0 && $this->running) {
// $this->check_memory_usage();
$current_memory = memory_get_usage();
if ($current_memory >> 20 >= $this->maxmegs) {
$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;
}
// $this->check_task_status();
try {
$status = $this->getState();
if ($status == self::STATUS_TOSTOP) {
if ($status == self::STATE_TOSTOP) {
$this->running = FALSE;
$ret = self::STATUS_TOSTOP;
$ret = self::STATE_TOSTOP;
}
} catch (Exception $e) {
$this->running = FALSE;

View File

@@ -37,13 +37,15 @@ abstract class task_databoxAbstract extends task_abstract
while ($this->running) {
try {
$conn = connection::getPDOConnection();
} catch (Exception $e) {
} catch (PDOException $e) {
$this->log($e->getMessage());
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
$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);
}
// because connection is lost we cannot change status to 'torestart'
// anyway the current status 'running' with no pid
// 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
}
$this->running = FALSE;
return;
}
@@ -91,27 +94,22 @@ abstract class task_databoxAbstract extends task_abstract
$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) {
case self::STATE_MAXMEGSREACHED:
case self::STATE_MAXRECSDONE:
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
$this->setState(self::STATUS_TORESTART);
$this->setState(self::STATE_TORESTART);
$this->running = FALSE;
}
break;
case self::STATUS_TOSTOP:
$this->setState(self::STATUS_TOSTOP);
case self::STATE_TOSTOP:
$this->setState(self::STATE_TOSTOP);
$this->running = FALSE;
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 !!!
// $this->setState(self::STATUS_TODELETE);
// $this->log('task will self delete');
// $this->running = FALSE;
$task_must_delete = TRUE;
break;
@@ -120,16 +118,17 @@ abstract class task_databoxAbstract extends task_abstract
}
$this->flushRecordsSbas();
} // foreach sbas
}
$this->incrementLoops();
$this->pause($duration);
} // while($this->running)
}
if ($task_must_delete) {
$this->setState(self::STATUS_TODELETE);
$this->setState(self::STATE_TODELETE);
$this->log('task will self delete');
}
return;
}
@@ -174,7 +173,6 @@ abstract class task_databoxAbstract extends task_abstract
// post-process
$this->postProcessOneContent($databox, $row);
// $this->check_memory_usage();
$current_memory = memory_get_usage();
if ($current_memory >> 20 >= $this->maxmegs) {
$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;
}
// $this->check_task_status();
try {
$status = $this->getState();
// printf("%s (%d) status=%s \n", __FILE__, __LINE__, var_export($status, true));
if ($status == self::STATUS_TOSTOP) {
if ($status == self::STATE_TOSTOP) {
$this->running = FALSE;
$ret = self::STATUS_TOSTOP;
$ret = self::STATE_TOSTOP;
}
} catch (Exception $e) {
$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)
break;
} // foreach($rs as $row)
}
//
// if nothing was done, at least check the status
if (count($rs) == 0 && $this->running) {
// $this->check_memory_usage();
$current_memory = memory_get_usage();
if ($current_memory >> 20 >= $this->maxmegs) {
$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;
}
// $this->check_task_status();
try {
$status = $this->getState();
// printf("%s (%d) status=%s \n", __FILE__, __LINE__, var_export($status, true));
if ($status == self::STATUS_TOSTOP) {
if ($status == self::STATE_TOSTOP) {
$this->running = FALSE;
$ret = self::STATUS_TOSTOP;
// $this->task_status = self::STATUS_TOSTOP;
// $this->return_xxxvalue = self::RETURNSTATUS_STOPPED;
$ret = self::STATE_TOSTOP;
}
} catch (Exception $e) {
$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)
$this->setProgress(0, 0);
return($ret);
return $ret;
}
}

View File

@@ -22,7 +22,6 @@ class task_manager
const STATUS_SCHED_TOSTOP = 'tostop';
protected $appbox;
protected $tasks;
public function __construct(appbox &$appbox)

View File

@@ -2,7 +2,7 @@
/*
* 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
* file that was distributed with this source code.
@@ -10,7 +10,6 @@
/**
*
* @package task_manager
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
@@ -102,7 +101,7 @@ class task_period_archive extends task_abstract
$ptype = substr($pname, 0, 3);
$pname = substr($pname, 4);
$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)
while (($n = $ns->firstChild))
$ns->removeChild($n);
@@ -234,13 +233,13 @@ class task_period_archive extends task_abstract
</select>
<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/>
<br/>
<?php echo _('task::_common_:periodicite de la tache') ?>&nbsp;:&nbsp;
<?php echo _('task::_common_:periodicite de la tache') ?>&nbsp;:&nbsp;
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');" value="">&nbsp;<?php echo _('task::_common_:secondes (unite temporelle)') ?><br/>
<br/>
<?php echo _('task::archive:delai de \'repos\' avant traitement') ?>&nbsp;:&nbsp;
<?php echo _('task::archive:delai de \'repos\' avant traitement') ?>&nbsp;:&nbsp;
<input type="text" name="cold" style="width:40px;" onchange="chgxmltxt(this, 'cold');" value="">&nbsp;<?php echo _('task::_common_:secondes (unite temporelle)') ?><br/>
<br/>
<input type="checkbox" name="move_archived" onchange="chgxmlck(this, 'move_archived');">&nbsp;<?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 !
sleep(1);
$this->setState(self::STATUS_TORESTART);
$this->setState(self::STATE_TORESTART);
} else {
$this->log(sprintf(('Error : missing hotfolder \'%s\', stopping.'), $path_in));
// runner = manual : can't restart so simply quit
$this->setState(self::STATUS_STOPPED);
$this->setState(self::STATE_STOPPED);
}
$this->running = FALSE;
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 !
sleep(1);
$this->setState(self::STATUS_TORESTART);
$this->setState(self::STATE_TORESTART);
} else {
$this->log(sprintf(('Error : error fetching task \'%d\', stopping.'), $this->getID()));
// runner = manual : can't restart so simply quit
$this->setState(self::STATUS_STOPPED);
$this->setState(self::STATE_STOPPED);
}
$this->running = FALSE;
return;
}
if ($row['status'] == self::STATUS_TOSTOP) {
if ($row['status'] == self::STATE_TOSTOP) {
$this->running = FALSE;
return;
}
@@ -449,39 +448,27 @@ class task_period_archive extends task_abstract
switch ($r) {
case 'TOSTOP':
$this->setState(self::STATUS_STOPPED);
$this->setState(self::STATE_STOPPED);
$this->running = FALSE;
break;
case 'WAIT':
$this->setState(self::STATUS_STOPPED);
$this->setState(self::STATE_STOPPED);
$this->running = FALSE;
break;
case 'BAD':
$this->setState(self::STATUS_STOPPED);
$this->setState(self::STATE_STOPPED);
$this->running = FALSE;
break;
case 'NORECSTODO':
$duration = time() - $duration;
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 ++ ) {
$s = $this->getState();
if ($s == self::STATUS_TOSTOP) {
$this->setState(self::STATUS_STOPPED);
if ($s == self::STATE_TOSTOP) {
$this->setState(self::STATE_STOPPED);
$this->running = FALSE;
} else {
// $conn->close();
// unset($conn);
sleep(1);
// $conn = connection::getPDOConnection();
}
}
}
@@ -489,14 +476,14 @@ class task_period_archive extends task_abstract
case 'MAXRECSDONE':
case 'MAXMEMORY':
case 'MAXLOOP':
if ($row['status'] == self::STATUS_STARTED && $this->getRunner() !== self::RUNNER_MANUAL) {
$this->setState(self::STATUS_TORESTART);
if ($row['status'] == self::STATE_STARTED && $this->getRunner() !== self::RUNNER_MANUAL) {
$this->setState(self::STATE_TORESTART);
$this->running = FALSE;
}
break;
default:
if ($row['status'] == self::STATUS_STARTED) {
$this->setState(self::STATUS_STOPPED);
if ($row['status'] == self::STATE_STARTED) {
$this->setState(self::STATE_STOPPED);
$this->running = FALSE;
}
break;
@@ -513,8 +500,6 @@ class task_period_archive extends task_abstract
*/
function archiveHotFolder($server_coll_id)
{
// $this->filesToIgnore = array('.', '..', 'Thumbs.db', '');
clearstatcache();
$conn = connection::getPDOConnection();
@@ -570,7 +555,7 @@ class task_period_archive extends task_abstract
while ($cold > 0) {
$s = $this->getState();
if ($s == self::STATUS_TOSTOP)
if ($s == self::STATE_TOSTOP)
return('TOSTOP');
sleep(2);
$cold -= 2;
@@ -724,7 +709,7 @@ class task_period_archive extends task_abstract
while (($file = $listFolder->read()) !== NULL) {
if (time() - $time0 >= 2) { // each 2 secs, check the status of the task
$s = $this->getState();
if ($s == self::STATUS_TOSTOP) {
if ($s == self::STATE_TOSTOP) {
$nnew = 'TOSTOP'; // since we will return a string...
break; // ...we can check it against numerical result
}
@@ -779,7 +764,7 @@ class task_period_archive extends task_abstract
* @param <type> $depth
* @return <type>
*/
function listFilesPhase2($dom, $node, $path, $depth=0)
function listFilesPhase2($dom, $node, $path, $depth = 0)
{
static $iloop = 0;
if ($depth == 0)
@@ -877,7 +862,7 @@ class task_period_archive extends task_abstract
* @param <type> $depth
* @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;
if ($depth == 0)
@@ -903,7 +888,6 @@ class task_period_archive extends task_abstract
if ($n->getAttribute('isdir') == '1') {
if (($grpSettings = $this->getGrpSettings($name)) !== FALSE) { // get 'caption', 'representation'
// this is a grp folder, we check it
$dnl = $xpath->query('./file[@name=".grouping.xml"]', $n);
if ($dnl->length == 1) {
// 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
* @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;
if ($depth == 0)
@@ -1033,11 +1017,6 @@ class task_period_archive extends task_abstract
if ($n->getAttribute('isdir')) {
// a dir
// if($n->getAttribute('error') && $this->move_error)
// {
// @mkdir($path_error . '/' . $name);
// }
$ret |= $this->removeBadGroups($dom, $n, $path . '/' . $name
, $path_archived . '/' . $name
, $path_error . '/' . $name
@@ -1086,7 +1065,7 @@ class task_period_archive extends task_abstract
* @param <type> $depth
* @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;
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
}
}
// printf("========== %s === %s ====== \n", __LINE__, var_export($nodesToDel, true));
foreach ($nodesToDel as $n)
$n->parentNode->removeChild($n);
@@ -1153,7 +1131,7 @@ class task_period_archive extends task_abstract
* @param <type> $depth
* @return <type>
*/
function bubbleResults($dom, $node, $path, $depth=0)
function bubbleResults($dom, $node, $path, $depth = 0)
{
static $iloop = 0;
if ($depth == 0)
@@ -1212,7 +1190,7 @@ class task_period_archive extends task_abstract
* @param <type> $depth
* @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;
if ($depth == 0)
@@ -1567,7 +1545,7 @@ class task_period_archive extends task_abstract
* @param <type> $grp_rid
* @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');
if ($match == '*')
@@ -1823,7 +1801,7 @@ class task_period_archive extends task_abstract
* @param <type> $attributes
* @param <type> $depth
*/
function setAllChildren($dom, $node, $attributes, $depth=0)
function setAllChildren($dom, $node, $attributes, $depth = 0)
{
static $iloop = 0;
if ($depth == 0)

View File

@@ -2,7 +2,7 @@
/*
* 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
* 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)) {
$this->setState(self::STATUS_STOPPED);
$this->setState(self::STATE_STOPPED);
$this->log(sprintf(_('task::cindexer:file \'%s\' does not exists'), $cmd));
throw new Exception('cindexer executable not found', self::ERR_EXECUTABLE_NOT_FOUND);
return;
@@ -442,8 +442,6 @@ class task_period_cindexer extends task_abstract
$nullfile = $this->system == 'WINDOWS' ? 'NUL' : '/dev/null';
$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[2] = array("file", $nullfile, "a+");
@@ -465,7 +463,7 @@ class task_period_cindexer extends task_abstract
$this->running = true;
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
if ( ! $qsent && (($sock = socket_create(AF_INET, SOCK_STREAM, 0)) !== false)) {
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
if ($qsent == 'Q') {
$this->log(_('task::cindexer:the cindexer clean-quit'));
$this->new_status = self::STATUS_STOPPED;
$this->new_status = self::STATE_STOPPED;
} elseif ($qsent == 'K') {
$this->log(_('task::cindexer:the cindexer has been killed'));
$this->new_status = self::STATUS_STOPPED;
$this->new_status = self::STATE_STOPPED;
} else {
$this->log(_('task::cindexer:the cindexer crashed'));
$this->exception = new Exception('cindexer crashed', self::ERR_CRASHED);
@@ -536,7 +534,6 @@ class task_period_cindexer extends task_abstract
} elseif ($pid == 0) {
// child
umask(0);
// openlog('MyLog', LOG_PID | LOG_PERROR, LOG_LOCAL0);
if (($err = posix_setsid()) < 0) {
$this->exception = new Exception('cindexer can\'t detach from terminal', $err);
} 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));
sleep(2);
}
@@ -572,10 +569,10 @@ class task_period_cindexer extends task_abstract
// child (indexer) has exited
if ($sigsent == SIGINT) {
$this->log(_('task::cindexer:the cindexer clean-quit'));
$this->new_status = self::STATUS_STOPPED;
$this->new_status = self::STATE_STOPPED;
} elseif ($sigsent == SIGKILL) {
$this->log(_('task::cindexer:the cindexer has been killed'));
$this->new_status = self::STATUS_STOPPED;
$this->new_status = self::STATE_STOPPED;
} else {
$this->log(_('task::cindexer:the cindexer crashed'));
$this->exception = new Exception('cindexer crashed', self::ERR_CRASHED);
@@ -601,5 +598,3 @@ class task_period_cindexer extends task_abstract
sleep(2);
}
}
// class

View File

@@ -18,9 +18,7 @@
class task_period_emptyColl extends task_appboxAbstract
{
protected $base_id;
protected $suicidable = true;
protected $total_records = 0;
public function getName()
@@ -47,9 +45,8 @@ class task_period_emptyColl extends task_appboxAbstract
protected function retrieveContent(appbox $appbox)
{
if ( ! $this->base_id) {
$this->current_state = self::STATE_FINISHED;
return;
$this->setState(self::STATE_STOPPED);
return array();
}
$collection = collection::get_from_base_id($this->base_id);
$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);
if ($this->total_records == 0) {
$this->current_state = self::STATE_FINISHED;
$this->setState(self::STATE_STOPPED);
$this->log('Job finished');
}

View File

@@ -17,9 +17,7 @@
class task_period_ftp extends task_appboxAbstract
{
protected $proxy;
protected $proxyport;
protected $debug;
/**
@@ -566,8 +564,7 @@ class task_period_ftp extends task_appboxAbstract
{
$conn = $appbox->get_connection();
$sql = 'SELECT crash, nbretry FROM ftp_export'
. ' WHERE id = :export_id';
$sql = 'SELECT crash, nbretry FROM ftp_export WHERE id = :export_id';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':export_id' => $id));

View File

@@ -2,7 +2,7 @@
/*
* 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
* file that was distributed with this source code.
@@ -17,25 +17,15 @@
class task_period_ftpPull extends task_appboxAbstract
{
protected $debug = false;
protected $proxy;
protected $proxyport;
protected $host;
protected $port;
protected $user;
protected $password;
protected $ssl;
protected $passive;
protected $ftppath;
protected $localpath;
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 ?>.passive.checked = <?php echo p4field::isyes($sxml->passive) ? "true" : 'false' ?>;
</script>
<?php
return("");
} else { // ... so we NEVER come here
@@ -134,6 +125,7 @@ class task_period_ftpPull extends task_appboxAbstract
setDirty();
}
</script>
<?php
}
@@ -203,11 +195,11 @@ class task_period_ftpPull extends task_appboxAbstract
if ($parm["xml"] === null) {
// pas de xml 'raw' : on accepte les champs 'graphic view'
if ($domTaskSettings = DOMDocument::loadXML($taskrow["settings"])) {
if (($domTaskSettings = DOMDocument::loadXML($taskrow["settings"]))) {
$xmlchanged = false;
foreach (array("proxy", "proxyport", "period", "host", "port", "user", "password", "ssl", "passive", "localpath", "ftppath") as $f) {
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)
while (($n = $ns->firstChild))
$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
if ($parm["xml"] && ! DOMDocument::loadXML($parm["xml"]))
if ($parm["xml"] && ! DOMDocument::loadXML($parm["xml"])) {
return(false);
}
$sql = "";
$params = array(':task_id' => $taskid);
@@ -295,7 +288,7 @@ class task_period_ftpPull extends task_appboxAbstract
$this->running = FALSE;
}
if ( ! $this->running) {
$this->set_status(self::STATUS_STOPPED);
$this->set_status(self::STATE_STOPPED);
return array();
}
@@ -308,14 +301,16 @@ class task_period_ftpPull extends task_appboxAbstract
$todo = count($list_1);
$this->setProgress($done, $todo);
if ($this->debug)
if ($this->debug) {
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 !
$s = $this->getState();
if ($s == self::STATUS_TOSTOP) {
if ($s == self::STATE_TOSTOP) {
if (isset($ftp) && $ftp instanceof ftpclient)
$ftp->close();
$this->set_status(self::STATUS_STOPPED);
$this->set_status(self::STATE_STOPPED);
$this->running = FALSE;
return array();
}
@@ -379,3 +374,4 @@ class task_period_ftpPull extends task_appboxAbstract
}
}

View File

@@ -2,7 +2,7 @@
/*
* 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
* 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
private $connbas = null; // cnx a la base
private $msg = "";
private $sbas_id;
protected function run2()
@@ -529,11 +526,11 @@ class task_period_outofdate extends task_abstract
switch ($r) {
case 'WAIT':
$ret = self::STATUS_STOPPED;
$this->setState(self::STATE_STOPPED);
$this->running = false;
break;
case 'BAD':
$ret = self::STATUS_STOPPED;
$this->setState(self::STATE_STOPPED);
$this->running = false;
break;
case 'NORECSTODO':
@@ -546,21 +543,21 @@ class task_period_outofdate extends task_abstract
case 'MAXRECSDONE':
case 'MAXMEMORY':
case 'MAXLOOP':
if ($row['status'] == self::STATUS_STARTED && $this->getRunner() !== self::RUNNER_MANUAL) {
$ret = self::STATUS_TORESTART;
if ($row['status'] == self::STATE_STARTED && $this->getRunner() !== self::RUNNER_MANUAL) {
$this->setState(self::STATE_TORESTART);
$this->running = false;
}
break;
default:
if ($row['status'] == self::STATUS_STARTED) {
$ret = self::STATUS_STOPPED;
if ($row['status'] == self::STATE_STARTED) {
$this->setState(self::STATE_STOPPED);
$this->running = false;
}
break;
}
}
} else {
$ret = self::STATUS_STOPPED;
$this->setState(self::STATE_STOPPED);
$this->running = false;
}
$loop ++;

View File

@@ -2,7 +2,7 @@
/*
* 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
* 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 ?>.maxmegs.value = "<?php echo p4string::MakeString($sxml->maxmegs, "js", '"') ?>";
</script>
<?php
return("");
}
@@ -261,7 +262,7 @@ class task_period_subdef extends task_databoxAbstract
, $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();

View File

@@ -2,7 +2,7 @@
/*
* 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
* file that was distributed with this source code.
@@ -10,7 +10,6 @@
/**
*
* @package task_manager
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @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", '"') ?>";
parent.calccmd();
</script>
<?php
return("");
}
else { // ... so we NEVER come here
// bad xml
return("BAD XML");
}
}
@@ -283,16 +282,16 @@ class task_period_workflow01 extends task_databoxAbstract
ob_start();
?>
<form name="graphicForm" onsubmit="return(false);" method="post">
<?php echo _('task::outofdate:Base') ?>&nbsp;:&nbsp;
<?php echo _('task::outofdate:Base') ?>&nbsp;:&nbsp;
<select onchange="chgsbas(this);setDirty();" name="sbas_id">
<option value="">...</option>
<?php
$sbas_ids = $user->ACL()->get_granted_sbas(array('bas_manage'));
foreach ($sbas_ids as $databox) {
print('<option value="' . $databox->get_sbas_id() . '">' . p4string::MakeString($databox->get_viewname(), "form") . '</option>');
}
?>
<?php
$sbas_ids = $user->ACL()->get_granted_sbas(array('bas_manage'));
foreach ($sbas_ids as $databox) {
print('<option value="' . $databox->get_sbas_id() . '">' . p4string::MakeString($databox->get_viewname(), "form") . '</option>');
}
?>
</select>
&nbsp;
@@ -300,9 +299,9 @@ class task_period_workflow01 extends task_databoxAbstract
<br/>
<br/>
<?php echo _('task::_common_:periodicite de la tache') ?>&nbsp;:&nbsp;
<?php echo _('task::_common_:periodicite de la tache') ?>&nbsp;:&nbsp;
<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/>
<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'"));
}
protected $status_origine;
protected $coll_origine;
protected $status_destination;
protected $coll_destination;
protected function loadSettings(SimpleXMLElement $sx_task_settings)
@@ -382,28 +378,28 @@ class task_period_workflow01 extends task_databoxAbstract
$sql_s = $sql_w = '';
$sql_parms = array();
if ($this->coll_origine != '') {
$sql_w .= ($sql_w ? ' AND ' : '')
. '(coll_id=:coll_org)';
$sql_w .= ($sql_w ? ' AND ' : '') . '(coll_id=:coll_org)';
$sql_parms[':coll_org'] = $this->coll_origine;
}
if ($this->status_origine != '') {
$x = explode('_', $this->status_origine);
if (count($x) !== 2)
throw new Exception('Error in settings for status origine');
if (count($x) !== 2) {
throw new Exception('Error in settings for status origin');
}
$sql_w .= ($sql_w ? ' AND ' : '')
. '((status >> :stat_org_n & 1) = :stat_org_v)';
$sql_parms[':stat_org_n'] = $x[0];
$sql_parms[':stat_org_v'] = $x[1];
}
if ($this->coll_destination != '') {
$sql_s .= ($sql_s ? ', ' : '')
. 'coll_id=:coll_dst';
$sql_s .= ($sql_s ? ', ' : '') . 'coll_id=:coll_dst';
$sql_parms[':coll_dst'] = $this->coll_destination;
}
if ($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');
}
$sql_s .= ($sql_s ? ', ' : '');
if ((int) $x[1] === 0)
$sql_s .= 'status = status &~(1 << :stat_dst)';
@@ -491,6 +487,7 @@ class task_period_workflow01 extends task_databoxAbstract
} catch (Exception $e) {
}
return p4string::jsonencode($retjs);
}
}

View File

@@ -16,14 +16,12 @@ use PHPExiftool\Writer;
/**
*
* @package task_manager
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class task_period_writemeta extends task_databoxAbstract
{
protected $clear_doc;
protected $metasubdefs = array();
function help()
@@ -61,7 +59,7 @@ class task_period_writemeta extends task_databoxAbstract
$ptype = substr($pname, 0, 3);
$pname = substr($pname, 4);
$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)
while (($n = $ns->firstChild))
$ns->removeChild($n);

View File

@@ -293,7 +293,7 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
$this->evaluateMetaJson200($content);
$task_manager->getTasks(true);
$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);
$task_manager->getTasks(true);
$task = $task_manager->getTask($idTask);
$this->assertEquals(\task_abstract::STATUS_TOSTOP, $task->getState());
$this->assertEquals(\task_abstract::STATE_TOSTOP, $task->getState());
}
/**

View File

@@ -294,7 +294,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
$this->evaluateMetaYaml200($content);
$task_manager->getTasks(true);
$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);
$task_manager->getTasks(true);
$task = $task_manager->getTask($idTask);
$this->assertEquals(\task_abstract::STATUS_TOSTOP, $task->getState());
$this->assertEquals(\task_abstract::STATE_TOSTOP, $task->getState());
}
/**

View File

@@ -3,7 +3,7 @@
/*
* 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
* file that was distributed with this source code.
@@ -11,7 +11,6 @@
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
@@ -25,355 +24,315 @@ $parm = $request->get_parms('action', 'position', 'test', 'renew', 'path', 'test
$output = '';
switch ($parm['action'])
{
case 'TREE':
$output = module_admin::getTree($parm['position']);
break;
case 'APACHE':
if ($parm['test'] == 'success')
$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);
}
switch ($parm['action']) {
case 'TREE':
$output = module_admin::getTree($parm['position']);
break;
case 'APACHE':
if ($parm['test'] == 'success')
$output = '1';
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');
$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;
}
}
}
}
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']);
$output = p4string::jsonencode(array('results' => ($tests ? '1' : '0')));
break;
if($collection->get_record_amount() <= 500)
{
$collection->empty_collection(500);
}
else
{
$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>";
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 {
$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);
$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;
if ($collection->get_record_amount() <= 500) {
$collection->empty_collection(500);
} else {
$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>";
case 'SETTASKSTATUS':
$parm = $request->get_parms('task_id', 'status', 'signal');
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)
{
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;
}
$output = json_encode($pid);
break;
case 'SETTASKSTATUS':
$parm = $request->get_parms('task_id', 'status', 'signal');
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');
try
{
$task_manager = new task_manager($appbox);
}
$output = json_encode($pid);
break;
$task_manager->setSchedulerState($parm['status']);
}
catch (Exception $e)
{
case 'SETSCHEDSTATUS':
$parm = $request->get_parms('status', 'signal');
try {
$task_manager = new task_manager($appbox);
}
break;
$task_manager->setSchedulerState($parm['status']);
} catch (Exception $e) {
case 'RESETTASKCRASHCOUNTER':
$parm = $request->get_parms("task_id");
try
{
$task_manager = new task_manager($appbox);
$task = $task_manager->getTask($parm['task_id']);
$task->resetCrashCounter();
}
catch (Exception $e)
{
}
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 'RESETTASKCRASHCOUNTER':
$parm = $request->get_parms("task_id");
try {
$task_manager = new task_manager($appbox);
$task = $task_manager->getTask($parm['task_id']);
$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':
$parm = $request->get_parms('act', 'task_id', "usr");
$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)));
$output = $ret->saveXML();
break;
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)
{
case 'CHANGETASK':
$parm = $request->get_parms('act', 'task_id', "usr");
$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 {
$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);
$ret['scheduler'] = $task_manager->getSchedulerState();
$output = $ret->saveXML();
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)
{
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()
);
}
$ret['tasks'] = array();
if(1)
{
$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;
}
}
foreach ($task_manager->getTasks(true) as $task) {
if ($task->getState() == task_abstract::STATE_TOSTOP && $task->getPID() === NULL) {
// fix
$task->setState(task_abstract::STATE_STOPPED);
}
$id = $task->getID();
$ret['tasks'][$id] = array(
'id' => $id
, 'pid' => $task->getPID()
, 'crashed' => $task->getCrashCounter()
, 'completed' => $task->getCompletedPercentage()
, 'status' => $task->getState()
);
}
$output = p4string::jsonencode($ret);
break;
if (1) {
$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':
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
$ret = array('sbas_id' => null);
$output = p4string::jsonencode($ret);
break;
$databox = databox::get_instance((int) $parm['sbas_id']);
$databox->unmount_databox($appbox);
case 'UNMOUNTBASE':
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
$ret = array('sbas_id' => null);
$ret['sbas_id'] = $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 = databox::get_instance((int) $parm['sbas_id']);
$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;
$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);
$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);

View File

@@ -2,7 +2,7 @@
/*
* 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
* file that was distributed with this source code.
@@ -10,7 +10,6 @@
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
@@ -347,8 +346,6 @@ foreach ($tasks as $t) {
</head>
<body>
<?php ?>
<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') ?>
@@ -422,11 +419,7 @@ foreach ($tasks as $t) {
</table>
<div id="db_processlist"></div>
<!--
<a id="newTaskButton" href="#"><?php echo _('admin::tasks: Nouvelle tache') ?></a>
-->
<?php ?>
<script type="text/javascript">
function editTask(tid)

View File

@@ -124,21 +124,21 @@ try {
$status_2 = databox_status::operation_and($mask_oui, $mask_non);
if ( ! $filename->is_new_in_base(phrasea::sbasFromBas($base_id)) || count($error_file) > 0) {
// file already exists in base
if ( ! lazaretFile::copy_uploaded_to_lazaret($filename, $base_id, $_FILES['Filedata']["name"], implode("\n", $error_file), $status_2)) {
// copy in lazaret failed
if ( ! lazaretFile::move_uploaded_to_lazaret($filename, $base_id, $_FILES['Filedata']["name"], implode("\n", $error_file), $status_2)) {
// move in lazaret failed
if (UPLOADER == 'FLASH')
header('HTTP/1.1 500 Internal Server Error');
else
echo '<script type="text/javascript">parent.classic_uploaded("' . _("erreur lors de l'archivage") . '")</script>';
}
else {
// copy in lazaret succeed
// move in lazaret succeed
if (UPLOADER == 'HTML')
echo '<script type="text/javascript">parent.classic_uploaded("' . _('Document ajoute a la quarantaine') . '")</script>';
}
// if (UPLOADER == 'HTML')
// echo '<script type="text/javascript">parent.classic_uploaded("' . _("Fichier uploade, en attente") . '")</script>';
if (UPLOADER == 'HTML')
echo '<script type="text/javascript">parent.classic_uploaded("' . _("Fichier uploade, en attente") . '")</script>';
unset($filename);
unlink($_FILES['Filedata']['tmp_name']);