Example #1
0
 public static function link_generate($file_id = false, $options = array(), $link_options = array())
 {
     $key = 'file_id';
     if ($file_id === false && $link_options) {
         foreach ($link_options as $link_option) {
             if (isset($link_option['data']) && isset($link_option['data'][$key])) {
                 ${$key} = $link_option['data'][$key];
                 break;
             }
         }
         if (!${$key} && isset($_REQUEST[$key])) {
             ${$key} = $_REQUEST[$key];
         }
     }
     $bubble_to_module = false;
     if (!isset($options['type'])) {
         $options['type'] = 'file';
     }
     $options['page'] = isset($options['page']) ? $options['page'] : 'file_admin';
     if (!isset($options['arguments'])) {
         $options['arguments'] = array();
     }
     $options['arguments']['file_id'] = $file_id;
     $options['module'] = 'file';
     if (isset($options['data'])) {
         $data = $options['data'];
     } else {
         $data = array();
         if ($file_id > 0) {
             $data = self::get_file($file_id);
         }
         $options['data'] = $data;
     }
     if (!isset($data['customer_id']) && isset($_REQUEST['customer_id']) && (int) $_REQUEST['customer_id']) {
         $data['customer_id'] = (int) $_REQUEST['customer_id'];
     }
     // what text should we display in this link?
     $options['text'] = !isset($data['file_name']) || !trim($data['file_name']) ? 'N/A' : $data['file_name'];
     if (isset($data['customer_id']) && $data['customer_id'] > 0) {
         $bubble_to_module = array('module' => 'customer', 'argument' => 'customer_id');
     }
     array_unshift($link_options, $options);
     if (!module_security::has_feature_access(array('name' => 'Customers', 'module' => 'customer', 'category' => 'Customer', 'view' => 1, 'description' => 'view'))) {
         $bubble_to_module = false;
         /*if(!isset($options['full']) || !$options['full']){
               return '#';
           }else{
               return isset($options['text']) ? $options['text'] : 'N/A';
           }*/
     }
     if ($bubble_to_module) {
         global $plugins;
         return $plugins[$bubble_to_module['module']]->link_generate(false, array(), $link_options);
     } else {
         // return the link as-is, no more bubbling or anything.
         // pass this off to the global link_generate() function
         return link_generate($link_options);
     }
 }
Example #2
0
 public static function link_generate($invoice_id = false, $options = array(), $link_options = array())
 {
     // link generation can be cached and save a few db calls.
     $link_cache_key = 'invoice_link3_' . md5(module_security::get_loggedin_id() . '_' . serialize(func_get_args())) . '_' . (isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : false);
     $link_cache_timeout = module_config::c('cache_link_timeout', 3600);
     if ($cached_link = module_cache::get('invoice', $link_cache_key)) {
         return $cached_link;
     }
     $key = 'invoice_id';
     if ($invoice_id === false && $link_options) {
         foreach ($link_options as $link_option) {
             if (isset($link_option['data']) && isset($link_option['data'][$key])) {
                 ${$key} = $link_option['data'][$key];
                 break;
             }
         }
         if (!${$key} && isset($_REQUEST[$key])) {
             ${$key} = $_REQUEST[$key];
         }
     }
     $bubble_to_module = false;
     if (!isset($options['type'])) {
         $options['type'] = 'invoice';
     }
     if (!isset($options['page'])) {
         $options['page'] = 'invoice_admin';
     }
     if (!isset($options['arguments'])) {
         $options['arguments'] = array();
     }
     $options['arguments']['invoice_id'] = $invoice_id;
     $options['module'] = 'invoice';
     if (!isset($options['data']) || !$options['data']) {
         if ((int) $invoice_id > 0) {
             $data = self::get_invoice($invoice_id, 2);
         } else {
             $data = array();
         }
         $options['data'] = $data;
     } else {
         $data = $options['data'];
     }
     // todo - read total_amoutn_due from new c_ cached field
     if (!isset($data['total_amount_due'])) {
     } else {
         if (isset($data['date_cancel']) && $data['date_cancel'] != '0000-00-00') {
             $link_options['class'] = 'invoice_cancel';
         } else {
             if ($data['total_amount_due'] <= 0) {
                 $link_options['class'] = 'success_text';
             } else {
                 $link_options['class'] = 'error_text';
             }
         }
     }
     // what text should we display in this link?
     $options['text'] = !isset($data['name']) || !trim($data['name']) ? 'N/A' : $data['name'];
     if (self::can_i('edit', 'Invoices') && (isset($data['customer_id']) && $data['customer_id'] > 0 || isset($_REQUEST['customer_id']) && $_REQUEST['customer_id'] > 0)) {
         $bubble_to_module = array('module' => 'customer', 'argument' => 'customer_id');
     }
     array_unshift($link_options, $options);
     if (!module_security::has_feature_access(array('name' => 'Customers', 'module' => 'customer', 'category' => 'Customer', 'view' => 1, 'description' => 'view'))) {
         $bubble_to_module = false;
         /*
                     if(!isset($options['full']) || !$options['full']){
                         return '#';
                     }else{
                         return isset($options['text']) ? $options['text'] : 'N/A';
                     }*/
     }
     if ($bubble_to_module) {
         global $plugins;
         $link = $plugins[$bubble_to_module['module']]->link_generate(false, array(), $link_options);
     } else {
         // return the link as-is, no more bubbling or anything.
         // pass this off to the global link_generate() function
         //print_r($link_options);
         $link = link_generate($link_options);
     }
     module_cache::put('invoice', $link_cache_key, $link, $link_cache_timeout);
     return $link;
 }
Example #3
0
 public function link_generate($config_id = false, $options = array(), $link_options = array())
 {
     // we accept link options from a bubbled link call.
     // so we have to prepent our options to the start of the link_options array incase
     // anything bubbled up to this method.
     // build our options into the $options variable and array_unshift this onto the link_options at the end.
     // we check if we're bubbling from a sub link, and find the item id from a sub link
     if ($config_id === false && $link_options) {
         $key = 'config_id';
         foreach ($link_options as $link_option) {
             if (isset($link_option['data']) && isset($link_option['data'][$key])) {
                 ${$key} = $link_option['data'][$key];
                 break;
             }
         }
     }
     // grab the data for this particular link, so that any parent bubbled link_generate() methods
     // can access data from a sub item (eg: an id)
     $data = array();
     $options['data'] = $data;
     // what text should we display in this link?
     $options['text'] = !isset($data['part_number']) || !trim($data['part_number']) ? 'N/A' : $data['part_number'];
     // generate the arguments for this link
     $options['arguments'] = array('config_id' => $config_id);
     // generate the path (module & page) for this link
     $options['page'] = isset($options['page']) ? $options['page'] : 'config_admin';
     $options['module'] = $this->module_name;
     // append this to our link options array, which is eventually passed to the
     // global link generate function which takes all these arguments and builds a link out of them.
     // optionally bubble this link up to a parent link_generate() method, so we can nest modules easily
     // change this variable to the one we are going to bubble up to:
     $bubble_to_module = false;
     if (isset($options['bubble_to_module'])) {
         $bubble_to_module = $options['bubble_to_module'];
     }
     array_unshift($link_options, $options);
     if ($bubble_to_module) {
         global $plugins;
         return $plugins[$bubble_to_module['module']]->link_generate(false, $bubble_to_module, $link_options);
     } else {
         // return the link as-is, no more bubbling or anything.
         // pass this off to the global link_generate() function
         return link_generate($link_options);
     }
 }
Example #4
0
    public static function import_link($options = array())
    {
        $m = get_display_mode();
        if ($m == 'mobile' || $m == 'iframe') {
            return false;
        }
        if (module_config::c('import_method', 1)) {
            ?>
 <form action="<?php 
            echo link_generate(array(array('page' => 'import', 'module' => 'import_export')));
            ?>
" method="post" style="display:none;" id="import_form"><input type="submit" name="buttongo" value="go"><input type="hidden" name="import_options" value='<?php 
            echo module_config::c('import_export_base64', 1) ? base64_encode(json_encode($options)) : addcslashes(json_encode($options), "'");
            ?>
'></form> <?php 
            $url = 'javascript:document.forms.import_form.submit();';
        } else {
            //oldway:
            $url = link_generate(array(array('arguments' => array('import_options' => base64_encode(json_encode($options))), 'page' => 'import', 'module' => 'import_export')));
        }
        return $url;
    }
Example #5
0
 public static function link_generate($extra_default_id = false, $options = array(), $link_options = array())
 {
     $key = 'extra_default_id';
     if ($extra_default_id === false && $link_options) {
         foreach ($link_options as $link_option) {
             if (isset($link_option['data']) && isset($link_option['data'][$key])) {
                 ${$key} = $link_option['data'][$key];
                 break;
             }
         }
         if (!${$key} && isset($_REQUEST[$key])) {
             ${$key} = $_REQUEST[$key];
         }
     }
     $bubble_to_module = false;
     if (!isset($options['type'])) {
         $options['type'] = 'extra';
     }
     $options['page'] = 'extra_settings';
     if (!isset($options['arguments'])) {
         $options['arguments'] = array();
     }
     $options['arguments']['extra_default_id'] = $extra_default_id;
     $options['module'] = 'extra';
     $data = self::get_extra_default($extra_default_id);
     $options['data'] = $data;
     // what text should we display in this link?
     $options['text'] = !isset($data['extra_key']) || !trim($data['extra_key']) ? 'N/A' : htmlspecialchars($data['extra_key']);
     //if(isset($data['extra_default_id']) && $data['extra_default_id']>0){
     $bubble_to_module = array('module' => 'config', 'argument' => 'extra_default_id');
     // }
     array_unshift($link_options, $options);
     if ($bubble_to_module) {
         global $plugins;
         return $plugins[$bubble_to_module['module']]->link_generate(false, array(), $link_options);
     } else {
         // return the link as-is, no more bubbling or anything.
         // pass this off to the global link_generate() function
         return link_generate($link_options);
     }
 }
Example #6
0
 public static function link_generate($report_id = false, $options = array(), $link_options = array())
 {
     $key = 'report_id';
     if ($report_id === false && $link_options) {
         foreach ($link_options as $link_option) {
             if (isset($link_option['data']) && isset($link_option['data'][$key])) {
                 ${$key} = $link_option['data'][$key];
                 break;
             }
         }
         if (!${$key} && isset($_REQUEST[$key])) {
             ${$key} = $_REQUEST[$key];
         }
     }
     $bubble_to_module = false;
     if (!isset($options['type'])) {
         $options['type'] = 'report';
     }
     $options['page'] = 'report_admin';
     if (!isset($options['arguments'])) {
         $options['arguments'] = array();
     }
     $options['arguments']['report_id'] = $report_id;
     $options['module'] = 'report';
     if ((int) $report_id > 0) {
         $data = self::get_report($report_id);
         $options['data'] = $data;
     } else {
         $data = array();
         if (!isset($options['full']) || !$options['full']) {
             // we are not doing a full <a href> link, only the url (eg: create new report)
         } else {
             // we are trying to do a full <a href> link -
             return _l('N/A');
         }
     }
     // what text should we display in this link?
     $options['text'] = !isset($data['report_id']) || !trim($data['report_id']) ? _l('N/A') : $data['report_id'];
     array_unshift($link_options, $options);
     if (!module_security::has_feature_access(array('name' => 'Customers', 'module' => 'customer', 'category' => 'Customer', 'view' => 1, 'description' => 'view'))) {
         if (!isset($options['full']) || !$options['full']) {
             return '#';
         } else {
             return isset($options['text']) ? $options['text'] : _l('N/A');
         }
     }
     if ($bubble_to_module) {
         global $plugins;
         return $plugins[$bubble_to_module['module']]->link_generate(false, array(), $link_options);
     } else {
         // return the link as-is, no more bubbling or anything.
         // pass this off to the global link_generate() function
         return link_generate($link_options);
     }
 }
Example #7
0
 public static function link_generate($backup_id = false, $options = array(), $link_options = array())
 {
     $key = 'backup_id';
     if ($backup_id === false && $link_options) {
         foreach ($link_options as $link_option) {
             if (isset($link_option['data']) && isset($link_option['data'][$key])) {
                 ${$key} = $link_option['data'][$key];
                 break;
             }
         }
         if (!${$key} && isset($_REQUEST[$key])) {
             ${$key} = $_REQUEST[$key];
         }
     }
     $bubble_to_module = false;
     if (!isset($options['type'])) {
         $options['type'] = 'backup';
     }
     if (!isset($options['page'])) {
         $options['page'] = 'backup_settings';
     }
     if (!isset($options['arguments'])) {
         $options['arguments'] = array();
     }
     $options['arguments']['backup_id'] = $backup_id;
     $options['module'] = 'backup';
     // what text should we display in this link?
     if (isset($options['data']) && $options['data']) {
         //$options['data'] = $options['data'];
     } else {
         $data = self::get_backup($backup_id);
         $options['data'] = $data;
     }
     $options['text'] = isset($options['data']['question']) ? $options['data']['question'] : _l('N/A');
     array_unshift($link_options, $options);
     if (self::can_i('view', 'Backups')) {
         if ($options['page'] == 'backup_settings') {
             $bubble_to_module = array('module' => 'config');
         }
     }
     if ($bubble_to_module) {
         global $plugins;
         return $plugins[$bubble_to_module['module']]->link_generate(false, array(), $link_options);
     } else {
         // return the link as-is, no more bubbling or anything.
         // pass this off to the global link_generate() function
         return link_generate($link_options);
     }
 }
Example #8
0
 public static function link_generate($job_id = false, $options = array(), $link_options = array())
 {
     // link generation can be cached and save a few db calls.
     $cache_options = $options;
     if (isset($cache_options['data'])) {
         unset($cache_options['data']);
         $cache_options['data_name'] = isset($options['data']) && isset($options['data']['name']) ? $options['data']['name'] : '';
     }
     $cache_options['customer_id'] = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : false;
     $cache_options['current_user'] = module_security::get_loggedin_id();
     $link_cache_key = 'job_link_' . $job_id . '_' . md5(serialize($cache_options));
     if ($cached_link = module_cache::get('job', $link_cache_key)) {
         return $cached_link;
     }
     $link_cache_timeout = module_config::c('cache_link_timeout', 3600);
     $key = 'job_id';
     if ($job_id === false && $link_options) {
         foreach ($link_options as $link_option) {
             if (isset($link_option['data']) && isset($link_option['data'][$key])) {
                 ${$key} = $link_option['data'][$key];
                 break;
             }
         }
         if (!${$key} && isset($_REQUEST[$key])) {
             ${$key} = $_REQUEST[$key];
         }
     }
     $bubble_to_module = false;
     if (!isset($options['type'])) {
         $options['type'] = 'job';
     }
     $options['page'] = 'job_admin';
     if (!isset($options['arguments'])) {
         $options['arguments'] = array();
     }
     $options['module'] = 'job';
     $data = array();
     if (isset($options['data'])) {
         $data = $options['data'];
     }
     if (isset($options['full']) && $options['full']) {
         // only hit database if we need to print a full link with the name in it.
         if (!isset($options['data']) || !$options['data']) {
             if ((int) $job_id > 0) {
                 $data = self::get_job($job_id, false, true);
             } else {
                 $data = array();
             }
             $options['data'] = $data;
         } else {
             $data = $options['data'];
         }
         // what text should we display in this link?
         $options['text'] = !isset($data['name']) || !trim($data['name']) ? _l('N/A') : $data['name'];
         if (!$data || !$job_id || isset($data['_no_access'])) {
             $link = $options['text'];
             module_cache::put('job', $link_cache_key, $link, $link_cache_timeout);
             return $link;
         }
     } else {
         if (isset($_REQUEST['customer_id']) && (int) $_REQUEST['customer_id'] > 0) {
             $data['customer_id'] = (int) $_REQUEST['customer_id'];
         }
     }
     $options['text'] = isset($options['text']) ? $options['text'] : '';
     // htmlspecialchars is done in link_generatE() function
     // generate the arguments for this link
     $options['arguments']['job_id'] = $job_id;
     if (isset($data['customer_id']) && $data['customer_id'] > 0) {
         $bubble_to_module = array('module' => 'customer', 'argument' => 'customer_id');
     }
     array_unshift($link_options, $options);
     if (!module_security::has_feature_access(array('name' => 'Customers', 'module' => 'customer', 'category' => 'Customer', 'view' => 1, 'description' => 'view'))) {
         $bubble_to_module = false;
         /*
         if(!isset($options['full']) || !$options['full']){
             return '#';
         }else{
             return isset($options['text']) ? $options['text'] : _l('N/A');
         }
         */
     }
     if ($bubble_to_module) {
         global $plugins;
         $link = $plugins[$bubble_to_module['module']]->link_generate(false, array(), $link_options);
     } else {
         // return the link as-is, no more bubbling or anything.
         // pass this off to the global link_generate() function
         $link = link_generate($link_options);
     }
     module_cache::put('job', $link_cache_key, $link, $link_cache_timeout);
     return $link;
 }
Example #9
0
 /**
  * This is where all the magic happens.
  * We take a page name (ie: the name of the 'plugin_extra' block like 'customer') and the html_data for that page (or block, or single input element)
  * We check each of the input elements (there may be more than 1 in the html data!) to see if any of them are marked for encryption (see encrypt_field table)
  *
  * @static
  * @param $page_name
  * @param $html_data
  */
 public static function parse_html_input($page_name, $html_data, $edit = true)
 {
     // find out what field names are encrypted against thie 'page_name'
     $fields = get_multiple('encrypt_field', array('page_name' => $page_name), 'field_name');
     // convert any of these encrypted fields into a ****** [lock] block.
     // first look for all text input fields (could also be date input fields!)
     if (preg_match_all('#<input[^>]*type="text"[^>]*>#imsU', $html_data, $matches)) {
         foreach ($matches[0] as $match) {
             if (preg_match('#display\\s*:\\s*none#', $match)) {
                 continue;
             }
             if (preg_match('#\\[new\\]#', $match)) {
                 continue;
             }
             // find the id or the name of each element.
             $encrypt_field_id = false;
             $encrypt_field_name = '';
             if (preg_match('#id="([^"]*)"#', $match, $name_matches)) {
                 $encrypt_field_name = $name_matches[1];
             } else {
                 if (preg_match('#name="([^"]*)"#', $match, $name_matches)) {
                     $encrypt_field_name = $name_matches[1];
                 }
             }
             if (isset($fields[$encrypt_field_name])) {
                 // this is an encryptable field!
                 $encrypt_field_id = $fields[$encrypt_field_name]['encrypt_field_id'];
             }
             $existing_value = '';
             if (preg_match('#value="([^"]+)#', $match, $value_matches)) {
                 if (strpos($value_matches[1], 'encrypt:') === false) {
                     $existing_value = $value_matches[1];
                 }
             }
             if ($encrypt_field_id) {
                 // find the "vlaue" of this input box.
                 // the value will be the id in the encrypt table.
                 // it should look something like this:
                 //    encrypt:123
                 $encrypt_id = 0;
                 // new value
                 $replace = '';
                 // what we are going to replace this with.
                 if (preg_match('#value="encrypt:([^"]*)"#', $match, $value_matches)) {
                     $encrypt_id = (int) $value_matches[1];
                     // remove the value from the input box and display our empty box on the page.
                     // rename our real box to a hidden input and give it an id so we can load our
                     // encrypt:123 value into it for submission.
                     $dummy_input = preg_replace('#value="[^"]+"#', 'value="*********"', $match);
                     $dummy_input = preg_replace('#id="[^"]+"#', '', $dummy_input);
                     $dummy_input = preg_replace('#name="[^"]+"#', 'name="nothing" disabled="disabled"', $dummy_input);
                     $replace .= $dummy_input;
                     // add our hidden input back so normal form submits work.
                     // give our hidden input an id that we can work with, so we can update it's value after saving.
                     $hidden_input = preg_replace('#id="[^"]+"#', '', $match);
                     $hidden_input = preg_replace('#type="text"#i', 'type="hidden" id="encrypt_hidden_' . $encrypt_field_id . '"', $hidden_input);
                     $replace .= $hidden_input;
                 } else {
                     // no encrypted value within this field yet.
                     // we leave the box as is, but give the user the option to encrypt whatever is in it.
                     //$dummy_input = preg_replace('#value="[^"]+"#','value=""',$match);
                     // remove any id from the box.
                     $dummy_input = preg_replace('#id="[^"]+"#', '', $match);
                     $dummy_input = preg_replace('#type="text"#i', 'type="text" id="encrypt_hidden_' . $encrypt_field_id . '"', $dummy_input);
                     $replace .= $dummy_input;
                 }
                 if (!$edit) {
                     $replace = '*********';
                 }
                 // put our hidden field in here.
                 if (self::can_i('view', 'Encrypts')) {
                     $link = link_generate(array('raw' => true, array('full' => true, 'text' => '<img src="' . full_link('includes/plugin_encrypt/images/' . (!$encrypt_id ? 'un' : '') . 'lock.png') . '" style="vertical-align:top;" border="0"> ', 'module' => 'encrypt', 'page' => 'encrypt_popup', 'arguments' => array('encrypt_id' => $encrypt_id, 'encrypt_field_id' => $encrypt_field_id, 'page_name' => $page_name, 'value' => base64_encode($existing_value), 'callback_id' => 'encrypt_hidden_' . $encrypt_field_id, 'editable' => $edit))));
                     $button = '<span class="encrypt_popup">' . popup_link($link, array('width' => 600, 'height' => 400, 'force' => true, 'hide_close' => true, 'title' => _l('Encryption'))) . '</span>';
                     $replace .= ' &nbsp; ' . $button;
                 }
                 $html_data = preg_replace('#' . preg_quote($match, '#') . '#msU', str_replace('$', '\\$', $replace), $html_data);
             } else {
                 if (self::can_i('create', 'Encrypts') && $edit) {
                     // no encrypt field for this one.
                     $element_id = '';
                     if (preg_match('#id="([^"]+)"#', $match, $id_matches)) {
                         $element_id = $id_matches[1];
                     }
                     // give them an option to encrypt this field.
                     $link = link_generate(array('raw' => true, array('full' => true, 'text' => '<img src="' . full_link('includes/plugin_encrypt/images/unlock.png') . '" style="vertical-align:top;" border="0"> ', 'module' => 'encrypt', 'page' => 'encrypt_popup', 'arguments' => array('encrypt_field_name' => $encrypt_field_name, 'page_name' => $page_name, 'value' => base64_encode($existing_value), 'callback_id' => $element_id, 'editable' => $edit))));
                     $button = '<span class="encrypt_create">' . popup_link($link, array('width' => 600, 'height' => 300, 'force' => true, 'hide_close' => false)) . '</span>';
                     $html_data = preg_replace('#' . preg_quote($match, '#') . '#msU', str_replace('$', '\\$', $match) . ' &nbsp; ' . $button, $html_data);
                 }
             }
         }
     }
     // now all textareas:
     // now all select fields:
     return $html_data;
 }
Example #10
0
 /** static stuff */
 public static function link_generate($member_id = false, $options = array(), $link_options = array())
 {
     // we accept link options from a bubbled link call.
     // so we have to prepent our options to the start of the link_options array incase
     // anything bubbled up to this method.
     // build our options into the $options variable and array_unshift this onto the link_options at the end.
     $key = 'member_id';
     // the key we look for in data arrays, on in _REQUEST variables. for sub link building.
     // we check if we're bubbling from a sub link, and find the item id from a sub link
     if (${$key} === false && $link_options) {
         foreach ($link_options as $link_option) {
             if (isset($link_option['data']) && isset($link_option['data'][$key])) {
                 ${$key} = $link_option['data'][$key];
                 break;
             }
         }
         if (!${$key} && isset($_REQUEST[$key])) {
             ${$key} = $_REQUEST[$key];
         }
     }
     // grab the data for this particular link, so that any parent bubbled link_generate() methods
     // can access data from a sub item (eg: an id)
     if (isset($options['full']) && $options['full']) {
         // only hit database if we need to print a full link with the name in it.
         if (!isset($options['data']) || !$options['data']) {
             $data = self::get_member($member_id);
             $options['data'] = $data;
         } else {
             $data = $options['data'];
         }
         // what text should we display in this link?
         $options['text'] = $data['first_name'] . ' ' . $data['last_name'];
     }
     $options['text'] = isset($options['text']) ? htmlspecialchars($options['text']) : '';
     // generate the arguments for this link
     $options['arguments'] = array('member_id' => $member_id);
     // generate the path (module & page) for this link
     $options['page'] = 'member_admin' . ($member_id || $member_id == 'new' ? '' : '_list');
     $options['module'] = 'member';
     // append this to our link options array, which is eventually passed to the
     // global link generate function which takes all these arguments and builds a link out of them.
     if (!self::can_i('view', 'Members')) {
         if (!isset($options['full']) || !$options['full']) {
             return '#';
         } else {
             return isset($options['text']) ? $options['text'] : 'N/A';
         }
     }
     // optionally bubble this link up to a parent link_generate() method, so we can nest modules easily
     // change this variable to the one we are going to bubble up to:
     $bubble_to_module = false;
     if (class_exists('module_newsletter', false) && module_config::c('member_menu_under_newsletter', 1)) {
         $bubble_to_module = array('module' => 'newsletter', 'argument' => 'member_id');
     }
     /*$bubble_to_module = array(
           'module' => 'people',
           'argument' => 'people_id',
       );*/
     array_unshift($link_options, $options);
     if ($bubble_to_module) {
         global $plugins;
         return $plugins[$bubble_to_module['module']]->link_generate(false, array(), $link_options);
     } else {
         // return the link as-is, no more bubbling or anything.
         // pass this off to the global link_generate() function
         return link_generate($link_options);
     }
 }
Example #11
0
 public static function link_generate($faq_id = false, $options = array(), $link_options = array())
 {
     $key = 'faq_id';
     if ($faq_id === false && $link_options) {
         foreach ($link_options as $link_option) {
             if (isset($link_option['data']) && isset($link_option['data'][$key])) {
                 ${$key} = $link_option['data'][$key];
                 break;
             }
         }
         if (!${$key} && isset($_REQUEST[$key])) {
             ${$key} = $_REQUEST[$key];
         }
     }
     $bubble_to_module = false;
     if (!isset($options['type'])) {
         $options['type'] = 'faq';
     }
     if (!isset($options['page'])) {
         $options['page'] = 'faq_settings';
     }
     if (!isset($options['arguments'])) {
         $options['arguments'] = array();
     }
     $options['arguments']['faq_id'] = $faq_id;
     $options['module'] = 'faq';
     // what text should we display in this link?
     if ($options['page'] == 'faq_products') {
         if (isset($options['data']) && $options['data']) {
             //$options['data'] = $options['data'];
         } else {
             $data = self::get_faq_product($faq_id);
             $options['data'] = $data;
         }
         $options['text'] = isset($options['data']['name']) ? $options['data']['name'] : '';
         if (!module_config::can_i('view', 'Settings') || !module_faq::can_i('edit', 'FAQ')) {
             return htmlspecialchars($options['text']);
         }
         array_unshift($link_options, $options);
         $options['page'] = 'faq_settings';
         // bubble back onto ourselves for the link.
         return self::link_generate($faq_id, $options, $link_options);
     } else {
         if ($options['page'] == 'faq_questions') {
             if (isset($options['data']) && $options['data']) {
                 //$options['data'] = $options['data'];
             } else {
                 $data = self::get_faq($faq_id);
                 $options['data'] = $data;
             }
             $options['text'] = isset($options['data']['question']) ? $options['data']['question'] : '';
             array_unshift($link_options, $options);
             $options['page'] = 'faq_settings';
             // bubble back onto ourselves for the link.
             return self::link_generate($faq_id, $options, $link_options);
         } else {
             if (isset($options['data']) && $options['data']) {
                 //$options['data'] = $options['data'];
             } else {
                 $data = self::get_faq($faq_id);
                 $options['data'] = $data;
                 $options['class'] = 'error';
             }
             $options['text'] = isset($options['data']['question']) ? $options['data']['question'] : _l('N/A');
         }
     }
     array_unshift($link_options, $options);
     if ($options['page'] == 'faq_admin' && $options['data'] && isset($options['data']['status_id'])) {
         // pick the class name for the error. or faq status
         $link_options['class'] = 'faq_status_' . $options['data']['status_id'];
     }
     if (self::can_i('edit', 'FAQ')) {
         if ($options['page'] == 'faq_settings') {
             $bubble_to_module = array('module' => 'config');
         }
     }
     if ($bubble_to_module) {
         global $plugins;
         return $plugins[$bubble_to_module['module']]->link_generate(false, array(), $link_options);
     } else {
         // return the link as-is, no more bubbling or anything.
         // pass this off to the global link_generate() function
         return link_generate($link_options);
     }
 }
Example #12
0
 /** static stuff */
 public static function link_generate($customer_id = false, $options = array(), $link_options = array())
 {
     // link generation can be cached and save a few db calls.
     $link_cache_key = 'customer_link_' . md5(module_security::get_loggedin_id() . '_' . serialize(func_get_args()) . '_' . (isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : false));
     $link_cache_timeout = module_config::c('cache_link_timeout', 3600);
     if ($cached_link = module_cache::get('customer', $link_cache_key)) {
         return $cached_link;
     }
     // we accept link options from a bubbled link call.
     // so we have to prepent our options to the start of the link_options array incase
     // anything bubbled up to this method.
     // build our options into the $options variable and array_unshift this onto the link_options at the end.
     $key = 'customer_id';
     // the key we look for in data arrays, on in _REQUEST variables. for sub link building.
     $customer_data = false;
     // we check if we're bubbling from a sub link, and find the item id from a sub link
     if (${$key} === false && $link_options) {
         foreach ($link_options as $link_option) {
             if (isset($link_option['data']) && isset($link_option['data'][$key])) {
                 ${$key} = $link_option['data'][$key];
                 break;
             }
         }
         if (!${$key} && isset($_REQUEST[$key])) {
             ${$key} = $_REQUEST[$key];
         }
         // check if this still exists.
         // this is a hack incase the customer is deleted, the invoices are still left behind.
         if (${$key} && $link_options) {
             $customer_data = self::get_customer(${$key}, true, true);
             if (!$customer_data || !isset($customer_data[$key]) || $customer_data[$key] != ${$key}) {
                 $link = link_generate($link_options);
                 module_cache::put('customer', $link_cache_key, $link, $link_cache_timeout);
                 return $link;
             }
         }
     }
     // grab the data for this particular link, so that any parent bubbled link_generate() methods
     // can access data from a sub item (eg: an id)
     //$options['text'] = isset($options['text']) ? htmlspecialchars($options['text']) : '';
     // generate the arguments for this link
     if (!isset($options['type'])) {
         $options['type'] = 'customer';
     }
     if (!isset($options['page'])) {
         $options['page'] = 'customer_admin_' . ($customer_id || $customer_id == 'new' ? 'open' : 'list');
     }
     if (!isset($options['arguments'])) {
         $options['arguments'] = array();
     }
     $options['arguments']['customer_id'] = $customer_id;
     if (!isset($options['arguments']['customer_type_id'])) {
         $options['arguments']['customer_type_id'] = self::get_current_customer_type_id();
     }
     // generate the path (module & page) for this link
     $options['module'] = 'customer';
     if ($options['page'] == 'customer_settings_types') {
         if (empty($options['data'])) {
             $data = self::get_customer_type($customer_id);
             $options['data'] = $data;
         }
         $options['text'] = isset($options['data']['type_name_plural']) ? $options['data']['type_name_plural'] : '';
         array_unshift($link_options, $options);
         $options['page'] = 'customer_settings';
         // bubble back onto ourselves for the link.
         return self::link_generate(0, $options, $link_options);
     }
     if (isset($options['full']) && $options['full']) {
         // only hit database if we need to print a full link with the name in it.
         if (!isset($options['data']) || !$options['data']) {
             if ((int) $customer_id > 0) {
                 $data = $customer_data ? $customer_data : self::get_customer($customer_id, true, true);
             } else {
                 $data = array();
             }
             $options['data'] = $data;
         } else {
             $data = $options['data'];
         }
         // what text should we display in this link?
         $options['text'] = !empty($options['text']) ? $options['text'] : (!isset($data['customer_name']) || !trim($data['customer_name']) ? _l('N/A') : $data['customer_name']);
         if (!$data || !$customer_id && $options['page'] != 'customer_settings' || !$customer_id && $options['page'] == 'customer_settings' && !$options['arguments']['customer_type_id'] || isset($data['_no_access'])) {
             $link = $options['text'];
             module_cache::put('customer', $link_cache_key, $link, $link_cache_timeout);
             return $link;
         }
     }
     // append this to our link options array, which is eventually passed to the
     // global link generate function which takes all these arguments and builds a link out of them.
     // $options['skip_permissions'] is used in password reset, otherwise we get # in url
     $page_type = 'Active Leads';
     if ($options['arguments']['customer_type_id'] > 0) {
         $customer_type = module_customer::get_customer_type($options['arguments']['customer_type_id']);
         if ($customer_type && !empty($customer_type['type_name'])) {
             $page_type = $customer_type['type_name_plural'];
         }
     }
     if (!self::can_i('view', $page_type) && (!isset($options['skip_permissions']) || !$options['skip_permissions'])) {
         if (!isset($options['full']) || !$options['full']) {
             $link = '#';
         } else {
             $link = isset($options['text']) ? $options['text'] : 'N/A';
         }
         module_cache::put('customer', $link_cache_key, $link, $link_cache_timeout);
         return $link;
     }
     if (isset($data['customer_status'])) {
         switch ($data['customer_status']) {
             case _CUSTOMER_STATUS_OVERDUE:
                 $link_options['class'] = 'customer_overdue error_text';
                 break;
             case _CUSTOMER_STATUS_OWING:
                 $link_options['class'] = 'customer_owing';
                 break;
             case _CUSTOMER_STATUS_PAID:
                 $link_options['class'] = 'customer_paid success_text';
                 break;
         }
     }
     // optionally bubble this link up to a parent link_generate() method, so we can nest modules easily
     // change this variable to the one we are going to bubble up to:
     $bubble_to_module = false;
     if ($options['page'] == 'customer_settings') {
         $link_options[0]['arguments']['customer_id'] = false;
         $bubble_to_module = array('module' => 'config');
     }
     /*$bubble_to_module = array(
           'module' => 'people',
           'argument' => 'people_id',
       );*/
     array_unshift($link_options, $options);
     if ($bubble_to_module) {
         global $plugins;
         $link = $plugins[$bubble_to_module['module']]->link_generate(false, array(), $link_options);
     } else {
         // return the link as-is, no more bubbling or anything.
         // pass this off to the global link_generate() function
         $link = link_generate($link_options);
     }
     module_cache::put('customer', $link_cache_key, $link, $link_cache_timeout);
     return $link;
 }
Example #13
0
 public static function link_generate($user_id = false, $options = array(), $link_options = array())
 {
     $link_cache_key = 'user_link_' . md5(module_security::get_loggedin_id() . '_' . serialize(func_get_args()));
     $link_cache_timeout = module_config::c('cache_link_timeout', 3600);
     if ($cached_link = module_cache::get('user', $link_cache_key)) {
         return $cached_link;
     }
     $key = 'user_id';
     if ($user_id === false && $link_options) {
         foreach ($link_options as $link_option) {
             if (isset($link_option['data']) && isset($link_option['data'][$key])) {
                 ${$key} = $link_option['data'][$key];
                 break;
             }
         }
         if (!${$key} && isset($_REQUEST[$key])) {
             ${$key} = $_REQUEST[$key];
         }
     }
     $bubble_to_module = false;
     if (isset($options['data'])) {
         $data = $options['data'];
     } else {
         $data = array();
     }
     if (!$data && $user_id) {
         $data = self::get_user($user_id, false, true, true);
         //,2);
         $options['data'] = $data;
     }
     if (isset($options['full']) && $options['full']) {
         // what text should we display in this link?
         $options['text'] = !isset($data['name']) || !trim($data['name']) ? 'N/A' : $data['name'] . (isset($data['last_name']) ? ' ' . $data['last_name'] : '');
         if (!$data || !$user_id) {
             // linking to a new user?
             // shouldn't happen in a "full" link.
             return $options['text'];
         }
         if (isset($data['_perms']) && !$data['_perms']) {
             return $options['text'];
         }
     }
     $use_master_key = self::get_contact_master_key();
     if (isset($data[$use_master_key]) && $data[$use_master_key]) {
         $options['type'] = 'contact';
     } else {
         if (isset($data['customer_id']) && $data['customer_id']) {
             $use_master_key = 'customer_id';
             $options['type'] = 'contact';
         } else {
             if (isset($data['vendor_id']) && $data['vendor_id']) {
                 $use_master_key = 'vendor_id';
                 $options['type'] = 'contact';
             }
         }
     }
     $options['arguments'] = array('user_id' => $user_id);
     if (!isset($options['type'])) {
         $options['type'] = 'user';
     }
     switch ($options['type']) {
         case 'contact':
             $options['arguments'][$use_master_key] = isset($data[$use_master_key]) ? $data[$use_master_key] : 0;
             // for a contact link under supplier or a customer
             $options['page'] = 'contact_admin';
             switch ($use_master_key) {
                 case 'customer_id':
                     if ($user_id == 'new' || (int) $user_id > 0) {
                         // so the "view all contacts" link works.
                         $bubble_to_module = array('module' => 'customer', 'argument' => 'customer_id');
                     }
                     break;
                 case 'vendor_id':
                     if ($user_id == 'new' || (int) $user_id > 0) {
                         // so the "view all contacts" link works.
                         $bubble_to_module = array('module' => 'vendor', 'argument' => 'vendor_id');
                     }
                     break;
             }
             break;
         default:
             $bubble_to_module = array('module' => 'config');
             $options['page'] = 'user_admin';
     }
     $options['module'] = 'user';
     array_unshift($link_options, $options);
     // check if people have permission to link to this item.
     /*if((!isset($options['skip_permissions']) || !$options['skip_permissions'])){
                 if(isset($options['type']) && $options['type'] == 'contact'){
                     // check they can access this particular contact type
                     if(!module_security::has_feature_access(array(
                         'name' => 'Customers',
                         'module' => 'customer',
                         'category' => 'Customer',
                         'view' => 1,
                         'description' => 'Permissions',
                         ))
                         && (!isset($options['skip_permissions']) || !$options['skip_permissions'])
                     ){
                         if(!isset($options['full']) || !$options['full']){
                             return '#';
                         }else{
                             return isset($options['text']) ? $options['text'] : 'N/A';
                         }
     
                     }
                 }else{
                     // we assume we're linking to a staff user.
                     if(
                         !module_security::has_feature_access(array(
                             'name' => 'Users',
                             'module' => 'user',
                             'category' => 'Config',
                             'description' => 'Permissions',
                             'view' => 1,
                         ))
                         && (int)$user_id != module_security::get_loggedin_id()
                     ){
                         if(!isset($options['full']) || !$options['full']){
                             return '#';
                         }else{
                             return isset($options['text']) ? $options['text'] : 'N/A';
                         }
                     }
     
                 }
             }*/
     if ($bubble_to_module) {
         global $plugins;
         if (isset($plugins[$bubble_to_module['module']])) {
             $link = $plugins[$bubble_to_module['module']]->link_generate(false, array('skip_permissions' => isset($options['skip_permissions']) ? $options['skip_permissions'] : false), $link_options);
             module_cache::put('user', $link_cache_key, $link, $link_cache_timeout);
             return $link;
         }
     }
     // return the link as-is, no more bubbling or anything.
     // pass this off to the global link_generate() function
     $link = link_generate($link_options);
     module_cache::put('user', $link_cache_key, $link, $link_cache_timeout);
     return $link;
 }
Example #14
0
 public static function link_generate($newsletter_id = false, $options = array(), $link_options = array(), $data = false)
 {
     $key = 'newsletter_id';
     if ($newsletter_id === false && $link_options) {
         foreach ($link_options as $link_option) {
             if (isset($link_option['data']) && isset($link_option['data'][$key])) {
                 ${$key} = $link_option['data'][$key];
                 break;
             }
         }
         if (!${$key} && isset($_REQUEST[$key])) {
             ${$key} = $_REQUEST[$key];
         }
     }
     $bubble_to_module = false;
     if (!isset($options['type'])) {
         $options['type'] = 'newsletter';
     }
     if (!isset($options['arguments'])) {
         $options['arguments'] = array();
     }
     $options['arguments']['newsletter_id'] = $newsletter_id;
     $options['module'] = 'newsletter';
     $data = isset($options['data']) ? $options['data'] : array();
     if (isset($options['full']) && $options['full']) {
         if (!$data) {
             $data = self::get_newsletter($newsletter_id);
         }
         $options['data'] = $data;
     }
     // what text should we display in this link?
     if (!isset($options['text']) || !$options['text']) {
         $options['text'] = !isset($data['subject']) || !trim($data['subject']) ? 'N/A' : $data['subject'];
     }
     if (!$link_options) {
         // only bubble up once to this same module.
         //$options['page'] = 'newsletter_edit';
         if (!isset($options['page'])) {
             $options['page'] = 'newsletter_edit';
         }
         $bubble_to_module = array('module' => 'newsletter');
     } else {
         // for first loop
         $options['page'] = 'newsletter_admin';
     }
     array_unshift($link_options, $options);
     if (!module_security::has_feature_access(array('name' => 'Newsletters', 'module' => 'newsletter', 'category' => 'Newsletter', 'view' => 1, 'description' => 'view'))) {
         if (!isset($options['full']) || !$options['full']) {
             return '#';
         } else {
             return isset($options['text']) ? $options['text'] : 'N/A';
         }
     }
     if ($bubble_to_module) {
         global $plugins;
         return $plugins[$bubble_to_module['module']]->link_generate(false, array(), $link_options);
     } else {
         // return the link as-is, no more bubbling or anything.
         // pass this off to the global link_generate() function
         return link_generate($link_options);
     }
 }
Example #15
0
 public static function link_generate($finance_id = false, $options = array(), $link_options = array())
 {
     $key = 'finance_id';
     if ($finance_id === false && $link_options) {
         foreach ($link_options as $link_option) {
             if (isset($link_option['data']) && isset($link_option['data'][$key])) {
                 ${$key} = $link_option['data'][$key];
                 break;
             }
         }
         if (!${$key} && isset($_REQUEST[$key])) {
             ${$key} = $_REQUEST[$key];
         }
     }
     $bubble_to_module = false;
     if (!isset($options['type'])) {
         $options['type'] = 'finance';
     }
     if (!isset($options['page'])) {
         if ($finance_id && !isset($link_options['stop_bubble'])) {
             $options['page'] = 'finance_edit';
         } else {
             $options['page'] = 'finance';
         }
     }
     if (!isset($options['arguments'])) {
         $options['arguments'] = array();
     }
     $options['arguments']['finance_id'] = $finance_id;
     $options['module'] = 'finance';
     if (isset($options['data'])) {
         $data = $options['data'];
     } else {
         $data = self::get_finance($finance_id, false);
     }
     $options['data'] = $data;
     // what text should we display in this link?
     $options['text'] = !isset($data['name']) || !trim($data['name']) ? 'N/A' : $data['name'];
     if (($options['page'] == 'recurring' || $options['page'] == 'finance_edit') && !isset($link_options['stop_bubble'])) {
         $link_options['stop_bubble'] = true;
         $bubble_to_module = array('module' => 'finance', 'argument' => 'finance_id');
     }
     array_unshift($link_options, $options);
     if ($bubble_to_module) {
         global $plugins;
         return $plugins[$bubble_to_module['module']]->link_generate(false, array(), $link_options);
     } else {
         // return the link as-is, no more bubbling or anything.
         // pass this off to the global link_generate() function
         return link_generate($link_options);
     }
 }
Example #16
0
 /** static stuff */
 public static function link_generate($product_id = false, $options = array(), $link_options = array())
 {
     // we accept link options from a bubbled link call.
     // so we have to prepent our options to the start of the link_options array incase
     // anything bubbled up to this method.
     // build our options into the $options variable and array_unshift this onto the link_options at the end.
     $key = 'product_id';
     // the key we look for in data arrays, on in _REQUEST variables. for sub link building.
     // we check if we're bubbling from a sub link, and find the item id from a sub link
     if (${$key} === false && $link_options) {
         foreach ($link_options as $link_option) {
             if (isset($link_option['data']) && isset($link_option['data'][$key])) {
                 ${$key} = $link_option['data'][$key];
                 break;
             }
         }
         if (!${$key} && isset($_REQUEST[$key])) {
             ${$key} = $_REQUEST[$key];
         }
     }
     if (!isset($options['type'])) {
         $options['type'] = 'product';
     }
     if (!isset($options['page'])) {
         $options['page'] = 'product_settings';
     }
     if (!isset($options['arguments'])) {
         $options['arguments'] = array();
     }
     $options['arguments']['product_id'] = $product_id;
     $options['module'] = 'product';
     if ($options['page'] == 'product_admin' || $options['page'] == 'product_admin_category') {
         array_unshift($link_options, $options);
         if ($options['page'] == 'product_admin_category') {
             $options['data'] = self::get_product_category($product_id);
             $options['data']['name'] = $options['data']['product_category_name'];
         }
         $options['page'] = 'product_settings';
         // bubble back onto ourselves for the link.
         return self::link_generate($product_id, $options, $link_options);
     }
     // grab the data for this particular link, so that any parent bubbled link_generate() methods
     // can access data from a sub item (eg: an id)
     if (isset($options['full']) && $options['full']) {
         // only hit database if we need to print a full link with the name in it.
         if (!isset($options['data']) || !$options['data']) {
             if ((int) $product_id > 0) {
                 $data = self::get_product($product_id);
             } else {
                 $data = array();
                 return _l('N/A');
             }
             $options['data'] = $data;
         } else {
             $data = $options['data'];
         }
         // what text should we display in this link?
         $options['text'] = $data['name'];
     }
     $options['text'] = isset($options['text']) ? htmlspecialchars($options['text']) : '';
     // generate the arguments for this link
     $options['arguments'] = array('product_id' => $product_id);
     // generate the path (module & page) for this link
     $options['module'] = 'product';
     // append this to our link options array, which is eventually passed to the
     // global link generate function which takes all these arguments and builds a link out of them.
     if (!self::can_i('view', 'Products')) {
         if (!isset($options['full']) || !$options['full']) {
             return '#';
         } else {
             return isset($options['text']) ? $options['text'] : _l('N/A');
         }
     }
     // optionally bubble this link up to a parent link_generate() method, so we can nest modules easily
     // change this variable to the one we are going to bubble up to:
     $bubble_to_module = false;
     $bubble_to_module = array('module' => 'config', 'argument' => 'product_id');
     array_unshift($link_options, $options);
     if ($bubble_to_module) {
         global $plugins;
         return $plugins[$bubble_to_module['module']]->link_generate(false, array(), $link_options);
     } else {
         // return the link as-is, no more bubbling or anything.
         // pass this off to the global link_generate() function
         return link_generate($link_options);
     }
 }
Example #17
0
 public static function link_generate($social_id = false, $options = array(), $link_options = array())
 {
     // we accept link options from a bubbled link call.
     // so we have to prepent our options to the start of the link_options array incase
     // anything bubbled up to this method.
     // build our options into the $options variable and array_unshift this onto the link_options at the end.
     $key = 'social_id';
     // the key we look for in data arrays, on in _REQUEST variables. for sub link building.
     // we check if we're bubbling from a sub link, and find the item id from a sub link
     if (${$key} === false && $link_options) {
         foreach ($link_options as $link_option) {
             if (isset($link_option['data']) && isset($link_option['data'][$key])) {
                 ${$key} = $link_option['data'][$key];
                 break;
             }
         }
         if (!${$key} && isset($_REQUEST[$key])) {
             ${$key} = $_REQUEST[$key];
         }
     }
     if (!isset($options['page'])) {
         $options['page'] = 'social_settings';
     }
     if (!isset($options['arguments'])) {
         $options['arguments'] = array();
     }
     $options['arguments']['social_id'] = $social_id;
     $options['module'] = 'social';
     $options['text'] = isset($options['text']) ? htmlspecialchars($options['text']) : '';
     // generate the arguments for this link
     $options['arguments'] = array('social_id' => $social_id);
     // generate the path (module & page) for this link
     $options['module'] = 'social';
     // append this to our link options array, which is eventually passed to the
     // global link generate function which takes all these arguments and builds a link out of them.
     if (!module_social::can_i('view', 'Social')) {
         if (!isset($options['full']) || !$options['full']) {
             return '#';
         } else {
             return isset($options['text']) ? $options['text'] : _l('N/A');
         }
     }
     // optionally bubble this link up to a parent link_generate() method, so we can nest modules easily
     // change this variable to the one we are going to bubble up to:
     $bubble_to_module = false;
     if (isset($options['config']) && $options['config']) {
         $bubble_to_module = array('module' => 'config', 'argument' => 'social_id');
     }
     array_unshift($link_options, $options);
     if ($bubble_to_module) {
         global $plugins;
         return $plugins[$bubble_to_module['module']]->link_generate(false, array(), $link_options);
     } else {
         // return the link as-is, no more bubbling or anything.
         // pass this off to the global link_generate() function
         return link_generate($link_options);
     }
 }
Example #18
0
 public static function link_open_data_type($data_type_id, $full = false, $data = array())
 {
     // we accept link options from a bubbled link call.
     // so we have to prepent our options to the start of the link_options array incase
     // anything bubbled up to this method.
     // build our options into the $options variable and array_unshift this onto the link_options at the end.
     $options = array('full' => $full, 'data' => $data);
     $link_options = array();
     if (isset($options['full']) && $options['full']) {
         if ((int) $data_type_id > 0) {
             if (!$data) {
                 $data = self::get_data_type($data_type_id);
             }
         }
         $options['data'] = $data;
         // what text should we display in this link?
         $options['text'] = !isset($data['data_name']) || !trim($data['data_name']) ? _l('N/A') : $data['data_name'];
         if (!$data || !$data_type_id || isset($data['_no_access'])) {
             $link = $options['text'];
             return $link;
         }
     }
     //$options['text'] = isset($options['text']) ? htmlspecialchars($options['text']) : '';
     // generate the arguments for this link
     $options['arguments'] = array('data_type_id' => $data_type_id);
     // generate the path (module & page) for this link
     $options['page'] = 'data_type_admin';
     $options['module'] = 'data';
     // append this to our link options array, which is eventually passed to the
     // global link generate function which takes all these arguments and builds a link out of them.
     if (!self::can_i('view', _MODULE_DATA_NAME)) {
         if (!isset($options['full']) || !$options['full']) {
             $link = '#';
         } else {
             $link = isset($options['text']) ? $options['text'] : 'N/A';
         }
         return $link;
     }
     // optionally bubble this link up to a parent link_generate() method, so we can nest modules easily
     // change this variable to the one we are going to bubble up to:
     $bubble_to_module = false;
     $bubble_to_module = array('module' => 'config', 'argument' => 'data_type_id');
     array_unshift($link_options, $options);
     if ($bubble_to_module) {
         global $plugins;
         $link = $plugins[$bubble_to_module['module']]->link_generate(false, array(), $link_options);
     } else {
         // return the link as-is, no more bubbling or anything.
         // pass this off to the global link_generate() function
         $link = link_generate($link_options);
     }
     return $link;
 }
Example #19
0
 public static function link_generate($note_id = false, $options = array(), $link_options = array())
 {
     $key = 'note_id';
     if ($note_id === false && $link_options) {
         foreach ($link_options as $link_option) {
             if (isset($link_option['data']) && isset($link_option['data'][$key])) {
                 ${$key} = $link_option['data'][$key];
                 break;
             }
         }
         if (!${$key} && isset($_REQUEST[$key])) {
             ${$key} = $_REQUEST[$key];
         }
     }
     $bubble_to_module = false;
     $options['page'] = 'note_admin';
     if (!isset($options['arguments'])) {
         $options['arguments'] = array();
     }
     $options['arguments']['note_id'] = $note_id;
     $options['module'] = 'note';
     $data = array();
     //self::get_note($note_id);
     $options['data'] = $data;
     // what text should we display in this link?
     $options['text'] = 'note';
     //(!isset($data['name'])||!trim($data['name'])) ? 'N/A' : $data['name'];
     array_unshift($link_options, $options);
     if ($bubble_to_module) {
         global $plugins;
         return $plugins[$bubble_to_module['module']]->link_generate(false, array(), $link_options);
     } else {
         // return the link as-is, no more bubbling or anything.
         // pass this off to the global link_generate() function
         return link_generate($link_options);
     }
 }
Example #20
0
 public static function link_generate($ticket_id = false, $options = array(), $link_options = array())
 {
     $key = 'ticket_id';
     if ($ticket_id === false && $link_options) {
         foreach ($link_options as $link_option) {
             if (isset($link_option['data']) && isset($link_option['data'][$key])) {
                 ${$key} = $link_option['data'][$key];
                 break;
             }
         }
         if (!${$key} && isset($_REQUEST[$key])) {
             ${$key} = $_REQUEST[$key];
         }
     }
     $bubble_to_module = false;
     if (!isset($options['type'])) {
         $options['type'] = 'ticket';
     }
     if (!isset($options['page'])) {
         $options['page'] = 'ticket_admin';
     }
     if (!isset($options['arguments'])) {
         $options['arguments'] = array();
     }
     $options['arguments']['ticket_id'] = $ticket_id;
     $options['module'] = 'ticket';
     // what text should we display in this link?
     if ($options['page'] == 'ticket_settings_fields') {
         if (isset($options['data']) && $options['data']) {
             //$options['data'] = $options['data'];
         } else {
             $data = self::get_ticket_extras_key($ticket_id);
             $options['data'] = $data;
         }
         $options['text'] = isset($options['data']['key']) ? $options['data']['key'] : '';
         array_unshift($link_options, $options);
         $options['page'] = 'ticket_settings';
         // bubble back onto ourselves for the link.
         return self::link_generate($ticket_id, $options, $link_options);
     } else {
         if ($options['page'] == 'ticket_settings_types') {
             if (isset($options['data']) && $options['data']) {
                 //$options['data'] = $options['data'];
             } else {
                 $data = self::get_ticket_type($ticket_id);
                 $options['data'] = $data;
             }
             $options['text'] = isset($options['data']['name']) ? $options['data']['name'] : '';
             array_unshift($link_options, $options);
             $options['page'] = 'ticket_settings';
             // bubble back onto ourselves for the link.
             return self::link_generate($ticket_id, $options, $link_options);
         } elseif ($options['page'] == 'ticket_settings_accounts') {
             if (isset($options['data']) && $options['data']) {
                 //$options['data'] = $options['data'];
             } else {
                 $data = self::get_ticket_account($ticket_id);
                 $options['data'] = $data;
             }
             $options['text'] = $options['data']['name'];
             array_unshift($link_options, $options);
             $options['page'] = 'ticket_settings';
             // bubble back onto ourselves for the link.
             return self::link_generate($ticket_id, $options, $link_options);
         } else {
             if (isset($options['data']) && $options['data']) {
                 //$options['data'] = $options['data'];
             } else {
                 $data = self::get_ticket($ticket_id);
                 $options['data'] = $data;
                 $options['class'] = 'error';
             }
             $options['text'] = $ticket_id ? self::ticket_number($ticket_id) : 'N/A';
         }
     }
     array_unshift($link_options, $options);
     if ($options['page'] == 'ticket_admin' && $options['data'] && isset($options['data']['status_id'])) {
         // pick the class name for the error. or ticket status
         $link_options['class'] = 'ticket_status_' . $options['data']['status_id'];
     }
     if (self::can_i('edit', 'Ticket Settings') && $options['page'] == 'ticket_settings') {
         $bubble_to_module = array('module' => 'config');
     } else {
         if ((!isset($_GET['customer_id']) || !$_GET['customer_id']) && class_exists('module_faq', false) && (module_config::c('ticket_separate_product_queue', 0) || module_config::c('ticket_separate_product_menu', 0))) {
         } else {
             if ($options['data']['customer_id'] > 0) {
                 if (!module_security::has_feature_access(array('name' => 'Customers', 'module' => 'customer', 'category' => 'Customer', 'view' => 1, 'description' => 'view'))) {
                     /*if(!isset($options['full']) || !$options['full']){
                           return '#';
                       }else{
                           return isset($options['text']) ? $options['text'] : 'N/A';
                       }*/
                 } else {
                     $bubble_to_module = array('module' => 'customer', 'argument' => 'customer_id');
                 }
             }
         }
     }
     if ($bubble_to_module) {
         global $plugins;
         return $plugins[$bubble_to_module['module']]->link_generate(false, array(), $link_options);
     } else {
         // return the link as-is, no more bubbling or anything.
         // pass this off to the global link_generate() function
         return link_generate($link_options);
     }
 }