Пример #1
0
 public function body()
 {
     print 'This is an example Attachment page.';
     $com = $this->init_module(Utils_Attachment::module_name(), array('grupa'));
     $this->display_module($com);
     //------------------------------ print out src
     print '<hr><b>Install</b><br>';
     $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/Attachment/AttachmentInstall.php');
     print '<hr><b>Main</b><br>';
     $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/Attachment/Attachment_0.php');
     print '<hr><b>Common</b><br>';
     $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/Attachment/AttachmentCommon_0.php');
 }
Пример #2
0
 public function body($arg = null, $rb = null, $uid = null)
 {
     if (isset($arg) && isset($rb)) {
         $this->group = $rb->tab . '/' . $arg['id'];
         if (Utils_WatchdogCommon::get_category_id($rb->tab) !== null) {
             $this->watchdog_category = $rb->tab;
             $this->watchdog_id = $arg['id'];
         }
         $this->set_view_func(array('Utils_RecordBrowserCommon', 'create_default_linked_label'), array($rb->tab, $arg['id']));
     }
     if (!isset($this->group) && !$uid) {
         trigger_error('Key not given to attachment module', E_USER_ERROR);
     }
     $_SESSION['client']['utils_attachment_group'] = $this->group;
     load_js('modules/Utils/Attachment/attachments.js');
     Base_ThemeCommon::load_css('Utils_Attachment', 'browse');
     $this->rb = $this->init_module(Utils_RecordBrowser::module_name(), 'utils_attachment', 'utils_attachment');
     $defaults = array('permission' => Base_User_SettingsCommon::get('CRM_Common', 'default_record_permission'), 'func' => serialize($this->func), 'args' => serialize($this->args));
     $rb_cols = array();
     $single_group = is_string($this->group) || count($this->group) == 1;
     if ($this->force_multiple) {
         $single_group = false;
     }
     if ($single_group) {
         $group = is_string($this->group) ? $this->group : reset($this->group);
         $defaults['local'] = $group;
     } else {
         // force attached to display
         $rb_cols['attached_to'] = true;
         $this->rb->set_button(false);
     }
     $this->rb->set_defaults($defaults);
     $this->rb->set_additional_actions_method(array($this, 'add_actions'));
     $this->rb->set_header_properties(array('sticky' => array('width' => 1, 'display' => false), 'attached_to' => array('width' => "16em"), 'edited_on' => array('width' => "12em"), 'title' => array('width' => "20em")));
     if ($uid) {
         $this->rb->set_button(false);
         $this->rb->disable_actions(array('delete'));
         $this->display_module($this->rb, array(array(':Created_by' => $uid), $rb_cols, array('sticky' => 'DESC', 'edited_on' => 'DESC')), 'show_data');
     } else {
         $crits = array();
         if (!is_array($this->group)) {
             $this->group = array($this->group);
         }
         if (isset($_SESSION['attachment_copy']) && count($this->group) == 1 && $_SESSION['attachment_copy']['group'] != $this->group) {
             $this->rb->new_button(Base_ThemeCommon::get_template_file(Utils_Attachment::module_name(), 'link.png'), __('Paste'), Utils_TooltipCommon::open_tag_attrs($_SESSION['attachment_copy']['text']) . ' ' . $this->create_callback_href(array($this, 'paste')));
         }
         if ($this->group) {
             $g = array_map(array('DB', 'qstr'), $this->group);
             $crits['id'] = DB::GetCol('SELECT attachment FROM utils_attachment_local WHERE local IN (' . implode(',', $g) . ')');
         } else {
             $crits['id'] = 0;
         }
         $this->display_module($this->rb, array($crits, $rb_cols, array('sticky' => 'DESC', 'edited_on' => 'DESC')), 'show_data');
     }
 }
Пример #3
0
 public function manage_permissions()
 {
     $this->help('Permissions Editor', 'permissions');
     $this->init();
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), 'permissions_' . $this->tab, 'permissions_' . $this->tab);
     $gb->set_table_columns(array(array('name' => __('Access type'), 'width' => '100px'), array('name' => __('Clearance required'), 'width' => '30'), array('name' => __('Applies to records'), 'width' => '60'), array('name' => __('Fields'), 'width' => '100px')));
     $ret = DB::Execute('SELECT * FROM ' . $this->tab . '_access AS acs ORDER BY action DESC');
     $tmp = DB::GetAll('SELECT * FROM ' . $this->tab . '_access_clearance AS acs');
     $clearance = array();
     foreach ($tmp as $t) {
         $clearance[$t['rule_id']][] = $t['clearance'];
     }
     $tmp = DB::GetAll('SELECT * FROM ' . $this->tab . '_access_fields AS acs');
     $fields = array();
     foreach ($tmp as $t) {
         $fields[$t['rule_id']][] = $t['block_field'];
     }
     $all_clearances = array_flip(Base_AclCommon::get_clearance(true));
     $all_fields = array();
     foreach ($this->table_rows as $v) {
         $all_fields[$v['id']] = $v['name'];
     }
     $actions = $this->get_permission_actions();
     $rules = array();
     while ($row = $ret->FetchRow()) {
         if (!isset($clearance[$row['id']])) {
             $clearance[$row['id']] = array();
         }
         if (!isset($fields[$row['id']])) {
             $fields[$row['id']] = array();
         }
         $action = $actions[$row['action']];
         $crits = Utils_RecordBrowserCommon::parse_access_crits($row['crits'], true);
         $crits_text = Utils_RecordBrowserCommon::crits_to_words($this->tab, $crits);
         foreach ($fields[$row['id']] as $k => $v) {
             if (isset($all_fields[$v])) {
                 $fields[$row['id']][$k] = $all_fields[$v];
             } else {
                 unset($fields[$row['id']][$k]);
             }
         }
         foreach ($clearance[$row['id']] as $k => $v) {
             if (isset($all_clearances[$v])) {
                 $clearance[$row['id']][$k] = $all_clearances[$v];
             } else {
                 unset($clearance[$row['id']][$k]);
             }
         }
         $c_all_fields = count($all_fields);
         $c_fields = count($fields[$row['id']]);
         $props = $c_all_fields ? ($c_all_fields - $c_fields) / $c_all_fields : 0;
         $color = dechex(255 - 68 * $props) . dechex(187 + 68 * $props) . 'BB';
         $fields_value = $c_all_fields - $c_fields . ' / ' . $c_all_fields;
         if ($props != 1) {
             $fields_value = Utils_TooltipCommon::create($fields_value, '<b>' . __('Excluded fields') . ':</b><hr>' . implode('<br>', $fields[$row['id']]), false);
         }
         $rules[$row['action']][$row['id']] = array($action, '<span class="Utils_RecordBrowser__permissions_crits">' . implode(' <span class="joint">' . __('and') . '</span><br>', $clearance[$row['id']]) . '</span>', array('value' => '<span class="Utils_RecordBrowser__permissions_crits">' . $crits_text . '</span>', 'overflow_box' => false), array('style' => 'background-color:#' . $color, 'value' => $fields_value));
     }
     foreach ($actions as $a => $l) {
         if (isset($rules[$a])) {
             foreach ($rules[$a] as $id => $vals) {
                 $gb_row = $gb->get_new_row();
                 $gb_row->add_data_array($vals);
                 if (Base_AdminCommon::get_access('Utils_RecordBrowser', 'permissions') == 2) {
                     $gb_row->add_action($this->create_callback_href(array($this, 'edit_permissions_rule'), array($id)), 'edit', 'Edit');
                     $gb_row->add_action($this->create_callback_href(array($this, 'edit_permissions_rule'), array($id, true)), 'copy', __('Clone rule'), Base_ThemeCommon::get_template_file(Utils_Attachment::module_name(), 'copy_small.png'));
                     $gb_row->add_action($this->create_confirm_callback_href(__('Are you sure you want to delete this rule?'), array($this, 'delete_permissions_rule'), array($id)), 'delete', 'Delete');
                 }
             }
         }
     }
     if (Base_AdminCommon::get_access('Utils_RecordBrowser', 'permissions') == 2) {
         Base_ActionBarCommon::add('add', __('Add new rule'), $this->create_callback_href(array($this, 'edit_permissions_rule'), array(null)));
     }
     Base_ThemeCommon::load_css('Utils_RecordBrowser', 'edit_permissions');
     $this->display_module($gb);
     eval_js('utils_recordbrowser__crits_initialized = false;');
 }
Пример #4
0
 public static function display_date($row, $nolink = false, $a = null, $view = false)
 {
     $date = Base_RegionalSettingsCommon::time2reg($row['edited_on'], false);
     $time = Base_RegionalSettingsCommon::time2reg($row['edited_on'], true, false);
     $info = Utils_RecordBrowserCommon::get_record_info('utils_attachment', $row['id']);
     $by = Base_UserCommon::get_user_label($info['edited_by'] ? $info['edited_by'] : $info['created_by'], $nolink);
     $format = Base_User_SettingsCommon::get(Utils_Attachment::module_name(), 'edited_on_format');
     return str_replace(array('%D', '%T', '%U'), array($date, $time, $by), $format);
 }
Пример #5
0
@ini_set('memory_limit', '256M');
@ini_set('memory_limit', '512M');
Utils_WatchdogCommon::dont_notify();
$rs_checkpoint = Patch::checkpoint('recordset');
if (!$rs_checkpoint->is_done()) {
    Patch::require_time(5);
    Utils_RecordBrowserCommon::uninstall_recordset('utils_attachment');
    $fields = array(array('name' => _M('Edited on'), 'type' => 'timestamp', 'extra' => false, 'visible' => true, 'required' => false, 'display_callback' => array('Utils_AttachmentCommon', 'display_date'), 'QFfield_callback' => array('Utils_AttachmentCommon', 'QFfield_date')), array('name' => _M('Title'), 'type' => 'text', 'param' => 255, 'required' => false, 'extra' => false, 'visible' => true), array('name' => _M('Note'), 'type' => 'long text', 'required' => false, 'extra' => false, 'visible' => true, 'display_callback' => array('Utils_AttachmentCommon', 'display_note'), 'QFfield_callback' => array('Utils_AttachmentCommon', 'QFfield_note')), array('name' => _M('Permission'), 'type' => 'commondata', 'required' => true, 'param' => array('order_by_key' => true, 'CRM/Access'), 'extra' => false), array('name' => _M('Sticky'), 'type' => 'checkbox', 'visible' => true, 'extra' => false), array('name' => _M('Crypted'), 'type' => 'checkbox', 'extra' => false, 'QFfield_callback' => array('Utils_AttachmentCommon', 'QFfield_crypted')), array('name' => _M('Func'), 'type' => 'text', 'param' => 255, 'required' => true, 'extra' => false, 'visible' => false), array('name' => _M('Args'), 'type' => 'text', 'param' => 255, 'required' => true, 'extra' => false, 'visible' => false));
    Utils_RecordBrowserCommon::install_new_recordset('utils_attachment', $fields);
    Utils_RecordBrowserCommon::add_access('utils_attachment', 'view', 'ACCESS:employee', array('(!permission' => 2, '|employees' => 'USER'), array('func', 'args'));
    Utils_RecordBrowserCommon::add_access('utils_attachment', 'delete', 'ACCESS:employee', array(':Created_by' => 'USER_ID'));
    Utils_RecordBrowserCommon::add_access('utils_attachment', 'delete', array('ACCESS:employee', 'ACCESS:manager'));
    Utils_RecordBrowserCommon::add_access('utils_attachment', 'add', 'ACCESS:employee');
    Utils_RecordBrowserCommon::add_access('utils_attachment', 'edit', 'ACCESS:employee', array('(permission' => 0, '|employees' => 'USER', '|customer' => 'USER'), array('edited_on'));
    Utils_RecordBrowserCommon::register_processing_callback('utils_attachment', array('Utils_AttachmentCommon', 'submit_attachment'));
    Utils_RecordBrowserCommon::set_tpl('utils_attachment', Base_ThemeCommon::get_template_filename(Utils_Attachment::module_name(), 'View_entry'));
    $ret = DB::CreateTable('utils_attachment_local', '
			local C(255) NOTNULL,
			attachment I4 NOTNULL,
			func C(255),
			args C(255)', array('constraints' => ', FOREIGN KEY (attachment) REFERENCES utils_attachment_data_1(ID)'));
    if (!$ret) {
        print 'Unable to create table utils_attachment_link.<br>';
        return false;
    }
    DB::CreateIndex('utils_attachment_local__idx', 'utils_attachment_local', 'local');
    $rs_checkpoint->done();
}
//parse old notes
Patch::set_message('Processing notes');
$old_checkpoint = Patch::checkpoint('old');
Пример #6
0
 public function salesopportunity_addon($salesopportunity)
 {
     $attachment_groups = array();
     $related_crits = array('related' => 'premium_salesopportunity/' . $salesopportunity['id']);
     if (ModuleManager::is_installed('CRM_Meeting') >= 0) {
         $records = Utils_RecordBrowserCommon::get_records('crm_meeting', $related_crits, array());
         foreach ($records as $rec) {
             $attachment_groups[] = 'crm_meeting/' . $rec['id'];
         }
     }
     if (ModuleManager::is_installed('CRM_Tasks') >= 0) {
         $records = Utils_RecordBrowserCommon::get_records('task', $related_crits, array());
         foreach ($records as $rec) {
             $attachment_groups[] = 'task/' . $rec['id'];
         }
     }
     if (ModuleManager::is_installed('CRM_PhoneCall') >= 0) {
         $records = Utils_RecordBrowserCommon::get_records('phonecall', $related_crits, array());
         foreach ($records as $rec) {
             $attachment_groups[] = 'phonecall/' . $rec['id'];
         }
     }
     if (Base_User_SettingsCommon::get('CRM/Contacts/NotesAggregate', 'show_all_notes')) {
         $attachment_groups[] = 'premium_salesopportunity/' . $salesopportunity['id'];
     }
     $a = $this->init_module(Utils_Attachment::module_name(), array($attachment_groups));
     $a->set_multiple_group_mode();
     $this->display_module($a);
 }