本文整理汇总了PHP中Groups::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Groups::save方法的具体用法?PHP Groups::save怎么用?PHP Groups::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Groups
的用法示例。
在下文中一共展示了Groups::save方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUpGroups
function setUpGroups($lang)
{
if (!file_exists(GROUP_FILE_LOCATION)) {
$aGroupDB = new Groups();
$aGroupDB->setFileName(GROUP_FILE_LOCATION);
$names = ImageTypes::getMenuNames();
foreach ($names as $name) {
$aGroup = new Group();
$aGroup->setType($lang[$name]);
$aGroup->setGroupImage($name);
$aGroup->rebuildElementLine();
$aGroupDB->addElement($aGroup);
}
$aGroupDB->save();
} else {
// validate we have all the default groups
$addedElement = false;
$aGroupDB = new Groups(GROUP_FILE_LOCATION);
$names = ImageTypes::getMenuNames();
foreach ($names as $name) {
if ($aGroupDB->getAGroup($name) == "") {
$aGroup = new Group();
$aGroup->setType($lang[$name]);
$aGroup->setGroupImage($name);
$aGroup->rebuildElementLine();
$aGroupDB->addElement($aGroup);
$addedElement = true;
}
}
if ($addedElement) {
$aGroupDB->save();
}
}
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Eloquent::unguard();
$this->command->info("Creating Super Admins");
$group = new Groups();
$group->name = "admin";
$group->save();
$group = new Groups();
$group->name = "department-admin";
$group->save();
$group = new Groups();
$group->name = "operator";
$group->save();
$group = new Groups();
$group->name = "customer";
$group->save();
$admin = new User();
$admin->name = "Admin";
$admin->email = "admin@mail.com";
$admin->password = Hash::make("admin");
$admin->avatar = "/assets/images/default-avatar.jpg";
$admin->show_avatar = 1;
$admin->birthday = "01-15-1990";
$admin->bio = "This is dummy admin bio";
$admin->gender = "Male";
$admin->mobile_no = "0000000000";
$admin->country = "India";
$admin->activated = 1;
$admin->activated_at = \Carbon\Carbon::now();
$admin->save();
DB::table('users_groups')->insert(['user_id' => 1, 'group_id' => 1]);
}
示例3: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Groups();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Groups'])) {
$model->attributes = $_POST['Groups'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->groupID));
}
}
$this->render('create', array('model' => $model));
}
示例4: createAction
public function createAction()
{
$this->view->Title = "Tạo mới nhóm thành viên";
$this->view->headTitle($this->view->Title);
if ($this->getRequest()->isPost()) {
$Group = new Groups();
$Role = $this->getRequest()->getParam('Role');
$Group->merge($_POST);
$Group->role = Zend_Json::encode($Role);
$Group->save();
$this->Member->log('Tạo nhóm thành viên: ' . $Group->name . ' (' . $Group->id . ')', 'Groups');
My_Plugin_Libs::setSplash('Nhóm thành viên:<b>' . $Group->name . '</b> đã được tạo.');
$this->_redirect($this->_helper->url('index', 'Group'));
}
$Resources = new Zend_Config_Xml(APPLICATION_PATH . '/configs/resources.xml', 'admin');
$this->view->Resources = $Resources;
}
示例5: creategroupAction
public function creategroupAction()
{
if ($this->request->isPost() == true) {
try {
$this->response->setContentType('application/json');
$groupname = $this->request->getPost('groupname', 'striptags');
$user_id = $this->request->getPost('user_id');
$group = new Groups();
$group->assign(array('user_id' => $user_id, 'name' => $groupname, 'created_at' => (new \DateTime())->format('Y-m-d H:i:s'), 'updated_at' => (new \DateTime())->format('Y-m-d H:i:s')));
if ($group->save()) {
$data = array('status' => 'success', 'msg' => 'group created', 'code' => 2, 'group_name' => $group->name);
}
$this->response->setContent(json_encode($data));
$this->response->send();
} catch (Exception $ex) {
$this->response->setContent(json_encode(array('error' => $ex->getMessage())));
$this->response->send();
}
}
}
示例6: actionCreateGroup
/**
* Creates new group
*/
public function actionCreateGroup()
{
$model = new NewGroupForm();
$processOutput = true;
// collect user input data
if (isset($_POST['NewGroupForm'])) {
$model->attributes = $_POST['NewGroupForm'];
// validate user input and if ok return json data and end application.
if ($model->validate()) {
$groups = new Groups();
$groups->name = $model->name;
$groups->owner = Yii::app()->user->id;
$groups->description = $model->description;
try {
if ($groups->save()) {
echo CJSON::encode(array("result" => "1"));
} else {
echo CJSON::encode(array("result" => "Unknown error"));
}
Yii::app()->end();
} catch (Exception $e) {
//Refactor: A macro can be defined in a suitable place
if ($e->getCode() == 23000) {
echo CJSON::encode(array("result" => "Duplicate Entry"));
}
Yii::app()->end();
// echo 'Caught exception: ', $e->getMessage(), "\n";
// echo 'Code: ', $e->getCode(), "\n";
}
}
if (Yii::app()->request->isAjaxRequest) {
$processOutput = false;
}
}
Yii::app()->clientScript->scriptMap['jquery.js'] = false;
Yii::app()->clientScript->scriptMap['jquery-ui.min.js'] = false;
$this->renderPartial('createGroup', array('model' => $model), false, $processOutput);
}
示例7: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Groups();
$users = User::getNames();
unset($users['admin']);
unset($users['']);
if (isset($_POST['Groups'])) {
$model->attributes = $_POST['Groups'];
if (isset($_POST['users'])) {
$users = $_POST['users'];
} else {
$users = array();
}
if ($model->save()) {
foreach ($users as $user) {
$link = new GroupToUser();
$link->groupId = $model->id;
$userRecord = User::model()->findByAttributes(array('username' => $user));
if (isset($userRecord)) {
$link->userId = $userRecord->id;
$link->username = $userRecord->username;
$link->save();
}
}
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model, 'users' => $users));
}
示例8: add_group
/**
* RPC Routine to add an empty group with minimum details.
* Used as a placeholder for importing questions.
* Returns the groupid of the created group.
*
* @access public
* @param string $sSessionKey Auth credentials
* @param int $iSurveyID Dd of the Survey to add the group
* @param string $sGroupTitle Name of the group
* @param string $sGroupDescription Optional description of the group
* @return array|int The id of the new group - Or status
*/
public function add_group($sSessionKey, $iSurveyID, $sGroupTitle, $sGroupDescription = '')
{
if ($this->_checkSessionKey($sSessionKey)) {
if (hasSurveyPermission($iSurveyID, 'survey', 'update')) {
$oSurvey = Survey::model()->findByPk($iSurveyID);
if (!isset($oSurvey)) {
return array('status' => 'Error: Invalid survey ID');
}
if ($oSurvey['active'] == 'Y') {
return array('status' => 'Error:Survey is active and not editable');
}
$oGroup = new Groups();
$oGroup->sid = $iSurveyID;
$oGroup->group_name = $sGroupTitle;
$oGroup->description = $sGroupDescription;
$oGroup->group_order = getMaxGroupOrder($iSurveyID);
$oGroup->language = Survey::model()->findByPk($iSurveyID)->language;
if ($oGroup->save()) {
return (int) $oGroup->gid;
} else {
return array('status' => 'Creation Failed');
}
} else {
return array('status' => 'No permission');
}
} else {
return array('status' => 'Invalid Session Key');
}
}
示例9: edit
/**
* questiongroup::edit()
* Load editing of a question group screen.
*
* @access public
* @param int $surveyid
* @param int $gid
* @return void
*/
public function edit($surveyid, $gid)
{
$clang = $this->getController()->lang;
$surveyid = sanitize_int($surveyid);
$gid = sanitize_int($gid);
$aViewUrls = $aData = array();
if (hasSurveyPermission($surveyid, 'surveycontent', 'read')) {
Yii::app()->session['FileManagerContext'] = "edit:group:{$surveyid}";
Yii::app()->loadHelper('admin/htmleditor');
Yii::app()->loadHelper('surveytranslator');
$aAdditionalLanguages = Survey::model()->findByPk($surveyid)->additionalLanguages;
$aBaseLanguage = Survey::model()->findByPk($surveyid)->language;
$aLanguages = array_merge(array($aBaseLanguage), $aAdditionalLanguages);
$grplangs = array_flip($aLanguages);
// Check out the intgrity of the language versions of this group
$egresult = Groups::model()->findAllByAttributes(array('sid' => $surveyid, 'gid' => $gid));
foreach ($egresult as $esrow) {
$esrow = $esrow->attributes;
// Language Exists, BUT ITS NOT ON THE SURVEY ANYMORE
if (!in_array($esrow['language'], $aLanguages)) {
Groups::model()->deleteAllByAttributes(array('sid' => $surveyid, 'gid' => $gid, 'language' => $esrow['language']));
} else {
$grplangs[$esrow['language']] = 'exists';
}
if ($esrow['language'] == $aBaseLanguage) {
$basesettings = $esrow;
}
}
// Create groups in missing languages
while (list($key, $value) = each($grplangs)) {
if ($value != 'exists') {
$basesettings['language'] = $key;
$group = new Groups();
foreach ($basesettings as $k => $v) {
$group->{$k} = $v;
}
switchMSSQLIdentityInsert('groups', true);
$group->save();
switchMSSQLIdentityInsert('groups', false);
}
}
$first = true;
foreach ($aLanguages as $sLanguage) {
$oResult = Groups::model()->findByAttributes(array('sid' => $surveyid, 'gid' => $gid, 'language' => $sLanguage));
$aData['aGroupData'][$sLanguage] = $oResult->attributes;
$aTabTitles[$sLanguage] = getLanguageNameFromCode($sLanguage, false);
if ($first) {
$aTabTitles[$sLanguage] .= ' (' . $clang->gT("Base language") . ')';
$first = false;
}
}
$aData['action'] = $aData['display']['menu_bars']['gid_action'] = 'editgroup';
$aData['surveyid'] = $surveyid;
$aData['gid'] = $gid;
$aData['tabtitles'] = $aTabTitles;
$aData['aBaseLanguage'] = $aBaseLanguage;
$this->_renderWrappedTemplate('survey/QuestionGroups', 'editGroup_view', $aData);
}
}
示例10: cleanDB
public function cleanDB()
{
//Not truncating countries , migrations , permissions , settings
DB::table('blocking')->truncate();
DB::table('canned_messages')->truncate();
DB::table('closed_conversations')->truncate();
DB::table('companies')->truncate();
DB::table('company_customers')->truncate();
DB::table('company_department_admins')->truncate();
DB::table('departments')->truncate();
DB::table('department_admins')->truncate();
DB::table('groups')->truncate();
DB::table('message_threads')->truncate();
DB::table('online_users')->truncate();
DB::table('operators_department')->truncate();
DB::table('paired_templates')->truncate();
DB::table('thread_geo_info')->truncate();
DB::table('thread_messages')->truncate();
DB::table('throttle')->truncate();
DB::table('tickets')->truncate();
DB::table('tickets_attachment')->truncate();
DB::table('translations')->truncate();
DB::table('users')->truncate();
DB::table('users_groups')->truncate();
//DB::table('permissions')->truncate();
/*
DB::statement("INSERT INTO `permissions` (`id`, `key`, `text`, `created_at`, `updated_at`) VALUES
(1, 'tickets.create', 'Operator/Department admin/Customer can create tickets', '2014-12-28 03:30:28', '2014-12-28 03:30:28'),
(2, 'tickets.edit', 'Operator/Department admin/Customer can reply to ticket', '2014-12-28 03:30:43', '2014-12-28 03:30:43'),
(3, 'tickets.all', 'Operator/Department admin/Customer can see all tickets , if you assigned anyone tickets.create , tickets.edit , tickets.delete then assigning this permission is mandatory so they can view ticket', '2014-12-28 03:31:02', '2014-12-28 03:31:02'),
(4, 'tickets.delete', 'Operator/Department admin/Customer can delete ticket', '2014-12-28 03:31:17', '2014-12-28 03:31:17'),
(5, 'customers.create', 'Operator/Department admin/Customer can create a new customer', '2014-12-28 03:31:58', '2014-12-28 03:31:58'),
(6, 'customers.edit', 'Operator/Department admin/Customer can edit customer', '2014-12-28 03:32:16', '2014-12-28 03:32:16'),
(7, 'customers.all', 'Operator/Department admin/Customer can view all customers , if you assigned anyone customers.create , customers.edit , customers.delete then assigning this permission is mandatory so they can view customer', '2014-12-28 03:32:30', '2014-12-28 03:32:30'),
(8, 'customers.delete', 'Operator/Department admin/Customer can delete customer', '2014-12-28 03:32:46', '2014-12-28 03:32:46'),
(9, 'operators.create', 'Operator/Department admin/Customer can create operator', '2014-12-28 03:33:02', '2014-12-28 03:33:02'),
(10, 'operators.edit', 'Operator/Department admin/Customer can edit operator', '2014-12-28 03:33:18', '2014-12-28 03:33:18'),
(11, 'operators.activate', 'Operator/Department admin/Customer can activate operators', '2014-12-28 03:33:33', '2014-12-28 03:33:33'),
(12, 'operators.delete', 'Operator/Department admin/Customer can delete operator', '2014-12-28 03:33:51', '2014-12-28 03:33:51'),
(13, 'operators.all', 'Operator/Department admin/Customer can view all operators , if you assigned anyone operators.create , operators.edit , operators.delete then assigning this permission is mandatory so they can view operator', '2014-12-28 03:34:08', '2014-12-28 03:34:08'),
(14, 'departments.create', 'Operator/Department admin/Customer can create department', '2014-12-28 03:34:25', '2014-12-28 03:34:25'),
(15, 'departments.edit', 'Operator/Department admin/Customer can edit department', '2014-12-28 03:34:39', '2014-12-28 03:34:39'),
(16, 'departments.all', 'Operator/Department admin/Customer can view all departments , if you assigned anyone departments.create , departments.edit , departments.delete then assigning this permission is mandatory so they can view department', '2014-12-28 03:35:22', '2014-12-28 03:35:22'),
(17, 'departments.delete', 'Operator/Department admin/Customer can delete department', '2014-12-28 03:35:41', '2014-12-28 03:35:41'),
(18, 'companies.create', 'Operator/Department admin/Customer can create company', '2014-12-28 03:35:58', '2014-12-28 03:35:58'),
(19, 'companies.edit', 'Operator/Department admin/Customer can edit company', '2014-12-28 03:36:13', '2014-12-28 03:36:13'),
(20, 'companies.all', 'Operator/Department admin/Customer can view all companies , if you assigned anyone companies.create , companies.edit , companies.delete then assigning this permission is mandatory so they can view company', '2014-12-28 03:36:28', '2014-12-28 03:36:28'),
(21, 'companies.delete', 'Operator/Department admin/Customer can delete company', '2014-12-28 03:36:46', '2014-12-28 03:36:46'),
(22, 'canned_messages.create', 'Operator/Department admin/Customer can create canned messages', '2014-12-28 03:37:05', '2014-12-28 03:37:05'),
(23, 'canned_messages.edit', 'Operator/Department admin/Customer can edit canned messages', '2014-12-28 03:37:23', '2014-12-28 03:37:23'),
(24, 'canned_messages.all', 'Operator/Department admin/Customer can view all canned messages , if you assigned anyone canned_messages.create , canned_messages.edit , canned_messages.delete then assigning this permission is mandatory so they can view canned message', '2014-12-28 03:38:31', '2014-12-28 03:38:31'),
(25, 'canned_messages.delete', 'Operator/Department admin/Customer can delete canned messages', '2014-12-28 03:38:46', '2014-12-28 03:38:46'),
(26, 'conversations.accept', 'Operator/Department admin/Customer can accept new chats .', '2014-12-28 03:39:05', '2014-12-28 03:39:05'),
(27, 'conversations.close', 'Operator/Department admin/Customer can close conversations . conversations will be moved to closed conversations', '2014-12-28 03:39:24', '2014-12-28 03:39:24'),
(28, 'conversations.delete', 'Operator/Department admin/Customer can delete closed conversations . conversations will be permanently deleted', '2014-12-28 03:40:33', '2014-12-28 03:40:33'),
(29, 'conversations.closed', 'Operator/Department admin/Customer can view closed conversations .', '2014-12-28 03:40:49', '2014-12-28 03:40:49'),
(30, 'mailchimp.pair_email', 'Operator/Department admin/Customer can pair emails to templates .', '2014-12-28 03:41:03', '2014-12-28 03:41:03'),
(31, 'mailchimp.all', 'Operator/Department admin/Customer can view all mailchimp templates .', '2014-12-28 03:41:17', '2014-12-28 03:41:17'),
(32, 'mailchimp.delete', 'Operator/Department admin/Customer can delete paired templates .', '2014-12-28 03:41:31', '2014-12-28 03:41:31'),
(33, 'blocking.block', 'Operator/Department admin/Customer can block ip .', '2014-12-28 03:41:52', '2014-12-28 03:41:52'),
(34, 'blocking.all', 'Operator/Department admin/Customer can view all blocked ip''s , if you assigned anyone blocking.delete then assigning this permission is mandatory so they can view blocked ip', '2014-12-28 03:42:12', '2014-12-28 03:42:12'),
(35, 'blocking.delete', 'Operator/Department admin/Customer can remove blocked ip .', '2014-12-28 03:42:27', '2014-12-28 03:42:27'),
(36, 'settings.all', 'Operator/Department admin/Customer can change settings which includes smtp , mailchimp , mailgun configurations .', '2014-12-28 03:42:44', '2014-12-28 03:42:44'),
(37, 'departments_admins.create', 'Operator/Department admin/Customer can create department admin .', '2014-12-28 03:43:04', '2014-12-28 03:43:04'),
(38, 'departments_admins.edit', 'Operator/Department admin/Customer can edit department admin .', '2014-12-28 03:43:24', '2014-12-28 03:43:24'),
(39, 'departments_admins.remove', 'Operator/Department admin/Customer can remove department admin .', '2014-12-28 03:43:42', '2014-12-28 03:43:42'),
(40, 'departments_admins.activate', 'Operator/Department admin/Customer can activate department admin .', '2014-12-28 03:44:00', '2014-12-28 03:44:00'),
(41, 'departments_admins.all', 'Operator/Department admin/Customer can view all department admins , if you assigned anyone departments_admins.create , departments_admins.edit , departments_admins.delete then assigning this permission is mandatory so they can view department admin', '2014-12-28 03:44:15', '2014-12-28 03:44:15'),
(42, 'departments_admins.delete', 'Operator/Department admin/Customer can delete department admin .', '2014-12-28 03:44:34', '2014-12-28 03:44:34')"
);
*/
$group = new Groups();
$group->name = "admin";
$group->save();
$group = new Groups();
$group->name = "department-admin";
$group->save();
$group = new Groups();
$group->name = "operator";
$group->save();
$group = new Groups();
$group->name = "customer";
$group->save();
$admin = new User();
$admin->name = "Admin";
$admin->email = "admin@mail.com";
$admin->password = Hash::make("admin");
$admin->avatar = "/assets/images/default-avatar.jpg";
$admin->show_avatar = 1;
$admin->birthday = "01-01-1990";
$admin->bio = "This is bio";
$admin->gender = "Male";
$admin->mobile_no = "1111111111";
$admin->country = "India";
$admin->activated = 1;
$admin->activated_at = \Carbon\Carbon::now();
$admin->save();
DB::table('users_groups')->insert(['user_id' => 1, 'group_id' => 1]);
return 'Success';
}
示例11: executeValidate
public function executeValidate(sfWebRequest $request)
{
$id = $request->getParameter('id');
if ($id) {
$this->forward404Unless($reservation = Doctrine::getTable('Reservation')->find(array($id)), sprintf('Object reservation does not exist (%s).', $id));
}
$d = array();
$d['designation'] = $request->getParameter('designation');
$d['description'] = $request->getParameter('description');
$d['type'] = $request->getParameter('type');
if ($d['type'] == "") {
$d['type'] = "group";
}
$d['public_designation'] = '';
$d['public_description'] = '';
$d['public'] = $request->getParameter('public') ? 1 : 0;
if ($d['public']) {
$d['public_designation'] = $request->getParameter('public_designation');
$d['public_description'] = $request->getParameter('public_description');
}
switch ($d['type']) {
case 'group':
$d['type_id'] = $request->getParameter('type_group');
break;
case 'event':
$d['type_id'] = $request->getParameter('type_event');
break;
default:
$d['type_id'] = $request->getParameter('type_user');
break;
}
// create group if new reservation
if ($d['type_id'] == "" && $d['type'] == "group") {
$g = new Groups();
$g->setName($d['designation']);
$g->save();
$d['type_id'] = $g->getId();
}
if ($id) {
$this->update('Reservation', $d, $id);
} else {
//$this->insert('Reservation', $d);
$r = new Reservation();
$r->setDesignation($d['designation']);
$r->setDescription($d['description']);
$r->setType($d['type']);
$r->setTypeId($d['type_id']);
$r->setPublic($d['public']);
$r->setPublicDesignation($d['public_designation']);
$r->setPublicDescription($d['public_description']);
$r->save();
$request->setParameter('id', $r->getId());
}
$this->startdate = $request->getParameter('startdate');
$this->stopdate = $request->getParameter('stopdate');
if (!$request->getParameter('ajax')) {
$this->redirect('reservation/list');
} else {
if ($id) {
$this->executeAjaxDetailedReservation($request);
} else {
$this->executeAjaxAddPeriod($request);
}
}
}