public function get_row(midcom_core_dbaobject $document) { $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); $entry = array(); $entry['id'] = $document->id; $entry['index_title'] = $document->title; $entry['index_filesize'] = 0; $entry['filesize'] = ''; $entry['mimetype'] = ''; $icon = MIDCOM_STATIC_URL . '/stock-icons/mime/gnome-text-blank.png'; $alt = ''; $att = $document->load_attachment(); if ($att) { $icon = midcom_helper_misc::get_mime_icon($att->mimetype); $alt = $att->name; $stats = $att->stat(); $entry['index_filesize'] = $stats[7]; $entry['filesize'] = midcom_helper_misc::filesize_to_string($stats[7]); $entry['mimetype'] = org_openpsa_documents_document_dba::get_file_type($att->mimetype); } $title = '<a class="tab_escape" href="' . $prefix . 'document/' . $document->guid . '/"><img src="' . $icon . '"'; $title .= 'alt="' . $alt . '" style="border: 0px; height: 16px; vertical-align: middle" /> ' . $document->title . '</a>'; $entry['title'] = $title; $entry['created'] = strftime('%Y-%m-%d %X', $document->metadata->created); $entry['index_author'] = ''; $entry['author'] = ''; if ($document->author) { $author = org_openpsa_contacts_person_dba::get_cached($document->author); $entry['index_author'] = $author->rname; $author_card = org_openpsa_widgets_contact::get($author->guid); $entry['author'] = $author_card->show_inline(); } return $entry; }
/** * Object editing view * * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. * @return boolean Indicating success. */ public function _handler_edit($handler_id, array $args, array &$data) { $this->_object = midcom::get('dbfactory')->get_object_by_guid($args[0]); $this->_object->require_do('midgard:update'); $this->_object->require_do('midgard:parameters'); midcom::get('auth')->require_user_do('midgard.admin.asgard:manage_objects', null, 'midgard_admin_asgard_plugin'); // List all parameters for display $qb = midcom_db_parameter::new_query_builder(); $qb->add_constraint('parentguid', '=', $this->_object->guid); $qb->add_order('domain'); $qb->add_order('name'); $data['parameters'] = $qb->execute(); $this->_prepare_request_data(); midgard_admin_asgard_plugin::bind_to_object($this->_object, $handler_id, $data); }
public function get_row(midcom_core_dbaobject $invoice) { $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); $entry = array(); $number = $invoice->get_label(); $link_html = "<a href='{$prefix}invoice/{$invoice->guid}/'>" . $number . "</a>"; if ($number == "") { $number = "n/a"; } $entry['id'] = $invoice->id; $entry['index_number'] = $number; $entry['number'] = $link_html; if (!is_a($this->_customer, 'org_openpsa_contacts_group_dba')) { try { $customer = org_openpsa_contacts_group_dba::get_cached($invoice->customer); $entry['customer'] = "<a href=\"{$this->_request_data['invoices_url']}list/customer/all/{$customer->guid}/\">" . $customer->get_label() . "</a>"; } catch (midcom_error $e) { $entry['customer'] = ''; } } if (!is_a($this->_customer, 'org_openpsa_contacts_person_dba')) { try { $contact = org_openpsa_contacts_person_dba::get_cached($invoice->customerContact); $entry['contact'] = "<a href=\"{$this->_request_data['invoices_url']}list/customer/all/{$contact->guid}/\">" . $contact->get_label() . "</a>"; } catch (midcom_error $e) { $entry['contact'] = ''; } } if (!empty($this->_request_data['deliverable'])) { $constraints = array('invoice' => $invoice->id, 'deliverable' => $this->_request_data['deliverable']->id); $item_sum = org_openpsa_invoices_invoice_item_dba::get_sum($constraints); $this->_request_data['totals']['deliverable'] += $item_sum; $entry['index_item_sum'] = $item_sum; $entry['item_sum'] = '<span title="' . $this->_l10n->get('sum including vat') . ': ' . org_openpsa_helpers::format_number($item_sum / 100 * $invoice->vat + $item_sum) . '">' . org_openpsa_helpers::format_number($item_sum) . '</span>'; } $entry['index_sum'] = $invoice->sum; $entry['sum'] = '<span title="' . $this->_l10n->get('sum including vat') . ': ' . org_openpsa_helpers::format_number($invoice->sum / 100 * $invoice->vat + $invoice->sum) . '">' . org_openpsa_helpers::format_number($invoice->sum) . '</span>'; $entry['due'] = ''; if ($invoice->due > 0) { $entry['due'] = strftime('%Y-%m-%d', $invoice->due); } $colname = 'action'; if ($this->_list_type == 'paid') { $colname = 'paid'; } $entry[$colname] = $this->_master->render_invoice_actions($invoice); return $entry; }
public function __set($property, $value) { parent::__set($property, $value); if ($property == 'firstname' || $property == 'lastname' || $property == 'homepage' || $property == 'email') { $this->_update_computed_members(); } }
public function __get($property) { if ($property == 'status_type') { return org_openpsa_projects_workflow::get_status_type($this->status); } return parent::__get($property); }
public function __construct($id = null) { parent::__construct($id); if (!$this->orgOpenpsaObtype) { $this->orgOpenpsaObtype = self::TYPE_NORMAL; } }
public function __get($property) { if ($property == 'up' && extension_loaded('midgard2')) { $property = 'snippetdir'; } return parent::__get($property); }
/** * Wrapped so we can hook notifications and also because current core doesn't support deletes */ function delete($notify = true, $event = false) { if ($notify) { $this->notify('remove', $event); } return parent::delete(); }
/** * By default all authenticated users should be able to do * whatever they wish with relatedto objects, later we can add * restrictions on object level as necessary. */ function get_class_magic_default_privileges() { $privileges = parent::get_class_magic_default_privileges(); $privileges['USERS']['midgard:create'] = MIDCOM_PRIVILEGE_ALLOW; $privileges['USERS']['midgard:update'] = MIDCOM_PRIVILEGE_ALLOW; $privileges['USERS']['midgard:read'] = MIDCOM_PRIVILEGE_ALLOW; return $privileges; }
public function __construct($id = null) { $this->_use_rcs = false; $this->_use_activitystream = false; parent::__construct($id); if (!$this->id) { $this->timestamp = $this->gmtime(); } }
public function __get($property) { if ($property == 'invoice_label' || $property == 'postal_label') { if (!isset($this->_address_extras[$property])) { $this->_get_address_extra($property); } return $this->_address_extras[$property]; } return parent::__get($property); }
public function __construct($id = null) { parent::__construct($id); /* To specify different values for MMS and SMS first unset the MMS values to destroy the reference, then set correct value */ $this->mms_lib =& $this->sms_lib; $this->mms_lib_api =& $this->sms_lib_api; $this->mms_lib_location =& $this->sms_lib_location; $this->mms_lib_client_id =& $this->sms_lib_client_id; $this->mms_lib_user =& $this->sms_lib_user; $this->mms_lib_password =& $this->sms_lib_password; $config = midcom_baseclasses_components_configuration::get('org.openpsa.directmarketing', 'config'); $this->chunk_size = $config->get('chunk_size'); }
public function _on_deleting() { $this->update_cache(false); if ($this->reportedHours > 0) { midcom_connection::set_error(MGD_ERR_HAS_DEPENDANTS); midcom::get('uimessages')->add(midcom::get('i18n')->get_string('org.openpsa.projects', 'org.openpsa.projects'), midcom::get('i18n')->get_string('task deletion now allowed because of hour reports', 'org.openpsa.projects'), 'warning'); return false; } return parent::_on_deleting(); }
/** * Returns the the parent object. Tries to utilize the Memcache * data, loading the actual information only if it is not cached. * * @param midcom_core_dbaobject $object The DBA object we're working on * @return bool Indicating visibility state. * @see get_parent_guid() * @todo rethink this, IMO we should trust midgard cores get_parent and then just do the object conversion if neccessary since this can return stale objects and other nastiness */ public static function get_parent(midcom_core_dbaobject $object) { static $parents = array(); static $parentlinks = array(); if (!isset($parentlinks[$object->guid])) { $parent_guid = $object->get_parent_guid(); if (empty($parent_guid)) { $parent = null; if (!empty($object->guid)) { $parentlinks[$object->guid] = null; } } else { if (!isset($parents[$parent_guid])) { try { $parents[$parent_guid] = midcom::get('dbfactory')->get_object_by_guid($parent_guid); } catch (midcom_error $e) { } } $parent =& $parents[$parent_guid]; if (!empty($object->guid)) { $parentlinks[$object->guid] =& $parents[$parent_guid]; } } } else { $parent =& $parentlinks[$object->guid]; } return $parent; }
/** * Generates, loads and prepares the schema database. * * The operations are done on all available schemas within the DB. */ public function create($type, $include_fields) { if ($type != null) { $dba_type = $type; if (!midcom::get('dbclassloader')->is_midcom_db_object($type)) { $dba_type = midcom::get('dbclassloader')->get_midcom_class_name_for_mgdschema_object($type); } $dummy_object = new $dba_type(); $type_fields = $dummy_object->get_properties(); } else { $type = get_class($this->_object); if (!midcom::get('dbclassloader')->is_midcom_db_object($type)) { $this->_object = midcom::get('dbfactory')->convert_midgard_to_midcom($this->_object); } $type_fields = $this->_object->get_properties(); } if (empty($include_fields)) { $include_fields = null; } else { if (is_string($include_fields)) { $include_fields = array($include_fields); } } //This is an ugly little workaround for unittesting $template = midcom_helper_datamanager2_schema::load_database('file:/midgard/admin/asgard/config/schemadb_default.inc'); $empty_db = clone $template['object']; $this->_schemadb = array('object' => $empty_db); //workaround end $this->_reflector = new midgard_reflection_property(midcom_helper_reflector::resolve_baseclass($type)); // Iterate through object properties unset($type_fields['metadata']); if (!extension_loaded('midgard2')) { // Midgard1 returns properties is random order so we need to sort them heuristically usort($type_fields, array($this, 'sort_schema_fields')); } foreach ($type_fields as $key) { if (in_array($key, $this->_config->get('object_skip_fields'))) { continue; } // Skip the fields that aren't requested, if inclusion list has been defined if ($include_fields && !in_array($key, $include_fields)) { continue; } // Only hosts have lang field that we will actually display if ($key == 'lang' && !is_a($this->_object, 'midcom_db_host')) { continue; } // Skip topic symlink field because it is a special field not meant to be touched directly if ($key == 'symlink' && is_a($this->_object, 'midcom_db_topic')) { continue; } // Linked fields should use chooser if ($this->_reflector->is_link($key)) { $this->_add_linked_field($key); // Skip rest of processing continue; } $field_type = $this->_reflector->get_midgard_type($key); switch ($field_type) { case MGD_TYPE_GUID: case MGD_TYPE_STRING: if ($key == 'component' && is_a($this->_object, 'midcom_db_topic')) { $this->_add_component_dropdown($key); break; } // Special name handling, start by checking if given type is same as $this->_object and if not making a dummy copy (we're probably in creation mode then) if (midcom::get('dbfactory')->is_a($this->_object, $type)) { $name_obj = $this->_object; } else { $name_obj = new $type(); } if ($key === midcom_helper_reflector::get_name_property($name_obj)) { $this->_add_name_field($key, $name_obj); break; } unset($name_obj); // Special page treatment if ($key === 'info' && $type === 'midcom_db_page') { $this->_add_info_field_for_page($key); break; } if ($key === 'info' && $type === 'midcom_db_pageelement') { $this->_schemadb['object']->append_field($key, array('title' => $key, 'storage' => $key, 'type' => 'select', 'type_config' => array('options' => array('' => 'not inherited', 'inherit' => 'inherited')), 'widget' => 'select')); break; } $this->_schemadb['object']->append_field($key, array('title' => $key, 'storage' => $key, 'type' => 'text', 'widget' => 'text')); break; case MGD_TYPE_LONGTEXT: $this->_add_longtext_field($key, $type); break; case MGD_TYPE_INT: case MGD_TYPE_UINT: $this->_add_int_field($key); break; case MGD_TYPE_FLOAT: $this->_schemadb['object']->append_field($key, array('title' => $key, 'storage' => $key, 'type' => 'number', 'widget' => 'text')); break; case MGD_TYPE_BOOLEAN: $this->_schemadb['object']->append_field($key, array('title' => $key, 'storage' => $key, 'type' => 'boolean', 'widget' => 'checkbox')); break; case MGD_TYPE_TIMESTAMP: $this->_schemadb['object']->append_field($key, array('title' => $key, 'storage' => $key, 'type' => 'date', 'widget' => 'jsdate')); break; } } $this->_add_rcs_field(); if ($this->add_copy_fields) { $this->_add_copy_fields(); } return $this->_schemadb; }
public function __construct($id = null) { $this->_use_rcs = false; $this->_use_activitystream = false; parent::__construct($id); }
public function __get($property) { if ($property == 'deliverable_html') { if (is_null($this->_deliverable_html)) { $this->_generate_html(); } return $this->_deliverable_html; } return parent::__get($property); }
public function __get($property) { if ($property == 'contacts') { if (is_null($this->_contacts)) { $this->get_members(); } return $this->_contacts; } return parent::__get($property); }
/** * By default all authenticated users should be able to do * whatever they wish with relatedto objects, later we can add * restrictions on object level as necessary. */ function get_class_magic_default_privileges() { $privileges = parent::get_class_magic_default_privileges(); $privileges['ANONYMOUS']['midgard:read'] = MIDCOM_PRIVILEGE_DENY; return $privileges; }