Ejemplo n.º 1
0
function user_area_sat_access($area_id, $sattelite_id, $user)
{
    $area_access = FALSE;
    $sat_access = FALSE;
    if (user_has_role('Webmaster National', $user)) {
        return TRUE;
    }
    if (!empty($user->field_area['und'])) {
        foreach ($user->field_area['und'] as $value) {
            if ($value['tid'] == $area_id) {
                $area_access = TRUE;
                break;
            }
        }
    }
    if (!empty($user->field_satellite['und'])) {
        foreach ($user->field_satellite['und'] as $value) {
            if ($value['tid'] == $sattelite_id) {
                $sat_access = TRUE;
                break;
            }
        }
    }
    if ($area_access || $sat_access) {
        return TRUE;
    } else {
        return FALSE;
    }
}
Ejemplo n.º 2
0
/**
 * @file
 * The primary PHP file for this theme.
 */
function basukebu_preprocess_page(&$variables)
{
    $js_path = drupal_get_path('theme', 'basukebu') . '/js/';
    if (user_has_role(IS_AUTH_USER)) {
        drupal_add_js($js_path . 'basukebu.sticky_header.js');
    }
}
Ejemplo n.º 3
0
function threadall($lang)
{
    global $system_languages, $with_toolbar;
    if (!user_has_role('writer')) {
        return run('error/unauthorized', $lang);
    }
    $slang = false;
    if (isset($_GET['slang'])) {
        $slang = $_GET['slang'];
    } else {
        $slang = $lang;
    }
    if (!in_array($slang, $system_languages)) {
        return run('error/notfound', $lang);
    }
    $site_title = translate('title', $lang);
    $site_abstract = translate('description', $lang);
    $site_cloud = translate('keywords', $lang);
    head('title', translate('threadall:title', $slang));
    head('description', false);
    head('keywords', false);
    head('robots', 'noindex, nofollow');
    $edit = user_has_role('writer') ? url('threadedit', $_SESSION['user']['locale']) . '?' . 'clang=' . $lang : false;
    $banner = build('banner', $lang, $with_toolbar ? false : compact('edit'));
    $scroll = true;
    $toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'scroll')) : false;
    $threadlist = build('threadlist', $lang, false, false, $slang);
    $content = view('threadall', $slang, compact('site_title', 'site_abstract', 'site_cloud', 'threadlist'));
    $output = layout('viewing', compact('toolbar', 'banner', 'content'));
    return $output;
}
Ejemplo n.º 4
0
function adminuser($lang, $arglist = false)
{
    if (!user_has_role('administrator')) {
        return run('error/unauthorized', $lang);
    }
    $user_id = false;
    if (is_array($arglist)) {
        if (isset($arglist[0])) {
            $user_id = $arglist[0];
        }
    }
    if (!$user_id) {
        return run('error/notfound', $lang);
    }
    $user_id = user_id($user_id);
    if (!$user_id) {
        return run('error/notfound', $lang);
    }
    $useredit = build('useredit', $lang, $user_id);
    if ($useredit === false) {
        return redirect('admin', $lang);
    }
    head('title', translate('admin:title', $lang));
    head('description', false);
    head('keywords', false);
    head('robots', 'noindex, nofollow');
    $admin = true;
    $banner = build('banner', $lang, compact('admin'));
    $content = view('adminuser', $lang, compact('useredit'));
    $output = layout('standard', compact('banner', 'content'));
    return $output;
}
Ejemplo n.º 5
0
function threadsummary($lang, $thread)
{
    global $system_languages, $with_toolbar;
    if (!user_has_role('writer')) {
        return run('error/unauthorized', $lang);
    }
    $slang = false;
    if (isset($_GET['slang'])) {
        $slang = $_GET['slang'];
    } else {
        $slang = $lang;
    }
    if (!in_array($slang, $system_languages)) {
        return run('error/notfound', $lang);
    }
    $thread_id = thread_id($thread);
    if (!$thread_id) {
        return run('error/notfound', $lang);
    }
    $r = thread_get($lang, $thread_id);
    if (!$r) {
        return run('error/notfound', $lang);
    }
    extract($r);
    /* thread_name thread_title thread_type thread_abstract thread_cloud thread_image thread_visits thread_nosearch thread_nocloud thread_nocomment thread_nomorecomment thread_novote thread_nomorevote thread_created thread_modified */
    $thread_search = !$thread_nosearch;
    $thread_tag = !$thread_nocloud;
    $thread_comment = !$thread_nocomment;
    $thread_morecomment = !$thread_nomorecomment;
    $thread_vote = !$thread_novote;
    $thread_morevote = !$thread_nomorevote;
    $thread_contents = array();
    $r = thread_get_contents($lang, $thread_id, false);
    if ($r) {
        $thread_url = url('thread', $lang) . '/' . $thread_id;
        foreach ($r as $c) {
            extract($c);
            /* node_id node_name node_title node_number node_ignored */
            $node_url = $thread_url . '/' . $node_id . '?' . 'slang=' . $slang;
            $thread_contents[] = compact('node_id', 'node_title', 'node_url', 'node_ignored');
        }
    }
    $headline_text = translate('threadall:title', $slang);
    $headline_url = url('thread', $lang) . '?' . 'slang=' . $slang;
    $headline = compact('headline_text', 'headline_url');
    $title = view('headline', false, $headline);
    $sidebar = view('sidebar', false, compact('title'));
    head('title', $thread_title ? $thread_title : $thread_id);
    head('description', $thread_abstract);
    head('keywords', $thread_cloud);
    head('robots', 'noindex, nofollow');
    $edit = user_has_role('writer') ? url('threadedit', $_SESSION['user']['locale']) . '/' . $thread_id . '?' . 'clang=' . $lang : false;
    $banner = build('banner', $lang, $with_toolbar ? compact('headline') : compact('headline', 'edit'));
    $scroll = true;
    $toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'scroll')) : false;
    $content = view('threadsummary', $slang, compact('thread_id', 'thread_title', 'thread_abstract', 'thread_cloud', 'thread_image', 'thread_visits', 'thread_search', 'thread_tag', 'thread_comment', 'thread_morecomment', 'thread_vote', 'thread_morevote', 'thread_ilike', 'thread_tweet', 'thread_plusone', 'thread_linkedin', 'thread_pinit', 'thread_created', 'thread_modified', 'thread_contents'));
    $output = layout('viewing', compact('toolbar', 'banner', 'content', 'sidebar'));
    return $output;
}
 public function skip_stage_conditions($assignment_id, $next_stage_to_check)
 {
     $ci = get_instance();
     $is_technician = user_has_role($ci->session->userdata('user_id'), 'Technician');
     if (!$is_technician) {
         return false;
     }
     return $next_stage_to_check->senior_technician_only && !$this->is_senior_technician($this->current_param);
 }
Ejemplo n.º 7
0
function suggest($lang, $arglist = false)
{
    global $search_all, $rss_thread;
    $cloud = false;
    if (is_array($arglist)) {
        if (isset($arglist[0])) {
            $cloud = $arglist[0];
        }
    }
    $cloud_id = false;
    if ($cloud) {
        $cloud_id = cloud_id($cloud);
        if (!$cloud_id) {
            header('HTTP/1.1 404 Not Found');
            return false;
        }
        if ($cloud_id == $rss_thread) {
            if (!user_has_role('administrator')) {
                header('HTTP/1.1 401 Unauthorized');
                return false;
            }
        }
        $r = thread_get($lang, $cloud_id);
        if (!$r) {
            header('HTTP/1.1 404 Not Found');
            return false;
        }
        extract($r);
        /* thread_type thread_nosearch */
        if ($thread_type == 'thread' or $thread_nosearch) {
            header('HTTP/1.1 404 Not Found');
            return false;
        }
    } else {
        if ($search_all !== true) {
            header('HTTP/1.1 404 Not Found');
            return false;
        }
    }
    $term = isset($arglist['term']) ? $arglist['term'] : false;
    if (!$term) {
        header('HTTP/1.1 400 Bad Request');
        return false;
    }
    $r = cloud_suggest($lang, $cloud_id, $term);
    if (!$r) {
        header('HTTP/1.1 404 Not Found');
        return false;
    }
    $taglist = array();
    foreach ($r as $tag) {
        $taglist[] = $tag['tag_name'];
    }
    return json_encode($taglist);
}
Ejemplo n.º 8
0
function editnode($lang, $arglist = false)
{
    global $supported_languages, $supported_contents, $with_toolbar;
    if (!user_has_role('writer')) {
        return run('error/unauthorized', $lang);
    }
    $node = false;
    if (is_array($arglist)) {
        if (isset($arglist[0])) {
            $node = $arglist[0];
        }
    }
    if (!$node) {
        return run('error/notfound', $lang);
    }
    $node_id = node_id($node);
    if (!$node_id) {
        return run('error/notfound', $lang);
    }
    $clang = false;
    foreach ($supported_languages as $slang) {
        if (isset($_POST[$slang])) {
            $clang = $slang;
            break;
        }
    }
    if (!$clang) {
        if (isset($_POST['clang'])) {
            $clang = $_POST['clang'];
        } else {
            if (isset($_GET['clang'])) {
                $clang = $_GET['clang'];
            } else {
                $clang = $lang;
            }
        }
        if (!in_array($clang, $supported_languages)) {
            return run('error/notfound', $lang);
        }
    }
    $node_editor = build('nodeeditor', $lang, $clang, $node_id, $supported_contents);
    head('title', $node_id);
    head('description', false);
    head('keywords', false);
    head('robots', 'noindex, nofollow');
    $view = url('node', $clang) . '/' . $node_id . '?' . 'slang=' . $lang;
    $banner = build('banner', $lang, $with_toolbar ? false : compact('view'));
    $scroll = true;
    $toolbar = $with_toolbar ? build('toolbar', $lang, compact('view', 'scroll')) : false;
    $content = view('editing/editnode', $lang, compact('node_editor'));
    $output = layout('editing', compact('toolbar', 'banner', 'content'));
    return $output;
}
Ejemplo n.º 9
0
function foldersummary($lang, $folder)
{
    global $with_toolbar;
    $folder_id = thread_id($folder);
    if (!$folder_id) {
        return run('error/notfound', $lang);
    }
    $r = thread_get($lang, $folder_id);
    if (!$r) {
        return run('error/notfound', $lang);
    }
    extract($r);
    /* thread_type thread_name thread_title thread_abstract thread_cloud */
    if ($thread_type != 'folder') {
        return run('error/notfound', $lang);
    }
    $folder_name = $thread_name;
    $folder_title = $thread_title;
    $folder_abstract = $thread_abstract;
    $folder_cloud = $thread_cloud;
    if ($folder_title) {
        head('title', $folder_title);
    }
    if ($folder_abstract) {
        head('description', $folder_abstract);
    }
    if ($folder_cloud) {
        head('keywords', $folder_cloud);
    }
    $folder_contents = array();
    $r = thread_get_contents($lang, $folder_id);
    if ($r) {
        $folder_url = url('folder', $lang) . '/' . $folder_name;
        foreach ($r as $c) {
            extract($c);
            /* node_name node_title */
            if (!$node_title) {
                continue;
            }
            $page_title = $node_title;
            $page_url = $folder_url . '/' . $node_name;
            $folder_contents[] = compact('page_title', 'page_url');
        }
    }
    $content = view('foldersummary', false, compact('folder_id', 'folder_title', 'folder_contents'));
    $edit = user_has_role('writer') ? url('folderedit', $_SESSION['user']['locale']) . '/' . $folder_id . '?' . 'clang=' . $lang : false;
    $validate = url('folder', $lang) . '/' . $folder_name;
    $banner = build('banner', $lang, $with_toolbar ? false : compact('edit', 'validate'));
    $toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'validate')) : false;
    $output = layout('standard', compact('toolbar', 'banner', 'content'));
    return $output;
}
Ejemplo n.º 10
0
function bookall($lang)
{
    global $with_toolbar;
    head('title', translate('bookall:title', $lang));
    $edit = user_has_role('writer') ? url('bookedit', $_SESSION['user']['locale']) . '?' . 'clang=' . $lang : false;
    $validate = url('book', $lang);
    $banner = build('banner', $lang, $with_toolbar ? false : compact('edit', 'validate'));
    $toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'validate')) : false;
    $booklist = build('threadlist', $lang, 'book');
    $content = view('bookall', $lang, compact('booklist'));
    $output = layout('standard', compact('toolbar', 'banner', 'content'));
    return $output;
}
Ejemplo n.º 11
0
function node($lang, $arglist = false)
{
    global $system_languages, $with_toolbar;
    if (!user_has_role('writer')) {
        return run('error/unauthorized', $lang);
    }
    $slang = false;
    if (isset($_GET['slang'])) {
        $slang = $_GET['slang'];
    } else {
        $slang = $lang;
    }
    if (!in_array($slang, $system_languages)) {
        return run('error/notfound', $lang);
    }
    $node = false;
    if (is_array($arglist)) {
        if (isset($arglist[0])) {
            $node = $arglist[0];
        }
    }
    if (!$node) {
        return run('error/notfound', $lang);
    }
    $node_id = node_id($node);
    if (!$node_id) {
        return run('error/notfound', $lang);
    }
    $r = node_get($lang, $node_id);
    if (!$r) {
        return run('error/notfound', $lang);
    }
    extract($r);
    /* node_number node_ignored node_name node_title node_abstract node_cloud node_image node_visits node_nocomment node_nomorecomment node_ilike node_tweet node_plusone node_linkedin node_pinit */
    $node_comment = !$node_nocomment;
    $node_morecomment = !$node_nomorecomment;
    $node_vote = !$node_novote;
    $node_morevote = !$node_nomorevote;
    head('title', $node_id);
    head('description', $node_abstract);
    head('keywords', $node_cloud);
    head('robots', 'noindex, nofollow');
    $edit = user_has_role('writer') ? url('editnode', $_SESSION['user']['locale']) . '/' . $node_id . '?' . 'clang=' . $lang : false;
    $banner = build('banner', $lang, $with_toolbar ? compact('headline') : compact('headline', 'edit'));
    $scroll = true;
    $toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'scroll')) : false;
    $node_contents = build('nodecontent', $lang, $node_id);
    $content = view('node', $slang, compact('node_id', 'node_name', 'node_title', 'node_abstract', 'node_cloud', 'node_image', 'node_created', 'node_modified', 'node_comment', 'node_morecomment', 'node_vote', 'node_morevote', 'node_ilike', 'node_tweet', 'node_plusone', 'node_linkedin', 'node_pinit', 'node_contents'));
    $output = layout('standard', compact('toolbar', 'banner', 'content'));
    return $output;
}
Ejemplo n.º 12
0
 public function index($assignment_id)
 {
     $this->load->model('miniant/diagnostic_tree_model');
     require_capability('servicequotes:writesqs');
     $technician_id = parent::get_technician_id($assignment_id);
     $is_technician = user_has_role($this->session->userdata('user_id'), 'Technician');
     $this->assignment = $this->assignment_model->get($assignment_id);
     if (empty($this->assignment)) {
         add_message('This job is no longer on record.', 'warning');
         redirect(base_url());
     }
     $order = (object) $this->order_model->get_values($this->assignment->order_id);
     $order_type = $this->order_model->get_type_string($order->order_type_id);
     parent::update_time($order->id);
     $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager');
     $this->workflow_manager->initialise(array('workflow' => $order_type, 'stage' => 'required_parts', 'param' => $this->assignment->id, 'module' => 'miniant'));
     if ($technician_id == $order->senior_technician_id) {
         $units = $this->assignment_model->get_units($assignment_id);
     } else {
         $units = $this->assignment_model->get_units($assignment_id, $technician_id);
     }
     $diagnostic_estimate_tree = $this->diagnostic_tree_model->get_estimate_tree($assignment_id);
     $estimated_time = $this->diagnostic_tree_model->get_estimate_time($diagnostic_estimate_tree);
     // We no longer ask the technician to estimate the labour, it is done entirely by the system based on diagnostic rules
     $this->diagnostic_model->edit($this->assignment->diagnostic_id, array('estimated_time' => $estimated_time));
     // Create SQ if none for this job/unit yet
     $sq = $this->servicequote_model->get(array('order_id' => $order->id, 'diagnostic_id' => $this->assignment->diagnostic_id), true);
     if (empty($sq->id)) {
         $sq_id = $this->servicequote_model->create_from_diagnostic($this->assignment->diagnostic_id);
     } else {
         $sq_id = $sq->id;
     }
     // Replace required_parts (loaded from step_parts table) with actual parts (from parts table)
     foreach ($units as $key => $unit) {
         $units[$key]->assignment = (object) $this->assignment_model->get_values($units[$key]->assignment_id);
         $units[$key]->diagnostic = (object) $this->diagnostic_model->get_values($units[$key]->assignment->diagnostic_id);
         // Only provide the SQ ID if this stage has been completed
         if ($this->assignment_model->has_statuses($units[$key]->assignment_id, array('REQUIRED PARTS RECORDED'))) {
             $units[$key]->required_parts = $this->diagnostic_model->get_required_parts($units[$key]->assignment->diagnostic_id, $sq_id);
         } else {
             $units[$key]->required_parts = $this->diagnostic_model->get_required_parts($units[$key]->assignment->diagnostic_id);
         }
         foreach ($units[$key]->required_parts as $part_key => $part) {
             form_element::$default_data["part_model_number[{$part->id}]"] = $part->part_number;
         }
     }
     $parts_title_options = array('title' => '', 'help' => 'Record the parts required this SQ', 'icons' => array());
     $info_title_options = array('title' => 'Unit info', 'help' => 'Information', 'icons' => array());
     $this->load_stage_view(array('units' => $units, 'parts_title_options' => $parts_title_options, 'info_title_options' => $info_title_options, 'diagnostic_id' => $this->assignment->diagnostic_id, 'is_technician' => $is_technician, 'sq_id' => $sq_id));
 }
Ejemplo n.º 13
0
 public function process()
 {
     $assignment_id = $this->input->post('assignment_id');
     $order_id = $this->input->post('order_id');
     $assignment = $this->assignment_model->get($assignment_id);
     $order = $this->order_model->get($order_id);
     $order_type = $this->order_model->get_type_string($order->order_type_id);
     $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager');
     $this->workflow_manager->initialise(array('workflow' => $order_type, 'stage' => 'office_notes', 'param' => $assignment_id, 'module' => 'miniant'));
     if (user_has_role($this->session->userdata('user_id'), 'Technician')) {
         trigger_event('office_notes_sighted', 'order', $order_id, false, 'miniant');
     }
     redirect($this->workflow_manager->get_next_url());
 }
Ejemplo n.º 14
0
function footer($lang, $components = false)
{
    $languages = false;
    $contact_page = $newsletter_page = $user_page = $nobody_page = $account_page = $admin_page = false;
    $is_identified = user_is_identified();
    $is_admin = user_has_role('administrator');
    $nobody_page = $is_identified ? url('nobody', $lang) : false;
    if ($components) {
        foreach ($components as $v => $param) {
            switch ($v) {
                case 'languages':
                    if ($param) {
                        $languages = build('languages', $lang, $param);
                    }
                    break;
                case 'contact':
                    if ($param) {
                        $contact_page = url('contact', $lang);
                    }
                    break;
                case 'newsletter':
                    if ($param) {
                        $newsletter_page = url('newslettersubscribe', $lang);
                    }
                    break;
                case 'account':
                    if ($param) {
                        if ($is_identified) {
                            if (!$is_admin) {
                                $account_page = url('account', $lang);
                            }
                        } else {
                            $user_page = url('user', $lang);
                        }
                    }
                    break;
                case 'admin':
                    if ($param) {
                        $admin_page = $is_admin ? url('admin', $lang) : false;
                    }
                    break;
                default:
                    break;
            }
        }
    }
    $output = view('footer', $lang, compact('languages', 'contact_page', 'newsletter_page', 'user_page', 'nobody_page', 'account_page', 'admin_page'));
    return $output;
}
Ejemplo n.º 15
0
function toolbar($lang, $components = false)
{
    $scroll = $nobody_page = $edit_page = $view_page = $validate_page = $admin_page = false;
    $is_identified = user_is_identified();
    $is_admin = user_has_role('administrator');
    $is_writer = user_has_role('writer');
    if ($components) {
        foreach ($components as $v => $param) {
            switch ($v) {
                case 'scroll':
                    $scroll = $param ? true : false;
                    break;
                case 'edit':
                    if ($param) {
                        if ($is_writer) {
                            $edit_page = $param;
                        }
                    }
                    break;
                case 'view':
                    if ($param) {
                        if ($is_writer) {
                            $view_page = $param;
                        }
                    }
                    break;
                case 'validate':
                    if ($param) {
                        if ($is_writer) {
                            $validate_page = $param;
                        }
                    }
                    break;
                case 'admin':
                    if ($param) {
                        if ($is_admin) {
                            $admin_page = url('admin', $lang);
                        }
                    }
                    break;
                default:
                    break;
            }
        }
    }
    $output = view('toolbar', $lang, compact('scroll', 'nobody_page', 'edit_page', 'view_page', 'validate_page', 'admin_page'));
    return $output;
}
 public function index($assignment_id)
 {
     $this->assignment = $this->assignment_model->get_values($assignment_id);
     if (empty($this->assignment)) {
         add_message('This job is no longer on record.', 'warning');
         redirect(base_url());
     }
     $order = (object) $this->order_model->get_values($this->assignment->order_id);
     $order_type = $this->order_model->get_type_string($order->order_type_id);
     $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager');
     $this->workflow_manager->initialise(array('workflow' => $order_type, 'stage' => 'assignment_details', 'param' => $assignment_id, 'module' => 'miniant'));
     $next_page_url = $this->workflow_manager->get_next_url();
     parent::update_time($order->id);
     $technician_id = parent::get_technician_id($assignment_id);
     $order_technician = $this->order_technician_model->get(array('order_id' => $order->id, 'technician_id' => $technician_id), true);
     $is_technician = user_has_role($this->session->userdata('user_id'), 'Technician');
     $order_technician_id = @$order_technician->id;
     $units = $this->get_units($assignment_id, $technician_id, $order->senior_technician_id);
     $notes = $this->message_model->get_with_author_names(array('document_type' => 'order', 'document_id' => $order->id));
     $equipment_type = null;
     $equipment_types = array();
     foreach ($units as $key => $unit) {
         $units[$key]->notes = $this->message_model->get_with_author_names(array('document_type' => 'assignment', 'document_id' => $assignment_id));
         if (is_null($equipment_type)) {
             $equipment_type = $this->unit_model->get_type_string($unit->unit_type_id);
         }
         if (!in_array($unit->unit_type_id, $equipment_types)) {
             $equipment_types[] = $unit->unit_type_id;
         }
     }
     if (count($equipment_types) > 1) {
         $equipment_type = 'Mixed';
     }
     $this->load->library('Dialog');
     $this->dialog->initialise(array('min_interval_between_answers' => 300));
     if ($is_technician) {
         $this->dialog->add_question(array('id' => 'ready_to_travel', 'shown' => !$this->order_technician_model->has_statuses($order_technician_id, array('STARTED TRAVEL')), 'text' => 'Are you ready to travel to the job?', 'answers' => array(array('text' => 'Yes', 'ids_to_show' => array('ready_to_start'), 'triggers' => array(array('system' => 'order_technician', 'document_id' => $order_technician_id, 'event_name' => 'leaving', 'module' => 'miniant'))))));
         $this->dialog->add_question(array('id' => 'continue', 'shown' => $this->order_technician_model->has_statuses($order_technician_id, array('STARTED')), 'text' => 'This job is currently in progress', 'answers' => array(array('text' => 'Continue this job', 'url' => $next_page_url))));
         $question_text = $order_type == 'Installation' ? 'Are you ready to start the installation?' : 'Are you ready to start the diagnostic?';
         $this->dialog->add_question(array('id' => 'ready_to_start', 'shown' => !$this->order_technician_model->has_statuses($order_technician_id, array('STARTED')) && $this->order_technician_model->has_statuses($order_technician_id, array('STARTED TRAVEL')), 'text' => $question_text, 'answers' => array(array('text' => 'Yes', 'triggers' => array(array('system' => 'order_technician', 'document_id' => $order_technician_id, 'event_name' => 'start', 'module' => 'miniant'), array('system' => 'order', 'document_id' => $order->id, 'event_name' => 'start', 'module' => 'miniant')), 'url' => $next_page_url, 'short_interval_js' => '$("#did_you_forget").show();return false;'))));
         $this->dialog->add_question(array('id' => 'did_you_forget', 'shown' => false, 'text' => 'Did you forget to click the "Are you ready to travel" button before you left?', 'answers' => array(array('text' => 'Yes', 'undo' => false, 'ids_to_show' => array('time_estimate')), array('text' => 'No', 'triggers' => array(array('system' => 'order_technician', 'document_id' => $order_technician_id, 'event_name' => 'start', 'module' => 'miniant'), array('system' => 'order', 'document_id' => $order->id, 'event_name' => 'start', 'module' => 'miniant')), 'url' => $next_page_url))));
         $this->dialog->add_question(array('id' => 'time_estimate', 'shown' => false, 'text' => 'Estimate how long it took you to travel', 'answers' => array(array('text' => 'Travel time', 'type' => 'dropdown', 'options' => array(0 => '-- Select One --', 900 => '15 minutes', 1800 => '30 minutes', 2700 => '45 minutes', 3600 => '1 hour', 4500 => '1 hour 15 minutes', 5400 => '1 hour 30 minutes', 6300 => '1 hour 45 minutes', 7200 => '2 hours', 8100 => '2 hours 15 minutes', 9000 => '2 hours 30 minutes', 9900 => '2 hours 45 minutes', 10800 => '3 hours', 11700 => '3 hours 15 minutes', 12600 => '3 hours 30 minutes', 13500 => '3 hours 45 minutes', 14400 => '4 hours', 15300 => '4 hours 15 minutes', 16200 => '4 hours 30 minutes', 17100 => '4 hours 45 minutes', 18000 => '5 hours'), 'ajax_callback' => 'miniant/stages/assignment_details/add_travel_time/' . $assignment_id, 'ajax_position' => 'end', 'ajax_data' => array('assignment_id' => $assignment_id), 'triggers' => array(array('system' => 'order_technician', 'document_id' => $order_technician_id, 'event_name' => 'start', 'module' => 'miniant')), 'url' => $next_page_url))));
     } else {
         $this->dialog->add_question(array('id' => 'review', 'shown' => true, 'text' => ' ', 'answers' => array(array('text' => 'Review this job', 'url' => $next_page_url))));
     }
     $this->load_stage_view(array('units' => $units, 'notes' => $notes, 'dialog' => $this->dialog->output(), 'equipment_type' => $equipment_type));
 }
Ejemplo n.º 17
0
function threadedit($lang, $arglist = false)
{
    global $supported_languages;
    if (!user_has_role('writer')) {
        return run('error/unauthorized', $lang);
    }
    $thread = $node = false;
    if (is_array($arglist)) {
        if (isset($arglist[0])) {
            $thread = $arglist[0];
        }
        if (isset($arglist[1])) {
            $node = $arglist[1];
        }
    }
    $clang = false;
    foreach ($supported_languages as $slang) {
        if (isset($_POST[$slang])) {
            $clang = $slang;
            break;
        }
    }
    if (!$clang) {
        if (isset($_POST['clang'])) {
            $clang = $_POST['clang'];
        } else {
            if (isset($_GET['clang'])) {
                $clang = $_GET['clang'];
            } else {
                $clang = $lang;
            }
        }
        if (!in_array($clang, $supported_languages)) {
            return run('error/notfound', $lang);
        }
    }
    if (!$thread) {
        require_once 'actions/threadeditall.php';
        return threadeditall($lang, $clang);
    }
    if (!$node) {
        require_once 'actions/threadeditsummary.php';
        return threadeditsummary($lang, $clang, $thread);
    }
    require_once 'actions/threadeditnode.php';
    return threadeditnode($lang, $clang, $thread, $node);
}
Ejemplo n.º 18
0
 /**
  * (non-PHPdoc)
  * @see AbstractCallback::getListeUser()
  * 
  * Fonction pour récupérer Le référent (et Directeur si différent) 
  * de l’ADEFIM rattachée 
  * 
  */
 public function getListeUser() {
     
     $users = array();
     
     $id_entreprises = $this->param->id_entreprises;
     
     db_set_active(@DB_EXTRANET);
     
     $query = db_select('user_entreprise', 'ue');
     $query->join('lien_user_entreprise_ref_esclave_entreprise', 'luee', 'luee.id_user_entreprise = ue.id');
     $query->join('drupal_user', 'du', 'ue.id_drupal_user = du.id');
     $query->fields('du', array('id_user_drupal'));
     $query->condition('luee.est_actif' , 1, '=');
     //filtre par entreprise
     $query->condition('luee.id_ref_esclave_entreprise', $id_entreprises, 'IN');
     
     $results = $query->execute()->fetchAll();
     
     db_set_active();
     
     foreach ($results as $result) {
         
         //chercher si l'utilisateur existe dans drupal
         $user = user_load($result->id_user_drupal);
         
         if ($user != false) {
             
             // Vérifier si l'utilisateur est ADMIN ENTREPISE (role 5)
             // @todo RESPONSABLE ENTREPISE
             if (user_has_role(5,$user)) {
                 $users[] = $user->uid;
             }
         }
     }
     
     // Supprimer les doublons si plusieurs entreprises
     $users = array_unique($users);
     
     return $users;
     
 }
Ejemplo n.º 19
0
function validateInvitedFreelancers($form, $form_state)
{
    if (!isset($form['field_freelancers_to_invite'])) {
        form_set_error('field_freelancers_to_invite', 'Please enter at least one Creative Pro to invite');
    }
    //debugLong($form_state['values']['field_freelancers_to_invite'], '_validate_freelancers_to_invite');
    $freelancers_to_invite = explode(',', $form_state['values']['field_freelancers_to_invite']);
    //debugLong($freelancers_to_invite, '_validate_freelancers_to_invite_exploded');
    if (empty($freelancers_to_invite[0])) {
        form_set_error('field_freelancers_to_invite', 'Enter at least one Creative Pro');
    }
    $invalid = array();
    $notApproved = array();
    foreach ($freelancers_to_invite as $name) {
        $f = user_load_by_name(trim($name));
        if ($f == false) {
            array_push($invalid, $name);
        } else {
            if (!user_has_role(8, $f)) {
                array_push($notApproved, $name);
            }
        }
    }
    if (!empty($invalid)) {
        $invalidInStr = implode(', ', $invalid);
        $errorMessage = 'Not creative pros: ' . $invalidInStr;
    }
    if (!empty($notApproved)) {
        $notApprovedInStr = implode(', ', $notApproved);
        if (isset($errorMessage)) {
            $errorMessage .= "<br>Freelancers not yet approved by Tap: " . $notApprovedInStr;
        } else {
            $errorMessage = "Freelancers not yet approved by Tap: " . $notApprovedInStr;
        }
    }
    if (!empty($errorMessage)) {
        form_set_error('field_freelancers_to_invite', $errorMessage);
    }
    $trimmed = array_map('trim', $freelancers_to_invite);
    $form_state['values']['field_freelancers_to_invite'] = implode(',', $trimmed);
}
Ejemplo n.º 20
0
 public function index($assignment_id)
 {
     $this->assignment = $this->assignment_model->get_values($assignment_id);
     if (empty($this->assignment)) {
         add_message('This job is no longer on record.', 'warning');
         redirect(base_url());
     }
     $order = (object) $this->order_model->get_values($this->assignment->order_id);
     $order_type = $this->order_model->get_type_string($order->order_type_id);
     $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager');
     $this->workflow_manager->initialise(array('workflow' => $order_type, 'stage' => 'unit_serial', 'param' => $assignment_id, 'module' => 'miniant'));
     $technician_id = parent::get_technician_id($assignment_id);
     $is_technician = user_has_role($this->session->userdata('user_id'), 'Technician');
     parent::update_time($order->id);
     $order_technician = $this->order_technician_model->get(array('order_id' => $order->id, 'technician_id' => $technician_id), true);
     if ($is_technician) {
         trigger_event('start', 'order_technician', $order_technician->id, false, 'miniant');
     }
     $next_page_url = $this->workflow_manager->get_next_url();
     $order_technician = $this->order_technician_model->get(array('order_id' => $order->id, 'technician_id' => $technician_id), true);
     $units = $this->get_units($assignment_id, $technician_id, $order->senior_technician_id);
     $this->load_stage_view(array('units' => $units));
 }
 /**
  * This dialog code was useful for simple dialogs, but it's becoming a mess now. The issues are:
  *  - No hooks for PHP callbacks in event triggers (can't change data for diagnostics, assignments etc. without using JS callbacks, which are messy)
  *  - No rule about whether to use STATUSES or table columns to store data about things like Assignment->no_issues_found
  */
 public function get_diagnostic_report_dialog($diagnostic_id, $order, $technician_id, $workflow_manager)
 {
     $assignment = $this->assignment_model->get(compact('diagnostic_id'), true);
     $is_senior_technician = $technician_id == $order->senior_technician_id;
     $order_type = $this->order_model->get_type_string($order->order_type_id);
     $is_technician = user_has_role($this->session->userdata('user_id'), 'Technician');
     $this->load->library('Dialog');
     $this->dialog->initialise(array('id' => 'dialog-' . $assignment->id));
     if ($is_technician) {
         $ids_to_show = $is_senior_technician ? array('hide_issue_photos') : array('hide_issue_photos');
         // Keeping this here in case the workflow changes later on for non-senior technicians
         $diagnostic_issues = $this->diagnostic_issue_model->get(array('diagnostic_id' => $diagnostic_id));
         $has_repair_issues = false;
         $has_sq_issues = false;
         foreach ($diagnostic_issues as $issue) {
             if ($issue->can_be_fixed_now) {
                 $has_repair_issues = true;
             } else {
                 $has_sq_issues = true;
             }
         }
         $this->dialog->add_question(array('id' => 'recorded_all_issues', 'shown' => $diagnostic_issues && !$this->assignment_model->has_statuses($assignment->id, array('ISSUES DIAGNOSED')), 'text' => 'Have you recorded all the issues for this unit?', 'answers' => array(array('text' => 'Yes', 'ids_to_show' => $ids_to_show, 'triggers' => array(array('system' => 'assignment', 'document_id' => $assignment->id, 'event_name' => 'diagnosed', 'module' => 'miniant')), 'ajax_callback' => 'miniant/stages/diagnostic_report/set_no_issues_found/' . $assignment->id . '/0'))));
         $this->dialog->add_question(array('id' => 'hide_issue_photos', 'shown' => $this->assignment_model->has_statuses($assignment->id, array('ISSUES DIAGNOSED')) && !$assignment->no_issues_found, 'text' => 'Has the office asked you to hide the issue photos?', 'answers' => array(array('text' => 'Yes', 'triggers' => array(array('system' => 'assignment', 'document_id' => $assignment->id, 'event_name' => 'issue_photos_hiding_setting_recorded', 'module' => 'miniant')), 'ids_to_show' => array('isolated_and_tagged'), 'ajax_callback' => 'miniant/stages/diagnostic_report/set_issue_photo_hiding/' . $assignment->id . '/1'), array('text' => 'No', 'ids_to_show' => array('isolated_and_tagged'), 'triggers' => array(array('system' => 'assignment', 'document_id' => $assignment->id, 'event_name' => 'issue_photos_hiding_setting_recorded', 'module' => 'miniant')), 'ajax_callback' => 'miniant/stages/diagnostic_report/set_issue_photo_hiding/' . $assignment->id . '/0'))));
         $this->dialog->add_question(array('id' => 'isolated_and_tagged', 'shown' => $this->assignment_model->has_statuses($assignment->id, array('ISSUES DIAGNOSED')) && !$assignment->no_issues_found, 'text' => 'Have you isolated and tagged this system?', 'answers' => array(array('text' => 'Yes', 'triggers' => array(array('system' => 'assignment', 'document_id' => $assignment->id, 'event_name' => 'isolated_and_tagged_recorded', 'module' => 'miniant')), 'ids_to_show' => array('called_office'), 'ajax_callback' => 'miniant/stages/diagnostic_report/set_isolated_and_tagged/' . $assignment->id . '/true'), array('text' => 'No', 'ids_to_show' => array('called_office'), 'triggers' => array(array('system' => 'assignment', 'document_id' => $assignment->id, 'event_name' => 'isolated_and_tagged_recorded', 'module' => 'miniant')), 'ajax_callback' => 'miniant/stages/diagnostic_report/set_isolated_and_tagged/' . $assignment->id . '/false'))));
         $this->dialog->add_question(array('id' => 'called_office', 'shown' => !$this->assignment_model->has_statuses($assignment->id, array('CALLED OFFICE')) && !$assignment->no_issues_found && $this->assignment_model->has_statuses($assignment->id, array('ISSUE PHOTOS HIDING SETTING RECORDED')) && $this->assignment_model->has_statuses($assignment->id, array('ISSUES DIAGNOSED')) && $this->assignment_model->has_statuses($assignment->id, array('ISOLATED AND TAGGED SETTING RECORDED')), 'text' => 'Have you called the office?', 'answers' => array(array('text' => 'Yes', 'ids_to_show' => array('repair_approved' => '$("table[data-assignment_id=' . $assignment->id . '] tr[data-can_be_fixed_now=1]").length > 0', 'sq_approved' => '$("table[data-assignment_id=' . $assignment->id . '] tr[data-can_be_fixed_now=0]").length > 0', 'continue' => '$("table[data-assignment_id=' . $assignment->id . '] tr[data-can_be_fixed_now]").length == 0'), 'triggers' => array(array('system' => 'assignment', 'document_id' => $assignment->id, 'event_name' => 'called_office', 'module' => 'miniant'))))));
         $redirect_url = 'workflow/redirect/' . $order_type . '/diagnostic_report/' . $assignment->id . '/miniant';
         $no_sq_issues_js_condition = '$("table[data-assignment_id=' . $assignment->id . '] tr[data-can_be_fixed_now=0]").length == 0';
         $this->dialog->add_question(array('id' => 'repair_approved', 'shown' => !$this->diagnostic_model->has_statuses($diagnostic_id, array('COMPLETE')) && !$assignment->no_issues_found && !$this->assignment_model->has_statuses($assignment->id, array('REPAIRS APPROVED')) && $this->assignment_model->has_statuses($assignment->id, array('CALLED OFFICE')) && $this->assignment_model->has_statuses($assignment->id, array('ISSUES DIAGNOSED')) && $this->assignment_model->has_statuses($assignment->id, array('ISSUE PHOTOS HIDING SETTING RECORDED')) && $this->assignment_model->has_statuses($assignment->id, array('ISOLATED AND TAGGED SETTING RECORDED')) && $has_repair_issues, 'text' => 'Has the office asked you to repair this unit now?', 'answers' => array(array('text' => 'Yes', 'triggers' => array(array('system' => 'assignment', 'document_id' => $assignment->id, 'event_name' => 'repairs_approved', 'module' => 'miniant'), array('system' => 'diagnostic', 'document_id' => $diagnostic_id, 'event_name' => 'completed', 'js_condition' => $no_sq_issues_js_condition, 'module' => 'miniant')), 'ids_to_show' => array('sq_approved' => '$("table[data-assignment_id=' . $assignment->id . '] tr[data-can_be_fixed_now=0]").length > 0', 'continue' => $no_sq_issues_js_condition), 'ajax_callback' => 'miniant/stages/diagnostic_report/set_no_issues_found/' . $assignment->id . '/0'), array('text' => 'No', 'triggers' => array(array('system' => 'assignment', 'document_id' => $assignment->id, 'event_name' => 'repairs_approved', 'undo' => true, 'module' => 'miniant'), array('system' => 'diagnostic', 'document_id' => $diagnostic_id, 'event_name' => 'completed', 'js_condition' => $no_sq_issues_js_condition, 'module' => 'miniant')), 'ids_to_show' => array('sq_approved' => '$("table[data-assignment_id=' . $assignment->id . '] tr[data-can_be_fixed_now=0]").length > 0', 'continue' => $no_sq_issues_js_condition), 'ajax_callback' => 'miniant/stages/diagnostic_report/set_no_issues_found/' . $assignment->id . '/0'))));
         $this->dialog->add_question(array('id' => 'sq_approved', 'shown' => !$this->diagnostic_model->has_statuses($diagnostic_id, array('COMPLETE')) && !$assignment->no_issues_found && !$this->assignment_model->has_statuses($assignment->id, array('SQ APPROVED')) && $this->assignment_model->has_statuses($assignment->id, array('CALLED OFFICE')) && $this->assignment_model->has_statuses($assignment->id, array('ISSUES DIAGNOSED')) && $this->assignment_model->has_statuses($assignment->id, array('ISSUE PHOTOS HIDING SETTING RECORDED')) && $this->assignment_model->has_statuses($assignment->id, array('ISOLATED AND TAGGED SETTING RECORDED')) && $has_sq_issues, 'text' => 'Has the office asked you to complete an SQ for this unit?', 'answers' => array(array('text' => 'Yes', 'triggers' => array(array('system' => 'assignment', 'document_id' => $assignment->id, 'event_name' => 'sq_approved', 'module' => 'miniant'), array('system' => 'diagnostic', 'document_id' => $diagnostic_id, 'event_name' => 'completed', 'module' => 'miniant')), 'ids_to_show' => array('continue'), 'ajax_callback' => 'miniant/stages/diagnostic_report/set_no_issues_found/' . $assignment->id . '/0'), array('text' => 'No', 'triggers' => array(array('system' => 'assignment', 'document_id' => $assignment->id, 'event_name' => 'sq_approved', 'undo' => true, 'module' => 'miniant'), array('system' => 'diagnostic', 'document_id' => $diagnostic_id, 'event_name' => 'completed', 'module' => 'miniant')), 'ids_to_show' => array('continue'), 'ajax_callback' => 'miniant/stages/diagnostic_report/set_no_issues_found/' . $assignment->id . '/0'))));
         $this->dialog->add_question(array('id' => 'continue', 'shown' => $this->diagnostic_model->has_statuses($diagnostic_id, array('COMPLETE')) && !$assignment->no_issues_found, 'text' => '&nbsp;', 'answers' => array(array('text' => 'Continue', 'url' => $redirect_url))));
     } else {
         $this->dialog->add_question(array('id' => 'continue', 'shown' => true, 'text' => ' ', 'answers' => array(array('text' => 'Continue', 'url' => $this->workflow_manager->get_next_url()))));
     }
     $dialog = $this->dialog->output();
     return $dialog;
 }
Ejemplo n.º 22
0
function admin($lang)
{
    global $paypal_username, $paypal_password, $paypal_signature;
    global $newsletter_thread;
    if (!user_has_role('administrator')) {
        return run('error/unauthorized', $lang);
    }
    head('title', translate('admin:title', $lang));
    head('description', false);
    head('keywords', false);
    head('robots', 'noindex, nofollow');
    $banner = build('banner', $lang);
    $newuser_page = url('newuser', $lang);
    $newsletter_page = $newsletter_thread ? url('newsletter', $lang) : false;
    $balance = false;
    if (!(empty($paypal_username) or empty($paypal_password) or empty($paypal_signature))) {
        $balance = build('balance', $lang);
    }
    $upload = build('upload', $lang);
    $usersearch = build('usersearch', $lang);
    $content = view('admin', $lang, compact('newuser_page', 'newsletter_page', 'balance', 'usersearch', 'upload'));
    $output = layout('standard', compact('banner', 'content'));
    return $output;
}
Ejemplo n.º 23
0
function threadeditnode($lang, $clang, $thread, $node)
{
    global $with_toolbar, $supported_contents, $limited_contents;
    if (!user_has_role('writer')) {
        return run('error/unauthorized', $lang);
    }
    $thread_id = thread_id($thread);
    if (!$thread_id) {
        return run('error/notfound', $lang);
    }
    $node_id = thread_node_id($thread_id, $node, $clang);
    if (!$node_id) {
        return run('error/notfound', $lang);
    }
    $thread_name = $thread_title = $thread_abstract = $thread_cloud = $thread_type = false;
    $r = thread_get($clang, $thread_id, false);
    if (!$r) {
        return run('error/notfound', $lang);
    }
    extract($r);
    /* thread_name thread_title thread_abstract thread_cloud thread_type */
    $content_types = $supported_contents;
    if ($thread_type and $limited_contents and array_key_exists($thread_type, $limited_contents)) {
        $content_types = $limited_contents[$thread_type];
    }
    $node_editor = build('nodeeditor', $lang, $clang, $node_id, $content_types);
    $node_name = $node_title = false;
    $r = thread_get_node($clang, $thread_id, $node_id, false);
    if ($r) {
        extract($r);
        /* node_name node_title */
    }
    head('title', $thread_title ? $thread_title : $thread_id);
    head('description', false);
    head('keywords', false);
    head('robots', 'noindex, nofollow');
    $banner = $toolbar = false;
    $headline_text = $thread_title ? $thread_title : $thread_id;
    $headline_url = url('threadedit', $lang) . '/' . $thread_id . '?' . 'clang=' . $clang;
    $headline = compact('headline_text', 'headline_url');
    $view = $node_name ? url('thread', $clang) . '/' . $thread_id . '/' . $node_id . '?' . 'slang=' . $lang : false;
    $banner = build('banner', $lang, $with_toolbar ? compact('headline') : compact('headline', 'view'));
    $scroll = true;
    $toolbar = $with_toolbar ? build('toolbar', $lang, compact('view', 'scroll')) : false;
    $prev_node_label = $prev_node_url = false;
    $r = thread_node_prev($clang, $thread_id, $node_id, false);
    if ($r) {
        extract($r);
        $prev_node_label = $prev_node_title ? $prev_node_title : $prev_node_id;
        $prev_node_url = url('threadedit', $lang) . '/' . $thread_id . '/' . $prev_node_id . '?' . 'clang=' . $clang;
    }
    $next_node_label = $next_node_url = false;
    $r = thread_node_next($clang, $thread_id, $node_id, false);
    if ($r) {
        extract($r);
        $next_node_label = $next_node_title ? $next_node_title : $next_node_id;
        $next_node_url = url('threadedit', $lang) . '/' . $thread_id . '/' . $next_node_id . '?' . 'clang=' . $clang;
    }
    $title = view('headline', false, $headline);
    $sidebar = view('sidebar', false, compact('title'));
    $content = view('editing/threadeditnode', $lang, compact('node_editor', 'node_id', 'node_title', 'prev_node_url', 'prev_node_label', 'next_node_url', 'next_node_label'));
    $output = layout('editing', compact('toolbar', 'banner', 'content', 'sidebar'));
    return $output;
}
Ejemplo n.º 24
0
function home($lang)
{
    global $root_node, $request_path, $with_toolbar, $sitename, $siteshot;
    if (!$root_node) {
        return run('error/internalerror', $lang);
    }
    $r = node_get($lang, $root_node);
    if (!$r) {
        return run('error/notfound', $lang);
    }
    extract($r);
    /* node_name node_title node_abstract node_cloud node_image node_created node_modified node_nocomment node_nomorecomment node_ilike node_tweet node_plusone node_linkedin node_pinit */
    head('title', translate('home:title', $lang));
    if ($node_abstract) {
        head('description', $node_abstract);
    } else {
        head('description', translate('description', $lang));
    }
    if ($node_cloud) {
        head('keywords', $node_cloud);
    } else {
        head('keywords', translate('keywords', $lang));
    }
    $request_path = $lang;
    $page_contents = build('nodecontent', $lang, $root_node);
    $besocial = $sharebar = false;
    if ($page_contents) {
        $ilike = $node_ilike;
        $tweetit = $node_tweet;
        $plusone = $node_plusone;
        $linkedin = $node_linkedin;
        $pinit = $node_pinit;
        if ($tweetit or $pinit) {
            $description = $node_abstract ? $node_abstract : translate('description', $lang);
            if ($tweetit) {
                $tweet_text = $description ? $description : $sitename;
                $tweetit = $tweet_text ? compact('tweet_text') : true;
            }
            if ($pinit) {
                $pinit_text = $description ? $description : $sitename;
                $pinit_image = $node_image ? $node_image : $siteshot;
                $pinit = $pinit_text && $pinit_image ? compact('pinit_text', 'pinit_image') : false;
            }
        }
        list($besocial, $sharebar) = socialize($lang, compact('ilike', 'tweetit', 'plusone', 'linkedin', 'pinit'));
    }
    $content = view('home', false, compact('page_contents', 'besocial'));
    $languages = 'home';
    $contact = $account = $admin = $donate = true;
    $edit = user_has_role('writer') ? url('editpage', $_SESSION['user']['locale']) . '/' . $root_node . '?' . 'clang=' . $lang : false;
    $validate = url('home', $lang);
    $banner = build('banner', $lang, $with_toolbar ? compact('languages', 'contact', 'account', 'admin', 'donate') : compact('languages', 'contact', 'account', 'admin', 'donate', 'edit', 'validate'));
    $toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'validate')) : false;
    $search_text = '';
    $search_url = url('search', $lang);
    $suggest_url = url('suggest', $lang);
    $search = view('searchinput', $lang, compact('search_url', 'search_text', 'suggest_url'));
    $sidebar = view('sidebar', false, compact('search'));
    $contact_page = url('contact', $lang);
    $newsletter_page = false;
    $footer = view('footer', $lang, compact('contact_page', 'newsletter_page'));
    $output = layout('standard', compact('footer', 'banner', 'content', 'sidebar', 'sharebar', 'toolbar'));
    return $output;
}
Ejemplo n.º 25
0
 /**
  * Checks permissions and instantiates the controller. Sets the page title and content.
  * 
  * @param String $raw_request a path /tina_mvc-page/controller/method/and/other/data/to/pass
  * @param Boolean $role_to_view FALSE allows all to view; '' must be loogged in to view; array or comma separated list of roles to view
  * @param Boolean $capability_to_view as for $role_to_view. Overrides the $role_to_view
  * @param String $called_from 'PAGE_FILTER', 'WIDGET', 'SHORTCODE' or 'CALL_CONTROLLLER_FUNC'
  * @param Boolean $custom_folder custom location for the controller
  * @param Object $shortcode_content
  */
 function __construct($raw_request = '', $role_to_view = NULL, $capability_to_view = NULL, $called_from = 'PAGE_FILTER', $custom_folder = FALSE, $shortcode_content = FALSE)
 {
     $this->raw_request = $raw_request;
     $this->request = str_replace('-', '_', $raw_request);
     $this->request = explode('/', $this->request);
     $this->called_from = $called_from;
     /**
      * Locate and instantiate a controller. It can override the default permissions so we need it now
      */
     $countroller_found = $this->get_instance_of($custom_folder, $shortcode_content);
     $this->CONTROLLER->set_request($this->request, $this->raw_request);
     $this->CONTROLLER->set_called_from($this->called_from);
     if (isset($this->CONTROLLER->role_to_view)) {
         $role_to_view = merge_permissions($role_to_view, $this->CONTROLLER->role_to_view);
     }
     if (isset($this->CONTROLLER->capability_to_view)) {
         $capability_to_view = merge_permissions($capability_to_view, $this->CONTROLLER->capability_to_view);
     }
     // pr( $role_to_view ); pr( $capability_to_view );
     $view_ok = FALSE;
     // default
     // watch the boolean checks here. Loose type checking for $capability_to_view
     if (!$capability_to_view and $role_to_view === FALSE) {
         $view_ok = 'View OK for all';
     } elseif ($capability_to_view === FALSE and $role_to_view == '' and is_user_logged_in()) {
         $view_ok = 'View OK for all logged in';
     } elseif ($capability_to_view !== FALSE and user_has_capability($capability_to_view)) {
         $view_ok = 'View OK by CAPABILITY';
     } elseif ($role_to_view !== FALSE and user_has_role($role_to_view)) {
         $view_ok = 'View OK by ROLE';
     } elseif ($this->called_from === 'PAGE_FILTER') {
         /**
          * Are we using custom login functionality?
          */
         if ($custom_login = get_tina_mvc_setting('custom_login')) {
             if ($this->do_login()) {
                 /**
                  * User is successfully authenticated.
                  * 
                  * We only do a redirect from a Tina MVC page, i.e. not from a widget or a shortcode where
                  * browser output has already started.
                  *
                  * If login returns TRUE we have an authenticated user and need to go through the various
                  * role and capability checks again.
                  */
                 $r = get_tina_mvc_setting('logon_redirect_target');
                 $tina_pages = get_tina_mvc_setting('tina_mvc_pages');
                 if ($r) {
                     if (!array_key_exists($r, $tina_pages)) {
                         error('Page in $tina_mvc_app_settings->logon_redirect_target is not a Tina MVC page.');
                     }
                     wp_safe_redirect(site_url() . '?p=' . $tina_pages[$r]['page_id']);
                     exit;
                 } elseif ($r === '') {
                     wp_safe_redirect(site_url() . '?p=' . $tina_pages[$custom_login]['page_id']);
                     exit;
                 } else {
                     wp_redirect(site_url());
                     exit;
                 }
             }
         } elseif (get_tina_mvc_setting('no_permission_behaviour') == 'wp_login') {
             $login_redir = wp_login_url(site_url($this->raw_request));
             wp_redirect($login_redir);
             exit;
         } else {
             /**
              * If do_login() returns FALSE or we are not using the custom login functionality, a user is not
              * logged in and a login form is in $this->the_post_content.
              */
             $view_ok = FALSE;
             $this->the_post_title = $this->CONTROLLER->get_post_title();
             $this->the_post_content = $this->CONTROLLER->get_post_content();
         }
     } else {
         $view_ok = FALSE;
     }
     // log( $view_ok ); // debugging permissions
     // prd( $this->the_post_content );
     /**
      * Check the $view_ok setting
      *
      * In cases where the constructor has set the post_title and post_content we don't want them
      * accidently displayed if permission checks do not pass.
      */
     if ($view_ok) {
         $this->CONTROLLER->dispatch();
         $this->the_post_title = $this->CONTROLLER->get_post_title();
         $this->the_post_content = $this->CONTROLLER->get_post_content();
     } elseif ($this->called_from === 'PAGE_FILTER') {
         if (get_tina_mvc_setting('custom_login')) {
             $this->the_post_title = $this->CONTROLLER->get_post_title();
             $this->the_post_content = $this->CONTROLLER->get_post_content();
         } else {
             if (get_tina_mvc_setting('no_permission_behaviour') == 'redirect') {
                 wp_redirect(site_url());
                 exit;
             } else {
                 // 'no_permission'
                 $this->the_post_title = 'No Permission';
                 $this->the_post_content = 'Sorry, you do not have permission to view this content.';
             }
         }
     } else {
         $this->the_post_title = '';
         $this->the_post_content = '';
     }
 }
Ejemplo n.º 26
0
            ?>
                           <?php 
        }
        ?>
                           <span class="user-points">
                               <?php 
        print isset($account) ? userpoints_get_current_points($account->uid) . ' ' . t('points') : '';
        ?>
                           </span>
                       </div>
					   <div class="user-job"><?php 
        print isset($account) ? $account->profile_job : '';
        ?>
</div>
                       <?php 
        if (FALSE && isset($account) && user_has_role(ROL_CONTEST_JURY, $account)) {
            ?>
                       <div class="jury-member">
                           <?php 
            print t('Jury of Arquideas');
            ?>
                       </div>
                       <?php 
        }
        ?>
                       <?php 
        $block = module_invoke('addthis', 'block', 'view', '0');
        print $block['content'];
        ?>
                       <?php 
    }
Ejemplo n.º 27
0
function banner($lang, $components = false)
{
    global $home_action;
    $home_page = url($home_action, $lang);
    $logo = view('logo', $lang, compact('home_page'));
    $menu = $languages = $headline = $search = $donate = false;
    $contact_page = $user_page = $nobody_page = $account_page = $edit_page = $view_page = $validate_page = $admin_page = false;
    $is_identified = user_is_identified();
    $is_admin = user_has_role('administrator');
    $is_writer = user_has_role('writer');
    if ($is_identified) {
        $nobody_page = url('nobody', $lang);
    }
    if ($components) {
        foreach ($components as $v => $param) {
            switch ($v) {
                case 'account':
                    if ($param) {
                        if ($is_identified) {
                            $account_page = url('account', $lang);
                        } else {
                            $user_page = url('user', $lang);
                        }
                    }
                    break;
                case 'contact':
                    if ($param) {
                        $contact_page = url('contact', $lang);
                    }
                    break;
                case 'languages':
                    if ($param) {
                        $languages = build('languages', $lang, $param);
                    }
                    break;
                case 'donate':
                    if ($param) {
                        $donate = build('donate', $lang);
                    }
                    break;
                case 'headline':
                    if ($param) {
                        $headline = view('headline', false, $param);
                    }
                    break;
                case 'search':
                    if ($param) {
                        $search = view('searchinput', $lang, $param);
                    }
                    break;
                case 'edit':
                    if ($param) {
                        if ($is_writer) {
                            $edit_page = $param;
                        }
                    }
                    break;
                case 'view':
                    if ($param) {
                        if ($is_writer) {
                            $view_page = $param;
                        }
                    }
                    break;
                case 'validate':
                    if ($param) {
                        if ($is_writer) {
                            $validate_page = $param;
                        }
                    }
                    break;
                case 'admin':
                    if ($param) {
                        if ($is_admin) {
                            $admin_page = url('admin', $lang);
                        }
                    }
                    break;
                default:
                    break;
            }
        }
    }
    $menu = view('bannermenu', $lang, compact('user_page', 'nobody_page', 'account_page', 'contact_page', 'edit_page', 'view_page', 'validate_page', 'admin_page'));
    $output = view('banner', false, compact('logo', 'menu', 'languages', 'headline', 'search', 'donate'));
    return $output;
}
Ejemplo n.º 28
0
 public function index($assignment_id)
 {
     require_capability('orders:editunitdetails');
     if (!($this->assignment = $this->assignment_model->get($assignment_id))) {
         die("The assignment ID {$assignment_id} could not be found!");
     }
     $order = (object) $this->order_model->get_values($this->assignment->order_id);
     $order_type = $this->order_model->get_type_string($order->order_type_id);
     $technician_id = parent::get_technician_id($assignment_id);
     $is_technician = user_has_role($this->session->userdata('user_id'), 'Technician');
     $order_technician = $this->order_technician_model->get(array('order_id' => $order->id, 'technician_id' => $technician_id), true);
     $units = $this->get_units($assignment_id, $technician_id, $order->senior_technician_id);
     parent::update_time($order->id);
     $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager');
     $this->workflow_manager->initialise(array('workflow' => $order_type, 'stage' => 'signature', 'param' => $assignment_id, 'module' => 'miniant'));
     $has_required_diagnostics = false;
     $tenancies = array();
     foreach ($units as $key => $unit) {
         $units[$key]->assignment = (object) $this->assignment_model->get_values($units[$key]->assignment_id);
         $unit_photos = get_photos('assignment', $unit->assignment_id, $unit->id, 'miniant');
         $photos = array();
         $photos['Equipment photos'] = array();
         if (!empty($unit_photos)) {
             foreach ($unit_photos as $photo) {
                 $photos['Equipment photos'][] = $photo;
             }
         }
         if ($order_type != 'Installation') {
             if (!empty($units[$key]->assignment->diagnostic_id)) {
                 $units[$key]->diagnostic = (object) $this->diagnostic_model->get_values($units[$key]->assignment->diagnostic_id);
                 $units[$key]->issues = $this->diagnostic_issue_model->get(array('diagnostic_id' => $units[$key]->diagnostic->id));
                 if (!$units[$key]->diagnostic->bypassed) {
                     $has_required_diagnostics = true;
                 }
             }
             if (!empty($units[$key]->issues) && !$units[$key]->assignment->hide_issue_photos) {
                 foreach ($units[$key]->issues as $diagnostic_issue) {
                     if ($issue_photos = get_photos('diagnostic_issue', null, $diagnostic_issue->id, 'miniant')) {
                         foreach ($issue_photos as $issue_photo) {
                             if (empty($photos["{$diagnostic_issue->issue_type_name} {$diagnostic_issue->part_type_name}"])) {
                                 $photos["{$diagnostic_issue->issue_type_name} {$diagnostic_issue->part_type_name}"] = array();
                             }
                             $photos["{$diagnostic_issue->issue_type_name} {$diagnostic_issue->part_type_name}"][] = $issue_photo;
                         }
                     }
                 }
             }
         }
         $units[$key]->photos = $photos;
         $parts_used = $this->part_model->get(array('assignment_id' => $unit->assignment_id));
         foreach ($parts_used as $key2 => $part_used) {
             if (empty($part_used->part_name)) {
                 $parts_used[$key2]->part_name = $this->part_type_model->get($part_used->part_type_id)->name;
             }
             if (empty($part_used->quantity)) {
                 $part_used->quantity = $part_used->description;
             }
             if (!empty($part_used->servicequote_id) || empty($part_used->quantity)) {
                 unset($parts_used[$key2]);
             }
         }
         $units[$key]->parts_used = $parts_used;
         if (empty($tenancies[$unit->tenancy_id])) {
             $tenancy = $this->tenancy_model->get($unit->tenancy_id);
             $tenancies[$unit->tenancy_id] = array('units' => array(), 'tenancy' => $tenancy, 'signature' => $this->tenancy_model->get_signature_for_order($tenancy->id, $order->id));
         }
         $tenancies[$unit->tenancy_id]['units'][] = $unit;
     }
     $site_photos = array('pre-job' => get_photos('order', 'site-pre-job', $order->id, 'miniant'), 'post-job' => get_photos('order', 'site-post-job', $order->id, 'miniant'));
     $this->load_stage_view(array('units' => $units, 'jstoload' => array('jquery.signaturepad', 'signaturepad/flashcanvas', 'signaturepad/json2'), 'module' => 'miniant', 'csstoload' => array('jquery.signaturepad'), 'tenancies' => $tenancies, 'site_photos' => $site_photos, 'terms' => $this->setting_model->get(array('name' => 'terms'), true)->value, 'is_maintenance' => $order->order_type_id == $this->order_model->get_type_id('Maintenance'), 'is_service' => $order->order_type_id == $this->order_model->get_type_id('Service'), 'is_repair' => $order->order_type_id == $this->order_model->get_type_id('Repair'), 'order_dowd' => $this->dowd_model->get_formatted_order_dowd($order->dowd_id, $order->id), 'time_started' => @$this->order_technician_model->get_status_change_log($order_technician->id, 'STARTED')->creation_date));
 }
Ejemplo n.º 29
0
function folderpage($lang, $folder, $page)
{
    global $with_toolbar;
    $folder_id = thread_id($folder);
    if (!$folder_id) {
        return run('error/notfound', $lang);
    }
    $page_id = thread_node_id($folder_id, $page, $lang);
    if (!$page_id) {
        return run('error/notfound', $lang);
    }
    $r = thread_get($lang, $folder_id);
    if (!$r) {
        return run('error/notfound', $lang);
    }
    extract($r);
    /* thread_type thread_name thread_title thread_abstract thread_cloud thread_image */
    if (!($thread_type == 'folder' or $thread_type == 'book' or $thread_type == 'story')) {
        return run('error/notfound', $lang);
    }
    $folder_name = $thread_name;
    $folder_title = $thread_title;
    $folder_abstract = $thread_abstract;
    $folder_cloud = $thread_cloud;
    $r = thread_get_node($lang, $folder_id, $page_id);
    if (!$r) {
        return run('error/notfound', $lang);
    }
    extract($r);
    /* node_number node_ignored node_name node_title node_abstract node_cloud node_image node_user_id node_visits node_nocomment node_nomorecomment node_novote node_nomorevote node_ilike node_tweet node_plusone node_linkedin node_pinit */
    if ($node_ignored) {
        return run('error/notfound', $lang);
    }
    $page_user_id = $node_user_id;
    $page_name = $node_name;
    $page_title = $node_title;
    $page_abstract = $node_abstract;
    $page_cloud = $node_cloud;
    $page_modified = $node_modified;
    if ($page_title) {
        head('title', $page_title);
    } else {
        if ($folder_title) {
            head('title', $folder_title);
        }
    }
    if ($page_abstract) {
        head('description', $page_abstract);
    } else {
        if ($folder_abstract) {
            head('description', $folder_abstract);
        }
    }
    if ($page_cloud) {
        head('keywords', $page_cloud);
    } else {
        if ($folder_cloud) {
            head('keywords', $folder_cloud);
        }
    }
    head('date', $page_modified);
    $page_contents = build('nodecontent', $lang, $page_id);
    $page_comment = false;
    if (!($thread_nocomment or $node_nocomment)) {
        $nomore = (!$page_contents or $thread_nomorecomment or $node_nomorecomment) ? true : false;
        $page_url = url('folder', $lang) . '/' . $folder_name . '/' . $page_name;
        $page_comment = build('nodecomment', $lang, $page_id, $page_user_id, $page_url, $nomore);
    }
    $vote = false;
    if (!($thread_novote or $node_novote)) {
        $nomore = (!$page_contents or $thread_nomorevote or $node_nomorevote) ? true : false;
        $vote = build('vote', $lang, $page_id, 'node', $nomore);
    }
    $visits = false;
    if ($thread_visits and $node_visits) {
        $nomore = user_has_role('writer');
        $visits = build('visits', $lang, $page_id, $nomore);
    }
    $besocial = $sharebar = false;
    if ($page_contents or $page_comment) {
        $ilike = $thread_ilike && $node_ilike;
        $tweetit = $thread_tweet && $node_tweet;
        $plusone = $thread_plusone && $node_plusone;
        $linkedin = $thread_linkedin && $node_linkedin;
        $pinit = $thread_pinit && $node_pinit;
        if ($tweetit) {
            $tweet_text = $node_abstract ? $node_abstract : ($node_title ? $node_title : $thread_title);
            $tweetit = $tweet_text ? compact('tweet_text') : true;
        }
        if ($pinit) {
            $pinit_text = $node_abstract ? $node_abstract : ($node_title ? $node_title : $thread_title);
            $pinit_image = $node_image;
            $pinit = $pinit_text && $pinit_image ? compact('pinit_text', 'pinit_image') : false;
        }
        list($besocial, $sharebar) = socialize($lang, compact('ilike', 'tweetit', 'plusone', 'linkedin', 'pinit'));
    }
    $content = view('folderpage', false, compact('page_title', 'page_contents', 'page_comment', 'besocial', 'vote', 'visits'));
    $edit = user_has_role('writer') ? url('folderedit', $_SESSION['user']['locale']) . '/' . $folder_id . '/' . $page_id . '?' . 'clang=' . $lang : false;
    $validate = url('folder', $lang) . '/' . $folder_name . '/' . $page_name;
    $banner = build('banner', $lang, $with_toolbar ? false : compact('edit', 'validate'));
    $toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'validate')) : false;
    $output = layout('standard', compact('sharebar', 'toolbar', 'banner', 'content'));
    return $output;
}
Ejemplo n.º 30
0
function story($lang, $arglist = false)
{
    global $request_path, $with_toolbar;
    $story = $page = false;
    if (is_array($arglist)) {
        if (isset($arglist[0])) {
            $story = $arglist[0];
        }
        if (isset($arglist[1])) {
            $page = $arglist[1];
        }
    }
    if (!$story) {
        return run('error/notfound', $lang);
    }
    $story_id = thread_id($story);
    if (!$story_id) {
        return run('error/notfound', $lang);
    }
    $page_id = thread_node_id($story_id, $page, $lang);
    if (!$page_id) {
        return run('error/notfound', $lang);
    }
    $r = thread_get($lang, $story_id);
    if (!$r) {
        return run('error/notfound', $lang);
    }
    extract($r);
    /* thread_type thread_name thread_title thread_abstract thread_cloud thread_nocloud thread_nosearch thread_nocomment thread_nomorecomment */
    if ($thread_type != 'story') {
        return run('error/notfound', $lang);
    }
    $story_name = $thread_name;
    $story_title = $thread_title;
    $story_abstract = $thread_abstract;
    $story_cloud = $thread_cloud;
    $story_nocloud = $thread_nocloud;
    $story_nosearch = $thread_nosearch;
    $r = thread_get_node($lang, $story_id, $page_id);
    if (!$r) {
        return run('error/notfound', $lang);
    }
    extract($r);
    /* node_number node_ignored node_name node_title node_abstract node_cloud node_user_id node_visits node_nocomment node_nomorecomment node_novote node_nomorevote node_ilike node_tweet node_plusone node_linkedin */
    if ($node_ignored) {
        return run('error/notfound', $lang);
    }
    $page_user_id = $node_user_id;
    $page_name = $node_name;
    $page_title = $node_title;
    $page_abstract = $node_abstract;
    $page_cloud = $node_cloud;
    $page_number = $node_number;
    $page_modified = $node_modified;
    if (!$page) {
        $request_path .= '/' . $page_name;
    }
    if ($story_title) {
        head('title', $story_title);
    }
    if ($page_abstract) {
        head('description', $page_abstract);
    } else {
        if ($story_abstract) {
            head('description', $story_abstract);
        }
    }
    if ($page_cloud) {
        head('keywords', $page_cloud);
    } else {
        if ($story_cloud) {
            head('keywords', $story_cloud);
        }
    }
    head('date', $page_modified);
    $page_contents = build('nodecontent', $lang, $page_id);
    $page_comment = false;
    if (!($thread_nocomment or $node_nocomment)) {
        $nomore = (!$page_contents or $thread_nomorecomment or $node_nomorecomment) ? true : false;
        $page_url = url('story', $lang) . '/' . $story_name . '/' . $page_name;
        $page_comment = build('nodecomment', $lang, $page_id, $page_user_id, $page_url, $nomore);
    }
    $vote = false;
    if (!($thread_novote or $node_novote)) {
        $nomore = (!$page_contents or $thread_nomorevote or $node_nomorevote) ? true : false;
        $vote = build('vote', $lang, $page_id, 'node', $nomore);
    }
    $visits = false;
    if ($thread_visits and $node_visits) {
        $nomore = user_has_role('writer');
        $visits = build('visits', $lang, $page_id, $nomore);
    }
    $besocial = $sharebar = false;
    if ($page_contents or $page_comment) {
        $ilike = $thread_ilike && $node_ilike;
        $tweetit = $thread_tweet && $node_tweet;
        $plusone = $thread_plusone && $node_plusone;
        $linkedin = $thread_linkedin && $node_linkedin;
        $pinit = $thread_pinit && $node_pinit;
        if ($tweetit) {
            $tweet_text = $node_abstract ? $node_abstract : ($node_title ? $node_title : $thread_title);
            $tweetit = $tweet_text ? compact('tweet_text') : true;
        }
        if ($pinit) {
            $pinit_text = $node_abstract ? $node_abstract : ($node_title ? $node_title : $thread_title);
            $pinit_image = $node_image;
            $pinit = $pinit_text && $pinit_image ? compact('pinit_text', 'pinit_image') : false;
        }
        list($besocial, $sharebar) = socialize($lang, compact('ilike', 'tweetit', 'plusone', 'linkedin', 'pinit'));
    }
    $content = view('storycontent', false, compact('page_id', 'page_title', 'page_contents', 'page_comment', 'page_number', 'besocial', 'vote', 'visits'));
    $search = false;
    if (!$story_nosearch) {
        $search_text = '';
        $search_url = url('search', $lang, $story_name);
        $suggest_url = url('suggest', $lang, $story_name);
        $search = view('searchinput', $lang, compact('search_url', 'search_text', 'suggest_url'));
    }
    $cloud = false;
    if (!$story_nocloud) {
        $cloud_url = url('search', $lang, $story_name);
        $byname = $bycount = $index = true;
        $cloud = build('cloud', $lang, $cloud_url, $story_id, false, 30, compact('byname', 'bycount', 'index'));
    }
    $summary = array();
    $r = thread_get_contents($lang, $story_id);
    if ($r) {
        $story_url = url('story', $lang) . '/' . $story_name;
        foreach ($r as $c) {
            extract($c);
            /* node_id node_name node_title node_number */
            $summary_page_id = $node_id;
            $summary_page_title = $node_title;
            $summary_page_url = $story_url . '/' . $node_name;
            $summary[] = compact('summary_page_id', 'summary_page_title', 'summary_page_url');
        }
    }
    $title = false;
    if ($story_title) {
        $headline_text = $story_title;
        $headline_url = false;
        $headline = compact('headline_text', 'headline_url');
        $title = view('headline', false, $headline);
    }
    $sidebar = view('sidebar', false, compact('search', 'cloud', 'title', 'summary'));
    $search = !$story_nosearch ? compact('search_url', 'search_text', 'suggest_url') : false;
    $edit = user_has_role('writer') ? url('storyedit', $_SESSION['user']['locale']) . '/' . $story_id . '/' . $page_id . '?' . 'clang=' . $lang : false;
    $validate = url('story', $lang) . '/' . $story_name . '/' . $page_name;
    $banner = build('banner', $lang, $with_toolbar ? compact('headline', 'search') : compact('headline', 'edit', 'validate', 'search'));
    $toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'validate')) : false;
    $output = layout('standard', compact('sharebar', 'toolbar', 'banner', 'sidebar', 'content'));
    return $output;
}