public function updateGroup() { $db = new PHPWS_DB('users_groups'); $db->addWhere('user_id', $this->id); $db->addColumn('id'); $result = $db->select('one'); if (PHPWS_Error::logIfError($result)) { PHPWS_Error::log($result); return PHPWS_Error::get(USER_ERROR, 'users', 'updateGroup'); } if (empty($result)) { $group = new PHPWS_Group(); $group->setUserId($this->id); } else { $group = new PHPWS_Group($result); } $group->setName($this->getUsername()); $group->setActive($this->isActive()); $result = $group->save(); if (PHPWS_Error::logIfError($result)) { $this->kill(); return PHPWS_Error::get(USER_ERROR, 'users', 'updateGroup'); } else { return true; } }
public static function postGroup(PHPWS_Group $group, $showLikeGroups = false) { $result = $group->setName($_POST['groupname'], true); if (PHPWS_Error::isError($result)) { return $result; } $group->setActive(true); return true; }