示例#1
0
 public function edit_directory()
 {
     $ldapPlugin = $this->getLdapPlugin();
     $ldapUserGroupManager = new LDAP_UserGroupManager($ldapPlugin->getLdap());
     $ldapUserGroupManager->setGroupName($this->request->get('bind_with_group'));
     $ldapUserGroupManager->setId($this->ugroup->getId());
     $btn_update = $GLOBALS['Language']->getText('plugin_ldap', 'ugroup_edit_btn_update');
     $btn_unlink = $GLOBALS['Language']->getText('plugin_ldap', 'ugroup_edit_btn_unlink');
     $vSubmit = new Valid_WhiteList('submit', array($btn_update, $btn_unlink));
     $vSubmit->required();
     if ($this->request->isPost() && $this->request->valid($vSubmit)) {
         if ($this->request->get('submit') == $btn_unlink) {
             $this->unlinkLDAPGroup($ldapUserGroupManager);
         } else {
             $this->linkLDAPGroup($ldapUserGroupManager);
         }
     } else {
         $this->edit_directory_group();
     }
 }
示例#2
0
} else {
    exit_error($Language->getText('global', 'error'), $Language->getText('project_admin_editugroup', 'ug_not_found'));
}
// Do not try to modify ugroups of project 100
$res = ugroup_db_get_ugroup($ugroupId);
if ($res && !db_error($res) && db_numrows($res) == 1) {
    $row = db_fetch_array($res);
    session_require(array('group' => $row['group_id'], 'admin_flags' => 'A'));
    if ($row['group_id'] == 100) {
        exit_error($Language->getText('global', 'error'), "Cannot modify this ugroup with LDAP plugin");
    }
} else {
    exit_error($Language->getText('global', 'error'), $Language->getText('project_admin_editugroup', 'ug_not_found', array($ugroupId, db_error())));
}
$group_id = $row['group_id'];
$ldapUserGroupManager = new LDAP_UserGroupManager($ldapPlugin->getLdap());
$ldapUserGroupManager->setId($ugroupId);
$hp = Codendi_HTMLPurifier::instance();
$btn_update = $Language->getText('plugin_ldap', 'ugroup_edit_btn_update');
$vSubmit = new Valid_WhiteList('submit', array($btn_update));
$vSubmit->required();
if ($request->isPost() && $request->valid($vSubmit)) {
    if ($request->get('submit') == $btn_update) {
        $vUserAdd = new Valid_String('user_add');
        $vUserAdd->required();
        if ($request->valid($vUserAdd)) {
            $ldapUserGroupManager->addListOfUsersToGroup($request->get('user_add'));
        }
    }
}
//
示例#3
0
 /**
  * Hook
  *
  * @param Array $params
  *
  * @return void
  */
 function codendi_daily_start($params)
 {
     if ($GLOBALS['sys_auth_type'] == 'ldap' && $this->isDailySyncEnabled()) {
         $ldapQuery = new LDAP_DirectorySynchronization($this->getLdap(), $this->getLogger());
         $ldapQuery->syncAll();
         $retentionPeriod = $this->getLdap()->getLDAPParam('daily_sync_retention_period');
         if ($retentionPeriod != NULL && $retentionPeriod != "") {
             $ldapCleanUpManager = new LDAP_CleanUpManager($retentionPeriod);
             $ldapCleanUpManager->cleanAll();
         }
         //Synchronize the ugroups with the ldap ones
         $ldapUserGroupManager = new LDAP_UserGroupManager($this->getLdap());
         $ldapUserGroupManager->synchronizeUgroups();
         return true;
     }
 }
示例#4
0
 /**
  * Hook in upgroup edition
  * $params['row'] A row from ugroup table
  *
  * @param Array $params
  */
 function ugroup_table_row($params)
 {
     if ($GLOBALS['sys_auth_type'] == 'ldap' && $this->isLDAPGroupsUsageEnabled()) {
         // No ldap for project 100
         if ($params['row']['group_id'] == 100) {
             $params['html_array'][150] = array('value' => '-', 'html_attrs' => 'align="center"');
         } else {
             $hp = Codendi_HTMLPurifier::instance();
             $ldapUserGroupManager = new LDAP_UserGroupManager($this->getLdap());
             $baseUrl = $this->getPluginPath() . '/ugroup_edit.php?ugroup_id=' . $params['row']['ugroup_id'];
             $urlAdd = $this->getPluginPath() . '/ugroup_add_user.php?ugroup_id=' . $params['row']['ugroup_id'] . '&func=add_user';
             $linkAdd = '<a href="' . $urlAdd . '">- ' . $GLOBALS['Language']->getText('plugin_ldap', 'ugroup_list_add_users') . '</a>';
             $ldapGroup = $ldapUserGroupManager->getLdapGroupByGroupId($params['row']['ugroup_id']);
             if ($ldapGroup !== null) {
                 $grpName = $hp->purify($ldapGroup->getCommonName());
                 $title = $GLOBALS['Language']->getText('plugin_ldap', 'ugroup_list_add_upd_binding', $grpName);
             } else {
                 $title = $GLOBALS['Language']->getText('plugin_ldap', 'ugroup_list_add_set_binding');
             }
             $urlBind = $this->getPluginPath() . '/ugroup_edit.php?ugroup_id=' . $params['row']['ugroup_id'] . '&func=bind_with_group';
             $linkBind = '<a href="' . $urlBind . '">- ' . $title . '</a>';
             $link = $linkAdd . '<br/>' . $linkBind;
             $params['html_array'][150] = array('value' => $link, 'html_attrs' => 'align="center"');
         }
     }
 }
示例#5
0
 /**
  * Create the good title link if we have already a ldap group linked or not
  *
  * @return String
  */
 private function getLDAPTitle()
 {
     $hp = Codendi_HTMLPurifier::instance();
     $ldapUserGroupManager = new LDAP_UserGroupManager($this->ldap_plugin->getLdap());
     $ldapGroup = $ldapUserGroupManager->getLdapGroupByGroupId($this->ugroup->getId());
     if ($ldapGroup !== null) {
         $grpName = $hp->purify($ldapGroup->getCommonName());
         $title = $GLOBALS['Language']->getText('plugin_ldap', 'ugroup_list_add_upd_binding', $grpName);
     } else {
         $title = $GLOBALS['Language']->getText('plugin_ldap', 'ugroup_list_add_set_binding');
     }
     return $title;
 }
示例#6
0
if ($res && !db_error($res) && db_numrows($res) == 1) {
    $row = db_fetch_array($res);
    session_require(array('group' => $row['group_id'], 'admin_flags' => 'A'));
    if ($row['group_id'] == 100) {
        exit_error($Language->getText('global', 'error'), "Cannot modify this ugroup with LDAP plugin");
    }
} else {
    exit_error($Language->getText('global', 'error'), $Language->getText('project_admin_editugroup', 'ug_not_found', array($ugroupId, db_error())));
}
$group_id = $row['group_id'];
$vFunc = new Valid_String('func', array('bind_with_group'));
$vFunc->required();
if (!$request->valid($vFunc)) {
    $GLOBALS['Response']->redirect('/project/admin/ugroup.php?group_id=' . $group_id);
}
$ldapUserGroupManager = new LDAP_UserGroupManager($ldapPlugin->getLdap());
$ldapUserGroupManager->setGroupName($request->get('bind_with_group'));
$ldapUserGroupManager->setId($ugroupId);
// Check if user have choosen the preserve members option.
$bindOption = LDAP_GroupManager::BIND_OPTION;
if ($request->exist('preserve_members') && $request->get('preserve_members') == 'on') {
    $bindOption = LDAP_GroupManager::PRESERVE_MEMBERS_OPTION;
}
// Check if user has checked the Synchronization option.
$synchro = LDAP_GroupManager::NO_SYNCHRONIZATION;
if ($request->existAndNonEmpty('synchronize')) {
    $synchro = LDAP_GroupManager::AUTO_SYNCHRONIZATION;
}
$hp = Codendi_HTMLPurifier::instance();
$btn_update = $Language->getText('plugin_ldap', 'ugroup_edit_btn_update');
$btn_unlink = $Language->getText('plugin_ldap', 'ugroup_edit_btn_unlink');
示例#7
0
if ($res && !db_error($res) && db_numrows($res) == 1) {
    $row = db_fetch_array($res);
    session_require(array('group' => $row['group_id'], 'admin_flags' => 'A'));
    if ($row['group_id'] == 100) {
        exit_error($Language->getText('global', 'error'), "Cannot modify this ugroup with LDAP plugin");
    }
} else {
    exit_error($Language->getText('global', 'error'), $Language->getText('project_admin_editugroup', 'ug_not_found', array($ugroupId, db_error())));
}
$group_id = $row['group_id'];
$vFunc = new Valid_String('func', array('bind_with_group'));
$vFunc->required();
if (!$request->valid($vFunc)) {
    $GLOBALS['Response']->redirect('/project/admin/ugroup.php?group_id=' . $group_id);
}
$ldapUserGroupManager = new LDAP_UserGroupManager($ldapPlugin->getLdap());
$ldapUserGroupManager->setGroupName($request->get('bind_with_group'));
$ldapUserGroupManager->setId($ugroupId);
// Check if user have choosen the preserve members option.
$bindOption = 'bind';
if ($request->exist('preserve_members') && $request->get('preserve_members') == 'on') {
    $bindOption = 'preserve_members';
}
$hp = Codendi_HTMLPurifier::instance();
$btn_update = $Language->getText('plugin_ldap', 'ugroup_edit_btn_update');
$btn_unlink = $Language->getText('plugin_ldap', 'ugroup_edit_btn_unlink');
$vSubmit = new Valid_WhiteList('submit', array($btn_update, $btn_unlink));
$vSubmit->required();
if ($request->isPost() && $request->valid($vSubmit)) {
    if ($request->get('submit') == $btn_unlink) {
        if ($ldapUserGroupManager->unbindFromBindLdap()) {
示例#8
0
 /**
  * Hook
  *
  * @param Array $params
  *
  * @return void
  */
 function codendi_daily_start($params)
 {
     if ($GLOBALS['sys_auth_type'] == 'ldap' && $this->isDailySyncEnabled()) {
         $ldapQuery = new LDAP_DirectorySynchronization($this->getLdap());
         $ldapQuery->syncAll();
         //Synchronize the ugroups with the ldap ones
         $ldapUserGroupManager = new LDAP_UserGroupManager($this->getLdap());
         $ldapUserGroupManager->synchronizeUgroups();
         return true;
     }
 }