+ /**
+ * getRoles - Get the roles of the group.
+ *
+ * @return array of Role id of this group.
+ */
+ function getRolesId () {
+
+ $rolesId = Array();
+
+ $roles_group_res = db_query_params ('SELECT role_id FROM role WHERE group_id=$1',
+ array ($this->getID()));
+ if (!$roles_group_res) {
+ $this->setError('Error: Roles from group id '. $this->getID() . ' ' .db_error());
+ return false;
+ } else {
+ for ($i=0; $i<db_numrows($roles_group_res); $i++) {
+ $rolesId[$i] = db_result($roles_group_res,$i,'role_id');
+ }
+ }
+
+ return $rolesId;
+ }
+
+ /**
+ * getUnixStatus - Status of activation of unix account.
+ *
+ * @return char (N)one, (A)ctive, (S)uspended or (D)eleted
+ */
+ function getUnixStatus() {
+ return $this->data_array['unix_status'];
+ }
+
+ /**
+ * setUnixStatus - Sets status of activation of unix account.
+ *
+ * @param string The unix status.
+ * N no_unix_account
+ * A active
+ * S suspended
+ * D deleted
+ *
+ * @return boolean success.
+ */
+ function setUnixStatus($status) {
+ global $SYS;
+ db_begin();
+ $res = db_query_params ('UPDATE groups SET unix_status=$1 WHERE group_id=$2',
+ array ($status,
+ $this->getID())) ;
+
+ if (!$res) {
+ $this->setError(sprintf(_('ERROR - Could Not Update Group Unix Status: %s'),db_error()));
+ db_rollback();
+ return false;
+ } else {
+ if ($status == 'A') {
+ if (!$SYS->sysCheckCreateGroup($this->getID())) {
+ $this->setError($SYS->getErrorMessage());
+ db_rollback();
+ return false;
+ }
+ } else {
+ if ($SYS->sysCheckGroup($this->getID())) {
+ if (!$SYS->sysRemoveGroup($this->getID())) {
+ $this->setError($SYS->getErrorMessage());
+ db_rollback();
+ return false;
+ }
+ }
+ }
+
+ $this->data_array['unix_status']=$status;
+ db_commit();
+ return true;
+ }
+ }
+
+ /**
+ * getUsers - Get the users of a group
+ *
+ * @return array of user's objects.
+ */
+ function getUsers() {
+ $users = Array();
+
+ $users_group_res = db_query_params ('SELECT u.user_id FROM users u, user_group ug WHERE ug.group_id=$1 AND ug.user_id=u.user_id AND u.status=$2',
+ array ($this->getID(),
+ 'A'));
+ if (!$users_group_res) {
+ $this->setError('Error: Enable to get users from group '. $this->getID() . ' ' .db_error());
+ return false;
+ }
+
+ for ($i=0; $i<db_numrows($users_group_res); $i++) {
+ $users[$i] = new GFUser(db_result($users_group_res,$i,'user_id'),false);
+ }
+
+ return $users;
+ }