diff --git a/lib/classes/API/V1/adapter.class.php b/lib/classes/API/V1/adapter.class.php
index 1b77bb81a8..1bef19931e 100644
--- a/lib/classes/API/V1/adapter.class.php
+++ b/lib/classes/API/V1/adapter.class.php
@@ -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;
diff --git a/lib/classes/module/console/schedulerState.class.php b/lib/classes/module/console/schedulerState.class.php
index 7fc919a305..4cb8bd755d 100644
--- a/lib/classes/module/console/schedulerState.class.php
+++ b/lib/classes/module/console/schedulerState.class.php
@@ -38,7 +38,6 @@ class module_console_schedulerState extends Command
, 'print short result, ie: stopped | started(12345) | stopping'
, NULL
);
-// $this->setHelp("");
return $this;
}
diff --git a/lib/classes/module/console/taskrun.class.php b/lib/classes/module/console/taskrun.class.php
index 4d6c9de373..2085f8003c 100755
--- a/lib/classes/module/console/taskrun.class.php
+++ b/lib/classes/module/console/taskrun.class.php
@@ -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
}
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/classes/task/Scheduler.class.php b/lib/classes/task/Scheduler.class.php
index 190da1cfc6..91a874fbc2 100755
--- a/lib/classes/task/Scheduler.class.php
+++ b/lib/classes/task/Scheduler.class.php
@@ -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]);
diff --git a/lib/classes/task/abstract.class.php b/lib/classes/task/abstract.class.php
index f8ff332372..9f88f98b9a 100755
--- a/lib/classes/task/abstract.class.php
+++ b/lib/classes/task/abstract.class.php
@@ -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
*/
protected $maxmegs;
-
protected $runner;
-
private $input;
-
private $output;
/**
@@ -88,25 +84,15 @@ abstract class task_abstract
* @var
*/
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;
diff --git a/lib/classes/task/appboxAbstract.class.php b/lib/classes/task/appboxAbstract.class.php
index 011f8529bf..43427028fc 100755
--- a/lib/classes/task/appboxAbstract.class.php
+++ b/lib/classes/task/appboxAbstract.class.php
@@ -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;
diff --git a/lib/classes/task/databoxAbstract.class.php b/lib/classes/task/databoxAbstract.class.php
index ab9a270b37..1fa8e479b1 100755
--- a/lib/classes/task/databoxAbstract.class.php
+++ b/lib/classes/task/databoxAbstract.class.php
@@ -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;
}
}
diff --git a/lib/classes/task/manager.class.php b/lib/classes/task/manager.class.php
index a96f3c32e0..8b4771d04e 100755
--- a/lib/classes/task/manager.class.php
+++ b/lib/classes/task/manager.class.php
@@ -22,7 +22,6 @@ class task_manager
const STATUS_SCHED_TOSTOP = 'tostop';
protected $appbox;
-
protected $tasks;
public function __construct(appbox &$appbox)
diff --git a/lib/classes/task/period/archive.class.php b/lib/classes/task/period/archive.class.php
index 496f764c63..284240a139 100755
--- a/lib/classes/task/period/archive.class.php
+++ b/lib/classes/task/period/archive.class.php
@@ -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
-
+
- :
+ :
- :
+ :
@@ -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 $depth
* @return
*/
- 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 $depth
* @return
*/
- 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 $depth
* @return
*/
- 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 $depth
* @return
*/
- 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 $depth
* @return
*/
- 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 $depth
* @return
*/
- 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 $grp_rid
* @return
*/
- 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 $attributes
* @param $depth
*/
- function setAllChildren($dom, $node, $attributes, $depth=0)
+ function setAllChildren($dom, $node, $attributes, $depth = 0)
{
static $iloop = 0;
if ($depth == 0)
diff --git a/lib/classes/task/period/cindexer.class.php b/lib/classes/task/period/cindexer.class.php
index b4b9b048f6..bbef74a950 100755
--- a/lib/classes/task/period/cindexer.class.php
+++ b/lib/classes/task/period/cindexer.class.php
@@ -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
diff --git a/lib/classes/task/period/emptyColl.class.php b/lib/classes/task/period/emptyColl.class.php
index 8939f726e1..01e64bed11 100755
--- a/lib/classes/task/period/emptyColl.class.php
+++ b/lib/classes/task/period/emptyColl.class.php
@@ -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');
}
diff --git a/lib/classes/task/period/ftp.class.php b/lib/classes/task/period/ftp.class.php
index 20df485ffe..8d85e481a6 100755
--- a/lib/classes/task/period/ftp.class.php
+++ b/lib/classes/task/period/ftp.class.php
@@ -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));
diff --git a/lib/classes/task/period/ftpPull.class.php b/lib/classes/task/period/ftpPull.class.php
index ffa070b309..203996b47d 100755
--- a/lib/classes/task/period/ftpPull.class.php
+++ b/lib/classes/task/period/ftpPull.class.php
@@ -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
.ssl.checked = ssl) ? "true" : 'false' ?>;
.passive.checked = passive) ? "true" : 'false' ?>;
+
+
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
}
}
+
diff --git a/lib/classes/task/period/outofdate.class.php b/lib/classes/task/period/outofdate.class.php
index cd0f7885da..069cdcc497 100755
--- a/lib/classes/task/period/outofdate.class.php
+++ b/lib/classes/task/period/outofdate.class.php
@@ -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 ++;
diff --git a/lib/classes/task/period/subdef.class.php b/lib/classes/task/period/subdef.class.php
index f2cb8167ff..b5b563ced2 100755
--- a/lib/classes/task/period/subdef.class.php
+++ b/lib/classes/task/period/subdef.class.php
@@ -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
.maxrecs.value = "maxrecs, "js", '"') ?>";
.maxmegs.value = "maxmegs, "js", '"') ?>";
+
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();
diff --git a/lib/classes/task/period/workflow01.class.php b/lib/classes/task/period/workflow01.class.php
index 8ae16bd513..fd6e7e016e 100755
--- a/lib/classes/task/period/workflow01.class.php
+++ b/lib/classes/task/period/workflow01.class.php
@@ -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
.period.value = "period, "js", '"') ?>";
parent.calccmd();
+