本文整理汇总了PHP中UserGroup::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP UserGroup::getId方法的具体用法?PHP UserGroup::getId怎么用?PHP UserGroup::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserGroup
的用法示例。
在下文中一共展示了UserGroup::getId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processDigitalAssetManagementExtension
private function processDigitalAssetManagementExtension($objUser)
{
global $_ARRAYLANG, $_CONFIG;
if (empty($_POST['access_user_add_dma_category'])) {
return true;
}
// TODO: Never used
// $objFWUser = \FWUser::getFWUserObject();
$objDownloadLib = new \Cx\Modules\Downloads\Controller\DownloadsLibrary();
$arrDownloadSettings = $objDownloadLib->getSettings();
$objUser->setGroups(array_merge($objUser->getAssociatedGroupIds(), array_map('trim', explode(',', $arrDownloadSettings['associate_user_to_groups']))));
$objUser->store();
$firstname = $objUser->getProfileAttribute('firstname');
$lastname = $objUser->getProfileAttribute('lastname');
$userName = !empty($firstname) || !empty($lastname) ? trim($firstname . ' ' . $lastname) : $objUser->getUsername();
$objGroup = new \UserGroup();
$objGroup->setName(sprintf($_ARRAYLANG['TXT_ACCESS_CUSTOMER_TITLE'], $userName));
$objGroup->setDescription(sprintf($_ARRAYLANG['TXT_ACCESS_USER_ACCOUNT_GROUP_DESC'], $userName));
$objGroup->setActiveStatus(true);
$objGroup->setType('frontend');
$objGroup->setUsers(array($objUser->getId()));
$objGroup->setDynamicPermissionIds(array());
$objGroup->setStaticPermissionIds(array());
if (!$objGroup->store()) {
self::$arrStatusMsg['error'] = array_merge(self::$arrStatusMsg['error'], $objGroup->getErrorMsg());
return false;
}
$arrLanguageIds = array_keys(\FWLanguage::getLanguageArray());
$arrNames = array();
$arrDescription = array();
foreach ($arrLanguageIds as $langId) {
$arrNames[$langId] = sprintf($_ARRAYLANG['TXT_ACCESS_CUSTOMER_TITLE'], $userName);
$arrDescription[$langId] = '';
}
$objCategory = new \Cx\Modules\Downloads\Controller\Category();
$objCategory->setActiveStatus(true);
$objCategory->setVisibility(false);
$objCategory->setNames($arrNames);
$objCategory->setDescriptions($arrDescription);
$objCategory->setOwner($objUser->getId());
$objCategory->setDeletableByOwner(false);
$objCategory->setModifyAccessByOwner(false);
$objCategory->setPermissions(array('read' => array('protected' => true, 'groups' => array($objGroup->getId())), 'add_subcategories' => array('protected' => true, 'groups' => array($objGroup->getId())), 'manage_subcategories' => array('protected' => true, 'groups' => array($objGroup->getId())), 'add_files' => array('protected' => true, 'groups' => array($objGroup->getId())), 'manage_files' => array('protected' => true, 'groups' => array($objGroup->getId()))));
if (!$objCategory->store()) {
self::$arrStatusMsg['error'] = array_merge(self::$arrStatusMsg['error'], $objCategory->getErrorMsg());
return false;
}
$damCategoryUri = '?cmd=Downloads&act=categories&parent_id=' . $objCategory->getId();
$damCategoryAnchor = '<a href="' . $damCategoryUri . '">' . htmlentities($objCategory->getName(LANG_ID), ENT_QUOTES, CONTREXX_CHARSET) . '</a>';
self::$arrStatusMsg['ok'][] = sprintf($_ARRAYLANG['TXT_ACCESS_NEW_DAM_CATEGORY_CREATED_TXT'], contrexx_raw2xhtml($objUser->getUsername()), $damCategoryAnchor);
return true;
}
示例2: errorHandler
/**
* Handles database errors
*
* Also migrates old Shop Customers to the User accounts and adds
* all new settings
* @return boolean false Always!
* @throws Cx\Lib\Update_DatabaseException
*/
static function errorHandler()
{
// Customer
$table_name_old = DBPREFIX . "module_shop_customers";
// If the old Customer table is missing, the migration has completed
// successfully already
if (!\Cx\Lib\UpdateUtil::table_exist($table_name_old)) {
return false;
}
// Ensure that the ShopSettings (including \Cx\Core\Setting) and Order tables
// are ready first!
//DBG::log("Customer::errorHandler(): Adding settings");
ShopSettings::errorHandler();
// \Cx\Core\Country\Controller\Country::errorHandler(); // Called by Order::errorHandler();
Order::errorHandler();
Discount::errorHandler();
\Cx\Core\Setting\Controller\Setting::init('Shop', 'config');
$objUser = \FWUser::getFWUserObject()->objUser;
// Create new User_Profile_Attributes
$index_notes = \Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_notes', 'Shop');
if (!$index_notes) {
//DBG::log("Customer::errorHandler(): Adding notes attribute...");
// $objProfileAttribute = new \User_Profile_Attribute();
$objProfileAttribute = $objUser->objAttribute->getById(0);
//DBG::log("Customer::errorHandler(): NEW notes attribute: ".var_export($objProfileAttribute, true));
$objProfileAttribute->setNames(array(1 => 'Notizen', 2 => 'Notes', 3 => 'Notes', 4 => 'Notes', 5 => 'Notes', 6 => 'Notes'));
$objProfileAttribute->setType('text');
$objProfileAttribute->setMultiline(true);
$objProfileAttribute->setParent(0);
$objProfileAttribute->setProtection(array(1));
//DBG::log("Customer::errorHandler(): Made notes attribute: ".var_export($objProfileAttribute, true));
if (!$objProfileAttribute->store()) {
throw new \Cx\Lib\Update_DatabaseException("Failed to create User_Profile_Attribute 'notes'");
}
//Re initialize shop setting
\Cx\Core\Setting\Controller\Setting::init('Shop', 'config');
//DBG::log("Customer::errorHandler(): Stored notes attribute, ID ".$objProfileAttribute->getId());
if (!(\Cx\Core\Setting\Controller\Setting::set('user_profile_attribute_notes', $objProfileAttribute->getId()) && \Cx\Core\Setting\Controller\Setting::update('user_profile_attribute_notes'))) {
throw new \Cx\Lib\Update_DatabaseException("Failed to update User_Profile_Attribute 'notes' setting");
}
//DBG::log("Customer::errorHandler(): Stored notes attribute ID setting");
}
$index_group = \Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_customer_group_id', 'Shop');
if (!$index_group) {
// $objProfileAttribute = new \User_Profile_Attribute();
$objProfileAttribute = $objUser->objAttribute->getById(0);
$objProfileAttribute->setNames(array(1 => 'Kundenrabattgruppe', 2 => 'Discount group', 3 => 'Kundenrabattgruppe', 4 => 'Kundenrabattgruppe', 5 => 'Kundenrabattgruppe', 6 => 'Kundenrabattgruppe'));
$objProfileAttribute->setType('text');
$objProfileAttribute->setParent(0);
$objProfileAttribute->setProtection(array(1));
if (!$objProfileAttribute->store()) {
throw new \Cx\Lib\Update_DatabaseException("Failed to create User_Profile_Attribute 'notes'");
}
//Re initialize shop setting
\Cx\Core\Setting\Controller\Setting::init('Shop', 'config');
if (!(\Cx\Core\Setting\Controller\Setting::set('user_profile_attribute_customer_group_id', $objProfileAttribute->getId()) && \Cx\Core\Setting\Controller\Setting::update('user_profile_attribute_customer_group_id'))) {
throw new \Cx\Lib\Update_DatabaseException("Failed to update User_Profile_Attribute 'customer_group_id' setting");
}
}
// For the migration, a temporary flag is needed in the orders table
// in order to prevent mixing up old and new customer_id values.
$table_order_name = DBPREFIX . "module_shop_orders";
if (!\Cx\Lib\UpdateUtil::column_exist($table_order_name, 'migrated')) {
$query = "\n ALTER TABLE `{$table_order_name}`\n ADD `migrated` TINYINT(1) unsigned NOT NULL default 0";
\Cx\Lib\UpdateUtil::sql($query);
}
// Create missing UserGroups for customers and resellers
$objGroup = null;
$group_id_customer = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_customer', 'Shop');
if ($group_id_customer) {
$objGroup = \FWUser::getFWUserObject()->objGroup->getGroup($group_id_customer);
}
if (!$objGroup || $objGroup->EOF) {
$objGroup = \FWUser::getFWUserObject()->objGroup->getGroups(array('group_name' => 'Shop Endkunden'));
}
if (!$objGroup || $objGroup->EOF) {
$objGroup = new \UserGroup();
$objGroup->setActiveStatus(true);
$objGroup->setDescription('Online Shop Endkunden');
$objGroup->setName('Shop Endkunden');
$objGroup->setType('frontend');
}
//DBG::log("Group: ".var_export($objGroup, true));
if (!$objGroup) {
throw new \Cx\Lib\Update_DatabaseException("Failed to create UserGroup for customers");
}
//DBG::log("Customer::errorHandler(): Made customer usergroup: ".var_export($objGroup, true));
if (!$objGroup->store() || !$objGroup->getId()) {
throw new \Cx\Lib\Update_DatabaseException("Failed to store UserGroup for customers");
}
//DBG::log("Customer::errorHandler(): Stored customer usergroup, ID ".$objGroup->getId());
\Cx\Core\Setting\Controller\Setting::set('usergroup_id_customer', $objGroup->getId());
//.........这里部分代码省略.........
示例3: saveUserGroupSubmit
//TODO: ability to remove a empty usergroup
namespace cd;
$session->requireAdmin();
$grp = new UserGroup($this->owner);
$header->setTitle('Admin: Manage user group: ' . $grp->getName());
echo '<h1>Manage user group: ' . $grp->getName() . '</h1>';
echo 'Created at ' . sql_datetime($grp->getTimeCreated()) . ' by ' . $grp->getCreatorName() . '<br/><br/>';
function saveUserGroupSubmit($p)
{
$grp = new UserGroup($p['g_id']);
$grp->setName($p['name']);
$grp->setInfo($p['info']);
$grp->setLevel($p['level']);
$grp->save();
return true;
}
$form = new XhtmlForm('adm_usergroup');
$form->addHidden('g_id', $grp->getId());
//XXXX hax
$form->addInput('name', 'Group name', $grp->getName());
$form->addTextarea('info', 'Info', $grp->getInfo());
$form->addDropdown('level', 'Level', getUserLevels(), $grp->getLevel());
$form->addSubmit('Save');
$form->setHandler('saveUserGroupSubmit');
echo $form->render();
echo '<br/><br/>';
echo '<h1>Group members</h1>';
foreach ($grp->getMembers() as $user) {
echo ahref('a/user/' . $user->id, $user->name) . '<br/>';
}