本文整理汇总了PHP中Members::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Members::instance方法的具体用法?PHP Members::instance怎么用?PHP Members::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Members
的用法示例。
在下文中一共展示了Members::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateObjectContext
/**
* Returns true if the object blongs to the texmplate context ($memberIds)
* @author Ignacio Vazquez - elpepe.uy@gmail.com
* @param ContentDataObject $object
* @param array $memberIds
*/
static function validateObjectContext($object, $memberIds)
{
$valid = true;
// Dimensiones requeridas para el tipo de objecto
$dimensions = Dimensions::getAllowedDimensions(self::instance()->getObjectTypeId());
$requiredDimensions = array();
foreach ($dimensions as $dim) {
if ($dim['is_required']) {
$requiredDimensions[$dim['dimension_id']] = $dim;
// Performance, dim id in the array key ! ! !
}
}
// Miembros del Objeto
$objMembers = $object->getMemberIds();
// P/cada miembro
foreach ($objMembers as $mid) {
$member = Members::instance()->findById($mid);
if ($member instanceof Member) {
/* @var $member Member */
$did = $member->getDimensionId();
// Si la dimension del miembro esta en la requeridas
if ($requiredDimensions[$did]) {
if (!in_array($mid, $memberIds)) {
$valid = false;
}
}
}
}
if (!$valid) {
throw new DAOValidationError($this, array(lang("template members do not match object members")));
}
}
示例2: getInstance
function getInstance()
{
if (!isset(self::$instance[get_class()])) {
self::$instance = new Members();
}
return self::$instance;
}
示例3: getChildObjectTypes
static function getChildObjectTypes($member_id)
{
$m = Members::instance()->findById($member_id);
$d = $m->getDimensionId();
$parent_object_type_id = $m->getObjectTypeId();
$sql = "\n \t\t\tSELECT distinct(child_object_type_id) FROM " . TABLE_PREFIX . "dimension_object_type_hierarchies \n \t\t\tWHERE \n \t\t \t\tdimension_id = {$d} AND \n \t\t \t\tparent_object_type_id = {$parent_object_type_id} ";
return self::findAll(array("conditions" => "object_type_id IN ({$sql}) AND dimension_id = {$d}"));
}
示例4: getChildObjectTypes
static function getChildObjectTypes($member)
{
if ($member instanceof Member) {
$member_id = $member->getId();
$m = $member;
} else {
$member_id = $member;
$m = Members::instance()->findById($member_id);
if (!$m instanceof Member) {
return array();
}
}
$d = $m->getDimensionId();
$parent_object_type_id = $m->getObjectTypeId();
$sql = "\r\n \t\t\tSELECT distinct(child_object_type_id) FROM " . TABLE_PREFIX . "dimension_object_type_hierarchies \r\n \t\t\tWHERE \r\n \t\t \t\tdimension_id = {$d} AND enabled=1 AND\r\n \t\t \t\tparent_object_type_id = {$parent_object_type_id} ";
return self::findAll(array("conditions" => "object_type_id IN ({$sql}) AND dimension_id = {$d}"));
}
示例5: getChildObjectTypes
static function getChildObjectTypes($member) {
if ($member instanceof Member) {
$member_id = $member->getId();
$m = $member;
} else {
$member_id = $member;
$m = Members::instance()->findById($member_id);
if (!$m instanceof Member) return array();
}
$d = $m->getDimensionId() ;
$parent_object_type_id = $m->getObjectTypeId() ;
$sql = "
SELECT distinct(child_object_type_id) FROM ".TABLE_PREFIX."dimension_object_type_hierarchies
WHERE
dimension_id = $d AND
parent_object_type_id = $parent_object_type_id ";
return self::findAll(array("conditions"=>"object_type_id IN ($sql) AND dimension_id = $d"));
}
示例6: quick_add_form
function quick_add_form()
{
$this->setLayout('empty');
if ($dimension_id = array_var($_GET, 'dimension_id')) {
$dimension = Dimensions::instance()->findById($dimension_id);
$dimensionOptions = $dimension->getOptions(true);
$object_Types = array();
$parent_member_id = array_var($_GET, 'parent_member_id');
if ($parent_member_id) {
$parent_member = Members::instance()->findById($parent_member_id);
$object_types = DimensionObjectTypes::getChildObjectTypes($parent_member_id);
} else {
$object_types = DimensionObjectTypes::instance()->findAll(array("conditions" => "dimension_id = {$dimension_id} AND is_root = 1 "));
}
if (count($object_types)) {
if (count($object_types) == 1) {
// Input Hidden
tpl_assign('object_type', $object_types[0]);
tpl_assign('object_type_name', ObjectTypes::instance()->findById($object_types[0]->getObjectTypeId())->getName());
} else {
// Input combo
tpl_assign('object_types', $object_types);
}
} else {
tpl_assign("error_msg", $parent_member->getName() . " does not accept child nodes ");
}
$editUrls = array();
foreach ($object_types as $object_type) {
/* @var $object_type DimensionObjectType */
if (ObjectTypes::instance()->findById($object_type->getObjectTypeId())->getType() != 'dimension_object') {
continue;
}
$options = $object_type->getOptions(1);
if (isset($options->defaultAjax) && $options->defaultAjax->controller != "dashboard") {
$editUrls[$object_type->getObjectTypeId()] = get_url($options->defaultAjax->controller, 'add');
} else {
$t = ObjectTypes::instance()->findById($object_type->getObjectTypeId());
/* @var $t ObjectType */
$class_name = ucfirst($t->getName()) . "Controller";
if ($t && controller_exists($t->getName(), $t->getPluginId())) {
$editUrls[$object_type->getObjectTypeId()] = get_url($t->getName(), 'add');
} else {
$editUrls[$object_type->getObjectTypeId()] = get_url('member', 'add', array("dim_id" => $dimension_id));
}
}
}
tpl_assign('editUrls', $editUrls);
tpl_assign('parent_member_id', $parent_member_id);
tpl_assign('dimension_id', $dimension_id);
if (is_object($dimensionOptions) && is_object($dimensionOptions->quickAdd) && $dimensionOptions->quickAdd->formAction) {
tpl_assign('form_action', ROOT_URL . "/" . $dimensionOptions->quickAdd->formAction);
} else {
tpl_assign('form_action', get_url('member', 'add', array('quick' => '1')));
}
} else {
die("SORRY. Invalid dimension");
}
}
示例7: manager
/**
* Return manager instance
*
* @access protected
* @param void
* @return Members
*/
function manager() {
if(!($this->manager instanceof Members)) $this->manager = Members::instance();
return $this->manager;
} // manager
示例8: core_dimensions_after_user_deleted
/**
*
* Fires AFTER User is deleted - Contact.class.php
* Deletes All members associated with that user
* @param Contact $user
*/
function core_dimensions_after_user_deleted(Contact $user, $null)
{
$uid = $user->getId();
//Delete MyStuff
if ($myStuff = Members::findById($user->getPersonalMemberId())) {
$myStuff->delete();
}
// Delete All members
$members = Members::instance()->findByObjectId($uid);
if (count($members)) {
foreach ($members as $member) {
$member->delete();
evt_add("reload dimension tree", $member->getDimensionId());
}
}
}
示例9: quick_add_form
function quick_add_form()
{
ajx_current("empty");
$this->setLayout('empty');
$dimension_id = array_var($_GET, 'dimension_id');
$dimension = is_numeric($dimension_id) ? Dimensions::instance()->findById($dimension_id) : null;
if ($dimension instanceof Dimension) {
$object_Types = array();
$parent_member_id = array_var($_GET, 'parent_member_id');
$parent_member = Members::instance()->findById($parent_member_id);
if ($parent_member instanceof Member) {
$object_types = DimensionObjectTypes::getChildObjectTypes($parent_member);
if (count($object_types) == 0) {
$parent_member = null;
$object_types = DimensionObjectTypes::instance()->findAll(array("conditions" => "enabled=1 AND dimension_id = {$dimension_id} AND is_root = 1 AND object_type_id<>(SELECT id from " . TABLE_PREFIX . "object_types WHERE name='company')"));
}
} else {
$object_types = DimensionObjectTypes::instance()->findAll(array("conditions" => "enabled=1 AND dimension_id = {$dimension_id} AND is_root = 1 AND object_type_id<>(SELECT id from " . TABLE_PREFIX . "object_types WHERE name='company')"));
}
$obj_types = array();
$editUrls = array();
foreach ($object_types as $object_type) {
$options = $object_type->getOptions(1);
if (isset($options->defaultAjax) && $options->defaultAjax->controller != "dashboard") {
$editUrls[$object_type->getObjectTypeId()] = get_url($options->defaultAjax->controller, 'add');
} else {
$t = ObjectTypes::instance()->findById($object_type->getObjectTypeId());
$obj_types[$t->getId()] = $t;
$class_name = ucfirst($t->getName()) . "Controller";
$controller_exists = controller_exists($t->getName(), $t->getPluginId());
if ($controller_exists) {
Env::useController(ucfirst($t->getName()));
eval('$controller = new ' . $class_name . '();');
}
if ($t && controller_exists($t->getName(), $t->getPluginId()) && $t->getHandlerClass() != '' && $controller_exists && method_exists($controller, 'add')) {
$params = array("type" => $t->getId());
if ($parent_member instanceof Member) {
$params['parent'] = $parent_member->getId();
}
$editUrls[$t->getId()] = get_url($t->getName(), 'add', $params);
} else {
$params = array("dim_id" => $dimension_id, "type" => $t->getId());
if ($parent_member instanceof Member) {
$params['parent'] = $parent_member->getId();
}
$editUrls[$t->getId()] = get_url('member', 'add', $params);
}
}
}
$urls = array();
foreach ($editUrls as $ot_id => $url) {
$ot = array_var($obj_types, $ot_id);
if ($ot instanceof ObjectType) {
$link_text = ucfirst(strtolower(lang('new ' . $ot->getName())));
$iconcls = $ot->getIconClass();
} else {
$link_text = lang('new');
$iconcls = "";
}
$urls[] = array('link_text' => $link_text, 'url' => $url, 'iconcls' => $iconcls);
}
Hook::fire('member_quick_add_urls', array('dimension' => $dimension, 'object_types' => $object_types, 'parent_member' => $parent_member), $urls);
if (count($urls) > 1) {
ajx_extra_data(array('draw_menu' => 1, 'urls' => $urls));
} else {
ajx_extra_data(array('urls' => $urls));
}
} else {
Logger::log("Invalid dimension: {$dimension_id}");
}
}
示例10: getMembersByObjectAndDimension
static function getMembersByObjectAndDimension($object_id, $dimension_id, $extra_conditions = "")
{
$sql = "\n \t\t\t\tSELECT distinct(id) \n \t\t\t\tFROM " . TABLE_PREFIX . "object_members om \n \t\t\t\tINNER JOIN " . TABLE_PREFIX . "members m ON om.member_id = m.id \n \t\t\t\tWHERE \n \t\t\t\t\tdimension_id = {$dimension_id} AND \n \t\t\t\t\tom.object_id = {$object_id} \n \t\t\t\t\t{$extra_conditions}";
$result = array();
$rows = DB::executeAll($sql);
if (!is_array($rows)) {
return $result;
}
foreach ($rows as $row) {
$member = Members::instance()->findById($row['id']);
if ($member instanceof Member) {
$result[] = $member;
}
}
return $result;
}
示例11: execute
//.........这里部分代码省略.........
}
FileRepository::setBackend(new FileRepository_Backend_FileSystem(FILES_DIR, TABLE_PREFIX));
} else {
FileRepository::setBackend(new FileRepository_Backend_DB(TABLE_PREFIX));
}
PublicFiles::setRepositoryPath(ROOT . '/public/files');
if (!defined('PUBLIC_FOLDER')) {
define('PUBLIC_FOLDER', 'public');
}
if (trim(PUBLIC_FOLDER) == '') {
PublicFiles::setRepositoryUrl(with_slash(ROOT_URL) . 'files');
} else {
PublicFiles::setRepositoryUrl(with_slash(ROOT_URL) . 'public/files');
}
$member_parents = array();
$members = Members::findAll();
foreach ($members as $member) {
$member_parents[$member->getId()] = $member->getAllParentMembersInHierarchy(false, false);
}
$object_members = DB::executeAll('SELECT * FROM ' . $t_prefix . 'object_members WHERE is_optimization=0 and not exists (SELECT x.object_id FROM ' . $t_prefix . 'object_members x where x.object_id=fo_object_members.object_id and x.is_optimization=1)');
foreach ($object_members as $om) {
$parents = isset($member_parents[$om['member_id']]) ? $member_parents[$om['member_id']] : array();
if (count($parents) > 0) {
$sql_values = "";
foreach ($parents as $p) {
$sql_values .= ($sql_values == "" ? "" : ",") . "(" . $om['object_id'] . "," . $p->getId() . ",1)";
}
$sql = "INSERT INTO " . $t_prefix . "object_members (object_id, member_id, is_optimization) VALUES {$sql_values} ON DUPLICATE KEY UPDATE is_optimization=1;";
DB::execute($sql);
}
}
$this->printMessage("Finished generating Object Members");
foreach ($members as $m) {
if ($m->getParentMember() instanceof Member && $m->getDimensionId() != $m->getParentMember()->getDimensionId()) {
$m->setDimensionId($m->getParentMember()->getDimensionId());
$m->save();
}
}
$app_move_logs = ApplicationLogs::findAll(array("conditions" => "action = 'move'"));
foreach ($app_move_logs as &$app_log) {
/* @var $app_log ApplicationLog */
$exp_log_data = explode(";", $app_log->getLogData());
if (count($exp_log_data) > 1) {
$old_to = array_var($exp_log_data, 1);
$old_from = array_var($exp_log_data, 0);
} else {
$old_to = array_var($exp_log_data, 0);
$old_from = "";
}
$to_id = str_replace("to:", "", $old_to);
$new_to_id = Members::instance()->findOne(array("id" => true, "conditions" => "ws_id = '{$to_id}'"));
if (count($new_to_id) > 0) {
$new_to_id = $new_to_id[0];
}
$new_from_ids = "";
$from_ids = str_replace("from:", "", $old_from);
if ($from_ids != "") {
$new_from_ids_array = Members::instance()->findAll(array("id" => true, "conditions" => "ws_id IN ({$from_ids})"));
$new_from_ids = implode(",", $new_from_ids_array);
}
if ($new_to_id) {
if ($new_from_ids) {
$log_data = "from:{$new_from_ids};to:{$new_to_id}";
} else {
$log_data = "to:{$new_to_id}";
}
示例12: list_members
private function list_members($request)
{
$service = $request['srv'];
$members = array();
$type = ObjectTypes::instance()->findByName($service);
$typeId = $type->getId();
$ids = array();
$dimensionController = new DimensionController();
foreach ($dimensionController->initial_list_dimension_members(Dimensions::findByCode('customer_project')->getId(), $typeId) as $member) {
$ids[] = $member['object_id'];
}
if (count($ids)) {
$args['conditions'] = " `object_id` IN (" . implode(",", $ids) . ") AND object_type_id = {$typeId}";
foreach (Members::instance()->findAll($args) as $member) {
/* @var $member Member */
$memberInfo = array('id' => $member->getId(), 'name' => $member->getName(), 'type' => $service, 'path' => $member->getPath());
$members[] = $memberInfo;
}
}
return $this->response('json', $members);
}
示例13: canContainObject
function canContainObject($object_type_id)
{
return Members::instance()->canContainObject($object_type_id, $this->getObjectTypeId(), $this->getDimensionId());
}
示例14: gen_id
<?php
$genid = gen_id();
$typeId = ObjectTypes::instance()->findByName("workspace")->getId();
//Check if There is a workspace in the active context
/* @var $member Member */
foreach (active_context_members(false) as $memberId) {
$member = Members::instance()->findById($memberId);
if ($member->getObjectTypeId() == $typeId) {
$id = $member->getObjectId();
if ($workspace = Workspaces::instance()->findById($id) && trim($member->getDescription()) != "") {
$description = $member->getDescription();
include_once 'template.php';
break;
}
}
}
示例15: list_all
/**
* Lists all contacts and clients
*
*/
function list_all()
{
ajx_current("empty");
// Get all variables from request
$start = array_var($_GET, 'start', 0);
$limit = array_var($_GET, 'limit', config_option('files_per_page'));
$page = 1;
if ($start > 0) {
$page = $start / $limit + 1;
}
$order = array_var($_GET, 'sort');
$order_dir = array_var($_GET, 'dir');
$action = array_var($_GET, 'action');
$attributes = array("ids" => explode(',', array_var($_GET, 'ids')), "types" => explode(',', array_var($_GET, 'types')), "accountId" => array_var($_GET, 'account_id'), "viewType" => array_var($_GET, 'view_type'));
//Resolve actions to perform
$actionMessage = array();
if (isset($action)) {
$actionMessage = $this->resolveAction($action, $attributes);
if ($actionMessage["errorCode"] == 0) {
flash_success($actionMessage["errorMessage"]);
} else {
flash_error($actionMessage["errorMessage"]);
}
}
$extra_conditions = "";
if ($attributes['viewType'] == 'contacts') {
$extra_conditions = 'AND `is_company` = 0';
} else {
if ($attributes['viewType'] == 'companies') {
$extra_conditions = 'AND `is_company` = 1';
}
}
$extra_conditions .= " AND disabled = 0 ";
switch ($order) {
case 'updatedOn':
$order = '`updated_on`';
break;
case 'createdOn':
$order = '`created_on`';
break;
case 'name':
$order = ' concat(surname, first_name) ';
break;
default:
$order = '`name`';
break;
}
if (!$order_dir) {
switch ($order) {
case 'name':
$order_dir = 'ASC';
break;
default:
$order_dir = 'DESC';
}
}
$context = active_context();
if (context_type() == 'mixed') {
// There are members selected
//$content_objects = Contacts::getContentObjects($context, ObjectTypes::findById(Contacts::instance()->getObjectTypeId()), $order, $order_dir, $extra_conditions, null, false,false, $start, $limit);
$content_objects = Contacts::instance()->listing(array("order" => $order, "order_dir" => $order_dir, "extra_conditions" => $extra_conditions, "start" => $start, "limit" => $limit));
} else {
// Estoy parado en 'All'. Filtro solo por permisos TODO: Fix this !
$conditions = "archived_on = '0000-00-00 00:00:00' AND trashed_on = '0000-00-00 00:00:00' {$extra_conditions}";
$content_objects = new stdClass();
$content_objects->objects = Contacts::instance()->findAll(array("conditions" => $conditions, "order" => "{$order} {$order_dir}", "offset" => $start, "limit" => $limit));
$content_objects->total = Contacts::instance()->count(array("conditions" => $conditions));
foreach ($content_objects->objects as $k => $contact) {
/* @var $contact Contact */
if (Plugins::instance()->isActivePlugin("core_dimensions")) {
$m = array_var(Members::instance()->findByObjectId($contact->getId(), Dimensions::findByCode("feng_persons")->getId()), 0);
if ($m instanceof Member) {
$mid = $m->getId();
if (!ContactMemberPermissions::instance()->contactCanReadMember(logged_user()->getPermissionGroupId(), $mid, logged_user())) {
unset($content_objects->objects[$k]);
$content_objects->total--;
}
}
}
}
$content_objects->objects = array_values($content_objects->objects);
}
// Prepare response object
$object = $this->newPrepareObject($content_objects->objects, $content_objects->total, $start, $attributes);
ajx_extra_data($object);
tpl_assign("listing", $object);
}