/** * Installs the gadget * * @access public * @return mixed True on successful installation, Jaws_Error otherwise */ function Install() { $variables = array(); $variables['logon_hours'] = str_pad('', 42, 'F'); $result = $this->installSchema('schema.xml', $variables); if (Jaws_Error::IsError($result)) { return $result; } $new_dir = JAWS_DATA . 'avatar'; if (!Jaws_Utils::mkdir($new_dir)) { return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', $new_dir)); } // Create the group 'users' $userModel = new Jaws_User(); $result = $userModel->AddGroup(array('name' => 'users', 'title' => 'Users', 'description' => '', 'enabled' => true, 'removable' => false)); if (Jaws_Error::IsError($result) && MDB2_ERROR_CONSTRAINT != $result->getCode()) { return $result; } return true; }
/** * Add an new group * * @access public * @return void */ function AddGroup() { $this->gadget->CheckPermission('ManageUserGroups'); $post = jaws()->request->fetch(array('gid', 'name', 'title', 'description'), 'post'); $user = $GLOBALS['app']->Session->GetAttribute('user'); $jUser = new Jaws_User(); // Update group if (!empty($post['gid'])) { $res = $jUser->UpdateGroup($post['gid'], $post, $user); // Add new group } else { unset($post['gid']); $res = $jUser->AddGroup($post, $user); } if (Jaws_Error::isError($res)) { $GLOBALS['app']->Session->PushResponse($res->getMessage(), 'Users.Groups', RESPONSE_ERROR); } elseif ($res == true) { $GLOBALS['app']->Session->PushResponse(_t('USERS_GROUPS_CREATED', $post['title']), 'Users.Groups', RESPONSE_NOTICE); } Jaws_Header::Location($this->gadget->urlMap('Groups')); }