当前位置: 首页>>代码示例>>PHP>>正文


PHP Members::findOne方法代码示例

本文整理汇总了PHP中Members::findOne方法的典型用法代码示例。如果您正苦于以下问题:PHP Members::findOne方法的具体用法?PHP Members::findOne怎么用?PHP Members::findOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Members的用法示例。


在下文中一共展示了Members::findOne方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: workspaces_page_rendered

function workspaces_page_rendered()
{
    if (!Plugins::instance()->isActivePlugin('crpm')) {
        $did = Dimensions::instance()->findByCode('workspaces')->getId();
        $one_member = Members::findOne(array('conditions' => 'dimension_id = ' . $did));
        if (!$one_member instanceof Member) {
            echo "<script>";
            echo "og.menuPanelCollapsed = true;";
            echo "</script>";
        }
    }
}
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:12,代码来源:workspaces_hooks.php

示例2: core_dim_add_new_contact_to_person_dimension

function core_dim_add_new_contact_to_person_dimension($object)
{
    /* @var $object Contact */
    $person_ot = ObjectTypes::findOne(array("conditions" => "`name` = 'person'"));
    $company_ot = ObjectTypes::findOne(array("conditions" => "`name` = 'company'"));
    $person_dim = Dimensions::findOne(array("conditions" => "`code` = 'feng_persons'"));
    if ($person_ot instanceof ObjectType && $person_dim instanceof Dimension) {
        $oid = $object->isCompany() ? $company_ot->getId() : $person_ot->getId();
        $tmp_mem = Members::findOne(array("conditions" => "`dimension_id` = " . $person_dim->getId() . " AND `object_type_id` = {$oid} AND `object_id` = " . $object->getId()));
        $reload_dimension = true;
        if ($tmp_mem instanceof Member) {
            $member = $tmp_mem;
            $reload_dimension = false;
        } else {
            $member = new Member();
            $member->setName($object->getObjectName());
            $member->setDimensionId($person_dim->getId());
            $parent_member_id = 0;
            $depth = 1;
            if ($object->isCompany()) {
                $member->setObjectTypeId($company_ot->getId());
            } else {
                $member->setObjectTypeId($person_ot->getId());
                if ($object->getCompanyId() > 0) {
                    $pmember = Members::findOne(array('conditions' => '`object_id` = ' . $object->getCompanyId() . ' AND `object_type_id` = ' . $company_ot->getId() . ' AND `dimension_id` = ' . $person_dim->getId()));
                    if ($pmember instanceof Member) {
                        $parent_member_id = $pmember->getId();
                        $depth = $pmember->getDepth() + 1;
                    }
                }
            }
            $member->setParentMemberId($parent_member_id);
            $member->setDepth($depth);
            $member->setObjectId($object->getId());
            $member->save();
        }
        $sql = "INSERT INTO `" . TABLE_PREFIX . "contact_dimension_permissions` (`permission_group_id`, `dimension_id`, `permission_type`)\n\t\t\t\t SELECT `c`.`permission_group_id`, " . $person_dim->getId() . ", 'check'\n\t\t\t\t FROM `" . TABLE_PREFIX . "contacts` `c` \n\t\t\t\t WHERE `c`.`is_company`=0 AND `c`.`user_type`!=0 AND `c`.`disabled`=0 AND `c`.`object_id`=" . $object->getId() . "\n\t\t\t\t ON DUPLICATE KEY UPDATE `dimension_id`=`dimension_id`;";
        DB::execute($sql);
        $sql = "INSERT INTO `" . TABLE_PREFIX . "contact_member_permissions` (`permission_group_id`, `member_id`, `object_type_id`, `can_write`, `can_delete`)\n\t\t\t\t SELECT `c`.`permission_group_id`, " . $member->getId() . ", `ot`.`id`, (`c`.`object_id` = " . $object->getId() . ") as `can_write`, (`c`.`object_id` = " . $object->getId() . ") as `can_delete`\n\t\t\t\t FROM `" . TABLE_PREFIX . "contacts` `c` JOIN `" . TABLE_PREFIX . "object_types` `ot` \n\t\t\t\t WHERE `c`.`is_company`=0 AND `c`.`object_id`=" . $object->getId() . "\n\t\t\t\t \tAND `c`.`user_type`!=0 AND `c`.`disabled`=0\n\t\t\t\t\tAND `ot`.`type` IN ('content_object', 'comment')\n\t\t\t\t ON DUPLICATE KEY UPDATE `member_id`=`member_id`;";
        DB::execute($sql);
        DB::execute("DELETE FROM `" . TABLE_PREFIX . "contact_member_permissions` WHERE `permission_group_id` = 0;");
        // NEW! Add contact to its own member to be searchable
        if (logged_user() instanceof Contact) {
            $ctrl = new ObjectController();
            $ctrl->add_to_members($object, array($member->getId()));
        } else {
            $object->addToMembers(array($member));
            $object->addToSharingTable();
        }
        // add permission to creator
        if ($object->getCreatedBy() instanceof Contact) {
            DB::execute("INSERT INTO `" . TABLE_PREFIX . "contact_member_permissions` (`permission_group_id`, `member_id`, `object_type_id`, `can_write`, `can_delete`)\n\t\t\t\t SELECT " . $object->getCreatedBy()->getPermissionGroupId() . ", " . $member->getId() . ", `ot`.`id`, 1, 1\n\t\t\t\t FROM `" . TABLE_PREFIX . "object_types` `ot` \n\t\t\t\t WHERE `ot`.`type` IN ('content_object', 'comment')\n\t\t\t\t ON DUPLICATE KEY UPDATE `member_id`=`member_id`;");
        }
        if ($reload_dimension) {
            evt_add("reload dimension tree", $member->getDimensionId());
        }
    }
}
开发者ID:rorteg,项目名称:fengoffice,代码行数:58,代码来源:core_dimensions_hooks.php

示例3: haveChilds

 /**
  * Returnrs true if members have child nodes, false otherwise
  */
 function haveChilds($check_permission = false)
 {
     $permission_conditions = "";
     if ($check_permission) {
         $logged_user_pgs = logged_user()->getPermissionGroupIds();
         $permission_conditions = " AND EXISTS (SELECT cmp.permission_group_id FROM " . TABLE_PREFIX . "contact_member_permissions cmp\r\n\t\t\tWHERE cmp.permission_group_id IN (" . implode(",", $logged_user_pgs) . ") AND cmp.member_id=" . TABLE_PREFIX . "members.id)";
     }
     $member = Members::findOne(array("conditions" => "`parent_member_id` = " . $this->getId() . ' ' . $permission_conditions));
     if ($member instanceof Member) {
         return true;
     }
     return false;
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:16,代码来源:Member.class.php


注:本文中的Members::findOne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。