本文整理汇总了PHP中Objects::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Objects::instance方法的具体用法?PHP Objects::instance怎么用?PHP Objects::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Objects
的用法示例。
在下文中一共展示了Objects::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rebuild
public function rebuild($start_date = null, $end_date = null)
{
if (!$start_date) {
$start_date = config_option('last_sharing_table_rebuild');
}
if ($start_date instanceof DateTimeValue) {
$start_date = $start_date->toMySQL();
}
if ($end_date instanceof DateTimeValue) {
$end_date = $end_date->toMySQL();
}
if ($end_date) {
$end_cond = "AND updated_on <= '{$end_date}'";
}
try {
$object_ids = Objects::instance()->findAll(array('id' => true, "conditions" => "updated_on >= '{$start_date}' {$end_cond}"));
$obj_count = 0;
DB::beginWork();
foreach ($object_ids as $id) {
$obj = Objects::findObject($id);
if ($obj instanceof ContentDataObject) {
$obj->addToSharingTable();
$obj_count++;
}
}
set_config_option('last_sharing_table_rebuild', DateTimeValueLib::now()->toMySQL());
DB::commit();
} catch (Exception $e) {
DB::rollback();
Logger::log("Failed to rebuild sharing table: " . $e->getMessage() . "\nTrace: " . $e->getTraceAsString());
}
return $obj_count;
}
示例2: getCOColumnType
/**
* Return column type
*
* @access public
* @param string $column_name
* @return string
*/
function getCOColumnType($column_name, $columns) {
if(isset($columns[$column_name])) {
return $columns[$column_name];
} else {
return Objects::instance()->getColumnType($column_name);
}
}
示例3: activity_feed
/**
*
*
*/
public function activity_feed()
{
ajx_set_no_back(true);
require_javascript("og/modules/dashboardComments.js");
require_javascript("jquery/jquery.scrollTo-min.js");
$filesPerPage = config_option('files_per_page');
$start = array_var($_GET, 'start') ? (int) array_var($_GET, 'start') : 0;
$limit = array_var($_GET, 'limit') ? array_var($_GET, 'limit') : $filesPerPage;
$order = array_var($_GET, 'sort');
$orderdir = array_var($_GET, 'dir');
$page = (int) ($start / $limit) + 1;
$extra_conditions = " AND jt.type IN ('content_object', 'comment')";
$trashed = array_var($_GET, 'trashed', false);
$archived = array_var($_GET, 'archived', false);
$pagination = ContentDataObjects::listing(array("start" => $start, "limit" => $limit, "order" => $order, "order_dir" => $orderdir, "trashed" => $trashed, "archived" => $archived, "count_results" => false, "extra_conditions" => $extra_conditions, "join_params" => array("jt_field" => "id", "e_field" => "object_type_id", "table" => TABLE_PREFIX . "object_types")));
$result = $pagination->objects;
$total_items = $pagination->total;
if (!$result) {
$result = array();
}
$info = array();
foreach ($result as $obj) {
$info_elem = $obj->getArrayInfo($trashed, $archived);
$instance = Objects::instance()->findObject($info_elem['object_id']);
$info_elem['url'] = $instance->getViewUrl();
if (method_exists($instance, "getText")) {
$info_elem['content'] = $instance->getText();
}
$info_elem['picture'] = $instance->getCreatedBy()->getPictureUrl();
$info_elem['friendly_date'] = friendly_date($instance->getCreatedOn());
$info_elem['comment'] = $instance->getComments();
if ($instance instanceof Contact) {
if ($instance->isCompany()) {
$info_elem['icon'] = 'ico-company';
$info_elem['type'] = 'company';
}
}
$info_elem['isRead'] = $instance->getIsRead(logged_user()->getId());
$info_elem['manager'] = get_class($instance->manager());
$info[] = $info_elem;
}
$listing = array("totalCount" => $total_items, "start" => $start, "objects" => $info);
tpl_assign("feeds", $listing);
}
示例4: activity_feed
//.........这里部分代码省略.........
foreach ($ids as $id) {
$obj = Objects::findObject($id);
if ($obj->canDelete(logged_user())) {
try {
$obj->untrash($errorMessage);
ApplicationLogs::createLog($obj, ApplicationLogs::ACTION_UNTRASH);
$success++;
} catch (Exception $e) {
$error++;
}
} else {
$error++;
}
}
if ($success > 0) {
flash_success(lang("success untrash objects", $success));
}
if ($error > 0) {
$errorString = is_null($errorMessage) ? lang("error untrash objects", $error) : $errorMessage;
flash_error($errorString);
}
}
}
}
}
}
}
}
}
}
/*FIXME else if (array_var($_GET, 'action') == 'move') {
$wsid = array_var($_GET, "moveTo");
$destination = Projects::findById($wsid);
if (!$destination instanceof Project) {
$resultMessage = lang('project dnx');
$resultCode = 1;
} else if (!can_add(logged_user(), $destination, 'ProjectMessages')) {
$resultMessage = lang('no access permissions');
$resultCode = 1;
} else {
$ids = explode(',', array_var($_GET, 'objects'));
$count = 0;
DB::beginWork();
foreach ($ids as $id) {
$split = explode(":", $id);
$type = $split[0];
$obj = Objects::findObject($split[1]);
$mantainWs = array_var($_GET, "mantainWs");
if ($type != 'Projects' && $obj->canEdit(logged_user())) {
if ($type == 'MailContents') {
$email = MailContents::findById($split[1]);
$conversation = MailContents::getMailsFromConversation($email);
foreach ($conversation as $conv_email) {
$count += MailController::addEmailToWorkspace($conv_email->getId(), $destination, $mantainWs);
if (array_var($_GET, 'classify_atts') && $conv_email->getHasAttachments()) {
MailUtilities::parseMail($conv_email->getContent(), $decoded, $parsedEmail, $warnings);
$classification_data = array();
for ($j=0; $j < count(array_var($parsedEmail, "Attachments", array())); $j++) {
$classification_data["att_".$j] = true;
}
$tags = implode(",", $conv_email->getTagNames());
MailController::classifyFile($classification_data, $conv_email, $parsedEmail, array($destination), $mantainWs, $tags);
}
}
$count++;
} else {
示例5: paginate
/**
* This function will return paginated result. Result is an array where first element is
* array of returned object and second populated pagination object that can be used for
* obtaining and rendering pagination data using various helpers.
*
* Items and pagination array vars are indexed with 0 for items and 1 for pagination
* because you can't use associative indexing with list() construct
*
* @access public
* @param array $arguments Query argumens (@see find()) Limit and offset are ignored!
* @param integer $items_per_page Number of items per page
* @param integer $current_page Current page number
* @return array
*/
function paginate($arguments = null, $items_per_page = 10, $current_page = 1)
{
if (isset($this) && instance_of($this, 'Objects')) {
return parent::paginate($arguments, $items_per_page, $current_page);
} else {
return Objects::instance()->paginate($arguments, $items_per_page, $current_page);
}
// if
}
示例6: executeReport
/**
* Execute a report and return results
*
* @param $id
* @param $params
*
* @return array
*/
static function executeReport($id, $params, $order_by_col = '', $order_by_asc = true, $offset=0, $limit=50, $to_print = false) {
if (is_null(active_context())) {
CompanyWebsite::instance()->setContext(build_context_array(array_var($_REQUEST, 'context')));
}
$results = array();
$report = self::getReport($id);
if($report instanceof Report){
$conditionsFields = ReportConditions::getAllReportConditionsForFields($id);
$conditionsCp = ReportConditions::getAllReportConditionsForCustomProperties($id);
$ot = ObjectTypes::findById($report->getReportObjectTypeId());
$table = $ot->getTableName();
eval('$managerInstance = ' . $ot->getHandlerClass() . "::instance();");
eval('$item_class = ' . $ot->getHandlerClass() . '::instance()->getItemClass(); $object = new $item_class();');
$order_by = '';
if (is_object($params)) {
$params = get_object_vars($params);
}
$report_columns = ReportColumns::getAllReportColumns($id);
$allConditions = "";
if(count($conditionsFields) > 0){
foreach($conditionsFields as $condField){
$skip_condition = false;
$model = $ot->getHandlerClass();
$model_instance = new $model();
$col_type = $model_instance->getColumnType($condField->getFieldName());
$allConditions .= ' AND ';
$dateFormat = 'm/d/Y';
if(isset($params[$condField->getId()])){
$value = $params[$condField->getId()];
if ($col_type == DATA_TYPE_DATE || $col_type == DATA_TYPE_DATETIME)
$dateFormat = user_config_option('date_format');
} else {
$value = $condField->getValue();
}
if ($value == '' && $condField->getIsParametrizable()) $skip_condition = true;
if (!$skip_condition) {
if($condField->getCondition() == 'like' || $condField->getCondition() == 'not like'){
$value = '%'.$value.'%';
}
if ($col_type == DATA_TYPE_DATE || $col_type == DATA_TYPE_DATETIME) {
$dtValue = DateTimeValueLib::dateFromFormatAndString($dateFormat, $value);
$value = $dtValue->format('Y-m-d');
}
if($condField->getCondition() != '%'){
if ($col_type == DATA_TYPE_INTEGER || $col_type == DATA_TYPE_FLOAT) {
$allConditions .= '`'.$condField->getFieldName().'` '.$condField->getCondition().' '.DB::escape($value);
} else {
if ($condField->getCondition()=='=' || $condField->getCondition()=='<=' || $condField->getCondition()=='>='){
if ($col_type == DATA_TYPE_DATETIME || $col_type == DATA_TYPE_DATE) {
$equal = 'datediff('.DB::escape($value).', `'.$condField->getFieldName().'`)=0';
} else {
$equal = '`'.$condField->getFieldName().'` '.$condField->getCondition().' '.DB::escape($value);
}
switch($condField->getCondition()){
case '=':
$allConditions .= $equal;
break;
case '<=':
case '>=':
$allConditions .= '(`'.$condField->getFieldName().'` '.$condField->getCondition().' '.DB::escape($value).' OR '.$equal.') ';
break;
}
} else {
$allConditions .= '`'.$condField->getFieldName().'` '.$condField->getCondition().' '.DB::escape($value);
}
}
} else {
$allConditions .= '`'.$condField->getFieldName().'` like '.DB::escape("%$value");
}
} else $allConditions .= ' true';
}
}
if(count($conditionsCp) > 0){
$dateFormat = user_config_option('date_format');
$date_format_tip = date_format_tip($dateFormat);
foreach($conditionsCp as $condCp){
$cp = CustomProperties::getCustomProperty($condCp->getCustomPropertyId());
$skip_condition = false;
if(isset($params[$condCp->getId()."_".$cp->getName()])){
$value = $params[$condCp->getId()."_".$cp->getName()];
//.........这里部分代码省略.........
示例7: manager
/**
* Return manager instance
*
* @access protected
* @param void
* @return Objects
*/
function manager()
{
if (!$this->manager instanceof Objects) {
$this->manager = Objects::instance();
}
return $this->manager;
}
示例8: chdir
<?php
chdir(dirname(__FILE__));
header("Content-type: text/plain");
define("CONSOLE_MODE", true);
include "init.php";
Env::useHelper('format');
define('SCRIPT_MEMORY_LIMIT', 1024 * 1024 * 1024);
// 1 GB
@set_time_limit(0);
ini_set('memory_limit', SCRIPT_MEMORY_LIMIT / (1024 * 1024) + 50 . 'M');
$i = 0;
$objects_ids = Objects::instance()->findAll(array('columns' => array('id'), 'id' => true));
//,'conditions' => 'object_type_id = 6'
echo "\nObjects to process: " . count($objects_ids) . "\n-----------------------------------------------------------------";
foreach ($objects_ids as $object_id) {
$object = Objects::findObject($object_id);
$i++;
if ($object instanceof ContentDataObject) {
$members = $object->getMembers();
DB::execute("DELETE FROM " . TABLE_PREFIX . "object_members WHERE object_id = " . $object->getId() . " AND is_optimization = 1;");
ObjectMembers::addObjectToMembers($object->getId(), $members);
} else {
//
}
if ($i % 100 == 0) {
echo "\n{$i} objects processed. Mem usage: " . format_filesize(memory_get_usage(true));
}
}
示例9: add_mail
/**
* Add single mail
*
* @access public
* @param void
* @return null
*/
function add_mail()
{
if (logged_user()->isGuest()) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$this->addHelper('textile');
$mail_accounts = MailAccounts::getMailAccountsByUser(logged_user());
if (count($mail_accounts) < 1) {
flash_error(lang('no mail accounts set'));
ajx_current("empty");
return;
}
$this->setTemplate('add_mail');
$mail_data = array_var($_POST, 'mail');
$sendBtnClick = array_var($mail_data, 'sendBtnClick', '') == 'true' ? true : false;
$isDraft = array_var($mail_data, 'isDraft', '') == 'true' ? true : false;
$isUpload = array_var($mail_data, 'isUpload', '') == 'true' ? true : false;
$autosave = array_var($mail_data, 'autosave', '') == 'true';
$id = array_var($mail_data, 'id');
$mail = MailContents::findById($id);
$isNew = false;
if (!$mail) {
$isNew = true;
$mail = new MailContent();
}
tpl_assign('mail_to', urldecode(array_var($_GET, 'to')));
tpl_assign('link_to_objects', array_var($_GET, 'link_to_objects'));
$def_acc_id = $this->getDefaultAccountId();
if ($def_acc_id > 0) {
$def_acc = MailAccounts::getAccountById($def_acc_id);
if ($def_acc instanceof MailAccount) {
tpl_assign('default_account', $def_acc);
}
}
tpl_assign('mail', $mail);
tpl_assign('mail_data', $mail_data);
tpl_assign('mail_accounts', $mail_accounts);
Hook::fire('send_to', array_var($_GET, 'ids'), array_var($_GET, 'me'));
// Form is submited
if (is_array($mail_data)) {
$account = MailAccounts::findById(array_var($mail_data, 'account_id'));
if (!$account instanceof MailAccount) {
flash_error(lang('mail account dnx'));
ajx_current("empty");
return;
}
$accountUser = MailAccountContacts::getByAccountAndContact($account, logged_user());
if (!$accountUser instanceof MailAccountContact) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
if ($account->getOutgoingTrasnportType() == 'ssl' || $account->getOutgoingTrasnportType() == 'tls') {
$available_transports = stream_get_transports();
if (array_search($account->getOutgoingTrasnportType(), $available_transports) === FALSE) {
flash_error('The server does not support SSL.');
ajx_current("empty");
return;
}
}
$cp_errs = $this->checkRequiredCustomPropsBeforeSave(array_var($_POST, 'object_custom_properties', array()));
if (is_array($cp_errs) && count($cp_errs) > 0) {
foreach ($cp_errs as $err) {
flash_error($err);
}
ajx_current("empty");
return;
}
$subject = array_var($mail_data, 'subject');
$body = array_var($mail_data, 'body');
if (($pre_body_fname = array_var($mail_data, 'pre_body_fname')) != "") {
$body = str_replace(lang('content too long not loaded'), '', $body, $count = 1);
$tmp_filename = ROOT . "/tmp/{$pre_body_fname}";
if (is_file($tmp_filename)) {
$body .= file_get_contents($tmp_filename);
if (!$isDraft) {
@unlink($tmp_filename);
}
}
}
if (array_var($mail_data, 'format') == 'html') {
$css = "font-family:sans-serif,Arial,Verdana; font-size:14px; line-height:1.6; color:#222;";
Hook::fire('email_base_css', null, $css);
str_replace(array("\r", "\n"), "", $css);
$body = '<div style="' . $css . '">' . $body . '</div>';
$body = str_replace('<blockquote>', '<blockquote style="border-left:1px solid #987ADD;padding-left:10px;">', $body);
}
$type = 'text/' . array_var($mail_data, 'format');
$to = trim(array_var($mail_data, 'to'));
if (str_ends_with($to, ",") || str_ends_with($to, ";")) {
$to = substr($to, 0, strlen($to) - 1);
//.........这里部分代码省略.........
示例10: define
include "init.php";
Env::useHelper('format');
define('SCRIPT_MEMORY_LIMIT', 1024 * 1024 * 1024); // 1 GB
@set_time_limit(0);
ini_set('memory_limit', ((SCRIPT_MEMORY_LIMIT / (1024*1024))+50).'M');
DB::execute("CREATE TABLE IF NOT EXISTS `fixed_objects` (
`object_id` INTEGER UNSIGNED,
PRIMARY KEY (`object_id`)
) ENGINE = InnoDB;");
$drop_tmp_table = true;
$object_ids = Objects::instance()->findAll(array('id' => true, 'conditions' => 'id NOT IN (SELECT object_id FROM fixed_objects)'));
$processed_objects = array();
$i = 0;
$msg = "";
echo "\nObjects to process: " . count($object_ids) . "\n-----------------------------------------------------------------";
foreach ($object_ids as $object_id) {
$object = Objects::findObject($object_id);
if ($object instanceof ContentDataObject) {
$object->addToSharingTable();
}
$processed_objects[] = $object_id;
$i++;
$memory_limit_exceeded = memory_get_usage(true) > SCRIPT_MEMORY_LIMIT;
示例11: manager
/**
* Return manager instance
*
* @access protected
* @param void
* @return Objects
*/
function manager() {
if(!($this->manager instanceof Objects)) $this->manager = Objects::instance();
return $this->manager;
} // manager
示例12: processListActions
private function processListActions()
{
$linkedObject = null;
if (array_var($_GET, 'action') == 'delete') {
$ids = explode(',', array_var($_GET, 'objects'));
$result = ContentDataObjects::listing(array("extra_conditions" => " AND o.id IN (" . implode(",", $ids) . ") ", "include_deleted" => true));
$objects = $result->objects;
foreach ($objects as $object) {
$object->setDontMakeCalculations(true);
}
$real_deleted_ids = array();
list($succ, $err) = $this->do_delete_objects($objects, false, $real_deleted_ids);
if ($err > 0) {
flash_error(lang('error delete objects', $err));
} else {
Hook::fire('after_object_delete_permanently', $real_deleted_ids, $ignored);
flash_success(lang('success delete objects', $succ));
}
} else {
if (array_var($_GET, 'action') == 'delete_permanently') {
$ids = explode(',', array_var($_GET, 'objects'));
$objects = Objects::instance()->findAll(array("conditions" => "id IN (" . implode(",", $ids) . ")"));
$real_deleted_ids = array();
list($succ, $err) = $this->do_delete_objects($objects, true, $real_deleted_ids);
if ($err > 0) {
flash_error(lang('error delete objects', $err));
}
if ($succ > 0) {
Hook::fire('after_object_delete_permanently', $real_deleted_ids, $ignored);
flash_success(lang('success delete objects', $succ));
}
} else {
if (array_var($_GET, 'action') == 'markasread') {
$ids = explode(',', array_var($_GET, 'objects'));
list($succ, $err) = $this->do_mark_as_read_unread_objects($ids, true);
} else {
if (array_var($_GET, 'action') == 'markasunread') {
$ids = explode(',', array_var($_GET, 'objects'));
list($succ, $err) = $this->do_mark_as_read_unread_objects($ids, false);
} else {
if (array_var($_GET, 'action') == 'empty_trash_can') {
$result = ContentDataObjects::listing(array("select_columns" => array('id'), "raw_data" => true, "trashed" => true));
$objects = $result->objects;
foreach ($objects as $object) {
$object->setDontMakeCalculations(true);
}
if (count($objects) > 0) {
$obj_ids_str = implode(',', array_flat($objects));
$extra_conds = "AND o.id IN ({$obj_ids_str})";
$count = Trash::purge_trash(0, 1000, $extra_conds);
flash_success(lang('success delete objects', $count));
}
} else {
if (array_var($_GET, 'action') == 'archive') {
$ids = explode(',', array_var($_GET, 'objects'));
list($succ, $err) = $this->do_archive_unarchive_objects($ids, 'archive');
if ($err > 0) {
flash_error(lang('error archive objects', $err));
} else {
flash_success(lang('success archive objects', $succ));
}
} else {
if (array_var($_GET, 'action') == 'unarchive') {
$ids = explode(',', array_var($_GET, 'objects'));
list($succ, $err) = $this->do_archive_unarchive_objects($ids, 'unarchive');
if ($err > 0) {
flash_error(lang('error unarchive objects', $err));
} else {
flash_success(lang('success unarchive objects', $succ));
}
} else {
if (array_var($_GET, 'action') == 'unclassify') {
$ids = explode(',', array_var($_GET, 'objects'));
$err = 0;
$succ = 0;
foreach ($ids as $id) {
$split = explode(":", $id);
$type = $split[0];
if (Plugins::instance()->isActivePlugin('mail') && $type == 'MailContents') {
$email = MailContents::findById($split[1]);
if (isset($email) && !$email->isDeleted() && $email->canEdit(logged_user())) {
if (MailController::do_unclassify($email)) {
$succ++;
} else {
$err++;
}
} else {
$err++;
}
}
}
if ($err > 0) {
flash_error(lang('error unclassify emails', $err));
} else {
flash_success(lang('success unclassify emails', $succ));
}
} else {
if (array_var($_GET, 'action') == 'restore') {
$errorMessage = null;
$ids = explode(',', array_var($_GET, 'objects'));
//.........这里部分代码省略.........
示例13: add_multilple_objects_to_sharing_table
function add_multilple_objects_to_sharing_table($ids_str, $user)
{
if (substr(php_uname(), 0, 7) == "Windows" || !can_save_permissions_in_background()) {
$ids = explode(',', $ids_str);
foreach ($ids as $id) {
$object = Objects::instance()->findObject($id);
if ($object instanceof ContentDataObject) {
$object->addToSharingTable();
}
}
} else {
$command = "nice -n19 " . PHP_PATH . " " . ROOT . "/application/helpers/add_object_to_sharing_table.php " . ROOT . " " . $user->getId() . " " . $user->getTwistedToken() . " " . $ids_str;
exec("{$command} > /dev/null &");
//Test php command
exec(PHP_PATH . " -r 'echo function_exists(\"foo\") ? \"yes\" : \"no\";' 2>&1", $output, $return_var);
if ($return_var != 0) {
Logger::log(print_r("Error executing php command", true));
Logger::log(print_r($output, true));
Logger::log(print_r("Error code: " . $return_var, true));
}
//END Test php command
}
}
示例14: list_dimension_members
/**
*
*
*/
function list_dimension_members($member_id, $context_dimension_id, $object_type_id, $allowed_member_type_ids)
{
if ($member_id != 0) {
$contact_pg_ids = ContactPermissionGroups::getPermissionGroupIdsByContactCSV(logged_user()->getId(), false);
$member = members::findById($member_id);
$dimension = Dimensions::getDimensionById($context_dimension_id);
if ($object_type_id != null) {
$dimension_object_type_contents = $dimension->getObjectTypeContent($object_type_id);
foreach ($dimension_object_type_contents as $dotc) {
$dot_id = $dotc->getDimensionObjectTypeId();
if (is_null($allowed_member_type_ids) || in_array($dot_id, $allowed_member_type_ids)) {
$allowed_object_type_ids[] = $dot_id;
}
}
}
if ($dimension instanceof Dimension && $member instanceof Member) {
if (!$dimension->getDefinesPermissions() || $dimension->hasAllowAllForContact($contact_pg_ids)) {
$dimension_members = $dimension->getAllMembers(false, "parent_member_id, name", true);
} else {
if ($dimension->hasCheckForContact($contact_pg_ids)) {
$member_list = $dimension->getAllMembers(false, "parent_member_id, name", true);
$allowed_members = array();
foreach ($member_list as $dim_member) {
if (ContactMemberPermissions::instance()->contactCanReadMemberAll($contact_pg_ids, $dim_member->getId(), logged_user())) {
$allowed_members[] = $dim_member;
}
}
$dimension_members = $allowed_members;
}
}
$members_to_retrieve = array();
$association_ids = DimensionMemberAssociations::getAllAssociationIds($member->getDimensionId(), $context_dimension_id);
if (count($association_ids) > 0) {
$associated_members_ids_csv = '';
foreach ($association_ids as $id) {
$association = DimensionMemberAssociations::findById($id);
$children = $member->getAllChildrenInHierarchy();
if ($association->getDimensionId() == $context_dimension_id) {
$new_csv = MemberPropertyMembers::getAllMemberIds($id, $member_id);
$associated_members_ids_csv .= $new_csv != '' ? $new_csv . "," : '';
foreach ($children as $child) {
$new_csv = MemberPropertyMembers::getAllMemberIds($id, $child->getId());
$associated_members_ids_csv .= $new_csv != '' ? $new_csv . "," : '';
}
} else {
$new_csv = MemberPropertyMembers::getAllPropertyMemberIds($id, $member_id) . ",";
$associated_members_ids_csv .= $new_csv != '' ? $new_csv . "," : '';
foreach ($children as $child) {
$new_csv = MemberPropertyMembers::getAllPropertyMemberIds($id, $child->getId());
$associated_members_ids_csv .= $new_csv != '' ? $new_csv . "," : '';
}
}
}
$associated_members_ids = explode(',', $associated_members_ids_csv);
$associated_members_ids = array_unique($associated_members_ids);
}
if (isset($associated_members_ids) && count($associated_members_ids) > 0) {
foreach ($associated_members_ids as $id) {
$associated_member = Members::findById($id);
if (in_array($associated_member, $dimension_members)) {
$context_hierarchy_members = $associated_member->getAllParentMembersInHierarchy(true);
foreach ($context_hierarchy_members as $context_member) {
if (!in_array($context_member, $members_to_retrieve) && in_array($context_member, $dimension_members)) {
$members_to_retrieve[$context_member->getName()] = $context_member;
}
}
}
}
// alphabetical order
$members_to_retrieve = array_ksort($members_to_retrieve);
} else {
$members_to_retrieve[] = $dimension_members;
}
$membersset = array();
foreach ($members_to_retrieve as $m) {
$membersset[$m->getId()] = true;
}
$members = array();
// Todo adapt this code to call "buildMemberList" - (performance and code improvement)
foreach ($members_to_retrieve as $m) {
if ($m->getArchivedById() > 0) {
continue;
}
if ($object_type_id != null) {
$selectable = in_array($m->getObjectTypeId(), $allowed_object_type_ids) ? true : false;
}
$tempParent = $m->getParentMemberId();
$x = $m;
while ($x instanceof Member && !isset($membersset[$tempParent])) {
$tempParent = $x->getParentMemberId();
$x = $x->getParentMember();
}
if (!$x instanceof Member) {
$tempParent = 0;
}
if ($dot = DimensionObjectTypes::instance()->findOne(array("conditions" => "\n\t\t\t\t\t\tdimension_id = " . $dimension->getId() . " AND\n\t\t\t\t\t\tobject_type_id = " . $m->getObjectTypeId()))) {
//.........这里部分代码省略.........
示例15: get_allowed_columns
private function get_allowed_columns($object_type)
{
$fields = array();
if (isset($object_type)) {
$customProperties = CustomProperties::getAllCustomPropertiesByObjectType($object_type);
$objectFields = array();
foreach ($customProperties as $cp) {
if ($cp->getType() == 'table') {
continue;
}
$fields[] = array('id' => $cp->getId(), 'name' => $cp->getName(), 'type' => $cp->getType(), 'values' => $cp->getValues(), 'multiple' => $cp->getIsMultipleValues());
}
$ot = ObjectTypes::findById($object_type);
eval('$managerInstance = ' . $ot->getHandlerClass() . "::instance();");
$objectColumns = $managerInstance->getColumns();
$objectFields = array();
$objectColumns = array_diff($objectColumns, $managerInstance->getSystemColumns());
foreach ($objectColumns as $column) {
$objectFields[$column] = $managerInstance->getColumnType($column);
}
$common_columns = Objects::instance()->getColumns(false);
$common_columns = array_diff_key($common_columns, array_flip($managerInstance->getSystemColumns()));
$objectFields = array_merge($objectFields, $common_columns);
foreach ($objectFields as $name => $type) {
if ($type == DATA_TYPE_FLOAT || $type == DATA_TYPE_INTEGER) {
$type = 'numeric';
} else {
if ($type == DATA_TYPE_STRING) {
$type = 'text';
} else {
if ($type == DATA_TYPE_BOOLEAN) {
$type = 'boolean';
} else {
if ($type == DATA_TYPE_DATE || $type == DATA_TYPE_DATETIME) {
$type = 'date';
}
}
}
}
$field_name = Localization::instance()->lang('field ' . $ot->getHandlerClass() . ' ' . $name);
if (is_null($field_name)) {
$field_name = lang('field Objects ' . $name);
}
$fields[] = array('id' => $name, 'name' => $field_name, 'type' => $type);
}
$externalFields = $managerInstance->getExternalColumns();
foreach ($externalFields as $extField) {
$field_name = Localization::instance()->lang('field ' . $ot->getHandlerClass() . ' ' . $extField);
if (is_null($field_name)) {
$field_name = lang('field Objects ' . $extField);
}
$fields[] = array('id' => $extField, 'name' => $field_name, 'type' => 'external', 'multiple' => 0);
}
if (!array_var($_REQUEST, 'noaddcol')) {
Hook::fire('custom_reports_additional_columns', null, $fields);
}
}
usort($fields, array(&$this, 'compare_FieldName'));
return $fields;
}