/**
 * Render object tasks section
 * 
 * Parameters:
 * 
 * - object - Selected project object
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_object_tasks($params, &$smarty)
{
    $object = array_var($params, 'object');
    if (!instance_of($object, 'ProjectObject')) {
        return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true);
    }
    // if
    $open_tasks = $object->getOpenTasks();
    if (is_foreachable($open_tasks)) {
        foreach ($open_tasks as $open_task) {
            ProjectObjectViews::log($open_task, $smarty->get_template_vars('logged_user'));
        }
        // foreach
    }
    // if
    $completed_tasks = $object->getCompletedTasks(COMPLETED_TASKS_PER_OBJECT);
    if (is_foreachable($completed_tasks)) {
        foreach ($completed_tasks as $completed_task) {
            ProjectObjectViews::log($completed_task, $smarty->get_template_vars('logged_user'));
        }
        // foreach
    }
    // if
    $smarty->assign(array('_object_tasks_object' => $object, '_object_tasks_open' => $open_tasks, '_object_tasks_can_reorder' => (int) $object->canEdit($smarty->get_template_vars('logged_user')), '_object_tasks_completed' => $completed_tasks, '_object_tasks_completed_remaining' => $object->countCompletedTasks() - COMPLETED_TASKS_PER_OBJECT, '_object_tasks_skip_wrapper' => array_var($params, 'skip_wrapper', false), '_object_tasks_skip_head' => array_var($params, 'skip_head', false), '_object_tasks_force_show' => array_var($params, 'force_show', true)));
    return $smarty->fetch(get_template_path('_object_tasks', 'tasks', RESOURCES_MODULE));
}
 /**
  * Fuehrt die einzelnen Methoden aus, abhaengig vom parameter
  *
  * @param array $parameters POST, GET und COOKIE-Variablen
  */
 public function action($gpc)
 {
     //Daten initialisieren
     $this->_gpc = $gpc;
     $this->_nav_id = $this->_smarty->get_template_vars('local_link');
     $this->_view();
     return true;
 }
Beispiel #3
0
 /**
  * Returns an array containing template variables
  *
  * @param string $name
  * @return array
  */
 public function get_template_vars($name = null)
 {
     if ($this->_smarty instanceof Smarty) {
         return $this->_smarty->get_template_vars($name);
     } else {
         if (!empty($this->_smartyMethods['assign'])) {
             $method = $this->_smartyMethods['assign'];
             $assigned = array();
             for ($a = 0; $a < count($method); $a++) {
                 if (count($method[$a]) > 1) {
                     $assigned[$method[$a][0]] = $method[$a][1];
                 } elseif (is_array($method[$a][0])) {
                     while (list($key, $val) = each($method[$a][0])) {
                         $assigned[$key] = $val;
                     }
                 }
             }
             if (null === $name) {
                 return $assigned;
             } elseif (isset($assigned[$name])) {
                 return $assigned[$name];
             }
         }
     }
     return null;
 }
/**
 * List object comments
 * 
 * Parameters:
 * 
 * - object - Parent object. It needs to be an instance of ProjectObject class
 * - comments - List of comments. It is optional. If it is missing comments 
 *   will be loaded by calling getCommetns() method of parent object
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_object_comments_all($params, &$smarty)
{
    $object = array_var($params, 'object');
    if (!instance_of($object, 'ProjectObject')) {
        return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true);
    }
    // if
    $logged_user = $smarty->get_template_vars('logged_user');
    if (!instance_of($logged_user, 'User')) {
        return '';
    }
    // if
    $visiblity = $logged_user->getVisibility();
    //    if ($object->canView($logged_user) && $object->getVisibility() == VISIBILITY_PRIVATE) {
    if ($object->canView($logged_user)) {
        $visiblity = VISIBILITY_PRIVATE;
    }
    $comments = $object->getComments($visiblity);
    if (is_foreachable($comments)) {
        foreach ($comments as $comment) {
            ProjectObjectViews::log($comment, $logged_user);
            //BOF:task_1260
            $comment->set_action_request_n_fyi_flag($logged_user);
            //EOF:task_1260
        }
        // foreach
    }
    // if
    $count_from = 0;
    $smarty->assign(array('_object_comments_object' => $object, '_object_comments_count_from' => $count_from, '_object_comments_comments' => $comments, '_total_comments' => sizeof($comments)));
    return $smarty->fetch(get_template_path('_object_comments_all', 'comments', RESOURCES_MODULE));
}
 /**
  * Schickt das Kontrollmail an den Sender, um sicherzugehen, dass die Sender-Adresse wirklich existiert
  *
  * @param int $mod_navID Nav-ID des Moduls
  */
 private function _checkmail_send($mod_navID)
 {
     $mail_vars = $this->_config_textes['Mail'];
     /* nav_id angegeben? */
     if (!key_exists('nav_id', $this->_gpc['GET'])) {
         throw new CMSException(array('mail' => 'param_navid'), EXCEPTION_MODULE_CODE, "", array('mail' => 'param_missing'));
     }
     /* darf modul mit nav_id mail senden? */
     if ($this->_get_tabledata($mod_navID) == false) {
         throw new CMSException(array('mail' => 'modul_no_mail'), EXCEPTION_MODULE_CODE, array('mail' => 'no_support'));
     }
     if ($this->_check_mailtable() == false) {
         throw new CMSException(array('mail' => 'no_matching_table1'), EXCEPTION_MODULE_CODE, array('mail' => 'no_matching_table2'));
     }
     if (isset($this->_gpc['POST']['btn_send']) && $this->_gpc['POST']['btn_send'] == 'Senden') {
         /*Formular wurde gesendet */
         //Formular-Kontrolle
         if ($this->_gpc['POST']['entry_id'] != $this->_gpc['GET']['entry_id']) {
             throw new CMSException(array('mail' => 'wrong_form'), EXCEPTION_MODULE_CODE, array('mail' => 'data_collaps'));
         }
         //Benutzung einfacher Variablen
         $title = $this->_gpc['POST']['title'];
         $content = $this->_gpc['POST']['content'];
         $name = $this->_gpc['POST']['name'];
         $email = $this->_gpc['POST']['email'];
         $entry_id = $this->_gpc['POST']['entry_id'];
         /* Formular kontrollieren */
         $answer = array();
         $success = $this->_check_form($answer);
         if ($success == true) {
             /*Mail schicken*/
             $navigation_id = $this->_smarty->get_template_vars('local_link');
             $this->_mysql->query("SELECT `{$this->mail_tbl['column_name']}`, `{$this->mail_tbl['column_email']}` FROM `{$this->mail_tbl['table']}` WHERE `{$this->mail_tbl['column_ID']}` = '{$entry_id}'");
             $mail_reciver = $this->_mysql->fetcharray('assoc');
             $mail_reciver_name = $mail_reciver[$this->mail_tbl['column_name']];
             $mail_reciver_email = $mail_reciver[$this->mail_tbl['column_email']];
             $mail = new Mailsend();
             $mailsend_controll = $mail->mail_send_link($this->_mysql, $mail_reciver_name, $mail_reciver_email, $name, $email, $title, $content);
             if ($mailsend_controll == true) {
                 /* Erfolgreich gespeichert */
                 $this->_send_feedback($mail_vars['saved_title'], $mail_vars['saved_content'], "?nav_id={$navigation_id}", $mail_vars['send_link']);
             } else {
                 /* Fehler bei der Speicherung */
                 $this->_send_feedback($mail_vars['failer_save_title'], $mail_vars['failer_save_content'], "?nav_id={$navigation_id}", $mail_vars['send_link']);
             }
         } else {
             /* Fehler im Formular */
             $this->_send_entryform(false, $answer);
         }
     } else {
         /* Kein Formular abgeschickt */
         //Captcha zurücksetzen
         if (key_exists('captcha_revoke', $this->_gpc['POST'])) {
             $first_form = false;
         } else {
             $first_form = true;
         }
         $this->_send_entryform($first_form);
     }
 }
 /**
  * Kommentarfunktion dieser Klasse
  *
  */
 private function _comment()
 {
     $gbook_vars = $this->_configvars['Gbook'];
     $this->_initCaptcha();
     if (isset($this->_gpc['POST']['btn_send']) && $this->_gpc['POST']['btn_send'] == 'Senden') {
         /*Formular wurde gesendet */
         /* Formular kontrollieren */
         $answer = array();
         $success = $this->_check_form($answer, array('title'));
         if ($success == true) {
             /*Eintrag machen*/
             $navigation_id = $this->_smarty->get_template_vars('local_link');
             foreach ($answer as $key => $value) {
                 $answer[$key] = stripslashes($value);
             }
             $answer['time'] = "NOW()";
             $this->_msbox->commentEntry((int) $this->_gpc['GET']['ref_ID'], $answer);
             $this->_send_feedback($gbook_vars['allright_title'], $gbook_vars['allright_content'], "?nav_id={$navigation_id}", $gbook_vars['allright_link']);
         } else {
             /* Fehler im Formular */
             $this->_send_entryform(false, implode("<br />\n", $answer), true);
         }
     } else {
         /* Kein Formular abgeschickt */
         //Captcha zurücksetzen
         if (key_exists('captcha_revoke', $this->_gpc['POST'])) {
             $first_form = false;
         } else {
             $first_form = true;
         }
         $this->_send_entryform($first_form, null, true);
     }
 }
/**
 * Render select team control
 * 
 * Params:
 * 
 * - project - Project instance that need to be used
 * - active_only - Return only active milestones, true by default
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_team($params, &$smarty)
{
    $project = array_var($params, 'project');
    if (!instance_of($project, 'Project')) {
        return new InvalidParamError('project', $project, '$project value is expected to be an instance of Project class', true);
    }
    // if
    unset($params['project']);
    $value = null;
    if (isset($params['value'])) {
        $value = $params['value'];
        unset($params['value']);
    }
    // if
    $options = array();
    $logged_user = $smarty->get_template_vars('logged_user');
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
    mysql_select_db(DB_NAME);
    $query = "select a.id, a.name from healingcrystals_projects a inner join healingcrystals_project_users b on (a.id=b.project_id and b.user_id='" . $logged_user->getId() . "') where a.status='active' and a.completed_on is null and b.role_id<>'9' order by a.name";
    $result = mysql_query($query, $link);
    while ($info = mysql_fetch_assoc($result)) {
        if ($info['id'] == $project->getId()) {
            $option_attributes = array('selected' => true);
            $options[] = option_tag(lang($info['name']), $info['id'], $option_attributes);
        } else {
            $options[] = option_tag(lang($info['name']), $info['id']);
        }
    }
    mysql_close($link);
    return select_box($options, $params);
}
Beispiel #8
0
/**
 * smarty_resource_view_source
 *
 * The first function, source() is supposed to retrieve the resource.
 * Its second parameter $tpl_source is a variable passed by reference
 * where the result should be stored. The function is supposed to
 * return TRUE if it was able to successfully retrieve the resource
 * and FALSE otherwise.
 *
 * @param string $tpl_name
 * @param string $tpl_source reference
 * @param object $smarty reference
 * @uses Package::buildPath()
 * @return void
 */
function smarty_resource_view_source($tplName, &$tplSource, Smarty &$smarty)
{
    $templateVars = $smarty->get_template_vars();
    $currentModule = $templateVars['__ZF__']['module'];
    $currentController = $templateVars['__ZF__']['controller'];
    $resourcePath = null;
    if ("login" !== strtolower($currentController) && "static" !== strtolower($currentController) && "admin" !== strtolower($currentModule)) {
        $client = $smarty->get_registered_object('client');
        if (($path = Package::buildPath($smarty->template_dir, 'clients', $client->identifier, 'modules', $currentModule, $currentController, $tplName)) && is_readable($path)) {
            $resourcePath = $path;
        } elseif (($path = Package::buildPath($smarty->template_dir, 'clients', $client->identifier, 'modules', $currentModule, 'default', $tplName)) && is_readable($path)) {
            $resourcePath = $path;
        } elseif (($path = Package::buildPath($smarty->template_dir, 'clients', $client->identifier, 'modules', $currentModule, $tplName)) && is_readable($path)) {
            $resourcePath = $path;
        } elseif (($path = Package::buildPath($smarty->template_dir, 'clients', $client->identifier, 'modules', $tplName)) && is_readable($path)) {
            $resourcePath = $path;
        } elseif (($path = Package::buildPath($smarty->template_dir, 'clients', $client->identifier, $tplName)) && is_readable($path)) {
            $resourcePath = $path;
        }
    }
    if (!$resourcePath) {
        if (($path = Package::buildPath($smarty->template_dir, 'modules', $currentModule, $currentController, $tplName)) && is_readable($path)) {
            $resourcePath = $path;
        } elseif (($path = Package::buildPath($smarty->template_dir, 'modules', $currentModule, 'default', $tplName)) && is_readable($path)) {
            $resourcePath = $path;
        } elseif (($path = Package::buildPath($smarty->template_dir, 'modules', $currentModule, $tplName)) && is_readable($path)) {
            $resourcePath = $path;
        } elseif (($path = Package::buildPath($smarty->template_dir, 'modules', $tplName)) && is_readable($path)) {
            $resourcePath = $path;
        } elseif (($path = Package::buildPath($smarty->template_dir, $tplName)) && is_readable($path)) {
            $resourcePath = $path;
        } else {
            return false;
        }
    }
    if ('admin' == $currentModule && isset($resourcePath)) {
        if ($tpl = $smarty->_read_file($resourcePath)) {
            $tplSource = $tpl;
        }
        return true;
    }
    if ($resourcePath) {
        if ($tpl = $smarty->_read_file($resourcePath)) {
            $tplSource = $tpl;
        }
        // $tplSource = $path;
        /*
        $smarty->_smarty_include(
        	array(
        		'smarty_include_tpl_file'	=> $path,
        		'smarty_include_vars'		=> array()
        	)
        );
        die('we got to here');
        */
        return true;
    }
    return false;
}
Beispiel #9
0
 /**
  * Escapes smarty stored vars for sfData
  *
  * @param sfSmartyView $view
  * @param integer $escaping
  * @return sfOutputEscaper
  */
 private function getSfData($view, $escaping = ESC_RAW)
 {
     $current_sf_data = self::$smarty->get_template_vars('sf_data');
     if (!empty($current_sf_data) && $view->getAttribute('sf_type') == 'partial') {
         if (isset($current_sf_data['sf_content'])) {
             $view->getAttributeHolder()->set('sf_content', $current_sf_data['sf_content']);
         }
     }
     return sfOutputEscaper::escape($escaping, $view->getAttributeHolder()->getAll());
 }
/**
 * with_successive_milestones helper
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_with_successive_milestones($params, &$smarty)
{
    static $counter = 1;
    $name = array_var($params, 'name');
    if (empty($name)) {
        return new InvalidParamError('name', $name, '$name value is required', true);
    }
    // if
    $milestone = array_var($params, 'milestone');
    if (!instance_of($milestone, 'Milestone')) {
        return new InvalidParamError('milestone', $milestone, '$milestone value is expected to be an instance of Milestone class', true);
    }
    // if
    $id = array_var($params, 'id');
    if (empty($id)) {
        $id = 'with_successive_milestones_' . $counter;
        $counter++;
    }
    // if
    $value = array_var($params, 'value');
    $action = array_var($value, 'action', 'dont_move');
    $milestones = array_var($value, 'milestones');
    if (!is_array($milestones)) {
        $milestones = array();
    }
    // if
    $logged_user = $smarty->get_template_vars('logged_user');
    $successive_milestones = Milestones::findSuccessiveByMilestone($milestone, STATE_VISIBLE, $logged_user->getVisibility());
    if (!is_foreachable($successive_milestones)) {
        return '<p class="details">' . lang('This milestone does not have any successive milestones') . '</p>';
    }
    // if
    $result = "<div class=\"with_successive_milestones\">\n<div class=\"options\">\n";
    $options = array('dont_move' => lang("Don't change anything"), 'move_all' => lang('Adjust all successive milestone by the same number of days'), 'move_selected' => lang('Adjust only selected successive milestones by the same number of days'));
    foreach ($options as $k => $v) {
        $radio = radio_field($name . '[action]', $k == $action, array('value' => $k, 'id' => $id . '_' . $k));
        $label = label_tag($v, $id . '_' . $k, false, array('class' => 'inline'), '');
        $result .= '<span class="block">' . $radio . ' ' . $label . "</span>\n";
    }
    // if
    $result .= "</div>\n<div class=\"successive_milestones\">";
    foreach ($successive_milestones as $successive_milestone) {
        $input_attributes = array('name' => $name . '[milestones][]', 'id' => $id . '_milestones_' . $successive_milestone->getId(), 'type' => 'checkbox', 'value' => $successive_milestone->getId(), 'class' => 'auto');
        if (in_array($successive_milestone->getId(), $milestones)) {
            $input_attributes['checked'] = true;
        }
        // if
        $input = open_html_tag('input', $input_attributes, true);
        $label = label_tag($successive_milestone->getName(), $id . '_milestones_' . $successive_milestone->getId(), false, array('class' => 'inline'), '');
        $result .= '<span class="block">' . $input . ' ' . $label . "</span>\n";
    }
    // foreach
    $result .= "</div>\n</div>\n";
    return $result;
}
Beispiel #11
0
/**
 * Smarty {fill_form_values}...{/fill_form_values} extension.
 * Fills in form fields between the tags based on values in Smarty template
 * variables, and shows form errors stored in the template variable
 * "formErrors".
 *
 * @param array $params		Params from smarty template (unused)
 * @param string $content	HTML to filter (it's {...}THIS STUFF{/...}
 * @param Smarty $smarty
 * @return string		$content with form vars set properly.
 */
function smarty_fill_form_values($params, $content, &$smarty)
{
    if ($content === null) {
        return "";
    }
    $vars = $smarty->get_template_vars();
    $errors = array();
    if (array_key_exists('formErrors', $vars)) {
        $errors = $vars['formErrors'];
    }
    return fillInFormValues($content, $vars, $errors);
}
/**
 * Smarty function to display a subview
 * @param array $params
 * @param Smarty $smarty
 * @return string the HTML of a assigned subview
 */
function smarty_function_subview($params, &$smarty)
{
    if (empty($params['name'])) {
        throw new Exception('No name parameter provided for the subview');
    }
    $name = $params['name'];
    $views = $smarty->get_template_vars('_views');
    if (!isset($views[$name]['html'])) {
        return;
    }
    return $views[$name]['html'];
}
/**
 * Render main menu
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_menu($params, &$smarty)
{
    require SYSTEM_MODULE_PATH . '/models/menu/Menu.class.php';
    require SYSTEM_MODULE_PATH . '/models/menu/MenuGroup.class.php';
    require SYSTEM_MODULE_PATH . '/models/menu/MenuItem.class.php';
    $logged_user = $smarty->get_template_vars('logged_user');
    //BOF:task_1260
    $active_project = $smarty->get_template_vars('active_project');
    //EOF:task_1260
    $menu = new Menu();
    //BOF:task_1260
    /*
    //EOF:task_1260
    event_trigger('on_build_menu', array(&$menu, &$logged_user));
    //BOF:task_1260
    */
    event_trigger('on_build_menu', array(&$menu, &$logged_user, &$active_project));
    //EOF:task_1260
    $smarty->assign('_menu', $menu);
    return $smarty->fetch(get_template_path('_menu', null, SYSTEM_MODULE));
}
/**
 * Wrap form field into a DIV
 * 
 * Properties:
 * 
 * - field - field name
 * - errors - errors container (ValidationErrors instance)
 * - show_errors - show errors list inside of field wrapper
 *
 * @param array $params
 * @param string $content
 * @param Smarty $smarty
 * @param boolean $repeat
 * @return null
 */
function smarty_block_wrap($params, $content, &$smarty, &$repeat)
{
    $field = array_var($params, 'field');
    if (empty($field)) {
        return new InvalidParamError('field', $field, "'field' property is required for 'wrap_field' helper", true);
    }
    // if
    $classes = array();
    if (isset($params['class'])) {
        $classes = explode(' ', $params['class']);
        unset($params['class']);
    }
    // if
    if (!in_array('ctrlHolder', $classes)) {
        $classes[] = 'ctrlHolder';
    }
    // if
    $error_messages = null;
    if (isset($params['errors'])) {
        $errors = $params['errors'];
    } else {
        $errors = $smarty->get_template_vars('errors');
    }
    // if
    if (instance_of($errors, 'ValidationErrors')) {
        if ($errors->hasError($field)) {
            $classes[] = 'error';
            $error_messages = $errors->getFieldErrors($field);
        }
        // if
    }
    // if
    $show_errors = array_var($params, 'show_errors', true);
    $listed_errors = '';
    if (is_foreachable($error_messages) && $show_errors) {
        require_once $smarty->_get_plugin_filepath('function', 'field_errors');
        $listed_errors = smarty_function_field_errors(array('field' => $field, 'errors' => $errors), $smarty);
    }
    // if
    $aid = array_var($params, 'aid');
    if ($aid) {
        $aid = '<p class="aid">' . clean(lang($aid)) . '</p>';
    }
    // if
    // Unset helper properties, we need this for attributes
    unset($params['field']);
    unset($params['errors']);
    unset($params['show_errors']);
    unset($params['aid']);
    $params['class'] = implode(' ', $classes);
    return open_html_tag('div', $params) . "\n{$listed_errors}\n" . $content . $aid . "\n</div>";
}
/**
 * Select project group helper
 *
 * Params:
 * 
 * - value - ID of selected group
 * - optional - boolean
 * - can_create_new - Should this select box offer option to create a new 
 *   company from within the list
 * 
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_project_group($params, &$smarty)
{
    static $ids = array();
    $optional = array_var($params, 'optional', true, true);
    $value = array_var($params, 'value', null, true);
    $can_create_new = array_var($params, 'can_create_new', true, true);
    $id = array_var($params, 'id', null, true);
    if (empty($id)) {
        $counter = 1;
        do {
            $id = "select_project_group_dropdown_{$counter}";
            $counter++;
        } while (in_array($id, $ids));
    }
    // if
    $ids[] = $id;
    $params['id'] = $id;
    $groups = ProjectGroups::findAll($smarty->get_template_vars('logged_user'), true);
    if ($optional) {
        $options = array(option_tag(lang('-- None --'), ''), option_tag('', ''));
    } else {
        $options = array();
    }
    // if
    if (is_foreachable($groups)) {
        foreach ($groups as $group) {
            $option_attributes = array('class' => 'object_option');
            if ($value == $group->getId()) {
                $option_attributes['selected'] = true;
            }
            // if
            $options[] = option_tag($group->getName(), $group->getId(), $option_attributes);
        }
        // foreach
    }
    // if
    if ($can_create_new) {
        $params['add_object_url'] = assemble_url('project_groups_quick_add');
        $params['object_name'] = 'project_group';
        $params['add_object_message'] = lang('Please insert new project group name');
        $logged_user = get_logged_user();
        if (instance_of($logged_user, 'User') && ProjectGroup::canAdd($logged_user)) {
            $options[] = option_tag('', '');
            $options[] = option_tag(lang('New Project Group...'), '', array('class' => 'new_object_option'));
        }
        // if
    }
    // if
    return select_box($options, $params) . '<script type="text/javascript">$("#' . $id . '").new_object_from_select();</script>';
}
 /**
  * Fuehrt die einzelnen Methoden aus, abhaengig vom parameter
  *
  * @param array $parameters POST, GET und COOKIE-Variablen
  */
 public function action($gpc)
 {
     //Daten initialisieren
     $this->_gpc['POST'] = $gpc['POST'];
     $this->_gpc['GET'] = $gpc['GET'];
     /* Daten laden */
     $section_load = array('Editor', 'Editor-Entry', 'Editor-Error', 'Menu');
     foreach ($section_load as $section) {
         $this->_smarty->config_load('textes.de.conf', $section);
         $this->_config_textes["{$section}"] = $this->_smarty->get_config_vars();
     }
     $this->_nav_id = $this->_smarty->get_template_vars('local_link');
     if (key_exists('ref_ID', $this->_gpc['GET']) && is_numeric($this->_gpc['GET']['ref_ID'])) {
         $id = (int) $this->_gpc['GET']['ref_ID'];
     }
     //Je nach Get-Parameter die zugehörige Anweisung ausfuehren
     if (key_exists('action', $this->_gpc['GET'])) {
         switch ($this->_gpc['GET']['action']) {
             case 'new':
                 $this->_create();
                 break;
             case 'edit':
                 $this->_edit($id);
                 break;
             case 'del':
                 $this->_del($id);
                 break;
             default:
                 $this->_view();
         }
         return true;
     } else {
         $this->_view();
         return true;
     }
 }
/**
 * Render file revisions resource block
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_file_revisions($params, &$smarty)
{
    $file = array_var($params, 'file');
    if (!instance_of($file, 'File')) {
        return new InvalidParamError('file', $file, '$file is expected to be an instance of File class', true);
    }
    // if
    $revisions = $file->getRevisions();
    if (is_foreachable($revisions)) {
        foreach ($revisions as $revision) {
            ProjectObjectViews::log($revision, $smarty->get_template_vars('logged_user'));
        }
        // foreach
    }
    // if
    $smarty->assign(array('_file' => $file, '_file_revisions' => $revisions, '_file_revisions_count' => is_array($revisions) ? count($revisions) : 1));
    return $smarty->fetch(get_template_path('_file_revisions', 'files', FILES_MODULE));
}
 /**
  * Führt die einzelnen Methoden aus, abhängig vom Parameter
  *
  * @param array $gpc $_POST- und $_GET-Arrays
  * @return boolean
  * @uses Smarty als Template-System
  */
 public function action($gpc)
 {
     //Daten laden
     $this->_smarty->config_load('textes.de.conf', 'Gbook');
     $this->_configvars['Gbook'] = $this->_smarty->get_config_vars();
     $this->_smarty->config_load('textes.de.conf', 'Form_Error');
     $this->_configvars['Error'] = $this->_smarty->get_config_vars();
     $this->_gpc = $gpc;
     $this->_nav_id = $this->_smarty->get_template_vars('local_link');
     $this->_msbox = new MessageBoxes($this->_mysql, 'gbook', array('ID' => 'gbook_ID', 'ref_ID' => 'gbook_ref_ID', 'content' => 'gbook_content', 'name' => 'gbook_name', 'time' => 'gbook_time', 'email' => 'gbook_email', 'hp' => 'gbook_hp', 'title' => 'gbook_title'));
     $this->_smilie = new Smilies(SMILIES_DIR);
     if ($this->_getStatus() == 'off') {
         $this->_smarty->assign('info', $this->_configvars['Gbook']['modul_deactivated']);
     }
     if (key_exists('action', $this->_gpc['GET'])) {
         switch ($this->_gpc['GET']['action']) {
             case 'new':
                 $this->_add();
                 break;
             case 'comment':
                 $this->_comment();
                 break;
             case 'edit':
                 $this->_edit();
                 break;
             case 'del':
                 $this->_del();
                 break;
             case 'view':
                 $this->_view(5);
                 break;
             case '':
                 $this->_view(5);
                 break;
             default:
                 throw new CMSException(array('gbook' => 'invalid_option'), EXCEPTION_MODULE_CODE);
         }
     } else {
         $this->_view(5);
     }
     return true;
 }
/**
 * Render object assignees list
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_object_owner_selector($params, &$smarty)
{
    $object = array_var($params, 'object');
    if (!instance_of($object, 'ProjectObject')) {
        return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true);
    }
    // if
    $language = array_var($params, 'language', $smarty->get_template_vars('current_language'));
    // maybe we need to print this in a specific language?
    $users_table = TABLE_PREFIX . 'users';
    $assignments_table = TABLE_PREFIX . 'assignments';
    $owner_exists = false;
    $rows = db_execute_all("SELECT {$assignments_table}.is_owner AS is_assignment_owner, {$users_table}.id AS user_id, {$users_table}.company_id, {$users_table}.first_name, {$users_table}.last_name, {$users_table}.email FROM {$users_table}, {$assignments_table} WHERE {$users_table}.id = {$assignments_table}.user_id AND {$assignments_table}.object_id = ? ORDER BY {$assignments_table}.is_owner DESC", $object->getId());
    if (is_foreachable($rows)) {
        $owner = null;
        $other_assignees = array();
        $users_dropdown_for_tickets = '';
        foreach ($rows as $row) {
            if ($row['is_assignment_owner']) {
                $owner_exists = true;
            }
            if (empty($users_dropdown_for_tickets)) {
                $users_dropdown_for_tickets = '<select onchange="modify_responsible_status(this);">';
            }
            $users_dropdown_for_tickets .= '<option value="' . $row['user_id'] . '"' . ($row['is_assignment_owner'] ? ' selected ' : '') . '>';
            if (empty($row['first_name']) && empty($row['last_name'])) {
                $users_dropdown_for_tickets .= clean($row['email']);
            } else {
                $users_dropdown_for_tickets .= clean($row['first_name'] . ' ' . $row['last_name']);
            }
            $users_dropdown_for_tickets .= '</option>';
        }
        // foreach
    }
    if ($owner_exists) {
        $users_dropdown_for_tickets .= '</select>';
        $owner = $users_dropdown_for_tickets;
    } else {
        $owner = '--';
    }
    return $owner;
}
 /**
  * Editiert einen Eintrag im Mysql oder liefert das zugehörige Formular.
  *
  */
 private function _edit()
 {
     $news_vars = $this->_config_textes['News'];
     //Eingetragen und überprüfen
     if (isset($this->_gpc['POST']['btn_send']) && $this->_gpc['POST']['btn_send'] == 'Senden') {
         /* Formular kontrollieren */
         $answer = array();
         $success = $this->_check_form($answer);
         if ($success == true) {
             /*Eintrag machen*/
             $navigation_id = $this->_smarty->get_template_vars('local_link');
             $answer['ID'] = $this->_gpc['GET']['ref_ID'];
             //In Datenbank einschreiben
             $this->_msbox->editEntry($answer);
             $this->_send_feedback($news_vars['allright_title'], $news_vars['allright_content'], "?nav_id={$navigation_id}", $news_vars['allright_link']);
         } else {
             $this->_send_entryform(false, implode("<br />\n", $answer), true);
         }
     } else {
         $this->_send_entryform(true, null, false, true);
     }
 }
Beispiel #21
0
function displayChildren(Smarty $smarty, $tree)
{
    $templateVars = $smarty->get_template_vars();
    $currentController = strtolower($templateVars['__ZF__']['controller']);
    $currentAction = strtolower($templateVars['__ZF__']['action']);
    $string = "";
    $string .= '<ul>';
    foreach ($tree as $child) {
        // if it is a root
        if (null === $child->inherits) {
            $string .= '<li>';
            $string .= '<div>' . $child->name . '</div>';
            if (is_array($child->children)) {
                $string .= displayChildren($smarty, $child->children);
            }
            $string .= '</li>';
        } else {
            if (!is_array($child->children)) {
                $string .= '<li>';
                if ("category" === $currentController && $child->identifier === $currentAction) {
                    $string .= '<div class="on">' . $child->name . " (" . $child->howmany . ")" . '</div>';
                } else {
                    $string .= '<a href="/category/' . $child->identifier . '">' . $child->name . " (" . $child->howmany . ")" . '</a>';
                }
                $string .= '</li>';
            } else {
                $string .= '<li>';
                $string .= '<div>' . $child->name . '</div>';
                if (is_array($child->children)) {
                    $string .= displayChildren($smarty, $child->children);
                }
                $string .= '</li>';
            }
        }
    }
    $string .= '</ul>';
    return $string;
}
/**
 * Render object attachments
 * 
 * Parameters:
 * 
 * - object - object which has attachments
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_mobile_access_object_attachments($params, &$smarty)
{
    $object = array_var($params, 'object');
    if (!instance_of($object, 'ProjectObject')) {
        return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true);
    }
    // if
    $logged_user = $smarty->get_template_vars('logged_user');
    if (!instance_of($logged_user, 'User')) {
        return '';
    }
    // if
    $attachments = $object->getAttachments();
    if (is_foreachable($attachments)) {
        foreach ($attachments as $attachment) {
            ProjectObjectViews::log($attachment, $logged_user);
        }
        // foreach
    }
    // if
    $smarty->assign(array('_mobile_access_object_attachments_object' => $object, '_mobile_access_object_attachments' => $attachments));
    return $smarty->fetch(get_template_path('_object_attachments', null, MOBILE_ACCESS_MODULE));
}
/**
 * List object attachments
 * 
 * Parameters:
 * 
 * - object - selected object
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_object_attachments_all($params, &$smarty)
{
    $object = array_var($params, 'object');
    if (!instance_of($object, 'ProjectObject')) {
        return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true);
    }
    // if
    $logged_user = $smarty->get_template_vars('logged_user');
    if (!instance_of($logged_user, 'User')) {
        return '';
    }
    // if
    $attachments = $object->getAttachments();
    if (is_foreachable($attachments)) {
        foreach ($attachments as $attachment) {
            ProjectObjectViews::log($attachment, $logged_user);
        }
        // foreach
    }
    // if
    $smarty->assign(array('_object_attachments_object' => $object, '_object_attachments' => $attachments, '_object_attachments_show_header' => array_var($params, 'show_header', true), '_object_attachments_brief' => array_var($params, 'brief', false), '_object_attachments_show_empty' => array_var($params, 'show_empty', false), '_total_attachments' => sizeof($attachments)));
    return $smarty->fetch(get_template_path('_object_attachments_all', 'attachments', RESOURCES_MODULE));
}
/**
 * Show users local time based on his or hers local settings
 * 
 * Parameters:
 * 
 * - user - User, if NULL logged user will be used
 * - datetime - Datetime value that need to be displayed. If NULL request time 
 *   will be used
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_user_time($params, &$smarty)
{
    $user = array_var($params, 'user');
    if (!instance_of($user, 'User')) {
        $user = get_logged_user();
    }
    // if
    if (!instance_of($user, 'User')) {
        return lang('Unknown time');
    }
    // if
    $value = array_var($params, 'datetime');
    if (!instance_of($value, 'DateValue')) {
        $value = $smarty->get_template_vars('request_time');
    }
    // if
    if (!instance_of($value, 'DateValue')) {
        return lang('Unknown time');
    }
    // if
    require_once SMARTY_PATH . '/plugins/modifier.time.php';
    return clean(smarty_modifier_time($value, get_user_gmt_offset($user)));
}
/**
 * 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);
}
Beispiel #26
0
 /**
  * Allows testing with empty() and isset() to work
  *
  * @param string $key
  * @return boolean
  */
 public function __isset($key)
 {
     return null !== $this->smarty->get_template_vars($key);
 }
Beispiel #27
0
 public function getTemplateVars($var = NULL)
 {
     return $this->_smarty->get_template_vars($var);
 }
 /**
  * Entfernt die Sessionid aus dem Text. Nützlich, falls Bilder eingefügt wurden und die 
  * Sessionid aus der Bild-URL entfernt werden soll, bevor der Text in der Datenbank gespeichert wird.
  * (Eingefügt wird die Session-ID in den Smarty-Templates).
  *
  * @param string $text Text, wo die Session-ID herausgeschnitten werden soll.
  */
 private function _cutSessID($text)
 {
     $sess_id = $this->_smarty->get_template_vars('SID');
     return str_replace($sess_id, "", $text);
 }
/**
 * Render object assignees list
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_object_action_request($params, &$smarty)
{
    $object = array_var($params, 'object');
    if (!instance_of($object, 'ProjectObject')) {
        return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true);
    }
    // if
    $user = array_var($params, 'user');
    $language = array_var($params, 'language', $smarty->get_template_vars('current_language'));
    // maybe we need to print this in a specific language?
    $users_table = TABLE_PREFIX . 'users';
    $assignments_table = TABLE_PREFIX . 'assignments';
    $action_request_table = TABLE_PREFIX . 'assignments_action_request';
    //BOF:task_1260
    /*
    //EOF:task_1260
    $action_request_user_id = '';
    //BOF:task_1260
    */
    $action_request_user_id = array();
    $resp = '';
    /*
    //EOF:task_1260
    $query = db_execute_all("select $action_request_table.user_id from $action_request_table where $action_request_table.object_id=? and is_action_request='1'", $object->getId());
    //BOF:task_1260
    */
    $query = db_execute_all("select distinct {$action_request_table}.user_id from {$action_request_table} inner join healingcrystals_project_objects on {$action_request_table}.comment_id=healingcrystals_project_objects.id where healingcrystals_project_objects.parent_id=? and {$action_request_table}.selected_by_user_id=? and is_action_request='1'", $object->getId(), $user->getId());
    //EOF:task_1260
    if (is_foreachable($query)) {
        foreach ($query as $entry) {
            //BOF:task_1260
            /*
            //EOF:task_1260
            $action_request_user_id = $entry['user_id'];
            //BOF:task_1260
            */
            $action_request_user_id[] = $entry['user_id'];
            //EOF:task_1260
        }
    }
    $rows = db_execute_all("SELECT {$assignments_table}.is_owner AS is_assignment_owner, {$users_table}.id AS user_id, {$users_table}.company_id, {$users_table}.first_name, {$users_table}.last_name, {$users_table}.email FROM {$users_table}, {$assignments_table} WHERE {$users_table}.id = {$assignments_table}.user_id AND {$assignments_table}.object_id = ? ORDER BY {$assignments_table}.is_owner DESC", $object->getId());
    if (is_foreachable($rows)) {
        //BOF:task_1260
        /*
        		//EOF:task_1260
        $users_dropdown_for_tickets = '';
        //BOF:task_1260
        */
        //EOF:task_1260
        foreach ($rows as $row) {
            //BOF:task_1260
            /*
            //EOF:task_1260
            if (empty($users_dropdown_for_tickets)){
            	        	$users_dropdown_for_tickets = '<select onchange="modify_action_request(this);">';
            	        	if (empty($action_request_user_id)){
            	        		$users_dropdown_for_tickets .= '<option value="0">-- Select --</option>';
            	        	}
            	        }
            	        $users_dropdown_for_tickets .= '<option value="' . $row['user_id'] . '"' . ($row['user_id']==$action_request_user_id ? ' selected ' : '') . '>';
                      	if(empty($row['first_name']) && empty($row['last_name'])) {
                        	$users_dropdown_for_tickets .= clean($row['email']);
                      	} else {
                        	$users_dropdown_for_tickets .= clean($row['first_name'] . ' ' . $row['last_name']);
                      	}
            	        $users_dropdown_for_tickets .= '</option>';
            //BOF:task_1260
            */
            if (in_array($row['user_id'], $action_request_user_id)) {
                if (empty($row['first_name']) && empty($row['last_name'])) {
                    $resp .= '<a href="' . assemble_url('project_people', array('project_id' => $object->getProjectId())) . '">' . clean($row['email']) . '</a>, ';
                } else {
                    $resp .= '<a href="' . assemble_url('project_people', array('project_id' => $object->getProjectId())) . '">' . clean($row['first_name'] . ' ' . $row['last_name']) . '</a>, ';
                }
            }
            //EOF:task_1260
        }
        // foreach
    }
    //BOF:task_1260
    /*
    	//EOF:task_1260
    if (!empty($users_dropdown_for_tickets)){
    	if (!empty($action_request_user_id)){
    		$users_dropdown_for_tickets .= '<option value="-1">Unset</option></select>';
    	}
    		$resp = $users_dropdown_for_tickets;
    } else {
    	$$resp = '--';
    }
    //BOF:task_1260
    */
    if (empty($resp)) {
        $resp = '--';
    } else {
        $resp = substr($resp, 0, -2);
    }
    //EOF:task_1260
    return $resp;
}
Beispiel #30
0
 public function __get($key)
 {
     return $this->_smarty->get_template_vars($key);
 }