Пример #1
0
 public static function search_format($id)
 {
     $row = Utils_RecordBrowserCommon::get_records('bugtrack', array('id' => $id));
     if (!$row) {
         return false;
     }
     $row = array_pop($row);
     return Utils_RecordBrowserCommon::record_link_open_tag('bugtrack', $row['id']) . __('Bug (attachment) #%d, %s', array($row['id'], $row['project_name'])) . Utils_RecordBrowserCommon::record_link_close_tag();
 }
Пример #2
0
 public static function search_format($id)
 {
     if (!Utils_RecordBrowserCommon::get_access('task', 'browse')) {
         return false;
     }
     $row = self::get_tasks(array('id' => $id));
     if (!$row) {
         return false;
     }
     $row = array_pop($row);
     return Utils_RecordBrowserCommon::record_link_open_tag('task', $row['id']) . __('Task (attachment) #%d, %s', array($row['id'], $row['title'])) . Utils_RecordBrowserCommon::record_link_close_tag();
 }
Пример #3
0
 public static function search_format($id)
 {
     $row = Utils_RecordBrowserCommon::get_record('crm_meeting', $id);
     if (!$row) {
         return false;
     }
     return Utils_RecordBrowserCommon::record_link_open_tag('crm_meeting', $row['id']) . __('Meeting (attachment) #%d, %s at %s', array($row['id'], $row['title'], Base_RegionalSettingsCommon::time2reg($row['date'], false))) . Utils_RecordBrowserCommon::record_link_close_tag();
 }
Пример #4
0
 /**
  * Create link to record with specific text.
  * @param int $id Record id
  * @param string $text Text to display as link
  * @param bool $nolink Do not create link switch
  * @param string $action Link to specific action. 'view' or 'edit'.
  * @return string html string with link
  */
 public function record_link($id, $text, $nolink = false, $action = 'view')
 {
     return Utils_RecordBrowserCommon::record_link_open_tag($this->tab, $id, $nolink, $action) . $text . Utils_RecordBrowserCommon::record_link_close_tag();
 }
Пример #5
0
	public static function search($word, $types) {
	        if(!$types) return;
	        
	        $r = null;
                $limit = Base_SearchCommon::get_recordset_limit_records();
	        $ret = array();
                
                foreach($types as $type) {
                    if($type=='files') {
		        $r = DB::SelectLimit('SELECT ua.id,uaf.original,ual.func,ual.args,ual.local,ua.f_title FROM utils_attachment_data_1 ua INNER JOIN utils_attachment_local AS ual ON ual.attachment=ua.id INNER JOIN utils_attachment_file AS uaf ON uaf.attach_id=ua.id WHERE ua.active=1 AND '.
				' uaf.original '.DB::like().' '.DB::Concat(DB::qstr('%'),'%s',DB::qstr('%')).' AND uaf.deleted=0', $limit, -1, array($word));
                    } elseif($type=='downloads') {
                        if(strlen($word)==32) {
                            $query = 'SELECT ua.id,uaf.original,ual.func,ual.args,ual.local,ua.f_title FROM utils_attachment_file uaf INNER JOIN utils_attachment_download uad ON uad.attach_file_id=uaf.id INNER JOIN utils_attachment_data_1 ua ON uaf.attach_id=ua.id INNER JOIN utils_attachment_local AS ual ON ual.attachment=ua.id WHERE uad.token='.DB::qstr($word);
                            $r = DB::Execute($query);
                        } else {
                            $query = parse_url($word,PHP_URL_QUERY);
                            if($query) {
                                $vars = array();
                                parse_str($query,$vars);
                                if($vars && isset($vars['id']) && isset($vars['token'])) {
                                    $query = 'SELECT ua.id,uaf.original,ual.func,ual.args,ual.local,ua.f_title FROM utils_attachment_file uaf INNER JOIN utils_attachment_download uad ON uad.attach_file_id=uaf.id INNER JOIN utils_attachment_data_1 ua ON uaf.attach_id=ua.id INNER JOIN utils_attachment_local AS ual ON ual.attachment=ua.id WHERE uad.id='.DB::qstr($vars['id']).' AND uad.token='.DB::qstr($vars['token']);
                                    $r = DB::Execute($query);
                                }
                            }
                        }
                    }
                
                    if($r) {
		        while($row = $r->FetchRow()) {
		            if(!self::get_access($row['id'])) continue;
			    $func = unserialize($row['func']);
                            $record = $func ? call_user_func_array($func, unserialize($row['args'])) : '';
                            if(!$record) continue;
                            $title = $row['original'].' - '.self::description_callback(Utils_RecordBrowserCommon::get_record('utils_attachment',$row['id']));
                            $title = Utils_RecordBrowserCommon::record_link_open_tag('utils_attachment', $row['id'])
                                 . __('Files').': ' . $title
                                 . Utils_RecordBrowserCommon::record_link_close_tag();
                            $ret[$row['id'].'#'.$row['local']] = $title . " ($record)";
		        }
                    }
                }
                return $ret;
	}
Пример #6
0
    public static function watchdog_label($tab, $cat, $rid, $events = array(), $label = null, $details = true) {
        $ret = array('category'=>$cat);
        if ($rid!==null) {
            $r = self::get_record($tab, $rid);
            if ($r===null) return null;
			if (!self::get_access($tab, 'view', $r)) return null;
            if (is_array($label)) {
                $label = Utils_RecordBrowserCommon::record_link_open_tag($tab, $rid)
                         . call_user_func($label, $r, true)
                         . Utils_RecordBrowserCommon::record_link_close_tag();
                $label = self::create_default_record_tooltip_ajax($label, $tab, $rid);
            } elseif ($label) {
                $label = Utils_RecordBrowserCommon::create_linked_label_r($tab, $label, $r);
                $label = self::create_default_record_tooltip_ajax($label, $tab, $rid);
            } else {
                $label = Utils_RecordBrowserCommon::create_default_linked_label($tab, $rid, false, false);
            }

            $ret['title'] = $label;
            $ret['view_href'] = Utils_RecordBrowserCommon::create_record_href($tab, $rid);
            $events_display = array();
            $events = array_reverse($events);
            $other_events = array();
            $header = false;
            foreach ($events as $v) {
        	if (count($events_display)>20) {
        		$other_events[__('And more...')] = 1;
        		break;
        	}
                $param = explode('_', $v);
                switch ($param[0]) {
                    case 'C':   $what = 'Created';
                    case 'D':   if (!isset($what)) $what = 'Deleted';
                    case 'R':   if (!isset($what)) $what = 'Restored';
								$event_display = array(
									'who'=> Base_UserCommon::get_user_label($r['created_by'], true),
									'when'=>Base_RegionalSettingsCommon::time2reg($r['created_on']),
									'what'=>_V($what)
									);
                                break;
                    case 'E':   $event_display = self::get_edit_details_modify_record($tab, $r['id'], $param[1] ,$details);
				                if (isset($event_display['what']) && !empty($event_display['what'])) $header = true;
                                break;

                    case 'N':   $event_display = false;
                                switch($param[1]) {
                                    case '+':
                                        $action = __('Note linked');
                                        break;
                                    case '-':
                                        $action = __('Note unlinked');
                                        break;
                                    default:
                                	if (!isset($other_events[$param[1]])) $other_events[$param[1]] = 0;
                                	$other_events[$param[1]]++;
                                	$event_display = null;
                                	break;
                                }
                                if($event_display===false) {
                                    $date = isset($param[3]) ? Base_RegionalSettingsCommon::time2reg($param[3]) : '';
                                    $who = isset($param[4]) ? Base_UserCommon::get_user_label($param[4], true) : '';
                                    $action .= ' - ' . self::create_default_linked_label('utils_attachment', $param[2]);
                                    $event_display = array('what'=>$action,
                                         'who' => $who,
                                         'when' => $date);
                                }
                                break;
                    default:    $event_display = array('what'=>_V($v));
                }
                if ($event_display) $events_display[] = $event_display;
            }
            foreach ($other_events as $k=>$v)
        		$events_display[] = array('what'=>_V($k).($v>1?' ['.$v.']':''));

            if ($events_display) {
                $theme = Base_ThemeCommon::init_smarty();

                if ($header) {
                    $theme->assign('header', array(__('Field'), __('Old value'), __('New value')));
                }

                $theme->assign('events', $events_display);

                $tpl = 'changes_list';
                if (Utils_WatchdogCommon::email_mode()) {
                    $record_data = self::get_record_tooltip_data($tab, $rid);
                    $theme->assign('record', $record_data);
                    $tpl = 'changes_list_email';
                }
                ob_start();
                Base_ThemeCommon::display_smarty($theme,'Utils_RecordBrowser', $tpl);
                $output = ob_get_clean();

                $ret['events'] = $output;
            } else {
                // if we've generated empty events for certain record, then
                // it's possible that some of the fields, that have changed,
                // are hidden so we have to check if there are any other events
                // If all events are the same and output is empty we can safely
                // mark all as notified.
                $all_events = Utils_WatchdogCommon::check_if_notified($tab, $rid);
                if (count($all_events) == count($events)) {
                    Utils_WatchdogCommon::notified($tab, $rid);
                }
                $ret = null;
            }
        }
        return $ret;
    }
Пример #7
0
 public static function display_mail_thread($record, $nolink, $desc)
 {
     if ($record['thread']) {
         return Utils_RecordBrowserCommon::record_link_open_tag('rc_mail_threads', $record['thread'], $nolink) . DB::GetOne('SELECT count(*) FROM rc_mails_data_1 WHERE f_thread=%d AND active=1', array($record['thread'])) . Utils_RecordBrowserCommon::record_link_close_tag();
     }
     return '';
 }
Пример #8
0
 public static function display_attached_to($row, $nolink = false, $a = null, $view = false)
 {
     $locals = DB::GetCol('SELECT local FROM utils_attachment_local WHERE attachment=%d', array($row['id']));
     $ret = array();
     foreach ($locals as $local) {
         $param = explode('/', $local);
         if (count($param) == 2 && preg_match('/^[1-9][0-9]*$/', $param[1])) {
             if (!Utils_RecordBrowserCommon::check_table_name($param[0], false, false)) {
                 DB::Execute('DELETE FROM utils_attachment_local WHERE local=%s', array($local));
                 continue;
             }
             $label = Utils_RecordBrowserCommon::create_default_linked_label($param[0], $param[1], true);
             $link = Utils_RecordBrowserCommon::record_link_open_tag($param[0], $param[1], $nolink, 'view', array('switch_to_addon' => __('Notes'))) . $label . Utils_RecordBrowserCommon::record_link_close_tag();
             $link = Utils_RecordBrowserCommon::create_default_record_tooltip_ajax($link, $param[0], $param[1]);
             $ret[] = $link;
         }
     }
     return implode(', ', $ret);
 }
Пример #9
0
 public static function search_format($id)
 {
     $phone = self::get_phonecall($id);
     if (!$phone) {
         return false;
     }
     return Utils_RecordBrowserCommon::record_link_open_tag('phonecall', $phone['id']) . __('Phonecall (attachment) #%d, %s at %s', array($phone['id'], $phone['subject'], Base_RegionalSettingsCommon::time2reg($phone['date_and_time']))) . Utils_RecordBrowserCommon::record_link_close_tag();
 }