public function update_repo_conf_column($repo_id, $access_level = false)
 {
     $repo_table_name = TABLE_PREFIX . 'rt_gitolite_repomaster';
     $public_key_table_name = TABLE_PREFIX . 'rt_gitolite_user_public_keys';
     if ($access_level == false) {
         $access_level_row = get_access_levels($repo_id);
         if ($access_level_row && isset($access_level_row["permissions"])) {
             $access_level = unserialize($access_level_row["permissions"]);
         }
     }
     $repo_conf_str = "";
     $access_array = array(GITOLITE_READACCESS => 'R', GITOLITE_MANAGEACCESS => 'RW+');
     $rep_row = DB::executeFirstRow("SELECT * FROM " . $repo_table_name . " where repo_id = " . $repo_id . " limit 1");
     if ($rep_row) {
         if (!array_key_exists('gitolite_config', $rep_row)) {
             mysql_query("ALTER TABLE {$repo_table_name} ADD column `gitolite_config` text NULL");
         }
         $repo_conf_str = "";
         //repo " .  $row['repo_name'] . "\n";
         if (!is_array($access_level) && $access_level != "") {
             $access_level = unserialize($access_level);
         }
         $prjobj = new Project($rep_row['project_id']);
         $prjusers = $prjobj->users()->getIds();
         if (is_array($prjusers)) {
             $str = "";
             $sep = "";
             foreach ($access_level as $user => $permission) {
                 $str .= $sep . $user;
                 $sep = ",";
             }
             $sql = "select user_id,pub_file_name  from  {$public_key_table_name} where  is_deleted = '0' and user_id in ({$str}) order by user_id;";
             $key_result = DB::execute($sql);
             if ($key_result) {
                 foreach ($key_result as $my_key_row) {
                     $access = isset($access_array[$access_level[$my_key_row["user_id"]]]) ? $access_array[$access_level[$my_key_row["user_id"]]] : false;
                     if ($access) {
                         $repo_conf_str .= "\t" . $access . "\t=\t" . $my_key_row["pub_file_name"] . "\n";
                     }
                 }
             }
             $sql = "update " . $repo_table_name . " set gitolite_config='" . $repo_conf_str . "' where repo_id =" . $repo_id;
             DB::execute($sql);
         }
     }
     return true;
 }
示例#2
0
 function BodyScope(&$lexer)
 {
     global $KEY_TO_TABLE_TYPE;
     $dummy = NULL;
     $this->descendants = array();
     parent::Scope($lexer, $dummy);
     if (strlen($lexer->post) > 0) {
         // parent::Scope swallows all tags, leaving only (possibly) some trailing text
         $this->addChild(new PlainText($lexer, $this));
     }
     $this->global_vars = array();
     foreach ($KEY_TO_TABLE_TYPE as $key => $table_type) {
         // e.g. 'res_id' => RESOURCE
         if (array_key_exists($key, $_REQUEST)) {
             $this->global_vars["{$table_type}-ID"] = $_REQUEST[$key];
         }
     }
     $this->global_vars['this-url'] = preg_replace('/&chop&.*/', '', $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING']);
     $this->global_vars['ref-url'] = preg_replace('/&chop&.*/', '', @$_SERVER['HTTP_REFERER']);
     if (get_user_id()) {
         $this->global_vars["logged-in-user-id"] = get_user_id();
         $this->global_vars["logged-in-user-name"] = get_user_name();
         $this->global_vars["logged-in-user-username"] = get_user_username();
         $access = get_user_access();
         if ($access) {
             $this->global_vars["logged-in-user-access"] = get_user_access();
             //$this->global_vars["logged-in-is-administrator"] = is_administrator();
             //$this->global_vars["logged-in-is-editor"] = is_editor();
             $levels = get_access_levels();
             foreach ($levels as $accesslevel => $enabled) {
                 $this->global_vars["logged-in-is-" . $accesslevel] = $enabled;
             }
         }
     }
 }