/** * For a particular project: update all passwd information */ function generateProjectPasswd($project) { $passwd_file = Pluf::f('idf_plugin_syncmercurial_passwd_file'); if (!file_exists($passwd_file) or !is_writable($passwd_file)) { throw new Exception(sprintf(__('%s does not exist or is not writable.'), $passwd_file)); } $ht = new File_Passwd_Authbasic($passwd_file); $ht->setMode(Pluf::f('idf_plugin_syncmercurial_passwd_mode', FILE_PASSWD_SHA)); $ht->load(); $mem = $project->getMembershipData(); $members = array_merge((array) $mem['members'], (array) $mem['owners'], (array) $mem['authorized']); foreach ($members as $user) { if ($ht->userExists($user->login)) { $ht->changePasswd($user->login, $this->getMercurialPass($user)); } else { $ht->addUser($user->login, $this->getMercurialPass($user)); } } $ht->save(); }
/** * For a particular project: update all passwd information */ function generateProjectPasswd($project) { $passwd_file = Pluf::f('idf_plugin_syncsvn_passwd_file'); if (!file_exists($passwd_file) or !is_writable($passwd_file)) { return false; } $ht = new File_Passwd_Authbasic($passwd_file); $ht->setMode(FILE_PASSWD_SHA); $ht->load(); $mem = $project->getMembershipData(); $members = array_merge((array) $mem['members'], (array) $mem['owners'], (array) $mem['authorized']); foreach ($members as $user) { if ($ht->userExists($user->login)) { $ht->changePasswd($user->login, $this->getSvnPass($user)); } else { $ht->addUser($user->login, $this->getSvnPass($user)); } } $ht->save(); }