function index() { if ($this->request->isAsyncCall()) { $my_pub_key = ConfigOptions::getValue('frosso_auth_my_pub_key', false); $my_pri_key = ConfigOptions::getValue('frosso_auth_my_pri_key', false); $token = ConfigOptions::getValue('frosso_auth_my_pri_token', false); $this->smarty->assign(array('my_pub_key' => $my_pub_key, 'my_pri_key' => $my_pri_key, 'token' => $token)); if ($this->request->isSubmitted()) { $my_pub_sub = $this->request->post('my_pub_key'); $my_pri_sub = $this->request->post('my_pri_key'); $sub_token = $this->request->post('token'); if ($sub_token) { if (FrossoAuthModel::isValidKey($my_pub_sub, $my_pri_sub)) { ConfigOptions::setValue('frosso_auth_my_pub_key', $my_pub_sub); ConfigOptions::setValue('frosso_auth_my_pri_key', $my_pri_sub); ConfigOptions::setValue('frosso_auth_my_pri_token', $sub_token); $my_pub_key = $my_pub_sub; $my_pri_key = $my_pri_sub; $this->response->ok(); } else { $this->response->exception(new ValidationErrors(array('my_pub_key' => lang("Public key and private key must be valid")))); } } else { $this->response->exception(new ValidationErrors(array('token' => lang("Token must be valid")))); } } // isSubmitted } else { $this->response->badRequest(); } // if }
/** * Trigger daily tasks * * @param void * @return null */ function daily() { $this->renderText('Daily event started on ' . strftime(FORMAT_DATETIME) . '.<br />', false, false); event_trigger('on_daily'); ConfigOptions::setValue('last_daily_activity', time()); $this->renderText('Daily event finished on ' . strftime(FORMAT_DATETIME) . '.'); }
/** * Settings form * * @param void * @return null */ function index() { js_assign('test_svn_url', assemble_url('admin_source_test_svn')); $source_data = $this->request->post('source'); if (!is_foreachable($source_data)) { $source_data = array('svn_path' => ConfigOptions::getValue('source_svn_path'), 'svn_config_dir' => ConfigOptions::getValue('source_svn_config_dir'), 'source_svn_use_output_redirect' => ConfigOptions::getValue('source_svn_use_output_redirect'), 'source_svn_trust_server_cert' => ConfigOptions::getValue('source_svn_trust_server_cert')); } // if if ($this->request->isSubmitted()) { $svn_path = array_var($source_data, 'svn_path', null); $svn_path = $svn_path ? with_slash($svn_path) : null; ConfigOptions::setValue('source_svn_path', $svn_path); $svn_config_dir = array_var($source_data, 'svn_config_dir') == '' ? null : array_var($source_data, 'svn_config_dir'); ConfigOptions::setValue('source_svn_config_dir', $svn_config_dir); $svn_use_output_redirection = array_var($source_data, 'source_svn_use_output_redirect') == "1"; ConfigOptions::setValue('source_svn_use_output_redirect', $svn_use_output_redirection); $svn_trust_server_certificate = array_var($source_data, 'source_svn_trust_server_cert') == "1"; ConfigOptions::setValue('source_svn_trust_server_cert', $svn_trust_server_certificate); flash_success("Source settings successfully saved"); $this->redirectTo('admin_source'); } // if if (!RepositoryEngine::executableExists()) { $this->wireframe->addPageMessage(lang("SVN executable not found. You won't be able to use this module"), 'error'); } // if $this->smarty->assign(array('source_data' => $source_data)); }
/** * Show invoicing settings panel * * @param void * @return null */ function index() { require_once INVOICING_MODULE_PATH . '/models/InvoicePdfGenerator.class.php'; $paper_formats = array(PAPER_FORMAT_A4, PAPER_FORMAT_A3, PAPER_FORMAT_A5, PAPER_FORMAT_LETTER, PAPER_FORMAT_LEGAL); $paper_orientations = array(PAPER_ORIENTATION_PORTRAIT, PAPER_ORIENTATION_LANDSCAPE); $pdf_settings_data = $this->request->post('pdf_settings'); if (!is_array($pdf_settings_data)) { $pdf_settings_data = array('paper_format' => ConfigOptions::getValue('invoicing_pdf_paper_format'), 'paper_orientation' => ConfigOptions::getValue('invoicing_pdf_paper_orientation'), 'header_text_color' => ConfigOptions::getValue('invoicing_pdf_header_text_color'), 'page_text_color' => ConfigOptions::getValue('invoicing_pdf_page_text_color'), 'border_color' => ConfigOptions::getValue('invoicing_pdf_border_color'), 'background_color' => ConfigOptions::getValue('invoicing_pdf_background_color')); } // if if ($this->request->isSubmitted()) { db_begin_work(); ConfigOptions::setValue('invoicing_pdf_paper_format', array_var($pdf_settings_data, 'paper_format', 'A4')); ConfigOptions::setValue('invoicing_pdf_paper_orientation', array_var($pdf_settings_data, 'paper_orientation', 'Portrait')); ConfigOptions::setValue('invoicing_pdf_header_text_color', array_var($pdf_settings_data, 'header_text_color', '000000')); ConfigOptions::setValue('invoicing_pdf_page_text_color', array_var($pdf_settings_data, 'page_text_color', '000000')); ConfigOptions::setValue('invoicing_pdf_border_color', array_var($pdf_settings_data, 'border_color', '000000')); ConfigOptions::setValue('invoicing_pdf_background_color', array_var($pdf_settings_data, 'background_color', 'FFFFFF')); db_commit(); flash_success('Successfully modified PDF settings'); $this->redirectTo('admin_invoicing_pdf'); } // if $this->smarty->assign(array('paper_formats' => $paper_formats, 'paper_orientations' => $paper_orientations, 'pdf_settings_data' => $pdf_settings_data)); }
function __construct($request) { parent::__construct($request); $three_o_four_data = $this->request->post('three_o_four'); if (!is_array($three_o_four_data)) { $three_o_four_data = array('etag_enabled' => ConfigOptions::getValue('three_o_four_etag_enabled'), 'response_cache_enabled' => ConfigOptions::getValue('three_o_four_response_cache_enabled')); } // if $this->smarty->assign(array('three_o_four' => $three_o_four_data)); if ($this->request->isSubmitted()) { ConfigOptions::setValue('three_o_four_etag_enabled', array_var($three_o_four_data, 'etag_enabled', null)); ConfigOptions::setValue('three_o_four_response_cache_enabled', array_var($three_o_four_data, 'response_cache_enabled', null)); flash_success('Cache settings have been updated'); $this->redirectTo('three_o_four_settings'); } }
/** * PublicSubmitAdmin index page * */ function index() { $public_submit_data = $this->request->post('public_submit'); if (!is_array($public_submit_data)) { $public_submit_data = array('project_id' => ConfigOptions::getValue('public_submit_default_project'), 'enabled' => ConfigOptions::getValue('public_submit_enabled'), 'captcha' => ConfigOptions::getValue('public_submit_enable_captcha')); } // if $this->smarty->assign(array('public_submit_data' => $public_submit_data)); if ($this->request->isSubmitted()) { ConfigOptions::setValue('public_submit_default_project', array_var($public_submit_data, 'project_id', null)); ConfigOptions::setValue('public_submit_enabled', array_var($public_submit_data, 'enabled', null)); ConfigOptions::setValue('public_submit_enable_captcha', array_var($public_submit_data, 'captcha', null)); flash_success('Public Submit settings have been updated'); $this->redirectTo('admin_settings_public_submit'); } // if }
/** * Main Backup page * */ function index() { $backup_data = $this->request->post('backup'); if (!is_array($backup_data)) { $backup_data = array('enabled' => $this->backup_enabled, 'how_many_backups' => $this->how_many_backups); } // if $this->smarty->assign(array('backup_data' => $backup_data, 'how_many_values' => array(3, 5, 10, 15, 30, 60))); if ($this->request->isSubmitted()) { ConfigOptions::setValue('backup_enabled', (bool) array_var($backup_data, 'enabled', 0)); $how_many = (int) array_var($backup_data, 'how_many_backups', 5); ConfigOptions::setValue('backup_how_many_backups', $how_many < 0 ? 5 : $how_many); flash_success('Backup settings have been updated'); $this->redirectTo('admin'); } // if }
/** * Show and process manage categories page * * @param void * @return null */ function index() { $category_definitions = array(); event_trigger('on_master_categories', array(&$category_definitions)); $this->smarty->assign('category_definitions', $category_definitions); if ($this->request->isSubmitted()) { if (is_foreachable($category_definitions)) { foreach ($category_definitions as $category_definition) { $value = $this->request->post($category_definition['name']); if (!is_array($value) || count($value) < 1) { $value = array(lang('General')); } // if ConfigOptions::setValue($category_definition['name'], $value); } // foreach } // if flash_success('Master categories have been updated'); $this->redirectTo('admin'); } // if }
/** * Edit translation file in chosen language * * @param void * @return void */ function edit_translation_file() { if ($this->active_language->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if $translation_id = $this->request->get('filename'); if (!$translation_id) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if $dictionary_filename = Languages::getDictionaryPath($translation_id); if (!is_file($dictionary_filename)) { flash_error('Dictionary does not exists'); $this->redirectToUrl($this->active_language->getViewUrl()); } // if $dictionary = Languages::getDictionary($translation_id); $translation_file = Languages::getTranslationPath($this->active_language, $translation_id); if (!is_file($translation_file)) { flash_error('Translation file does not exists. You need to create it first.'); $this->redirectToUrl($this->active_language->getViewUrl()); } // if $translation_data = Languages::getTranslation($this->active_language, $translation_id); $prepared_form_data = $this->request->post('form_data'); if (!is_array($prepared_form_data)) { $prepared_form_data = array(); foreach ($dictionary as $dictionary_id => $dictionary_value) { $prepared_form_data[$dictionary_id] = array("dictionary_value" => $dictionary_value, "translated_value" => array_var($translation_data, $dictionary_value)); } // foreach $this->smarty->assign(array("prepared_form_data" => $prepared_form_data)); } // if $this->smarty->assign(array("translation_file" => $translation_id, "form_url" => $this->active_language->getEditTranslationFileUrl($translation_id))); if ($this->request->isSubmitted()) { if (is_foreachable($prepared_form_data)) { $new_prepared_data = array(); $translation_data = array(); foreach ($prepared_form_data as $prepared_form_data_key => $prepared_form_data_value) { $translation_data[array_var($dictionary, $prepared_form_data_key)] = $prepared_form_data_value; $new_prepared_data[$prepared_form_data_key] = array("dictionary_value" => array_var($dictionary, $prepared_form_data_key), "translated_value" => $prepared_form_data_value); } // foreach } // if file_put_contents($translation_file, '<?php return ' . var_export($translation_data, true) . ' ?>'); cache_remove_by_pattern('lang_cache_for_*'); if (module_loaded('incoming_mail')) { // set config option for translation if (array_key_exists(EMAIL_SPLITTER, $translation_data)) { $config_option = ConfigOptions::getValue('email_splitter_translations'); $config_option[$this->active_language->getLocale()] = $translation_data[EMAIL_SPLITTER]; ConfigOptions::setValue('email_splitter_translations', $config_option); } // if } // if $this->smarty->assign(array("prepared_form_data" => $new_prepared_data)); } // if }
/** * Set specific role as default role * * @param void * @return null */ function set_as_default() { if ($this->request->isSubmitted()) { if ($this->active_role->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if ($this->active_role->getType() == ROLE_TYPE_PROJECT) { $this->httpError(HTTP_ERR_INVALID_PROPERTIES); } // if ConfigOptions::setValue('default_role', $this->active_role->getId()); flash_success(':name role has been set as default', array('name' => $this->active_role->getName())); $this->redirectTo('admin_roles'); } else { $this->httpError(HTTP_ERR_BAD_REQUEST); } // if }
/** * Set invoice number generator pattern * * @param string $pattern * @return boolean */ function setInvoiceNumberGeneratorPattern($pattern) { return ConfigOptions::setValue('invoicing_number_pattern', $pattern); }
<?php /** * Tasks file that is executed every day * * @package activeCollab * @subpackage tasks */ require_once dirname(__FILE__) . '/init.php'; echo 'Daily event started on ' . strftime(FORMAT_DATETIME) . ".\n"; event_trigger('on_daily'); ConfigOptions::setValue('last_daily_activity', time()); echo 'Daily event finished on ' . strftime(FORMAT_DATETIME) . ".\n";
/** * Save company details info * * @param void * @return void */ function index() { $brand_path = PUBLIC_PATH . '/brand'; $default_image_name = 'invoicing_logo.jpg'; $default_full_image_name = $brand_path . '/' . $default_image_name; if (!folder_is_writable($brand_path)) { $brand_folder_writable = false; $this->wireframe->addPageMessage(lang('Brand folder is not writable (:brand_folder). You will not be able to upload company logo.', array('brand_folder' => $brand_path)), PAGE_MESSAGE_WARNING); } // if $company_data = $this->request->post('company'); if (!is_foreachable($company_data)) { $company_data = array('name' => ConfigOptions::getValue('invoicing_company_name'), 'details' => ConfigOptions::getValue('invoicing_company_details')); } // if if ($this->request->isSubmitted()) { $errors = new ValidationErrors(); db_begin_work(); $company_name = trim(array_var($company_data, 'name')); $company_details = trim(array_var($company_data, 'details')); if (!$company_name || !$company_details) { if (!$company_name) { $errors->addError(lang('Company name is required'), 'company_name'); } // if if (!$company_details) { $errors->addError(lang('Company details are required'), 'company_details'); } // if } else { // copy and convert logo $logo_file = array_var($_FILES, 'company_logo', null); if ($logo_file['name']) { $pathinfo = pathinfo($logo_file['name']); do { $new_filename = make_string(30) . '.' . array_var($pathinfo, 'extension'); $new_file_full_path = $brand_path . '/' . $new_filename; } while (is_file($new_file_full_path)); if (move_uploaded_file($logo_file['tmp_name'], $new_file_full_path)) { if (FIX_UPLOAD_PERMISSION !== false) { @chmod($new_file_full_path, FIX_UPLOAD_PERMISSION); } // if scale_image($new_file_full_path, $new_file_full_path, 600, 150, IMAGETYPE_JPEG, 100); } else { $errors->addError(lang('Could not upload company logo'), 'company_logo'); } // if } // if $company_logo_url = get_company_invoicing_logo_url(); db_commit(); } // if if (!$errors->hasErrors()) { // set config options ConfigOptions::setValue('invoicing_company_name', $company_name); ConfigOptions::setValue('invoicing_company_details', $company_details); @unlink($default_full_image_name); rename($new_file_full_path, $default_full_image_name); flash_success('Company identity successfully modified'); $this->redirectTo('admin_invoicing_company_identity'); db_commit(); } else { @unlink($new_file_full_path); db_rollback(); $this->smarty->assign('errors', $errors); } // if } // if $company_logo_url = get_company_invoicing_logo_url(); $this->smarty->assign(array('company_data' => $company_data, 'company_logo_url' => $company_logo_url)); }
<?php /** * Tasks file that is executed frequently * * @package activeCollab * @subpackage tasks */ require_once dirname(__FILE__) . '/init.php'; echo 'Frequently event started on ' . strftime(FORMAT_DATETIME) . ".\n"; event_trigger('on_frequently'); ConfigOptions::setValue('last_frequently_activity', time()); echo 'Frequently event finished on ' . strftime(FORMAT_DATETIME) . ".\n";