51 $names = self::getAllOrguNames();
53 return array_keys($names);
59 if (self::where(array(
'ref_id' => $this->
getRefId() ))->hasSets()) {
77 public static function getTextRepresentationOfUsersOrgUnits($user_id, $separator = self::ORG_SEPARATOR, $using_tmp_table =
true)
79 if ($using_tmp_table) {
87 $res =
$ilDB->queryF(
"SELECT " .
$ilDB->groupConcat(
"path", $separator) .
" AS orgus FROM orgu_usr_assignements WHERE user_id = %s GROUP BY user_id;", array(
'integer' ), array( $user_id ));
90 return $dat->orgus ? $dat->orgus :
'-';
94 if (!$array_of_org_ids) {
99 return implode($separator,
$paths);
113 if ($sort_by_title) {
125 public static function writePathByRefId(
$ref_id)
128 $names = self::getAllOrguNames();
132 if ($ref_id == $root_ref_id || !$ref_id) {
135 while ($ref_id != $root_ref_id && $ref_id) {
136 $ref_id =
$tree->getParent($ref_id);
137 if ($ref_id != $root_ref_id && $names[$ref_id]) {
143 $first = array_shift(
$path);
144 $last = array_pop(
$path);
145 $middle = implode(self::GLUE_SIMPLE,
$path);
146 if (strlen($middle) > self::MAX_MIDDLE_PATH_LENGTH) {
147 $middle = substr($middle, 0, self::MAX_MIDDLE_PATH_LENGTH) .
" ...";
149 $expression = implode(self::GLUE_SIMPLE, [ $first, $middle, $last ]);
151 $expression = implode(self::GLUE_SIMPLE,
$path);
156 $ilOrgUnitPathStorage = self::findOrGetInstance($original_ref_id);
157 $ilOrgUnitPathStorage->setRefId($original_ref_id);
159 $ilOrgUnitPathStorage->setPath($expression);
160 $ilOrgUnitPathStorage->store();
166 public static function clearDeleted()
172 $ilDB = $DIC[
'ilDB'];
173 $ref_ids = self::getAllOrguRefIds();
174 $q =
"DELETE FROM " . self::TABLE_NAME .
" WHERE " .
$ilDB->in(
'ref_id', $ref_ids,
true,
'integer');
175 $ilDB->manipulate($q);
184 protected static function writeFullPathByRefId(
$ref_id)
187 $names = self::getAllOrguNames();
191 if ($ref_id == $root_ref_id || !$ref_id) {
194 while ($ref_id != $root_ref_id && $ref_id) {
195 $ref_id =
$tree->getParent($ref_id);
196 if ($ref_id != $root_ref_id && $names[$ref_id]) {
203 $expression = implode(self::GLUE,
$path);
207 $ilOrgUnitPathStorage = self::findOrGetInstance($original_ref_id);
208 $ilOrgUnitPathStorage->setRefId($original_ref_id);
210 $ilOrgUnitPathStorage->setPath($expression);
211 $ilOrgUnitPathStorage->store();
221 public static function getAllOrguNames($lng_key = null)
223 if (
count(self::$orgu_names) == 0) {
228 $ilDB = $DIC[
'ilDB'];
229 $res =
$ilDB->queryF(
'SELECT * FROM object_reference 230 JOIN object_data ON object_reference.obj_id = object_data.obj_id AND deleted IS NULL 231 WHERE object_data.type = %s', array(
'text' ), array(
'orgu' ));
233 self::$orgu_names[
$data->ref_id] =
$data->title;
237 return self::$orgu_names;
246 return self::TABLE_NAME;
Class ilOrgUnitPathStorage.
static _lookupObjectId($a_ref_id)
static where($where, $operator=null)
foreach($_POST as $key=> $value) $res
static getTextRepresentationOfOrgUnits($sort_by_title=true)
Get ref id path array.
getConnectorContainerName()
static getAllOrguRefIds()
static getArray($key=null, $values=null)
static orderBy($orderBy, $orderDirection='ASC')
const MAX_MIDDLE_PATH_LENGTH