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) {
126 public static function writePathByRefId(
$ref_id)
129 $names = self::getAllOrguNames();
133 if ($ref_id == $root_ref_id || !$ref_id) {
136 while ($ref_id != $root_ref_id && $ref_id) {
137 $ref_id = $tree->getParent($ref_id);
138 if ($ref_id != $root_ref_id && $names[$ref_id]) {
144 $first = array_shift(
$path);
145 $last = array_pop(
$path);
146 $middle = implode(self::GLUE_SIMPLE,
$path);
147 if (strlen($middle) > self::MAX_MIDDLE_PATH_LENGTH) {
148 $middle = substr($middle, 0, self::MAX_MIDDLE_PATH_LENGTH) .
" ...";
150 $expression = implode(self::GLUE_SIMPLE, [$first, $middle, $last]);
152 $expression = implode(self::GLUE_SIMPLE,
$path);
157 $ilOrgUnitPathStorage = self::findOrGetInstance($original_ref_id);
158 $ilOrgUnitPathStorage->setRefId($original_ref_id);
160 $ilOrgUnitPathStorage->setPath($expression);
161 $ilOrgUnitPathStorage->store();
167 public static function clearDeleted()
173 $ilDB = $DIC[
'ilDB'];
174 $ref_ids = self::getAllOrguRefIds();
175 $q =
"DELETE FROM " . self::TABLE_NAME .
" WHERE " .
$ilDB->in(
'ref_id', $ref_ids,
true,
'integer');
176 $ilDB->manipulate($q);
186 protected static function writeFullPathByRefId(
$ref_id)
189 $names = self::getAllOrguNames();
193 if ($ref_id == $root_ref_id || !$ref_id) {
196 while ($ref_id != $root_ref_id && $ref_id) {
197 $ref_id = $tree->getParent($ref_id);
198 if ($ref_id != $root_ref_id && $names[$ref_id]) {
205 $expression = implode(self::GLUE,
$path);
209 $ilOrgUnitPathStorage = self::findOrGetInstance($original_ref_id);
210 $ilOrgUnitPathStorage->setRefId($original_ref_id);
212 $ilOrgUnitPathStorage->setPath($expression);
213 $ilOrgUnitPathStorage->store();
224 public static function getAllOrguNames($lng_key = null)
226 if (
count(self::$orgu_names) == 0) {
231 $ilDB = $DIC[
'ilDB'];
232 $res =
$ilDB->queryF(
'SELECT * FROM object_reference 233 JOIN object_data ON object_reference.obj_id = object_data.obj_id AND deleted IS NULL 234 WHERE object_data.type = %s', array(
'text'), array(
'orgu'));
236 self::$orgu_names[
$data->ref_id] =
$data->title;
240 return self::$orgu_names;
249 return self::TABLE_NAME;
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