/**
  * Log user in
  */
 function login()
 {
     $params = $this->request->get('params', false);
     if ($params) {
         $rsa = new Crypt_RSA();
         $my_pub_key = ConfigOptions::getValue('frosso_auth_my_pub_key');
         $my_pri_key = ConfigOptions::getValue('frosso_auth_my_pri_key');
         $rsa->loadKey($my_pri_key);
         $decrypted_params = $rsa->decrypt($params);
         if ($decrypted_params) {
             list($email, $token, $timestamp) = explode(';', $decrypted_params);
             if ($email && $token && $timestamp) {
                 if ($token == ConfigOptions::getValue('frosso_auth_my_pri_token') && time() - 60 * 10 < $timestamp && $timestamp < time() + 60 * 10) {
                     Authentication::useProvider('FrossoProvider', false);
                     Authentication::getProvider()->initialize(array('sid_prefix' => AngieApplication::getName(), 'secret_key' => AngieApplication::getAdapter()->getUniqueKey()));
                     Authentication::getProvider()->authenticate($email);
                 } else {
                     $this->response->forbidden();
                 }
                 // token non valido
             } else {
                 $this->response->badRequest(array('message' => 'Parametri non '));
             }
             // parametri non validi
         } else {
             $this->response->badRequest(array('message' => 'Parametri non validi'));
         }
     } else {
         $this->response->badRequest(array('message' => 'Parametri non settati'));
     }
     // parametri non settati
 }
 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
 }
示例#3
0
 public static function handleOnAfterInit()
 {
     // only allow GET requests
     if ($_SERVER['REQUEST_METHOD'] != 'GET' || defined('USE_FLASH') && (flash_get('success') != NULL || flash_get('error') != NULL)) {
         return;
     }
     $etagEnabled = ConfigOptions::getValue('three_o_four_etag_enabled');
     $cacheEnabled = ConfigOptions::getValue('three_o_four_response_cache_enabled');
     $engineEnabled = $etagEnabled || $cacheEnabled;
     if (!$engineEnabled) {
         return;
     }
     $request = self::_getRequest();
     $request->three_o_four_emit_etag = $etagEnabled;
     if ($cacheEnabled && isset(self::$_routeMap[$request->matched_route])) {
         $cacheOpts = self::$_routeMap[$request->matched_route];
         //$request->three_o_four_cache_response = self::_isCacheableRequest($request);
         $request->three_o_four_cache_response = true;
         $request->three_o_four_cache_opts = $cacheOpts;
         if (($cacheData = self::_getFromCache($request)) !== NULL) {
             // if the user has no view permissions, continue request as usual to output the standard 403
             if (self::_checkPermissions($cacheData, $request)) {
                 self::_sendResponse($cacheData['content'], $cacheData['contentLength'], $cacheData['etag'], $cacheData['headers']);
                 exit;
             }
         }
     }
     $application = application();
     $application->events_manager->listen('on_shutdown', 'onShutdown', THREE_O_FOUR_MODULE);
     ob_start();
     $request->three_o_four_buffering_started = true;
 }
/**
 * Render select_default_assignment_filter control
 * 
 * Parameters:
 * 
 * - user - User - User using the page
 * - value - integer - ID of selected filter
 * - optional - boolean - Value is optional?
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_default_assignment_filter($params, &$smarty)
{
    $user = array_var($params, 'user', null, true);
    $value = array_var($params, 'value', null, true);
    $optional = array_var($params, 'optional', true, true);
    $default_filter_id = (int) ConfigOptions::getValue('default_assignments_filter');
    $default_filter = $default_filter_id ? AssignmentFilters::findById($default_filter_id) : null;
    $options = array();
    if (instance_of($default_filter, 'AssignmentFilter') && $optional) {
        $options[] = option_tag(lang('-- System Default (:filter) --', array('filter' => $default_filter->getName())), '');
    }
    // if
    $grouped_filters = AssignmentFilters::findGrouped($user, true);
    if (is_foreachable($grouped_filters)) {
        foreach ($grouped_filters as $group_name => $filters) {
            $group_options = array();
            foreach ($filters as $filter) {
                $group_options[] = option_tag($filter->getName(), $filter->getId(), array('selected' => $value == $filter->getId()));
            }
            // foreach
            if (count($options) > 0) {
                $options[] = option_tag('', '');
            }
            // if
            $options[] = option_group_tag($group_name, $group_options);
        }
        // foreach
    }
    // if
    return select_box($options, $params);
}
 /**
  * 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));
 }
 /**
  * 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));
 }
 /**
  * Index action
  */
 function index()
 {
     $rsa = new Crypt_RSA();
     $rsa->loadKey(ConfigOptions::getValue('frosso_auth_my_pub_key'));
     $text = 'frosso@remedia.it;' . ConfigOptions::getValue('frosso_auth_my_pri_token', false) . ';' . time();
     $crypt = $rsa->encrypt($text);
     echo '<textarea cols="200">' . $crypt . "</textarea>";
     echo '<br/><textarea cols="200">' . urlencode($crypt) . "</textarea>";
     $this->response->badRequest();
 }
 /**
  * Controller constructor
  *
  */
 function __construct($request)
 {
     parent::__construct($request);
     $this->backup_enabled = (bool) ConfigOptions::getValue('backup_enabled');
     $this->how_many_backups = (int) ConfigOptions::getValue('backup_how_many_backups');
     $total_size = dir_size(UPLOAD_PATH);
     $total_size += dir_size(PUBLIC_PATH . '/avatars');
     $total_size += dir_size(PUBLIC_PATH . '/projects_icons');
     $total_size += dir_size(PUBLIC_PATH . '/logos');
     $total_size += backup_module_calculate_database_size(TABLE_PREFIX) * 1.1685;
     $existing_backups = backup_module_get_backups(BACKUP_PATH);
     $this->smarty->assign(array('backup_admin_url' => assemble_url('backup_admin'), 'backup_enabled' => $this->backup_enabled, 'backup_how_many_backups' => $this->how_many_backups, 'total_size' => $total_size, 'backup_dir_size' => dir_size(BACKUP_PATH), 'existing_backups' => $existing_backups));
 }
 /**
  * generate pdf
  *
  * @param Invoice $invoice
  * @return InvoicePdfGenerator
  */
 function preparePDF(&$invoice)
 {
     $owner_company = get_owner_company();
     $generator = new InvoicePdfGenerator($invoice, $owner_company);
     $generator->paper_format = ConfigOptions::getValue('invoicing_pdf_paper_format');
     $generator->paper_orientation = ConfigOptions::getValue('invoicing_pdf_paper_orientation');
     $generator->setHeaderFontColor('#' . ConfigOptions::getValue('invoicing_pdf_header_text_color'));
     $generator->setBodyFontColor('#' . ConfigOptions::getValue('invoicing_pdf_page_text_color'));
     $generator->setBorderColor('#' . ConfigOptions::getValue('invoicing_pdf_border_color'));
     $generator->setBackgroundColor('#' . ConfigOptions::getValue('invoicing_pdf_background_color'));
     $generator->FontFamily = 'freesans';
     return $generator;
 }
 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');
     }
 }
/**
 * Render select language box
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_language($params, &$smarty)
{
    $default_language_id = ConfigOptions::getValue('language');
    $value = $default_language_id;
    if (array_key_exists('value', $params)) {
        $value = $params['value'];
        unset($params['value']);
    }
    // if
    $optional = false;
    if (array_key_exists('optional', $params)) {
        $optional = (bool) $params['optional'];
        unset($params['optional']);
    }
    $default_language = null;
    $languages = Languages::findAll();
    if (is_foreachable($languages)) {
        foreach ($languages as $language) {
            if ($language->getId() == $default_language_id) {
                $default_language = $language;
            }
            // if
        }
        // foreach
    }
    // if
    $options = array();
    if ($optional) {
        if (instance_of($default_language, 'Language')) {
            $options[] = option_tag(lang('-- System Default (:value) --', array('value' => $default_language->getName())), '');
        } else {
            $options[] = option_tag(lang('-- None --'), '');
        }
        // if
        $options[] = option_tag('', '');
    }
    // if
    if (is_foreachable($languages)) {
        foreach ($languages as $language) {
            $option_attributes = $language->getId() == $value ? array('selected' => true) : null;
            $options[] = option_tag($language->getName(), $language->getId(), $option_attributes);
        }
        // foreach
    }
    // if
    return select_box($options, $params);
}
 /**
  * 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
 }
/**
 * Return value of a given config option
 * 
 * Output of this helper is not cleaned!
 *
 * @param array $params
 * @param Smarty $smarty
 * @return mixed
 */
function smarty_function_config_option($params, &$smarty)
{
    $name = array_var($params, 'name');
    if (empty($name)) {
        return new InvalidParamError('name', $name, '$name value is required');
    }
    // if
    if (isset($params['user']) && instance_of($params['user'], 'User')) {
        return UserConfigOptions::getValue($name, $params['user']);
        //    } elseif(isset($params['project']) && instance_of($params['project'], 'Project')) {
        //      return ProjectConfigOptions::getValue($name, $params['project']);
    } elseif (isset($params['company']) && instance_of($params['company'], 'Company')) {
        return CompanyConfigOptions::getValue($name, $params['company']);
    } else {
        return ConfigOptions::getValue($name);
    }
    // if
}
 /**
  * Show dashboard overview
  *
  * @param void
  * @return null
  */
 function index()
 {
     // Welcome message, displayed only to administrators
     if ($this->logged_user->isAdministrator() && ConfigOptions::getValue('show_welcome_message')) {
         $this->wireframe->addPageAction(lang('Hide Welcome Message'), assemble_url('admin_settings_hide_welcome_message'), null, array('method' => 'post', 'confirm' => lang('You are about to hide welcome message. If you wish to bring it back later on you can do it from General settings page in Administration. Hide now?')));
         $this->smarty->assign(array('show_welcome_message' => true, 'available_modules' => Modules::findNotInstalled()));
         //BOF: task 05 | AD
         $this->wireframe->addPageAction(lang('View All'), assemble_url('view_projects_info'));
         //EOF: task 05 | AD
         // Regular dashboard
     } else {
         if (Project::canAdd($this->logged_user)) {
             $this->wireframe->addPageAction(lang('New Project'), assemble_url('projects_add'));
             //BOF: task 05 | AD
             $this->wireframe->addPageAction(lang('View All'), assemble_url('view_projects_info'));
             //EOF: task 05 | AD
         }
         // if
         $this->wireframe->addRssFeed($this->owner_company->getName() . ' - ' . lang('Recent activities'), assemble_url('rss', array('token' => $this->logged_user->getToken(true))), FEED_RSS);
         $pinned_project_ids = PinnedProjects::findProjectIdsByUser($this->logged_user);
         if (is_foreachable($pinned_project_ids)) {
             $pinned_projects = Projects::findByIds($pinned_project_ids);
         } else {
             $pinned_projects = null;
         }
         // if
         $dashboard_sections = new NamedList();
         event_trigger('on_dashboard_sections', array(&$dashboard_sections, &$this->logged_user));
         $important_items = new NamedList();
         event_trigger('on_dashboard_important_section', array(&$important_items, &$this->logged_user));
         $this->smarty->assign(array('show_welcome_message' => false, 'important_items' => $important_items, 'pinned_projects' => $pinned_projects, 'dashboard_sections' => $dashboard_sections, 'online_users' => Users::findWhoIsOnline($this->logged_user), 'grouped_activities' => group_by_date(ActivityLogs::findActiveProjectsActivitiesByUser($this->logged_user, 20), $this->logged_user)));
     }
     // if
     //BOF:mod 20110623
     $tabs = new NamedList();
     $tabs->add('dashboard', array('text' => 'Active Teams', 'url' => assemble_url('dashboard')));
     $tabs->add('home_page', array('text' => 'Home Page', 'url' => assemble_url('goto_home_tab')));
     $tabs->add('assigned_action_request', array('text' => 'Assigned Action Requests', 'url' => assemble_url('assigned_action_request')));
     $tabs->add('owned_tickets', array('text' => 'Owned Tickets', 'url' => assemble_url('my_tickets')));
     $tabs->add('subscribed_tickets', array('text' => 'Subscribed Tickets', 'url' => assemble_url('my_subscribed_tickets')));
     $this->smarty->assign('page_tabs', $tabs);
     $this->smarty->assign('page_tab', 'dashboard');
     //EOF:mod 20110623
 }
 /**
  * List all roles
  *
  * @param void
  * @return null
  */
 function index()
 {
     $system_roles = array();
     $project_roles = array();
     $all_roles = Roles::findAll();
     if (is_foreachable($all_roles)) {
         foreach ($all_roles as $role) {
             if ($role->getType() == ROLE_TYPE_PROJECT) {
                 $project_roles[] = $role;
             } else {
                 $system_roles[] = $role;
             }
             // if
         }
         // foreach
     }
     // if
     $this->smarty->assign(array('system_roles' => $system_roles, 'project_roles' => $project_roles, 'default_role_id' => ConfigOptions::getValue('default_role')));
 }
/**
 * Render select theme widget
 * 
 * Parameters:
 * 
 * - optional
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_theme($params, &$smarty)
{
    $themes = array();
    if (!defined('THEMES_PATH')) {
        define('THEMES_PATH', ENVIRONMENT_PATH . '/' . PUBLIC_FOLDER_NAME . '/assets/themes');
    }
    // if
    $d = dir(THEMES_PATH);
    if ($d) {
        while (($entry = $d->read()) !== false) {
            if (str_starts_with($entry, '.')) {
                continue;
            }
            // if
            if (is_dir(THEMES_PATH . '/' . $entry)) {
                $themes[] = $entry;
            }
            // if
        }
        // while
        $value = null;
        if (array_key_exists('value', $params)) {
            $value = array_var($params, 'value');
            unset($params['value']);
        }
        // if
    }
    // if
    $optional = array_var($params, 'optional', false, true);
    $options = array();
    if ($optional) {
        $options[] = option_tag(lang('-- System Default (:theme) --', array('theme' => ConfigOptions::getValue('theme'))), '');
        $options[] = option_tag('', '');
    }
    // if
    foreach ($themes as $theme) {
        $option_attributes = $value == $theme ? array('selected' => true) : null;
        $options[] = option_tag($theme, $theme, $option_attributes);
    }
    // foreach
    return select_box($options, $params);
}
 /**
  * Main page in administration for Incoming Mail
  *
  */
 function index()
 {
     $config_admin_email = ConfigOptions::getValue('notifications_from_email');
     $notifications_email = $config_admin_email ? $config_admin_email : ADMIN_EMAIL;
     $default_mailbox = IncomingMailboxes::findByFromEmail($notifications_email);
     $add_default_mailbox_url = assemble_url('incoming_mail_admin_add_mailbox', array('default_email_address' => $notifications_email));
     if (!instance_of($default_mailbox, 'IncomingMailbox')) {
         $this->wireframe->addPageMessage(lang('System is not able to receive email messages sent as replies to notifications. If you would like your users to be able to reply to notifications and have their messages automatically submitted as comments please <a href=":add_default_mailbox_url">define an incoming mailbox</a> for <strong>:address</strong>.', array('address' => $notifications_email, 'add_default_mailbox_url' => $add_default_mailbox_url)), PAGE_MESSAGE_WARNING);
     } elseif (!$default_mailbox->getEnabled()) {
         $this->wireframe->addPageMessage(lang('System is not able to receive email messages sent as replies to notifications. If you would like your users to be able to reply to notifications and have their messages automatically submitted as comments please <a href=":edit_default_mailbox_url">enable default incoming mailbox</a>.', array('edit_default_mailbox_url' => $default_mailbox->getEditUrl())), PAGE_MESSAGE_WARNING);
     }
     // if
     if (!MM_CAN_DOWNLOAD_LARGE_ATTACHMENTS) {
         $limited_filesize = format_file_size(FAIL_SAFE_IMAP_ATTACHMENT_SIZE_MAX);
         if (!function_exists('imap_savebody')) {
             $this->wireframe->addPageMessage(lang("<b>Your PHP version is obsolete</b> - You won't be able to download attachments larger than <b>:file_size</b>. Please upgrade to latest stable version of PHP to solve this issue.", array('file_size' => $limited_filesize)), PAGE_MESSAGE_WARNING);
         } else {
             $this->wireframe->addPageMessage(lang("Importing attachments larger than <b>:file_size</b> is disabled. Module uses failsafe IMAP functions due to platform restrictions.", array('file_size' => $limited_filesize)), PAGE_MESSAGE_WARNING);
         }
         // if
     }
     // if
     use_model('incoming_mail_activity_logs', INCOMING_MAIL_MODULE);
     $per_page = 50;
     // mailbox activity per page
     $page = (int) $this->request->get('page');
     if ($page < 1) {
         $page = 1;
     }
     // if
     $only_problematic = (bool) array_var($_GET, 'only_problematic', false);
     if ($only_problematic) {
         list($activity_history, $pagination) = IncomingMailActivityLogs::paginateConflicts($page, $per_page);
     } else {
         list($activity_history, $pagination) = IncomingMailActivityLogs::paginate(array('order' => 'created_on DESC'), $page, $per_page);
     }
     // if
     $activity_history = group_by_date($activity_history);
     $this->smarty->assign(array('mailboxes' => IncomingMailboxes::find(), 'activity_history' => $activity_history, 'pagination' => $pagination, 'only_problematic' => $only_problematic));
 }
/**
 * Render select datetime format widget
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_datetime_format($params, &$smarty)
{
    $e = DIRECTORY_SEPARATOR == '\\' ? '%d' : '%e';
    // Windows does not support %e
    $presets = array('date' => array("%b {$e}. %Y", "%a, %b {$e}. %Y", "{$e} %b %Y", "%Y/%m/{$e}", "%m/{$e}/%Y"), 'time' => array('%I:%M %p', '%H:%M'));
    $mode = 'date';
    if (array_key_exists('mode', $params)) {
        $mode = $params['mode'];
        unset($params['mode']);
    }
    // if
    $value = null;
    if (array_key_exists('value', $params)) {
        $value = $params['value'];
        unset($params['value']);
    }
    // if
    $optional = false;
    if (array_key_exists('optional', $params)) {
        $optional = (bool) $params['optional'];
        unset($params['optional']);
    }
    // if
    $reference_time = new DateTimeValue('2007-11-21 20:45:15');
    $options = array();
    if ($optional) {
        $default_format = ConfigOptions::getValue("format_{$mode}");
        $default_value = strftime($default_format, $reference_time->getTimestamp());
        $options[] = option_tag(lang('-- System Default (:value) --', array('value' => $default_value)), '');
        $options[] = option_tag('', '');
    }
    // if
    foreach ($presets[$mode] as $v) {
        $option_attributes = $v === $value ? array('selected' => true) : null;
        $options[] = option_tag(strftime($v, $reference_time->getTimestamp()), $v, $option_attributes);
    }
    // foreach
    return select_box($options, $params);
}
/**
 * Render select project template widget
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_project_template($params, &$smarty)
{
    $options = array(option_tag(lang('-- Create a Blank Project --'), ''), option_tag('', ''));
    $value = array_var($params, 'value', null, true);
    $projects_loaded = false;
    $group_id = ConfigOptions::getValue('project_templates_group');
    if ($group_id) {
        $group = ProjectGroups::findById($group_id);
        if (instance_of($group, 'ProjectGroup')) {
            $projects = Projects::findByGroup($group);
            $projects_loaded = true;
            if (is_foreachable($projects)) {
                foreach ($projects as $project) {
                    $option_attributes = $project->getId() == $value ? array('selected' => true) : null;
                    $options[] = option_tag($project->getName(), $project->getId(), $option_attributes);
                }
                // if
            }
            // if
        }
        // if
    }
    // if
    if (!$projects_loaded) {
        $projects = Projects::findNamesByUser($smarty->get_template_vars('logged_user'));
        if (is_foreachable($projects)) {
            foreach ($projects as $k => $v) {
                $option_attributes = $k == $value ? array('selected' => true) : null;
                $options[] = option_tag($v, $k, $option_attributes);
            }
            // foreach
        }
        // if
    }
    // if
    return select_box($options, $params);
}
 /**
  * Construct method
  *
  * @param string $request
  * @return PublicSubmitController
  */
 function __construct($request)
 {
     parent::__construct($request);
     if (!ConfigOptions::getValue('public_submit_enabled')) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $this->setLayout(array("module" => PUBLIC_SUBMIT_MODULE, "layout" => 'wireframe'));
     $this->active_project = Projects::findById(ConfigOptions::getValue('public_submit_default_project'));
     if (!instance_of($this->active_project, 'Project')) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     // check if captcha is enabled, and if it is, check that GD library is loaded
     $this->captcha_enabled = (bool) ConfigOptions::getValue('public_submit_enable_captcha');
     if ($this->captcha_enabled) {
         if (!(extension_loaded('gd') || extension_loaded('gd2')) || !function_exists('imagefttext')) {
             $this->captcha_enabled = false;
         }
         // if
     }
     // if
     $this->smarty->assign(array("active_project" => $this->active_project, "submit_ticket_url" => assemble_url('public_submit'), 'captcha_enabled' => $this->captcha_enabled));
 }
示例#21
0
/**
 * do daily backup
 *
 * @param null
 * @return null
 */
function backup_handle_on_daily()
{
    set_time_limit(0);
    $start_time = time();
    if (!ConfigOptions::getValue('backup_enabled')) {
        return true;
    }
    // if
    // check if backup path exists and if it's writable
    recursive_mkdir(BACKUP_PATH, 0777, WORK_PATH);
    if (!is_dir(BACKUP_PATH) || !folder_is_writable(BACKUP_PATH)) {
        backup_module_log_error('Backup path (' . BACKUP_PATH . ') does not exists or it is not writable', BACKUP_MODULE_SEND_ERROR_EMAIL);
        return false;
    }
    // if
    $htaccess = BACKUP_PATH . '/.htaccess';
    if (!is_file($htaccess)) {
        file_put_contents($htaccess, 'Deny from all');
    }
    $folder_name = "backup " . date('Y-m-d H-i') . " GMT";
    $backup_dir = BACKUP_PATH . '/' . $folder_name;
    // check if backup already exists
    if (is_dir($backup_dir)) {
        backup_module_log_error("Backup already exists ({$folder_name})", BACKUP_MODULE_SEND_ERROR_EMAIL);
        return false;
    }
    // if
    // try to create backup directory
    if (!recursive_mkdir($backup_dir, 0777, WORK_PATH)) {
        backup_module_log_error("Could not create backup folder ({$backup_dir})", BACKUP_MODULE_SEND_ERROR_EMAIL);
        return false;
    }
    // if
    chmod($backup_dir, 0777);
    // backup database (all tables that starts with TABLE_PREFIX)
    $tables = db_list_tables(TABLE_PREFIX);
    if (is_foreachable($tables)) {
        $result = db_dump_tables($tables, $backup_dir . '/database.sql');
        if (is_error($result)) {
            safe_delete_dir($backup_dir, BACKUP_PATH);
            backup_module_log_error($result->getMessage(), BACKUP_MODULE_SEND_ERROR_EMAIL);
            return false;
        }
        // if
    } else {
        safe_delete_dir($backup_dir, BACKUP_PATH);
        backup_module_log_error("Database specified in config.php file does not have exportable tables. Check your config settings", BACKUP_MODULE_SEND_ERROR_EMAIL);
        return false;
    }
    // backup uploads
    $errors = array();
    $result = backup_module_copy_dir(UPLOAD_PATH, $backup_dir . '/upload', true, $errors);
    if (!$result) {
        safe_delete_dir($backup_dir, BACKUP_PATH);
        backup_module_log_error($errors, BACKUP_MODULE_SEND_ERROR_EMAIL);
        return false;
    }
    // if
    // backup project icons
    $errors = array();
    $result = backup_module_copy_dir(PUBLIC_PATH . '/projects_icons', $backup_dir . '/projects_icons', true, $errors);
    if (!$result) {
        safe_delete_dir($backup_dir, BACKUP_PATH);
        backup_module_log_error($errors, BACKUP_MODULE_SEND_ERROR_EMAIL);
        return false;
    }
    // if
    // backup avatars
    $errors = array();
    $result = backup_module_copy_dir(PUBLIC_PATH . '/avatars', $backup_dir . '/avatars', true, $errors);
    if (!$result) {
        safe_delete_dir($backup_dir, BACKUP_PATH);
        backup_module_log_error($errors, BACKUP_MODULE_SEND_ERROR_EMAIL);
        return false;
    }
    // if
    // backup logos
    $errors = array();
    $result = backup_module_copy_dir(PUBLIC_PATH . '/logos', $backup_dir . '/logos', true, $errors);
    if (!$result) {
        safe_delete_dir($backup_dir, BACKUP_PATH);
        backup_module_log_error($errors, BACKUP_MODULE_SEND_ERROR_EMAIL);
        return false;
    }
    // if
    $app =& application();
    $checksum = backup_module_calculate_checksum($folder_name);
    $backup_note = "<?php \n/* \n";
    $backup_note .= 'Backup is created with activeCollab v' . $app->version . ' on ' . date(DATETIME_MYSQL, $start_time) . "\n\n";
    $backup_note .= "To restore system using this backup, visit this page: \n" . ROOT_URL . '/restore.php?backup=' . urlencode($folder_name) . '&checksum=' . $checksum;
    $backup_note .= "\n*/\n?>";
    if (!file_put_contents($backup_dir . '/restore_instructions.php', $backup_note)) {
        safe_delete_dir($backup_dir, BACKUP_PATH);
        backup_module_log_error("Could not create restore instructions for backup.", BACKUP_MODULE_SEND_ERROR_EMAIL);
        return false;
    }
    // if
    // remove old backups
    $how_many_backups = ConfigOptions::getValue('backup_how_many_backups');
    $how_many_backups = (int) $how_many_backups <= 0 ? 5 : $how_many_backups;
    $folders_in_backup_directory = backup_module_get_backups(BACKUP_PATH);
    if (count($folders_in_backup_directory) > $how_many_backups) {
        $old_backups = array_splice($folders_in_backup_directory, -(count($folders_in_backup_directory) - $how_many_backups));
        foreach ($old_backups as $old_backup) {
            safe_delete_dir($old_backup['path'], BACKUP_PATH);
        }
        // foreach
    }
    // if
    log_message('Daily backup created', LOG_LEVEL_INFO, 'backup');
}
 /**
  * Connect mailer instance
  *
  * @param void
  * @return boolean
  */
 function connect()
 {
     if ($this->connected) {
         return true;
     }
     // if
     require_once ANGIE_PATH . '/classes/swiftmailer/init.php';
     $mailing = ConfigOptions::getValue('mailing');
     // Create native connection
     if ($mailing == MAILING_NATIVE) {
         require_once SWIFTMAILER_LIB_PATH . '/Swift/Connection/NativeMail.php';
         $options = trim(ConfigOptions::getValue('mailing_native_options'));
         if (empty($options)) {
             $options = null;
         }
         // if
         $this->swift = new Swift(new Swift_Connection_NativeMail($options));
         // Create SMTP connection
     } elseif ($mailing == MAILING_SMTP) {
         require_once SWIFTMAILER_LIB_PATH . '/Swift/Connection/SMTP.php';
         $smtp_host = ConfigOptions::getValue('mailing_smtp_host');
         $smtp_port = ConfigOptions::getValue('mailing_smtp_port');
         $smtp_auth = ConfigOptions::getValue('mailing_smtp_authenticate');
         $smtp_user = ConfigOptions::getValue('mailing_smtp_username');
         $smtp_pass = ConfigOptions::getValue('mailing_smtp_password');
         $smtp_security = ConfigOptions::getValue('mailing_smtp_security');
         switch ($smtp_security) {
             case 'tsl':
                 $smtp_enc = SWIFT_SMTP_ENC_TLS;
                 break;
             case 'ssl':
                 $smtp_enc = SWIFT_SMTP_ENC_SSL;
                 break;
             default:
                 $smtp_enc = SWIFT_SMTP_ENC_OFF;
         }
         // switch
         $smtp = new Swift_Connection_SMTP($smtp_host, $smtp_port, $smtp_enc);
         if ($smtp_auth) {
             $smtp->setUsername($smtp_user);
             $smtp->setPassword($smtp_pass);
         }
         // if
         $this->swift = new Swift($smtp);
         // Not supported!
     } else {
         return new InvalidParamError('mailing', $mailer, "Unknown mailing type: '{$mailing}' in configuration", true);
     }
     // if
     // Set logger
     if (DEBUG >= DEBUG_DEVELOPMENT) {
         Swift_ClassLoader::load("Swift_Log_AngieLog");
         $logger = new Swift_Log_AngieLog();
         $logger->setLogLevel(SWIFT_LOG_EVERYTHING);
         Swift_LogContainer::setLog($logger);
     }
     // if
     return $this->swift;
 }
 /**
  * Constructor
  *
  * @param Request $request
  * @return ApplicationController
  */
 function __construct($request)
 {
     parent::__construct($request);
     // Set detault layout for application pages
     $this->setLayout(array('module' => SYSTEM_MODULE, 'layout' => 'wireframe'));
     // Get Smarty instance... We need it
     $this->smarty =& Smarty::instance();
     // Load and init owner company
     $this->owner_company = get_owner_company();
     if (instance_of($this->owner_company, 'Company')) {
         cache_set('owner_company', $this->owner_company);
     } else {
         $this->httpError(HTTP_ERR_NOT_FOUND, 'Owner company is not defined');
     }
     // if
     $this->application =& application();
     $this->authentication =& Authentication::instance();
     $this->logged_user =& $this->authentication->provider->getUser();
     $this->wireframe =& Wireframe::instance();
     $this->wireframe->page_company = $this->owner_company;
     $this->theme_name = instance_of($this->logged_user, 'User') ? UserConfigOptions::getValue('theme', $this->logged_user) : ConfigOptions::getValue('theme');
     $this->smarty->assign(array('root_url' => ROOT_URL, 'assets_url' => ASSETS_URL));
     // Maintenance mode
     if (ConfigOptions::getValue('maintenance_enabled')) {
         if (instance_of($this->logged_user, 'User') && $this->logged_user->isAdministrator()) {
             $this->wireframe->addPageMessage(lang('System is in maintenance mode and can be used by administrators only. <a href=":url">Click here</a> to turn off maintenance mode', array('url' => assemble_url('admin_settings_maintenance'))), 'warning');
         } else {
             $additional_error_info = ConfigOptions::getValue('maintenance_message');
             if ($additional_error_info) {
                 $additional_error_info .= "\n\n";
             }
             // if
             $additional_error_info .= lang('When system is in maintenance mode, administrators can log in and access the system') . ": " . assemble_url('login');
             $this->smarty->assign('additional_error_info', $additional_error_info);
             if ($this->restrict_access_in_maintenance_mode) {
                 $this->httpError(503);
             }
             // if
         }
         // if
     }
     // if
     // Check permissions
     if ($this->login_required && !instance_of($this->logged_user, 'User')) {
         // If async don't redirect to loging, just server proper HTTP code
         if ($this->request->isAsyncCall()) {
             $this->httpError(HTTP_ERR_UNAUTHORIZED, null, true, true);
             // Not async? Redirect to login with extracted route data...
         } else {
             $params = array();
             if ($request->matched_route != 'login') {
                 $params['re_route'] = $request->matched_route;
                 foreach ($this->request->url_params as $k => $v) {
                     if ($k == 'module' || $k == 'controller' || $k == 'action') {
                         continue;
                     }
                     // if
                     $params["re_{$k}"] = $v;
                 }
                 // foreach
             }
             // if
             $this->redirectTo($this->login_route, $params);
         }
         // if
     }
     // if
     if (instance_of($this->logged_user, 'User') && !$this->logged_user->getSystemPermission('system_access')) {
         $this->authentication->provider->logUserOut();
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $loaded_modules = $this->application->getModules();
     $assets_query_string = 'v=' . $this->application->version . '&modules=';
     foreach ($loaded_modules as $loaded_module) {
         $assets_query_string .= $loaded_module->getName() . ',';
     }
     // foreach
     $this->smarty->assign(array('api_status' => API_STATUS, 'application' => $this->application, 'owner_company' => $this->owner_company, 'authentication' => $this->authentication, 'logged_user' => $this->logged_user, 'request' => $this->request, 'theme_name' => $this->theme_name, 'request_time' => $this->request_time, 'loaded_modules' => $this->application->getModules(), 'captcha_url' => ROOT_URL . '/captcha.php?id=' . md5(time()), 'assets_query_string' => $assets_query_string, 'js_disabled_url' => assemble_url('js_disabled')));
     $this->smarty->assign_by_ref('wireframe', $this->wireframe);
     js_assign(array('homepage_url' => ROOT_URL, 'assets_url' => ASSETS_URL, 'indicator_url' => get_image_url('indicator.gif'), 'big_indicator_url' => get_image_url('indicator_big.gif'), 'ok_indicator_url' => get_image_url('ok_indicator.gif'), 'warning_indicator_url' => get_image_url('warning_indicator.gif'), 'error_indicator_url' => get_image_url('error_indicator.gif'), 'pending_indicator_url' => get_image_url('pending_indicator.gif'), 'url_base' => URL_BASE, 'keep_alive_interval' => KEEP_ALIVE_INTERVAL, 'refresh_session_url' => assemble_url('refresh_session'), 'jump_to_project_url' => assemble_url('jump_to_project_widget'), 'quick_add_url' => assemble_url('quick_add'), 'path_info_through_query_string' => PATH_INFO_THROUGH_QUERY_STRING, 'image_picker_url' => assemble_url('image_picker'), 'copyright_removed' => LICENSE_COPYRIGHT_REMOVED, 'custom_tabs_manager' => assemble_url('custom_tabs_manager'), 'add_milestone_url' => assemble_url('project_milestones_add', array('project_id' => '--PROJECT_ID--')), 'add_checklist_url' => assemble_url('project_checklists_add', array('project_id' => '--PROJECT_ID--')), 'add_discussion_url' => assemble_url('project_discussions_add', array('project_id' => '--PROJECT_ID--')), 'add_file_url' => assemble_url('project_files_upload', array('project_id' => '--PROJECT_ID--')), 'add_page_url' => assemble_url('project_pages_add', array('project_id' => '--PROJECT_ID--')), 'add_ticket_url' => assemble_url('project_tickets_add', array('project_id' => '--PROJECT_ID--')), 'add_timerecord_url' => assemble_url('project_time_add', array('project_id' => '--PROJECT_ID--')), 'attachment_rename_url' => assemble_url('attachment_rename', array('project_id' => '--PROJECT_ID--', 'attachment_id' => '--ATTACHMENT_ID--')), 'attachment_copy_to_url' => assemble_url('attachment_copy_to', array('project_id' => '--PROJECT_ID--', 'attachment_id' => '--ATTACHMENT_ID--')), 'attachment_move_to_url' => assemble_url('attachment_move_to', array('project_id' => '--PROJECT_ID--', 'attachment_id' => '--ATTACHMENT_ID--')), 'image_uploader_url' => assemble_url('image_uploader'), 'render_comments_url' => assemble_url('render_comments'), 'move_task_url' => assemble_url('project_task_move', array('project_id' => '--PROJECT_ID--', 'task_id' => '--TASK_ID--')), 'get_collection_url' => assemble_url('collection'), 'quick_task_reminder_url' => assemble_url('project_task_quickreminder', array('project_id' => '--PROJECT_ID--', 'task_id' => '--TASK_ID--')), 'convert_to_ticket_url' => assemble_url('project_object_convert_to_ticket', array('project_id' => '--PROJECT_ID--', 'object_id' => '--OBJECT_ID--')), 'convert_to_milestone_url' => assemble_url('project_object_convert_to_milestone', array('project_id' => '--PROJECT_ID--', 'object_id' => '--OBJECT_ID--')), 'convert_to_page_url' => assemble_url('project_object_convert_to_page', array('project_id' => '--PROJECT_ID--', 'object_id' => '--OBJECT_ID--')), 'snooze_task_url' => assemble_url('project_task_snooze', array('project_id' => '--PROJECT_ID--', 'task_id' => '--TASK_ID--'))));
     if ($this->logged_user) {
         $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
         mysql_select_db(DB_NAME);
         if (!empty($_SESSION['pg_ttl'])) {
             mysql_query("update healingcrystals_user_visited_pages set title='" . mysql_real_escape_string($_SESSION['pg_ttl']) . "' where user_id='" . $this->logged_user->getId() . "' and access_time='" . date('Y-m-d H:i:s', $_SESSION['temp_time']) . "'");
         }
         $current_url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
         $pos = strpos($_SERVER['QUERY_STRING'], '%2F');
         if ($pos !== false) {
             $max_pages_count_per_user = 50;
             //require_once SMARTY_PATH . '/plugins/function.page_title.php';
             //$current_page_title = smarty_function_page_title(array('default' => 'Projects'));
             //$current_page_title = PageConstruction::getPageTitle();
             $_SESSION['temp_time'] = time();
             mysql_query("insert into healingcrystals_user_visited_pages (user_id, page_url, title, access_time) values ('" . $this->logged_user->getId() . "', '" . $current_url . "', '', '" . date('Y-m-d H:i:s', $_SESSION['temp_time']) . "')");
             //mysql_query("insert into healingcrystals_user_visited_pages (user_id, page_url, title, access_time) values ('" . $this->logged_user->getId() . "', '" . $current_url . "', '', now())");
             $query = "select count(*) as count from healingcrystals_user_visited_pages where user_id='" . $this->logged_user->getId() . "'";
             $result = mysql_query($query);
             $info = mysql_fetch_assoc($result);
             $current_count = $info['count'];
             if ($current_count > $max_pages_count_per_user) {
                 $querries = array();
                 $query = "select * from healingcrystals_user_visited_pages where user_id='" . $this->logged_user->getId() . "' order by access_time limit 0, " . ($current_count - $max_pages_count_per_user);
                 $result = mysql_query($query);
                 while ($info = mysql_fetch_assoc($result)) {
                     $querries[] = "delete from healingcrystals_user_visited_pages where user_id='" . $this->logged_user->getId() . "' and page_url='" . $info['page_url'] . "' and access_time='" . $info['access_time'] . "'";
                 }
             }
             foreach ($querries as $query) {
                 mysql_query($query);
             }
         }
         $_SESSION['pg_ttl'] = '';
         mysql_close($link);
     }
 }
 /**
  * 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
 }
示例#25
0
/**
 * Send error log to administrator
 *
 * @param array $errors
 * @return boolean
 */
function backup_module_log_error($errors, $send_email = false)
{
    $log_message = is_foreachable($errors) ? implode("\n", $errors) : $errors;
    if ($send_email) {
        $mailer =& ApplicationMailer::mailer();
        $recipient = new Swift_Address();
        $recipient->setAddress(ADMIN_EMAIL);
        $recipient->setName('activeCollab admin');
        $sender = new Swift_Address();
        $sender->setAddress(ConfigOptions::getValue('notifications_from_email'));
        $sender->setName(ConfigOptions::getValue('notifications_from_name'));
        $tmp_message = "Automatic backup of activeCollab on " . ROOT_URL . " failed.\n\r";
        $tmp_message .= "Backup returned these errors: \n\r\n\r";
        $tmp_message .= $log_message;
        $message = new Swift_Message();
        $message->setSubject('activeCollab automatic backup error log');
        $message->setData($tmp_message);
        $message->setContentType('text/plain');
        $mailer->send($message, $recipient, $sender);
    }
    // if
    log_message($log_message, LOG_LEVEL_ERROR, 'backup');
}
 /**
  * Draws invoice header
  * 
  * @param null
  * @return null
  */
 function drawInvoiceHeaderBlock()
 {
     //  remember starting coordinates
     $starting_y = $this->GetY();
     $starting_x = $this->GetX();
     $company_image = get_company_invoicing_logo_path();
     if (is_file($company_image)) {
         $this->Image($company_image, $this->GetX(), $this->GetY(), null, 20);
     }
     // if
     $max_y1 = $this->getImageRBY();
     $this->SetX($starting_x);
     $this->SetY($starting_y);
     // draws company details
     $rgb = $this->convertHTMLColorToDec($this->getHeaderFontColor());
     $this->SetTextColor($rgb['R'], $rgb['G'], $rgb['B']);
     $company_name = ConfigOptions::getValue('invoicing_company_name');
     if (!$company_name) {
         $company_name = $this->owner_company->getName();
     }
     // if
     $company_details = ConfigOptions::getValue('invoicing_company_details');
     if (!$company_details) {
         $company_details = '';
         if ($this->owner_company->getConfigValue('office_address')) {
             $company_details .= "\n" . $this->owner_company->getConfigValue('office_address');
         }
         // if
         if ($this->owner_company->getConfigValue('office_phone')) {
             $company_details .= "\n" . $this->owner_company->getConfigValue('office_phone');
         }
         // if
         if ($this->owner_company->getConfigValue('office_fax')) {
             $company_details .= "\n" . $this->owner_company->getConfigValue('office_fax');
         }
         // if
         if ($this->owner_company->getConfigValue('office_homepage')) {
             $company_details .= "\n" . $this->owner_company->getConfigValue('office_homepage');
         }
         // if
     }
     // if
     $this->SetFont('', 'B', $this->font_size);
     $this->Cell(0, $this->line_height, $company_name, 0, 0, 'R');
     $this->Ln();
     $this->SetX($x);
     $this->SetFont('', '', $this->font_size);
     $this->MultiCell(0, $this->line_height, $company_details, 0, 'R', false, 1, '', '', true, 0, false, 1.25);
     $max_y2 = $this->GetY();
     $this->SetX($starting_x);
     $this->SetY(max($max_y1, $max_y2));
 }
/**
 * Handle on_master_categories event
 *
 * @param array $categories
 * @return null
 */
function tickets_handle_on_master_categories(&$categories)
{
    $categories[] = array('name' => 'ticket_categories', 'label' => lang('Ticket categories'), 'value' => ConfigOptions::getValue('ticket_categories'), 'module' => TICKETS_MODULE, 'controller' => 'tickets');
}
 /**
  * Show role details
  *
  * @param void
  * @return null
  */
 function role()
 {
     $role_id = $this->request->getId('role_id');
     if ($role_id) {
         $role = Roles::findById($role_id);
         if (instance_of($role, 'Role')) {
             if ($role->getType() == ROLE_TYPE_SYSTEM) {
                 $default_role_id = ConfigOptions::getValue('default_role');
                 $serve_as = 'system_role';
                 $role_data = array('id' => $role->getId(), 'name' => $role->getName(), 'is_default' => $role->getId() == $default_role_id, 'permissions' => array());
                 $system_permissions = Permissions::findSystem();
                 foreach ($system_permissions as $permission) {
                     $role_data['permissions'][$permission] = (bool) $role->getPermissionValue($permission, false);
                 }
                 // foreach
             } else {
                 $serve_as = 'project_role';
                 $role_data = array('id' => $role->getId(), 'name' => $role->getName(), 'permissions' => array());
                 foreach (array_keys(Permissions::findProject()) as $permission) {
                     $role_data['permissions'][$permission] = (int) $role->getPermissionValue($permission, 0);
                 }
                 // foreach
             }
             // if
             $this->serveData($role_data, $serve_as);
         }
         // if
     }
     // if
     $this->httpError(HTTP_ERR_NOT_FOUND);
 }
/**
 * Handle on_master_categories event
 *
 * @param array $categories
 * @return null
 */
function pages_handle_on_master_categories(&$categories)
{
    $categories[] = array('name' => 'pages_categories', 'label' => lang('Pages categories'), 'value' => ConfigOptions::getValue('pages_categories'), 'module' => PAGES_MODULE, 'controller' => 'pages');
}
示例#30
0
    ini_set("error_reporting", "");
    require ROOT . '/angie.php';
    require ANGIE_PATH . '/init.php';
    $application =& application();
    $application->prepare(array('initialize_resources' => true, 'connect_to_database' => true, 'initialize_smarty' => true, 'init_modules' => true, 'authenticate' => true, 'init_locale' => true, 'load_hooks' => true));
    //array
    $application->init();
    include_once WEBDAV_MODULE_PATH . '/models/authenticate.php';
    $not_installed_modules = Modules::findNotInstalled();
    foreach ($not_installed_modules as $module) {
        if ($module->name == 'webdav') {
            header("HTTP/1.1 503 Service Unavailable");
            die('Module is not installed');
        }
    }
    if (!ConfigOptions::getValue('webdav_enabled')) {
        header("HTTP/1.1 503 Service Unavailable");
        die('Module has been disabled by administrator');
    }
    //if
    // Activate if your PHP is CGI mode
    $phpcgi = 0;
    $realm = 'activeCollab webdav area';
    $user = AuthenticationBasicHTTP($realm);
    require_once WEBDAV_MODULE_PATH . '/models/filesystem.php';
    $server = new HTTP_WebDAV_Server_Filesystem();
    $server->ServeRequest(false, $user);
} else {
    header("HTTP/1.1 503 Service Unavailable");
    die;
}