コード例 #1
0
 /**
  * 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
 }
コード例 #2
0
 /**
  * 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) . '.');
 }
コード例 #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);
}
コード例 #5
0
 /**
  * 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));
 }
コード例 #6
0
 /**
  * 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));
 }
コード例 #7
0
 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
 }
コード例 #8
0
 /**
  * Return the number of option in category that logged user can see
  *
  * @param boolean $include_system_options Include system options
  * @return integer
  */
 function countOptions($include_system_options = false)
 {
     if (is_null($this->count_config_options)) {
         $this->count_config_options = ConfigOptions::countOptionsByCategory($this, $include_system_options);
     }
     // if
     return $this->count_config_options;
 }
コード例 #9
0
 /**
  * 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();
 }
コード例 #10
0
 /**
  * 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;
 }
コード例 #11
0
 static function countSinceLastVisit(IUser $user)
 {
     $query = self::getDBQuery($user, 100, ConfigOptions::getValueFor('fmn_last_visited', $user));
     if ($query) {
         $result = DB::execute($query);
         if ($result instanceof DBResult) {
             return $result->count();
         }
         // if
     } else {
         return 0;
     }
 }
コード例 #12
0
 function install()
 {
     if (!ConfigOptions::exists('frosso_auth_my_pub_key')) {
         ConfigOptions::addOption('frosso_auth_my_pub_key', FROSSO_AUTH_MODULE, '');
     }
     if (!ConfigOptions::exists('frosso_auth_my_pri_key')) {
         ConfigOptions::addOption('frosso_auth_my_pri_key', FROSSO_AUTH_MODULE, '');
     }
     if (!ConfigOptions::exists('frosso_auth_my_pri_token')) {
         ConfigOptions::addOption('frosso_auth_my_pri_token', FROSSO_AUTH_MODULE, 'token');
     }
     parent::install();
 }
コード例 #13
0
 /**
  * Index page action
  */
 function index()
 {
     ConfigOptions::setValueFor('fmn_last_visited', $this->logged_user, new DateTimeValue());
     // Popup
     if ($this->request->isAsyncCall()) {
         $this->setView(array('template' => 'popup', 'controller' => 'frosso_mail_notify', 'module' => FROSSO_MAILN_MODULE));
         // $this->response->assign(array(
         // 'mail_updates' => time(),
         // ));
     } else {
         // $this->response->forbidden();
     }
     // if
 }
コード例 #14
0
 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');
     }
 }
コード例 #15
0
/**
 * 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);
}
コード例 #16
0
 /**
  * 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
 }
コード例 #17
0
 /**
  * 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
 }
コード例 #18
0
 /**
  * Set value of $name config option for a given project
  *
  * @param string $name
  * @param mixed $value
  * @param Project $project
  * @return mixed
  */
 function setValue($name, $value, $project)
 {
     $option = ConfigOptions::findByName($name, PROJECT_CONFIG_OPTION);
     if (instance_of($option, 'ConfigOption')) {
         $table = TABLE_PREFIX . 'project_config_options';
         $count = db_execute_one("SELECT COUNT(*) AS 'row_num' FROM {$table} WHERE project_id = ? AND name = ?", $project->getId(), $name);
         if (isset($count) && $count['row_num'] > 0) {
             $result = db_execute("UPDATE {$table} SET value = ? WHERE project_id = ? AND name = ?", serialize($value), $project->getId(), $name);
         } else {
             $result = db_execute("INSERT INTO {$table} (project_id, name, value) VALUES (?, ?, ?)", $project->getId(), $name, serialize($value));
         }
         // if
         return $result && !is_error($result) ? $value : $result;
     } else {
         return new InvalidParamError('name', $name, "Project configuration option '{$name}' does not exist", true);
     }
     // if
 }
コード例 #19
0
/**
 * 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
}
コード例 #20
0
 /**
  * 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
 }
コード例 #21
0
/**
 * 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);
}
コード例 #22
0
 /**
  * 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));
 }
コード例 #23
0
/**
 * 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);
}
コード例 #24
0
 /**
  * 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
 }
コード例 #25
0
/**
 * 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);
}
コード例 #26
0
 /**
  * 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));
 }
コード例 #27
0
ファイル: SiteHelper.php プロジェクト: bogiesoft/yii-travel
 public static function getConfig($key)
 {
     $configModel = ConfigOptions::fetchByKeyWord($key);
     if ($configModel && $configModel->id > 0) {
         return $configModel->value;
     }
     return false;
 }
コード例 #28
0
 /**
  * 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);
     }
 }
コード例 #29
0
 /**
  * This function will return paginated result. Result is an array where first element is 
  * array of returned object and second populated pagination object that can be used for 
  * obtaining and rendering pagination data using various helpers.
  * 
  * Items and pagination array vars are indexed with 0 for items and 1 for pagination
  * because you can't use associative indexing with list() construct
  *
  * @access public
  * @param array $arguments Query argumens (@see find()) Limit and offset are ignored!
  * @param integer $items_per_page Number of items per page
  * @param integer $current_page Current page number
  * @return array
  */
 function paginate($arguments = null, $items_per_page = 10, $current_page = 1)
 {
     if (isset($this) && instance_of($this, 'ConfigOptions')) {
         return parent::paginate($arguments, $items_per_page, $current_page);
     } else {
         return ConfigOptions::instance()->paginate($arguments, $items_per_page, $current_page);
         //$instance =& ConfigOptions::instance();
         //return $instance->paginate($arguments, $items_per_page, $current_page);
     }
     // if
 }
コード例 #30
0
 /**
  * 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));
 }