Beispiel #1
0
    public static function print_table_data($owner_table, $owner_id)
    {
        if (self::can_i('view', 'Extra Fields') && isset(self::$column_headers[$owner_table])) {
            $extra_data = get_multiple('extra', array('owner_table' => $owner_table, 'owner_id' => $owner_id), 'extra_key');
            foreach (self::$column_headers[$owner_table] as $column_header) {
                ?>

                <td>
                    <?php 
                echo isset($extra_data[$column_header['key']]) ? forum_text($extra_data[$column_header['key']]['extra']) : '';
                ?>

                </td>
                <?php 
            }
        }
    }
Beispiel #2
0
 /**
  * @param $invoice_id
  * @param $invoice_data
  * @return array
  *
  * todo: make this method call the other 'get_replace_fields' available in website/job/etc..
  */
 public static function get_replace_fields($invoice_id, $invoice_data = false)
 {
     if (!$invoice_data) {
         $invoice_data = self::get_invoice($invoice_id);
     }
     $customer_data = array();
     if ($invoice_data['customer_id']) {
         $customer_data = module_customer::get_replace_fields($invoice_data['customer_id'], $invoice_data['user_id']);
     }
     if (!is_array($customer_data)) {
         $customer_data = array();
     }
     $data = array_merge($customer_data, $invoice_data);
     // so we get total_amount_due and stuff.
     $data = array_merge($data, array('invoice_number' => htmlspecialchars($invoice_data['name']), 'project_type' => _l(module_config::c('project_name_single', 'Website')), 'print_link' => self::link_public_print($invoice_id), 'title' => module_config::s('admin_system_name'), 'invoice_paid' => $invoice_data['total_amount_due'] <= 0 ? '<p> <font style="font-size: 1.6em;"><strong>' . _l('INVOICE PAID') . '</strong></font> </p>' : '', 'is_invoice_paid' => $invoice_data['total_amount_due'] <= 0 ? 1 : '', 'date_create' => print_date($invoice_data['date_create']), 'due_date' => print_date($invoice_data['date_due'])));
     $data['total_amount'] = dollar($invoice_data['total_amount'], true, $invoice_data['currency_id']);
     $data['total_amount_due'] = dollar($invoice_data['total_amount_due'], true, $invoice_data['currency_id']);
     $data['total_amount_paid'] = dollar($invoice_data['total_amount_paid'], true, $invoice_data['currency_id']);
     $data['date_paid'] = print_date($invoice_data['date_paid']);
     $data['date_due'] = print_date($invoice_data['date_due']);
     $data['date_sent'] = print_date($invoice_data['date_sent']);
     $data['invoice_number'] = $invoice_data['name'];
     $data['invoice_url'] = module_invoice::link_public($invoice_id);
     $data['invoice_date_range'] = '';
     if ($invoice_data['date_renew'] != '0000-00-00') {
         $data['invoice_date_range'] = _l('%s to %s', print_date($invoice_data['date_create']), print_date(strtotime("-1 day", strtotime($invoice_data['date_renew']))));
     }
     if (isset($invoice_data['credit_note_id']) && $invoice_data['credit_note_id']) {
         $credit_invoice = module_invoice::get_invoice($invoice_data['credit_note_id'], true);
         $data['credit_invoice_number'] = htmlspecialchars($credit_invoice['name']);
     }
     $data['invoice_notes'] = '';
     // grab any public notes
     if (class_exists('module_note', false) && module_note::is_plugin_enabled()) {
         $notes = module_note::get_notes(array('public' => 1, 'owner_table' => 'invoice', 'owner_id' => $invoice_id));
         if (count($notes) > 1) {
             $data['invoice_notes'] .= '<ul>';
             foreach ($notes as $note) {
                 if ($note['public']) {
                     $data['invoice_notes'] .= '<li>';
                     $data['invoice_notes'] .= htmlspecialchars($note['note']);
                     $data['invoice_notes'] .= '</li>';
                 }
             }
             $data['invoice_notes'] .= '</ul>';
         } else {
             $note = array_shift($notes);
             $data['invoice_notes'] .= htmlspecialchars($note['note']);
         }
     }
     $job_names = $website_url = $project_names = $project_names_and_url = array();
     foreach ($invoice_data['job_ids'] as $job_id) {
         $job_data = module_job::get_job($job_id);
         if ($job_data && $job_data['job_id'] == $job_id) {
             $job_names[$job_data['job_id']] = $job_data['name'];
             if (module_config::c('job_invoice_show_date_range', 1)) {
                 // check if this job is a renewable job.
                 if ($job_data['date_renew'] != '0000-00-00') {
                     $data['invoice_date_range'] = _l('%s to %s', print_date($job_data['date_start']), print_date(strtotime("-1 day", strtotime($job_data['date_renew']))));
                 }
             }
             $fields = module_job::get_replace_fields($job_id, $job_data);
             foreach ($fields as $key => $val) {
                 if (!isset($data[$key]) || !$data[$key] && $val) {
                     $data[$key] = $val;
                 }
             }
             if ($job_data['website_id']) {
                 $website_data = module_website::get_website($job_data['website_id']);
                 if ($website_data && $website_data['website_id'] == $job_data['website_id']) {
                     if (isset($website_data['url']) && $website_data['url']) {
                         $website_url[$website_data['website_id']] = module_website::urlify($website_data['url']);
                         $website_data['name_url'] = $website_data['name'] . ' (' . module_website::urlify($website_data['url']) . ')';
                     } else {
                         $website_data['name_url'] = $website_data['name'];
                     }
                     $project_names[$website_data['website_id']] = $website_data['name'];
                     $project_names_and_url[$website_data['website_id']] = $website_data['name_url'];
                     $fields = module_website::get_replace_fields($website_data['website_id'], $website_data);
                     foreach ($fields as $key => $val) {
                         if (!isset($data[$key]) || !$data[$key] && $val) {
                             $data[$key] = $val;
                         }
                     }
                 }
             }
         }
     }
     if (isset($invoice_data['website_id']) && $invoice_data['website_id']) {
         $website_data = module_website::get_website($invoice_data['website_id']);
         if ($website_data && $website_data['website_id'] == $invoice_data['website_id']) {
             if (isset($website_data['url']) && $website_data['url']) {
                 $website_url[$website_data['website_id']] = module_website::urlify($website_data['url']);
                 $website_data['name_url'] = $website_data['name'] . ' (' . module_website::urlify($website_data['url']) . ')';
             } else {
                 $website_data['name_url'] = $website_data['name'];
             }
             $project_names[$website_data['website_id']] = $website_data['name'];
             $project_names_and_url[$website_data['website_id']] = $website_data['name_url'];
             $fields = module_website::get_replace_fields($website_data['website_id'], $website_data);
             foreach ($fields as $key => $val) {
                 if (!isset($data[$key]) || !$data[$key] && $val) {
                     $data[$key] = $val;
                 }
             }
         }
     }
     $data['website_name'] = $data['project_name'] = forum_text(count($project_names) ? implode(', ', $project_names) : '');
     $data['website_name_url'] = forum_text(count($project_names_and_url) ? implode(', ', $project_names_and_url) : '');
     $data['website_url'] = forum_text(count($website_url) ? implode(', ', $website_url) : '');
     $data['job_name'] = forum_text($job_names ? implode(', ', $job_names) : '');
     if (class_exists('module_group', false)) {
         // get the job groups
         $wg = array();
         $g = array();
         foreach ($invoice_data['job_ids'] as $group_job_id) {
             $group_job_id = (int) trim($group_job_id);
             if ($group_job_id > 0) {
                 $job_data = module_job::get_job($group_job_id);
                 foreach (module_group::get_groups_search(array('owner_table' => 'job', 'owner_id' => $group_job_id)) as $group) {
                     $g[$group['group_id']] = $group['name'];
                 }
                 // get the website groups
                 if ($job_data['website_id']) {
                     foreach (module_group::get_groups_search(array('owner_table' => 'website', 'owner_id' => $job_data['website_id'])) as $group) {
                         $wg[$group['group_id']] = $group['name'];
                     }
                 }
             }
         }
         if (isset($invoice_data['website_id']) && $invoice_data['website_id']) {
             foreach (module_group::get_groups_search(array('owner_table' => 'website', 'owner_id' => $invoice_data['website_id'])) as $group) {
                 $wg[$group['group_id']] = $group['name'];
             }
         }
         $data['job_group'] = implode(', ', $g);
         $data['website_group'] = implode(', ', $wg);
     }
     // addition. find all extra keys for this invoice and add them in.
     // we also have to find any EMPTY extra fields, and add those in as well.
     if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) {
         $all_extra_fields = module_extra::get_defaults('invoice');
         foreach ($all_extra_fields as $e) {
             $data[$e['key']] = _l('N/A');
         }
         // and find the ones with values:
         $extras = module_extra::get_extras(array('owner_table' => 'invoice', 'owner_id' => $invoice_id));
         foreach ($extras as $e) {
             $data[$e['extra_key']] = $e['extra'];
         }
     }
     $new_data = hook_handle_callback('invoice_replace_fields', $invoice_id, $data);
     if (is_array($new_data)) {
         foreach ($new_data as $new_d) {
             $data = array_merge($data, $new_d);
         }
     }
     return $data;
 }
Beispiel #3
0
        <a href="<?php 
        echo module_note::link_open($note_item['note_id'], false, $note_item['options']);
        ?>
" data-options="<?php 
        echo htmlspecialchars(base64_encode(serialize($note_item['options'])));
        ?>
" class="note_edit note_options_link" rel="<?php 
        echo $note_item['note_id'];
        ?>
"> <?php 
        echo $note_text;
        ?>
 </a>
        <?php 
    } else {
        echo forum_text($note_item['note']);
    }
});
$columns['info'] = array('title' => 'Info', 'width' => 40, 'callback' => function ($note_item) {
    if (module_config::c('note_show_creator', 1)) {
        $user_data = module_user::get_user($note_item['create_user_id']);
        echo $user_data['name'];
    }
    if ($note_item['display_summary'] && $note_item['rel_data'] && $note_item['owner_id']) {
        global $plugins;
        if (module_config::c('note_show_creator', 1)) {
            echo ' / ';
        }
        echo $plugins[$note_item['owner_table']]->link_open($note_item['owner_id'], true);
    }
});
Beispiel #4
0
if (!isset($comments)) {
    die('Wrong file');
}
foreach ($comments as $comment) {
    ?>
    <div class="task_job_discussion_comments">
        <div class="info">
            <?php 
    echo $comment['user_id'] ? module_user::link_open($comment['user_id'], true, array(), true) : 'Unknown';
    ?>
            <?php 
    echo print_date($comment['date_created'], true);
    ?>
        </div>
        <?php 
    echo forum_text($comment['note']);
    ?>
    </div>
    <?php 
}
if ($job_data && isset($job_data['job_discussion']) && $job_data['job_discussion'] == 2) {
    // disabled & shown.
    return;
}
if ($allow_new) {
    ?>
<div class="task_job_discussion_comments">
    <div class="info">
        <?php 
    echo $current_user_id ? module_user::link_open($current_user_id, true, array(), true) : 'Unknown';
    ?>
Beispiel #5
0
    private function _output_block($facebook_data, $level)
    {
        if (!isset($facebook_data['picture']) && isset($facebook_data['attachment'], $facebook_data['attachment']['type'], $facebook_data['attachment']['media']['image']['src'])) {
            $facebook_data['picture'] = $facebook_data['attachment']['media']['image']['src'];
            $facebook_data['link'] = isset($facebook_data['attachment']['url']) ? $facebook_data['attachment']['url'] : false;
        }
        if (isset($facebook_data['comments'])) {
            $comments = $this->get_comments($facebook_data['comments']);
        } else {
            $comments = array();
        }
        //echo '<pre>';print_r($facebook_data);echo '</pre>';
        if ($facebook_data['message'] !== false) {
            ?>
		<div class="facebook_comment">
			<div class="facebook_comment_picture">
				<?php 
            if (isset($facebook_data['from']['id'])) {
                ?>
				<img src="//graph.facebook.com/<?php 
                echo $facebook_data['from']['id'];
                ?>
/picture">
				<?php 
            }
            ?>
			</div>
			<div class="facebook_comment_header">
				<?php 
            echo isset($facebook_data, $facebook_data['from']) ? ucm_facebook::format_person($facebook_data['from']) : 'N/A';
            ?>
				<span><?php 
            $time = strtotime(isset($facebook_data['updated_time']) ? $facebook_data['updated_time'] : (isset($facebook_data['created_time']) ? $facebook_data['created_time'] : false));
            echo $time ? ' @ ' . print_date($time, true) : '';
            // todo - better this! don't call on every comment, load list in main loop and pass through all results.
            if (isset($facebook_data['user_id']) && $facebook_data['user_id']) {
                echo ' (sent by ' . module_user::link_open($facebook_data['user_id'], true) . ')';
            } else {
                if (isset($facebook_data['id']) && $facebook_data['id']) {
                    $exists = get_single('social_facebook_message_comment', array('facebook_id', 'social_facebook_message_id'), array($facebook_data['id'], $this->social_facebook_message_id));
                    if ($exists && isset($exists['user_id']) && $exists['user_id']) {
                        echo ' (sent by ' . module_user::link_open($exists['user_id'], true) . ')';
                    }
                }
            }
            ?>
				</span>
			</div>
			<div class="facebook_comment_body">
				<?php 
            if (isset($facebook_data['picture']) && $facebook_data['picture']) {
                ?>
				<div class="facebook_picture">
					<?php 
                if (isset($facebook_data['link']) && $facebook_data['link']) {
                    ?>
 <a href="<?php 
                    echo htmlspecialchars($facebook_data['link']);
                    ?>
" target="_blank"> <?php 
                }
                ?>
					<img src="<?php 
                echo htmlspecialchars($facebook_data['picture']);
                ?>
">
					<?php 
                if (isset($facebook_data['link']) && $facebook_data['link']) {
                    ?>
 </a> <?php 
                }
                ?>
				</div>
				<?php 
            }
            ?>
				<div>
					<?php 
            echo forum_text($facebook_data['message']);
            ?>
				</div>
			</div>
			<div class="facebook_comment_actions">
				<?php 
            if ($this->can_reply && ($this->get('type') != 'conversation' && $level == 2)) {
                ?>
					<a href="#" class="facebook_reply_button"><?php 
                _e('Reply');
                ?>
</a>
				<?php 
            }
            ?>
			</div>
		</div>
		<?php 
        }
        ?>
		<div class="facebook_comment_replies">
		<?php 
        //if(strpos($facebook_data['message'],'picture')){
        //echo '<pre>'; print_r($facebook_data); echo '</pre>';
        //}
        if (count($comments)) {
            // recursively print out our comments!
            //$comments = array_reverse($comments);
            foreach ($comments as $comment) {
                $this->_output_block($comment, $level + 1);
            }
        }
        if ($this->can_reply && isset($facebook_data['id']) && $facebook_data['id'] && ($this->get('type') == 'conversation' && $level == 1 || $this->get('type') != 'conversation' && $level <= 2)) {
            $this->reply_box($facebook_data['id'], $level);
        }
        ?>
		</div>
		<?php 
    }
Beispiel #6
0
 public static function hook_invoice_replace_fields($callback_name, $invoice_id, $existing_data)
 {
     $new_data = array();
     $new_data['subscription_name'] = '';
     if ((int) $invoice_id > 0) {
         // check if this invoice is linked to any subscription payments.
         $subscription_history = get_single('subscription_history', 'invoice_id', $invoice_id);
         if ($subscription_history) {
             //$subscription_member_history = self::get_subscription_history($subscription_history['subscription_id'], $subscription_history['member_id'], $subscription_history['customer_id']);
             $subscription_owner = get_single('subscription_owner', 'subscription_owner_id', $subscription_history['subscription_owner_id']);
             $subscriptions = module_subscription::get_subscriptions_by($subscription_owner['owner_table'], $subscription_owner['owner_id']);
             /*if(isset($subscription_history['member_id']) && $subscription_history['member_id']){
                   $subscriptions = module_subscription::get_subscriptions_by_member($subscription_history['member_id']);
               }else if(isset($subscription_history['customer_id']) && $subscription_history['customer_id']){
                   $subscriptions = module_subscription::get_subscriptions_by_customer($subscription_history['customer_id']);
               }*/
             if (isset($subscriptions[$subscription_history['subscription_id']])) {
                 $subscription = self::get_subscription($subscription_history['subscription_id']);
                 $invoice_data = module_invoice::get_invoice($invoice_id, true);
                 $new_data['subscription_name'] = $subscription['name'];
                 // it might not be 'date_create' it might be days in the future
                 if (isset($subscription_history['from_next_due_date']) && $subscription_history['from_next_due_date'] && $subscription_history['from_next_due_date'] != '0000-00-00') {
                     $new_data['invoice_date_range'] = self::_calculate_next_time(strtotime($subscription_history['from_next_due_date']), $subscription, true);
                 } else {
                     $new_data['invoice_date_range'] = self::_calculate_next_time(strtotime($invoice_data['date_create']), $subscription, true);
                 }
                 // is this linked to a website? pull in website data into the invoice replace fields (code copied from invoice.php)
                 if ($subscription_owner['owner_table'] == 'website') {
                     $website_data = module_website::get_website($subscription_owner['owner_id']);
                     if ($website_data && $website_data['website_id'] == $subscription_owner['owner_id']) {
                         $website_url = $project_names = $project_names_and_url = array();
                         if (isset($website_data['url']) && $website_data['url']) {
                             $website_url[$website_data['website_id']] = module_website::urlify($website_data['url']);
                             $website_data['name_url'] = $website_data['name'] . ' (' . module_website::urlify($website_data['url']) . ')';
                         } else {
                             $website_data['name_url'] = $website_data['name'];
                         }
                         $project_names[$website_data['website_id']] = $website_data['name'];
                         $project_names_and_url[$website_data['website_id']] = $website_data['name_url'];
                         if (!$existing_data['website_name']) {
                             $new_data['website_name'] = $new_data['project_name'] = forum_text(count($project_names) ? implode(', ', $project_names) : '');
                         }
                         if (!$existing_data['website_name_url']) {
                             $new_data['website_name_url'] = forum_text(count($project_names_and_url) ? implode(', ', $project_names_and_url) : '');
                         }
                         if (!$existing_data['website_url']) {
                             $new_data['website_url'] = forum_text(count($website_url) ? implode(', ', $website_url) : '');
                         }
                     }
                 }
             }
         }
     }
     return $new_data;
 }
        ?>

                        <input type="submit" name="butt_save_note" id="butt_save_note" value="<?php 
        echo _l('Add Comment');
        ?>
" class="submit_button no_permissions">
                        <?php 
    }
    ?>

                        <input type="hidden" name="delete_file_comment_id" id="delete_file_comment_id" value="0" class="no_permissions">
                    </div>
                </div>
                <?php 
    foreach (module_file::get_file_comments($file_id) as $item) {
        $note_text = forum_text($item['comment']);
        if (preg_match_all('/#(\\d+)/', $note_text, $matches)) {
            //
            foreach ($matches[1] as $digit) {
                $note_text = preg_replace('/#' . $digit . '([^\\d]*)/', '<span node_id=' . $digit . ' class="pointer-ids pointer-id-' . $digit . '">#' . $digit . '</span>$1', $note_text);
            }
        }
        ?>

                <div style="border-top:1px dashed #CCCCCC; padding:3px; margin:3px 0;">
                    <?php 
        echo $note_text;
        ?>

                    <div style="font-size:10px; text-align:right; color:#CCCCCC;">From <?php 
        echo $item['create_user_id'] ? module_user::link_open($item['create_user_id'], true) : _l('Customer');
</a>
                                        <?php 
    }
    $long_description = trim($invoice_item_data['custom_long_description'] ? htmlspecialchars($invoice_item_data['custom_long_description']) : htmlspecialchars($invoice_item_data['long_description']));
    if ($long_description != '') {
        ?>

                            <a href="#" class="task_toggle_long_description">&raquo;</a>
                            <div class="task_long_description" <?php 
        if (module_config::c('invoice_show_long_desc', 1)) {
            ?>
 style="display:block;" <?php 
        }
        ?>
><?php 
        echo forum_text($long_description);
        ?>
</div>
                            <?php 
    } else {
        ?>

    &nbsp;
    <?php 
    }
    ?>

                                    </td>
                                    <?php 
    if ($show_task_dates) {
        ?>
Beispiel #9
0
 public static function html_faq($text)
 {
     if (function_exists('is_text_html') && !is_text_html($text)) {
         return forum_text($text);
     }
     return $text;
 }
Beispiel #10
0
    public function output_block($level)
    {
        if (!$this->get('social_twitter_message_id') || $level < -3) {
            return;
        }
        $twitter_data = @json_decode($this->get('data'), true);
        // any previous messages?
        if ($level <= 0) {
            if ($this->get('reply_to_id')) {
                // this tweet is a reply to a previous tweet!
                ?>
				<div class="twitter_previous_messages">
					<?php 
                $reply_message = new ucm_twitter_message($this->twitter_account, $this->get('reply_to_id'));
                $reply_message->output_block($level - 1);
                ?>
				</div>
				<?php 
            } else {
                if ($this->get('type') == _TWITTER_MESSAGE_TYPE_DIRECT) {
                    // find previous message(s)
                    $from = preg_replace('#[^0-9]#', '', $this->get('twitter_from_id'));
                    $to = preg_replace('#[^0-9]#', '', $this->get('twitter_to_id'));
                    if ($from && $to) {
                        $sql = "SELECT * FROM `" . _DB_PREFIX . "social_twitter_message` WHERE `type` = " . _TWITTER_MESSAGE_TYPE_DIRECT . " AND message_time <= " . (int) $this->get('message_time') . " AND social_twitter_message_id != " . (int) $this->social_twitter_message_id . " AND ( (`twitter_from_id` = {$from} AND `twitter_to_id` = {$to}) OR (`twitter_from_id` = {$to} AND `twitter_to_id` = {$from}) ) ORDER BY `message_time` DESC LIMIT 1";
                        $previous = qa1($sql);
                        if ($previous && $previous['social_twitter_message_id']) {
                            ?>
						<div class="twitter_previous_messages twitter_direct">
							<?php 
                            $reply_message = new ucm_twitter_message($this->twitter_account, $previous['social_twitter_message_id']);
                            $reply_message->output_block($level - 1);
                            ?>
						</div>
						<?php 
                        }
                    }
                }
            }
        }
        $message_from = isset($twitter_data['user']) ? $twitter_data['user'] : (isset($twitter_data['sender']) ? $twitter_data['sender'] : false);
        if ($this->get('summary')) {
            if ($message_from && $this->get('type') != _TWITTER_MESSAGE_TYPE_DIRECT) {
                $message_from['tweet_id'] = isset($twitter_data['id_str']) ? $twitter_data['id_str'] : false;
            }
            //echo '<pre>'; print_r($twitter_data); echo '</pre>';
            ?>
			<div class="twitter_comment <?php 
            echo $level != 0 ? ' twitter_comment_clickable' : 'twitter_comment_current';
            ?>
" data-id="<?php 
            echo $this->social_twitter_message_id;
            ?>
" data-link="<?php 
            echo module_social_twitter::link_open_twitter_message($this->get('social_twitter_id'), $this->social_twitter_message_id);
            ?>
" data-title="<?php 
            echo _l('Tweet');
            ?>
">
				<div class="twitter_comment_picture">
					<?php 
            if (isset($twitter_data['user']['id_str'])) {
                $pic = array('screen_name' => isset($twitter_data['user']['screen_name']) ? $twitter_data['user']['screen_name'] : '', 'image' => isset($twitter_data['user']['profile_image_url_https']) ? $twitter_data['user']['profile_image_url_https'] : '');
            } else {
                if (isset($twitter_data['sender']['id_str'])) {
                    $pic = array('screen_name' => isset($twitter_data['sender']['screen_name']) ? $twitter_data['sender']['screen_name'] : '', 'image' => isset($twitter_data['sender']['profile_image_url_https']) ? $twitter_data['sender']['profile_image_url_https'] : '');
                } else {
                    $pic = false;
                }
            }
            if ($pic) {
                ?>
						<img src="<?php 
                echo $pic['image'];
                ?>
">
						<?php 
            }
            ?>
				</div>
				<div class="twitter_comment_header">
					<?php 
            _e('From:');
            echo ' ';
            echo $message_from ? ucm_twitter::format_person($message_from) : 'N/A';
            ?>
					<span><?php 
            $time = strtotime($this->get('message_time'));
            echo $time ? ' @ ' . print_date($time, true) : '';
            if ($this->get('user_id')) {
                echo ' (sent by ' . module_user::link_open($this->get('user_id'), true) . ')';
            }
            ?>
					</span>
				</div>
				<div class="twitter_comment_body">
					<?php 
            if (isset($twitter_data['entities']['media']) && is_array($twitter_data['entities']['media'])) {
                foreach ($twitter_data['entities']['media'] as $media) {
                    if ($media['type'] == 'photo') {
                        ?>
								<div class="twitter_picture">
									<?php 
                        if (isset($media['url']) && $media['url']) {
                            ?>
 <a
										href="<?php 
                            echo htmlspecialchars($media['url']);
                            ?>
"
										target="_blank"> <?php 
                        }
                        ?>
										<img src="<?php 
                        echo htmlspecialchars($media['media_url_https']);
                        ?>
">
										<?php 
                        if (isset($media['url']) && $media['url']) {
                            ?>
 </a> <?php 
                        }
                        ?>
								</div>
							<?php 
                    }
                }
            }
            ?>
					<div>
						<?php 
            echo forum_text($this->get('summary'));
            ?>
					</div>
					<div class="twitter_comment_stats">
						<?php 
            $data = @json_decode($this->get('data'), true);
            //print_r($data);
            if ($data && (isset($data['retweet_count']) && $data['retweet_count'] > 0 || isset($data['favorite_count']) && $data['favorite_count'] > 0)) {
                if (isset($data['retweet_count']) && $data['retweet_count'] > 0) {
                    echo _l('Retweets: %s', $data['retweet_count']);
                }
                echo ' ';
                if (isset($data['favorite_count']) && $data['favorite_count'] > 0) {
                    echo _l('Favorites: %s', $data['favorite_count']);
                }
            }
            ?>
					</div>
				</div>
				<div class="twitter_comment_actions">
					<?php 
            if ($this->can_reply) {
                ?>
						<a href="#" class="twitter_reply_button"><?php 
                _e('Reply');
                ?>
</a>
					<?php 
            }
            ?>
				</div>
			</div>
		<?php 
        }
        ?>
		<?php 
        if ($level == 0) {
            ?>
			<div class="twitter_comment_replies">
			<?php 
            //if(strpos($twitter_data['message'],'picture')){
            //echo '<pre>'; print_r($twitter_data); echo '</pre>';
            //}
            if ($this->can_reply) {
                $this->reply_box($level, $message_from);
            }
            ?>
			</div>
		<?php 
        }
        if ($level >= 0) {
            // any follow up messages?
            if ($this->get('type') == _TWITTER_MESSAGE_TYPE_DIRECT) {
                $from = preg_replace('#[^0-9]#', '', $this->get('twitter_from_id'));
                $to = preg_replace('#[^0-9]#', '', $this->get('twitter_to_id'));
                if ($from && $to) {
                    $sql = "SELECT * FROM `" . _DB_PREFIX . "social_twitter_message` WHERE `type` = " . _TWITTER_MESSAGE_TYPE_DIRECT . " AND message_time >= " . (int) $this->get('message_time') . " AND social_twitter_message_id != " . (int) $this->social_twitter_message_id . " AND ( (`twitter_from_id` = {$from} AND `twitter_to_id` = {$to}) OR (`twitter_from_id` = {$to} AND `twitter_to_id` = {$from}) ) ORDER BY `message_time` ASC LIMIT 1";
                    $next = qa1($sql);
                    if ($next && $next['social_twitter_message_id']) {
                        ?>
						<div class="twitter_next_messages twitter_direct">
							<?php 
                        $reply_message = new ucm_twitter_message($this->twitter_account, $next['social_twitter_message_id']);
                        $reply_message->output_block($level + 1);
                        ?>
						</div>
						<?php 
                    }
                }
            } else {
                $next = get_multiple('social_twitter_message', array('social_twitter_id' => $this->twitter_account->get('social_twitter_id'), 'reply_to_id' => $this->social_twitter_message_id), 'social_twitter_message_id');
                if ($next) {
                    foreach ($next as $n) {
                        // this tweet is a reply to a previous tweet!
                        if ($n['social_twitter_message_id']) {
                            ?>
							<div class="twitter_next_messages">
								<?php 
                            $reply_message = new ucm_twitter_message($this->twitter_account, $n['social_twitter_message_id']);
                            $reply_message->output_block($level + 1);
                            ?>
							</div>
							<?php 
                        }
                    }
                }
            }
        }
    }
     // linkify the text, without messing with existing <a> links. todo: move this into a global method for elsewhere (eg: eamils)
     //$text = preg_replace('@(?!(?!.*?<a)[^<]*<\/a>)(?:(?:https?|ftp|file)://|www\.|ftp\.)[-A-Z0-9+&#/%=~_|$?!:,.]*[A-Z0-9+&#/%=~_|$]@i','<a href="\0" target="_blank">\0</a>', $text );
 }
 if (!strlen(trim($text))) {
     $text = $ticket_message['content'];
     $text = preg_replace("#<br[^>]*>#i", '', $text);
     $text = preg_replace('#(\\r?\\n\\s*){2,}#', "\n\n", $text);
     switch (module_config::c('ticket_utf8_method', 1)) {
         case 1:
             $text = forum_text($text, true);
             break;
         case 2:
             $text = forum_text(utf8_encode($text), true);
             break;
         case 3:
             $text = forum_text(utf8_encode(utf8_decode($text)), true);
             break;
     }
 }
 if (($ticket_message['cache'] == 'autoreply' || $ticket_message['message_type_id'] == _TICKET_MESSAGE_TYPE_AUTOREPLY) && strlen($ticket_message['htmlcontent']) > 2) {
     $text = $ticket_message['htmlcontent'];
     // override for autoreplies, always show as html.
 }
 if ((!$text || !strlen($text)) && strlen($ticket_message['content'])) {
     $text = nl2br($ticket_message['content']);
 }
 $text = preg_replace("#<br[^>]>#i", "\$0\n", $text);
 $text = preg_replace("#</p>#i", "\$0\n", $text);
 $text = preg_replace("#</div>#i", "\$0\n", $text);
 $lines = explode("\n", $text);
 $do_we_hide = count($lines) > 4 && module_config::c('ticket_hide_messages', 1) && $ticket_message_counter < $ticket_message_count && $ticket_message_count != 2;
Beispiel #12
0
?>
        </td>
    </tr>
    <tr>
        <th>
            <?php 
_e('Message:');
?>
        </th>
        <td id="email_message">
            <?php 
if (!$can_edit_emails) {
    if (strlen($email['html_content'])) {
        echo module_security::purify_html($email['html_content']);
    } else {
        echo forum_text($email['text_content']);
    }
} else {
    ?>
            <textarea name="content" id="email_content_editor" rows="10" cols="30" style="width:450px; height: 350px;"><?php 
    echo htmlspecialchars($email['text_content']);
    ?>
</textarea>

                                    <script type="text/javascript" src="<?php 
    echo _BASE_HREF;
    ?>
js/tiny_mce3.4.4/jquery.tinymce.js"></script>
<script type="text/javascript">
	$().ready(function() {
		$('#email_content_editor').tinymce({
Beispiel #13
0
                <?php 
    if (strlen($change_request['request']) > 40) {
        ?>
                    <a href="#" onclick="$(this).next().show();$(this).hide();return false;"><?php 
        echo substr($change_request['request'], 0, 40);
        ?>
....</a>
                    <div style="display:none;"><?php 
        echo forum_text($change_request['request']);
        ?>
</div>
                <?php 
    } else {
        ?>
                    <?php 
        echo forum_text($change_request['request']);
        ?>
                <?php 
    }
    ?>
            </td>
            <td>
                <?php 
    switch ($change_request['status']) {
        case _CHANGE_REQUEST_STATUS_NEW:
            _e('Incomplete');
            break;
        case _CHANGE_REQUEST_STATUS_COMPLETE:
            _e('Completed');
            break;
    }
                    </div> ?>
            <?php }else{ ?>

            <?php } */
/*</div>*/
if (isset($task_data['long_description']) && $task_data['long_description'] != '') {
    ?>
                <a href="#" class="task_toggle_long_description">&raquo;</a>
                <div class="task_long_description" <?php 
    if (module_config::c('job_tasks_show_long_desc', 0)) {
        ?>
 style="display:block;" <?php 
    }
    ?>
><?php 
    echo forum_text(trim($task_data['long_description']));
    ?>
</div>
            <?php 
} else {
    ?>
                &nbsp;
            <?php 
}
if (function_exists('hook_handle_callback') && $task_data['task_id']) {
    hook_handle_callback('job_task_after', $task_data['job_id'], $task_data['task_id'], $job, $task_data);
}
?>
        </td>
        <td valign="top" class="task_drag_handle">
            <?php 
Beispiel #15
0
$task_decimal_places_trim = module_config::c('task_amount_decimal_places_trim', 0);
$all_item_row_html = '';
$item_count = 0;
// changed from 1
foreach (module_quote::get_quote_items($quote_id, $quote) as $quote_item_id => $quote_item_data) {
    $row_replace = array('item_odd_or_even' => $item_count++ % 2 ? 'odd' : 'even', 'item_number' => '', 'item_description' => '', 'item_tax' => 0, 'item_tax_rate' => '');
    if (isset($quote_item_data['task_order']) && $quote_item_data['task_order'] > 0) {
        $row_replace['item_number'] = $quote_item_data['task_order'];
    } else {
        $row_replace['item_number'] = $item_count;
    }
    $row_replace['item_description'] .= htmlspecialchars($quote_item_data['description']);
    if (module_config::c('quote_show_long_desc', 1)) {
        $long_description = $quote_item_data['long_description'];
        if ($long_description != '') {
            $row_replace['item_description'] .= '<br/><em>' . forum_text($long_description) . '</em>';
        }
    }
    /*if(isset($quote_item_data['date_done']) && $quote_item_data['date_done'] != '0000-00-00'){
          $row_replace['item_date'] .= print_date($quote_item_data['date_done']);
      }else{
          // check if this is linked to a task.
          if($quote_item_data['quote_task_id']){
              $task = get_single('quote_task','quote_task_id',$quote_item_data['quote_task_id']);
              if($task && isset($task['date_done']) && $task['date_done'] != '0000-00-00'){
                  $row_replace['item_date'] .= print_date($task['date_done']);
              }else{
                  // check if quote has a date.
                  if(isset($quote['date_create']) && $quote['date_create'] != '0000-00-00'){
                      $row_replace['item_date'] .= print_date($quote['date_create']);
                  }
Beispiel #16
0
    public function external_hook($hook)
    {
        switch ($hook) {
            case 'view':
                $file_id = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : false;
                $hash = isset($_REQUEST['hash']) ? trim($_REQUEST['hash']) : false;
                if ($file_id && $hash) {
                    $correct_hash = $this->link_public($file_id, true);
                    if ($correct_hash == $hash) {
                        // all good to print a receipt for this payment.
                        $file_data = $this->get_file($file_id, false);
                        if ($file_data && $file_data['file_id'] == $file_id) {
                            if (isset($_POST['save_file_comments'])) {
                                if (isset($_POST['file_approve']) && isset($_POST['file_approve_go']) && isset($_POST['file_approve_name']) && strlen($_POST['file_approve_name']) > 0) {
                                    update_insert('file_id', $file_id, 'file', array('approved_time' => time(), 'approved_by' => $_POST['file_approve_name']));
                                    // send email, same 'updated' email as before.
                                    $this->send_file_changed_notice($file_id, false, true);
                                    //redirect_browser($this->link_public($file_id));
                                    $_REQUEST['new_comment_text'] = _l('File was approved at %s by %s', print_date(time(), true), htmlspecialchars($_POST['file_approve_name']));
                                }
                                if (isset($_POST['pointers'])) {
                                    update_insert('file_id', $file_id, 'file', array('pointers' => $_POST['pointers']));
                                }
                                $this->save_file_comments($file_id);
                                redirect_browser($this->link_public($file_id));
                            }
                            module_template::init_template('file_approval_view', '<h2>File Details</h2>
    File Name: <strong>{FILE_NAME}</strong> <br/>
    Download: <strong><a href="{FILE_DOWNLOAD_URL}">Click Here</a></strong> <br/>
    Status: <strong>{STATUS}</strong> <br/>
    Customer: <strong>{CUSTOMER_NAME}</strong> <br/>
    {if:JOB_NAME}Job: <strong>{JOB_NAME}</strong> <br/>{endif:JOB_NAME}
    {if:FILE_APPROVAL_PENDING}
    <h2>File Approval Pending</h2>
    <p>If you would like to approve this file please complete the form below:</p>
    <p>Your Name: <input type="text" name="file_approve_name"> </p>
    <p><input type="checkbox" name="file_approve_go" value="yes"> Yes, I approve this file. </p>
    <p><input type="submit" name="file_approve" value="Approve File" class="submit_button save_button"></p>
    {endif:FILE_APPROVAL_PENDING}
    {if:FILE_APPROVED}
    <h2>File Has Been Approved</h2>
    <p>Thank you, the file was approved by <strong>{APPROVED_BY}</strong> on <strong>{APPROVED_TIME}</strong>.</p>
    {endif:FILE_APPROVED}
    <h2>File Comments</h2>
    <p>Please feel free to add comments to this file using the form below.</p>
    {FILE_COMMENTS}
    {if:FILE_PREVIEW}
    <h2>File Preview</h2>
    <div style="overflow:scroll;">{FILE_PREVIEW}</div>
    {endif:FILE_PREVIEW}
    ', 'Used when displaying the file to a customer for approval.', 'code');
                            $template = module_template::get_template_by_key('file_approval_view');
                            // generate the html for the task output
                            $job_data = $file_data['job_id'] ? module_job::get_replace_fields($file_data['job_id']) : array();
                            if (class_exists('module_quote', false)) {
                                $quote_data = $file_data['quote_id'] ? module_quote::get_replace_fields($file_data['quote_id']) : array();
                            }
                            $customer_data = $file_data['customer_id'] ? module_customer::get_replace_fields($file_data['customer_id']) : array();
                            $file_data['file_preview'] = module_file::generate_preview($file_id, $file_data['file_name'], $file_data);
                            $file_data['FILE_DOWNLOAD_URL'] = module_file::link_public_view($file_id);
                            if (isset($file_data['approved_time'])) {
                                switch ($file_data['approved_time']) {
                                    case -1:
                                        $file_data['FILE_APPROVAL_PENDING'] = 1;
                                        break;
                                    case 0:
                                        break;
                                    default:
                                        $file_data['FILE_APPROVED'] = 1;
                                        $file_data['APPROVED_TIME'] = print_date($file_data['approved_time'], true);
                                }
                            }
                            if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) {
                                $all_extra_fields = module_extra::get_defaults('file');
                                foreach ($all_extra_fields as $e) {
                                    $file_data[$e['key']] = _l('N/A');
                                }
                                // and find the ones with values:
                                $extras = module_extra::get_extras(array('owner_table' => 'file', 'owner_id' => $file_id));
                                foreach ($extras as $e) {
                                    $file_data[$e['extra_key']] = $e['extra'];
                                }
                            }
                            ob_start();
                            ?>

                            <div id="file_notes">
                            <div style="border-top:1px dashed #CCCCCC; padding:3px; margin:3px 0;">
                                <textarea name="new_comment_text" style="width:100%;" class="no_permissions"></textarea>
                                <div style="text-align: right;">
                                <input type="submit" name="butt_save_note" id="butt_save_note" value="<?php 
                            echo _l('Add Comment');
                            ?>
" class="submit_button no_permissions">
                                    </div>
                            </div>
                            <?php 
                            foreach (module_file::get_file_comments($file_id) as $item) {
                                $note_text = forum_text($item['comment']);
                                if (preg_match_all('/#(\\d+)/', $note_text, $matches)) {
                                    //
                                    foreach ($matches[1] as $digit) {
                                        $note_text = preg_replace('/#' . $digit . '([^\\d]*)/', '<span node_id=' . $digit . ' class="pointer-ids pointer-id-' . $digit . '">#' . $digit . '</span>$1', $note_text);
                                    }
                                }
                                ?>

                                <div style="border-top:1px dashed #CCCCCC; padding:3px; margin:3px 0;">
                                    <?php 
                                echo $note_text;
                                ?>

                                    <div style="font-size:10px; text-align:right; color:#CCCCCC;">From <?php 
                                echo $item['create_user_id'] ? module_user::link_open($item['create_user_id'], true) : _l('Customer');
                                ?>
 on <?php 
                                echo print_date($item['date_created'], true);
                                ?>

                                    </div>
                                </div>

                                <?php 
                            }
                            ?>

                            </div>
                            <?php 
                            $file_data['file_comments'] = ob_get_clean();
                            $template->assign_values($file_data);
                            $template->assign_values($customer_data);
                            $template->assign_values($job_data);
                            if (class_exists('module_quote', false)) {
                                $quote_data['quote_approved_by'] = $quote_data['approved_by'];
                                $quote_data['quote_date_approved'] = $quote_data['date_approved'];
                                unset($quote_data['approved_by']);
                                unset($quote_data['date_approved']);
                                $template->assign_values($quote_data);
                            }
                            $template->page_title = $file_data['file_name'];
                            $template->content = '<form action="" method="post"><input type="hidden" name="save_file_comments" value="1">' . $template->content . '</form>';
                            echo $template->render('pretty_html');
                        }
                    }
                }
                break;
            case 'download_bucket':
                @ob_end_clean();
                $file_id = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : false;
                $hash = isset($_REQUEST['hash']) ? trim($_REQUEST['hash']) : false;
                if ($file_id && $hash) {
                    $correct_hash = $this->link_public_download_bucket($file_id, true);
                    if ($correct_hash == $hash) {
                        // all good to print a receipt for this payment.
                        $file_data = $this->get_file($file_id, false);
                        @ignore_user_abort(true);
                        $search = array();
                        $search['bucket_parent_file_id'] = $file_id;
                        $files = module_file::get_files($search);
                        //Create ZIP
                        $zip = new ZipArchive();
                        $zipName = "bucket-" . $file_id . "-" . md5($file_id . _UCM_SECRET) . ".zip";
                        if ($zip->open(_FILE_UPLOAD_PATH . $zipName, ZIPARCHIVE::CREATE) !== TRUE) {
                            echo 'Failed to create bucket zip file';
                            exit;
                        }
                        foreach ($files as $file) {
                            if (is_file($file['file_path'])) {
                                $zip->addFromString($file['file_name'], file_get_contents($file['file_path']));
                            }
                        }
                        $zip->close();
                        //Set headers
                        header("Pragma: public");
                        header("Expires: 0");
                        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                        header("Cache-Control: public");
                        header("Content-Description: File Transfer");
                        header("Content-type: application/octet-stream");
                        //header("Content-Disposition: attachment; filename='" . $zipName . "'");
                        header("Content-Disposition: attachment; filename=\"" . preg_replace("#[^a-zA-Z0-9]+#", "-", $file_data['file_name']) . ".zip\";");
                        header("Content-Transfer-Encoding: binary");
                        header("Content-Length: " . filesize(_FILE_UPLOAD_PATH . $zipName));
                        @clearstatcache();
                        //Make sure the file size isn't cached
                        $size = @readfile(_FILE_UPLOAD_PATH . $zipName);
                        if (!$size) {
                            echo file_get_contents(_FILE_UPLOAD_PATH . $zipName);
                        }
                        @unlink(_FILE_UPLOAD_PATH . $zipName);
                    }
                }
                exit;
                break;
            case 'download':
                @ob_end_clean();
                $file_id = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : false;
                $hash = isset($_REQUEST['hash']) ? trim($_REQUEST['hash']) : false;
                if ($file_id && $hash) {
                    $correct_hash = $this->link_public_view($file_id, true);
                    if ($correct_hash == $hash) {
                        // all good to print a receipt for this payment.
                        $file_data = $this->get_file($file_id, false);
                        if (isset($file_data['file_url']) && strlen($file_data['file_url'])) {
                            redirect_browser($file_data['file_url']);
                        } else {
                            if (is_file($file_data['file_path'])) {
                                header("Pragma: public");
                                header("Expires: 0");
                                header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                                header("Cache-Control: private", false);
                                header("Content-type: " . dtbaker_mime_type($file_data['file_name'], $file_data['file_path']));
                                if (!isset($_REQUEST['embed'])) {
                                    header("Content-Disposition: attachment; filename=\"" . $file_data['file_name'] . "\";");
                                    header("Content-Transfer-Encoding: binary");
                                }
                                header("Content-Length: " . filesize($file_data['file_path']));
                                //readfile($file_data['file_path']);
                                $size = @readfile($file_data['file_path']);
                                if (!$size) {
                                    echo file_get_contents($file_data['file_path']);
                                }
                            } else {
                                echo 'Not found';
                            }
                        }
                    }
                }
                exit;
                break;
        }
    }
Beispiel #17
0
 public static function get_replace_fields($quote_id, $quote_data = false)
 {
     if (!$quote_data) {
         $quote_data = self::get_quote($quote_id);
     }
     $data = array('quote_number' => htmlspecialchars($quote_data['name']), 'quote_name' => htmlspecialchars($quote_data['name']), 'project_type' => _l(module_config::c('project_name_single', 'Website')), 'print_link' => self::link_public_print($quote_id), 'quote_url' => self::link_public($quote_id), 'title' => module_config::s('admin_system_name'), 'create_date' => print_date($quote_data['date_create']));
     if (isset($quote_data['customer_id']) && $quote_data['customer_id']) {
         $customer_data = module_customer::get_replace_fields($quote_data['customer_id'], $quote_data['contact_user_id'] ? $quote_data['contact_user_id'] : false);
         $data = array_merge($data, $customer_data);
         // so we get total_amount_due and stuff.
     }
     $user_details = array('staff_first_name' => '', 'staff_last_name' => '', 'staff_email' => '', 'staff_phone' => '', 'staff_fax' => '', 'staff_mobile' => '');
     if (isset($quote_data['user_id']) && $quote_data['user_id']) {
         $user_data = module_user::get_user($quote_data['user_id'], false);
         if ($user_data && $user_data['user_id'] == $quote_data['user_id']) {
             $user_details = array('staff_first_name' => $user_data['name'], 'staff_last_name' => $user_data['last_name'], 'staff_email' => $user_data['email'], 'staff_phone' => $user_data['phone'], 'staff_fax' => $user_data['fax'], 'staff_mobile' => $user_data['mobile']);
         }
     }
     $data = array_merge($data, $user_details);
     foreach ($quote_data as $key => $val) {
         if (strpos($key, 'date') !== false) {
             $quote_data[$key] = print_date($val);
         }
     }
     if (isset($quote_data['description'])) {
         $quote_data['description'] = module_security::purify_html($quote_data['description']);
     }
     //        $customer_data = $quote_data['customer_id'] ? module_customer::get_replace_fields($quote_data['customer_id']) : array();
     //        $website_data = $quote_data['website_id'] ? module_website::get_replace_fields($quote_data['website_id']) : array();
     //        $data = array_merge($data,$customer_data,$website_data,$quote_data);
     $data = array_merge($data, $quote_data);
     $website_url = $project_names = $project_names_and_url = array();
     if ($quote_data['website_id']) {
         $website_data = module_website::get_website($quote_data['website_id']);
         if ($website_data && $website_data['website_id'] == $quote_data['website_id']) {
             if (isset($website_data['url']) && $website_data['url']) {
                 $website_url[$website_data['website_id']] = module_website::urlify($website_data['url']);
                 $website_data['name_url'] = $website_data['name'] . ' (' . module_website::urlify($website_data['url']) . ')';
             } else {
                 $website_data['name_url'] = $website_data['name'];
             }
             $project_names[$website_data['website_id']] = $website_data['name'];
             $project_names_and_url[$website_data['website_id']] = $website_data['name_url'];
             $fields = module_website::get_replace_fields($website_data['website_id'], $website_data);
             foreach ($fields as $key => $val) {
                 if (!isset($data[$key]) || !$data[$key] && $val) {
                     $data[$key] = $val;
                 }
             }
         }
     }
     $data['website_name'] = $data['project_name'] = forum_text(count($project_names) ? implode(', ', $project_names) : '');
     $data['website_name_url'] = forum_text(count($project_names_and_url) ? implode(', ', $project_names_and_url) : '');
     $data['website_url'] = forum_text(count($website_url) ? implode(', ', $website_url) : '');
     if (class_exists('module_group', false) && module_group::is_plugin_enabled()) {
         // get the quote groups
         $wg = array();
         $g = array();
         if ($quote_id > 0) {
             $quote_data = module_quote::get_quote($quote_id);
             foreach (module_group::get_groups_search(array('owner_table' => 'quote', 'owner_id' => $quote_id)) as $group) {
                 $g[$group['group_id']] = $group['name'];
             }
             /*// get the website groups
               foreach(module_group::get_groups_search(array(
                   'owner_table' => 'website',
                   'owner_id' => $quote_data['website_id'],
               )) as $group){
                   $wg[$group['group_id']] = $group['name'];
               }*/
         }
         $data['quote_group'] = implode(', ', $g);
         /*$data['website_group'] = implode(', ',$wg);*/
     }
     // addition. find all extra keys for this quote and add them in.
     // we also have to find any EMPTY extra fields, and add those in as well.
     if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) {
         $all_extra_fields = module_extra::get_defaults('quote');
         foreach ($all_extra_fields as $e) {
             $data[$e['key']] = _l('N/A');
         }
         // and find the ones with values:
         $extras = module_extra::get_extras(array('owner_table' => 'quote', 'owner_id' => $quote_id));
         foreach ($extras as $e) {
             $data[$e['extra_key']] = $e['extra'];
         }
     }
     // also do this for customer fields
     /*if($quote_data['customer_id']){
           $all_extra_fields = module_extra::get_defaults('customer');
           foreach($all_extra_fields as $e){
               $data[$e['key']] = _l('N/A');
           }
           $extras = module_extra::get_extras(array('owner_table'=>'customer','owner_id'=>$quote_data['customer_id']));
           foreach($extras as $e){
               $data[$e['extra_key']] = $e['extra'];
           }
       }*/
     return $data;
 }
Beispiel #18
0
    public static function print_note($note_id, $note_item, $display_summary = false, $can_edit = true, $can_delete = true, $options = array())
    {
        if (!$note_item) {
            $note_item = self::get_note($note_id);
        }
        static $x = 0;
        global $plugins;
        $can_view = $can_edit = $can_create = $can_delete = false;
        // re-check permissions...
        if (isset($options) && isset($options['owner_table']) && $options['owner_table'] && isset($options['title']) && $options['title']) {
            $can_view = $plugins[$options['owner_table']]->can_i('view', $options['title']);
            $can_edit = $plugins[$options['owner_table']]->can_i('edit', $options['title']);
            $can_create = $plugins[$options['owner_table']]->can_i('create', $options['title']);
            $can_delete = $plugins[$options['owner_table']]->can_i('delete', $options['title']);
        } else {
        }
        if (!module_security::is_page_editable()) {
            //$can_edit=$can_create=$can_delete=false;
        }
        if (isset($options['summary_owners'])) {
            unset($options['summary_owners']);
        }
        if (isset($options['display_summary'])) {
            unset($options['display_summary']);
        }
        //
        if (!trim($note_item['note'])) {
            $note_item['note'] = 'none';
        }
        ob_start();
        /** START TABLE LAYOUT **/
        $table_manager = module_theme::new_table_manager();
        $columns = array();
        $columns['date'] = array('title' => 'Date', 'width' => 60, 'callback' => function ($note_item) {
            if ($note_item['reminder']) {
                echo '<strong>';
            }
            echo print_date($note_item['note_time']);
            if ($note_item['reminder']) {
                echo '</strong>';
            }
        });
        $columns['description'] = array('title' => 'Description', 'callback' => function ($note_item) {
            if (isset($note_item['public']) && $note_item['public']) {
                echo '* ';
            }
            if ($note_item['can_edit']) {
                $note_text = nl2br(htmlspecialchars(substr($note_item['note'], 0, module_config::c('note_trim_length', 35))));
                $note_text .= strlen($note_item['note']) > module_config::c('note_trim_length', 35) ? '...' : '';
                ?>

                <a href="<?php 
                echo module_note::link_open($note_item['note_id'], false, $note_item['options']);
                ?>
" data-options="<?php 
                echo htmlspecialchars(base64_encode(serialize($note_item['options'])));
                ?>
" class="note_edit note_options_link" rel="<?php 
                echo $note_item['note_id'];
                ?>
"> <?php 
                echo $note_text;
                ?>
 </a>
                <?php 
            } else {
                echo forum_text($note_item['note']);
            }
        });
        $columns['info'] = array('title' => 'Info', 'width' => 40, 'callback' => function ($note_item) {
            if ($note_item['display_summary']) {
                if ($note_item['rel_data']) {
                    global $plugins;
                    echo $plugins[$note_item['owner_table']]->link_open($note_item['owner_id'], true);
                }
            } else {
                // find the user name who made thsi note.
                $user_data = module_user::get_user($note_item['create_user_id']);
                echo $user_data['name'];
            }
        });
        if ($can_delete) {
            $columns['del'] = array('title' => ' ', 'callback' => function ($note_item) {
                if ($note_item['can_delete']) {
                    ?>
 <a href="<?php 
                    echo module_note::link_open($note_item['note_id'], false, array_merge($note_item['options'], array('do_delete' => 'yes', 'note_id' => $note_item['note_id'])));
                    ?>
" data-options="<?php 
                    echo htmlspecialchars(base64_encode(serialize(array_merge($note_item['options'], array('do_delete' => 'yes', 'note_id' => $note_item['note_id'])))));
                    ?>
" rel="<?php 
                    echo $note_item['note_id'];
                    ?>
" onclick="if(confirm('<?php 
                    _e('Really Delete Note?');
                    ?>
'))return true; else return false;" class="note_delete note_options_link delete ui-state-default ui-corner-all ui-icon ui-icon-trash">[x]</a> <?php 
                }
            });
        }
        $table_manager->set_columns($columns);
        $table_manager->inline_table = true;
        $table_manager->row_callback = function ($row_data, &$row_object) use($display_summary, $can_edit, $can_delete, &$options) {
            $row_data['display_summary'] = $display_summary;
            $row_data['can_edit'] = $can_edit;
            $row_data['can_delete'] = $can_delete;
            $row_data['options'] = $options;
            $row_object->row_id = 'note_' . $row_data['note_id'];
            return $row_data;
        };
        $table_manager->print_row($note_item);
        /*?>
        		<tr id="note_<?php echo $note_item['note_id'];?>" class="<?php echo ($x++%2)?'odd':'even';?>">
        			<td>
                        <?php
                        if($note_item['reminder'])echo '<strong>';
                        echo print_date($note_item['note_time']);
                        if($note_item['reminder'])echo '</strong>';
                        ?>
        			</td>
        			<td>
                        <?php
                        if(isset($note_item['public']) && $note_item['public'])echo '* ';
                        if($can_edit){
                            $note_text = nl2br(htmlspecialchars(substr($note_item['note'],0,module_config::c('note_trim_length',35))));
                            $note_text .= strlen($note_item['note']) > module_config::c('note_trim_length',35) ? '...' : '';
                            ?>
                        <a href="<?php echo self::link_open($note_item['note_id'],false,$options);?>" data-options="<?php echo htmlspecialchars(base64_encode(serialize($options)));?>" class="note_edit note_options_link" rel="<?php echo $note_item['note_id'];?>"> <?php echo $note_text; ?> </a>
                        <?php }else{
                            echo forum_text($note_item['note']);
                        } ?>
        			</td>
        			<td nowrap="nowrap">
        				<?php
        				if($display_summary){
        					if($note_item['rel_data']){
                                echo $plugins[$note_item['owner_table']]->link_open($note_item['owner_id'],true);
        					}
        				}else{
        					// find the user name who made thsi note.
        					$user_data = module_user::get_user($note_item['create_user_id']);
        					echo $user_data['name'];
        				}
        				?>
        			</td>
                    <?php if($can_delete){ ?>
                    <td><a href="<?php echo self::link_open($note_item['note_id'],false,array_merge($options,array('do_delete'=>'yes','note_id'=>$note_item['note_id'])));?>" data-options="<?php echo htmlspecialchars(base64_encode(serialize(array_merge($options,array('do_delete'=>'yes','note_id'=>$note_item['note_id'])))));?>" rel="<?php echo $note_item['note_id'];?>" onclick="if(confirm('<?php _e('Really Delete Note?');?>'))return true; else return false;" class="note_delete note_options_link delete ui-state-default ui-corner-all ui-icon ui-icon-trash">[x]</a></td>
                    <?php } ?>
        		</tr>
        		<?php
        		*/
        return ob_get_clean();
    }
    // todo: move this out to a function in ticket.php
    // todo: put the utf8_encode / decode as an option for people who have troubles with it.
    /*if(preg_match('#<br[^>]*>#i',$ticket_message['content'])){
          $ticket_message['content'] = preg_replace("#\r?\n#",'',$ticket_message['content']);
      }*/
    $ticket_message['content'] = preg_replace("#<br[^>]*>#i", '', $ticket_message['content']);
    $ticket_message['content'] = preg_replace('#(\\r?\\n\\s*){2,}#', "\n\n", $ticket_message['content']);
    switch (module_config::c('ticket_utf8_method', 1)) {
        case 1:
            $text = forum_text($ticket_message['content']);
            break;
        case 2:
            $text = forum_text(utf8_encode($ticket_message['content']));
            break;
        case 3:
            $text = forum_text(utf8_encode(utf8_decode($ticket_message['content'])));
            break;
    }
    //$text = forum_text(utf8_encode($ticket_message['content']));
    //$text = forum_text(utf8_encode(utf8_decode($ticket_message['content'])));
    if ($ticket_message['cache'] == 'autoreply' && strlen($ticket_message['htmlcontent']) > 2) {
        $text = $ticket_message['htmlcontent'];
    }
    $lines = explode("\n", $text);
    $do_we_hide = count($lines) > 4 && module_config::c('ticket_hide_messages', 1) && $ticket_message_counter < $ticket_message_count && $ticket_message_count != 2;
    if ($ticket_message['cache'] == 'autoreply') {
        $last_response_from = 'autoreply';
        ?>

                                                            <a href="#" onclick="$('.autoreply_holder').show(); $(this).hide(); return false;"><?php 
        _e('Show auto reply &raquo;');