• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

classes/class.ilObjGroup.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00035 //TODO: function getRoleId($groupRole) returns the object-id of grouprole
00036 
00037 require_once "class.ilObject.php";
00038 
00039 class ilObjGroup extends ilObject
00040 {
00041         var $m_grpStatus;
00042 
00043         var $m_roleMemberId;
00044 
00045         var $m_roleAdminId;
00046 
00053         function ilObjGroup($a_id = 0,$a_call_by_reference = true)
00054         {
00055                 global $tree;
00056 
00057                 $this->tree =& $tree;
00058 
00059                 $this->type = "grp";
00060                 $this->ilObject($a_id,$a_call_by_reference);
00061                 $this->setRegisterMode(true);
00062         }
00063 
00069         function join($a_user_id, $a_mem_role="")
00070         {
00071                 global $rbacadmin;
00072 
00073                 if (is_array($a_mem_role))
00074                 {
00075                         foreach ($a_mem_role as $role)
00076                         {
00077                                 $rbacadmin->assignUser($role,$a_user_id, false);
00078                         }
00079                 }
00080                 else
00081                 {
00082                         $rbacadmin->assignUser($a_mem_role,$a_user_id, false);
00083                 }
00084 
00085                 ilObjUser::updateActiveRoles($a_user_id);
00086                 return true;
00087         }
00088 
00093         function getDefaultMemberRole()
00094         {
00095                 $local_group_Roles = $this->getLocalGroupRoles();
00096 
00097                 return $local_group_Roles["il_grp_member_".$this->getRefId()];
00098         }
00099 
00104         function getDefaultAdminRole()
00105         {
00106                 $local_group_Roles = $this->getLocalGroupRoles();
00107 
00108                 return $local_group_Roles["il_grp_admin_".$this->getRefId()];
00109         }
00110 
00117         function addMember($a_user_id, $a_mem_role)
00118         {
00119                 global $rbacadmin;
00120 
00121                 if (isset($a_user_id) && isset($a_mem_role) )
00122                 {
00123                         $this->join($a_user_id,$a_mem_role);
00124                         return true;
00125                 }
00126                 else
00127                 {
00128                         $this->ilias->raiseError(get_class($this)."::addMember(): Missing parameters !",$this->ilias->error_obj->WARNING);
00129                         return false;
00130                 }
00131         }
00132 
00137         function getNewRegistrations()
00138         {
00139                 $appList = array();
00140                 $q = "SELECT * FROM grp_registration WHERE grp_id=".$this->getId();
00141                 $res = $this->ilias->db->query($q);
00142 
00143                 while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00144                 {
00145                         array_push($appList,$row);
00146                 }
00147 
00148                 return ($appList) ? $appList : false;
00149         }
00150 
00155         function deleteApplicationListEntry($a_userId)
00156         {
00157                 $q = "DELETE FROM grp_registration WHERE user_id=".$a_userId." AND grp_id=".$this->getId();
00158                 $res = $this->ilias->db->query($q);
00159         }
00160 
00167         function leaveGroup()
00168         {
00169                 global $rbacadmin, $rbacreview;
00170 
00171                 $member_ids = $this->getGroupMemberIds();
00172 
00173                 if (count($member_ids) <= 1 || !in_array($this->ilias->account->getId(), $member_ids))
00174                 {
00175                         return 2;
00176                 }
00177                 else
00178                 {
00179                         if (!$this->isAdmin($this->ilias->account->getId()))
00180                         {
00181                                 $this->leave($this->ilias->account->getId());
00182                                 $member = new ilObjUser($this->ilias->account->getId());
00183                                 $member->dropDesktopItem($this->getRefId(), "grp");
00184 
00185                                 return 0;
00186                         }
00187                         else if (count($this->getGroupAdminIds()) == 1)
00188                         {
00189                                 return 1;
00190                         }
00191                 }
00192         }
00193 
00198         function leave($a_user_id)
00199         {
00200                 global $rbacadmin;
00201 
00202                 $arr_groupRoles = $this->getMemberRoles($a_user_id);
00203 
00204                 if (is_array($arr_groupRoles))
00205                 {
00206                         foreach ($arr_groupRoles as $groupRole)
00207                         {
00208                                 $rbacadmin->deassignUser($groupRole, $a_user_id);
00209                         }
00210                 }
00211                 else
00212                 {
00213                         $rbacadmin->deassignUser($arr_groupRoles, $a_user_id);
00214                 }
00215 
00216                 ilObjUser::updateActiveRoles($a_user_id);
00217 
00218                 return true;
00219         }
00220 
00225         function removeMember($a_user_id, $a_grp_id="")
00226         {
00227                 if (isset($a_user_id) && isset($a_grp_id) && $this->isMember($a_user_id))
00228                 {
00229                         if (count($this->getGroupMemberIds()) > 1)
00230                         {
00231                                 if ($this->isAdmin($a_user_id) && count($this->getGroupAdminIds()) < 2)
00232                                 {
00233                                         return "grp_err_administrator_required";
00234                                 }
00235                                 else
00236                                 {
00237                                         $this->leave($a_user_id);
00238                                         $member = new ilObjUser($a_user_id);
00239                                         $member->dropDesktopItem($this->getRefId(), "grp");
00240 
00241                                         return "";
00242                                 }
00243                         }
00244                         else
00245                         {
00246                                 return "grp_err_last_member";
00247                         }
00248                 }
00249                 else
00250                 {
00251                         $this->ilias->raiseError(get_class($this)."::removeMember(): Missing parameters !",$this->ilias->error_obj->WARNING);
00252                 }
00253         }
00254 
00261         function getGroupMemberIds()
00262         {
00263                 global $rbacadmin, $rbacreview;
00264 
00265                 $usr_arr= array();
00266 
00267                 $rol  = $this->getLocalGroupRoles();
00268 
00269                 foreach ($rol as $value)
00270                 {
00271                         foreach ($rbacreview->assignedUsers($value) as $member_id)
00272                         {
00273                                 array_push($usr_arr,$member_id);
00274                         }
00275                 }
00276 
00277                 $mem_arr = array_unique($usr_arr);
00278                 
00279                 return $mem_arr ? $mem_arr : array();
00280         }
00281         
00289         function getGroupMemberData($a_mem_ids)
00290         {
00291                 global $rbacadmin, $rbacreview, $ilBench, $ilDB;
00292 
00293                 $usr_arr= array();
00294                 
00295                 $q = "SELECT login,firstname,lastname,title,usr_id ".
00296                          "FROM usr_data ".
00297                          "WHERE usr_id IN (".implode(',',$a_mem_ids).")";
00298                 $r = $ilDB->query($q);
00299                 
00300                 while($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
00301                 {
00302                         $mem_arr[] = array("id" => $row->usr_id,
00303                                                                 "login" => $row->login,
00304                                                                 "firstname" => $row->firstname,
00305                                                                 "lastname" => $row->lastname
00306                                                                 );
00307                 }
00308 
00309                 return $mem_arr ? $mem_arr : array();
00310         }
00311 
00312         function getCountMembers()
00313         {
00314                 return count($this->getGroupMemberIds());
00315         }
00316 
00323         function getGroupAdminIds($a_grpId="")
00324         {
00325                 global $rbacreview;
00326 
00327                 if (!empty($a_grpId))
00328                 {
00329                         $grp_id = $a_grpId;
00330                 }
00331                 else
00332                 {
00333                         $grp_id = $this->getRefId();
00334                 }
00335 
00336                 $usr_arr = array();
00337                 $roles = $this->getDefaultGroupRoles($this->getRefId());
00338 
00339                 foreach ($rbacreview->assignedUsers($this->getDefaultAdminRole()) as $member_id)
00340                 {
00341                         array_push($usr_arr,$member_id);
00342                 }
00343 
00344                 return $usr_arr;
00345         }
00346 
00352         function getDefaultGroupRoles($a_grp_id="")
00353         {
00354                 global $rbacadmin, $rbacreview;
00355 
00356                 if (strlen($a_grp_id) > 0)
00357                 {
00358                         $grp_id = $a_grp_id;
00359                 }
00360                 else
00361                 {
00362                         $grp_id = $this->getRefId();
00363                 }
00364 
00365                 $rolf      = $rbacreview->getRoleFolderOfObject($grp_id);
00366                 $role_arr  = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"]);
00367 
00368                 foreach ($role_arr as $role_id)
00369                 {
00370                         $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
00371 
00372                         $grp_Member ="il_grp_member_".$grp_id;
00373                         $grp_Admin  ="il_grp_admin_".$grp_id;
00374 
00375                         if (strcmp($role_Obj->getTitle(), $grp_Member) == 0 )
00376                         {
00377                                 $arr_grpDefaultRoles["grp_member_role"] = $role_Obj->getId();
00378                         }
00379 
00380                         if (strcmp($role_Obj->getTitle(), $grp_Admin) == 0)
00381                         {
00382                                 $arr_grpDefaultRoles["grp_admin_role"] = $role_Obj->getId();
00383                         }
00384                 }
00385 
00386                 return $arr_grpDefaultRoles;
00387         }
00388 
00395         function getLocalGroupRoles()
00396         {
00397                 global $rbacadmin,$rbacreview;
00398                 
00399                 if (empty($this->local_roles))
00400                 {
00401                         $this->local_roles = array();
00402                         $rolf      = $rbacreview->getRoleFolderOfObject($this->getRefId());
00403                         $role_arr  = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"]);
00404 
00405                         foreach ($role_arr as $role_id)
00406                         {
00407                                 if ($rbacreview->isAssignable($role_id,$rolf["ref_id"]) == true)
00408                                 {
00409                                         $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
00410                                         $this->local_roles[$role_Obj->getTitle()] = $role_Obj->getId();
00411                                 }
00412                         }
00413                 }
00414                 
00415                 return $this->local_roles;
00416         }
00417 
00423         function getGrpStatusClosedTemplateId()
00424         {
00425                 $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_closed'";
00426                 $res = $this->ilias->db->query($q);
00427                 $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
00428 
00429                 return $row["obj_id"];
00430         }
00431 
00437         function getGrpStatusOpenTemplateId()
00438         {
00439                 $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_open'";
00440                 $res = $this->ilias->db->query($q);
00441                 $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
00442 
00443                 return $row["obj_id"];
00444         }
00445         
00451         function setRegistrationFlag($a_regFlag="")
00452         {
00453                 $q = "SELECT * FROM grp_data WHERE grp_id='".$this->getId()."'";
00454                 $res = $this->ilias->db->query($q);
00455 
00456                 if (!isset($a_regFlag))
00457                 {
00458                         $a_regFlag = 0;
00459                 }
00460 
00461                 if ($res->numRows() == 0)
00462                 {
00463                         $q = "INSERT INTO grp_data (grp_id, register) VALUES(".$this->getId().",".$a_regFlag.")";
00464                         $res = $this->ilias->db->query($q);
00465                 }
00466                 else
00467                 {
00468                         $q = "UPDATE grp_data SET register=".$a_regFlag." WHERE grp_id=".$this->getId()."";
00469                         $res = $this->ilias->db->query($q);
00470                 }
00471         }
00472 
00478         function getRegistrationFlag()
00479         {
00480                 $q = "SELECT * FROM grp_data WHERE grp_id='".$this->getId()."'";
00481                 $res = $this->ilias->db->query($q);
00482                 $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
00483 
00484                 return $row["register"];
00485         }
00486 
00492         function getPassword()
00493         {
00494                 $q = "SELECT * FROM grp_data WHERE grp_id='".$this->getId()."'";
00495                 $res = $this->ilias->db->query($q);
00496                 $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
00497 
00498                 return $row["password"];
00499         }
00500         
00506         function setPassword($a_password="")
00507         {
00508                 $q = "SELECT * FROM grp_data WHERE grp_id='".$this->getId()."'";
00509                 $res = $this->ilias->db->query($q);
00510 
00511                 if ($res->numRows() == 0)
00512                 {
00513                         $q = "INSERT INTO grp_data (grp_id, password) VALUES(".$this->getId().",'".$a_password."')";
00514                         $res = $this->ilias->db->query($q);
00515                 }
00516                 else
00517                 {
00518                         $q = "UPDATE grp_data SET password='".$a_password."' WHERE grp_id=".$this->getId()."";
00519                         $res = $this->ilias->db->query($q);
00520                 }
00521         }
00522 
00528         function setExpirationDateTime($a_date)
00529         {
00530                 $q = "SELECT * FROM grp_data WHERE grp_id='".$this->getId()."'";
00531                 $res = $this->ilias->db->query($q);
00532                 $date = ilFormat::input2date($a_date);
00533 
00534                 if ($res->numRows() == 0)
00535                 {
00536                         $q = "INSERT INTO grp_data (grp_id, expiration) VALUES(".$this->getId().",'".$date."')";
00537                         $res = $this->ilias->db->query($q);
00538                 }
00539                 else
00540                 {
00541                         $q = "UPDATE grp_data SET expiration='".$date."' WHERE grp_id=".$this->getId()."";
00542                         $res = $this->ilias->db->query($q);
00543                 }
00544         }
00545 
00551         function getExpirationDateTime()
00552         {
00553                 $q = "SELECT * FROM grp_data WHERE grp_id='".$this->getId()."'";
00554                 $res = $this->ilias->db->query($q);
00555                 $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
00556                 $datetime = $row["expiration"];
00557                 $date = ilFormat::fdateDB2dateDE($datetime);
00558                 $time = substr($row["expiration"], -8);
00559                 $datetime = array(0=>$date, 1=>$time);
00560 
00561                 return $datetime;
00562         }
00563 
00564         function registrationPossible()
00565         {
00566                 $datetime = $this->getExpirationDateTime();
00567                 $today_date = ilFormat::getDateDE();
00568                 $today_time = date("H:i:s");
00569        
00570                 $ts_exp_date = ilFormat::dateDE2timestamp($datetime[0]);
00571                 $ts_today_date = ilFormat::dateDE2timestamp($today_date);
00572         
00573                 $ts_exp_time = substr($datetime[1], 0, 2).
00574                                                 substr($datetime[1], 3, 2).
00575                                                 substr($datetime[1], 6, 2);
00576                 
00577                 $ts_today_time = substr($today_time, 0, 2).
00578                                                 substr($today_time, 3, 2).
00579                                                 substr($today_time, 6, 2);
00580                 
00581                 if ($ts_today_date < $ts_exp_date) 
00582                 {
00583                         return true;
00584                 }
00585                 elseif (($ts_today_date == $ts_exp_date) and (strcmp($ts_exp_time,$ts_today_time) >= 0)) 
00586                 {
00587                         return true;
00588                 }
00589                 else 
00590                 {
00591                         return false;
00592                 }
00593         }
00594 
00613         function setGroupStatus($a_grpStatus)
00614         {
00615                 global $rbacadmin, $rbacreview, $rbacsystem;
00616 
00617                 //get Rolefolder of group
00618                 $rolf_data = $rbacreview->getRoleFolderOfObject($this->getRefId());
00619 
00620                 //define all relevant roles that rights are needed to be changed
00621                 $arr_parentRoles = $rbacreview->getParentRoleIds($this->getRefId());
00622                 $arr_relevantParentRoleIds = array_diff(array_keys($arr_parentRoles),$this->getDefaultGroupRoles());
00623 
00624                 //group status open (aka public) or group status closed
00625                 if ($a_grpStatus == 0 || $a_grpStatus == 1)
00626                 {
00627                         if ($a_grpStatus == 0)
00628                         {
00629                                 $template_id = $this->getGrpStatusOpenTemplateId();
00630                         } else {
00631                                 $template_id = $this->getGrpStatusClosedTemplateId();
00632                         }
00633                         //get defined operations from template
00634                         $template_ops = $rbacreview->getOperationsOfRole($template_id, 'grp', ROLE_FOLDER_ID);
00635 
00636                         foreach ($arr_relevantParentRoleIds as $parentRole)
00637                         {
00638                                 $granted_permissions = array();
00639 
00640                                 // Delete the linked role for the parent role
00641                                 // (just in case if it already exists).
00642                                 $rbacadmin->deleteLocalRole($parentRole,$rolf_data["child"]);
00643 
00644                                 // Grant permissions on the group object for 
00645                                 // the parent role. In the foreach loop we
00646                                 // compute the intersection of the role     
00647                                 // template il_grp_status_open/_closed and the 
00648                                 // permission template of the parent role.
00649                                 $current_ops = $rbacreview->getRoleOperationsOnObject($parentRole, $this->getRefId());
00650                                 $rbacadmin->revokePermission($this->getRefId(), $parentRole);
00651                                 foreach ($template_ops as $template_op) 
00652                                 {
00653                                         if (in_array($template_op,$current_ops)) 
00654                                         {
00655                                                 array_push($granted_permissions,$template_op);
00656                                         }
00657                                 }
00658                                 if (!empty($granted_permissions))
00659                                 {
00660                                         $rbacadmin->grantPermission($parentRole, $granted_permissions, $this->getRefId());
00661                                 }
00662 
00663                                 // Create a linked role for the parent role and
00664                                 // initialize it with the intersection of 
00665                                 // il_grp_status_open/_closed and the permission
00666                                 // template of the parent role
00667                                 $rbacadmin->copyRolePermissionIntersection(
00668                                         $template_id, ROLE_FOLDER_ID, 
00669                                         $parentRole, $arr_parentRoles[$parentRole]['parent'], 
00670                                         $rolf_data["child"], $parentRole
00671                                 );      
00672                                 $rbacadmin->assignRoleToFolder($parentRole,$rolf_data["child"],"false");
00673                         }//END foreach
00674                 }
00675         }
00676 
00682         function getGroupStatus()
00683         {
00684                 global $rbacsystem,$rbacreview;
00685 
00686                 $role_folder = $rbacreview->getRoleFolderOfObject($this->getRefId());
00687                 $local_roles = $rbacreview->getRolesOfRoleFolder($role_folder["ref_id"]);
00688 
00689                 //get Rolefolder of group
00690                 $rolf_data = $rbacreview->getRoleFolderOfObject($this->getRefId());
00691                 //get all relevant roles
00692                 $arr_globalRoles = array_diff($local_roles, $this->getDefaultGroupRoles());
00693 
00694                 //if one global role has no permission to join the group is officially closed !
00695                 foreach ($arr_globalRoles as $globalRole)
00696                 {
00697                         $ops_of_role = $rbacreview->getOperationsOfRole($globalRole,"grp", ROLE_FOLDER_ID);
00698 
00699                         if ($rbacsystem->checkPermission($this->getRefId(), $globalRole ,"join"))
00700                         {
00701                                 return 0;
00702                         }
00703                 }
00704 
00705                 return 1;
00706         }
00707 
00714         function getMemberRoles($a_user_id)
00715         {
00716                 global $rbacadmin, $rbacreview,$ilBench;
00717 
00718                 $ilBench->start("Group", "getMemberRoles");
00719 
00720                 $arr_assignedRoles = array();
00721 
00722                 $arr_assignedRoles = array_intersect($rbacreview->assignedRoles($a_user_id),$this->getLocalGroupRoles());
00723 
00724                 $ilBench->stop("Group", "getMemberRoles");
00725 
00726                 return $arr_assignedRoles;
00727         }
00728         
00735         function getMemberRolesTitle($a_user_id)
00736         {
00737                 global $ilDB,$ilBench;
00738 
00739                 $ilBench->start("Group", "getMemberRolesTitle");
00740                 
00741                 $str_member_roles ="";
00742 
00743                 $q = "SELECT title ".
00744                          "FROM object_data ".
00745                          "LEFT JOIN rbac_ua ON object_data.obj_id=rbac_ua.rol_id ".
00746                          "WHERE object_data.type = 'role' ".
00747                          "AND rbac_ua.usr_id = ".$ilDB->quote($a_user_id)." ".
00748                          "AND rbac_ua.rol_id IN (".implode(',',$this->getLocalGroupRoles()).")";
00749 
00750                 $r = $ilDB->query($q);
00751 
00752                 while($row = $r->fetchRow(DB_FETCHMODE_ASSOC))
00753                 {
00754                         $str_member_roles .= $row["title"].", ";
00755                 }
00756 
00757                 $ilBench->stop("Group", "getMemberRolesTitle");
00758                                 
00759                 return substr($str_member_roles,0,-2);
00760         }
00761         
00768         function setMemberStatus($a_user_id, $a_member_role)
00769         {
00770                 if (isset($a_user_id) && isset($a_member_role))
00771                 {
00772                         $this->removeMember($a_user_id);
00773                         $this->addMember($a_user_id, $a_member_role);
00774                 }
00775         }
00776 
00783         function isMember($a_userId = "")
00784         {
00785                 if (strlen($a_userId) == 0)
00786                 {
00787                         $user_id = $this->ilias->account->getId();
00788                 }
00789                 else 
00790                 {
00791                         $user_id = $a_userId;
00792                 }
00793                 
00794                 if ($this->getType() == "grp")
00795                 {
00796 
00797                         $arr_members = $this->getGroupMemberIds();
00798 
00799                         if (in_array($user_id, $arr_members))
00800                         {
00801                                 return true;
00802                         }
00803                         else
00804                         {
00805                                 return false;
00806                         }
00807                 }
00808         }
00809 
00816         function isAdmin($a_userId)
00817         {
00818                 global $rbacreview;
00819 
00820                 $grp_Roles = $this->getDefaultGroupRoles();
00821 
00822                 if (in_array($a_userId,$rbacreview->assignedUsers($grp_Roles["grp_admin_role"])))
00823                 {
00824                         return true;
00825                 }
00826                 else
00827                 {
00828                         return false;
00829                 }
00830         }
00831 
00840         function ilClone($a_parent_ref)
00841         {
00842                 global $rbacadmin;
00843 
00844                 // always call parent ilClone function first!!
00845                 $new_ref_id = parent::ilClone($a_parent_ref);
00846                 
00847                 // get object instance of cloned group
00848                 $groupObj =& $this->ilias->obj_factory->getInstanceByRefId($new_ref_id);
00849                 
00850                 // find a free number
00851                 for ($n = 1;$n < 99;$n++)
00852                 {
00853                         $groupname_copy = $groupObj->getTitle()."_(copy_".$n.")";
00854 
00855                         if (!ilUtil::groupNameExists($groupname_copy))
00856                         {
00857                                 $groupObj->setTitle($groupname_copy);
00858                                 $groupObj->update();
00859                                 break;
00860                         }
00861                 }
00862 
00863                 // setup rolefolder & default local roles (admin & member)
00864                 $roles = $groupObj->initDefaultRoles();
00865 
00866                 // ...finally assign groupadmin role to creator of group object
00867                 $rbacadmin->assignUser($roles[0], $groupObj->getOwner(), "n");
00868                 ilObjUser::updateActiveRoles($groupObj->getOwner());
00869 
00870                 // TODO: function getGroupStatus returns integer but setGroupStatus expects a string.
00871                 // I disabled this function. Please investigate
00872                 // shofmann@databay.de  4.7.03
00873                 // copy group status
00874                 // 0=public/visible for all,1=closed/invisible for all
00875                 $groupObj->setGroupStatus($this->getGroupStatus());
00876 
00877                 // always destroy objects in ilClone method because clone() is recursive and creates instances for each object in subtree!
00878                 unset($groupObj);
00879                 unset($rfoldObj);
00880                 unset($roleObj);
00881 
00882                 // ... and finally always return new reference ID!!
00883                 return $new_ref_id;
00884         }
00885 
00894         function delete()
00895         {
00896                 // always call parent delete function first!!
00897                 if (!parent::delete())
00898                 {
00899                         return false;
00900                 }
00901                 
00902                 $query = "DELETE FROM grp_data WHERE grp_id=".$this->getId();
00903                 $this->ilias->db->query($query);
00904 
00905                 return true;
00906         }
00907 
00913         function initDefaultRoles()
00914         {
00915                 global $rbacadmin, $rbacreview;
00916 
00917                 // create a local role folder
00918                 $rfoldObj =& $this->createRoleFolder();
00919 
00920                 // ADMIN ROLE
00921                 // create role and assign role to rolefolder...
00922                 $roleObj = $rfoldObj->createRole("il_grp_admin_".$this->getRefId(),"Groupadmin of group obj_no.".$this->getId());
00923                 $this->m_roleAdminId = $roleObj->getId();
00924 
00925                 //set permission template of new local role
00926                 $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_admin'";
00927                 $r = $this->ilias->db->getRow($q, DB_FETCHMODE_OBJECT);
00928                 $rbacadmin->copyRolePermission($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
00929 
00930                 // set object permissions of group object
00931                 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),"grp",$rfoldObj->getRefId());
00932                 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->getRefId());
00933 
00934                 // set object permissions of role folder object
00935                 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),"rolf",$rfoldObj->getRefId());
00936                 $rbacadmin->grantPermission($roleObj->getId(),$ops,$rfoldObj->getRefId());
00937 
00938                 // MEMBER ROLE
00939                 // create role and assign role to rolefolder...
00940                 $roleObj = $rfoldObj->createRole("il_grp_member_".$this->getRefId(),"Groupmember of group obj_no.".$this->getId());
00941                 $this->m_roleMemberId = $roleObj->getId();
00942 
00943                 //set permission template of new local role
00944                 $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_member'";
00945                 $r = $this->ilias->db->getRow($q, DB_FETCHMODE_OBJECT);
00946                 $rbacadmin->copyRolePermission($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
00947                 
00948                 // set object permissions of group object
00949                 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),"grp",$rfoldObj->getRefId());
00950                 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->getRefId());
00951 
00952                 // set object permissions of role folder object
00953                 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),"rolf",$rfoldObj->getRefId());
00954                 $rbacadmin->grantPermission($roleObj->getId(),$ops,$rfoldObj->getRefId());
00955 
00956                 unset($rfoldObj);
00957                 unset($roleObj);
00958 
00959                 $roles[] = $this->m_roleAdminId;
00960                 $roles[] = $this->m_roleMemberId;
00961                 return $roles ? $roles : array();
00962         }
00963 
00974         function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
00975         {
00976                 global $tree;
00977                 
00978                 $parent_id = (int) $tree->getParentId($a_node_id);
00979                 
00980                 if ($parent_id != 0)
00981                 {
00982                         $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
00983                         $obj_data->notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$parent_id,$a_params);
00984                 }
00985                                 
00986                 return true;
00987         }
00988 
00997         function _search(&$a_search_obj)
00998         {
00999                 global $ilBench;
01000 
01001                 // NO CLASS VARIABLES IN STATIC METHODS
01002 
01003                 $where_condition = $a_search_obj->getWhereCondition("like",array("title","description"));
01004                 $in = $a_search_obj->getInStatement("ore.ref_id");
01005 
01006                 $query = "SELECT ore.ref_id AS ref_id FROM object_data AS od, object_reference AS ore ".
01007                         $where_condition." ".
01008                         $in." ".
01009                         "AND od.obj_id = ore.obj_id ".
01010                         "AND od.type = 'grp' ";
01011 
01012                 $ilBench->start("Search", "ilObjGroup_search");
01013                 $res = $a_search_obj->ilias->db->query($query);
01014                 $ilBench->stop("Search", "ilObjGroup_search");
01015 
01016                 $counter = 0;
01017 
01018                 while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
01019                 {
01020                         $result_data[$counter++]["id"]                          =  $row->ref_id;
01021                         #$result_data[$counter]["link"]                         =  "group.php?cmd=view&ref_id=".$row->ref_id;
01022                         #$result_data[$counter++]["target"]                     =  "";
01023                 }
01024 
01025                 return $result_data ? $result_data : array();
01026         }
01027 
01036         function _getLinkToObject($a_id)
01037         {
01038                 return array("repository.php?ref_id=".$a_id."&set_mode=flat&cmdClass=ilobjgroupgui","");
01039         }
01040         
01041         function isUserRegistered($a_user_id = 0)
01042         {
01043                 global $rbacsystem;
01044                 
01045                 // exclude system role from check
01046                 if (in_array(SYSTEM_ROLE_ID,$_SESSION["RoleId"]))
01047                 {
01048                         return true;            
01049                 }
01050 
01051                 if (!$this->isMember() or !$rbacsystem->checkAccess("join", $this->ref_id))
01052                 {
01053                         return false;
01054                 }
01055                 
01056                 return true;
01057         }
01058 } //END class.ilObjGroup
01059 ?>

Generated on Fri Dec 13 2013 08:00:14 for ILIAS Release_3_3_x_branch .rev 46803 by  doxygen 1.7.1